public void Choose(GameBoardEntityDirection direction) { if (movingSum > 0) { GameBoardManager manager = GetComponentInParent <GameBoardManager>(); GameBoardPlayer player = GetComponentInParent <GameBoardPlayer>(); movingSum = manager.TryMove(player.GetComponent <GameBoardEntity>(), movingSum, direction); if (movingSum <= 0) { manager.AmbiguousDirectionSolvedEvent.Invoke(); Destroy(this.gameObject); } else { GetComponentInParent <GameBoardManager>()?.AmbiguousDirectionEvent?.Invoke(); } } else { GetComponentInParent <GameBoardManager>()?.AmbiguousDirectionSolvedEvent.Invoke(); Destroy(this.gameObject); } }
public static GameBoardEntityDirection Left(this GameBoardEntityDirection dir) { switch (dir) { case GameBoardEntityDirection.NORTH: return(GameBoardEntityDirection.WEST); case GameBoardEntityDirection.SOUTH: return(GameBoardEntityDirection.EAST); case GameBoardEntityDirection.EAST: return(GameBoardEntityDirection.NORTH); case GameBoardEntityDirection.WEST: return(GameBoardEntityDirection.SOUTH); default: return(GameBoardEntityDirection.SOUTH); } }
public static Vector3Int NextTile(this Vector3Int coordinates, GameBoardEntityDirection dir) { switch (dir) { case GameBoardEntityDirection.NORTH: return(new Vector3Int(coordinates.x, coordinates.y, coordinates.z + 1)); case GameBoardEntityDirection.SOUTH: return(new Vector3Int(coordinates.x, coordinates.y, coordinates.z - 1)); case GameBoardEntityDirection.EAST: return(new Vector3Int(coordinates.x + 1, coordinates.y, coordinates.z)); case GameBoardEntityDirection.WEST: return(new Vector3Int(coordinates.x - 1, coordinates.y, coordinates.z)); default: return(coordinates); } }