Ejemplo n.º 1
0
        void StartRound(List <Player> players)
        {
            TimeSpan duration = Map.Config.RoundTime;

            Map.Message("This round will last for &a" + duration.Shorten(true, true));
            RoundEnd = DateTime.UtcNow.Add(duration);

            Player[] online = PlayerInfo.Online.Items;
            foreach (Player p in online)
            {
                if (p.level != Map || p.Game.Referee)
                {
                    continue;
                }
                Alive.Add(p);
            }
            Infected.Clear();

            Random rnd   = new Random();
            Player first = null;

            do
            {
                first = QueuedZombie != null?PlayerInfo.FindExact(QueuedZombie) : players[rnd.Next(players.Count)];

                QueuedZombie = null;
            } while (first == null || first.level != Map);

            Map.Message("&c" + first.DisplayName + " &Sstarted the infection!");
            InfectPlayer(first, null);
        }
Ejemplo n.º 2
0
        public void ResetState()
        {
            Status          = ZombieGameStatus.NotStarted;
            MaxRounds       = 0;
            RoundInProgress = false;
            RoundStart      = DateTime.MinValue;
            RoundEnd        = DateTime.MinValue;
            Player[] online = PlayerInfo.Online.Items;

            Alive.Clear();
            Infected.Clear();

            Lottery.Clear();
            Bounties.Clear();
            RecentMaps.Clear();

            foreach (Player pl in online)
            {
                pl.Game.Referee  = false;
                pl.Game.RatedMap = false;
                pl.Game.ResetZombieState();
                ResetInvisibility(pl);
                pl.SetPrefix();

                if (pl.level == null || !pl.level.name.CaselessEq(CurLevelName))
                {
                    continue;
                }
                HUD.Reset(pl);
            }

            LastLevelName = "";
            CurLevelName  = "";
            CurLevel      = null;
        }
Ejemplo n.º 3
0
        void DoRound()
        {
            if (!Running)
            {
                return;
            }
            List <Player> players = DoRoundCountdown();

            if (players == null)
            {
                return;
            }
            RoundInProgress = true;
            Random random = new Random();
            Player first  = PickFirstZombie(random, players);

            CurLevel.ChatLevel(first.color + first.name + " %Sstarted the infection!");
            first.Game.Infected = true;
            PlayerMoneyChanged(first);
            UpdatePlayerColor(first, InfectCol);

            RoundInProgress = true;
            int    roundMins = random.Next(CurLevel.MinRoundTime, CurLevel.MaxRoundTime);
            string suffix    = roundMins == 1 ? " %Sminute!" : " %Sminutes!";

            CurLevel.ChatLevel("The round will last for &a" + roundMins + suffix);
            RoundEnd       = DateTime.UtcNow.AddMinutes(roundMins);
            timer          = new System.Timers.Timer(roundMins * 60 * 1000);
            timer.Elapsed += new ElapsedEventHandler(EndRound);
            timer.Enabled  = true;

            Player[] online = PlayerInfo.Online.Items;
            foreach (Player p in online)
            {
                if (p.level == null || p.level != CurLevel || p.Game.Referee)
                {
                    continue;
                }
                if (p != first)
                {
                    Alive.Add(p);
                }
            }

            Infected.Clear();
            Infected.Add(first);
            UpdateAllPlayerStatus();
            DoCoreGame(random);

            if (!Running)
            {
                Status = ZombieGameStatus.LastRound; return;
            }
            else
            {
                HandOutRewards();
            }
        }
