Creation.cs 2.06 KiB
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Creation : MonoBehaviour {
public Text vitText;
public Text strText;
public Text defText;
public Text agiText;
public Text lucText;
public Text unalocText;
private int vitality;
private int strength;
private int defense;
private int agility;
private int luck;
private int unallocated;
// Use this for initialization
void Start () {
vitality = 5;
strength = 5;
defense = 5;
agility = 5;
luck = 5;
unallocated = 10;
updateScore ();
}
// Update is called once per frame
void Update () {
}
private void updateScore(){
unalocText.text = "Vitality: " + unallocated.ToString ();
vitText.text = "Vitality: " + vitality.ToString ();
strText.text = "Strength: " + strength.ToString ();
defText.text = "Defense: " + defense.ToString ();
agiText.text = "Agility: " + agility.ToString ();
lucText.text = "Luck: " + luck.ToString ();
}
// Incrementing each field, used by + buttons
public void inc_vit(){
if (unallocated > 0) {
unallocated--;
vitality++;
updateScore ();
}
}
public void inc_str(){
if (unallocated > 0) {
unallocated--;
strength++;
updateScore ();
}
}
public void inc_def(){
if (unallocated > 0) {
unallocated--;
defense++;
updateScore ();
}
}
public void inc_agi(){
if (unallocated > 0) {
unallocated--;
agility++;
updateScore ();
}
}
public void inc_luc(){
if (unallocated > 0) {
unallocated--;
luck++;
updateScore ();
}
}
//Decrementing each field, used by - buttons
public void dec_str(){
if (strength > 1) {
strength--;
unallocated++;
updateScore ();
}
}
public void dec_vit(){
if (vitality > 1) {
vitality--;
unallocated++;
updateScore ();
}
}
public void dec_def(){
if (defense > 1) {
defense--;
unallocated++;
updateScore ();
}
}
public void dec_agi(){
if (agility > 1) {
agility--;
unallocated++;
updateScore ();
}
}
public void dec_luc(){
if (luck > 1) {
luck--;
unallocated++;
updateScore ();
}
}
}