示例#1
0
        public static void SwitchTeamTo(Player player, CtfTeam newTeam, bool unbalanced)
        {
            CtfTeam oldTeam = newTeam == RedTeam ? BlueTeam : RedTeam;

            player.Message("You have switched to the {0}&S team.", newTeam.ClassyName);
            if (unbalanced)
            {
                player.Message("&SThe teams are now unbalanced!");
            }

            oldTeam.Players.Remove(player);
            if (!newTeam.Has(player))
            {
                newTeam.Players.Add(player);
            }

            if (player.IsHoldingFlag)
            {
                world.Players.Message("&cFlag holder {0} &cswitched to the {1}&c team, " +
                                      "thus dropping the flag for the {2}&c team!",
                                      player.Name, newTeam.ClassyName, oldTeam.ClassyName);
                oldTeam.HasFlag      = false;
                player.IsHoldingFlag = false;
                world.Map.QueueUpdate(new BlockUpdate(Player.Console, newTeam.FlagPos, newTeam.FlagBlock));
            }
            player.Team = newTeam;
            player.TeleportTo(newTeam.Spawn);
        }
		static void ClickOpposingFlag(PlayerPlacingBlockEventArgs e, CtfTeam opposition) {
			if (opposition.HasFlag) {
				e.Player.Message("You can't capture the opposing team's flag, " +
				                 "if you're not in posession of your own flag.");
				e.Result = CanPlaceResult.CTFDenied;
			} else {
				e.Result = CanPlaceResult.Allowed;
				e.Player.Team.HasFlag = true;
				e.Player.IsHoldingFlag = true;
				world.Players.Message("{0} &sgot the {1}&s flag.",
				                      e.Player.ClassyName, opposition.ClassyName );
			}
		}
示例#3
0
        static void AddPlayerToTeam(CtfTeam team, Player p)
        {
            team.Players.Add(p);
            p.Message("Adding you to the " + team.ClassyName + " team");
            p.TeleportTo(team.Spawn);
            p.Team = team;

            p.IsPlayingCTF = true;
            if (p.Supports(CpeExt.HeldBlock))
            {
                p.Send(Packet.MakeHoldThis(Block.TNT, false));
            }
        }
示例#4
0
 static void ClickOpposingFlag(PlayerPlacingBlockEventArgs e, CtfTeam opposition)
 {
     if (opposition.HasFlag)
     {
         e.Player.Message("You can't capture the opposing team's flag, " +
                          "if you're not in posession of your own flag.");
         e.Result = CanPlaceResult.CTFDenied;
     }
     else
     {
         e.Result = CanPlaceResult.Allowed;
         e.Player.Team.HasFlag  = true;
         e.Player.IsHoldingFlag = true;
         world.Players.Message("{0} &Sgot the {1}&S flag.",
                               e.Player.ClassyName, opposition.ClassyName);
     }
 }
		static void ClickOwnFlag(PlayerPlacingBlockEventArgs e, CtfTeam opposition) {
			if (!e.Player.IsHoldingFlag) {
				e.Player.Message("You don't have the {0}&s flag.", opposition.ClassyName);
				e.Result = CanPlaceResult.CTFDenied;
			} else {
				world.Map.QueueUpdate(new BlockUpdate(Player.Console, opposition.FlagPos, opposition.FlagBlock));
				CtfTeam team = e.Player.Team;
				team.Score++;
				team.HasFlag = false;
				e.Player.IsHoldingFlag = false;
				
				world.Players.Message("{0} &sscored a point for {1}&s team.",
				                      e.Player.ClassyName, team.ClassyName);
				e.Result = CanPlaceResult.CTFDenied;
				Check();
			}
		}
示例#6
0
        static void RemovePlayerFromTeam(Player p, CtfTeam opposingTeam)
        {
            p.Team.Players.Remove(p);
            p.Message("Removing you from the game");
            if (p.IsHoldingFlag)
            {
                world.Players.Message("&cFlag holder " + p.ClassyName + " &cleft CTF, " +
                                      "thus dropping the flag for the " + p.Team.ClassyName + " team!");
                p.Team.HasFlag  = false;
                p.IsHoldingFlag = false;
                world.Map.QueueUpdate(new BlockUpdate(Player.Console, opposingTeam.FlagPos,
                                                      opposingTeam.FlagBlock));
            }

            p.IsPlayingCTF = false;
            p.Team         = null;
            if (p.Supports(CpeExt.HeldBlock))
            {
                p.Send(Packet.MakeHoldThis(Block.Stone, false));
            }
        }
