Example #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.name == "Foliage")
        {
            TreeShakeManager.ShakeTree(other.gameObject, other.gameObject.GetComponent <MeshRenderer>());
        }

        if (other.gameObject.name.Contains("Shield"))
        {
            hitByShield = true;
            if (icodescript != null)
            {
                SendFlying(true);
            }
            else
            {
                PlayerManager.GetMainPlayer().BounceCharacter(false, this.gameObject, false, false);
                StartCoroutine("WaitForShield");
            }
        }
    }
Example #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);
                    }
                }
            }
        }
    }