如何解决此问题,使其不会“出售”相同的Cookie

时间:2019-03-29 00:08:45

标签: visual-studio unity3d

我正在开发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;
        }
    }
}

0 个答案:

没有答案
相关问题