当前位置: 首页>>代码示例>>C#>>正文


C# Player.TriggerChanged方法代码示例

本文整理汇总了C#中Player.TriggerChanged方法的典型用法代码示例。如果您正苦于以下问题:C# Player.TriggerChanged方法的具体用法?C# Player.TriggerChanged怎么用?C# Player.TriggerChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player.TriggerChanged方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AllocateParcel

        /// <summary>
        /// Refactor with common parts of parcel purchase
        /// </summary>
        /// <param name="bp"></param>
        /// <param name="owner"></param>
        public void AllocateParcel(BuyPoint bp, Player owner)
        {
            TransferAllRights(bp, owner);

            owner.TriggerChanged();
            bp.TriggerChanged();

            // TODO: This should really be a transfer event - since they weren't 'bought'
            m_controller.EventManager.TriggerLandRightsGiven(bp);

            // FIXME: This should be done via events
            UpdateHudStatus(owner);

            //            m_controller.Events.PostToAll(
            //                string.Format(BUY_RIGHTS_CRAWL_MSG, buyer.Name, bp.Name, bp.RegionName),
            //                EventLevel.Crawl);
        }
开发者ID:cmickeyb,项目名称:waterwars,代码行数:22,代码来源:GameStartingState.cs

示例2: GiveWaterRights

        public override void GiveWaterRights(Player p, int amount)
        {
            m_log.InfoFormat("[WATER WARS]: Giving rights to {0} to {1}", WaterWarsUtils.GetWaterUnitsText(amount), p.Name);

            p.WaterEntitlement += amount;

            m_controller.EventManager.TriggerWaterRightsGiven(p, amount);

            p.TriggerChanged();

            // FIXME: Should be done via event subscription.
            UpdateHudStatus(p);
        }
开发者ID:justinccdev,项目名称:waterwars,代码行数:13,代码来源:AbstractPlayState.cs

示例3: UpgradeGameAsset

        public override void UpgradeGameAsset(Player p, AbstractGameAsset ga, int newLevel)
        {
            BuyPoint bp = ga.Field.BuyPoint;

            if (!ga.IsBuilt)
                throw new WaterWarsGameLogicException(
                    "{0} tried to upgrade {1} at {2} in {3} but the asset is only partially built",
                    p.Name, ga.Name, bp.Name, bp.Location.RegionName);

            if (newLevel <= ga.Level)
                throw new WaterWarsGameLogicException(
                    "{0} tried to upgrade {1} to level {2} but asset is already at level {3}",
                    p, ga, newLevel, ga.Level);

            if (newLevel > ga.MaxLevel)
                throw new WaterWarsGameLogicException(
                    "{0} tried to upgrade {1} to level {2} but max level of asset is {3}",
                    p, ga, newLevel, ga.MaxLevel);

            int price = ga.ConstructionCosts[newLevel] - ga.ConstructionCosts[ga.Level];

            if (p.Money < price)
                throw new WaterWarsGameLogicException(
                    "{0} has {1}, not enough to upgrade {2} to level {3} which costs {4}",
                    p, p.Money, ga, newLevel, price);

            m_log.InfoFormat(
                "[WATER WARS]: {0} upgrading {1} on {2} in {3} to level {4}",
                p.Name, ga.Name, bp.Name, bp.Location.RegionName, newLevel);

            // Perform the transaction
            p.Money -= price;
            int oldLevel = ga.Level;
            ga.Level = newLevel;
            ga.Name = string.Format("{0} ({1})", ga.InitialNames[ga.Level], ga.Field.Name);
            ga.RevenueThisTurn = m_controller.EconomicDistributor.Allocate(ga.Game.EconomicActivity, ga);

            m_controller.EventManager.TriggerGameAssetUpgraded(ga, oldLevel);

            bp.TriggerChanged();
            p.TriggerChanged();
            ga.TriggerChanged();

            UpdateHudStatus(p);
        }
开发者ID:cmickeyb,项目名称:waterwars,代码行数:45,代码来源:BuildStageState.cs

示例4: SellWaterRights

        public override void SellWaterRights(Player buyer, Player seller, int amount, int salePrice)
        {
            if (buyer.Money < salePrice)
                throw new WaterWarsGameLogicException(
                    string.Format(
                        "Player {0} tried to buy {1} water rights from {2} for {3} but they only have {4}",
                        buyer, amount, seller, salePrice, buyer.Money));

            if (seller.WaterEntitlement < amount)
                throw new WaterWarsGameLogicException(
                    string.Format(
                        "Player {0} tried to sell {1} water rights to {2} but they only have {3}",
                        seller, amount, buyer, WaterWarsUtils.GetWaterUnitsText(seller.WaterEntitlement)));

            m_log.InfoFormat(
                "[WATER WARS]: Player {0} selling {1} water rights to {2} for {3}",
                seller, amount, buyer, salePrice);

            buyer.Money -= salePrice;
            buyer.WaterRightsCostsThisTurn += salePrice;
            seller.Money += salePrice;
            seller.WaterRightsRevenueThisTurn += salePrice;
            buyer.WaterEntitlement += amount;
            seller.WaterEntitlement -= amount;

            m_controller.EventManager.TriggerWaterRightsSold(buyer, seller, amount, salePrice, true);

            buyer.TriggerChanged();
            seller.TriggerChanged();

            // FIXME: Should be done via event subscription.
            UpdateHudStatus(buyer);
            UpdateHudStatus(seller);

            m_controller.Events.PostToAll(
                string.Format(SELL_WATER_RIGHTS_CRAWL_MSG, seller.Name, WaterWarsUtils.GetWaterUnitsText(amount), buyer.Name),
                EventLevel.Crawl);
        }
