private void ClearWave(Allegiance allegiance, int wave)
        {
            if (wave < 0)
            {
                return;
            }

            Dictionary <int, List <BaseCreature> > list;

            if (allegiance == Allegiance.Myrmidex)
            {
                list = MyrmidexTeam;
            }
            else
            {
                list = TribeTeam;
            }

            if (list.ContainsKey(wave))
            {
                ColUtility.ForEach(list[wave].Where(bc => bc.Alive), bc => bc.Delete());
                ColUtility.Free(list[wave]);
                list.Remove(wave);
            }
        }
 public static void CheckRemove(Mobile victim)
 {
     ColUtility.ForEach(GetContextsForVictim <SwarmContext>(victim), context =>
     {
         context.RemoveEffects();
     });
 }
Exemple #3
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write(0);

            writer.Write(KickLocation);
            writer.Write(Lobby);

            writer.Write(Encounters.Count);
            Encounters.ForEach(encounter =>
            {
                writer.Write((int)encounter.Encounter);
                encounter.Serialize(writer);
            });

            writer.Write(Table == null ? 0 : Table.Count);

            if (Table != null)
            {
                ColUtility.ForEach(Table, (m, encounter) =>
                {
                    writer.Write(m);
                    writer.Write((int)encounter);
                });
            }

            writer.Write(Addons.Count);
            Addons.ForEach(addon => writer.Write(addon));
        }
Exemple #4
0
        public static void CheckNetwork()
        {
            bool allactive = true;

            foreach (MoonstonePowerGeneratorAddon c in Generators)
            {
                if (!c.Activated)
                {
                    allactive = false;
                    break;
                }
            }

            if (allactive)
            {
                Boss = new Zipactriotl(true);
                Boss.MoveToWorld(new Point3D(899, 2303, -20), Map.TerMur);

                ColUtility.ForEach(Generators.Where(c => c.Generator != null), c =>
                {
                    c.Generator.CanSpawn = true;
                });

                MorphItems();
            }
        }
Exemple #5
0
 public static void CheckRemove(Mobile victim)
 {
     ColUtility.ForEach(PropertyEffect.GetContexts <SwarmContext>(victim, EffectsType.Swarm), context =>
     {
         context.RemoveEffects();
     });
 }
Exemple #6
0
        public override void EndEffects()
        {
            ColUtility.ForEach(Skulls.Where(i => i != null && !i.Deleted), i => i.Delete());
            ColUtility.Free(Skulls);

            BuffInfo.RemoveBuff(Caster, BuffIcon.Conduit);
        }
Exemple #7
0
        public void Dispose()
        {
            ColUtility.ForEach(Children.AsEnumerable(), child => Children.Remove(child));
            Children = null;

            Children = null;
            Parent   = null;
        }
        public void DoWarning()
        {
            ColUtility.ForEach(this.Region.GetEnumeratedMobiles().Where(m => m is PlayerMobile), m =>
            {
                m.SendLocalizedMessage(1156252);                 // You have 5 minutes remaining in the encounter!
            });

            DoneWarning = true;
        }
Exemple #9
0
        public override void Delete()
        {
            base.Delete();

            Timer.DelayCall(TimeSpan.FromSeconds(30), () =>
            {
                ColUtility.ForEach(_Spawn.Where(sp => sp != null && sp.Alive), sp => sp.Kill());
                ColUtility.Free(_Spawn);
            });
        }
Exemple #10
0
 private void RemovePlayers()
 {
     ColUtility.ForEach(Region.GetEnumeratedMobiles().Where(
                            m => m is PlayerMobile ||
                            (m is BaseCreature &&
                             ((BaseCreature)m).GetMaster() is PlayerMobile)),
                        m =>
     {
         MovePlayer(m, Controller.KickLocation, false);
     });
 }
