Example #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Enemy")
        {
            Enemy e = other.GetComponent <Enemy>();
            if (e.collDamage != 0)
            {
                main.BodyHitReaction(mr, MPB, bodyColor);

                curHealthPoint -= e.collDamage;
                healthPanelScript.HitFunction(curHealthPoint / maxHealthPoint, e.collDamage);

                if (curHealthPoint <= 0)
                {
                    main.PlayerDie(this);
                }
            }
        }
    }
Example #2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            Player p = main.player;

            // обнуляем позиции по У
            transform.position = new Vector3(transform.position.x, 0, transform.position.z);
            if (p != null)
            {
                p.transform.position = new Vector3(p.transform.position.x, 0, p.transform.position.z);
            }

            // враг лечит игрока
            if (collHeal != 0 && p.curHealthPoint < p.maxHealthPoint)
            {
                p.curHealthPoint += collHeal; if (p.curHealthPoint > p.maxHealthPoint)
                {
                    p.curHealthPoint = p.maxHealthPoint;
                }
                //p.healthPanelScript.HealFunction(p.curHealthPoint / p.maxHealthPoint, collHeal);
                //p.UIHealthRefresh();
                p.playerBarsScript.RefreshHealth(p.curHealthPoint / p.maxHealthPoint, p.curHealthPoint);
            }

            // игрок дамажит врага первым
            main.BodyHitReaction(mr, MPB, bodyColor);
            float damage;
            if (p.timerForRage > 0)
            {
                damage = p.rageCollDamage;
            }
            else
            {
                damage = p.collDamage;
            }
            curHealthPoint -= damage;
            healthPanelScript.HitFunction(curHealthPoint / maxHealthPoint, damage);

            p.swishBlade.SetActive(false);
            p.swishBlade.SetActive(true);

            if (curHealthPoint <= 0)
            {
                main.EnemyDie(this);
            }
            else // если враг не умер, он в ответ дамажит игрока
            {
                healthPanel.gameObject.SetActive(true);

                if (collDamage > 0 && p.timerForRage <= 0)
                {
                    main.BodyHitReaction(p.mr, p.MPB, p.bodyColor);

                    p.curHealthPoint -= collDamage; if (p.curHealthPoint < 0)
                    {
                        p.curHealthPoint = 0;
                    }
                    //p.healthPanelScript.HitFunction(p.curHealthPoint / p.maxHealthPoint, collDamage);
                    //p.UIHealthRefresh();
                    p.playerBarsScript.RefreshHealth(p.curHealthPoint / p.maxHealthPoint, p.curHealthPoint);

                    if (p.curHealthPoint <= 0)
                    {
                        main.PlayerDie(p);
                    }
                }
            }
        }
    }