Skip to content

Commit e91e2eb

Browse files
committed
refactoring boosts
1 parent c8e69bf commit e91e2eb

File tree

96 files changed

+92
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+92
-257
lines changed

Assets/Scripts/BackgroundSetter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Collections;
2-
using System.Collections.Generic;
31
using System.Linq;
42
using UnityEngine;
53
using UnityEngine.UI;

Assets/Scripts/Board/BoardSolver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
public class BoardSolver
55
{
6-
private BoostExicuter _boostExicuter;
6+
private IBoostExicuter _boostExicuter;
77
private SequenceSolver _sequenceSolver;
88
private ISwapSolwer _regularSwapSolver;
99
private ISwapSolwer _boostSwapSolver;
1010

1111
public event UnityAction CountedSwapMaked;
1212

13-
public BoardSolver(Workers workers, ItemSwaper itemSwaper, BoostExicuter boostExicuter)
13+
public BoardSolver(Workers workers, ItemSwaper itemSwaper, IBoostExicuter boostExicuter)
1414
{
1515
_boostExicuter = boostExicuter;
1616
_sequenceSolver = new(workers);

Assets/Scripts/Board/BoostSwapSolver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
public class BoostSwapSolver : ISwapSolwer
55
{
6-
private BoostExicuter _boostExicuter;
6+
private IBoostExicuter _boostExicuter;
77
private UnityAction _swapCallback;
88

9-
public BoostSwapSolver(BoostExicuter boostExicuter, UnityAction swapCallback)
9+
public BoostSwapSolver(IBoostExicuter boostExicuter, UnityAction swapCallback)
1010
{
1111
_boostExicuter = boostExicuter;
1212
_swapCallback = swapCallback;

Assets/Scripts/Board/DiagonalBoardFaller.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using Cysharp.Threading.Tasks;
2-
using System.Collections.Generic;
3-
using UnityEngine;
42

53
public class DiagonalBoardFaller : IBoardFaller
64
{

Assets/Scripts/Board/ISwapSolwer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Cysharp.Threading.Tasks;
2-
using UnityEngine.Events;
32

43
public interface ISwapSolwer
54
{

Assets/Scripts/Board/MidleCellFinder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using UnityEngine;
43

54
public class MidleCellFinder

Assets/Scripts/Boost/BombBoostAction.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ public class BombBoostAction : IBoostAction
88
private const float BombRadius = 2f;
99
private Board _board;
1010
private ItemNextStateMover _itemRemover;
11-
private BoostExicuter _boostExicuter;
11+
private IBoostExicuter _boostExicuter;
1212
private BoardClearer _boardClearer;
1313

14-
public BombBoostAction(Board board, ItemNextStateMover itemRemover, BoostExicuter boostExicuter)
14+
public BombBoostAction(Board board, IBoostExicuter boostExicuter)
1515
{
1616
_board = board;
17-
_itemRemover = itemRemover;
17+
_itemRemover = new();
1818
_boostExicuter = boostExicuter;
1919
_boardClearer = new(board);
2020
}

Assets/Scripts/Boost/BoostExicuter.cs

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
using Cysharp.Threading.Tasks;
22

33

4+
public interface IBoostExicuter
5+
{
6+
UniTask Execute(IBoostItem boostItem);
7+
UniTask Execute(IItem item, ToolTypes toolTypes);
8+
}
9+
410

5-
public class BoostExicuter
11+
public class BoostExicuter : IBoostExicuter
612
{
713
private IBoostAction _horisontal;
814
private IBoostAction _vertical;
@@ -13,44 +19,46 @@ public class BoostExicuter
1319

1420
private BoardClearer _boardClearer;
1521

16-
public BoostExicuter(ItemNextStateMover itemRemover, Board board, GoalCellOnBoardFinder goalItemFinder)
22+
public BoostExicuter(Board board, GoalCellOnBoardFinder goalItemFinder)
1723
{
18-
_horisontal = new HorizontalLineRemover(board, itemRemover, this);
19-
_vertical = new VerticalLineRemover(board, itemRemover, this);
20-
_bomb = new BombBoostAction(board, itemRemover, this);
21-
_rainbow = new RainbowBoostAction(board, itemRemover, this);
22-
_rocket = new RocketBoostAction(board, goalItemFinder, itemRemover, this);
23-
_xlines = new XLineRemover(board, itemRemover, this);
24+
_horisontal = new HorizontalLineRemover(board, this);
25+
_vertical = new VerticalLineRemover(board, this);
26+
_bomb = new BombBoostAction(board, this);
27+
_rainbow = new RainbowBoostAction(board, this);
28+
_rocket = new RocketBoostAction(board, goalItemFinder, this);
29+
_xlines = new XLineRemover(board, this);
2430

2531
_boardClearer = new(board);
2632
}
2733

28-
public async UniTask Execute(IItem item)
34+
public async UniTask Execute(IBoostItem boostItem)
2935
{
30-
if (item is IBoostItem boostItem)
36+
if (boostItem.IsUsed == true)
37+
{
38+
return;
39+
}
40+
41+
boostItem.IsUsed = true;
42+
43+
switch (boostItem.GetBoostType())
3144
{
32-
switch (boostItem.GetBoostType())
33-
{
34-
case BoostTypes.None:
35-
break;
36-
case BoostTypes.Bomb:
37-
await _bomb.Execute(boostItem);
38-
break;
39-
case BoostTypes.Horizontal:
40-
await _horisontal.Execute(boostItem);
41-
break;
42-
case BoostTypes.Vertical:
43-
await _vertical.Execute(boostItem);
44-
break;
45-
case BoostTypes.Rainbow:
46-
await _rainbow.Execute(boostItem);
47-
break;
48-
case BoostTypes.Rocket:
49-
await _rocket.Execute(boostItem);
50-
break;
51-
default:
52-
break;
53-
}
45+
case BoostTypes.None:
46+
break;
47+
case BoostTypes.Bomb:
48+
await _bomb.Execute(boostItem);
49+
break;
50+
case BoostTypes.Horizontal:
51+
await _horisontal.Execute(boostItem);
52+
break;
53+
case BoostTypes.Vertical:
54+
await _vertical.Execute(boostItem);
55+
break;
56+
case BoostTypes.Rainbow:
57+
await _rainbow.Execute(boostItem);
58+
break;
59+
case BoostTypes.Rocket:
60+
await _rocket.Execute(boostItem);
61+
break;
5462
}
5563

5664
_boardClearer.ClearBordFromDeadItems();

Assets/Scripts/Boost/BoostInjector.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using UnityEngine;
22
using Zenject;
3-
using Cysharp.Threading.Tasks;
43

54

65
public class BoostInjector : MonoBehaviour

Assets/Scripts/Boost/BoostItem.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ public class BoostItem : Item, IBoostItem
44
{
55
private BoostTypes _type;
66

7-
public IItem SwapWith { get; set; }
7+
public bool IsUsed { get; set; }
88

99
public event UnityAction<BoostTypes> SetedType;
1010

1111
public event UnityAction<BoostTypes> LeavedBoostState;
1212

13-
public void SetBoostType(BoostTypes value)
13+
public void Init(BoostTypes value)
1414
{
15+
IsUsed = false;
1516
_type = value;
1617
SetedType?.Invoke(value);
1718
}
19+
20+
1821
public BoostTypes GetBoostType() => _type;
1922

2023
protected override void OnStateChanged(ItemStateTypes old, ItemStateTypes @new)

0 commit comments

Comments
 (0)