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


C# Monster.EnemyBasic方法代码示例

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


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

示例1: Combat

  static bool Combat(ref Character player, Monster enemy)
  {
    double maxPlayerHp = player.hp;
    double maxPlayerMp =  player.mp;
    
    bool playerWin = false;

    while(player.hp > 1 && enemy.hp > 1)
    {

      combatstart:
      ConsoleKeyInfo keyPrompt = CombatPrompt(player, enemy);
      Console.Clear();
      if(keyPrompt.Key.ToString().ToLower() == "a")
      {
        Console.WriteLine("You hit the enemy hard, but the monster blocks some damage.");
        WriteDamage(player.CharacterAttack("strong", player, enemy));
        enemy.hp -= player.CharacterAttack("strong", player, enemy);
      }
      else if (keyPrompt.Key.ToString().ToLower() == "s")
      {
        if(player.mp > 0)
        {
          Console.WriteLine("You aim, and strike at the monster's weak point.");
          WriteDamage(player.CharacterAttack("pierce", player, enemy));
          enemy.hp -= player.CharacterAttack("pierce", player, enemy);
          player.mp--;
        }
        else
        {
          Console.WriteLine("You are too fatigued to do that");
          Console.ReadKey(true);
        }
      }
      else if(keyPrompt.Key.ToString().ToLower() == "h")
      {
        if(player.healed) 
        {
          Console.Clear();
          Console.WriteLine("You feel too fatigued to do that again.");
          Console.ReadKey(true);
          goto combatstart;
        }
        Console.WriteLine ("You focus, and your mind repairs itself.");
        Console.WriteLine ("You feel too fatigued to do that again.");
        player.hp = maxPlayerHp;
        player.healed = true;
      }
      else if(keyPrompt.Key.ToString().ToLower() == "d")
      {
        Console.WriteLine("You focus, and attempt to launch a powerful energy beam at the enemy.");
        if(player.mp > 3)
        {
          player.mp -= 4;
          Console.WriteLine("Your energy beam collides with the energy in a massive explosion.");
          player.CharacterAttack("destroy", player, enemy);
          enemy.hp -= player.CharacterAttack("destroy", player, enemy);
        }
        else
        {
          player.mp = 0;
          Console.WriteLine("You send some sparks from your hand, but you feel too drained to launch an energy beam.");
        }
      }
      else if (keyPrompt.Key.ToString().ToLower() == "f")
      {
        player.progress--;
        player.progress--;
        Console.WriteLine("You run back the way you came.");
        goto fleeing;
      }
      else if(keyPrompt.Key.ToString().ToLower() == "g")
      {
        if(player.freeKill)
        {
          enemy.hp = 0;
          Console.WriteLine("You pray to god, and the monster is condemned to hell.");
        }
        else
        {
          Console.WriteLine("You don't feel like God will help again.");
          goto combatstart;
        }
      }
      Console.ReadKey(true);

      if(enemy.hp > 0)
      {
      Console.WriteLine("The enemy returns with an attack of its own!");
      player.hp -= enemy.EnemyBasic(player, enemy);
      Console.ReadKey(true);
      }
    }
    
    if(player.hp >= 1)
    {
      playerWin = true;
      Console.WriteLine("The monster has been slain.");
      Console.ReadKey(true);
    }
//.........这里部分代码省略.........
开发者ID:shaunlazaro,项目名称:ConsoleGame,代码行数:101,代码来源:killall.cs


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