示例#1
0
    public void PurchaseLand(PPlayer Player, PBlock Block)
    {
        PPurchaseLandTag PurchaseLandTag = Monitor.CallTime(PTime.PurchaseLandTime, new PPurchaseLandTag(Player, Block));

        Player = PurchaseLandTag.Player;
        Block  = PurchaseLandTag.Block;
        int LandPrice = PurchaseLandTag.LandPrice;

        if (Player != null && Block != null && Player.IsAlive)
        {
            LoseMoney(Player, LandPrice);
            Block.Lord = Player;
            GetHouse(Block, 1);
            PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(Block));
            if (Block.IsBusinessLand && Block.BusinessType.Equals(PBusinessType.NoType))
            {
                PBusinessType        ChosenType = PBusinessType.NoType;
                List <PBusinessType> Types      = new List <PBusinessType>()
                {
                    PBusinessType.ShoppingCenter, PBusinessType.Institute,
                    PBusinessType.Altar, PBusinessType.Castle, PBusinessType.Park
                };
                if (Player.IsUser)
                {
                    ChosenType = Types[PNetworkManager.NetworkServer.ChooseManager.Ask(Player, "选择商业用地的发展方向", Types.ConvertAll((PBusinessType BusinessType) => BusinessType.Name).ToArray(), Types.ConvertAll((PBusinessType BusinessType) => BusinessType.ToolTip).ToArray())];
                }
                else
                {
                    ChosenType = PAiBusinessChooser.ChooseDirection(this, Player, Block);
                }
                Block.BusinessType = ChosenType;
                if (ChosenType.Equals(PBusinessType.Park))
                {
                    GetMoney(Player, PMath.Percent(Block.Price, 50));
                }
                else if (ChosenType.Equals(PBusinessType.Castle))
                {
                    GetHouse(Block, GetBonusHouseNumberOfCastle(Player, Block));
                }
                PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(Block));
            }
            else
            {
                Block.BusinessType = PBusinessType.NoType;
            }
            PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder(Player.Name + "购买了" + Block.Name));
        }
    }