| using System;  | 
| using System.Collections;  | 
| using System.Collections.Generic;  | 
| using System.Linq;  | 
|   | 
| using UnityEngine;  | 
| namespace vnxbqy.UI  | 
| {  | 
|       | 
|     public class TrialDungeonModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk  | 
|     {  | 
|         Dictionary<int, Dictionary<int, Item[]>> trialRewardDict = new Dictionary<int, Dictionary<int, Item[]>>();  | 
|         Dictionary<int, int> trialDungeonPetHorseLevels = null;  | 
|         PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }  | 
|         DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }  | 
|         DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }  | 
|         PetModel petModel { get { return ModelCenter.Instance.GetModel<PetModel>(); } }  | 
|         MountModel horseModel { get { return ModelCenter.Instance.GetModel<MountModel>(); } }  | 
|   | 
|         bool serverInited = false;  | 
|   | 
|         public const int TRIALEXCHANGE_GUIDE = 91;  | 
|         public const int TRIALDUNGOEN_MAPID = 60010;  | 
|   | 
|         public int trialSweepGradeLimit { get; private set; }  | 
|   | 
|         public override void Init()  | 
|         {  | 
|             ParseConfig();  | 
|         }  | 
|   | 
|         public void OnBeforePlayerDataInitialize()  | 
|         {  | 
|             serverInited = false;  | 
|         }  | 
|   | 
|         public void OnPlayerLoginOk()  | 
|         {  | 
|             serverInited = true;  | 
|         }  | 
|   | 
|         void ParseConfig()  | 
|         {  | 
|             var trialRewards = TrialRewardsConfig.GetValues();  | 
|             for (int i = 0; i < trialRewards.Count; i++)  | 
|             {  | 
|                 Dictionary<int, Item[]> dict = null;  | 
|                 if (!trialRewardDict.TryGetValue(trialRewards[i].lineId, out dict))  | 
|                 {  | 
|                     dict = new Dictionary<int, Item[]>();  | 
|                     trialRewardDict.Add(trialRewards[i].lineId, dict);  | 
|                 }  | 
|                 var itemsArray = LitJson.JsonMapper.ToObject<int[][]>(trialRewards[i].rewards);  | 
|                 if (itemsArray != null && itemsArray.Length > 0)  | 
|                 {  | 
|                     Item[] items = new Item[itemsArray.Length];  | 
|                     for (int k = 0; k < itemsArray.Length; k++)  | 
|                     {  | 
|                         items[k] = new Item()  | 
|                         {  | 
|                             id = itemsArray[k][0],  | 
|                             count = itemsArray[k][1],  | 
|                         };  | 
|                     }  | 
|                     dict.Add(trialRewards[i].grade, items);  | 
|                 }  | 
|             }  | 
|   | 
|             var funcConfig = FuncConfigConfig.Get("TrialSweepGradeLimit");  | 
|             if (funcConfig != null)  | 
|             {  | 
|                 trialSweepGradeLimit = int.Parse(funcConfig.Numerical1);  | 
|             }  | 
|   | 
|             funcConfig = FuncConfigConfig.Get("MunekadoLockLimit");  | 
|             trialDungeonPetHorseLevels = ConfigParse.GetDic<int, int>(funcConfig.Numerical2);  | 
|         }  | 
|   | 
|         public override void UnInit()  | 
|         {  | 
|         }  | 
|   | 
|         public bool TryGetTrialRewards(int lineId, int grade, out Item[] rewards)  | 
|         {  | 
|             rewards = null;  | 
|             if (trialRewardDict.ContainsKey(lineId))  | 
|             {  | 
|                 if (trialRewardDict[lineId].ContainsKey(grade))  | 
|                 {  | 
|                     rewards = trialRewardDict[lineId][grade];  | 
|                     return rewards != null && rewards.Length > 0;  | 
|                 }  | 
|             }  | 
|             return false;  | 
|         }  | 
|   | 
|         public void ProcessTrialError(int error)  | 
|         {  | 
|             switch (error)  | 
|             {  | 
|                 case 1:  | 
|                     SysNotifyMgr.Instance.ShowTip("TrialTokenCountError");  | 
|                     break;  | 
|                 case 2:  | 
|                     FuncOpen.Instance.ProcessorFuncErrorTip(88);  | 
|                     break;  | 
|             }  | 
|         }  | 
|   | 
|         public bool CompleteTrialFloor(int _lineId)  | 
|         {  | 
|             DungeonRecord dungeonRecord;  | 
|             if (dungeonModel.TryGetRecord(60010, out dungeonRecord))  | 
|             {  | 
|                 if (dungeonRecord.lineGrades != null  | 
|                     && dungeonRecord.lineGrades.ContainsKey(_lineId))  | 
|                 {  | 
|                     return dungeonRecord.lineGrades[_lineId] > 0;  | 
|                 }  | 
|             }  | 
|             return false;  | 
|         }  | 
|   | 
|         public int GetDungeonRequirePetHorseLevel(int lineId)  | 
|         {  | 
|             if (trialDungeonPetHorseLevels.ContainsKey(lineId))  | 
|             {  | 
|                 return trialDungeonPetHorseLevels[lineId];  | 
|             }  | 
|             return 0;  | 
|         }  | 
|   | 
|         public int GetPetHorseLevel()  | 
|         {  | 
|             var level = 0;  | 
|             if (petModel._DicPetBack != null)  | 
|             {  | 
|                 foreach (var item in petModel._DicPetBack.Values)  | 
|                 {  | 
|                     level += item.PetClass;  | 
|                 }  | 
|             }  | 
|             if (horseModel._DicHorse != null)  | 
|             {  | 
|                 foreach (var item in horseModel._DicHorse.Values)  | 
|                 {  | 
|                     level += item.Lv;  | 
|                 }  | 
|             }  | 
|             return level;  | 
|         }  | 
|     }  | 
| }  | 
|   |