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


C# Enemy.Attack方法代码示例

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


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

示例1: Attack

    public bool Attack(Enemy enemy)
    {
        string[] checkObjs = enemy.CanBeDefeatedBy();

        foreach (string obj in checkObjs)
        {
            if (equippedItem != null && equippedItem.ToString().ToLower() == obj.ToLower () && (CheckFatigue() ? true : (Random.Range (0, 11) > 5 ? true : false)))
            {
                hunger = Mathf.Clamp(hunger - enemy.Attack() / 4, 0, 100);
                tiredness = Mathf.Clamp(tiredness - enemy.Attack() / 4, 0, 100);
                return true;
            }
            if (equippedItem == null && obj.ToLower() == "fists" && (CheckFatigue() ? true : (Random.Range (0, 11) > 5 ? true : false)))
                return true;
        }
        hunger = Mathf.Clamp (hunger - enemy.Attack() / 2, 0, 100);
        tiredness = Mathf.Clamp (tiredness - enemy.Attack() / 4, 0, 100);
        return false;
    }
开发者ID:shamushand,项目名称:SPE,代码行数:19,代码来源:Player.cs

示例2: DoActivity

        // Tue die Action
        public override void DoActivity(Enemy e)
        {
            // laufe zu nächstem pfad
            if (_lookAtNextNode)
            {
                PathNode next = _currentPath;

                // schaue zu nächstem wegpunkt
                if (next != null)
                    e.LookAt(next.WayPoint.Location.Position);
            }

            // schaue auf player
            if (_lookAtPlayer)
            {
                e.LookAt(_player.LocationBehavior.Position);
            }

            // greife an
            if (_attack && Main.MainObject.GameManager.GameState.Player.IsAlive)
            {
                e.Attack();
            }

            // laufe gerade aus (richtung wp)
            if (_walk)
            {
                Vector2 moved = Move(e);

                _walkedDistance = (float)(moved.Length() / Main.GameTimeUpdate.ElapsedGameTime.TotalSeconds);
            }
        }
开发者ID:StWol,项目名称:Last-Man,代码行数:33,代码来源:WalkToPlayer.cs

示例3: Attack

        private static void Attack(Player p, Enemy e, int num_figths)
        {
            int EnemyWins = 0;
            int PlayerWins = 0;

            for (int i = 0; i < num_figths; i++)
            {
                p.Hp = 12;
                e.Hp = 10;

                Logger.Log("===============================", ConsoleColor.Red);
                Logger.Log(string.Format("Combat number #{0} starts", i + 1), ConsoleColor.White);
                Logger.Log("===============================", ConsoleColor.Red);

                while (true)
                {
                    p.Attack(e);
                    if (e.Hp <= 0)
                        break;

                    e.Attack(p);
                    if (p.Hp <= 0)
                        break;

                }

                if (p.Hp <= 0)
                {
                    Logger.Log(string.Format("{0}Died!!!", p.Name), ConsoleColor.Yellow);
                    EnemyWins++;
                }
                if (e.Hp <= 0)
                {
                    Logger.Log(string.Format("{0}Died!!!", e.Name), ConsoleColor.Yellow);
                    PlayerWins++;
                }
            }

            float floatx = float.Parse(PlayerWins.ToString());

            Logger.LogTrue(string.Format("Total Fights {0}, {1} wins {2} - {5}%, {3} wins {4} - {6}%",
                num_figths, p.Name,
                PlayerWins, e.Name, EnemyWins,
                (float)PlayerWins / num_figths * 100,
                (float)EnemyWins / num_figths * 100), ConsoleColor.Cyan);
        }
开发者ID:glennwiz,项目名称:Dungeons-and-dragons-Simulator,代码行数:46,代码来源:FightCreator.cs

示例4: TakeDamage

    // True, player lives. False, player dies.
    public bool TakeDamage(Enemy enemy)
    {
        if (enemy.Attack() >= health)
            return false;

        hunger = Mathf.Clamp(hunger - enemy.Attack() / 4, 0, 100);
        tiredness = Mathf.Clamp (tiredness - enemy.Attack() / 2, 0, 100);
        health = Mathf.Clamp (health - enemy.Attack(), 0, 100);
        return true;
    }
开发者ID:shamushand,项目名称:SPE,代码行数:11,代码来源:Player.cs

示例5: Battle

 private void Battle(Sibling sibling, Enemy enemy)
 {
     if(sibling.Weapon.Beats(enemy.Weapon)) {
         sibling.Attack();
         enemy.Die();
     } else if(enemy.Weapon.Beats(sibling.Weapon)) {
         if(sibling.Ability) {
             sibling.UseAbility();
             enemy.Die();
         } else {
             sibling.Die();
             enemy.Attack();
         }
     }
 }
开发者ID:nikibobi,项目名称:LD27,代码行数:15,代码来源:Game.cs


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