开发者ID:cmickeyb,项目名称:waterwars,代码行数:38,代码来源:BuildStageState.cs

示例5: SellRights

        public override void SellRights(BuyPoint bp, Player buyer, RightsType type, int salePrice)
        {
            Player seller = Player.None;

            if (type == RightsType.Development || type == RightsType.Combined)
                seller = bp.DevelopmentRightsOwner;
            else
                seller = bp.WaterRightsOwner;

            if (!bp.OwnerActions.ContainsKey("SellDevelopmentRights"))
                throw new WaterWarsGameLogicException(
                    "Player {0} tried to sell development rights on {1} in {2} but they have already sold game assets to the economy on this parcel",
                    seller.Name, bp.Name, bp.Location.RegionName);

            if (buyer.Money < salePrice)
                throw new WaterWarsGameLogicException(
                    "Player {0} tried to buy {1} rights for {2} from {3} for {4} but they only have {5}",
                    buyer, type, bp, seller, salePrice, buyer.Money);

            m_log.InfoFormat(
                "[WATER WARS]: Player {0} selling {1} rights of {2} to {3} for {4}",
                seller, type, bp, buyer, salePrice);

            // Perform the transaction
            if (type == RightsType.Water || type == RightsType.Combined)
                bp.WaterRightsOwner = buyer;

            buyer.Money -= salePrice;
            buyer.LandCostsThisTurn += salePrice;
            seller.Money += salePrice;
            seller.LandRevenueThisTurn += salePrice;

            // If we're selling development rights then we also need to remove any game assets already on the parcel
            if (type == RightsType.Development || type == RightsType.Combined)
            {
                lock (bp.GameAssets)
                {
                    foreach (AbstractGameAsset asset in bp.GameAssets.Values)
                        m_controller.Dispatcher.RemoveGameAssetView(asset);
                }

                bp.RemoveAllGameAssets();
            }

            if (type == RightsType.Development || type == RightsType.Combined)
                TransferDevelopmentRights(bp, buyer);

            m_controller.EventManager.TriggerLandRightsSold(bp, buyer, seller, type, salePrice, true);
            buyer.TriggerChanged();
            seller.TriggerChanged();
            bp.TriggerChanged();

            // FIXME: Should be done via event subscription.
            UpdateHudStatus(buyer);
            UpdateHudStatus(seller);

            m_controller.Events.PostToAll(
                string.Format(SELL_RIGHTS_CRAWL_MSG, seller.Name, type, bp.Name, bp.Location.RegionName, buyer.Name),
                EventLevel.Crawl);
        }
开发者ID:cmickeyb,项目名称:waterwars,代码行数:60,代码来源:BuildStageState.cs

示例6: BuyLandRights

        public override void BuyLandRights(BuyPoint bp, Player buyer)
        {
            if (bp.DevelopmentRightsOwner != Player.None)
                throw new WaterWarsGameLogicException(
                    string.Format(
                        "[WATER WARS]: {0} tried to buy parcel {1} but development rights are already owned by {2}",
                        buyer, bp, bp.DevelopmentRightsOwner));

            if (bp.WaterRightsOwner != Player.None)
                throw new WaterWarsGameLogicException(
                    string.Format(
                        "[WATER WARS]: {0} tried to buy parcel {1} but water rights are already owned by {2}",
                        buyer, bp, bp.WaterRightsOwner));

            if (buyer.Money < bp.CombinedPrice)
                // TODO: Signal this to the player in-world in some way
                throw new WaterWarsGameLogicException(
                    string.Format("[WATER WARS]: Player {0} didn't have enough money to buy {1}", buyer, bp));

            m_log.InfoFormat("[WATER WARS]: Player {0} buying land rights for {1}", buyer, bp);

            buyer.Money -= bp.CombinedPrice;
            buyer.LandCostsThisTurn += bp.CombinedPrice;

            TransferAllRights(bp, buyer);

            buyer.TriggerChanged();
            bp.TriggerChanged();
            m_controller.EventManager.TriggerLandRightsBought(bp, buyer);

            // FIXME: This should be done via events
            UpdateHudStatus(buyer);

            m_controller.Events.PostToAll(
                string.Format(BUY_RIGHTS_CRAWL_MSG, buyer.Name, bp.Name, bp.Location.RegionName),
                EventLevel.Crawl);
        }
开发者ID:cmickeyb,项目名称:waterwars,代码行数:37,代码来源:BuildStageState.cs


注:本文中的Player.TriggerChanged方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。