Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
2,437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityStandardAssets.CrossPlatformInput;
  3. using UnityEngine.UI;
  4. using System.Collections;
  5.  
  6. public class StoreManager : MonoBehaviour
  7. {
  8.  
  9.     public bool touchingStore;
  10.     public bool pressingKey;
  11.     public bool hasItems = false;
  12.  
  13.     public Button btnBuy;
  14.     public Button btnSteal;
  15.  
  16.  
  17.     public Text GoldText;
  18.  
  19.     public GameObject MainCamera;
  20.  
  21.     public GameObject Canvas2;
  22.  
  23.     GameObject Child1;
  24.     GameObject Child2;
  25.     GameObject Child3;
  26.  
  27.  
  28.     // Use this for initialization
  29.     void Start ()
  30.     {
  31.  
  32.  
  33.         touchingStore = false;
  34.         pressingKey = false;
  35.  
  36.         GoldText = GetComponent<Text> ();
  37.  
  38.         print ("setting start text");
  39.         //DOESN'T CHANGE TEXT
  40.         GoldText.text = "25";
  41.  
  42.  
  43. //      btnBuy.onClick.AddListener (BuyItems);
  44.         btnSteal.onClick.AddListener (StealItems);
  45.     }
  46.  
  47.     void Update ()
  48.     {
  49.         if (CrossPlatformInputManager.GetButtonDown ("EnterStore") == true) {
  50.             pressingKey = true;
  51.         }
  52.     }
  53.  
  54.     void OnTriggerEnter2D (Collider2D coll)
  55.     {
  56.         if (coll.gameObject.tag == "Store") {
  57.             if (GameObject.Find ("Canvas2(Clone)") == null) {
  58.                 touchingStore = true;
  59.                 Instantiate (Canvas2);
  60.             }
  61.         }
  62.            
  63.     }
  64.  
  65.  
  66.     public void BuyItems ()
  67.     {
  68.         //DOESN'T CHANGE TEXT
  69.         print ("Changing text?");
  70.         GoldText.text = "2";
  71.     }
  72.  
  73.     public void StealItems ()
  74.     {
  75.         KillPlayerOnCollision.attack = true;
  76.         Child1 = GameObject.Find ("Canvas2(Clone)").transform.GetChild (0).gameObject;
  77.         Child1.SetActive (false);
  78.         Child2 = GameObject.Find ("Canvas2(Clone)").transform.GetChild (1).gameObject;
  79.         Child2.SetActive (false);
  80.         Child3 = GameObject.Find ("Canvas2(Clone)").transform.GetChild (2).gameObject;
  81.         Child3.SetActive (false);
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement