SHARE
TWEET

Player Bite Logic

a guest Dec 6th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class PlayerBite : MonoBehaviour {
  7.  
  8.     public GameObject connectedCube;
  9.     public GameObject boxLocation;
  10.  
  11.     public Text gateText;
  12.     public Text roomText;
  13.     public Text endingText;
  14.     public Text finishText;
  15.     public Text coinText;
  16.  
  17.     // Use this for initialization
  18.     void Start () {
  19.         finishText.gameObject.SetActive(false);
  20.     }
  21.    
  22.     // Update is called once per frame
  23.     void Update () {
  24.         if(connectedCube != null)
  25.         {
  26.             connectedCube.transform.position = new Vector3(boxLocation.transform.position.x, connectedCube.transform.position.y, boxLocation.transform.position.z);
  27.         }
  28.     }
  29.  
  30.     private void OnTriggerEnter(Collider other)
  31.     {
  32.         if(other.tag == "Escaped Room")
  33.         {
  34.             roomText.color = Color.green;
  35.         }
  36.  
  37.         if(other.tag == "Finish Level")
  38.         {
  39.             endingText.color = Color.green;
  40.             finishText.gameObject.SetActive(true);
  41.             Time.timeScale = 0;
  42.         }
  43.  
  44.         if(other.tag == "Coin")
  45.         {
  46.             coinText.color = Color.green;
  47.             other.gameObject.SetActive(false);
  48.         }
  49.     }
  50.  
  51.     private void OnTriggerStay(Collider other)
  52.     {
  53.         if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.E))
  54.         {
  55.             if(other.tag == "Lever")
  56.             {
  57.                 other.gameObject.GetComponent<SwitchLogic>().ActivateSwitch();
  58.                 gateText.color = Color.green;
  59.             }
  60.         }
  61.  
  62.         if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.E))
  63.         {
  64.             if(other.tag == "Movable Cube")
  65.             {
  66.                 connectedCube = other.gameObject;
  67.                 //connectedCube.transform.parent = gameObject.transform;
  68.             }
  69.             else if (connectedCube != null)
  70.             {
  71.                 //connectedCube.transform.parent = null;
  72.                 connectedCube = null;
  73.             }
  74.         }
  75.         else
  76.         {
  77.             if(connectedCube != null)
  78.             {
  79.                 //connectedCube.transform.parent = null;
  80.                 connectedCube = null;
  81.             }
  82.         }
  83.     }
  84. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top