Exemple #11
0
        public void DoSpawn()
        {
            Map map = this.Map;

            if (Spawn == null)
            {
                return;
            }

            ColUtility.ForEach(Spawn.Where(bc => bc == null || !bc.Alive || bc.Deleted), bc => Spawn.Remove(bc));

            if (map != null && map != Map.Internal && !this.Deleted && Spawn.Count == 0 && HasSpawned < 3)
            {
                HasSpawned++;
                NextSpawn = DateTime.UtcNow + TimeSpan.FromMinutes(Utility.RandomMinMax(2, 5));

                int time = 333;
                for (int i = 0; i < SpawnCount - Spawn.Count; i++)
                {
                    Timer.DelayCall(TimeSpan.FromMilliseconds(time), () =>
                    {
                        Point3D p = this.Location;

                        for (int j = 0; j < 25; j++)
                        {
                            int x = Utility.RandomMinMax(this.X - 3, this.X + 3);
                            int y = Utility.RandomMinMax(this.Y - 3, this.Y + 3);
                            int z = map.GetAverageZ(x, y);

                            if (map.CanSpawnMobile(x, y, z) && this.InLOS(new Point3D(x, y, z)))
                            {
                                p = new Point3D(x, y, z);
                                break;
                            }
                        }

                        BaseCreature bc = Activator.CreateInstance(_SpawnList[Utility.Random(_SpawnList.Length)]) as BaseCreature;

                        if (bc != null)
                        {
                            Spawn.Add(bc);
                            bc.MoveToWorld(p, map);

                            Timer.DelayCall <BaseCreature>(creature => creature.Combatant = Focus, bc);
                        }
                    });

                    time += 333;
                }
            }
        }
        public void RegisterDeath(BaseCreature bc)
        {
            List <DamageStore> rights = bc.GetLootingRights();

            ColUtility.ForEach(rights.Where(ds => ds.m_Mobile is PlayerMobile && ds.m_HasRight && MyrmidexInvasionSystem.AreEnemies(ds.m_Mobile, bc)), ds =>
            {
                if (MyrmidexInvasionSystem.IsAlliedWith(bc, Allegiance.Myrmidex))
                {
                    int points = 1;
                    if (IsFrontLine(ds.m_Mobile, bc))
                    {
                        ds.m_Mobile.SendLocalizedMessage(1156599); // You assist the Eodonians in pushing back the Myrmidex!
                        points *= 4;
                    }
                    else
                    {
                        ds.m_Mobile.SendLocalizedMessage(1156600); // You kill one of the Myrmidex away from the front ranks and gain little recognition.
                    }
                    if (!Players.ContainsKey((PlayerMobile)ds.m_Mobile))
                    {
                        Players[(PlayerMobile)ds.m_Mobile] = points;
                    }
                    else
                    {
                        Players[(PlayerMobile)ds.m_Mobile] += points;
                    }
                }
                else
                {
                    int points = 1;
                    if (IsFrontLine(ds.m_Mobile, bc))
                    {
                        ds.m_Mobile.SendLocalizedMessage(1156598); // You assist the Myrmidex in pushing back the Eodonians!
                        points *= 4;
                    }
                    else
                    {
                        ds.m_Mobile.SendLocalizedMessage(1156601); // You kill one of the Eodonians away from the front ranks and gain little recognition.
                    }
                    if (!Players.ContainsKey((PlayerMobile)ds.m_Mobile))
                    {
                        Players[(PlayerMobile)ds.m_Mobile] = points;
                    }
                    else
                    {
                        Players[(PlayerMobile)ds.m_Mobile] += points;
                    }
                }
            });
        }
Exemple #13
0
        public virtual void Expire(bool message = true)
        {
            if (message)
            {
                ColUtility.ForEach(this.Region.GetEnumeratedMobiles().Where(m => m is PlayerMobile), m =>
                {
                    m.SendLocalizedMessage(1156253, "", 0x32);                     // The encounter timer has expired!
                });
            }

            Timer.DelayCall(TimeSpan.FromSeconds(5), () =>
            {
                Reset(true);
            });
        }
