예제 #1
0
    public void HandleAction(float delay, InputManager.attackType type)
    {
        if (!isAttacking && !isDefending && !TM.calibrationFlag)
        {
            return;
        }

        IV.Spawn(type);

        //Handle Attack
        if (isAttacking)
        {
            switch (atkStyle)
            {
            case attackStyle.pattern:
                int index;
                if (TM.CheckPattern(delay, type, out index))
                {
                    Debug.Log("Attack successful!");
                    AnM.PlayerAttack(type);
                    currentPattern.MatchPattern(index);
                }
                else
                {
                    AnM.PlayerTrip();
                    IV.Disable();
                    isAttacking = false;
                }
                break;

            case attackStyle.free:
            default:
                if (TM.CheckFree(delay))
                {
                    Debug.Log("Successful Attack!");
                    AnM.PlayerAttack(type);
                    float dmg = Mathf.Max(player.GetAttack(type) - enemy.GetDefense(type), 1);
                    enemy.TakeDamage(dmg);
                }
                else
                {
                    AnM.PlayerTrip();
                    IV.Disable();
                    isAttacking = false;
                }
                break;
            }
        }
        //Handle Defense
        if (isDefending)
        {
            if (!matchingEnabled)
            {
                return;
            }
            int index;
            AnM.PlayerDefense(type);
            if (TM.CheckPattern(delay, type, out index))
            {
                Debug.Log("Block successful!");
                currentPattern.MatchPattern(index);
            }
            else
            {
                StartCoroutine(DisableMatching());
            }
        }
    }