Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityStandardAssets.CrossPlatformInput;
- using UnityEngine.UI;
- using System.Collections;
- public class StoreManager : MonoBehaviour
- {
- public bool touchingStore;
- public bool pressingKey;
- public Button btnBuy;
- public Button btnSteal;
- public Text GoldText;
- public GameObject MainCamera;
- public GameObject Canvas2;
- GameObject Child1;
- GameObject Child2;
- GameObject Child3;
- // Use this for initialization
- void Start ()
- {
- touchingStore = false;
- pressingKey = false;
- GoldText = GoldText.GetComponent<Text> ();
- Debug.Log (GoldText != null);
- Debug.Log (GetComponent<AudioSource>() != null);
- print ("setting start text");
- GoldText.text = "35";
- btnBuy.onClick.AddListener (BuyItems);
- btnSteal.onClick.AddListener (StealItems);
- }
- void Update ()
- {
- if (CrossPlatformInputManager.GetButtonDown ("EnterStore") == true) {
- pressingKey = true;
- }
- }
- void OnTriggerEnter2D (Collider2D coll)
- {
- if (coll.gameObject.tag == "Store") {
- if (GameObject.Find ("Canvas2(Clone)") == null && pressingKey == true) {
- touchingStore = true;
- Instantiate (Canvas2);
- }
- }
- }
- public void BuyItems ()
- {
- print ("Changing text?");
- GoldText.text = "2";
- }
- public void StealItems ()
- {
- KillPlayerOnCollision.attack = true;
- Child1 = GameObject.Find ("Canvas2(Clone)").transform.GetChild (0).gameObject;
- Child1.SetActive (false);
- Child2 = GameObject.Find ("Canvas2(Clone)").transform.GetChild (1).gameObject;
- Child2.SetActive (false);
- Child3 = GameObject.Find ("Canvas2(Clone)").transform.GetChild (2).gameObject;
- Child3.SetActive (false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement