示例#1
0
        public void UpdateBlocks()
        {
            if (!Owned)
            {
                return;
            }

            if (c_Blocks.Count == 0)
            {
                UnconvertDoors();
            }

            c_House.Blocks.Clear();
            c_House.Blocks.AddRange(c_Blocks);

            c_House.UpdateRegion();

            ConvertItems(false);
            c_House.InitSectorDefinition();
        }
示例#2
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 = c_Price + (sellitems ? c_ItemsPrice : 0);

                if (c_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;

                int minX = ((Rectangle2D)c_Blocks[0]).Start.X;
                int minY = ((Rectangle2D)c_Blocks[0]).Start.Y;
                int maxX = ((Rectangle2D)c_Blocks[0]).End.X;
                int maxY = ((Rectangle2D)c_Blocks[0]).End.Y;

                foreach (Rectangle2D rect in c_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;
                    }
                }

                c_House = new TownHouse(m, this, new ArrayList(c_Blocks), c_Locks, c_Secures);

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

                c_House.Location          = new Point3D(minX, minY, Map.GetAverageZ(minX, minY));
                c_House.Map               = Map;
                c_House.Region.GoLocation = c_BanLoc;
                c_House.Sign.Location     = c_SignLoc;
                c_House.Hanger            = new Item(0xB98);
                c_House.Hanger.Location   = c_SignLoc;
                c_House.Hanger.Map        = Map;
                c_House.Hanger.Movable    = false;
                c_House.Price             = (RentByTime == TimeSpan.FromDays(0) ? c_Price : 1);

                c_House.UpdateRegion();

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

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

                c_RTOPayments = 1;

                HideOtherSigns();

                c_DecoreItemInfos = new ArrayList();

                ConvertItems(sellitems);
            }
            catch { Errors.Report(String.Format("TownHouseSign-> Purchase()-> {0}", m)); }
        }