Ejemplo n.º 4
0
        void DoRound()
        {
            if (!Running)
            {
                return;
            }
            List <Player> players = DoRoundCountdown();

            if (players == null)
            {
                return;
            }
            Random random = new Random();

            RoundInProgress = true;
            int    roundMins = random.Next(CurLevel.MinRoundTime, CurLevel.MaxRoundTime);
            string suffix    = roundMins == 1 ? " %Sminute!" : " %Sminutes!";

            CurLevel.ChatLevel("This round will last for &a" + roundMins + suffix);
            RoundEnd = DateTime.UtcNow.AddMinutes(roundMins);

            Player[] online = PlayerInfo.Online.Items;
            foreach (Player p in online)
            {
                if (p.level == null || p.level != CurLevel || p.Game.Referee)
                {
                    continue;
                }
                Alive.Add(p);
            }
            Infected.Clear();

            Player first = PickFirstZombie(random, players);

            CurLevel.ChatLevel("&c" + first.DisplayName + " %Sstarted the infection!");
            InfectPlayer(first, null);

            DoCoreGame(random);
            if (!Running)
            {
                Status = ZombieGameStatus.LastRound; return;
            }

            EndRound();
            if (RecentMaps.Count > 20)
            {
                RecentMaps.RemoveAt(0);
            }
            RecentMaps.Add(CurLevelName);
        }
Ejemplo n.º 5
0
        public void HandOutRewards()
        {
            if (!RoundInProgress)
            {
                return;
            }
            RoundInProgress = false;
            RoundStart      = DateTime.MinValue;
            RoundEnd        = DateTime.MinValue;
            Bounties.Clear();
            if (!Running)
            {
                return;
            }

            Player[] alive = Alive.Items;
            CurLevel.ChatLevel(Colors.lime + "The game has ended!");
            if (alive.Length == 0)
            {
                CurLevel.ChatLevel(Colors.maroon + "Zombies have won this round.");
            }
            else if (alive.Length == 1)
            {
                CurLevel.ChatLevel(Colors.green + "Congratulations to the sole survivor:");
            }
            else
            {
                CurLevel.ChatLevel(Colors.green + "Congratulations to the survivors:");
            }

            timer.Enabled = false;
            string playersString = "";

            Player[] online = null;

            if (alive.Length == 0)
            {
                online = PlayerInfo.Online.Items;
                foreach (Player pl in online)
                {
                    ResetPlayer(pl, ref playersString);
                }
            }
            else
            {
                foreach (Player pl in alive)
                {
                    if (pl.Game.PledgeSurvive)
                    {
                        pl.SendMessage("You received &a5 %3" + Server.moneys +
                                       "%s for successfully pledging that you would survive.");
                        pl.money += 5;
                        pl.OnMoneyChanged();
                    }
                    pl.Game.CurrentRoundsSurvived++;
                    pl.Game.TotalRoundsSurvived++;
                    pl.Game.MaxRoundsSurvived = Math.Max(pl.Game.CurrentRoundsSurvived, pl.Game.MaxRoundsSurvived);
                    ResetPlayer(pl, ref playersString);
                }
            }

            CurLevel.ChatLevel(playersString);
            online = PlayerInfo.Online.Items;
            Random rand = new Random();

            foreach (Player pl in online)
            {
                if (!pl.level.name.CaselessEq(CurLevelName))
                {
                    continue;
                }
                int money = GetMoney(pl, alive, rand);

                Player.GlobalDespawn(pl, true);
                Player.GlobalSpawn(pl, true);
                if (money == -1)
                {
                    pl.SendMessage("You may not hide inside a block! No " + Server.moneys + " for you."); money = 0;
                }
                else if (money > 0)
                {
                    pl.SendMessage(Colors.gold + "You gained " + money + " " + Server.moneys);
                }

                pl.Game.BlocksLeft      = 50;
                pl.Game.CurrentInfected = 0;
                pl.money        += money;
                pl.Game.Infected = false;
                if (pl.Game.Referee)
                {
                    pl.SendMessage("You gained one " + Server.moneys + " because you're a ref. Would you like a medal as well?");
                    pl.money++;
                }
                pl.OnMoneyChanged();
            }
            UpdateAllPlayerStatus();
            Alive.Clear();
            Infected.Clear();
        }