示例#1
0
    private GameObject[,] CloneArray(GameObject[,] _array)
    {
        var _arrayClone = new GameObject[_board.BoardSize, _board.BoardSize];

        _arrayClone = (GameObject[, ])_array.Clone();
        return(_arrayClone);
    }
示例#2
0
 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);
 }
示例#3
0
    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);
    }
示例#4
0
    //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);
    }
示例#5
0
    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);
    }
示例#6
0
 public GameObject[,] CloneGameObjects() => gameObjects.Clone() as GameObject[, ];
示例#7
0
 /// <summary>
 /// Grabs all fog tiles for mapping purposes
 /// </summary>
 /// <returns></returns>
 public GameObject[,] getFogTiles()
 {
     GameObject[,] returnBoard = (GameObject[, ])fogTiles.Clone();
     return(returnBoard);
 }