Exemple #1
0
 private void SearchForHouse()
 {
     foreach (TownHouse house in TownHouse.AllTownHouses)
     {
         if (house.ForSaleSign == this)
         {
             m_House = house;
         }
     }
 }
Exemple #2
0
        public virtual void ClearHouse()
        {
            UnconvertDoors();
            ClearDemolishTimer();
            ClearRentTimer();
            PackUpItems();
            RecreateItems();
            m_House = null;
            Visible = true;

            if (m_RentToOwn)
            {
                m_RentByTime = m_OriginalRentTime;
            }
        }
Exemple #3
0
        public void Purchase(Mobile m, bool sellitems)
        {
            try
            {
                if (Owned)
                {
                    m.SendMessage("Someone already owns this house!");
                    return;
                }

                if (!PriceReady)
                {
                    m.SendMessage("The setup for this house is not yet complete.");
                    return;
                }

                int price = m_Price + (sellitems ? m_ItemsPrice : 0);

                if (m_Free)
                {
                    price = 0;
                }

                if (m.AccessLevel == AccessLevel.Player && !Server.Mobiles.Banker.Withdraw(m, price))
                {
                    m.SendMessage("You cannot afford this house.");
                    return;
                }

                if (m.AccessLevel == AccessLevel.Player)
                {
                    m.SendLocalizedMessage(1060398, price.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                }
                Visible = false;
                Rectangle2D startrec = m_Blocks[0];

                int minX = startrec.Start.X;
                int minY = startrec.Start.Y;
                int maxX = startrec.End.X;
                int maxY = startrec.End.Y;

                foreach (Rectangle2D rect in m_Blocks)
                {
                    if (rect.Start.X < minX)
                    {
                        minX = rect.Start.X;
                    }
                    if (rect.Start.Y < minY)
                    {
                        minY = rect.Start.Y;
                    }
                    if (rect.End.X > maxX)
                    {
                        maxX = rect.End.X;
                    }
                    if (rect.End.Y > maxY)
                    {
                        maxY = rect.End.Y;
                    }
                }

                m_House = new TownHouse(m, this, m_Locks, m_Secures);

                m_House.Components.Resize(maxX - minX, maxY - minY);
                m_House.Components.Add(0x520, m_House.Components.Width - 1, m_House.Components.Height - 1, -5);

                m_House.MoveToWorld(new Point3D(minX, minY, Map.GetAverageZ(minX, minY)), Map);

                m_House.Region.GoLocation = m_BanLoc;
                m_House.Sign.Location     = m_SignLoc;
                m_House.Hanger            = new Static(0xB98);
                m_House.Hanger.MoveToWorld(m_SignLoc, Map);

                if (m_ForcePublic)
                {
                    m_House.Public = true;
                }

                m_House.Price = (RentByTime == TimeSpan.FromDays(0) ? m_Price : 1);

                RUOVersion.UpdateRegion(this);

                if (m_House.Price == 0)
                {
                    m_House.Price = 1;
                }

                if (m_RentByTime != TimeSpan.Zero)
                {
                    BeginRentTimer(m_RentByTime);
                }

                m_RTOPayments = 1;

                HideOtherSigns();

                m_DecoreItemInfos = new List <DecoreItemInfo>();

                ConvertItems(sellitems);

                uint keyval = m_House.CreateKeys(m);
                foreach (GenericHouseDoor door in m_House.Doors)
                {
                    door.KeyValue = keyval;
                }
            }
            catch (Exception e)
            {
                Errors.Report(String.Format("An error occurred during home purchasing.  More information available on the console."));
                Console.WriteLine(e.Message);
                Console.WriteLine(e.Source);
                Console.WriteLine(e.StackTrace);
            }
        }
Exemple #4
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            if (version >= 13)
            {
                m_ForcePrivate = reader.ReadBool();
                m_ForcePublic  = reader.ReadBool();
                m_NoTrade      = reader.ReadBool();
            }

            if (version >= 12)
            {
                m_Free = reader.ReadBool();
            }

            if (version >= 11)
            {
                m_Murderers = (Intu)reader.ReadInt();
            }

            if (version >= 10)
            {
                m_LeaveItems = reader.ReadBool();
            }

            if (version >= 9)
            {
                m_RentToOwn        = reader.ReadBool();
                m_OriginalRentTime = reader.ReadTimeSpan();
                m_RTOPayments      = reader.ReadInt();
            }

            m_PreviewItems = new ArrayList();
            if (version >= 7)
            {
                m_PreviewItems = reader.ReadItemList();
            }

            if (version >= 6)
            {
                m_ItemsPrice = reader.ReadInt();
                m_KeepItems  = reader.ReadBool();
            }

            m_DecoreItemInfos = new List <DecoreItemInfo>();
            if (version >= 5)
            {
                int            decorecount = reader.ReadInt();
                DecoreItemInfo info;
                for (int i = 0; i < decorecount; ++i)
                {
                    info = new DecoreItemInfo();
                    info.Load(reader);
                    m_DecoreItemInfos.Add(info);
                }

                m_Relock = reader.ReadBool();
            }

            if (version >= 4)
            {
                m_RecurRent     = reader.ReadBool();
                m_RentByTime    = reader.ReadTimeSpan();
                m_RentTime      = reader.ReadDateTime();
                m_DemolishTime  = reader.ReadDateTime();
                m_YoungOnly     = reader.ReadBool();
                m_MinTotalSkill = reader.ReadInt();
                m_MaxTotalSkill = reader.ReadInt();
            }

            if (version >= 3)
            {
                m_MinZ = reader.ReadInt();
                m_MaxZ = reader.ReadInt();
            }

            if (version >= 2)
            {
                m_House = (TownHouse)reader.ReadItem();
            }

            m_Price    = reader.ReadInt();
            m_Locks    = reader.ReadInt();
            m_Secures  = reader.ReadInt();
            m_BanLoc   = reader.ReadPoint3D();
            m_SignLoc  = reader.ReadPoint3D();
            m_Skill    = reader.ReadString();
            m_SkillReq = reader.ReadDouble();

            m_Blocks = new List <Rectangle2D>();
            int count = reader.ReadInt();

            for (int i = 0; i < count; ++i)
            {
                m_Blocks.Add(reader.ReadRect2D());
            }

            if (m_RentTime > DateTime.Now)
            {
                BeginRentTimer(m_RentTime - DateTime.Now);
            }

            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(StartTimers));

            ClearPreview();

            s_TownHouseSigns.Add(this);
        }