using UnityEngine; using System.Collections; using UnityEngine.UI; public class WeaponShopButton : MonoBehaviour { public PlayerStats stats; // to get access to weapon array public int weaponNumber; public Text wepName; public Text description; public Text cost; public Image imageDisplay; private WeaponStats[] weapons; // Use this for initialization void Start () { stats = GameObject.Find ("Player").GetComponent<PlayerStats> (); weapons = GameObject.Find("Canvas").GetComponent<WeaponList>().weapons; setButton(); } // Update is called once per frame void Update () { } // created by following the 'Creating An In-Game Shop' shop tutorial on unity3d.com // dynamically allocates the shop buttons based on created weapons void setButton() { string costToString = weapons[weaponNumber].cost.ToString(); // convert float to string wepName.text = weapons[weaponNumber].weaponName; description.text = weapons[weaponNumber].weaponDescription; cost.text = costToString; imageDisplay.sprite = weapons[weaponNumber].image; } public void OnClick() { // this is where we will implement buying the weapons based on currency // i.e. : if coins >= weaponCost, then .... // WILL DO LATER - for now, just change weapon stats.setWeapon(weapons[weaponNumber]); } // to display weapon stats when you hover over a weapon public void HoverEnter() { } // to revert back to the original button public void HoverExit() { } }