Exemple #14
0
        private static void CheckTable()
        {
            if (_Table == null)
            {
                return;
            }

            ColUtility.ForEach(_Table, (mob, expires) =>
            {
                if (expires < DateTime.UtcNow)
                {
                    _Table.Remove(mob);
                }
            });
        }
Exemple #15
0
        public void CheckAdvance()
        {
            List <BaseCreature>        list    = GetAll(Allegiance.Myrmidex);
            IEnumerable <PlayerMobile> winners = null;

            foreach (BaseCreature bc in list.Where(b => IsInMyrmidexObjective(b.Location) && 0.25 > Utility.RandomDouble()))
            {
                ClearWave(Allegiance.Myrmidex, GetWave(MyrmidexTeam, bc));
                winners = GetPlayers(Allegiance.Myrmidex);
                RegionMessage(1156630); // The Myrmidex are victorious!  If you are allied to the Myrmidex visit the Tinker in the Barrab village to continue the quest!  Otherwise, continue the fight until your team is victorious!
                break;
            }

            if (winners == null)
            {
                ColUtility.Free(list);
                list = GetAll(Allegiance.Tribes);

                foreach (BaseCreature bc in list.Where(b => IsInTribalObjective(b.Location) && 0.25 > Utility.RandomDouble()))
                {
                    ClearWave(Allegiance.Tribes, GetWave(TribeTeam, bc));
                    winners = GetPlayers(Allegiance.Tribes);
                    RegionMessage(1156631); // The Eodonians are victorious!  If you are allied to the Eodonians visit the Tinker in the Barrab village to continue the quest!  Otherwise, continue the fight until your team is victorious!
                    break;
                }
            }

            if (winners != null)
            {
                ColUtility.ForEach(winners.Where(pm => Players.ContainsKey(pm) && Players[pm] > MinCredit), pm =>
                {
                    AllianceEntry entry = MyrmidexInvasionSystem.GetEntry(pm);

                    if (entry != null && !entry.CanRecieveQuest)
                    {
                        entry.CanRecieveQuest = true;
                    }

                    if (Players.ContainsKey(pm))
                    {
                        Players.Remove(pm);
                    }
                });
            }

            ColUtility.Free(list);
        }
Exemple #16
0
 public static void OnTick()
 {
     if (Contexts == null)
     {
         EndTimer();
     }
     else
     {
         ColUtility.ForEach(Contexts, (key, value) =>
         {
             if (value != null)
             {
                 value.ForEach(c => c.OnTick(key));
             }
         });
     }
 }
Exemple #17
0
        public void CheckSpawn()
        {
            if (Spawn == null)
            {
                Delete();
            }
            else
            {
                int count = 0;
                ColUtility.ForEach(Spawn.Where(bc => bc != null && bc.Alive), bc => count++);

                if (count == 0)
                {
                    Delete();
                }
            }
        }
Exemple #18
0
        public static void Initialize()
        {
            if (ShadowguardController.Instance == null)
            {
                return;
            }

            ColUtility.ForEach(ShadowguardController.Instance.Addons.Where(addon => addon.Map != Map.Internal), addon =>
            {
                ShadowguardInstance instance = ShadowguardController.GetInstance(addon.Location, addon.Map);

                if (instance != null && !instance.InUse)
                {
                    instance.ClearRegion();
                }
            });
        }
        public void AssignNavPoints()
        {
            int myrcount = 0;
            int trcount  = 0;

            ColUtility.ForEach <int, List <BaseCreature> >(MyrmidexTeam, (key, value) => myrcount += value.Count);
            ColUtility.ForEach <int, List <BaseCreature> >(TribeTeam, (key, value) => trcount     += value.Count);

            ColUtility.ForEach <int, List <BaseCreature> >(MyrmidexTeam, (key, value) =>
            {
                value.ForEach(bc => AssignNavpoints(bc, Allegiance.Myrmidex));
            });

            ColUtility.ForEach <int, List <BaseCreature> >(TribeTeam, (key, value) =>
            {
                value.ForEach(bc => AssignNavpoints(bc, Allegiance.Tribes));
            });
        }
