| | |
| | | {
|
| | | Dictionary<int, List<TrialExchangeConfig>> trialTokenExchangeDict = new Dictionary<int, List<TrialExchangeConfig>>();
|
| | | Dictionary<int, int> lineToTokenClassDict;
|
| | | Dictionary<int, Dictionary<int, Item[]>> trialRewardDict = new Dictionary<int, Dictionary<int, Item[]>>();
|
| | | public Dictionary<int, List<int>> trialClassTokens = new Dictionary<int, List<int>>();
|
| | | public List<int> trialTokens = new List<int>();
|
| | | PlayerPackModel packModel { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
| | |
| | | ParseConfig();
|
| | | packModel.RefreshItemCountAct += RefreshItemCountAct;
|
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
| | | dungeonModel.dungeonRecordChangeEvent += DungeonRecordChangeEvent;
|
| | | }
|
| | |
|
| | | private void DungeonRecordChangeEvent(int _dungeonId)
|
| | | {
|
| | | if (_dungeonId == 60010)
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | |
| | |
|
| | | void ParseConfig()
|
| | | {
|
| | | var configs = ConfigManager.Instance.GetAllValues<TrialExchangeConfig>();
|
| | | var configs = Config.Instance.GetAllValues<TrialExchangeConfig>();
|
| | | for (int i = 0; i < configs.Count; i++)
|
| | | {
|
| | | List<TrialExchangeConfig> list;
|
| | | var itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(configs[i].tokenId);
|
| | | var itemConfig = Config.Instance.Get<ItemConfig>(configs[i].tokenId);
|
| | | if (!trialTokenExchangeDict.TryGetValue(itemConfig.LV, out list))
|
| | | {
|
| | | list = new List<TrialExchangeConfig>();
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | var funcConfig = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("LineToItemStage");
|
| | | var funcConfig = Config.Instance.Get<FuncConfigConfig>("LineToItemStage");
|
| | | lineToTokenClassDict = ConfigParse.GetDic<int, int>(funcConfig.Numerical1);
|
| | |
|
| | | var trialRewards = Config.Instance.GetAllValues<TrialRewardsConfig>();
|
| | | 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],
|
| | | bind = itemsArray[k][2] == 1
|
| | | };
|
| | | }
|
| | | dict.Add(trialRewards[i].grade, items);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | |
| | | return trialTokenExchangeDict.TryGetValue(lv, out list);
|
| | | }
|
| | |
|
| | | 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 List<int> GetTotalClass()
|
| | | {
|
| | | return trialTokenExchangeDict.Keys.ToList();
|
| | |
| | | error = 2;
|
| | | return false;
|
| | | }
|
| | | var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(_id);
|
| | | var config = Config.Instance.Get<TrialExchangeConfig>(_id);
|
| | | if (config == null)
|
| | | {
|
| | | return false;
|
| | |
| | | {
|
| | | NewBieCenter.Instance.RemoveNewBieGuide(TRIALEXCHANGE_GUIDE);
|
| | | }
|
| | | var tokenConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(config.tokenId);
|
| | | var tokenConfig = Config.Instance.Get<ItemConfig>(config.tokenId);
|
| | | ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),
|
| | | Language.Get("TokenUseConfirm", config.tokenCount, tokenConfig.ItemName, config.description), (bool isOk) =>
|
| | | {
|
| | | CA32F_tagCMTrialExchange pak = new CA32F_tagCMTrialExchange();
|
| | | pak.ID = (uint)_id;
|
| | | GameNetSystem.Instance.SendInfo(pak);
|
| | | if (isOk)
|
| | | {
|
| | | CA32F_tagCMTrialExchange pak = new CA32F_tagCMTrialExchange();
|
| | | pak.ID = (uint)_id;
|
| | | GameNetSystem.Instance.SendInfo(pak);
|
| | | }
|
| | | });
|
| | | return true;
|
| | | }
|
| | |
| | |
|
| | | public int EquipCompare(int _itemId)
|
| | | {
|
| | | var config = ConfigManager.Instance.GetTemplate<ItemConfig>(_itemId);
|
| | | var config = Config.Instance.Get<ItemConfig>(_itemId);
|
| | | var equipPlace = config.EquipPlace;
|
| | | if (equipPlace == 0)
|
| | | {
|
| | |
| | | {
|
| | | return 1;
|
| | | }
|
| | | var compareConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(equipItem.itemId);
|
| | | var compareConfig = Config.Instance.Get<ItemConfig>(equipItem.itemId);
|
| | | if (compareConfig == null)
|
| | | {
|
| | | return 1;
|
| | |
| | | return compareConfig.LV > config.LV ? -1 : 1;
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | public int GetExchangeItemByJob(TrialExchangeConfig config)
|
| | | {
|
| | | if (config == null)
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | if (config.exchangeItemID.Length == 1)
|
| | | {
|
| | | return config.exchangeItemID[0];
|
| | | }
|
| | | var job = PlayerDatas.Instance.baseData.Job;
|
| | | if (job - 1 < config.exchangeItemID.Length && job - 1 >= 0)
|
| | | {
|
| | | return config.exchangeItemID[job - 1];
|
| | | }
|
| | | return config.exchangeItemID[0];
|
| | | }
|
| | |
|
| | | #region 红点
|
| | |
| | | {
|
| | | if (SatisfyExchangeBetter(list[i].id))
|
| | | {
|
| | | var itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(list[i].tokenId);
|
| | | var itemConfig = Config.Instance.Get<ItemConfig>(list[i].tokenId);
|
| | | if (itemConfig.LV > maxClass)
|
| | | {
|
| | | maxClass = itemConfig.LV;
|
| | |
| | |
|
| | | public bool SatisfyExchangeBetter(int _id)
|
| | | {
|
| | | var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(_id);
|
| | | if (!CompleteTrialFloor(0))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var config = Config.Instance.Get<TrialExchangeConfig>(_id);
|
| | | if (config == null)
|
| | | {
|
| | | return false;
|
| | |
| | | {
|
| | | return false;
|
| | | }
|
| | | var exchangeItemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(config.exchangeItemID);
|
| | | var exchangeItemConfig = Config.Instance.Get<ItemConfig>(GetExchangeItemByJob(config));
|
| | | if (exchangeItemConfig.EquipPlace == 0)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | if (EquipCompare(config.exchangeItemID) == 1)
|
| | | if (EquipCompare(GetExchangeItemByJob(config)) == 1)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | var itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(list[i].exchangeItemID);
|
| | | var itemConfig = Config.Instance.Get<ItemConfig>(GetExchangeItemByJob(list[i]));
|
| | | if (SatisfyExchangeBetter(list[i].id) && itemConfig.EquipPlace != 0)
|
| | | {
|
| | | _id = list[i].id;
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | public bool IsAnySatisfyExchangeBetter()
|
| | | public bool IsAnySatisfyExchangeBetter(int _itemId)
|
| | | {
|
| | | int _class = 0;
|
| | | return TryGetSatisfyExchange(out _class);
|
| | | if (!trialTokens.Contains(_itemId))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var config = Config.Instance.Get<ItemConfig>(_itemId);
|
| | | List<TrialExchangeConfig> list;
|
| | | if (TryGetTrialExchanges(config.LV, out list))
|
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | if (list[i].tokenId == _itemId && SatisfyExchangeBetter(list[i].id))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | | #endregion
|
| | | }
|