コード例 #1
0
    public void BuyEnergy()
    {
        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        int gemucoins = GameManager.GEMUCOINS;

        GameManager.FREECOINS += currentShopContent.Amount;
        if (GameManager.FREECOINS > GameManager.MAX_FREECOIN_FROM_TIMER)
        {
            GameManager.FREECOINS = GameManager.MAX_FREECOIN_FROM_TIMER;
        }
        PlayerPrefs.SetInt("freecoins", GameManager.FREECOINS);

        gemucoins -= (int)currentShopContent.Price;
        PlayerPrefs.SetInt(PlayerPrefHandler.keyCoin, gemucoins);
        GameManager.GEMUCOINS = gemucoins;

        guiIngame.RefreshFreeEnergyInfo();
        GL1Connector.GetInstance().DecBalance(this.gameObject, currentShopContent.Price.ToString(), "", "CMENERGY" + currentShopContent.Amount.ToString());

        RefreshInfo();

        gs.ShowDialogBox("Info", "You just bought " + currentShopContent.Amount + " Energy", false, "confirm", this.gameObject);
    }
コード例 #2
0
    public void showTimerBox()
    {
        System.TimeSpan Dur = TimerHandler.instance.DurationLeft_FreeGift;

        Debug.Log("Duration:" + Dur);

        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        gs.ShowDialogBox("No Energy", setTimerString(Dur), false, "", this.gameObject);
    }
