示例#1
0
    private static void AddEatenDesserts(int count)
    {
        int num = GameProgress.EatenDessertsCount();

        GameProgress.SetEatenDessertsCount(num + count);
        num  = GameProgress.m_data.GetInt("TotalDessertCount", 0);
        num -= count;
        GameProgress.m_data.SetInt("TotalDessertCount", (num >= 0) ? num : 0);
    }
示例#2
0
    private FeedingPrize.PrizeType GiveReward(GameObject dessert)
    {
        FeedingPrize.PrizeType result = FeedingPrize.PrizeType.None;
        int num = GameProgress.EatenDessertsCount();

        if (UnityEngine.Random.value < this.m_PrizeProbability || num <= 1 || dessert.name == "GoldenCake")
        {
            FeedingPrize feedingPrize;
            if (num <= 1)
            {
                feedingPrize = null;
                foreach (FeedingPrize x in this.m_FeedingPrizes)
                {
                    if (x.type == FeedingPrize.PrizeType.SuperGlue)
                    {
                        feedingPrize = x;
                        break;
                    }
                }
            }
            else
            {
                feedingPrize = this.SelectFeedingPrize();
            }
            FeedingPrize feedingPrize2 = feedingPrize;
            if (dessert.name == "GoldenCake" && feedingPrize2.type == FeedingPrize.PrizeType.Junk)
            {
                feedingPrize2 = this.m_FeedingPrizes[1];
            }
            if (feedingPrize2 != null)
            {
                if (feedingPrize2.type != FeedingPrize.PrizeType.Junk && feedingPrize2.type != FeedingPrize.PrizeType.None)
                {
                    GameObject gameObject = this.m_Reward.transform.Find("Offset/AnimationNode").gameObject;
                    if (gameObject.transform.childCount > 0)
                    {
                        UnityEngine.Object.Destroy(gameObject.transform.GetChild(0).gameObject);
                    }
                    GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(feedingPrize2.icon, gameObject.transform.position, gameObject.transform.rotation);
                    gameObject2.transform.parent     = gameObject.transform;
                    gameObject2.transform.localScale = Vector3.one * feedingPrize2.iconScale;
                    CurrencyParticleBurst burst = null;
                    string text = "King Pig feeding prize";
                    switch (feedingPrize2.type)
                    {
                    case FeedingPrize.PrizeType.SuperGlue:
                        GameProgress.AddSuperGlue(1);
                        if (Singleton <IapManager> .Instance != null)
                        {
                            Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.SuperGlueSingle, 1, text);
                        }
                        break;

                    case FeedingPrize.PrizeType.SuperMagnet:
                        GameProgress.AddSuperMagnet(1);
                        if (Singleton <IapManager> .Instance != null)
                        {
                            Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.SuperMagnetSingle, 1, text);
                        }
                        break;

                    case FeedingPrize.PrizeType.TurboCharge:
                        GameProgress.AddTurboCharge(1);
                        if (Singleton <IapManager> .Instance != null)
                        {
                            Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.TurboChargeSingle, 1, text);
                        }
                        break;

                    case FeedingPrize.PrizeType.SuperMechanic:
                        GameProgress.AddBluePrints(1);
                        if (Singleton <IapManager> .Instance != null)
                        {
                            Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.BlueprintSingle, 1, text);
                        }
                        break;

                    case FeedingPrize.PrizeType.NightVision:
                        GameProgress.AddNightVision(1);
                        if (Singleton <IapManager> .Instance != null)
                        {
                            Singleton <IapManager> .Instance.SendFlurryInventoryGainEvent(IapManager.InAppPurchaseItemType.NightVisionSingle, 1, text);
                        }
                        break;

                    case FeedingPrize.PrizeType.SnoutCoins:
                    {
                        int value = Singleton <GameConfigurationManager> .Instance.GetValue <int>("king_pig_snout_reward", "min");

                        int value2 = Singleton <GameConfigurationManager> .Instance.GetValue <int>("king_pig_snout_reward", "max");

                        int num2 = UnityEngine.Random.Range(value, value2 + 1);
                        if (num2 > 0)
                        {
                            if (Singleton <DoubleRewardManager> .Instance.HasDoubleReward)
                            {
                                num2 *= 2;
                            }
                            GameProgress.AddSnoutCoins(num2);
                            GameObject gameObject3 = GameObject.FindGameObjectWithTag("KingPigMouth");
                            if (gameObject3 != null)
                            {
                                Camera main   = Camera.main;
                                Camera camera = Singleton <GuiManager> .Instance.FindCamera();

                                if (main == null || camera == null)
                                {
                                    break;
                                }
                                Vector3 a = gameObject3.transform.position * (1f / main.orthographicSize);
                                gameObject2.transform.parent   = null;
                                gameObject2.transform.position = a * camera.orthographicSize;
                            }
                            burst = gameObject2.GetComponent <CurrencyParticleBurst>();
                            if (burst != null)
                            {
                                burst.SetBurst(num2, 10f, true);
                            }
                        }
                        break;
                    }

                    case FeedingPrize.PrizeType.Scrap:
                    {
                        int value3 = Singleton <GameConfigurationManager> .Instance.GetValue <int>("king_pig_scrap_reward", "min");

                        int value4 = Singleton <GameConfigurationManager> .Instance.GetValue <int>("king_pig_scrap_reward", "max");

                        int num3 = UnityEngine.Random.Range(value3, value4 + 1);
                        if (num3 > 0)
                        {
                            GameProgress.AddScrap(num3);
                            GameObject gameObject4 = GameObject.FindGameObjectWithTag("KingPigMouth");
                            if (gameObject4 != null)
                            {
                                Camera main2   = Camera.main;
                                Camera camera2 = Singleton <GuiManager> .Instance.FindCamera();

                                if (main2 == null || camera2 == null)
                                {
                                    break;
                                }
                                Vector3 a2 = gameObject4.transform.position * (1f / main2.orthographicSize);
                                gameObject2.transform.parent   = null;
                                gameObject2.transform.position = a2 * camera2.orthographicSize;
                            }
                            burst = gameObject2.GetComponent <CurrencyParticleBurst>();
                            if (burst != null)
                            {
                                burst.SetBurst(num3, 10f, true);
                            }
                        }
                        break;
                    }
                    }
                    if (feedingPrize2.type == FeedingPrize.PrizeType.SnoutCoins || feedingPrize2.type == FeedingPrize.PrizeType.Scrap)
                    {
                        this.DelayAction(delegate
                        {
                            if (burst != null)
                            {
                                burst.Burst();
                            }
                        }, 1.3f);
                    }
                    else
                    {
                        this.DelayAction(delegate
                        {
                            this.m_Reward.SetActive(true);
                        }, this.m_GrowDuration);
                    }
                    if (PlayerProgressBar.Instance != null && Singleton <PlayerProgress> .IsInstantiated())
                    {
                        GameObject gameObject5 = GameObject.FindGameObjectWithTag("KingPigMouth");
                        Vector3    vector      = gameObject5.transform.position * (1f / this.m_mainCam.orthographicSize);
                        vector *= this.m_hudCam.orthographicSize;
                        PlayerProgressBar.Instance.DelayUpdate();
                        int amount = Singleton <PlayerProgress> .Instance.AddExperience(PlayerProgress.ExperienceType.KingBurp);

                        PlayerProgressBar.Instance.AddParticles(vector, amount, 1.3f, 0f, null);
                    }
                    if (Singleton <SocialGameManager> .IsInstantiated())
                    {
                        Singleton <SocialGameManager> .Instance.ReportAchievementProgress("grp.KINGS_FAVORITE", 100.0);
                    }
                }
                result = feedingPrize2.type;
            }
        }
        return(result);
    }
示例#3
0
 private void CheckAchievements()
 {
     if (Singleton <SocialGameManager> .IsInstantiated())
     {
         Singleton <SocialGameManager> .Instance.TryReportAchievementProgress("grp.FEEDER", 100.0, (int limit) => GameProgress.EatenDessertsCount() >= limit);
     }
 }
示例#4
0
 private string GetKingPigTotalText()
 {
     return(GameProgress.EatenDessertsCount().ToString());
 }