Advertisement
Guest User

Untitled

a guest
Feb 11th, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 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.  
  12.     public Button btnBuy;
  13.     public Button btnSteal;
  14.  
  15.     public Text GoldText;
  16.  
  17.     public GameObject MainCamera;
  18.  
  19.     public GameObject Canvas2;
  20.  
  21.     GameObject Child1;
  22.     GameObject Child2;
  23.     GameObject Child3;
  24.  
  25.  
  26.     // Use this for initialization
  27.     void Start ()
  28.     {
  29.         touchingStore = false;
  30.         pressingKey = false;
  31.  
  32.         GoldText = GoldText.GetComponent<Text> ();
  33.  
  34.         Debug.Log (GoldText != null);
  35.         Debug.Log (GetComponent<AudioSource>() != null);
  36.         print ("setting start text");
  37.         GoldText.text = "35";
  38.  
  39.  
  40.         btnBuy.onClick.AddListener (BuyItems);
  41.         btnSteal.onClick.AddListener (StealItems);
  42.     }
  43.  
  44.     void Update ()
  45.     {
  46.         if (CrossPlatformInputManager.GetButtonDown ("EnterStore") == true) {
  47.             pressingKey = true;
  48.         }
  49.     }
  50.  
  51.     void OnTriggerEnter2D (Collider2D coll)
  52.     {
  53.         if (coll.gameObject.tag == "Store") {
  54.             if (GameObject.Find ("Canvas2(Clone)") == null && pressingKey == true) {
  55.                 touchingStore = true;
  56.                 Instantiate (Canvas2);
  57.             }
  58.         }
  59.     }
  60.  
  61.     public void BuyItems ()
  62.     {
  63.         print ("Changing text?");
  64.         GoldText.text = "2";
  65.     }
  66.  
  67.     public void StealItems ()
  68.     {
  69.         KillPlayerOnCollision.attack = true;
  70.         Child1 = GameObject.Find ("Canvas2(Clone)").transform.GetChild (0).gameObject;
  71.         Child1.SetActive (false);
  72.         Child2 = GameObject.Find ("Canvas2(Clone)").transform.GetChild (1).gameObject;
  73.         Child2.SetActive (false);
  74.         Child3 = GameObject.Find ("Canvas2(Clone)").transform.GetChild (2).gameObject;
  75.         Child3.SetActive (false);
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement