Ejemplo n.º 1
0
 private void OnTriggerStay(Collider other)
 {
     // This is the on ship oxygen provider | If the player is within the radius they will gain oxygen
     if (other.gameObject.tag == "ShipOxygen")
     {
         gameObject.GetComponent <Player_Needs>().playerCurrentO2 += Time.deltaTime * 5;
     }
     // Check if the player is standing over the Food pickup item
     if (other.gameObject.tag == "Food")
     {
         // If player does not already have food in their inventory
         if (playerInventory.getPickupAmount(Player_Inventory.Pickups.Food) < 1)
         {
             // Enable the text to inform the player of the key to press to pickup food
             pickupFood.enabled = true;
             if (Input.GetKeyDown(KeyCode.E))
             {
                 // Add food to inventory
                 playerInventory.addPickup(Player_Inventory.Pickups.Food);
                 pickupFood.enabled = false;
                 Destroy(other.gameObject);
             }
         }
     }
     // Check if the player is standing over the PowerCell pickup item
     if (other.gameObject.tag == "PowerCell")
     {
         // If player does not already have power in their inventory
         if (playerInventory.getPickupAmount(Player_Inventory.Pickups.Power) < 1)
         {
             // Enable the text to inform the player of the key to press to pickup powercell
             pickupPowerCell.enabled = true;
             if (Input.GetKeyDown(KeyCode.E))
             {
                 // Add powercell to inventory
                 playerInventory.addPickup(Player_Inventory.Pickups.Power);
                 pickupPowerCell.enabled = false;
                 Destroy(other.gameObject);
             }
         }
     }
     // Check if the player is standing over the OxygenTank pickup item
     if (other.gameObject.tag == "OxygenTank")
     {
         if (playerInventory.getPickupAmount(Player_Inventory.Pickups.Oxygen) < 1)
         {
             // Enable the text to inform the player of the key to press to pickup oxygen tank
             pickupOxygenTank.enabled = true;
             if (Input.GetKeyDown(KeyCode.E))
             {
                 // If player picks up the oxygen tank | Add oxygen tank to inventory
                 playerInventory.addPickup(Player_Inventory.Pickups.Oxygen);
                 pickupOxygenTank.enabled = false;
                 Destroy(other.gameObject);
             }
         }
     }
     // Check if the player is standing over the fire Extinguisher pickup item
     if (other.gameObject.tag == "Extinguisher")
     {
         if (playerInventory.getShipPartAmount(Player_Inventory.ShipPart.Extinguisher) < 1)
         {
             // Enable the text to inform the player of the key to press to pickup fire extinguisher
             pickupFireExt.enabled = true;
             if (Input.GetKeyDown(KeyCode.E))
             {
                 // Add fire extinguisher to inventory
                 playerInventory.addShipPart(Player_Inventory.ShipPart.Extinguisher);
                 pickupFireExt.enabled = false;
                 Destroy(other.gameObject);
             }
         }
     }
     // Check if the player is standing over the Hammer pickup item
     if (other.gameObject.tag == "Hammer")
     {
         if (playerInventory.getShipPartAmount(Player_Inventory.ShipPart.Hammer) < 1)
         {
             // Enable the text to inform the player of the key to press to pickup Hammer
             pickupHammer.enabled = true;
             if (Input.GetKeyDown(KeyCode.E))
             {
                 // Add Hammer to inventory
                 playerInventory.addShipPart(Player_Inventory.ShipPart.Hammer);
                 pickupHammer.enabled = false;
                 Destroy(other.gameObject);
             }
         }
     }
     // Check if the player is standing over the Metal Pipe pickup item
     if (other.gameObject.tag == "Metal Pipe")
     {
         if (playerInventory.getShipPartAmount(Player_Inventory.ShipPart.Pipe) < 1)
         {
             // Enable the text to inform the player of the key to press to pickup Metal Pipe
             pickupPipe.enabled = true;
             if (Input.GetKeyDown(KeyCode.E))
             {
                 // Add Metal Pipe to inventory
                 playerInventory.addShipPart(Player_Inventory.ShipPart.Pipe);
                 pickupPipe.enabled = false;
                 Destroy(other.gameObject);
             }
         }
     }
     // Check if the player is standing over the Spanner pickup item
     if (other.gameObject.tag == "Spanner")
     {
         if (playerInventory.getShipPartAmount(Player_Inventory.ShipPart.Spanner) < 1)
         {
             // Enable the text to inform the player of the key to press to pickup Spanner
             pickupSpanner.enabled = true;
             if (Input.GetKeyDown(KeyCode.E))
             {
                 // Add Spanner to inventory
                 playerInventory.addShipPart(Player_Inventory.ShipPart.Spanner);
                 pickupSpanner.enabled = false;
                 Destroy(other.gameObject);
             }
         }
     }
     // Check if the player is standing over the Spring pickup item
     if (other.gameObject.tag == "Spring")
     {
         if (playerInventory.getShipPartAmount(Player_Inventory.ShipPart.Spring) < 1)
         {
             // Enable the text to inform the player of the key to press to pickup Spring
             pickupSpring.enabled = true;
             if (Input.GetKeyDown(KeyCode.E))
             {
                 // If player picks up the Spring | Add Spring to inventory
                 playerInventory.addShipPart(Player_Inventory.ShipPart.Spring);
                 pickupSpring.enabled = false;
                 Destroy(other.gameObject);
             }
         }
     }
 }