Skip to content
Snippets Groups Projects
WeaponShopButton.cs 1.17 KiB
using UnityEngine;
using System.Collections;
using UnityEngine.UI;


public class WeaponShopButton : MonoBehaviour {

    public ArenaCombatControl characterLook; // to get access to weapon array
    public int weaponNumber;
    public Text wepName;
    public Text description;
    public Text cost;

	// Use this for initialization
	void Start () {
        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 = characterLook.weapons[weaponNumber].cost.ToString(); // convert float to string
        wepName.text = characterLook.weapons[weaponNumber].weaponName;
        description.text = characterLook.weapons[weaponNumber].weaponDescription;
        cost.text = costToString;
    }

    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
        characterLook.currentWeapon = weaponNumber;
    }
}