Пример #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log(weaponActive.ToString());

        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);
                        has.RandomizeSfx(stab0, stab1, stab2, stab3);
                        ph.ReceiveDamage(Utility.GetSpearDamageAmount(ea.GetSpear(), es.GetEnemyPower(), ea.GetEmberPercentage()));
                        damaged = true;
                        BloodEffect(other.transform.parent.transform);

                        if (ea.GetEmber())
                        {
                            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(Utility.GetSpearDamageAmount(ea.GetSpear(), es.GetEnemyPower(), ea.GetEmberPercentage()));
                        damaged = true;
                        BloodEffect(other.transform.parent.transform);

                        if (ea.GetEmber())
                        {
                            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(Utility.GetSpearDamageAmount(ea.GetSpear(), es.GetEnemyPower(), ea.GetEmberPercentage()));
                    damaged_shield = true;

                    if (ea.GetEmber())
                    {
                        HotParticlesForShield(other.transform);
                    }
                    else
                    {
                        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);
                    }
                }
            }
        }
    }