我正在开发2D游戏,并且具有自动销售功能,但是当购买了1个以上的商店时,它“出售”相同的cookie并记入其中的信用额。
public class AutoSell : MonoBehaviour
{
public bool SellingCookie = false;
public static int CashIncrease = 1;
public int InternalIncrease;
void Update()
{
CashIncrease = GlobalShop.shopPerSec;
InternalIncrease = CashIncrease;
if (SellingCookie == false)
{
SellingCookie = true;
StartCoroutine(SellTheCookie());
}
}
IEnumerator SellTheCookie()
{
if (GlobleCookies.CookieCount <= 0)
{
SellingCookie = false;
}
else
{
GlobleCash.CashCount += InternalIncrease;
GlobleCookies.CookieCount -= 1;
yield return new WaitForSeconds(1);
SellingCookie = false;
}
}
}