Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class StarDisplay : MonoBehaviour {
  7.  
  8. private Text starText;
  9. private int stars = 100;
  10. public enum Status {SUCCESS, FAILURE};
  11.  
  12. // Use this for initialization
  13. void Start () {
  14. starText = GetComponent<Text> ();
  15. UpdateDisplay ();
  16. }
  17.  
  18. public void AddStars(int amount){
  19. stars += amount;
  20. UpdateDisplay ();
  21. }
  22.  
  23. public Status UseStars (int amount){
  24. if (stars >= amount) {
  25. stars -= amount;
  26. UpdateDisplay ();
  27. return Status.SUCCESS;
  28. }
  29. return Status.FAILURE;
  30. }
  31.  
  32. private void UpdateDisplay(){
  33. starText.text = stars.ToString ();
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement