Exemple #1
0
    private void OnLevelLoaded(GameLevelLoaded data)
    {
        LevelManager levelManager = WPFMonoBehaviour.levelManager;

        if (levelManager != null && levelManager.CurrentGameMode is BaseGameMode && !levelManager.m_sandbox && !levelManager.m_raceLevel)
        {
            int index = 0;
            if (this.IsDailyChallenge(data.episodeIndex, data.levelIndex, out index) && !this.dailyChallenges[index].collected)
            {
                DailyLevel daily = Singleton <GameManager> .instance.gameData.m_dailyChallengeData.GetDaily(this.dailyChallenges[index].DailyKey);

                Vector3 position;
                if (daily != null && daily.GetPosition(this.dailyChallenges[index].positionIndex, out position))
                {
                    GameObject gameObject  = WPFMonoBehaviour.gameData.m_lootCrates[(int)this.TodaysLootCrate(index)];
                    GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject, position, Quaternion.identity);
                    LootCrate  component   = gameObject2.GetComponent <LootCrate>();
                    LootCrate  lootCrate   = component;
                    lootCrate.OnCollect = (Action)Delegate.Combine(lootCrate.OnCollect, new Action(delegate()
                    {
                        this.OnDailyRewardCollected(index);
                    }));
                    LootCrate lootCrate2 = component;
                    lootCrate2.RewardExperience = (Func <int>)Delegate.Combine(lootCrate2.RewardExperience, new Func <int>(this.RewardExperience));
                    component.SetAnalyticData(index, this.dailyChallenges[index].adRevealed);
                    this.dailyChallenges[index].revealed = true;
                    UnityEngine.Debug.LogWarning("Instantiated " + gameObject.name + " at position " + position.ToString());
                }
            }
        }
    }
 public void AddDaily(DailyLevel daily)
 {
     if (this.GetDaily(daily.GetKey()) == null)
     {
         this.dailyLevels.Add(daily);
     }
 }
Exemple #3
0
    private ChallengeInfo CreateNewChallenge(LootCrateType type, int tryCount = 0)
    {
        if (tryCount > 100)
        {
            return(default(ChallengeInfo));
        }
        float num = UnityEngine.Random.Range(0f, 100f);
        float unlockLevelChance = this.challengeConfigs.GetUnlockLevelChance(type);
        float num2 = unlockLevelChance + this.challengeConfigs.GetLockedLevelChance1(type);
        float num3 = num2 + this.challengeConfigs.GetLockedLevelChance2(type);
        float num4 = num3 + this.challengeConfigs.GetUnlockedJokerLevelChance(type);
        float num5 = num4 + this.challengeConfigs.GetLockedJokerLevelChanche(type);
        List <ChallengeInfo> list;
        List <ChallengeInfo> list2;
        List <ChallengeInfo> list3;
        List <ChallengeInfo> list4;
        List <ChallengeInfo> list5;

        this.GetPossibleLevels(type, out list, out list2, out list3, out list4, out list5);
        ChallengeInfo challengeInfo;

        if (num < unlockLevelChance && list.Count > 0)
        {
            challengeInfo = list[UnityEngine.Random.Range(0, list.Count)];
        }
        else if (num < num2 && list2.Count > 0)
        {
            challengeInfo = list2[UnityEngine.Random.Range(0, list2.Count)];
        }
        else if (num < num3 && list3.Count > 0)
        {
            challengeInfo = list3[UnityEngine.Random.Range(0, list3.Count)];
        }
        else if (num < num3 && list3.Count <= 0 && list2.Count > 0)
        {
            challengeInfo = list2[UnityEngine.Random.Range(0, list2.Count)];
        }
        else if (num < num3 && list3.Count <= 0 && list.Count > 0)
        {
            challengeInfo = list[UnityEngine.Random.Range(0, list.Count)];
        }
        else if (num < num4 && list4.Count > 0)
        {
            challengeInfo = list4[UnityEngine.Random.Range(0, list4.Count)];
        }
        else if (num <= num5 && list5.Count > 0)
        {
            challengeInfo = list5[UnityEngine.Random.Range(0, list5.Count)];
        }
        else if (num <= num5 && list5.Count <= 0 && list4.Count > 0)
        {
            challengeInfo = list4[UnityEngine.Random.Range(0, list4.Count)];
        }
        else
        {
            challengeInfo = this.CreateNewChallenge(type, tryCount + 1);
        }
        if (this.IsDailyChallenge(challengeInfo) && !string.IsNullOrEmpty(challengeInfo.levelName))
        {
            challengeInfo = this.CreateNewChallenge(type, tryCount);
        }
        DailyLevel daily = Singleton <GameManager> .instance.gameData.m_dailyChallengeData.GetDaily(challengeInfo.DailyKey);

        if (daily != null)
        {
            do
            {
                challengeInfo.positionIndex = UnityEngine.Random.Range(0, daily.Count);
            }while (!daily.ValidPositionIndex(challengeInfo.positionIndex));
        }
        return(challengeInfo);
    }