- Home /
how to make multiple purchase buttons in just 2 scripts?
I am trying to make a 2d clicker game and am unsure on how to make multiple purchase buttons without there being an error. In my game, I already have a purchase button up and working, but when i duplicate the scripts to make a second, it does not work. So, i decided to put the different varibles into one script but that also does not work for me. As for my scripts, i have a seperate one defining my variable you are to purchase, so it goes by global. For example, (GlobalBaker). All I really need to know is how to add multiple variable into these scripts known as, PurchaseLog and AutoFloppa. I already have the global script set up for my new purchase button and it is called GlobalFloppaFamily. So, how would i seperate these variables into my 2 scripts so that it works properly? My first purchase button and global is also displayed in these scripts.
PurchaseLog Script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PurchaseLog : MonoBehaviour {
public GameObject AutoFloppa;
public AudioSource playSound;
public void StartAutoFloppa()
{
playSound.Play();
AutoFloppa.SetActive(true);
GlobalFloppaCash.FloppaCashCount -= GlobalBabyFloppa.babyfloppaValue;
GlobalBabyFloppa.babyfloppaValue *= 2;
GlobalBabyFloppa.turnOffButton = true;
GlobalBabyFloppa.babyfloppaPerSec += 1;
GlobalBabyFloppa.numberOfBabyFloppa +=1;
}
}
AutoFloppa Script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class AutoFloppa : MonoBehaviour {
public bool CreatingFloppa = false;
public static int FloppaIncrease = 1;
public int InternalIncrease;
void Update () {
FloppaIncrease = GlobalBabyFloppa.babyfloppaPerSec;
InternalIncrease = FloppaIncrease;
if (CreatingFloppa == false)
{
CreatingFloppa = true;
StartCoroutine(CreateTheFloppa());
}
}
IEnumerator CreateTheFloppa () { GlobalFloppa.FloppaCount += InternalIncrease; yield return new WaitForSeconds (1); CreatingFloppa = false; } }