Beispiel #1
0
    // QR found by cam handler
    private void HandleOnQRCodeFound(ZXing.BarcodeFormat barCodeType, string barCodeValue)
    {
        QRCodeManager.Instance.StopScanning();
        Product prod = Product.Parse(barCodeValue);

        if (prod == null)
        {
            QRCode qr = QRCode.QRParse(barCodeValue);
            if (ValidQR(qr.RawData))
            {
                UserUtilities.AllocatePoints(qr.TokenValue);
                IndicateScore(qr.TokenValue, true);
                SoundManager.Instance.PlaySound("CoinCollect");

                GameManager.Instance.analytics.LogEvent(new EventHitBuilder().SetEventCategory("Token Distribution").SetEventAction(qr.QRType.ToString()).SetEventValue(qr.TokenValue));

                if (qr.QRType != QRCode.QRTypes.Tokens)
                {
                    GameManager.Organizations Org = (GameManager.Organizations)Enum.Parse(typeof(GameManager.Organizations), qr.QRType.ToString());
                    if (GameManager.Instance.MiniGameEnabledOrgs.Contains(Org))
                    {
                        GameManager.Instance.Unlock(Org);
                    }
                }
            }
            else
            {
                DisplayNotification(true, "You have already redeemed this reward today.");
            }
        }
        else
        {
            GameObject        Popup = Instantiate(Confirmtion_Prefab, gameObject.transform);
            ConfirmationPopup conf  = Popup.GetComponent <ConfirmationPopup>();
            conf.prod         = prod;
            conf.Message.text = "Are you certain you would like to spend " + prod.TokenValue + " Tokens to recieve " + prod.ProductName + ".";
        }

        List_BTN.interactable = false;
        List_Tab.SetActive(true);
        Scan_BTN.interactable = true;
        Scan_Tab.SetActive(false);
    }
Beispiel #2
0
    public void Accept()
    {
        if (UserUtilities.User.CurrentPoints >= prod.TokenValue)
        {
            UserUtilities.SpendPoints((int)prod.TokenValue);
            UIManager.Instance.IndicateScore((int)prod.TokenValue, false);
            SoundManager.Instance.PlaySound("CoinCollect");

            GameManager.Organizations Org = (GameManager.Organizations)Enum.Parse(typeof(GameManager.Organizations), prod.Organization.ToString());
            if (GameManager.Instance.MiniGameEnabledOrgs.Contains(Org))
            {
                GameManager.Instance.Unlock(Org);
            }

            UIManager.Instance.DisplayNotification(true, "You have successfully redeemed " + prod.ProductName + " for " + prod.TokenValue + " Tokens.");
            GameManager.Instance.analytics.LogEvent(new EventHitBuilder().SetEventCategory("Reward Redemption").SetEventAction(prod.ProductName).SetEventValue(prod.TokenValue));
        }
        else
        {
            SoundManager.Instance.PlaySound("error");
            UIManager.Instance.DisplayNotification(true, "You do not have enough tokens for this purchase.");
        }
        Destroy(gameObject);
    }