Exemplo n.º 1
0
        public void Shoot(Unit unit, ShootAction action)
        {
            Shot shot = new Shot();
            shot.Direction = action.Direction;
            shot.X = Tools.GetX(unit.X, action.Direction);
            shot.Y = Tools.GetY(unit.Y, action.Direction);

            Tile tile = Data.Map.Tiles[shot.Y][shot.X];
            if (tile.IsWall) return;

            shot.Tile = tile;
            tile.Shot = shot;
            ShotList.Add(shot);
        }
Exemplo n.º 2
0
        public void MoveShot(Shot shot, Tile tile)
        {
            shot.Tile.Shot = null;

            shot.X = tile.X;
            shot.Y = tile.Y;

            tile.Shot = shot;
            shot.Tile = tile;
        }
Exemplo n.º 3
0
        public void MoveTheShot(Shot shot)
        {
            int newX = Tools.GetX(shot.X, shot.Direction);
            int newY = Tools.GetY(shot.Y, shot.Direction);

            // is space off map
            if (newX < 0 || newX >= Data.Map.MapWidth) { shot.Collided = true; return; } //fail
            if (newY < 0 || newY >= Data.Map.MapLength) { shot.Collided = true; return; } //fail

            // Is space collision free
            Tile tile = Data.Map.Tiles[newY][newX];
            if (tile.IsWall) { shot.Collided = true; return; } //fail

            MoveShot(shot, tile);
        }
Exemplo n.º 4
0
 public void KillShot(Shot shot)
 {
     shot.Tile.Shot = null;
     shot.Tile = null;
     ShotList.Remove(shot);
 }