Advertisement
Hiitsu

Untitled

Apr 27th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.13 KB | None | 0 0
  1. using System.Collections;
  2. using System;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using System.Timers;
  7.  
  8. public class Boty : MonoBehaviour
  9. {
  10.     GameControl gc;
  11.  
  12.  
  13.     public static int zysk;
  14.     public GameObject BuyButton;
  15.     public float Koszt;
  16.     public int iloscBotow=0;
  17.     public int maxilosc;
  18.  
  19.     public int wartosc;
  20.  
  21.     public Text KosztText;
  22.     public Text iloscBotowText;
  23.  
  24.     public Button buy;
  25.     public Button collect;
  26.  
  27.     private static Timer timer;
  28.  
  29.     public int co_ile;
  30.  
  31.    
  32.    
  33.  
  34.     // Use this for initialization
  35.     void Start()
  36.     {
  37.         timer = new System.Timers.Timer();
  38.         timer.Interval = co_ile * 1000;
  39.         timer.AutoReset = true;
  40.         timer.Enabled = true;
  41.         zysk = wartosc;
  42.     }
  43.    
  44.  
  45.     void Update()
  46.     {
  47.  
  48.        
  49.        
  50.         if (Koszt < 1000)
  51.         { KosztText.text = "cost " + Koszt; }
  52.        if(Koszt >=1000 & Koszt < 1000000)
  53.         { KosztText.text = "cost " + Koszt / 1000 + " K"; }
  54.       if(Koszt >=1000000)
  55.         { KosztText.text = "cost" + Koszt / 1000000 + " KK"; }
  56.       iloscBotowText.text = "Amount " + iloscBotow;
  57.     }
  58.    public void BuyBot()
  59.     {
  60.            
  61.        if(GameControl.AbleToBuy(Koszt))
  62.         {
  63.           GameControl.dodajPW(-Koszt);
  64.            
  65.             iloscBotow = iloscBotow + 1;
  66.            
  67.             if (iloscBotow == maxilosc) { BuyButton.SetActive(false); }
  68.            Koszt = Mathf.Round(Koszt*1.22f);
  69.             timer.Elapsed += new ElapsedEventHandler(ZwiekszPunktyWiedzy);
  70.             timer.Start();
  71.         }
  72.     }
  73.     private static void ZwiekszPunktyWiedzy(object sender, System.Timers.ElapsedEventArgs e) { GameControl.PunktyWiedzy += zysk; }
  74.  
  75. }
  76. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  77. using System.Collections;
  78. using System;
  79. using System.Collections.Generic;
  80. using UnityEngine;
  81. using UnityEngine.UI;
  82. public class GameControl : MonoBehaviour {
  83.  
  84.     public Button ksiazkaButton;
  85.  
  86.     public GameObject BotyPanel;
  87.     public GameObject UpgradePanel;
  88.     public GameObject AchievementPanel;
  89.  
  90.     public Text PunktyWiedzyText;
  91.     public Text iloscKlikniecText;
  92.  
  93.    
  94.  
  95.     public static float PunktyWiedzy;
  96.     public int iloscKlikniec;
  97.     // Use this for initialization
  98.     void Start() {
  99.         UpgradePanel.SetActive(false);
  100.         BotyPanel.SetActive(false);
  101.         AchievementPanel.SetActive(false);
  102.     }
  103.  
  104.     // Update is called once per frame
  105.     void Update() {
  106.  
  107.         PunktyWiedzyText.text = "Points of Knowledge:         " + PunktyWiedzy;
  108.         iloscKlikniecText.text = "Click Amount: " + iloscKlikniec;
  109.     }
  110.     public void PunktyWiedzyZwieksz()
  111.     {
  112.         PunktyWiedzy += 1;
  113.  
  114.     }
  115.     public void inciloscKlikniec()
  116.     {
  117.         iloscKlikniec += 1;
  118.     }
  119.  
  120.     public void showBoty()
  121.     {
  122.         AchievementPanel.SetActive(false);
  123.         BotyPanel.SetActive(true);
  124.         UpgradePanel.SetActive(false);
  125.     }
  126.     public void hideBoty()
  127.     {
  128.         BotyPanel.SetActive(false);
  129.     }
  130.     public void showUpgrady()
  131.     {
  132.         AchievementPanel.SetActive(false);
  133.         UpgradePanel.SetActive(true);
  134.         BotyPanel.SetActive(false);
  135.     }
  136.     public void hideUpgrady()
  137.     {
  138.         UpgradePanel.SetActive(false);
  139.     }
  140.     public void showAchievementy()
  141.     {
  142.         AchievementPanel.SetActive(true);
  143.         BotyPanel.SetActive(false);
  144.         UpgradePanel.SetActive(false);
  145.     }
  146.     public void hideAchievementy()
  147.     {
  148.         AchievementPanel.SetActive(false);
  149.     }
  150.     public  static void dodajPW(float increment)
  151.     {
  152.         PunktyWiedzy += increment;
  153.        
  154.  
  155.     }
  156.     public static bool AbleToBuy(float liczba)
  157.     {
  158.         if (liczba <= PunktyWiedzy)
  159.             return true;
  160.         else
  161.             return false;
  162.     }
  163.     //public static void CoCzas(int wartosc, int ilosc) { PunktyWiedzy += wartosc*ilosc; }
  164.     //public static void SetPunktyWiedzy(float PN)
  165.    // {
  166.    //     this.PunktyWiedzy = PN;
  167.   //  }
  168.   //  public float GetPunktyWiedzy() { return PunktyWiedzy; }
  169.  
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement