public void StartGame() { if (!this.GameStarted) { this.WiningBlink = -1; this.GameStarted = true; this.RoomBattleBallGameField = new RoomBattleBallGameField(new GameTeam[this.Room.RoomGamemapManager.Model.MaxY, this.Room.RoomGamemapManager.Model.MaxX]); this.GreenScore = 0; this.BlueScore = 0; this.YellowScore = 0; this.RedScore = 0; this.UpdateScore(GameTeam.Green); this.UpdateScore(GameTeam.Blue); this.UpdateScore(GameTeam.Yellow); this.UpdateScore(GameTeam.Red); foreach (RoomItem item in this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemBattleBanzaiPatch))) { item.ExtraData = "1"; item.UpdateState(false, true); } } }
public void StopGame() { if (this.GameStarted) { this.GameStarted = false; this.RoomBattleBallGameField = null; foreach (RoomItem item in this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemBattleBanzaiPatch))) { if (item.ExtraData == "1") { item.ExtraData = "0"; item.UpdateState(true, true); } } //team, team score Dictionary <int, int> scores = new Dictionary <int, int>(); scores.Add((int)GameTeam.Blue, this.BlueScore); scores.Add((int)GameTeam.Green, this.GreenScore); scores.Add((int)GameTeam.Yellow, this.YellowScore); scores.Add((int)GameTeam.Red, this.RedScore); scores = scores.OrderByDescending(d => d.Value).ToDictionary(d => d.Key, d => d.Value); this.WiningTeamTiles.Clear(); KeyValuePair <int, int> bestScore = scores.ElementAt(0); List <int> winingTeams = new List <int>(); foreach (KeyValuePair <int, int> data in scores.OrderByDescending(d => d.Value)) { if (bestScore.Value == data.Value) //wining team or tie :o { this.WiningTeamTiles.Add((int)data.Key, new List <RoomItemBattleBanzaiPatch>()); winingTeams.Add((int)data.Key); } } foreach (RoomUnitUser user in this.Room.RoomUserManager.GetRealUsers()) { if (user.GameType == GameType.BattleBanzai) { if (winingTeams.Contains((int)user.GameTeam)) { this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.Wave, new ValueHolder("VirtualID", user.VirtualID))); } } } foreach (RoomItemBattleBanzaiPatch tile in this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemBattleBanzaiPatch))) { if (tile.ExtraData == "5") { if (winingTeams.Contains((int)GameTeam.Red)) { this.WiningTeamTiles[(int)GameTeam.Red].Add(tile); } } else if (tile.ExtraData == "8") { if (winingTeams.Contains((int)GameTeam.Green)) { this.WiningTeamTiles[(int)GameTeam.Green].Add(tile); } } else if (tile.ExtraData == "11") { if (winingTeams.Contains((int)GameTeam.Blue)) { this.WiningTeamTiles[(int)GameTeam.Blue].Add(tile); } } else if (tile.ExtraData == "14") { if (winingTeams.Contains((int)GameTeam.Yellow)) { this.WiningTeamTiles[(int)GameTeam.Yellow].Add(tile); } } } this.WiningBlink = 0; } }