コード例 #3
0
    void OnClick()
    {
        Gamestate_Gameplay gs = GameObject.FindGameObjectWithTag("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs)
        {
            Transform trHiddenID = this.transform.parent.Find("Label Hidden ID");
            if (trHiddenID)
            {
                UILabel label = trHiddenID.gameObject.GetComponent <UILabel>();
                if (label)
                {
                    int index = int.Parse(label.text);

                    bool            bContinue = true;
                    ContentCategory cat       = (ContentCategory)gs.categories[index];
                    for (int j = 0; j < cat.contents.Length; j++)
                    {
                        int iPrizeAmount = 0;
                        if (PlayerPrefs.HasKey("cc." + index + "." + j))
                        {
                            iPrizeAmount = PlayerPrefs.GetInt("cc." + index + "." + j);
                        }

                        if (iPrizeAmount == 0)
                        {
                            bContinue = false;
                            break;
                        }
                    }

                    if (bContinue)
                    {
                        gs.OnClickBonusButton(index);
                    }
                    else
                    {
                        gs.ShowDialogBox("Info", "Not enough prize", false, "", this.gameObject);
                    }
                }
            }
        }
    }
コード例 #4
0
    public void ProcessBuyPowerup()
    {
        powerUpAch = true;
        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        int gemucoins = GameManager.GEMUCOINS;

        gemucoins -= (int)currentShopContent.Price;
        PlayerPrefs.SetInt(PlayerPrefHandler.keyCoin, gemucoins);
        GameManager.GEMUCOINS = gemucoins;

        int    iAmount = 0;
        string sKey    = currentShopContent.name + "_Amount";

        if (PlayerPrefs.HasKey(sKey))
        {
            iAmount = PlayerPrefs.GetInt(sKey);
        }

        Debug.LogError("[GUI_Shop] sKey=" + sKey + " amount=" + iAmount);
        iAmount += currentShopContent.Amount;
        PlayerPrefs.SetInt(sKey, iAmount);
        Debug.LogError("[GUI_Shop] sKey=" + sKey + " amount=" + iAmount);
        guiIngame.RefreshPowerUpsInfo();
        guiIngame.RefreshGemuCoinInfo();
        RefreshInfo();
        //gs.achievementManager.OnAchievementEvent(AchievementType.PowerPlay,1);

        gs.ShowDialogBox("Info", "You just bought 1 " + currentShopContent.Name + " Power-Up", false, "confirmAch", null);
//		if ( PlayerPrefs.HasKey(sKey) )
//		{
//			iAmount = PlayerPrefs.GetInt(sKey);
//			Debug.LogError("[GUI_Shop] sKey="+sKey+" amount="+iAmount);
//		}

        GL1Connector.GetInstance().DecBalance(null, currentShopContent.Price.ToString(), "", "CMPOWERUP" + currentShopContent.Price.ToString());
    }
コード例 #5
0
    public void OnClickSpin()
    {
        currCoin  = GameManager.GEMUCOINS;
        currCoin -= 100;
        GameManager.GEMUCOINS = currCoin;
        PlayerPrefs.SetInt(PlayerPrefHandler.keyCoin, currCoin);

        GUI_InGame.instance.RefreshGemuCoinInfo();
        Debug.Log("spin gacha");

        int       itemWon = 0, contentChild = 0;
        Transform trChild;

        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        //play animation

        if (Random.value >= 0 && Random.value <= 0.1)
        {
            itemWon = Random.Range(0, 4);
        }
        else
        {
            itemWon = Random.Range(4, gachaList.Count);
        }

        gs.ShowDialogBox("Info", "You got " + gachaList [itemWon], false, "", this.gameObject);

        switch (itemWon)
        {
        case 0:
            contentChild = 1;
            trChild      = GUI_Shop.GetInstance().containerShopJoystick.transform.GetChild(contentChild);
            setShopItem(trChild, "joystick");
            break;

        case 1:
            contentChild = 2;
            trChild      = GUI_Shop.GetInstance().containerShopJoystick.transform.GetChild(contentChild);
            setShopItem(trChild, "joystick");
            break;

        case 2:
            contentChild = 1;
            trChild      = GUI_Shop.GetInstance().containerShopClaw.transform.GetChild(contentChild);
            setShopItem(trChild, "claw");
            break;

        case 3:
            contentChild = 2;
            trChild      = GUI_Shop.GetInstance().containerShopClaw.transform.GetChild(contentChild);
            setShopItem(trChild, "claw");
            break;

        case 4:
            contentChild = 0;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;

        case 5:
            contentChild = 1;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;

        case 6:
            contentChild = 2;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;

        case 7:
            contentChild = 3;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;

        case 8:
            contentChild = 4;
            trChild      = GUI_Shop.GetInstance().containerShopPowerups.transform.GetChild(contentChild);
            setShopItem(trChild, "powerup");
            break;
        }

        if (currCoin < 100)
        {
            buttonGachaActive.gameObject.SetActive(false);
            buttonGachaInactive.gameObject.SetActive(true);
        }
        else
        {
            buttonGachaActive.gameObject.SetActive(true);
            buttonGachaInactive.gameObject.SetActive(false);
        }
    }
コード例 #6
0
    public void OnClickShopContent()
    {
        UIButton button = UIButton.current;

        if (button == null)
        {
            return;
        }

        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay>();

        if (gs == null)
        {
            return;
        }

        ShopContent content = button.transform.parent.gameObject.GetComponent <ShopContent> ();

        if (content.type == ShopContentType.IAP)
        {
            if (content.uniqueID == "freecoins")
            {
                GUI_Dialog.InsertStack(gemuFreeCoins.gameObject);
                //if ( GameDataManager.GetTimerToWatchAds() > GameDataManager.TIMER_TO_WATCH_ADS )
                //{
                //if (GameDataManager.PlayUnityVideoAd ()) {
                //	StartCoroutine(ShowingAds());
                //} else {
                //	gs.ShowDialogBox ("Info", "Please wait...", false, "", this.gameObject);
                //}
                //}
                //else
                //	gs.ShowDialogBox("Info","Please wait to watch the next ads.",false,"",this.gameObject);
            }
            else if (PlayerPrefs.HasKey("joystick." + content.uniqueID) == true)
            {
                PlayerPrefs.SetString("playerjoy", content.uniqueID);
                gs.SetJoystick(content.uniqueID);
                RefreshJoystickStatus();
            }
            else if (PlayerPrefs.HasKey("claw." + content.uniqueID) == true)
            {
                PlayerPrefs.SetString("playerclaw", content.uniqueID);
                gs.SetClaw(content.uniqueID);
                RefreshClawStatus();
            }
            else
            {
                currentShopContent = content;
                AndroidInAppPurchaseManager.instance.purchase(currentShopContent.uniqueID);
                //OnSuccessfulPurchase(currentShopContent.uniqueID);
            }
        }
        else if (content.type == ShopContentType.PowerUp)
        {
            int gemucoins = GameManager.GEMUCOINS;
            if (gemucoins - content.Price >= 0)
            {
                currentShopContent = content;
                gs.ShowDialogBox(content.Name, content.Desc + "\n\nDo you want to buy ?", true, "buypowerup", this.gameObject);
                //gs.achievementManager.OnAchievementEvent(AchievementType.PowerPlay,1);
            }
            else
            {
                gs.ShowDialogBox("Info", "Not enough coins", false, "confirm", this.gameObject);
            }
        }
        else if (content.type == ShopContentType.Claw)
        {
            if (PlayerPrefs.HasKey("claw." + content.uniqueID) == false)
            {
                int gemucoins = GameManager.GEMUCOINS;
                if (gemucoins - content.Price >= 0)
                {
                    //currentShopContent = content;
                    //gs.ShowDialogBox(content.Name,content.Desc+"Do you want to buy ?",true,"buyclaw",this.gameObject);
                    PlayerPrefs.SetString("playerclaw", content.uniqueID);
                    gs.SetClaw(content.uniqueID);
                    RefreshClawStatus();
                }
                else
                {
                    //gs.ShowDialogBox("Info","Not enough GemuGold",false,"confirm",this.gameObject);
                }
            }
            else
            {
                PlayerPrefs.SetString("playerclaw", content.uniqueID);
                gs.SetClaw(content.uniqueID);
                RefreshClawStatus();
            }
        }
        else if (content.type == ShopContentType.Joystick)
        {
            if (PlayerPrefs.HasKey("joystick." + content.uniqueID) == false)
            {
                int gemucoins = GameManager.GEMUCOINS;
                if (gemucoins - content.Price >= 0)
                {
                    //currentShopContent = content;
                    //gs.ShowDialogBox(content.Name,content.Desc+"Do you want to buy ?",true,"buyjoystick",this.gameObject);
                    PlayerPrefs.SetString("playerjoy", content.uniqueID);
                    gs.SetJoystick(content.uniqueID);
                    RefreshJoystickStatus();
                }
                else
                {
                    //gs.ShowDialogBox("Info","Not enough GemuGold",false,"confirm",this.gameObject);
                }
            }
            else
            {
                PlayerPrefs.SetString("playerjoy", content.uniqueID);
                gs.SetJoystick(content.uniqueID);
                RefreshJoystickStatus();
            }
        }
        else if (content.type == ShopContentType.FreeCoin)
        {
            int gemucoins = GameManager.GEMUCOINS;
            if (gemucoins - content.Price >= 0)
            {
                currentShopContent = content;
                gs.ShowDialogBox(content.Name, "Do you want to buy ?", true, "buyenergy", this.gameObject);
            }
            else
            {
                gs.ShowDialogBox("Info", "Not enough GemuGold", false, "confirm", this.gameObject);
            }
        }
        else
        {
            gs.ShowNotImplemented();
        }

        PlayerPrefs.Save();
    }
コード例 #7
0
    public void OnClickFreeEnergy()
    {
        Gamestate_Gameplay gs = GameObject.Find("Gamestate").GetComponent <Gamestate_Gameplay> ();

        if (gs == null)
        {
            return;
        }

        if (GameManager.FREECOINS >= 200)
        {
            gs.ShowDialogBox("Info", "Your energy is full", false, "energyFull", this.gameObject);
        }
        else
        {
            if (TimerHandler.instance.FreeGiftAvailablilty())
            {
                Advertisement.Show(null, new ShowOptions {
                    resultCallback = result => {
                        Debug.Log(result.ToString());

                        switch (result)
                        {
                        case (ShowResult.Failed):
                            gs.ShowDialogBox("Info", "Ads Failed for some reason", false, "confirm", this.gameObject);
                            break;

                        case (ShowResult.Skipped):
                            gs.ShowDialogBox("Info", "Ads Skipped. No energy added", false, "confirm", this.gameObject);
                            break;

                        case (ShowResult.Finished):


                            watchCount++;

                            if (watchCount >= 5)
                            {
                                watchCount = 0;
                                System.TimeSpan FreeGiftDuration    = TimeSpan.FromMinutes(20);
                                System.DateTime FreeGiftDurationEnd = System.DateTime.Now.Add(FreeGiftDuration);

                                PlayerPrefs.SetString(GamePreferences.Key_FreeGiftTimer, FreeGiftDurationEnd.ToBinary().ToString());

                                gs.ShowDialogBox("Info", "You got 20 energy", false, "confirm", this.gameObject);

                                PlayerPrefs.SetString(GamePreferences.Key_FreeGiftTimer, FreeGiftDurationEnd.ToBinary().ToString());
                                PlayerPrefs.Save();
                            }
                            else
                            {
                                gs.ShowDialogBox("Info", "You got 20 energy", false, "FreeEnergy", this.gameObject);
                            }

                            GameManager.FREECOINS += 20;
                            guiIngame.RefreshFreeEnergyInfo();
                            guiIngame.RefreshGemuCoinInfo();
                            RefreshInfo();


                            //start the timer
                            //System.TimeSpan FreeGiftDuration = TimerHandler.instance.FreeGiftExponentialTimer();


                            break;
                        }
                    }
                });
            }
            else
            {
                showTimerBox();
            }
        }
    }