Ejemplo n.º 1
0
 public void ScorePoint(Player p, PushBallTeam scoredOn)
 {
     if (p.pushBallTeam != scoredOn)
     {
         p.pushBallGoals++;
         p.pushBallTeam.points++;
         Player.GlobalMessageLevel(level, p.color + p.prefix + p.name + " &escored a point on the " + scoredOn.teamstring + "&e!");
     }
     else
     {
         foreach (PushBallTeam team in pushBallTeams)
         {
             if (team != scoredOn)
             {
                 team.points++;
             }
         }
         Player.GlobalMessageLevel(level, p.color + p.prefix + p.name + " &escored on their own goal!");
     }
     SpawnBall();
     foreach (PushBallTeam team in pushBallTeams)
     {
         foreach (Player pl in team.players)
         {
             team.SpawnPlayer(pl);
         }
         if (team.points >= winPoints)
         {
             End(team); break;
         }
     }
 }
Ejemplo n.º 2
0
 // Player p is the "cause" of the end (winner, manual ender, etc).
 public void End(PushBallTeam winningTeam)
 {
     level.pushBallStarted = false;
     if (level.countdown == true) { level.countdown = false; countDown.Stop(); }
     foreach (Player pl in level.players)
     {
         if (pl.hidden && !pl.referee) { Command.all.Find("hide").Use(pl, "s"); }
         if (pl.invincible && !pl.referee) { Command.all.Find("invincible").Use(pl, ""); }
         if (pl.isFlying && !pl.referee) { Command.all.Find("fly").Use(pl, ""); }
         pl.userlinetype = "blockinfo";
     }
     if (winningTeam != null)
     {
         SpawnBall();
         Player.GlobalMessageLevel(level, winningTeam.color + winningTeam.teamstring + " &ehas won the PushBall game, with " + winningTeam.points + " points!");
         Player mvp = null; var mvpGoals = 0;
         foreach (Player p in level.players)
         {
             if (p.pushBallGoals > mvpGoals) mvpGoals = p.pushBallGoals; mvp = p;
             p.pushBallGoals = 0;
         }
         if (mvp != null) { if (mvp.pushBallGoals == mvpGoals) { Player.GlobalMessageLevel(level, "&eThis game's MVP was: " + mvp.color + mvp.prefix + mvp.name + "&e!"); } }
         foreach (PushBallTeam pbt in pushBallTeams) pbt.points = 0;
     }
     else { Player.GlobalMessageLevel(level, "The game was ended manually, so no winner was decided."); }
 }
Ejemplo n.º 3
0
 public void End(PushBallTeam winningTeam) // Player p is the "cause" of the end (winner, manual ender, etc).
 {
     level.pushBallStarted = false;
     if (level.countdown == true)
     {
         level.countdown = false; countDown.Stop();
     }
     foreach (Player pl in level.players)
     {
         if (pl.hidden && !pl.referee)
         {
             Command.all.Find("hide").Use(pl, "s");
         }
         if (pl.invincible && !pl.referee)
         {
             Command.all.Find("invincible").Use(pl, "");
         }
         if (pl.isFlying && !pl.referee)
         {
             Command.all.Find("fly").Use(pl, "");
         }
         pl.userlinetype = "blockinfo";
     }
     if (winningTeam != null)
     {
         SpawnBall();
         Player.GlobalMessageLevel(level, winningTeam.teamstring + "&e has won the PushBall game, with " + winningTeam.points + " points!");
         Player mvp = null; var mvpGoals = 0;
         foreach (Player p in level.players)
         {
             if (p.pushBallGoals > mvpGoals)
             {
                 mvpGoals = p.pushBallGoals;
             }
             mvp             = p;
             p.pushBallGoals = 0;
         }
         if (mvp != null)
         {
             if (mvp.pushBallGoals == mvpGoals)
             {
                 Player.GlobalMessageLevel(level, "&eThis game's MVP was: " + mvp.color + mvp.prefix + mvp.name + "&e!");
             }
         }
         foreach (PushBallTeam pbt in pushBallTeams)
         {
             pbt.points = 0;
         }
     }
     else
     {
         Player.GlobalMessageLevel(level, "The game was ended manually, so no winner was decided.");
     }
 }
Ejemplo n.º 4
0
        public void RemoveTeam(string color)
        {
            char teamCol = (char)color[1];

            PushBallTeam  workteam = pushBallTeams.Find(team => team.color == teamCol);
            List <Player> storedP  = new List <Player>();

            for (int i = 0; i < workteam.players.Count; i++)
            {
                storedP.Add(workteam.players[i]);
            }
            foreach (Player p in storedP)
            {
                workteam.RemoveMember(p);
            }
        }
Ejemplo n.º 5
0
        public void AddTeam(string color)
        {
            char teamCol = (char)color[1];

            PushBallTeam workteam = new PushBallTeam();

            workteam.color = teamCol;
            workteam.points = 0;
            workteam.level = level;
            char[] temp = c.Name("&" + teamCol).ToCharArray();
            temp[0] = char.ToUpper(temp[0]);
            string tempstring = new string(temp);
            workteam.teamstring = "&" + teamCol + tempstring + " team" + Server.DefaultColor;

            pushBallTeams.Add(workteam);

            level.ChatLevel(workteam.teamstring + "&e has been added to the PushBall game!");
        }
