Пример #1
0
    public void SetPause()
    {
        mainPanel.SetActive(false);
        //turn on pause panel
        resumeButton.SetActive(true);
        pausedTitle.SetActive(true);
        pausePanel.SetActive(true);
        gameOverTitle.SetActive(false);
        retryButton.SetActive(false);
        revive1.SetActive(false);
        revive2.SetActive(false);
        levelmenu.UpdateMainInformation();

        GameManager.state = GameManager.PAUSE;
        gamecontroller.GameOver();
    }
Пример #2
0
 private void ShareCallback(IShareResult result)
 {
     if (result.Cancelled || !String.IsNullOrEmpty(result.Error))
     {
         Debug.Log("ShareLink Error: " + result.Error);
         facebookError.SetActive(true);
         facebookPanel.SetActive(false);
     }
     else if (!String.IsNullOrEmpty(result.PostId))
     {
         // Print post identifier of the shared content
         Debug.Log(result.PostId);
         int gems = ZPlayerPrefs.GetInt("totalgems");
         gems = gems + 50;
         ZPlayerPrefs.SetInt("totalgems", gems);
         ZPlayerPrefs.SetInt("playcounter", 0);
         ZPlayerPrefs.Save();
         facebookShared.SetActive(true);
         facebookPanel.SetActive(false);
     }
     else            /*
                      * // Share succeeded without postID
                      * Debug.Log("ShareLink success!");
                      * int gems = ZPlayerPrefs.GetInt ("totalgems");
                      * gems = gems + 50;
                      * ZPlayerPrefs.SetInt ("totalgems", gems);
                      * ZPlayerPrefs.SetInt ("playcounter", 0);
                      * ZPlayerPrefs.Save ();
                      * facebookPanel.SetActive (false);
                      * facebookShared.SetActive (true);
                      */
     {
         Debug.Log("ShareLink Error: " + result.Error);
         facebookError.SetActive(true);
         facebookPanel.SetActive(false);
     }
     levelmenu.UpdateMainInformation();
 }
