Esempio n. 1
0
        private void CreateWallPiece(
            List <GameObject> createdWallPieces,
            GameObject verticalEdgePiece,
            List <GameObject> piecesCache)
        {
            Vector3 spawnPosition = new Vector3(
                verticalEdgePiece.transform.position.x,
                verticalEdgePiece.transform.position.y + (ArenaGridPiece.transform.localScale.y * 2),
                verticalEdgePiece.transform.position.z
                );

            GameObject createdWallPiece = Instantiate(ArenaWallPiece,
                                                      spawnPosition,
                                                      ArenaWallPiece.transform.rotation,
                                                      gameObject.transform);

            WallHandler handler = createdWallPiece.GetComponentInChildren <WallHandler>();

            int x = verticalEdgePiece.GetComponentInChildren <ArenaGridPiece>().CoordinateX;
            int y = verticalEdgePiece.GetComponentInChildren <ArenaGridPiece>().CoordinateY;

            handler.CoordinateX = x;
            handler.CoordinateY = y;
            handler.WallType    = ArenaUtilities.GetWallType(x, y, piecesCache);
            handler.WallState   = Utilities.WallState.Created;

            createdWallPieces.Add(createdWallPiece);
        }
Esempio n. 2
0
        private void CreateArenaWalls(List <GameObject> arenaGridPieces)
        {
            List <GameObject> createdWallPieces = new List <GameObject>();

            foreach (var horizontalEdgePiece in ArenaUtilities.GetHorizontalEdges(arenaGridPieces))
            {
                CreateWallPiece(createdWallPieces, horizontalEdgePiece, arenaGridPieces);
            }

            foreach (var verticalEdgePiece in ArenaUtilities.GetVerticalEdges(arenaGridPieces))
            {
                CreateWallPiece(createdWallPieces, verticalEdgePiece, arenaGridPieces);
            }
            arenaManager.ArenaWallPiecesCache = createdWallPieces;
        }
Esempio n. 3
0
 private void RemoveUnnecessaryHorizontalPieces(int coordY, bool removeDownSide,
                                                List <GameObject> arenaPiecesCache, List <GameObject> wallPiecesCache)
 {
     foreach (var gridPiece in ArenaUtilities.FindPiecesOutsideOfHorizontalLane(
                  coordY, removeDownSide, arenaPiecesCache))
     {
         Destroy(gridPiece);
         arenaPiecesCache.Remove(gridPiece);
     }
     foreach (var wallToDestroy in ArenaUtilities.FindWallPiecesOutsideOfHorizontalLane(coordY,
                                                                                        removeDownSide, wallPiecesCache))
     {
         Destroy(wallToDestroy);
         wallPiecesCache.Remove(wallToDestroy);
     }
 }
Esempio n. 4
0
 private void RemoveUnnecessaryVerticalPieces(int coordX, bool removeLeftSide,
                                              List <GameObject> arenaPiecesCache, List <GameObject> wallPiecesCache)
 {
     foreach (var pieceToDestroy in ArenaUtilities.FindPiecesOutsideOfVerticalLane(coordX,
                                                                                   removeLeftSide, arenaPiecesCache))
     {
         Destroy(pieceToDestroy);
         arenaPiecesCache.Remove(pieceToDestroy);
     }
     foreach (var wallToDestroy in ArenaUtilities.FindWallPiecesOutsideOfVerticalLane(coordX,
                                                                                      removeLeftSide, wallPiecesCache))
     {
         Destroy(wallToDestroy);
         wallPiecesCache.Remove(wallToDestroy);
     }
 }
Esempio n. 5
0
        public void RemovePiecesVertical(int coordX, int coordY, bool removeLeftSide,
                                         List <GameObject> arenaPiecesCache, List <GameObject> wallPiecesCache)
        {
            List <GameObject> piecesToBeCreated      = ArenaUtilities.FindVerticalLane(coordX, coordY, arenaPiecesCache);
            List <GameObject> piecesTopOfClick       = piecesToBeCreated.Where(p => p.GetComponentInChildren <ArenaGridPiece>().CoordinateY > coordY).ToList();
            List <GameObject> pieceClickedAndUnderIt = piecesToBeCreated.Except(piecesTopOfClick)
                                                       .Reverse()
                                                       .ToList();

            if (piecesTopOfClick.Count > pieceClickedAndUnderIt.Count)
            {
                StartCoroutine(CreateVerticalWallPieces(piecesTopOfClick, removeLeftSide, coordX, true, arenaPiecesCache, wallPiecesCache));
                StartCoroutine(CreateVerticalWallPieces(pieceClickedAndUnderIt, removeLeftSide, coordX, false, arenaPiecesCache, wallPiecesCache));
            }
            else
            {
                StartCoroutine(CreateVerticalWallPieces(piecesTopOfClick, removeLeftSide, coordX, false, arenaPiecesCache, wallPiecesCache));
                StartCoroutine(CreateVerticalWallPieces(pieceClickedAndUnderIt, removeLeftSide, coordX, true, arenaPiecesCache, wallPiecesCache));
            }
        }
Esempio n. 6
0
        public void RemovePiecesHorizontal(int coordX, int coordY, bool removeDownSide,
                                           List <GameObject> arenaPiecesCache, List <GameObject> wallPiecesCache)
        {
            List <GameObject> piecesToBeCreated    = ArenaUtilities.FindHorizontalLane(coordX, coordY, arenaPiecesCache);
            List <GameObject> piecesLeft           = piecesToBeCreated.Where(p => p.GetComponentInChildren <ArenaGridPiece>().CoordinateX < coordX).Reverse().ToList();
            List <GameObject> pieceClickedAndRight = piecesToBeCreated.Except(piecesLeft).ToList();

            if (piecesLeft.Count > pieceClickedAndRight.Count)
            {
                StartCoroutine(CreateHorizontalWallPieces(piecesLeft, removeDownSide, coordY, true,
                                                          arenaPiecesCache, wallPiecesCache));
                StartCoroutine(CreateHorizontalWallPieces(pieceClickedAndRight, removeDownSide, coordY,
                                                          false, arenaPiecesCache, wallPiecesCache));
            }
            else
            {
                StartCoroutine(CreateHorizontalWallPieces(piecesLeft, removeDownSide, coordY, false,
                                                          arenaPiecesCache, wallPiecesCache));
                StartCoroutine(CreateHorizontalWallPieces(pieceClickedAndRight, removeDownSide, coordY,
                                                          true, arenaPiecesCache, wallPiecesCache));
            }
        }