Exemplo n.º 1
0
 void OnTriggerEnter(Collider other)
 {
     if (!other.isTrigger)
     {
         if (other.gameObject.GetComponent <NPCCage>() != null)
         {
             other.gameObject.GetComponent <NPCCage>().CageHit();
         }
         else
         {
             if (other.gameObject.name != "LeafBox" && other.gameObject.layer == 15)
             {
                 currentEnemy = other.gameObject.GetComponent <EnemyHP>();
                 if (currentEnemy != null && currentEnemy.isDark && !currentEnemy.invincible)
                 {
                     currentEnemy.health -= 100;
                     if (currentEnemy.health <= 0 && !currentEnemy.infiniteHealth)
                     {
                         currentEnemy.Death();
                     }
                     else
                     {
                         currentEnemy.BeenHit(true, -1);
                     }
                 }
                 //    BurstDrop();
             }
             else
             {
                 if (other.gameObject.name != "LeafBox" && Physics.Raycast(this.transform.position, -Vector3.up, out groundHit, 2f, whatIsCollidable) && groundHit.normal.y >= 0.75f)
                 {
                 }
                 else
                 {
                     lbo = other.gameObject.GetComponentInParent <LeafBoxObstacle>();
                     if (lbo != null)
                     {
                         //   BurstDrop();
                         if (lbo.boxType == 5)
                         {
                             lbo.DestroyBox();
                         }
                         else
                         {
                             lbo.Wrong();
                             PlayerManager.GetMainPlayer().PlayBlockStar();
                         }
                     }
                 }
             }
         }
         BurstDrop();
     }
 }
Exemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        if (thisCollider == null)
        {
            thisCollider = this.GetComponent <Collider>();
        }

        if (isWindball && activeAttack)
        {
            if (Physics.Linecast(this.transform.position - (this.GetComponent <Rigidbody>().velocity.normalized *2f), this.transform.position + (this.GetComponent <Rigidbody>().velocity.normalized *5f), out raycast, tpc.whatIsGround) &&
                raycast.collider == other && raycast.normal.y < tpc.groundTolerance && !raycast.collider.gameObject.name.Contains("Button"))
            {
                StopWindball();
                activeAttack = false;
            }
        }

        if (activeAttack)
        {
            if (other.gameObject.name == "Foliage")
            {
                TreeShakeManager.ShakeTree(other.gameObject, other.gameObject.GetComponent <MeshRenderer>());
            }

            if (other.gameObject.layer == enemyLayer)
            {
                Physics.IgnoreCollision(thisCollider, other, false);
                hitColliders.Add(other);

                currentEnemy = other.gameObject.GetComponent <EnemyHP>();
                //    Physics.IgnoreCollision(tpc.gameObject.GetComponent<Collider>(), other, true);

                //    StopCoroutine("InvinceDelay");
                //    coroutes.Add(StartCoroutine("InvinceDelay", other));

                if (this.gameObject.name == "Stone Attack")
                {
                    StartCoroutine(StoneBounce());
                }

                if (currentEnemy != null && !currentEnemy.invincible && !currentEnemy.damageOnly)
                {
                    tpc.HitAnEnemy(other.gameObject.transform.position, isWindball, currentEnemy.infiniteHealth);

                    if (!isWindball && tpc.pID == 0)
                    {
                        if (tpc.elfPower)
                        {
                            addedAttack = 1;
                        }
                        else
                        {
                            addedAttack = 0;
                        }
                    }

                    currentEnemy.health -= (attackAmount + addedAttack);
                    if (currentEnemy.health <= 0 && !currentEnemy.infiniteHealth)
                    {
                        currentEnemy.Death();
                    }
                    else
                    {
                        currentEnemy.BeenHit(isWindball, tpc.pID);
                    }
                }
            }

            if (other.gameObject.layer == 0 && !other.isTrigger)
            {
                if (other.gameObject.GetComponentInParent <EnemyBarrier>())
                {
                    if (isWindball)
                    {
                        StopWindball();
                    }
                    else
                    {
                        tpc.HitPushBack(tpc.transform.position - other.gameObject.transform.position);
                    }
                }
            }
        }
    }