public bool SwitchTeam(int id, CTFTeam team = CTFTeam.None) { Debug.Assert(PlayerExists(id)); Debug.Assert(players[id].Team != CTFTeam.None); if (players[id].Team == team) { return(false); } if (players[id].Team == CTFTeam.Red) { players[id].Team = CTFTeam.Blue; --RedPlayer; ++BluePlayer; } else { players[id].Team = CTFTeam.Red; --BluePlayer; ++RedPlayer; } setTeam(id); setPvP(id); announcePlayerSwitchTeam(id); warpToSpawn(id); return(true); }
public GameTeamSelector(CTFGame game, int teamSize, bool randomTeam) : base(50, 50) { m_Game = game; m_TeamSize = teamSize; m_RandomTeam = randomTeam; //Closable = false; Dragable = false; AddPage(0); AddBackground(0, 0, 250, 220, 5054); AddBackground(10, 10, 230, 200, 3000); AddPage(1); AddLabel(20, 20, 0, "Select a team:"); if (m_RandomTeam) { AddButton(20, 60, 4005, 4006, 1, GumpButtonType.Reply, 0); AddLabel(55, 60, 0, "Join Random Team"); } else { for (int i = 0; i < m_Game.Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Game.Teams[i]; if (team.ActiveMemberCount < m_TeamSize) { AddButton(20, 60 + i * 20, 4005, 4006, i + 1, GumpButtonType.Reply, 0); AddLabel(55, 60 + i * 20, 0, "Join Team " + team.Name); } } } }
public override bool AllowHarmful(Mobile from, Mobile target) { CTFTeam ft = CTFGame.FindTeamFor(from); CTFTeam tt = CTFGame.FindTeamFor(target); return(ft != null && tt != null && ft != tt && ft.Game == tt.Game && ft.Game.Running); }
public CTFPlayer() { Team = CTFTeam.None; Class = null; Online = true; Dead = false; Data = new PlayerData(null); }
public override bool OnSingleClick(Mobile from, object o) { if (!(o is Mobile)) { return(base.OnSingleClick(from, o)); } Mobile m = (Mobile)o; CTFTeam team = CTFGame.FindTeamFor(m); if (team != null) { string msg; Item[] items = null; if (m.Backpack != null) { items = m.Backpack.FindItemsByType(typeof(CTFFlag)); } if (items == null || items.Length == 0) { msg = String.Format("(Team: {0})", team.Name); } else { StringBuilder sb = new StringBuilder("(Team: "); sb.Append(team.Name); sb.Append(" -- Flag"); if (items.Length > 1) { sb.Append("s"); } sb.Append(": "); for (int j = 0; j < items.Length; j++) { CTFFlag flag = (CTFFlag)items[j]; if (flag != null && flag.Team != null) { if (j > 0) { sb.Append(", "); } sb.Append(flag.Team.Name); } } sb.Append(")"); msg = sb.ToString(); } m.PrivateOverheadMessage(Network.MessageType.Label, team.Hue, true, msg, from.NetState); } return(true); }
public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; from.CloseGump(typeof(GameTeamSelector)); if (!GameJoinStone.IsNaked(from)) { from.SendMessage("You must be naked to join."); return; } if (m_Game.Deleted) { return; } if (info.ButtonID == 0) { return; } CTFTeam team = null; if (m_RandomTeam) { team = m_Game.RandomTeam(); } else { team = m_Game.GetTeam(info.ButtonID - 1); } if (team != null && team.ActiveMemberCount < m_TeamSize) { bool freeze = from.Frozen; from.Kill(); if (from.Corpse != null && !from.Corpse.Deleted) { from.Corpse.Delete(); } from.Location = team.Home; from.Map = team.Map; from.Resurrect(); from.Frozen = freeze; m_Game.SwitchTeams(from, team); from.SendMessage("You have joined team {0}!", team.Name); } else { from.SendMessage("That team is full, please try again."); from.SendGump(new GameTeamSelector(m_Game, m_RandomTeam)); } }
public void UpdateTeam() { if (m_Game != null && m_TeamID != -1) { m_Team = m_Game.GetTeam(m_TeamID); if (m_Team != null) { this.Hue = m_Team.Hue; this.Name = m_Team.Name + " Orc"; } } }
public bool InvalidPlace(CTFTeam team, int x, int y, bool middle) { if ((middle && x >= wallLeft - 1 && x <= wallRight + 1) || (redSpawnArea.Contains(x, y)) || (blueSpawnArea.Contains(x, y)) || (x >= redFlagNoEdit.Left && x < redFlagNoEdit.Right && y < redFlagNoEdit.Bottom) || (x >= blueFlagNoEdit.Left && x < blueFlagNoEdit.Right && y < blueFlagNoEdit.Bottom) || (team == CTFTeam.Red && Main.tile[x, y].type == Terraria.ID.TileID.CobaltBrick) || (team == CTFTeam.Blue && Main.tile[x, y].type == Terraria.ID.TileID.RedBrick)) { return(true); } return(false); }
public override bool AllowHarmful(Mobile from, Mobile target) { CTFTeam ft = CTFGame.FindTeamFor(from); if (ft == null) { return(false); } CTFTeam tt = CTFGame.FindTeamFor(target); if (tt == null) { return(false); } return(ft != tt && ft.Game == tt.Game && ft.Game.Running); }
public CTFRobe( CTFTeam team ) : base(0x1F03, team.Hue) { Name = "[Event Item]"; Weight = 0.1; Movable = false; Attributes.LowerRegCost = 100; Attributes.CastRecovery = 4; Attributes.CastSpeed = 2; Attributes.LowerManaCost = 30; Resistances.Physical = 70; Resistances.Fire = 65; Resistances.Cold = 65; Resistances.Poison = 65; Resistances.Energy = 65; LootType = LootType.Cursed; }
public GameTeamSelector(CTFGame game, int teamSize) : base("Select a Team", null) { List <String> mTeams = new List <String>(); m_Game = game; m_TeamSize = teamSize; for (int i = 0; i < m_Game.Teams.Count; i++) { CTFTeam team = (CTFTeam)m_Game.Teams[i]; if (team.ActiveMemberCount < m_TeamSize) { mTeams.Add("Join Team " + team.Name); } } Answers = mTeams.ToArray(); }
public override void OnDamage(int amount, Mobile from, bool willKill) { if (willKill == true && m_Game != null && from != null) { CTFTeam team = m_Game.GetTeam(from); willKill = false; this.Blessed = true; this.Hidden = true; this.Combatant = null; this.Freeze(TimeSpan.FromSeconds(m_Timer + 1)); from.SendMessage("You killed the {0} orc!", m_Team.Name); this.Game.PlayerMessage("{0} ({1}) killed the {2} orc!", from.Name, team.Name, m_Team.Name); team.Points += m_Points; Timer.DelayCall(TimeSpan.FromSeconds(m_Timer), new TimerCallback(RTimer)); } base.OnDamage(amount, from, willKill); }
protected override void OnTarget(Mobile from, object targ) { if (!(targ is PlayerMobile)) { from.SendMessage("You can only target players."); return; } CTFTeam team = CTFGame.FindTeamFor((PlayerMobile)targ); if (team == null) { from.SendMessage("This player is not in a CTF game."); } else { team.Game.LeaveGame((PlayerMobile)targ); LeaveGameGate.Strip((PlayerMobile)targ); from.SendMessage("Player kicked from CTF."); } }
public override void AggressiveAction(Mobile aggressor, bool criminal) { base.AggressiveAction(aggressor, criminal); if (m_Game != null && m_Game.Running && aggressor != null) { Item item = aggressor.FindItemOnLayer(Layer.OuterTorso); if (item is CTFRobe) { CTFTeam team = m_Game.GetTeam(aggressor); if (team != null && team.Name == m_Team.Name) { AOS.Damage(aggressor, 200, 0, 100, 0, 0, 0); this.Game.PlayerMessage("{0} ({1}) was killed for betraying his orc!", aggressor.Name, team.Name); aggressor.BoltEffect(0); aggressor.PlaySound(0x307); } } } }
private CTFTeam EvaluateTeam(SensorTeam.Teams team) { var entry = Leaderboard.Entries[team == SensorTeam.Teams.Cyan ? 0 : 1]; var flagIsHome = ((JObject)entry.ModeData)?["flagStatus"]?.ToString() == "Home"; var ctfTeam = new CTFTeam { Team = team, BasePosition = team == SensorTeam.Teams.Cyan ? new Vector2(-this.Robot.WorldSize, -this.Robot.WorldSize) : new Vector2(+this.Robot.WorldSize, +this.Robot.WorldSize), FlagIsHome = flagIsHome, FlagPosition = entry.Position, FlagCarriedBy = entry.FleetID, Score = entry.Score }; return(ctfTeam); }
public override void OnResponse(NetState state, int index) { Mobile from = state.Mobile; if (m_Game.Deleted) { return; } CTFTeam team = m_Game.GetTeam(index); if (team != null && team.ActiveMemberCount < m_TeamSize) { bool freeze = from.Frozen; from.Kill(); if (from.Corpse != null && !from.Corpse.Deleted) { from.Corpse.Delete(); } from.Location = team.Home; from.Map = team.Map; from.Resurrect(); from.Frozen = freeze; m_Game.SwitchTeams(from, team); from.SendAsciiMessage("You have joined team {0}!", team.Name); } else { from.SendAsciiMessage("That team is full, please try again."); from.SendMenu(new GameTeamSelector(m_Game)); } }
public void EndGame(CTFTeam winner) { Debug.Assert(GameIsRunning); Phase = CTFPhase.Ended; announceGameEnd(winner); }
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); switch ( version ) { case 1: { m_PlayerSpawn = reader.ReadPoint3D(); goto case 0; } case 0: { m_Stone = (CTFGameStone)reader.ReadItem(); ; m_Team = CTFGame.TeamArray[reader.ReadInt()]; m_FlagHome = reader.ReadPoint3D(); m_FlagHomeMap = reader.ReadMap(); if (version == 0) m_PlayerSpawn = m_FlagHome; break; } } Timer.DelayCall( TimeSpan.Zero, new TimerCallback( ReturnToHome ) ); }
public static CTFFlag GetTeamFlag(CTFTeam team) { return FlagArray[team.Number]; }
void announceGameEnd(CTFTeam winner) { cb.AnnounceGameEnd(winner, RedScore, BlueScore); }
public DeathTimer( Mobile m, CTFTeam t, CTFGame g, TimeSpan DeathDelay ) : base( TimeSpan.Zero, TimeSpan.FromMilliseconds(250) ) { m_Mob = m; m_Team = t; m_Game = g; m_Res = DateTime.Now + DeathDelay; if (m is PlayerMobile) { m_GumpItem = new CustomGumpItem("Resurrect in", DeathDelay.Hours + ":" + DeathDelay.Minutes + ":" + DeathDelay.Seconds, m_Game, (PlayerMobile)m); GameInfoGump.AddCustomMessage((PlayerMobile)m, m_GumpItem); } Priority = TimerPriority.TwoFiftyMS; }