Beispiel #1
0
    public void ReceiveDamage(int x)
    {
        if (total_health > 0)
        {
            if (total_health > x)
            {
                total_health -= x;
                healthLoad.transform.localScale = new Vector3(((float)GetEnemyHealth() / totalStartHealth) * startScaleX, healthLoad.transform.localScale.y, healthLoad.transform.localScale.z);
            }
            else
            {
                total_health = 0;
                healthLoad.gameObject.SetActive(false);
                healthBack.gameObject.SetActive(false);
                shieldLoad.gameObject.SetActive(false);
                shieldBack.gameObject.SetActive(false);

                ic.SetIsDead(true);
                ic.GetAnim().SetLayerWeight(ic.GetAnim().GetLayerIndex("Layer1"), 0f);
            }
        }
    }
Beispiel #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if ((other.gameObject.CompareTag("AchillesBody")))
        {
            playerScript = other.transform.parent.GetComponent <Player>();
            ph           = other.transform.parent.GetComponent <PlayerHealth>();


            if (!playerScript.GetAnim().GetCurrentAnimatorStateInfo(1).IsName("Defense"))
            {
                if (infCtrl.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("QuickAttack1"))
                {
                    playerScript.SetIsAttacked(true);
                    playerScript.BackDirection(Utility.EnemyDirection(other.transform.parent.transform, enemy.transform));
                    if (ph.GetPlayerHealth() > 0 && !damaged)
                    {
                        CameraShaker.Instance.ShakeOnce(GameController.Instance.magnitudeValsBig); //float magnitude, float roughness, float fadeInTime, float fadeOutTime
                        has.RandomizeSfx(stab0, stab1, stab2, stab3);
                        ph.ReceiveDamage(damageAmount);
                        damaged = true;
                        BloodEffect(other.transform.parent.transform);
                        HotParticles(other.transform.parent.transform);
                    }
                }

                if (infCtrl.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("StrongAttack1"))
                {
                    playerScript.SetIsAttacked(true);
                    playerScript.BackDirection(Utility.EnemyDirection(other.transform.parent.transform, enemy.transform));
                    if (ph.GetPlayerHealth() > 0 && !damaged)
                    {
                        CameraShaker.Instance.ShakeOnce(GameController.Instance.magnitudeValsBig);
                        has.RandomizeSfx(swing0, swing1, swing2);
                        ph.ReceiveDamage(damageAmount);
                        damaged = true;
                        BloodEffect(other.transform.parent.transform);
                        HotParticles(other.transform.parent.transform);
                    }
                }
            }
        }

        if (other.gameObject.CompareTag("AchillesShield"))
        {
            playerScript = other.transform.parent.parent.parent.parent.parent.GetComponent <Player>();
            ph           = other.transform.parent.parent.parent.parent.parent.GetComponent <PlayerHealth>();

            if (playerScript.GetAnim().GetCurrentAnimatorStateInfo(1).IsName("Defense") &&
                (infCtrl.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("QuickAttack1") ||
                 infCtrl.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("StrongAttack1")))
            {
                if (ph.GetPlayerShieldHealth() > 0 && !damaged_shield)
                {
                    CameraShaker.Instance.ShakeOnce(GameController.Instance.magnitudeValsSmall);
                    ph.ReceiveShieldDamage(damageAmount);
                    damaged_shield = true;

                    HotParticlesForShield(other.transform);
                    DestroyParticles(other.transform);

                    if (other.transform.parent.parent.parent.parent.parent.GetComponent <PlayerState>().GetShield() > 2)
                    {
                        has.RandomizeSfxShieldIron(shieldhit_iron_0, shieldhit_iron_1, shieldhit_iron_2);
                    }
                    else
                    {
                        has.RandomizeSfxShieldWood(shieldhit_wood_0, shieldhit_wood_1, shieldhit_wood_2);
                    }
                }
            }
        }
    }