private GameObject[,] CloneArray(GameObject[,] _array) { var _arrayClone = new GameObject[_board.BoardSize, _board.BoardSize]; _arrayClone = (GameObject[, ])_array.Clone(); return(_arrayClone); }
public Simulator(GameObject[,] pcs, List<GameObject> mvdPawns, Player current, Player other) { pieces = (GameObject[,]) pcs.Clone(); movedPawns = new List<GameObject>(mvdPawns); currentPlayer = new Player(current); otherPlayer = new Player(other); }
List <Vector2Int> DFS(int x, int y) { GameObject[,] copyofcopy = copy.Clone() as GameObject[, ]; List <Vector2Int> CheckList = new List <Vector2Int>(); string name = unit[x, y].name; Queue <Vector2Int> queue = new Queue <Vector2Int>(); queue.Enqueue(new Vector2Int(x, y)); CheckList.Add(new Vector2Int(x, y)); copyofcopy[x, y] = null; while (queue.Count != 0) { Vector2Int vec = queue.Dequeue(); if (vec.x + 1 < 12 && copyofcopy[vec.x + 1, vec.y] != null) { if (name == copyofcopy[vec.x + 1, vec.y].name) { queue.Enqueue(new Vector2Int(vec.x + 1, vec.y)); CheckList.Add(new Vector2Int(vec.x + 1, vec.y)); copyofcopy[vec.x + 1, vec.y] = null; } } if (vec.x - 1 > 0 && copyofcopy[vec.x - 1, vec.y] != null) { if (name == copyofcopy[vec.x - 1, vec.y].name) { queue.Enqueue(new Vector2Int(vec.x - 1, vec.y)); CheckList.Add(new Vector2Int(vec.x - 1, vec.y)); copyofcopy[vec.x - 1, vec.y] = null; } } if (vec.y + 1 < 20 && copyofcopy[vec.x, vec.y + 1] != null) { if (name == copyofcopy[vec.x, vec.y + 1].name) { queue.Enqueue(new Vector2Int(vec.x, vec.y + 1)); CheckList.Add(new Vector2Int(vec.x, vec.y + 1)); copyofcopy[vec.x, vec.y + 1] = null; } } if (vec.y - 1 > 0 && copyofcopy[vec.x, vec.y - 1] != null) { if (name == copyofcopy[vec.x, vec.y - 1].name) { queue.Enqueue(new Vector2Int(vec.x, vec.y - 1)); CheckList.Add(new Vector2Int(vec.x, vec.y - 1)); copyofcopy[vec.x, vec.y - 1] = null; } } } return(CheckList); }
//Returns the child state after the specified move is attempted public State GetChild(List <Vector2Int> move) { State child = new State((GameObject[, ])board.Clone(), turn, skipTurn, healthLost, thisZombie, false, new List <Vector2Int>(enemyLocs), playerLoc); //Clones the current state for (int i = 0; i < move.Count; i++) { child.makeMove(move[i], i); } //Set the child state's last move and flip its turn child.lastMove = move; child.turn = -child.turn; if (Enemy.skipEveryOtherTurn && turn == 1) { skipTurn = !skipTurn; } return(child); }
public bool Rotate(bool isToRight = true) { GameObject[,] rotateMap = cubesMap.Clone() as GameObject[, ]; for (int i = cubes.Count - 1; i >= 0; i--) { grid.Remove(cubes[i], true); } int y = -1; for (y = rotateMap.GetLength(0) - 1; y >= 0; y--) { for (int x = rotateMap.GetLength(1) - 1; x >= 0; x--) { int rx = isToRight ? Math.Abs(y - rotateMap.GetLength(0) + 1) : y, ry = isToRight ? x : Math.Abs(x - rotateMap.GetLength(1) + 1); GameObject current = cubesMap[y, x]; rotateMap[ry, rx] = current; if (current && !grid.Add(current, new Vector2Int(rx, ry) + axisCords, true)) { goto multiBreak; } } } multiBreak: if (y > -1) { for (y = cubesMap.GetLength(0) - 1; y >= 0; y--) { for (int x = cubesMap.GetLength(1) - 1; x >= 0; x--) { if (cubesMap[y, x]) { grid.Add(cubesMap[y, x], new Vector2Int(axisCords.x + x, axisCords.y + y), true); } } } return(false); } cubesMap = rotateMap; return(true); }
public GameObject[,] CloneGameObjects() => gameObjects.Clone() as GameObject[, ];
/// <summary> /// Grabs all fog tiles for mapping purposes /// </summary> /// <returns></returns> public GameObject[,] getFogTiles() { GameObject[,] returnBoard = (GameObject[, ])fogTiles.Clone(); return(returnBoard); }