Esempio n. 1
0
        private void OnParticleCollision(GameObject other)
        {
            ICollisionHandler i = CollisionHandler as ICollisionHandler;

            if (i != null)
            {
#if UNITY_4
                int numCollisionEvents = _particleSystem.GetCollisionEvents(other, collisionEvents);
                if (numCollisionEvents != 0)
                {
                    i.HandleCollision(other, collisionEvents, numCollisionEvents);
                }
#elif UNITY_5_3_OR_NEWER
                int numCollisionEvents = _particleSystem.GetCollisionEvents(other, collisionEvents);
                if (numCollisionEvents != 0)
                {
                    i.HandleCollision(other, collisionEvents, numCollisionEvents);
                }
#else
                int numCollisionEvents = _particleSystem.GetCollisionEvents(other, collisionEvents);
                if (numCollisionEvents != 0)
                {
                    i.HandleCollision(other, new List <ParticleCollisionEvent>(collisionEvents), numCollisionEvents);
                }
#endif
            }
        }
Esempio n. 2
0
 private static void HandleItemCollisions(ICollisionHandler collisionHandler, Collection <IGameObject> blockList, Collection <IGameObject> itemList, Collection <IGameObject> pipeList)
 {
     for (int i = 0; i < itemList.Count; i++)
     {
         foreach (IGameObject obj in blockList)
         {
             collisionHandler.HandleCollision(itemList[i], obj);
         }
         foreach (IGameObject obj in pipeList)
         {
             collisionHandler.HandleCollision(itemList[i], obj);
         }
     }
 }
Esempio n. 3
0
 public virtual void Collided(ICollidable i_Collidable)
 {
     if (this is ICollidable && m_CollisionHandler != null)
     {
         m_CollisionHandler.HandleCollision(this as ICollidable, i_Collidable);
     }
 }
Esempio n. 4
0
 public void OnCollisionEnter(Collision col)
 {
     CollisionHandler.HandleCollision(gameObject, col);
     //DestroyObject(this.transform.parent.gameObject);
     Object.Destroy(this.transform.parent.gameObject);
     Debug.Log("collision");
 }
Esempio n. 5
0
 public void OnCollisionEnter(Collision col)
 {
     if (CollisionHandler != null)
     {
         CollisionHandler.HandleCollision(gameObject, col);
     }
 }
 public void OnCollisionEnter(Collision col)
 {
     if (!col.gameObject.CompareTag("Shield"))
     {
         CollisionHandler.HandleCollision(gameObject, col);
     }
 }
Esempio n. 7
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag(Tags.Ball) && canCollide)
     {
         collisionHandler.HandleCollision(collision.gameObject, this);
     }
 }
 public void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "Wall" || col.tag == "Player")
     {
         CollisionHandler.HandleCollision(gameObject, col);
     }
 }
Esempio n. 9
0
 private static void HandleEnemyCollisions(ICollisionHandler collisionHandler, Collection <IGameObject> blockList, Collection <IGameObject> enemyList, Collection <IGameObject> pipeList)
 {
     for (int i = 0; i < enemyList.Count; i++)
     {
         foreach (IGameObject obj in blockList)
         {
             collisionHandler.HandleCollision(enemyList[i], obj);
         }
         for (int j = i + 1; j < enemyList.Count; j++)
         {
             collisionHandler.HandleCollision(enemyList[i], enemyList[j]);
         }
         foreach (IGameObject obj in pipeList)
         {
             collisionHandler.HandleCollision(enemyList[i], obj);
         }
     }
 }
Esempio n. 10
0
 private static void HandleMarioCollisions(ICollisionHandler collisionHandler, IMario mario, Collection <IGameObject> blockList, Collection <IGameObject> enemyList, Collection <IGameObject> itemList, Collection <IGameObject> pipeList)
 {
     foreach (IGameObject obj in blockList)
     {
         collisionHandler.DetectMarioBlockCollisions(mario, obj);
     }
     collisionHandler.HandleMarioBlockCollisions();
     foreach (IGameObject obj in enemyList)
     {
         collisionHandler.HandleCollision(mario, obj);
     }
     foreach (IGameObject obj in itemList)
     {
         collisionHandler.HandleCollision(mario, obj);
     }
     foreach (IGameObject obj in pipeList)
     {
         collisionHandler.HandleCollision(mario, obj);
     }
 }
        private void OnParticleCollision(GameObject other)
        {
            ICollisionHandler i = CollisionHandler as ICollisionHandler;

            if (i != null)
            {
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
                int numCollisionEvents = _particleSystem.GetCollisionEvents(other, collisionEvents);
                if (numCollisionEvents != 0)
                {
                    i.HandleCollision(other, collisionEvents, numCollisionEvents);
                }
#else
                int numCollisionEvents = _particleSystem.GetCollisionEvents(other, collisionEvents);
                if (numCollisionEvents != 0)
                {
                    i.HandleCollision(other, collisionEvents, numCollisionEvents);
                }
#endif
            }
        }
Esempio n. 12
0
        private static void HandleFireBallCollisions(ICollisionHandler collisionHandler, Collection <IGameObject> blockList, Collection <IGameObject> enemyList, Collection <IGameObject> pipeList, IMario mario, Collection <IGameObject> fireBallList)
        {
            for (int i = 0; i < fireBallList.Count; i++)
            {
                foreach (IGameObject obj in blockList)
                {
                    collisionHandler.HandleCollision(fireBallList[i], obj);
                }
                foreach (IGameObject obj in pipeList)
                {
                    collisionHandler.HandleCollision(fireBallList[i], obj);
                }
                foreach (IGameObject obj in enemyList)
                {
                    collisionHandler.HandleCollision(fireBallList[i], obj);
                }

                if (GameUtilities.Game.State.Type == GameStates.Competitive && GameUtilities.GameObjectManager.MarioPlayer2 != null)
                {
                    collisionHandler.HandleCollision(fireBallList[i], mario);
                }
            }
        }
        public void HandleCollision(Collision collision, Level1 level)
        {
            ICollisionHandler handler = handlers[collision.entity1.GetType()];

            if (handler != null)
            {
                handler.HandleCollision(collision, level);
            }

            ICollisionHandler secondHandler = handlers[collision.entity2.GetType()];

            if (secondHandler != null)
            {
                secondHandler.HandleCollision(collision, level);
            }
        }
Esempio n. 14
0
        public void OnCollisionEnter(Collision col)
        {
            // Damaging the player
            if (col.gameObject.CompareTag("Player") && gameObject.transform.parent.CompareTag("EnemyProjectile"))
            {
                Firebolt firebolt = gameObject.transform.parent.GetComponent <Firebolt>();
                col.gameObject.GetComponent <Player>().ChangeHealthBy(-firebolt.damage);
            }

            // Damaging the enemy
            else if (col.gameObject.CompareTag("Enemy") && gameObject.transform.parent.CompareTag("PlayerProjectile"))
            {
                Firebolt firebolt = gameObject.transform.parent.GetComponent <Firebolt>();
                col.gameObject.GetComponent <Player>().ChangeHealthBy(-firebolt.damage);
            }

            CollisionHandler.HandleCollision(gameObject, col);
        }
Esempio n. 15
0
        public void ProcessCollisions(IList <ICollidable> firstEntities, IList <ICollidable> secondEntities, ICollisionHandler collisionHandler)
        {
            collisionTypesDetected.Clear();
            ICollision collision = null;

            foreach (ICollidable firstEntity in firstEntities)
            {
                collisionTypesDetected.Clear();
                foreach (ICollidable secondEntity in secondEntities)
                {
                    if (firstEntity.Hitbox.Intersects(secondEntity.Hitbox) && !firstEntity.Equals(secondEntity))
                    {
                        collision = new CollisionObject(firstEntity, secondEntity);
                        if (!collisionTypesDetected.Contains(collision.FirstEntityRelativePosition.ToString()))
                        {
                            collisionHandler.HandleCollision(collision);
                            collisionTypesDetected.Add(collision.FirstEntityRelativePosition.ToString());
                        }
                    }
                }
            }
        }
Esempio n. 16
0
 public void OnTriggerEnter(Collider otherCollider)
 {
     _handler.HandleCollision(CollisionType.ItemCollector, otherCollider);
 }
Esempio n. 17
0
 public void OnCollisionEnter(Collision col)
 {
     CollisionHandler?.HandleCollision(gameObject, col);
 }
Esempio n. 18
0
 public void OnCollisionEnter(Collision col)
 {
     Debug.Log("" + gameObject + col.collider.name +
               "\nSpeed: " + col.relativeVelocity);
     CollisionHandler.HandleCollision(gameObject, col);
 }
Esempio n. 19
0
 private static void HandleMarioMarioCollisions(ICollisionHandler collisionHandler, IMario mario1, IMario mario2)
 {
     collisionHandler.HandleCollision(mario1, mario2);
 }
Esempio n. 20
0
 public void OnCollisionEnter(Collision col)
 {
     //CollisionHandler.HandleCollision(gameObject, col);
     CollisionHandler.HandleCollision(this.gameObject, col);
 }