示例#1
0
    public void TakeDamage(float damage, AttackType a_type, AttackButton a_btn)
    {
        if (STATS.Get_Current_Action() == Movement_Direction.Blocking)
        {
            STATS.Apply_Damage(damage * MasterController.Controller.GameSettings.Damage_Reduction_From_Block, Base.Health);
            Play_Sound(Base.Blocked_Hit_Sound, .3f);
        }
        else
        {
            STATS.Apply_Damage(damage, Base.Health);
            Play_Sound(Base.Hit_Sound, .3f);
            Coroutine stun;
            float     stunTime = 0f, x_knock = 0f, y_knock = 0f;

            switch (a_type)
            {
            case AttackType.Forward:
                stunTime += MasterController.Controller.GameSettings.Forward_Stun_Time;
                x_knock  += MasterController.Controller.GameSettings.Forward_KB;
                break;

            case AttackType.Back:
                stunTime += MasterController.Controller.GameSettings.Back_Stun_Time;
                x_knock  += MasterController.Controller.GameSettings.Back_KB;
                break;

            case AttackType.Neutral:
                stunTime += MasterController.Controller.GameSettings.Neutral_Stun_Time;
                x_knock  += MasterController.Controller.GameSettings.Neutral_KB;
                break;

            case AttackType.Air:
                stunTime += MasterController.Controller.GameSettings.Air_Stun_Time;
                x_knock  += MasterController.Controller.GameSettings.Air_KB;
                break;

            case AttackType.Crouch:
                stunTime += MasterController.Controller.GameSettings.Crouch_Stun_Time;
                x_knock  += MasterController.Controller.GameSettings.Crouch_KB;
                break;

            case AttackType.Projectile:
                stunTime += MasterController.Controller.GameSettings.Projectile_Speed;
                x_knock  += MasterController.Controller.GameSettings.Projectile_KB;
                break;

            case AttackType.Wall:
                break;
            }
            y_knock = x_knock; //set to same as x
            if (a_btn == AttackButton.Primary)
            {
                stunTime += MasterController.Controller.GameSettings.PrimaryAttack_Stun_Time;
                x_knock  += MasterController.Controller.GameSettings.Primary_KB_X;
                y_knock  += MasterController.Controller.GameSettings.Primary_KB_Y;
            }
            else if (a_btn == AttackButton.Secondary)
            {
                stunTime += MasterController.Controller.GameSettings.SecondaryAttack_Stun_Time;
                x_knock  += MasterController.Controller.GameSettings.Secondary_KB_X;
                y_knock  += MasterController.Controller.GameSettings.Secondary_KB_Y;
            }
            stun = StartCoroutine(ApplyStunToPlayer(stunTime, x_knock, y_knock));
        }
        if (STATS.Get_Current_Stats().Current_Health <= 0)
        {
            if (PNum == 1)
            {
                FindObjectOfType <BattleController>().SetScore(2);
            }
            else if (PNum == 2)
            {
                FindObjectOfType <BattleController>().SetScore(1);
            }
            gameObject.SetActive(false);
        }
        //check health tier
        var t = STATS.Get_Current_Stats().Current_Health_Tier;

        if (t == HealthTier.low)
        {
            playerAnim.SetInteger("HealthTier", 1);
            AddClassMultiplier(MasterController.Controller.GameSettings.LowTier_Primary_Class_Multiplier,
                               MasterController.Controller.GameSettings.LowTier_Secondary_Class_Multiplier);
        }
        else if (t == HealthTier.medium)
        {
            playerAnim.SetInteger("HealthTier", 2);
            AddClassMultiplier(MasterController.Controller.GameSettings.MidTier_Primary_Class_Multiplier,
                               MasterController.Controller.GameSettings.MidTier_Secondary_Class_Multiplier);
        }
    }