Ejemplo n.º 1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_Resource = (ResourceType)reader.ReadInt();
            m_Government = (GovernmentEntity)reader.ReadItem();
            m_Owned = reader.ReadBool();
            m_ProductionDate = reader.ReadDateTime();
            m_ProductionRate = reader.ReadInt();
            BaseName = reader.ReadString();
            m_Claimant = (PlayerMobile)reader.ReadMobile();
            m_ClaimantGovernment = (GovernmentEntity)reader.ReadItem();

            if (version < 1)
                ProductionDate = DateTime.Now.AddDays(1);

            if (m_Owned)
            {
                m_Timer = new ResourceTimer(this);
                m_Timer.Start();
            }

            if (m_ClaimantGovernment != null && !m_ClaimantGovernment.Deleted)
            {
                m_ClaimTimer = new ClaimResourceTimer(this);
                m_ClaimTimer.Start();
            }
        }
Ejemplo n.º 2
0
        public override void OnDelete()
        {
            if ((m_ClaimTimer != null) && (m_ClaimTimer.Running))
            {
                m_ClaimTimer.Stop();
                m_ClaimTimer = null;
            }

            if (m_Timer != null && m_Timer.Running)
            {
                m_Timer.Stop();
                m_Timer = null;
            }

            base.OnDelete();
        }
Ejemplo n.º 3
0
        public void Capture()
        {
            if (m_ClaimantGovernment == null || m_ClaimantGovernment.Deleted)
                return;

            if (Government != null && !Government.Deleted && Government != m_ClaimantGovernment)
            {
                ReportInfo newReport = new ReportInfo("Lost contact with " + this.Resource.ToString() + " at X: " + this.X.ToString() + " and Y: " + this.Y.ToString() + ".");
                newReport.TimeOfReport = Formatting.GetTimeFormat(this, Format.Time);
                Government.Reports.Add(newReport);

                List<MilitarySpawner> nearbySpawners = new List<MilitarySpawner>();
                IPooledEnumerable nearbyItems = this.Map.GetItemsInRange(this.Location, 15);
                foreach (Item item in nearbyItems)
                {
                    if (item is MilitarySpawner && (item as MilitarySpawner).Government != null && !(item as MilitarySpawner).Government.Deleted)
                    {
                        MilitarySpawner spawner = item as MilitarySpawner;

                        if (spawner.Government == Government)
                            nearbySpawners.Add(spawner);
                        else if (Government.AlliedGuilds.Contains(spawner.Government))
                            nearbySpawners.Add(spawner);
                        else if (m_ClaimantGovernment.EnemyGuilds.Contains(spawner.Government))
                            nearbySpawners.Add(spawner);
                    }
                }
                nearbyItems.Free();

                for (int i = (nearbySpawners.Count - 1); i > -1; i--)
                    nearbySpawners[i].Delete();
                nearbySpawners.Clear();
            }

            IPooledEnumerable eable = Map.GetItemsInRange(this.Location, 15);
            List<MilitarySpawner> removeSpawner = new List<MilitarySpawner>();
            foreach (Item i in eable)
            {
                if (i is MilitarySpawner)
                {
                    MilitarySpawner spawner = i as MilitarySpawner;
                    if (spawner.Government != null && !spawner.Government.Deleted)
                        if (m_ClaimantGovernment.EnemyGuilds.Contains(spawner.Government))
                            removeSpawner.Add(spawner);
                }
            }
            eable.Free();
            for (int i = (removeSpawner.Count - 1); i > -1; i--)
                removeSpawner[i].Delete();
            removeSpawner.Clear();

            Government = m_ClaimantGovernment;
            Owned = true;
            ProductionDate = DateTime.Now.AddDays(1);
            Name = BaseName + " [" + Government.Name.ToString() + "]";

            if(m_LastCapture + TimeSpan.FromDays(7.0) <= DateTime.Now)
            {
                eable = this.Map.GetMobilesInRange(this.Location, 15);
                foreach (Mobile m in eable)
                {
                    if (m is PlayerMobile && Government != null && !Government.Deleted && Government.Members.Contains(m))
                    {
                        m.SendMessage("You have successfully claimed the " + this.Resource.ToString() + "!");
                        int reward = ProductionRate * Utility.RandomMinMax( Utility.Random(Government.Members.Count) + 1, Government.Members.Count + 2 );
                        LevelSystem.AwardExp(m as PlayerMobile, Utility.RandomMinMax(ProductionRate, reward));
                        LevelSystem.AwardCP(m as PlayerMobile, Utility.RandomMinMax(ProductionRate, reward));
                    }

                    if (m is BaseCreature &&
                        Government != null &&
                        !Government.Deleted &&
                        ((m as BaseCreature).Government != null &&
                        (m as BaseCreature).Government == Government ||
                        Government.Members.Contains((m as BaseCreature).ControlMaster)))
                    {
                        LevelSystem.AwardExp(m as BaseCreature, Utility.RandomMinMax(ProductionRate + 1, (ProductionRate * (Utility.Random(25) + 1))));
                    }
                }
                eable.Free();
            }

            m_LastCapture = DateTime.Now;
            m_Claimant = null;
            m_ClaimantGovernment = null;
            m_ClaimTimer.Stop();

            m_Timer = new ResourceTimer(this);
            m_Timer.Start();
        }