Advertisement
jretchy

Untitled

May 17th, 2022
449
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     bool playerHasPoints = false;
  3.  
  4.     bool canBuyFirstSkill = false;
  5.     bool canBuySecondSkill = false;
  6.     bool canBuyThirdSkill = false;
  7.     bool canBuyFourthSkill = false;
  8.  
  9.     public Button firstButton;
  10.     public Button secondButton;
  11.     public Button thirdButton;
  12.     public Button fourthButton;
  13.  
  14.     public GameObject firstPurchase;
  15.     public GameObject secondPurchase;
  16.     public GameObject thirdPurchase;
  17.     public GameObject fourthPurchase;
  18.  
  19.     public static int IQ = 0;
  20.  
  21.     bool buttonInteractable;
  22.  
  23.     [Header("Audio")]
  24.     public AudioSource myFx;
  25.     public AudioClip SkillUpgraded;
  26.     public AudioClip cantBuySkill;
  27.     public AudioClip hoverFx;
  28.  
  29.     public void BuySkillSound()
  30.     {
  31.         myFx.PlayOneShot(SkillUpgraded);
  32.     }
  33.  
  34.     public void cantBuySkillSound()
  35.     {
  36.         myFx.PlayOneShot(cantBuySkill);
  37.     }
  38.  
  39.     public void HoverSound()
  40.     {
  41.         myFx.PlayOneShot(hoverFx);
  42.     }
  43.  
  44.     private void Start()
  45.     {
  46.         firstPurchase.SetActive(false);
  47.         secondPurchase.SetActive(false);
  48.         thirdPurchase.SetActive(false);
  49.         fourthPurchase.SetActive(false);
  50.     }
  51.  
  52.     private void Update()
  53.     {
  54.         if (Points.pointsValue >= 1)
  55.         {
  56.             playerHasPoints = true;
  57.             buttonInteractable = true;
  58.         }
  59.         else if (Points.pointsValue < 1)
  60.         {
  61.             playerHasPoints = false;
  62.             buttonInteractable = false;
  63.         }
  64.  
  65.         if (playerHasPoints == true)
  66.         {
  67.             canBuyFirstSkill = true;
  68.         }
  69.     }
  70.  
  71.     public void FirstSkillPurchase()
  72.     {
  73.         if (playerHasPoints == true & canBuyFirstSkill == true & buttonInteractable == true)
  74.         {
  75.             IQ += 1;
  76.             firstButton.interactable = false;
  77.             Points.pointsValue -= 1;
  78.             firstPurchase.SetActive(true);
  79.             canBuySecondSkill = true;
  80.             canBuyFirstSkill = false;
  81.             BuySkillSound();
  82.         }
  83.         else
  84.         {
  85.             cantBuySkillSound();
  86.         }
  87.     }
  88.  
  89.     public void SecondSkillPurhchase()
  90.     {
  91.         if (playerHasPoints == true && canBuySecondSkill == true & buttonInteractable == true)
  92.         {
  93.             IQ += 1;
  94.             secondButton.interactable = false;
  95.             Points.pointsValue -= 1;
  96.             secondPurchase.SetActive(true);
  97.             canBuyThirdSkill = true;
  98.             canBuySecondSkill = false;
  99.             BuySkillSound();
  100.         }
  101.         else
  102.         {
  103.             cantBuySkillSound();
  104.         }
  105.     }
  106.  
  107.     public void ThirdSkillPurchase()
  108.     {
  109.         if (playerHasPoints == true && canBuyThirdSkill == true & buttonInteractable == true)
  110.         {
  111.             IQ += 1;
  112.             thirdButton.interactable = false;
  113.             Points.pointsValue -= 1;
  114.             thirdPurchase.SetActive(true);
  115.             canBuyFourthSkill = true;
  116.             canBuyThirdSkill = false;
  117.             BuySkillSound();
  118.         }
  119.         else
  120.         {
  121.             cantBuySkillSound();
  122.         }
  123.     }
  124.  
  125.     public void FouthSkillPurchase()
  126.     {
  127.         if (playerHasPoints == true && canBuyFourthSkill == true & buttonInteractable == true)
  128.         {
  129.             IQ += 1;
  130.             fourthButton.interactable = false;
  131.             Points.pointsValue -= 1;
  132.             fourthPurchase.SetActive(true);
  133.             canBuyFourthSkill = false;
  134.             BuySkillSound();
  135.         }
  136.         else
  137.         {
  138.             cantBuySkillSound();
  139.         }
  140.     }
  141.  
  142.     public void DeactivateButtons()
  143.     {
  144.         if (buttonInteractable == false)
  145.         {
  146.             firstButton.interactable = false;
  147.             secondButton.interactable = false;
  148.             thirdButton.interactable = false;
  149.             fourthButton.interactable = false;
  150.         }
  151.     }
  152.  
  153.  
  154.     public void ResetPoints()
  155.    
  156.     {
  157.         firstPurchase.SetActive(false);
  158.         secondPurchase.SetActive(false);
  159.         thirdPurchase.SetActive(false);
  160.         fourthPurchase.SetActive(false);
  161.  
  162.         canBuyFirstSkill = true;
  163.         canBuySecondSkill = false;
  164.         canBuyThirdSkill = false;
  165.         canBuyFourthSkill = false;
  166.  
  167.         firstButton.interactable = true;
  168.         secondButton.interactable = true;
  169.         thirdButton.interactable = true;
  170.         fourthButton.interactable = true;
  171.  
  172.         IQ = 0;
  173.     }
Advertisement
RAW Paste Data Copied
Advertisement