Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using TMPro;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6.  
  7. public class MoneyScript : MonoBehaviour
  8. {
  9.     [SerializeField] TextMeshProUGUI MoneyText;
  10.     [SerializeField] Text MultiAmount;
  11.     [SerializeField] Button MultiButton;
  12.     private ColorBlock theColor = new ColorBlock();
  13.  
  14.     double cash = 0;
  15.     double cashToUpgrade = 50.00;
  16.     double gain = 0.5;
  17.     // Start is called before the first frame update
  18.     void Start()
  19.     {
  20.         theColor.normalColor = Color.red;
  21.         theColor.highlightedColor = Color.red;
  22.         theColor.pressedColor = Color.red;
  23.         theColor.disabledColor = Color.red;
  24.         MultiButton.colors = theColor;
  25.         MoneyText.text = "$ 0.00";
  26.         MultiAmount.text = "$ 50.00";
  27.     }
  28.  
  29.     // Update is called once per frame
  30.     void Update()
  31.     {
  32.        
  33.     }
  34.  
  35.     public void ClickMoney()
  36.     {
  37.         cash += (gain);
  38.         MoneyText.text = $"$ {cash:00.00}";
  39.     }
  40.  
  41.     public void ClickMulti()
  42.     {
  43.         if (cash >= cashToUpgrade)
  44.         {
  45.             cash -= cashToUpgrade;
  46.             gain *= 1.5;
  47.             cashToUpgrade *= 2;
  48.             MoneyText.text = $"$ {cash:00.00}";
  49.             MultiAmount.text = $"$ {cashToUpgrade:00.00}";
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement