void OnCollisionEnter(Collision collision)
        {
            // Check if the player was hit.
            if (Deadly && collision.collider.gameObject.CompareTag("Player"))
            {
                // If the player is a minifig or a brick, do an explosion.
                var minifigController = collision.collider.GetComponent <MinifigController>();
                if (minifigController)
                {
                    minifigController.Explode();
                }
                else
                {
                    var brick = collision.collider.GetComponentInParent <Brick>();
                    if (brick)
                    {
                        BrickExploder.ExplodeConnectedBricks(brick);
                    }
                }

                GameOverEvent evt = Events.GameOverEvent;
                evt.Win = false;
                EventManager.Broadcast(evt);
            }

            // Turn on gravity and make non-deadly.
            m_RigidBody.useGravity = true;

            Deadly = false;
        }
Esempio n. 2
0
 void Awake()
 {
     if (m_Instance && m_Instance != this)
     {
         Destroy(this);
     }
     else
     {
         m_Instance = this;
     }
 }