Exemple #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));
        }
    }
 public PRefreshBlockBasicOrder() : base("refresh_block_basic",
                                         null,
                                         (string[] args) => {
     int BlockIndex             = Convert.ToInt32(args[1]);
     int LordIndex              = Convert.ToInt32(args[2]);
     int HouseNumber            = Convert.ToInt32(args[3]);
     int Price                  = Convert.ToInt32(args[5]);
     PBusinessType BusinessType = FindInstance <PBusinessType>(args[4]);
     PBlock Block               = PNetworkManager.NetworkClient.GameStatus.Map.FindBlock(BlockIndex);
     PPlayer Lord               = PNetworkManager.NetworkClient.GameStatus.FindPlayer(LordIndex);
     if (Block != null && BusinessType != null)
     {
         PAnimation.AddAnimation("刷新格子基本信息", () => {
             PPlayer OriginalLord = Block.Lord;
             Block.Lord           = Lord;
             Block.Price          = Price;
             Block.HouseNumber    = HouseNumber;
             Block.BusinessType   = BusinessType;
             PUIManager.GetUI <PMapUI>().Scene.BlockGroup.GroupUIList[BlockIndex].InitializeBlock(Block);
             if (OriginalLord != null)
             {
                 if (Block.IsBusinessLand)
                 {
                     OriginalLord.BusinessLandNumber--;
                 }
                 else
                 {
                     OriginalLord.NormalLandNumber--;
                 }
                 PUIManager.GetUI <PMapUI>().PlayerInformationGroup.Update(OriginalLord.Index);
             }
             if (Lord != null)
             {
                 if (Block.IsBusinessLand)
                 {
                     Lord.BusinessLandNumber++;
                 }
                 else
                 {
                     Lord.NormalLandNumber++;
                 }
                 PUIManager.GetUI <PMapUI>().PlayerInformationGroup.Update(Lord.Index);
             }
         });
     }
 }) {
 }