// An evil player wants to plant a bomb private void GameServer_BombPlacing(Client sender) { if (GameServer.Instance.GameManager.GameHasBegun) { var player = sender.Player; if (player.CurrentBombAmount > 0) { var bo = GameServer.Instance.GameManager.BombList.Find(b => b.CellPosition == player.CellPosition); if (bo != null) return; var bomb = new Bomb(player.Id, player.CellPosition, player.BombPower, player.BombTimer, player.Speed); bomb.Initialize(GameServer.Instance.GameManager.CurrentMap.Size, GameServer.Instance.GameManager.CurrentMap.CollisionLayer, GameServer.Instance.GameManager.HazardMap); GameServer.Instance.GameManager.CurrentMap.Board[bomb.CellPosition.X, bomb.CellPosition.Y] = bomb; GameServer.Instance.GameManager.CurrentMap.CollisionLayer[bomb.CellPosition.X, bomb.CellPosition.Y] = true; GameServer.Instance.GameManager.AddBomb(bomb); player.CurrentBombAmount--; GameServer.Instance.SendPlayerPlacingBomb(sender, bomb.CellPosition); } } }
// Send to all players that a bomb has blown up public void SendBombExploded(Bomb bomb) { NetOutgoingMessage message = _server.CreateMessage(); message.Write((byte)MessageType.ServerMessage.BombExploded); message.Write(bomb.CellPosition); _server.SendToAll(message, NetDeliveryMethod.ReliableOrdered); Program.Log.Info("[SEND] Sent that bomb exploded to everyone ! (position: " + bomb.Position + ")"); }
private void Bomb_IsExploded(Bomb bomb) { /* //_gameManager.CurrentMap.CalcBombExplosion(bomb); GameServer.Instance.SendBombExploded(bomb); bomb.Position.Bombed = null; //Kollar om bomben exploderar en annan bomb if (GameSettings.BombsExplodeBombs) { foreach (Explosion ex in bomb.Explosion) { foreach (Bomb b in GameManager.BombList) { if (b.Position == ex.Position) { if (b.Exploded == false) b.Explode(); } } } } */ }
private void RemoveBomb(Bomb bomb) { _bombList.Remove(bomb); base.RemoveBomb(bomb); Program.Log.Info("Bomb at " + bomb.CellPosition + " has been removed."); }
public void AddBomb(Bomb bomb) { _bombList.Add(bomb); base.AddBomb(bomb); }