Example #1
0
 public static void CaptureFlag(Player p, CTFTeam team)
 {
     if (!gameOn) { return; }
     team.hasFlag = null;
     ReturnFlag(team, false);
     p.carryingFlag = false;
     Player.GlobalMessage("&f- " + p.color + p.name + "&S captured the " + team.color + team.name + "&S flag!");
     Server.s.Log(p.name + " captured the " + team.name + " flag!");
     p.Reward(captureFlagReward);
     p.team.points++;
     UpdateScore();
     p.captureStreak++;
     p.captureCount++;
     if (team.capturedFlag == p)
     {
         Player.GlobalMessage("&f- " + p.color + p.name + "&6 is on a streak of &5" + p.captureStreak + "&6!");
     }
     else
     {
         p.captureStreak = 1;
     }
     team.capturedFlag = p;
     if (p.team.points >= scoreLimit)
     {
         GameEnd(p.team);
     }
 }
Example #2
0
 public static void UpdateScore(CTFTeam winners = null)
 {
     if (winners != null)
     {
         Player.GlobalMessage("^detail.user=Game over. Winners: " + winners.color + winners.name + " team!");
     }
     else
     {
         Player.GlobalMessage("^detail.user= &cRed: " + redTeam.points + "&f | &9Blue: " + blueTeam.points);
     }
 }
Example #3
0
 public static void TakeFlag(Player p, CTFTeam team)
 {
     if (!gameOn) { return; }
     if (p.justDroppedFlag) { return; }
     if (p.carryingFlag) { return; }
     if (redTeam.players.Count < 1 || blueTeam.players.Count < 1)
     {
             p.SendMessage("&f- &SYou cannot take the flag with no opposition!");
         return;
     }
     team.hasFlag = p;
     team.flagIsHome = false;
     p.carryingFlag = true;
     Player.GlobalMessage("&f- " + p.color + p.name + "&S took the " + team.color + team.name + "&S flag!");
     Server.s.Log(p.name + " took the " + team.name + " flag!");
     p.Reward(takeFlagReward);
 }
Example #4
0
        public static void Setup(Level level, bool resetTeams = false)
        {
            if (resetTeams)
            {
                CTFTeam tempRed = redTeam;
                CTFTeam tempBlue = blueTeam;
                redTeam = new CTFTeam("&c", Block.red);
                blueTeam = new CTFTeam("&9", Block.deepblue);
                tempRed.Replace(redTeam);
                tempBlue.Replace(blueTeam);
            }

            currLevel = level;
            redTeam.spawn = currLevel.redSpawn;
            redTeam.spawnrot = currLevel.redRotation;
            redTeam.flagBase = currLevel.redFlag;
            blueTeam.spawn = currLevel.blueSpawn;
            blueTeam.spawnrot = currLevel.blueRotation;
            blueTeam.flagBase = currLevel.blueFlag;
            redTeam.flagLocation = redTeam.flagBase;
            blueTeam.flagLocation = blueTeam.flagBase;

            Server.s.Log("CTF set up, waiting for players...");

            GameStart();
        }
Example #5
0
 public static void ReturnFlag(CTFTeam team, bool message = true)
 {
     team.flagLocation = team.flagBase;
     team.flagIsHome = true;
     team.DrawFlag();
     if (message)
     {
         Player.GlobalMessage("&f-&S The " + team.color + team.name + "&S team's flag was returned.");
         Server.s.Log(team.name + " flag was returned to base.");
     }
 }
Example #6
0
        public static void GameEnd(CTFTeam winners)
        {
            gameOn = false;
            UpdateScore(winners);
            Player.GlobalMessage("&f-&S The game has ended. Winners are the " + winners.color + winners.name + " team!");
            Server.s.Log("Game was ended. Winning team: " + winners.name);

            Thread.Sleep(5000);

            Player.GlobalMessage("&f- &SThis games top performers:");
            List<Player> ordered = Player.players.OrderByDescending(ply => ply.captureCount).ThenBy(ply => ply.captureStreak).ToList();
            ordered.ForEach(delegate(Player p)
            {
                Player.GlobalMessage("     " + p.color + p.name + " &a(" + p.captureCount + " captures, " + p.kills + " kills, " + p.deaths + " deaths)");

            });

            winners.points = 0;

            if (winners == redTeam) { redWins++; }
            if (winners == blueTeam) { blueWins++; }

            ReturnFlag(redTeam, false);
            ReturnFlag(blueTeam, false);

            currLevel.blocks = currLevel.backupBlocks;

            Thread.Sleep(5000);

            VoteMap();
        }
 public void Replace(CTFTeam replaceMent)
 {
     teams.Remove(this);
     players.ForEach(delegate(Player p)
     {
         p.team = replaceMent;
         DelPlayer(p);
         replaceMent.AddPlayer(p, false);
     });
 }