예제 #1
0
        public void HandleCollision(GameObject obj, Collider2D 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, 0.1f);
                }
            }

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

            // Play the collision particle system
            ProjectileExplosionParticleSystem.transform.position = ProjectileColliderObject.transform.position;
            ProjectileExplosionParticleSystem.Play();
            FireBaseScript.CreateExplosion(ProjectileColliderObject.transform.position, ProjectileExplosionRadius, ProjectileExplosionForce);
            c.gameObject.GetComponent <Health> ().TakeDamage(10);
        }
예제 #2
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, 0.1f);
                }
            }

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

            // 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);
                }
            }
            EnemyHealth enemyHealth = c.gameObject.GetComponent <EnemyHealth> ();

            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(100, c.transform.position);
            }

            PlayerHealth playerHealth = c.gameObject.GetComponent <PlayerHealth> ();

            if (playerHealth != null && playerHealth.currentHealth > 0)
            {
                GameObject player = playerHealth.gameObject;
                if (player.GetComponent <PlayerID>().playerUniqueName != this.ownerName)
                {
                    CmdTellServerWhoGotShot(player.GetComponent <PlayerID>().playerUniqueName, 20);
                    if (playerHealth.currentHealth <= 0)
                    {
                        IncreaseNumberOfKills(this.ownerName);
                    }
                }
            }
        }
예제 #3
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, 0.1f);
                }
            }

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

            if (c.gameObject.tag == "Enemy")
            {
                //Debug.Log("ENEMY");

                float dmg = 0;

                if (ProjectileColliderObject.name == "FireballCollider")
                {
                    dmg = GM.mgr_spells.calculateDamage("FF");
                }

                c.gameObject.GetComponent <MonsterAI>().health -= dmg;
            }


            // 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);
                }
            }
        }
        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, 0.1f);
                }
            }

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

            // if we have contacts, play the collision particle system and call the delegate
            if (c.contacts.Length != 0)
            {
                /*
                 * Collider[] colliders = Physics.OverlapSphere(transform.position, ProjectileExplosionRadius, ProjectileCollisionLayers);
                 * for (int i = 0; i < colliders.Length; i++)
                 * {
                 *  Rigidbody targetRigidbody = colliders[i].GetComponent<Rigidbody>();
                 *
                 *  if (!targetRigidbody)
                 *  {
                 *      continue;
                 *  }
                 *  targetRigidbody.AddExplosionForce(ProjectileExplosionForce, transform.position, ProjectileExplosionRadius);
                 *
                 * }
                 */
                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);
                }
            }
        }
예제 #5
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);
                }
            }
        }
        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, 0.1f);
                }

                GameObject.Destroy(shadowRenderer.gameObject);
            }

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

            // 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);
                }
            }

            //if collide with the player, inflicts damage
            if (c.collider.CompareTag("Player"))
            {
                c.collider.gameObject.SendMessage("ApplyDamage", boss.getFireballStrength(), SendMessageOptions.DontRequireReceiver);
            }
        }
        public void HandleCollision(GameObject obj, Collision c)
        {
            if (collided)
            {
                // already collided, don't do anything
                return;
            }

            print(obj.tag);

            if (c.gameObject.CompareTag("Player"))
            {
                FindObjectOfType <LevelManager>().LevelLost();
            }

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

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

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

            // 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);
                }
            }
        }
        public void HandleCollision(GameObject obj, Collision c)
        {
            //if (collided)
            //{
            //    float damage = 10;

            //    //SendMessageUpwards("TakeDamage", damage);
            //    // 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, 0.1f);
                }
            }

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

            // 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);
                }
            }
        }
        public void HandleCollision(GameObject obj, Collision c)
        {
            //return;
            if (collided)
            {
                // already collided, don't do anything
                return;
            }
            if (name.Equals("Firebolt(Clone)"))
            {
                if (c.collider.name.Equals("Player"))
                {
                    Player t = c.collider.gameObject.GetComponent <Player>();
                    t.hit();
                }
                else if (c.collider.name.Equals("Shield"))
                {
                }
                else
                {
                    return;
                }
            }
            else if (name.Equals("Fireball(Clone)"))
            {
                Debug.Log("HELLO");
                if (c.collider.name.Equals("Enemy(Clone)"))
                {
                    c.collider.gameObject.GetComponent <Enemy>().hit(1);
                }
                else
                {
                    return;
                }
            }
            else
            {
                Debug.Log(name);
            }

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

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

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

            // 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);
                }
            }
        }