Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class globalValues : MonoBehaviour {
- public enum TextType { money, hitpoints }
- public static int moneys = 0;
- public static int theHp = 100;
- public Text moneyText;
- public Text hpText;
- public static Text _moneyText;
- public static Text _hpText;
- private void Start()
- {
- _moneyText = moneyText;
- _hpText = hpText;
- SetText(TextType.money, _moneyText, theHp);
- SetText(TextType.hitpoints, _hpText, moneys);
- }
- public static void alterMoney(int addval)
- {
- moneys += addval;
- SetText(TextType.hitpoints, _moneyText, moneys);
- }
- public static void alterHp(int damage)
- {
- theHp -= damage;
- SetText(TextType.money, _hpText, theHp);
- if (theHp < 0)
- {
- //endgame
- }
- }
- public static void SetText(TextType type, Text text, int value)
- {
- switch (type)
- {
- case TextType.money:
- text.text = "Money: " + value.ToString();
- break;
- case TextType.hitpoints:
- text.text = "HP: " + value.ToString();
- break;
- default:
- break;
- }
- }
- }
Add Comment
Please, Sign In to add comment