Ejemplo n.º 6
0
 public void ScorePoint(Player p, PushBallTeam scoredOn)
 {
     p.pushBallGoals++;
     p.pushBallTeam.points++;
     SpawnBall();
     if (p.pushBallTeam != scoredOn)
     {
         Player.GlobalMessageLevel(level, p.color + p.prefix + p.name + "(" + p.pushBallTeam.teamstring + ") &escored a point on the " + scoredOn.teamstring + "&e!");
     }
     else
     {
         Player.GlobalMessageLevel(level, p.color + p.prefix + p.name + "(" + p.pushBallTeam.teamstring + ") &escored on his own goal!");
     }
     if (scoredOn.points >= winPoints)
     {
         End(scoredOn);
     }
 }
Ejemplo n.º 7
0
        public void AddTeam(string color)
        {
            char teamCol = (char)color[1];

            PushBallTeam workteam = new PushBallTeam();

            workteam.color  = teamCol;
            workteam.points = 0;
            workteam.level  = level;
            char[] temp = c.Name("&" + teamCol).ToCharArray();
            temp[0] = char.ToUpper(temp[0]);
            string tempstring = new string(temp);

            workteam.teamstring = "&" + teamCol + tempstring + " team&g";

            pushBallTeams.Add(workteam);

            level.ChatLevel(workteam.teamstring + "&e has been added to the PushBall game!");
        }
Ejemplo n.º 8
0
 public void ScorePoint(Player p, PushBallTeam scoredOn)
 {
     p.pushBallGoals++;
     p.pushBallTeam.points++;
     SpawnBall();
     if (p.pushBallTeam != scoredOn) Player.GlobalMessageLevel(level, p.color + p.prefix + p.name + "(" + p.pushBallTeam.teamstring + ") &escored a point on the " + scoredOn.teamstring + "&e!");
     else Player.GlobalMessageLevel(level, p.color + p.prefix + p.name + "(" + p.pushBallTeam.teamstring + ") &escored on his own goal!");
     if (scoredOn.points >= winPoints) { End(scoredOn); }
 }
Ejemplo n.º 9
0
 public override void Use(Player p, string message)
 {
     if (message.Split(' ')[0].ToLower() == "set")
     {
         if (p.group.Permission >= LevelPermission.Operator)
         {
             string name = message.Split(' ')[1].ToLower();
             string team = message.Split(' ')[2].ToLower();
             if (team == "none")
             {
                 Player pl = Player.Find(name);
                 if (pl == null || pl.level != p.level)
                 {
                     Player.SendMessage(p, "That player does not exist or is not on your level.");
                 }
                 if (pl.team == null)
                 {
                     Player.SendMessage(p, "That player is not on a team.");
                 }
                 pl.team.RemoveMember(pl);
                 return;
             }
             string color = c.Parse(team);
             if (color == "")
             {
                 Player.SendMessage(p, "Invalid team color chosen."); return;
             }
             Player who = Player.Find(name);
             if (who == null || who.level != p.level)
             {
                 Player.SendMessage(p, "That player does not exist or is not on your level.");
             }
             char teamCol = (char)color[1];
             if (p.level.pushBall.pushBallTeams.Find(team1 => team1.color == teamCol) == null)
             {
                 Player.SendMessage(p, "Invalid team color chosen."); return;
             }
             PushBallTeam workTeam = p.level.pushBall.pushBallTeams.Find(team1 => team1.color == teamCol);
             if (who.team != null)
             {
                 who.team.RemoveMember(who);
             }
             workTeam.AddMember(who);
         }
     }
     if (message.Split(' ')[0].ToLower() == "join")
     {
         string color = c.Parse(message.Split(' ')[1]);
         if (color == "")
         {
             Player.SendMessage(p, "Invalid team color chosen."); return;
         }
         char teamCol = (char)color[1];
         if (p.level.pushBall.pushBallTeams.Find(team => team.color == teamCol) == null)
         {
             Player.SendMessage(p, "Invalid team color chosen."); return;
         }
         PushBallTeam workTeam = p.level.pushBall.pushBallTeams.Find(team => team.color == teamCol);
         if (p.pushBallTeam != null)
         {
             p.pushBallTeam.RemoveMember(p);
         }
         workTeam.AddMember(p);
     }
     else if (message.Split(' ')[0].ToLower() == "leave")
     {
         if (p.pushBallTeam != null)
         {
             p.pushBallTeam.RemoveMember(p);
         }
         else
         {
             Player.SendMessage(p, "You are not on a team.");
             return;
         }
     }
     else if (message.Split(' ')[0].ToLower() == "chat")
     {
         if (p.pushBallTeam == null)
         {
             Player.SendMessage(p, "You must be on a team before you can use team chat."); return;
         }
         p.teamchat = !p.teamchat;
         if (p.teamchat)
         {
             Player.SendMessage(p, "Team chat has been enabled.");
             return;
         }
         else
         {
             Player.SendMessage(p, "Team chat has been disabled.");
             return;
         }
     }
     else if (message.Split(' ')[0].ToLower() == "scores")
     {
         if (!p.level.pushBallStarted)
         {
             Player.SendMessage(p, "Game not started yet."); return;
         }
         foreach (PushBallTeam t in p.level.pushBall.pushBallTeams)
         {
             Player.SendMessage(p, t.teamstring + " has " + t.points + " point(s).");
         }
     }
 }