Exemplo n.º 1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            if (Instances == null)
            {
                Instances = new List <BedrollSpawner>();
            }

            Instances.Add(this);

            DateTime next = reader.ReadDateTime();

            if (next < DateTime.UtcNow)
            {
                next = DateTime.UtcNow;
            }

            m_Timer = Timer.DelayCall(next - DateTime.UtcNow, RestartDelay, CheckRespawn);
            m_Timer.Start();

            Bedrolls          = new List <WrongBedrollBase>();
            MysteriousTunnels = new List <MysteriousTunnel>();

            int bedrollcount = reader.ReadInt();

            for (int x = 0; x < bedrollcount; x++)
            {
                WrongBedrollBase wb = reader.ReadItem() as WrongBedrollBase;

                if (wb != null)
                {
                    Bedrolls.Add(wb);
                }
            }

            int mysteriouscount = reader.ReadInt();

            for (int y = 0; y < mysteriouscount; y++)
            {
                MysteriousTunnel mt = reader.ReadItem() as MysteriousTunnel;

                if (mt != null)
                {
                    MysteriousTunnels.Add(mt);
                }
            }

            if (version == 0)
            {
                Timer.DelayCall(TimeSpan.FromSeconds(5), map =>
                {
                    EnchantedHotItem.SpawnChests(map);
                    Console.WriteLine("Hot Item chests spawned for {0}.", Map);
                }, Map);
            }
        }
Exemplo n.º 2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            if (Instances == null)
            {
                Instances = new List <BedrollSpawner>();
            }

            Instances.Add(this);

            DateTime next = reader.ReadDateTime();

            if (next < DateTime.UtcNow)
            {
                next = DateTime.UtcNow;
            }

            this.m_Timer = Timer.DelayCall(next - DateTime.UtcNow, RestartDelay, new TimerCallback(CheckRespawn));
            this.m_Timer.Start();

            Bedrolls          = new List <WrongBedrollBase>();
            MysteriousTunnels = new List <MysteriousTunnel>();

            int bedrollcount = reader.ReadInt();

            for (int x = 0; x < bedrollcount; x++)
            {
                WrongBedrollBase wb = reader.ReadItem() as WrongBedrollBase;

                if (wb != null)
                {
                    Bedrolls.Add(wb);
                }
            }

            int mysteriouscount = reader.ReadInt();

            for (int y = 0; y < mysteriouscount; y++)
            {
                MysteriousTunnel mt = reader.ReadItem() as MysteriousTunnel;

                if (mt != null)
                {
                    MysteriousTunnels.Add(mt);
                }
            }
        }
Exemplo n.º 3
0
        private void CheckRespawn()
        {
            Cleanup();

            // Bedrolls Spawn

            foreach (BedrollEntry entry in m_Entries)
            {
                WrongBedrollBase item = (WrongBedrollBase)Activator.CreateInstance(entry.Type);

                item.Movable = false;
                item.MoveToWorld(entry.Location, Map);
                Bedrolls.Add(item);
            }

            // Mysterious Tunnels Spawn

            MysteriousTunnel mt;
            WrongBedrollBase bedroll;
            int mtrandom;

            for (int i = 0; i < m_OutsideTunnels.Length; i++)
            {
                mt = new MysteriousTunnel();

                if (i < 3)
                {
                    mtrandom     = Utility.Random(m_Entries.Length);
                    mt.PointDest = Bedrolls[mtrandom].Location;
                    Bedrolls[mtrandom].PointDest      = m_OutsideTunnels[i];
                    Bedrolls[mtrandom].BedrollSpawner = this;
                }
                else
                {
                    mt.PointDest = m_RoomDestinations[Utility.Random(m_RoomDestinations.Length)];
                    bedroll      = Bedrolls.Where(x => x.InRange(mt.PointDest, 4) && x.PointDest == Point3D.Zero).FirstOrDefault();

                    if (bedroll != null)
                    {
                        bedroll.PointDest      = m_OutsideTunnels[i];
                        bedroll.BedrollSpawner = this;
                    }
                }

                mt.MoveToWorld(m_OutsideTunnels[i], Map);
                MysteriousTunnels.Add(mt);
            }
        }