public bool StartGame() { //Reset Flags arena.flagReset(); flagSpawn(); gameState = GameState.ActiveGame; flagMode = CTFMode.None; ResetKiller(null); killStreaks.Clear(); foreach (Player p in arena.Players) { PlayerStreak temp = new PlayerStreak(); temp.lastKillerCount = 0; temp.lastUsedWeap = null; temp.lastUsedWepKillCount = 0; temp.lastUsedWepTick = -1; killStreaks.Add(p._alias, temp); } //Let everyone know arena.sendArenaMessage("Game has started!", CFG.flag.resetBong); return(true); }
/// <summary> /// Did someone win yet? If so, set the announcement /// </summary> private void CheckWinner(int now) { //See if someone is winning if (winningTeam != null) { //Has XSeconds been called yet? if (flagMode == CTFMode.XSeconds) { return; } int tick = ((winningTeamTick - now) / 1000); switch (tick) { case 10: flagMode = CTFMode.TenSeconds; break; case 30: flagMode = CTFMode.ThirtySeconds; break; case 60: flagMode = CTFMode.SixtySeconds; break; default: if (tick <= 0) { flagMode = CTFMode.GameDone; } break; } } }
private void OnFlagChange(Arena.FlagState flag) { Team victory = flag.team; //Does this team now have all the flags? foreach (Arena.FlagState fs in arena._flags.Values) { if (fs.bActive && fs.team != flag.team) { //Not all flags are captured yet victory = null; break; } } if (!gameWon) { //All flags captured? if (victory != null) { //Yep winningTeamTick = (Environment.TickCount + (victoryHoldTime * 10)); winningTeamNotify = 0; winningTeam = victory; flagMode = CTFMode.XSeconds; } else { //Aborted? if (winningTeam != null) { //Yep winningTeam = null; winningTeamTick = 0; flagMode = CTFMode.Aborted; } } } }
/// <summary> /// Poll the flag state while checking for a winner /// </summary> private void PollCTF(int now) { //See if we have enough players to keep playing if (arena.PlayersIngame.Count() < minPlayers) { Reset(); } else { CheckWinner(now); } int countdown = winningTeamTick > 0 ? ((winningTeamTick - now) / 1000) : 0; switch (flagMode) { case CTFMode.Aborted: arena.setTicker(4, 1, 0, ""); arena.sendArenaMessage("Victory has been aborted.", CFG.flag.victoryAbortedBong); flagMode = CTFMode.None; break; case CTFMode.TenSeconds: //10 second win timer if (winningTeamNotify == 1) //Been notified already? { break; } winningTeamNotify = 1; arena.sendArenaMessage(string.Format("Victory for {0} in {1} seconds!", winningTeam._name, countdown), CFG.flag.victoryWarningBong); flagMode = CTFMode.None; break; case CTFMode.ThirtySeconds: //30 second win timer if (winningTeamNotify == 2) //Been notified already? { break; } winningTeamNotify = 2; arena.sendArenaMessage(string.Format("Victory for {0} in {1} seconds!", winningTeam._name, countdown), CFG.flag.victoryWarningBong); flagMode = CTFMode.None; break; case CTFMode.SixtySeconds: //60 second win timer if (winningTeamNotify == 3) //Been notified already? { break; } winningTeamNotify = 3; arena.sendArenaMessage(string.Format("Victory for {0} in {1} seconds!", winningTeam._name, countdown), CFG.flag.victoryWarningBong); flagMode = CTFMode.None; break; case CTFMode.XSeconds: //Initial win timer upon capturing SetNotifyBypass(countdown); //Checks to see if xSeconds matches any other timers arena.setTicker(4, 1, CFG.flag.victoryHoldTime, "Victory in "); arena.sendArenaMessage(string.Format("Victory for {0} in {1} seconds!", winningTeam._name, countdown), CFG.flag.victoryWarningBong); flagMode = CTFMode.None; break; case CTFMode.GameDone: //Game is done gameWon = true; arena.gameEnd(); break; } UpdateCTFTickers(); UpdateKillStreaks(); }