Ejemplo n.º 1
0
        public void HandleCollision(GameObject obj, Collision c)
        {
            if (collided)
            {
                // already collided, don't do anything
                return;
            }

            // stop the projectile
            collided = true;
            Stop();

            // destroy particle systems after a slight delay
            if (ProjectileDestroyParticleSystemsOnCollision != null)
            {
                foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision)
                {
                    GameObject.Destroy(p);
                }
            }

            // play collision sound
            if (ProjectileCollisionSound != null)
            {
                ProjectileCollisionSound.Play();
            }

            if (c.collider.tag.Equals("Monster"))
            {
                Monster monster = c.collider.gameObject.GetComponent <Monster>();
                monster.takeDamage(bulletDamage, firstElementType, secondElementType);

                // increament the level of all elements
                fireLevelController.IncrementElement(1);
                waterLevelController.IncrementElement(1);
                earthLevelController.IncrementElement(1);
                windLevelController.IncrementElement(1);
            }

            // if we have contacts, play the collision particle system and call the delegate
            if (c.contacts.Length != 0)
            {
                ProjectileExplosionParticleSystem.transform.position = c.contacts[0].point;
                ProjectileExplosionParticleSystem.Play();
                FireBaseScript.CreateExplosion(c.contacts[0].point, ProjectileExplosionRadius, ProjectileExplosionForce);
                if (CollisionDelegate != null)
                {
                    CollisionDelegate(this, c.contacts[0].point);
                }
            }
        }
Ejemplo n.º 2
0
        void ITriggerHandler.OnTriggerStay(GameObject obj, Collider c)
        {
            if (Time.time > nextTickTimer)
            {
                Debug.Log("[FireConstantBaseScript.OnTriggerStay] GameObject: " + obj + " | Collision: " + c);

                if (c.tag.Equals("Monster"))
                {
                    // damage the monster
                    Monster monster = c.gameObject.GetComponent <Monster>();
                    if (dotDamage != 0)
                    {
                        monster.takeDamage(dotDamage, firstElementType, secondElementType);
                        // increament the level of all elements
                        fireLevelController.IncrementElement(dotFireGain);
                        waterLevelController.IncrementElement(dotWaterGain);
                        earthLevelController.IncrementElement(dotEarthGain);
                        windLevelController.IncrementElement(dotWindGain);
                    }
                }

                nextTickTimer = Time.time + dotTickRateSeconds;
            }
        }