Skip to content

Commit

Permalink
refactoring boosts
Browse files Browse the repository at this point in the history
  • Loading branch information
UnityLV committed May 20, 2023
1 parent c8e69bf commit e91e2eb
Show file tree
Hide file tree
Showing 96 changed files with 92 additions and 257 deletions.
2 changes: 0 additions & 2 deletions Assets/Scripts/BackgroundSetter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Board/BoardSolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

public class BoardSolver
{
private BoostExicuter _boostExicuter;
private IBoostExicuter _boostExicuter;
private SequenceSolver _sequenceSolver;
private ISwapSolwer _regularSwapSolver;
private ISwapSolwer _boostSwapSolver;

public event UnityAction CountedSwapMaked;

public BoardSolver(Workers workers, ItemSwaper itemSwaper, BoostExicuter boostExicuter)
public BoardSolver(Workers workers, ItemSwaper itemSwaper, IBoostExicuter boostExicuter)
{
_boostExicuter = boostExicuter;
_sequenceSolver = new(workers);
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Board/BoostSwapSolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

public class BoostSwapSolver : ISwapSolwer
{
private BoostExicuter _boostExicuter;
private IBoostExicuter _boostExicuter;
private UnityAction _swapCallback;

public BoostSwapSolver(BoostExicuter boostExicuter, UnityAction swapCallback)
public BoostSwapSolver(IBoostExicuter boostExicuter, UnityAction swapCallback)
{
_boostExicuter = boostExicuter;
_swapCallback = swapCallback;
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Board/DiagonalBoardFaller.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Cysharp.Threading.Tasks;
using System.Collections.Generic;
using UnityEngine;

public class DiagonalBoardFaller : IBoardFaller
{
Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/Board/ISwapSolwer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Cysharp.Threading.Tasks;
using UnityEngine.Events;

public interface ISwapSolwer
{
Expand Down
3 changes: 1 addition & 2 deletions Assets/Scripts/Board/MidleCellFinder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;

public class MidleCellFinder
Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/Boost/BombBoostAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public class BombBoostAction : IBoostAction
private const float BombRadius = 2f;
private Board _board;
private ItemNextStateMover _itemRemover;
private BoostExicuter _boostExicuter;
private IBoostExicuter _boostExicuter;
private BoardClearer _boardClearer;

public BombBoostAction(Board board, ItemNextStateMover itemRemover, BoostExicuter boostExicuter)
public BombBoostAction(Board board, IBoostExicuter boostExicuter)
{
_board = board;
_itemRemover = itemRemover;
_itemRemover = new();
_boostExicuter = boostExicuter;
_boardClearer = new(board);
}
Expand Down
72 changes: 40 additions & 32 deletions Assets/Scripts/Boost/BoostExicuter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
using Cysharp.Threading.Tasks;


public interface IBoostExicuter
{
UniTask Execute(IBoostItem boostItem);
UniTask Execute(IItem item, ToolTypes toolTypes);
}


public class BoostExicuter
public class BoostExicuter : IBoostExicuter
{
private IBoostAction _horisontal;
private IBoostAction _vertical;
Expand All @@ -13,44 +19,46 @@ public class BoostExicuter

private BoardClearer _boardClearer;

public BoostExicuter(ItemNextStateMover itemRemover, Board board, GoalCellOnBoardFinder goalItemFinder)
public BoostExicuter(Board board, GoalCellOnBoardFinder goalItemFinder)
{
_horisontal = new HorizontalLineRemover(board, itemRemover, this);
_vertical = new VerticalLineRemover(board, itemRemover, this);
_bomb = new BombBoostAction(board, itemRemover, this);
_rainbow = new RainbowBoostAction(board, itemRemover, this);
_rocket = new RocketBoostAction(board, goalItemFinder, itemRemover, this);
_xlines = new XLineRemover(board, itemRemover, this);
_horisontal = new HorizontalLineRemover(board, this);
_vertical = new VerticalLineRemover(board, this);
_bomb = new BombBoostAction(board, this);
_rainbow = new RainbowBoostAction(board, this);
_rocket = new RocketBoostAction(board, goalItemFinder, this);
_xlines = new XLineRemover(board, this);

_boardClearer = new(board);
}

public async UniTask Execute(IItem item)
public async UniTask Execute(IBoostItem boostItem)
{
if (item is IBoostItem boostItem)
if (boostItem.IsUsed == true)
{
return;
}

boostItem.IsUsed = true;

switch (boostItem.GetBoostType())
{
switch (boostItem.GetBoostType())
{
case BoostTypes.None:
break;
case BoostTypes.Bomb:
await _bomb.Execute(boostItem);
break;
case BoostTypes.Horizontal:
await _horisontal.Execute(boostItem);
break;
case BoostTypes.Vertical:
await _vertical.Execute(boostItem);
break;
case BoostTypes.Rainbow:
await _rainbow.Execute(boostItem);
break;
case BoostTypes.Rocket:
await _rocket.Execute(boostItem);
break;
default:
break;
}
case BoostTypes.None:
break;
case BoostTypes.Bomb:
await _bomb.Execute(boostItem);
break;
case BoostTypes.Horizontal:
await _horisontal.Execute(boostItem);
break;
case BoostTypes.Vertical:
await _vertical.Execute(boostItem);
break;
case BoostTypes.Rainbow:
await _rainbow.Execute(boostItem);
break;
case BoostTypes.Rocket:
await _rocket.Execute(boostItem);
break;
}

_boardClearer.ClearBordFromDeadItems();
Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/Boost/BoostInjector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using UnityEngine;
using Zenject;
using Cysharp.Threading.Tasks;


public class BoostInjector : MonoBehaviour
Expand Down
7 changes: 5 additions & 2 deletions Assets/Scripts/Boost/BoostItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ public class BoostItem : Item, IBoostItem
{
private BoostTypes _type;

public IItem SwapWith { get; set; }
public bool IsUsed { get; set; }

public event UnityAction<BoostTypes> SetedType;

public event UnityAction<BoostTypes> LeavedBoostState;

public void SetBoostType(BoostTypes value)
public void Init(BoostTypes value)
{
IsUsed = false;
_type = value;
SetedType?.Invoke(value);
}


public BoostTypes GetBoostType() => _type;

protected override void OnStateChanged(ItemStateTypes old, ItemStateTypes @new)
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Boost/BoostLineRemoverBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public abstract class BoostLineRemoverBase : IBoostAction
private ItemNextStateMover _itemNextStateMover;
private BoardClearer _boardClearer;

protected BoostLineRemoverBase(Board board, ItemNextStateMover itemRemover)
protected BoostLineRemoverBase(Board board)
{
_board = board;
_itemNextStateMover = itemRemover;
_itemNextStateMover = new();
_boardClearer = new(board);
}

Expand Down
3 changes: 0 additions & 3 deletions Assets/Scripts/Boost/BoostSelector.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.Events;
using System;

public class BoostSelector : MonoBehaviour
{
Expand Down
7 changes: 3 additions & 4 deletions Assets/Scripts/Boost/RainbowBoostAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ public class RainbowBoostAction : IBoostAction
{
private Board _board;
private ItemNextStateMover _itemRemover;
private BoostExicuter _boostExicuter;
private IBoostExicuter _boostExicuter;
private BoardClearer _boardClearer;

public RainbowBoostAction(Board board, ItemNextStateMover itemRemover, BoostExicuter boostExicuter)
public RainbowBoostAction(Board board, IBoostExicuter boostExicuter)
{
_board = board;
_itemRemover = itemRemover;
_itemRemover = new();
_boostExicuter = boostExicuter;
_boardClearer = new(board);

}

public async UniTask Execute(IItem item)
Expand Down
7 changes: 4 additions & 3 deletions Assets/Scripts/Boost/RocketBoostAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ public class RocketBoostAction : IBoostAction
private Board _board;
private GoalCellOnBoardFinder _goalItemFinder;
private ItemNextStateMover _itemRemover;
private BoostExicuter _boostExicuter;
private IBoostExicuter _boostExicuter;
private BoardClearer _boardClearer;
private NeighbourRemover _neighbourRemover;

private ICell _executedOnCell;


public RocketBoostAction(Board board,
GoalCellOnBoardFinder goalItemFinder,
ItemNextStateMover itemRemover, BoostExicuter boostExicuter)
IBoostExicuter boostExicuter)
{
_goalItemFinder = goalItemFinder;
_itemRemover = itemRemover;
_itemRemover = new();
_boostExicuter = boostExicuter;
_board = board;
_boardClearer = new(board);
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Boost/XLineRemover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

public class XLineRemover : BoostLineRemoverBase
{
private BoostExicuter _boostExicuter;
private IBoostExicuter _boostExicuter;

public XLineRemover(Board board, ItemNextStateMover itemRemover, BoostExicuter boostExicuter) : base(board, itemRemover)
public XLineRemover(Board board, IBoostExicuter boostExicuter) : base(board)
{
Directons = new GridPosition[] { GridPosition.Left, GridPosition.Right, GridPosition.Up, GridPosition.Down };
_boostExicuter = boostExicuter;
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/CameraPositioner.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Zenject;

Expand Down
3 changes: 1 addition & 2 deletions Assets/Scripts/Cell/Cell.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using UnityEngine;
using UnityEngine;

public class Cell : MonoBehaviour, ICell
{
Expand Down
4 changes: 1 addition & 3 deletions Assets/Scripts/CellSelector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Cysharp.Threading.Tasks;
using System;
using UnityEngine;
using UnityEngine;
using UnityEngine.Events;

public class CellSelector
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/BackToMainMenu.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BackToMainMenu : MonoBehaviour
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/Bank/BankDefault.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Assets.Scripts.Code.Bank
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/Bank/Coins.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/Bank/Hearts.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;

namespace Assets.Scripts.Code.Bank
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/Bank/Stars.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/Camera/CameraStopZone.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraStopZone : MonoBehaviour
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/Camera/CameraZone.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraZone : MonoBehaviour
Expand Down
3 changes: 0 additions & 3 deletions Assets/Scripts/Code/Cells/CellProfile.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.UI;

public delegate void SwitchProfileCell(CellProfile cell);
Expand Down
3 changes: 0 additions & 3 deletions Assets/Scripts/Code/Cells/CellsProfileController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CellsProfileController : MonoBehaviour
{
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/DynamicMessage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/History.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/Player/PlayerBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

Expand Down
1 change: 0 additions & 1 deletion Assets/Scripts/Code/Player/PlayerNotificationPlay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
Expand Down
2 changes: 0 additions & 2 deletions Assets/Scripts/Code/Player/PseudorandomPoints.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PseudorandomPoints : MonoBehaviour
Expand Down
4 changes: 0 additions & 4 deletions Assets/Scripts/Code/ProfilePanel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Assets.Scripts.Code.UI;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class ProfilePanel : MonoBehaviour
{
Expand Down
Loading

0 comments on commit e91e2eb

Please sign in to comment.