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


C# Player.HasBuilding方法代码示例

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


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

示例1: DisplayBuildingCard

        /// <summary>
        /// Displays the building card for a given player. The boolean argument specifies whether or not the player can build a building. When false, the player can only see what he's built.
        /// </summary>
        /// <param name="p">The player whose building card should be displayed.</param>
        /// <param name="canBuild">Whether or not the player can actually build or not.</param>
        /// <returns>The building the player chooses to build.</returns>
        public override Building DisplayBuildingCard( Player p, bool canBuild )
        {
            Building toReturn=null;
            switch( this.Mode )
            {
                case graphicsMode.CLI:
                    foreach( Building b in GameManager.Instance.Buildings )
                    {
                        string ownedStar = p.HasBuilding( b ) ? "***" : string.Empty;
                        Console.WriteLine( "{5}\t{0}: {1} Gold, {2} Wood, {3} Stone, {4} VP", b.Name, b.GoldCost,
                            b.WoodCost, b.StoneCost, b.VictoryPointValue, ownedStar );
                    }
                    if( canBuild )
                    {
                        //bug:14
                        Console.WriteLine( "{0}, you may build the following buildings: ", p.Name );
                        foreach( Building bu in p.BuildableBuildings )
                        {
                            Console.WriteLine( "{0},{1}: {2}", bu.Row, bu.Column, bu.Name );
                        }
                        Console.WriteLine();
                        if( p.HasBuilding( GameManager.Instance.Buildings.GetBuilding( "Crane" ) ) )
                        {
                            Console.WriteLine( "You have a crane so gold prices of buildings in columns 3 and 4 are reduced by 1." );
                            Console.WriteLine();
                        }
                        Console.WriteLine( "Enter 'p' to pass." );
                        string choice = Console.ReadLine();

                        if( choice.Equals( "p", StringComparison.OrdinalIgnoreCase ) )
                        {
                            Console.WriteLine( "{0} passed without building a building.", p.Name );
                            return null;
                        }

                        string[] parsedChoice = choice.Split( ',' );
                        int chosenRow = int.Parse( parsedChoice[0] );
                        int chosenColumn = int.Parse( parsedChoice[1] );
                        toReturn = (Building)GameManager.Instance.Buildings.GetBuilding( chosenRow, chosenColumn ).Clone();
                    }
                    break;
                case graphicsMode.GUI:
                    throw new NotImplementedException();
            }
            return toReturn;
        }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:52,代码来源:UIManager.cs

示例2: HandleTownHall

        private void HandleTownHall( Player p )
        {
            if( p.HasBuilding( GameManager.Instance.Buildings.GetBuilding( "Town Hall" ) ) )
            {
                GoodsChoiceOptions choice = GameManager.Instance.UI.DisplayGetTownHallChoice( p );

                if( choice == GoodsChoiceOptions.None ) // player chose not to use their town hall
                {
                    return;
                }
                else if( choice == GoodsChoiceOptions.PlusTwoToken ) // player chose a plus two token
                {
                    p.PlusTwoTokens--;
                    p.VictoryPoints++;
                }
                else
                {
                    p.RemoveGood( choice );
                    p.VictoryPoints++;
                }
            }
        }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:22,代码来源:AllPhases.cs

示例3: DoPlayerBattle

 /// <summary>
 /// Execute a battle between the player and an enemy.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="enemy"></param>
 public void DoPlayerBattle( Player player, Enemy enemy, int reinforcements )
 {
     int totalStrength = player.TotalStrength + player.BonusStrengthAgainstEnemy( enemy ) + reinforcements;
     if( totalStrength > enemy.Strength ) // player wins
     {
         GameManager.Instance.UI.DisplayBattleResults( player, enemy, BattleResults.Victory );
         this.AwardPlayerAfterBattle( player, enemy );
     }
     else if( totalStrength == enemy.Strength ) // player ties
     {
         // Check if the player has the stone wall, which allows a tie to count as a victory
         if( player.HasBuilding( GameManager.Instance.GetBuilding( "Stone Wall" ) ) )
         {
             GameManager.Instance.UI.DisplayBattleResults( player, enemy, BattleResults.Victory );
             this.AwardPlayerAfterBattle( player, enemy );
         }
         else
         {
             GameManager.Instance.UI.DisplayBattleResults( player, enemy, BattleResults.Tie );
         }
     }
     else // player loses
     {
         GameManager.Instance.UI.DisplayBattleResults( player, enemy, BattleResults.Loss );
     }
 }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:31,代码来源:AllPhases.cs

示例4: HandleMerchantsGuild

 private void HandleMerchantsGuild( Player p )
 {
     if( p.HasBuilding( GameManager.Instance.Buildings.GetBuilding( "Merchants' Guild" ) ) )
     {
         GameManager.Instance.UI.DisplayMerchantsGuildBonus( p );
         p.Gold++;
     }
 }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:8,代码来源:AllPhases.cs

示例5: HandleStatueAction

 /// <summary>
 /// Allow the player to use his statue if possible.
 /// </summary>
 /// <param name="p">The player.</param>
 private void HandleStatueAction( Player p )
 {
     if( !p.HasBuilding( GameManager.Instance.Buildings.GetBuilding( "Statue" ) ) )
     {
         return;
     }
     else if( !p.MostRecentDiceRoll.AllSameRoll() )
     {
         return;
     }
     else
     {
         GameManager.Instance.UI.DisplayUseStatue( p );
     }
 }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:19,代码来源:AllPhases.cs

示例6: HandleMarket

 private void HandleMarket( Player p )
 {
     if( p.HasBuilding( GameManager.Instance.Buildings.GetBuilding( "Market" ) ) )
     {
         p.AddDie( new KingsburgDie( KingsburgDie.DieTypes.MarketPositive ) );
         p.AddDie( new KingsburgDie( KingsburgDie.DieTypes.MarketNegative ) );
         p.HasUsedMarket = false;
     }
 }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:9,代码来源:AllPhases.cs

示例7: HandleFarms

 private void HandleFarms( Player p )
 {
     if( p.HasBuilding( GameManager.Instance.Buildings.GetBuilding( "Farms" ) ) )
     {
         GameManager.Instance.UI.DisplayFarmBonus( p );
         p.AddDie();
     }
 }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:8,代码来源:AllPhases.cs

示例8: HandleEmbassy

 private void HandleEmbassy( Player p )
 {
     if( p.HasBuilding( GameManager.Instance.Buildings.GetBuilding( "Embassy" ) ) )
     {
         GameManager.Instance.UI.DisplayEmbassyBonus( p );
         p.VictoryPoints++;
     }
 }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:8,代码来源:AllPhases.cs

示例9: HandleCrane

 private bool HandleCrane( Player p, Building built )
 {
     if( p.HasBuilding( GameManager.Instance.Buildings.GetBuilding( "Crane" ) ) )
     {
         if( built.Column == 3 || built.Column == 4 )
         {
             GameManager.Instance.UI.DisplayUseCrane( p );
             return true;
         }
     }
     return false;
 }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:12,代码来源:AllPhases.cs

示例10: HandleChapelAction

 private void HandleChapelAction( Player p )
 {
     if( !p.HasBuilding( GameManager.Instance.Buildings.GetBuilding( "Chapel" ) ) )
     {
         return;
     }
     else if( p.MostRecentDiceRollTotalValue > 7 )
     {
         return;
     }
     else
     {
         GameManager.Instance.UI.DisplayUseChapel( p );
     }
 }
开发者ID:tylerbutler,项目名称:bitworthy,代码行数:15,代码来源:AllPhases.cs


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