示例#1
0
    public IEnumerator Damage(string botName, float bonusDamage, float normalDamage)
    {
        yield return(new WaitForSeconds(1.12f));

        GameObject    bot    = GameObject.Find(botName);
        BotController target = bot.GetComponent <BotController>();

        target.updatingHealth = true;


        if (normalDamage > 0)
        {
            target.attackedSparks.Play();
        }

        //print(target.health);

        //Half damage taken if player has entered guard
        if (target.guardMode && normalDamage > 0)
        {
            target.health   -= (bonusDamage + normalDamage) / 2;
            target.guardMode = false;
            StartCoroutine(target.Animation("IsGuarding"));
        }
        else
        {
            target.health -= bonusDamage + normalDamage;
            if (target.health > target.maxHealth)
            {
                target.health = target.maxHealth;
            }
        }
    }