Exemple #1
0
    public static Reward GetRewardForProgressionLevel(int level)
    {
        Reward reward = new Reward();
        Dictionary <ProgressionUnlockCategory, string[]> unlockedIDsForLevel = Service.Get <ProgressionService>().GetUnlockedIDsForLevel(level);
        Dictionary <ProgressionUnlockCategory, ProgressionService.UnlockDefinition> unlockedDefinitionsForLevel = Service.Get <ProgressionService>().GetUnlockedDefinitionsForLevel(level);
        Dictionary <ProgressionUnlockCategory, int> unlockedCountsForLevel = Service.Get <ProgressionService>().GetUnlockedCountsForLevel(level);

        foreach (KeyValuePair <ProgressionUnlockCategory, string[]> item in unlockedIDsForLevel)
        {
            if (RewardableLoader.RewardableTypeMap.ContainsKey(item.Key.ToString()))
            {
                for (int i = 0; i < item.Value.Length; i++)
                {
                    reward.Add(RewardableLoader.GenerateRewardable(item.Key.ToString(), item.Value));
                }
            }
        }
        foreach (KeyValuePair <ProgressionUnlockCategory, ProgressionService.UnlockDefinition> item2 in unlockedDefinitionsForLevel)
        {
            string text        = item2.Key.ToString();
            Type   elementType = typeof(ProgressionUnlockDefinition).GetField(text).FieldType.GetElementType();
            if (elementType != null)
            {
                FieldInfo attributedField = StaticGameDataDefinitionIdAttribute.GetAttributedField(elementType);
                if (attributedField != null)
                {
                    if (RewardableLoader.RewardableTypeMap.ContainsKey(text) && item2.Value.Definitions.Length > 0)
                    {
                        Type  type  = attributedField.GetValue(item2.Value.Definitions[0]).GetType();
                        Type  type2 = typeof(List <>).MakeGenericType(type);
                        IList list  = (IList)Activator.CreateInstance(type2);
                        for (int i = 0; i < item2.Value.Definitions.Length; i++)
                        {
                            list.Add(attributedField.GetValue(item2.Value.Definitions[i]));
                        }
                        for (int i = 0; i < list.Count; i++)
                        {
                            reward.Add(RewardableLoader.GenerateRewardable(text, list[i]));
                        }
                    }
                }
                else
                {
                    Log.LogErrorFormatted(typeof(RewardUtils), "Could not find a StaticGameDataDefinitionId field on type {0}", elementType);
                }
            }
            else
            {
                Log.LogErrorFormatted(typeof(RewardUtils), "Could not find an element type for the field {0}, the field must be an array", text);
            }
        }
        foreach (KeyValuePair <ProgressionUnlockCategory, int> item3 in unlockedCountsForLevel)
        {
            if (RewardableLoader.RewardableTypeMap.ContainsKey(item3.Key.ToString()))
            {
                reward.Add(RewardableLoader.GenerateRewardable(item3.Key.ToString(), item3.Value));
            }
        }
        return(reward);
    }
 public override IEnumerator PerformFirstPass()
 {
     Type[] rewardables = new Type[23]
     {
         typeof(CoinReward),
         typeof(MascotXPReward),
         typeof(CollectibleReward),
         typeof(ConsumableInstanceReward),
         typeof(DecalReward),
         typeof(EquipmentInstanceReward),
         typeof(EquipmentTemplateReward),
         typeof(DecorationInstanceReward),
         typeof(DecorationReward),
         typeof(IglooSlotsReward),
         typeof(LotReward),
         typeof(StructureInstanceReward),
         typeof(StructureReward),
         typeof(MusicTrackReward),
         typeof(LightingReward),
         typeof(FabricReward),
         typeof(ConsumableReward),
         typeof(DurableReward),
         typeof(TubeReward),
         typeof(EmoteReward),
         typeof(SizzleClipReward),
         typeof(ColourPackReward),
         typeof(SavedOutfitSlotReward)
     };
     RewardableLoader.Init(rewardables);
     yield break;
 }
Exemple #3
0
    public Reward ToReward()
    {
        Reward reward = new Reward();

        using (Enumerator enumerator = GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                KeyValuePair <string, JsonData> current = enumerator.Current;
                if (RewardableLoader.RewardableTypeMap.ContainsKey(current.Key) && current.Value != null)
                {
                    IRewardable rewardable = RewardableLoader.GenerateRewardable(current.Key);
                    rewardable.FromJson(current.Value);
                    reward.Add(rewardable);
                }
            }
        }
        return(reward);
    }