示例#1
0
    public void GiveDamage(int a)
    {
        if (nowHp == 0)
        {
            if (!CheckState((int)ActionState.dead))
            {
                _animation.SetMotionList(status.alphabet + Bdead);
                actionState = ActionState.dead;
            }
            return;
        }

        if (CheckState((int)ActionState.guard))
        {
            a     /= 3;
            nowHp -= a;

            acceleration  = 2.0f;
            gAcceleration = 1.0f;
            friction      = 0.1f;
            moveSpeed     = 2.0f;
        }
        else if (CheckState((int)ActionState.back_step))
        {
            a     /= 3;
            nowHp -= a;
        }
        else
        {
            nowHp -= a;

            StateController();
            _animation.ReSetAnimation(status.alphabet + Damage);
        }

        if (nowHp <= 0)
        {
            nowHp = 0;
            _animation.SetMotionList(status.alphabet + Bdead);
            actionState = ActionState.dead;
            battleManager.RemoveUnit(this);
        }

        CreateDamageNumber(a);
        battleManager.AddCombo(GetInstanceID());
        soundManager.PlaySE(status.soundEffects [1]);
        breakNumber--;
    }