Exemple #20
0
        public void ResendGumps(PlayerMobile player)
        {
            if (Viewers == null)
            {
                return;
            }

            ColUtility.ForEach(Viewers.Where(pm => pm != player), pm =>
            {
                AuctionBidGump g = pm.FindGump(typeof(AuctionBidGump)) as AuctionBidGump;

                if (g == null)
                {
                    pm.SendGump(new AuctionOwnerGump(pm, Safe));
                }
                else
                {
                    g.Refresh();
                }
            });
        }
        public List <BaseCreature> GetAll(Allegiance allegiance)
        {
            Dictionary <int, List <BaseCreature> > list;

            if (allegiance == Allegiance.Myrmidex)
            {
                list = MyrmidexTeam;
            }
            else
            {
                list = TribeTeam;
            }

            List <BaseCreature> bclist = new List <BaseCreature>();

            ColUtility.ForEach(list, (key, value) =>
            {
                bclist.AddRange(value.Where(bc => bc != null && !bc.Deleted && bc.Alive));
            });

            return(bclist);
        }
Exemple #22
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write(0);

            writer.Write(KickLocation);
            writer.Write(Lobby);

            writer.Write(Encounters.Count);

            for (var index = 0; index < Encounters.Count; index++)
            {
                var encounter = Encounters[index];

                writer.Write((int)encounter.Encounter);
                encounter.Serialize(writer);
            }

            writer.Write(Table == null ? 0 : Table.Count);

            if (Table != null)
            {
                ColUtility.ForEach(Table, (m, encounter) =>
                {
                    writer.Write(m);
                    writer.Write((int)encounter);
                });
            }

            writer.Write(Addons.Count);

            for (var index = 0; index < Addons.Count; index++)
            {
                var addon = Addons[index];

                writer.Write(addon);
            }
        }
Exemple #23
0
        public void Dispose()
        {
            ColUtility.ForEach(Children.AsEnumerable(), child => Children.Remove(child));
            Children = null;

            Children = null;
            Parent   = null;

            foreach (var kvp in _TextTooltips)
            {
                kvp.Value.Free();
            }

            foreach (var kvp in _ClilocTooltips)
            {
                kvp.Value.Free();
            }

            _ClilocTooltips.Clear();
            _TextTooltips.Clear();

            OnDispose();
        }
Exemple #24
0
        public void AddPlayers(Mobile m)
        {
            if (m == null || !m.Alive || !m.InRange(Controller.Location, 25) || m.NetState == null)
            {
                Reset(true);
            }
            else
            {
                Party p = Party.Get(m);

                if (p != null)
                {
                    ColUtility.ForEach(
                        p.Members.Where(
                            info => info.Mobile.Alive &&
                            Controller.Lobby.Contains(new Point2D(info.Mobile.X, info.Mobile.Y)) &&
                            info.Mobile.NetState != null),
                        info => AddPlayer(info.Mobile));
                }

                AddPlayer(m);
            }
        }
Exemple #25
0
        public void Dispose()
        {
            ColUtility.ForEach(Children.AsEnumerable(), child => Children.Remove(child));
            Children = null;

            Children = null;
            Parent = null;

            foreach (KeyValuePair<string, Spoof> kvp in _TextTooltips)
            {
                kvp.Value.Free();
            }

            foreach (KeyValuePair<Dictionary<int, string>, Spoof> kvp in _ClilocTooltips)
            {
                kvp.Value.Free();
            }

            _ClilocTooltips.Clear();
            _TextTooltips.Clear();

            OnDispose();
        }
