public void StartRound(MatchUpRules matchUpRules) { if (!tournamentStarted) { tournamentStarted = true; } bool evenPlayerCount = (CountRemainingPlayers() % 2 == 0); TournamentMemberCollection membersWaitList = registeredMembers.Clone() as TournamentMemberCollection; // Remove inactive players from wait list for (int i = membersWaitList.Count - 1; i >= 0; i--) { if (membersWaitList[i].Active == false) { membersWaitList.RemoveAt(i); } } if (!evenPlayerCount) { int skipIndex = MathFunctions.Rand(0, membersWaitList.Count); membersWaitList.RemoveAt(skipIndex); } this.activeMatchups.Clear(); // Continue making match-ups until all players have been accounted for while (membersWaitList.Count > 0) { int playerOneIndex = MathFunctions.Rand(0, membersWaitList.Count); TournamentMember playerOne = membersWaitList[playerOneIndex]; membersWaitList.RemoveAt(playerOneIndex); int playerTwoIndex = MathFunctions.Rand(0, membersWaitList.Count); TournamentMember playerTwo = membersWaitList[playerTwoIndex]; membersWaitList.RemoveAt(playerTwoIndex); MatchUp matchUp = new MatchUp(GenerateUniqueMatchUpID(), this, playerOne, playerTwo); matchUp.Rules = matchUpRules; this.activeMatchups.Add(matchUp); int combatMapIndex = MathFunctions.Rand(0, combatMaps.Count); InstancedMap iMap = MapCloner.CreateInstancedMap(MapManager.RetrieveMap(combatMaps[combatMapIndex])); matchUp.StartMatchUp(iMap); } }
public void StartGame(Client client) { if (client == GameLeader) { InstancedMap map = new InstancedMap(MapManager.GenerateMapID("i")); IMap originalMap = MapManager.RetrieveMap(1945); map.MapBase = 1945; map.Moral = Enums.MapMoral.Safe; MapCloner.CloneMapTileProperties(originalMap, map); MapCloner.CloneMapTiles(originalMap, map); ArenaMap = map; bool swapSides = false; foreach (Client playerClient in BlueTeam) { Messenger.PlayerMsg(playerClient, "You are on the Blue Team", Text.Yellow); int x; int y; if (swapSides) { x = BLUEX2; y = BLUEY2; } else { x = BLUEX1; y = BLUEY1; } swapSides = !swapSides; RemoveSnowballs(playerClient); playerClient.Player.GiveItem(446, 999); Messenger.PlayerMsg(playerClient, "You were given 999 snowballs! Use them well!", Text.BrightBlue); playerClient.Player.Status = PLAYERLIVES + " Lives";; Messenger.SendPlayerData(playerClient); Messenger.PlayerWarp(playerClient, map, x, y); } swapSides = false; foreach (Client playerClient in GreenTeam) { Messenger.PlayerMsg(playerClient, "You are on the Green Team", Text.Yellow); int x; int y; if (swapSides) { x = GREENX2; y = GREENY2; } else { x = GREENX1; y = GREENY1; } swapSides = !swapSides; RemoveSnowballs(playerClient); playerClient.Player.GiveItem(446, 999); Messenger.PlayerMsg(playerClient, "You were given 999 snowballs! Use them well!", Text.BrightGreen); playerClient.Player.Status = PLAYERLIVES + " Lives";; Messenger.SendPlayerData(playerClient); Messenger.PlayerWarp(playerClient, map, x, y); } } }
public static void SaveInstancedMap(DatabaseConnection dbConnection, string mapID, InstancedMap map) { for (int i = 0; i < Constants.MAX_MAP_NPCS; i++) { map.ActiveNpc[i].Save(); } MapDataManager.SaveInstancedMap(dbConnection.Database, mapID, map.baseMap); }
public static InstancedMap LoadInstancedMap(DatabaseConnection dbConnection, string mapID) { DataManager.Maps.InstancedMap loadedMap = MapDataManager.LoadInstancedMap(dbConnection.Database, mapID); InstancedMap map = new InstancedMap(loadedMap); return map; }