示例#1
0
 internal static Vector2 RandomPositionOnMap()
 {
     return(MapTile.RandomPositionInTile(Utilities.randomInt(0, Program.Objects.Map.GridDimension), Utilities.randomInt(0, Program.Objects.Map.GridDimension)));
 }
示例#2
0
 private void shiftTile(MapTile tile, int destX, int destY)
 {
     tile.shiftTo(destX, destY);
 }
示例#3
0
 internal void tileFinishedShifting(MapTile finishedTile)
 {
     _shiftedOutTile.WasKilled();
     _shiftedOutTile = null;
     _isShifting     = false;
 }
示例#4
0
        //shift the row/col of tiles
        private void shiftTiles(int index, ShiftDirection dir, DoorDirections newTileDoors)
        {
            if (_isShifting)
            {
                //should never happen with the queueing now in place, but still check it to be safe
                return;
            }

            //check if the index is valid
            if (index < 0 || index >= _gridDimension)
            {
                throw new Exception("Invalid grid index passed to shiftTiles()");
            }

            //set current shift direction
            _currShiftDir   = dir;
            _currShiftIndex = index;

            Program.Objects.MainCamera.shake();

            //spawn extra enemies
            Program.Objects.EnemyDirector.OnShift();

            bool isPositiveShift = (dir == ShiftDirection.RIGHT || dir == ShiftDirection.DOWN);

            int shiftStart = isPositiveShift ? _gridDimension - 1 : 0;
            int shiftEnd   = isPositiveShift ? 0 : _gridDimension - 1;
            int shiftInc   = isPositiveShift ? -1 : 1;

            if (dir == ShiftDirection.LEFT || dir == ShiftDirection.RIGHT)
            {
                //Set all the tiles to start moving
                for (int x = 0; x < _gridDimension; x++)
                {
                    shiftTile(x, index, x - shiftInc, index);
                }

                //store the tile that is getting shifted out
                _shiftedOutTile = _tiles[shiftStart, index];

                //shift the tiles in our array to represent the new arrangement
                for (int x = shiftStart; x != shiftEnd; x += shiftInc)
                {
                    _tiles[x, index] = _tiles[x + shiftInc, index];
                }

                //set the location of the tile that was pushed in a move it into place
                //TODO: don't reassign this. pass it in.
                MapTile pushingTile = new MapTile(MapTile.WorldPositionForGridCoordinates(shiftEnd + shiftInc, index), newTileDoors, false);
                _tiles[shiftEnd, index] = pushingTile;
                shiftTile(pushingTile, shiftEnd, index);
            }
            else   //UP or DOWN
                   //Set all the tiles to start moving
            {
                for (int y = 0; y < _gridDimension; y++)
                {
                    shiftTile(index, y, index, y - shiftInc);
                }

                //store the tile that is getting shifted out
                _shiftedOutTile = _tiles[index, shiftStart];

                //shift the tiles in our array to represent the new arrangement
                for (int y = shiftStart; y != shiftEnd; y += shiftInc)
                {
                    _tiles[index, y] = _tiles[index, y + shiftInc];
                }

                //set the location of the tile that was pushed in a move it into place
                //TODO: don't reassign this. pass it in.
                MapTile pushingTile = new MapTile(MapTile.WorldPositionForGridCoordinates(index, shiftEnd + shiftInc), newTileDoors, false);
                _tiles[index, shiftEnd] = pushingTile;
                shiftTile(pushingTile, index, shiftEnd);
            }

            _shiftedOutTile.flagForDestruction(tileFinishedShifting);

            //update the overlays
            UpdateOverlays();

            _isShifting = true;
        }
示例#5
0
 internal static Vector2 RandomPositionInTile(int x, int y)
 {
     return(MapTile.WorldPositionForGridCoordinates(x, y) + Utilities.randomVector() * 0.7f * MapTile.TileSideLength);
 }
示例#6
0
 internal void shiftTo(int destX, int destY)
 {
     //go
     setTarget(MapTile.WorldPositionForGridCoordinates(destX, destY));
 }