public static void On_Logout(LogoutEventArgs args) { PlayerMobile pm = (PlayerMobile)args.Mobile; for (int i = 0; i < Registry.Count; ++i) { RVS d = (RVS)Registry[i]; if (d.Caller == pm) { Registry.Remove(d); d.EndSelf(); } else if (d.InRVS(pm)) { if (!d.InProgress) { d.RefundBuyIn(pm); d.SendControllerSetup(); } else { d.EchoMessage("A player disconnected, duel must end."); d.EndSelf(); } } } }
public static void On_ShutDown(ShutdownEventArgs args) { for (int i = 0; i < Registry.Count; ++i) { RVS d = (RVS)Registry[i]; d.EndSelf(); } }
public static void RVSCleanUp_DelayLoop() { for (int i = 0; i < Registry.Count; ++i) { RVS d = (RVS)Registry[i]; if (d.Caller.NetState == null || d.Ended) { Registry.Remove(d); d.EndSelf(); } } Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerCallback(RVSCleanUp_DelayLoop)); }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; switch (info.ButtonID) { case 0: // Close { Handling.EndSelf(); return; } case 1: // Start { if (FilledTeams(Handling) < 2) { Handling.EchoMessage("You must have at least two participating teams to start a duel."); from.SendGump(new RVSSetup_Main(Handling)); return; } else if (!CheckLoggedIn()) { Handling.EchoMessage("One or more players participating in this duel have logged out, duel start delayed."); from.SendGump(new RVSSetup_Main(Handling)); return; } else if (!AllAlive()) { Handling.EchoMessage("Not all players participating in the duel are alive, duel start delayed."); from.SendGump(new RVSSetup_Main(Handling)); return; } else // Start RVS { Handling.UpdateAllPending(); return; } } case 2: // Rules { from.SendGump(new RVSSetup_Rules(Handling)); from.SendMessage("If the box next to something is checked, it is allowed."); return; } case 3: // Add A Team { if (Handling.Teams.Count >= 8) { from.SendMessage("There is a maximum of 8 teams"); from.SendGump(new RVSSetup_Main(Handling)); return; } RVS_Team toadd = new RVS_Team((Handling.Teams.Count + 1)); toadd.Players.Add("@null"); Handling.Teams.Add((Handling.Teams.Count + 1), toadd); from.SendGump(new RVSSetup_Main(Handling)); return; } case 4: // Remove A Team { if (Handling.Teams.Count <= 2) { from.SendMessage("Cannot have less then 2 teams."); from.SendGump(new RVSSetup_Main(Handling)); return; } RVS_Team toremove = (RVS_Team)Handling.Teams[Handling.Teams.Count]; if (toremove.Players.Count <= 1 && toremove.Players[0] == "@null") { Handling.Teams.Remove(Handling.Teams.Count); } else { from.SendMessage("You can not remove a team that contains players, move the players to a higher team."); } from.SendGump(new RVSSetup_Main(Handling)); return; } case 5: // Set Buy In { if (FilledTeams(Handling) != 1) { from.SendMessage("You cannot set the duel buy in after you have already added players."); from.SendGump(new RVSSetup_Main(Handling)); return; } from.SendGump(new RVSSetup_SetBuyIn(Handling)); return; } } if (info.ButtonID >= 6) { int id = (info.ButtonID - 5); from.SendGump(new RVSSetup_ParticipantSetup(Handling, id)); } }
public void StartRVS(RVS d) { Handeling = d; if (Handeling.Caller.NetState == null) { Handeling.EndSelf(); return; } HasStarted = true; InUse = true; Handeling.InProgress = true; Handeling.Controller = this; if (PlayerLocations == null) PlayerLocations = new Dictionary<Serial, Point3D>(); if (PlayerMaps == null) PlayerMaps = new Dictionary<Serial, Map>(); if (PlayerItems == null) PlayerItems = new Dictionary<Serial, ArrayList>(); if (ItemLocations == null) ItemLocations = new Dictionary<Serial, Point3D>(); if (InsuredItems == null) InsuredItems = new ArrayList(); if (FrozenItems == null) FrozenItems = new ArrayList(); if (Trees == null) Trees = new ArrayList(); if (Traps == null) Traps = new ArrayList(); if (Enemies == null) Enemies = new ArrayList(); if (Fountains == null) Fountains = new ArrayList(); if (EVsAndBSs == null) EVsAndBSs = new ArrayList(); SpawnTrees(Handeling, SheepSpawnPoint, SheepSpawnMap); SpawnTraps(Handeling, SheepSpawnPoint, SheepSpawnMap); SpawnFountainsSheep( Handeling, "Sheep", SheepSpawnPoint, SheepSpawnMap ); SpawnTrees(Handeling, RabbitSpawnPoint, RabbitSpawnMap); SpawnTraps(Handeling, RabbitSpawnPoint, RabbitSpawnMap); SpawnFountainsRabbits( Handeling, "Rabbit", RabbitSpawnPoint, RabbitSpawnMap ); SpawnEnemies( Handeling, "Sheep", 1); SheepPoints++; SpawnEnemies( Handeling, "Rabbit", 1); RabbitPoints++; IEnumerator key = Handeling.Teams.Keys.GetEnumerator(); for (int i = 0; i < Handeling.Teams.Count; ++i) { key.MoveNext(); RVS_Team d_team = (RVS_Team)Handeling.Teams[(int)key.Current]; for (int i2 = 0; i2 < d_team.Players.Count; ++i2) { object o = (object)d_team.Players[i2]; if (o is PlayerMobile) { PlayerMobile pm = (PlayerMobile)o; StorePlayer(pm); SpawnPlayer(pm, (int)key.Current); PlayerNoto(pm); PetNoto(pm); pm.Blessed = true; pm.Frozen = true; pm.Spell = null; ResurrectPlayer(pm); ResurrectPets(pm); } } } Timer.DelayCall(TimeSpan.FromSeconds(3.0), new TimerCallback(UnInvul)); EndTimer = new RVS_EndTimer(Handeling); }