Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag(ItemTag.Player))
        {
            hasExplosive = ChestController.DoesHaveItem(ItemTag.Tnt);

            if (hasExplosive && !explosionOccured)
            {
                //Explode();
                explosivePlanted    = true;
                explosionOccured    = true;
                messageBroadcasted  = true;
                instantiatedTNT     = (GameObject)Instantiate(TNT, new Vector3(transform.position.x + 1.5f, transform.position.y, transform.position.z), transform.rotation);
                instantiatedTNT.tag = "Untagged";
                //showPopUp("Explosion in " + explosionTimer.ToString() + " seconds...");
                ChestController.RemoveItem(ItemTag.Tnt);
            }
            else if (!messageBroadcasted && !(GameState.gameState.HazardWasDestroyed(ItemTag.Rock1) ||
                                              GameState.gameState.HazardWasDestroyed(ItemTag.Rock2)))
            {
                string message = "You need a TNT to destroy this rock!";
                messageBroadcasted = true;
                ShowPopUp(message);
            }
        }
    }
Exemplo n.º 2
0
 //Removes the item from the item slot
 public void RemoveItem()
 {
     if (item != null)
     {
         item.setInventoryController(inventory);
         if (inventory.PickupItem(item))
         {
             chest.RemoveItem(item);
         }
     }
 }
Exemplo n.º 3
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         //if (hasKey)
         if (ChestController.DoesHaveItem("Key"))
         {
             //gate.GetComponent<Rigidbody2D>().constraints = Rigidbody2DConstraints.None;
             //gate.transform.position += new Vector3(0, 0, -2);
             //gate.transform.localScale -= new Vector3(0.5F, 0, 0);
             //gate.transform.Rotate(0, 0, 90);
             //gate.SetActive(false);
             ChestController.RemoveItem("Key");
             gateAmimation.SetBool("Open", true);
             AudioManager.audioManager.PlaySound(ItemTag.Gate);
             gateCollider.enabled = false;
         }
         else
         {
             string message = "You need a key to open the gate!";
             showPopUp(message);
         }
     }
 }