public override void Process(Player player, Game game) { int newX = RTSTools.GetX(player.X, Direction); int newY = RTSTools.GetY(player.Y, Direction); // is space off map if (!game.Map.CheckLimits(newX, newY)) { return; } // Is space collision free Tile tile = game.Map.Tiles[newY][newX]; if (tile.IsSolid) { return; } if (tile.Player != null) { if (tile.Player is Bullet) //TODO put something here { return; } } Move(player, tile); }
public override void Process(Game game) { if (Timer++ < Constants.BulletSpeedLimit) { return; } Timer = 0; int newX = RTSTools.GetX(X, Direction); int newY = RTSTools.GetY(Y, Direction); // is space off map if (!game.Map.CheckLimits(newX, newY)) { Collided = true; return; } // Is space collision free Tile tile = game.Map.Tiles[newY][newX]; if (tile.IsSolid) { Collided = true; } if (tile.Player != null) { Shooter.Kills++; game.Messages.Add(String.Format("{0} fragged {1}", Shooter.Name, tile.Player.Name)); tile.Player.IsKilled = true; } Move(this, tile); }
public override void Process(Player player, Game game) { Bullet bullet = new Bullet(); bullet.Shooter = player; bullet.Direction = Direction; bullet.X = RTSTools.GetX(player.X, Direction); bullet.Y = RTSTools.GetY(player.Y, Direction); Tile tile = game.Map.TryGetTile(bullet.X, bullet.Y); if (tile == null) { return; } if (tile.IsSolid) { return; } //TODO might need to handle multple bullets being in the same place if (Constants.Debug) { Console.WriteLine("{0} fired {1}", player.Name, Direction); } bullet.Tile = tile; tile.Bullet = bullet; game.BulletList.Add(bullet); }