示例#7
0
        static void ClickOwnFlag(PlayerPlacingBlockEventArgs e, CtfTeam opposition)
        {
            if (!e.Player.IsHoldingFlag)
            {
                e.Player.Message("You don't have the {0}&S flag.", opposition.ClassyName);
                e.Result = CanPlaceResult.CTFDenied;
            }
            else
            {
                world.Map.QueueUpdate(new BlockUpdate(Player.Console, opposition.FlagPos, opposition.FlagBlock));
                CtfTeam team = e.Player.Team;
                team.Score++;
                team.HasFlag           = false;
                e.Player.IsHoldingFlag = false;

                world.Players.Message("{0} &Sscored a point for {1}&S team.",
                                      e.Player.ClassyName, team.ClassyName);
                e.Result = CanPlaceResult.CTFDenied;
                Check();
            }
        }
示例#8
0
        static void UpdateRoundScores()
        {
            CtfTeam winner = null;

            if (BlueTeam.Score > RedTeam.Score)
            {
                BlueTeam.RoundsWon++;
                winner = BlueTeam;
            }
            else if (RedTeam.Score > BlueTeam.Score)
            {
                RedTeam.RoundsWon++;
                winner = RedTeam;
            }
            if (winner == null) // should not happen
            {
                return;
            }

            CtfTeam loser = Opposition(winner);

            world.Players.Message("The {0}{1}&S team won that round: {0}{2} &S- {3}{4}",
                                  winner.Color, winner.Name, winner.Score, loser.Color, loser.Score);
        }
示例#9
0
 static CtfTeam Opposition(CtfTeam team)
 {
     return(team == RedTeam ? BlueTeam : RedTeam);
 }
示例#10
0
		static void RemovePlayerFromTeam(Player p, CtfTeam opposingTeam) {
			p.Team.Players.Remove(p);
			p.Message("&SRemoving you from the game");
			if (p.IsHoldingFlag) {
				world.Players.Message("&cFlag holder " + p.ClassyName + " &cleft CTF, " +
				                      "thus dropping the flag for the " + p.Team.ClassyName + " team!");
				p.Team.HasFlag = false;
				p.IsHoldingFlag = false;
				world.Map.QueueUpdate(new BlockUpdate(Player.Console, opposingTeam.FlagPos,
				                                      opposingTeam.FlagBlock));
			}	
			
			p.IsPlayingCTF = false;
			p.Team = null;		
			if (p.Supports(CpeExtension.HeldBlock))
				p.Send(Packet.MakeHoldThis(Block.Stone, false));
		}
示例#11
0
		static CtfTeam Opposition(CtfTeam team) {
			return team == RedTeam ? BlueTeam : RedTeam;
		}
示例#12
0
		public static void SwitchTeamTo(Player player, CtfTeam newTeam, bool unbalanced) {
			CtfTeam oldTeam = newTeam == RedTeam ? BlueTeam : RedTeam;
			player.Message("You have switched to the {0}&s team.", newTeam.ClassyName);
			if (unbalanced)
				player.Message( "&sThe teams are now unbalanced!");
			
			oldTeam.Players.Remove(player);
			if (!newTeam.Has(player))
				newTeam.Players.Add(player);
			
			if (player.IsHoldingFlag) {
				world.Players.Message("&cFlag holder {0} &cswitched to the {1}&c team, " +
				                      "thus dropping the flag for the {2}&c team!",
				                      player.Name, newTeam.ClassyName, oldTeam.ClassyName );
				oldTeam.HasFlag = false;
				player.IsHoldingFlag = false;
				world.Map.QueueUpdate(new BlockUpdate(Player.Console, newTeam.FlagPos, newTeam.FlagBlock));
			}
			player.Team = newTeam;
			player.TeleportTo(newTeam.Spawn);
		}
示例#13
0
		static void AddPlayerToTeam(CtfTeam team, Player p) {
			team.Players.Add(p);
			p.Message("&SAdding you to the " + team.ClassyName + " team");
			p.TeleportTo(team.Spawn);
			p.Team = team;
			
			p.IsPlayingCTF = true;
			if (p.Supports(CpeExtension.HeldBlock))
				p.Send(Packet.MakeHoldThis(Block.TNT, false));
		}