Пример #3
0
    public void BuyCharacter()
    {
        totalgems = ZPlayerPrefs.GetInt("totalgems");
        Debug.Log(totalgems.ToString());
        switch (selection)
        {
        case 1:
            if (totalgems >= 100)
            {
                totalgems = totalgems - 100;
                characters [selection] = 1;
                CHARACTER = selection;
                ZPlayerPrefs.SetInt("CHARACTER", selection);
                ZPlayerPrefs.SetInt("characters1", 1);
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.Save();
                purchaseSuccess.SetActive(true);
                UpdateCharacterShop();
                Debug.Log("Item purchased");
            }
            else
            {
                purchasePanelNoFunds.SetActive(true);
            }

            break;

        case 2:
            if (totalgems >= 200)
            {
                totalgems = totalgems - 200;
                characters [selection] = 1;
                CHARACTER = selection;
                ZPlayerPrefs.SetInt("CHARACTER", selection);
                ZPlayerPrefs.SetInt("characters2", 1);
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.Save();
                purchaseSuccess.SetActive(true);
                UpdateCharacterShop();
                Debug.Log("Item purchased");
            }
            else
            {
                purchasePanelNoFunds.SetActive(true);
            }
            break;

        case 3:
            if (totalgems >= 250)
            {
                totalgems = totalgems - 250;
                characters [selection] = 1;
                CHARACTER = selection;
                ZPlayerPrefs.SetInt("CHARACTER", selection);
                ZPlayerPrefs.SetInt("characters3", 1);
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.Save();
                purchaseSuccess.SetActive(true);
                UpdateCharacterShop();
            }
            else
            {
                purchasePanelNoFunds.SetActive(true);
            }
            break;

        case 4:
            if (totalgems >= 300)
            {
                totalgems = totalgems - 300;
                characters [selection] = 1;
                CHARACTER = selection;
                ZPlayerPrefs.SetInt("CHARACTER", selection);
                ZPlayerPrefs.SetInt("characters4", 1);
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.Save();
                purchaseSuccess.SetActive(true);
                UpdateCharacterShop();
            }
            else
            {
                purchasePanelNoFunds.SetActive(true);
            }
            break;

        case 5:
            if (totalgems >= 500)
            {
                totalgems = totalgems - 500;
                characters [selection] = 1;
                CHARACTER = selection;
                ZPlayerPrefs.SetInt("CHARACTER", selection);
                ZPlayerPrefs.SetInt("characters5", 1);
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.Save();
                purchaseSuccess.SetActive(true);
                UpdateCharacterShop();
            }
            else
            {
                purchasePanelNoFunds.SetActive(true);
            }
            break;

        case 6:
            if (totalgems >= 750)
            {
                totalgems = totalgems - 750;
                characters [selection] = 1;
                CHARACTER = selection;
                ZPlayerPrefs.SetInt("CHARACTER", selection);
                ZPlayerPrefs.SetInt("characters6", 1);
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.Save();
                purchaseSuccess.SetActive(true);
                UpdateCharacterShop();
            }
            else
            {
                purchasePanelNoFunds.SetActive(true);
            }
            break;

        case 7:
            if (totalgems >= 1000)
            {
                totalgems = totalgems - 1000;
                characters [selection] = 1;
                CHARACTER = selection;
                ZPlayerPrefs.SetInt("CHARACTER", selection);
                ZPlayerPrefs.SetInt("characters7", 1);
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.Save();
                purchaseSuccess.SetActive(true);
                UpdateCharacterShop();
            }
            else
            {
                purchasePanelNoFunds.SetActive(true);
            }
            break;

        case 8:
            if (totalgems >= 1500)
            {
                totalgems = totalgems - 1500;
                characters [selection] = 1;
                CHARACTER = selection;
                ZPlayerPrefs.SetInt("CHARACTER", selection);
                ZPlayerPrefs.SetInt("characters8", 1);
                ZPlayerPrefs.Save();
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.Save();
                purchaseSuccess.SetActive(true);
                UpdateCharacterShop();
            }
            else
            {
                purchasePanelNoFunds.SetActive(true);
            }
            break;

        case 9:
            if (totalgems >= 2000)
            {
                totalgems = totalgems - 2000;
                characters [selection] = 1;
                CHARACTER = selection;
                ZPlayerPrefs.SetInt("CHARACTER", selection);
                ZPlayerPrefs.SetInt("characters9", 1);
                ZPlayerPrefs.SetInt("totalgems", totalgems);
                ZPlayerPrefs.Save();
                purchaseSuccess.SetActive(true);

                UpdateCharacterShop();
            }
            else
            {
                purchasePanelNoFunds.SetActive(true);
            }
            break;
        }

        main.UpdateMainInformation();
    }
