Exemplo n.º 1
0
 private void OnTriggerStay(Collider other)
 {
     if (Attacking && !hitObject.Contains(other.gameObject.transform.root))
     {
         if (((1 << other.gameObject.layer) & layerMask) != 0)
         {
             hitObject.Add(other.gameObject.transform.root);
             if (other.GetComponentInParent <MonsterBasic>())
             {
                 MonsterBasic monster = other.gameObject.GetComponentInParent <MonsterBasic>();
                 monster.Damaged(AttackDamage, other.ClosestPoint(transform.position));
                 // Quaternion r = p.rotation;
                 // r.y = -r.y
                 GameObject g = Instantiate(HitParticle, other.ClosestPoint(transform.position), Quaternion.identity);
                 Destroy(g, DestroyTime);
             }
             else if (other.GetComponent <PlayerHP>())
             {
                 PlayerHP playerHP = other.gameObject.GetComponent <PlayerHP>();
                 playerHP.Damaged(AttackDamage);
                 if (playerHP.Invulnerability)
                 {
                     return;
                 }
                 GameObject g = Instantiate(HitParticle, other.ClosestPoint(transform.position), Quaternion.identity);
                 Destroy(g, DestroyTime);
             }
         }
     }
 }