Exemple #26
0
        public override void ClearItems()
        {
            if (ShadowguardCanals != null)
            {
                List <Item> list = new List <Item>(ShadowguardCanals.Where(i => i != null && !i.Deleted));

                foreach (var canal in list)
                {
                    canal.Delete();
                }

                ColUtility.Free(list);

                ColUtility.Free(ShadowguardCanals);
                ShadowguardCanals = null;
            }

            if (Elementals != null)
            {
                List <BaseCreature> list = new List <BaseCreature>(Elementals.Where(t => t != null && !t.Deleted));

                foreach (var elemental in list)
                {
                    elemental.Delete();
                }

                ColUtility.Free(list);

                ColUtility.Free(Elementals);
                Elementals = null;
            }

            if (FlowCheckers != null)
            {
                ColUtility.ForEach(FlowCheckers.Where(f => f != null), f => f.EndEncounter());
            }
        }
        public static void DisplayWaveInfo(BattleSpawner spawner, Mobile m)
        {
            int delay = 0;

            ColUtility.ForEach(spawner.MyrmidexTeam, kvp =>
            {
                if (kvp.Value.Count > 0)
                {
                    int wave  = kvp.Key + 1;
                    int count = kvp.Value.Where(bc => bc.Alive).Count();

                    Timer.DelayCall(TimeSpan.FromSeconds(delay), () =>
                    {
                        m.SendLocalizedMessage(1156606, String.Format("{0}\t{1}\t{2}", (BattleSpawner.WaveCount - count).ToString(), BattleSpawner.WaveCount.ToString(), wave.ToString()));         // Myrmidex have lost ~1_VAL~ of ~2_VAL~ from wave ~3_VAL~ of their front line.
                    });
                }

                delay++;
            });

            delay = 0;
            ColUtility.ForEach(spawner.TribeTeam, kvp =>
            {
                if (kvp.Value.Count > 0)
                {
                    int wave  = kvp.Key + 1;
                    int count = kvp.Value.Where(bc => bc.Alive).Count();

                    Timer.DelayCall(TimeSpan.FromSeconds(delay), () =>
                    {
                        m.SendLocalizedMessage(1156607, String.Format("{0}\t{1}\t{2}", (BattleSpawner.WaveCount - count).ToString(), BattleSpawner.WaveCount.ToString(), wave.ToString()));     // Myrmidex have lost ~1_VAL~ of ~2_VAL~ from wave ~3_VAL~ of their front line.
                    });
                }

                delay++;
            });
        }
 public void RegionMessage(int message)
 {
     ColUtility.ForEach(BattleRegion.GetEnumeratedMobiles().OfType <PlayerMobile>(), pm => pm.SendLocalizedMessage(message));
 }
        public void CheckAdvance()
        {
            List <BaseCreature> myrmidex = GetAll(Allegiance.Myrmidex);
            List <BaseCreature> tribes   = GetAll(Allegiance.Tribes);

            IEnumerable <PlayerMobile> winners = null;

            Dictionary <int, BaseCreature> hasBreached = new Dictionary <int, BaseCreature>();
            bool opposedBreach = false;

            IPooledEnumerable eable = this.Map.GetMobilesInBounds(_MyrmidexObjective);

            foreach (Mobile m in eable)
            {
                if (m is BaseCreature && tribes.Contains((BaseCreature)m))
                {
                    opposedBreach = true;
                    break; // once its opposed, no winner
                }
                else if (m is BaseCreature && myrmidex.Contains((BaseCreature)m))
                {
                    int wave = GetWave(MyrmidexTeam, ((BaseCreature)m));

                    hasBreached[wave] = (BaseCreature)m;
                }
            }

            if (hasBreached.Count > 0 && !opposedBreach)
            {
                foreach (var kvp in hasBreached)
                {
                    ClearWave(Allegiance.Myrmidex, GetWave(MyrmidexTeam, kvp.Value));
                }

                winners = GetPlayers(Allegiance.Myrmidex);
                RegionMessage(1156630); // The Myrmidex are victorious!  If you are allied to the Myrmidex visit the Tinker in the Barrab village to continue the quest!  Otherwise, continue the fight until your team is victorious!
            }

            eable.Free();
            hasBreached.Clear();
            opposedBreach = false;

            if (winners == null)
            {
                eable = this.Map.GetMobilesInBounds(_TribalObjective);

                foreach (Mobile m in eable)
                {
                    if (m is BaseCreature && myrmidex.Contains((BaseCreature)m))
                    {
                        opposedBreach = true;
                        break; // once its opposed, no winner
                    }
                    else if (m is BaseCreature && tribes.Contains((BaseCreature)m))
                    {
                        int wave = GetWave(TribeTeam, ((BaseCreature)m));

                        hasBreached[wave] = (BaseCreature)m;
                    }
                }

                if (hasBreached.Count > 0 && !opposedBreach)
                {
                    foreach (var kvp in hasBreached)
                    {
                        ClearWave(Allegiance.Tribes, GetWave(TribeTeam, kvp.Value));
                    }

                    winners = GetPlayers(Allegiance.Tribes);
                    RegionMessage(1156631); // The Eodonians are victorious!  If you are allied to the Eodonians visit Professor Raffkin in Sir Geoffrey's camp to continue the quest! Otherwise, continue the fight until your team is victorious!
                }
            }

            eable.Free();
            hasBreached.Clear();

            if (winners != null)
            {
                ColUtility.ForEach(winners.Where(pm => Players.ContainsKey(pm) && Players[pm] > MinCredit), pm =>
                {
                    AllianceEntry entry = MyrmidexInvasionSystem.GetEntry(pm);

                    if (entry != null && !entry.CanRecieveQuest)
                    {
                        entry.CanRecieveQuest = true;
                    }

                    if (Players.ContainsKey(pm))
                    {
                        Players.Remove(pm);
                    }
                });
            }

            ColUtility.Free(myrmidex);
            ColUtility.Free(tribes);
        }
        public override void OnDoubleClick(Mobile from)
        {
            if (from is PlayerMobile && Game == null && (Pending == null || !Pending.Contains(from)))
            {
                BaseGump.SendGump(new YahtzeeConfirmGump((PlayerMobile)from, "Join Yahtzee?", "Would you like to join the next yahtzee game?", () =>
                {
                    lock (Lock)
                    {
                        if (Game != null)
                        {
                            YahtzeeGame.SendMessage(from, "The game has already begun. Maybe next time...", 2118);
                        }
                        else if (YahtzeeGame.IsInGame((PlayerMobile)from))
                        {
                            YahtzeeGame.SendMessage(from, "You can only play in one game of Yahtzee at a time!", 2118);
                        }
                        else
                        {
                            if (Pending == null)
                            {
                                Pending = new List <Mobile>();
                                Timer.DelayCall(TimeSpan.FromSeconds(120), () =>
                                {
                                    if (Game == null)
                                    {
                                        Pending.ForEach(mob => mob.SendMessage("You lack the required players for Yahtzee!"));
                                        Pending.Clear();
                                        Pending = null;
                                    }
                                });
                            }

                            Pending.Add(from);

                            if (Pending.Count > 1)
                            {
                                ColUtility.ForEach(Pending.Where(mob => mob != from), mob => mob.SendMessage("{0} has joined the Yahtzee game!", from.Name));
                            }

                            if (Pending.Count >= PlayerCount)
                            {
                                Game = new YahtzeeGame(Pending, this, RollOrder);
                                Pending.ForEach(mob => YahtzeeGame.SendMessage(mob, "yahtzee will begin in 10 seconds!"));
                                Pending.Clear();

                                Timer.DelayCall(TimeSpan.FromSeconds(10), Game.BeginGame);
                            }
                            else
                            {
                                Pending.ForEach(mob => YahtzeeGame.SendMessage(mob, String.Format("Still waiting on {0} more players!", PlayerCount - Pending.Count)));
                            }
                        }
                    }
                }));
            }
            else if (Game != null && from is PlayerMobile)
            {
                PlayerEntry entry = Game.GetEntry((PlayerMobile)from);

                if (entry != null)
                {
                    BaseGump.SendGump(new YahtzeeGump(entry, entry.Player, Game));
                }
            }
        }