Example #1
0
    void Awake()
    {
        if (singleton != null)
        {
            enabled = false;
            Destroy(this);
            return;
        }
        singleton = this;

        treeEMs = new ParticleSystem.EmissionModule[treeParticles.Length];
        for (int t = 0; t < treeParticles.Length; t++)
        {
            treeEMs[t] = treeParticles[t].GetComponent <ParticleSystem>().emission;
        }
        treePinkEMs = new ParticleSystem.EmissionModule[treeParticlesPink.Length];
        for (int t = 0; t < treeParticlesPink.Length; t++)
        {
            treePinkEMs[t] = treeParticlesPink[t].GetComponent <ParticleSystem>().emission;
        }
        treeYellowEMs = new ParticleSystem.EmissionModule[treeParticlesYellow.Length];
        for (int t = 0; t < treeParticlesYellow.Length; t++)
        {
            treeYellowEMs[t] = treeParticlesYellow[t].GetComponent <ParticleSystem>().emission;
        }
        treeSnowEMs = new ParticleSystem.EmissionModule[treeParticlesSnow.Length];
        for (int t = 0; t < treeParticlesSnow.Length; t++)
        {
            treeSnowEMs[t] = treeParticlesSnow[t].GetComponent <ParticleSystem>().emission;
        }
    }
Example #2
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 #3
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);
                    }
                }
            }
        }
    }