Пример #4
0
    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    {
        // A consumable product has been purchased by this user.
        if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable1, StringComparison.Ordinal))
        {
            Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
            //If the item has been successfully purchased, store the item for later use!
            int totalgems = ZPlayerPrefs.GetInt("totalgems");
            totalgems += 50;
            ZPlayerPrefs.SetInt("totalgems", totalgems);
            ZPlayerPrefs.Save();
            purchaseSuccess.SetActive(true);
            levelmenu.UpdateMainInformation();
        }
        else         // A consumable product has been purchased by this user.
        if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable2, StringComparison.Ordinal))
        {
            Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
            //If the item has been successfully purchased, store the item for later use!
            int totalgems = ZPlayerPrefs.GetInt("totalgems");
            totalgems += 100;
            ZPlayerPrefs.SetInt("totalgems", totalgems);
            ZPlayerPrefs.Save();
            purchaseSuccess.SetActive(true);
            levelmenu.UpdateMainInformation();
        }
        else
        // A consumable product has been purchased by this user.
        if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable3, StringComparison.Ordinal))
        {
            Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
            //If the item has been successfully purchased, store the item for later use!
            int totalgems = ZPlayerPrefs.GetInt("totalgems");
            totalgems += 500;
            ZPlayerPrefs.SetInt("totalgems", totalgems);
            ZPlayerPrefs.Save();
            purchaseSuccess.SetActive(true);
            levelmenu.UpdateMainInformation();
        }
        else
        // A consumable product has been purchased by this user.
        if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable4, StringComparison.Ordinal))
        {
            Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
            //If the item has been successfully purchased, store the item for later use!
            int totalgems = ZPlayerPrefs.GetInt("totalgems");
            totalgems += 1000;
            ZPlayerPrefs.SetInt("totalgems", totalgems);
            ZPlayerPrefs.Save();
            purchaseSuccess.SetActive(true);
            levelmenu.UpdateMainInformation();
        }
        else
        // A consumable product has been purchased by this user.
        if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable5, StringComparison.Ordinal))
        {
            Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
            //If the item has been successfully purchased, store the item for later use!
            int totalgems = ZPlayerPrefs.GetInt("totalgems");
            totalgems += 2000;
            ZPlayerPrefs.SetInt("totalgems", totalgems);
            ZPlayerPrefs.Save();
            purchaseSuccess.SetActive(true);
            levelmenu.UpdateMainInformation();
        }
        else
        // A consumable product has been purchased by this user.
        if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable6, StringComparison.Ordinal))
        {
            Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
            //If the item has been successfully purchased, store the item for later use!
            int totalgems = ZPlayerPrefs.GetInt("totalgems");
            totalgems += 5000;
            ZPlayerPrefs.SetInt("totalgems", totalgems);
            ZPlayerPrefs.Save();
            purchaseSuccess.SetActive(true);
            levelmenu.UpdateMainInformation();
        }

        else
        {
            Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
            PlayerPrefs.SetInt("Itemss_All", 0);
            purchaseFailed.SetActive(true);
        }

        // Return a flag indicating wither this product has completely been received, or if the application needs to be reminded of this purchase at next app launch. Is useful when saving purchased products to the cloud, and when that save is delayed.
        return(PurchaseProcessingResult.Complete);
    }
Пример #5
0
    //Each time user change the background update the background shop
    public void UpdateBackgroundShop()
    {
        //Set all selected signs to false
        for (int i = 0; i < numofbackgrounds; i++)
        {
            selectedBackground [i].SetActive(false);

            //if a theme has been purchased, deactivate the prices and buy buttons
            if (themes [i] == 1)
            {
                prices [i].SetActive(false);
                backgroundButton [i].image.sprite = backgroundImages [i];
            }
        }
        //Set the current theme in main menu and update the information
        switch (THEME)
        {
        case 0:
            selectedBackground [THEME].SetActive(true);
            mainmenu.SetTheme(THEME);
            levelmenu.UpdateMainInformation();
            break;

        case 1:
            selectedBackground [THEME].SetActive(true);
            levelmenu.UpdateMainInformation();
            mainmenu.SetTheme(THEME);
            break;

        case 2:
            selectedBackground [THEME].SetActive(true);
            levelmenu.UpdateMainInformation();
            mainmenu.SetTheme(THEME);
            break;

        case 3:
            selectedBackground [THEME].SetActive(true);
            levelmenu.UpdateMainInformation();
            mainmenu.SetTheme(THEME);
            break;

        case 4:
            selectedBackground [THEME].SetActive(true);
            levelmenu.UpdateMainInformation();
            mainmenu.SetTheme(THEME);
            break;

        case 5:
            selectedBackground [THEME].SetActive(true);
            levelmenu.UpdateMainInformation();
            mainmenu.SetTheme(THEME);
            break;

        case 6:
            selectedBackground [THEME].SetActive(true);
            levelmenu.UpdateMainInformation();
            mainmenu.SetTheme(THEME);
            break;

        case 7:
            selectedBackground [THEME].SetActive(true);
            levelmenu.UpdateMainInformation();
            mainmenu.SetTheme(THEME);
            break;

        case 8:
            selectedBackground [THEME].SetActive(true);
            levelmenu.UpdateMainInformation();
            mainmenu.SetTheme(THEME);
            break;

        case 9:
            selectedBackground [THEME].SetActive(true);
            levelmenu.UpdateMainInformation();
            mainmenu.SetTheme(THEME);
            break;
        }
        Debug.Log("Store updated");
    }