Exemple #1
0
        static void PlayerChangedWorld(object sender, PlayerJoinedWorldEventArgs e)
        {
            if (e.OldWorld == null)
            {
                return;
            }

            if (e.NewWorld == world)
            {
                if (!BlueTeam.Has(e.Player) && !RedTeam.Has(e.Player))
                {
                    ChooseTeamFor(e.Player, e.NewWorld);
                }
            }
            else if (e.OldWorld == world)
            {
                RemovePlayer(e.Player, e.OldWorld);

                if (BlueTeam.Count + RedTeam.Count == 0)
                {
                    e.Player.Message("You were the last player in the game, and thus, the game has ended.");
                    Stop();
                }
            }
        }
Exemple #2
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);
        }
Exemple #3
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);
		}