Esempio n. 1
0
    void OnTriggerStay(Collider other)
    {
        if (other.gameObject.GetComponent <AttackRegion> () && mirror.isMirror != other.gameObject.GetComponent <AttackRegion> ().isMirror)
        {
            return;
        }

        if (other.gameObject.GetComponent <AttackRegion> () && !invulnerable)
        {
            AttackRegion attackRegion = other.gameObject.GetComponent <AttackRegion> ();

            if (attackRegion.attacker == AttackRegion.ENEMY && GetComponent <Player> () && !GetComponent <Player> ().isDead)
            {
                if (other.transform.parent && other.transform.parent.gameObject.GetComponent <BladeTrapMover> ())
                {
                    AudioSource.PlayClipAtPoint(bladeTrapMusic, Camera.main.transform.position);
                }
                else if (other.transform.parent && other.transform.parent.gameObject.GetComponent <Enemy> ())
                {
                    AudioSource.PlayClipAtPoint(enemyAttackMusic, Camera.main.transform.position);
                }

                health.Hurt(attackRegion.damage);
                int repelDir = calculateRepelDir(other.gameObject.GetComponent <Transform>().position);
                if (repeller)
                {
                    repeller.Repel(repelDir);
                }
                GetInvincibility();
            }
            else if (attackRegion.attacker == AttackRegion.PLAYER && GetComponent <Enemy> ())
            {
                if (health.health == 1 && attackRegion.damage != 0)
                {
                    AudioSource.PlayClipAtPoint(hitEnemyToDeath, Camera.main.transform.position);
                }
                else
                {
                    AudioSource.PlayClipAtPoint(hitEnemy, Camera.main.transform.position);
                }


                int repelDir;
                if (attackRegion.damage == 0 && health.maxHealth != 1)
                {
                    // Boomerang attacks the enemies with health greater than 1
                    repelDir = Direction.NONE;
                    StartCoroutine(fixedMoving());
                }
                else
                {
                    if (attackRegion.damage == 0)
                    {
                        attackRegion.damage = 1;
                    }

                    health.Hurt(attackRegion.damage);
                    GetInvincibility();
                    repelDir = calculateRepelDir(other.gameObject.GetComponent <Transform> ().position);
                    if (repeller)
                    {
                        repeller.Repel(repelDir);
                    }
                }
            }
        }
    }
Esempio n. 2
0
 void SetAttackRegionAttr(AttackRegion attackRegion, int attackDirection, int damage)
 {
     attackRegion.damage    = damage;
     attackRegion.attacker  = attackerType;
     attackRegion.direction = attackDirection;
 }
Esempio n. 3
0
    // Use this for initialization


    void Start()
    {
        myAttackRegion = GetComponent <AttackRegion>();
    }