| | |
| | | {
|
| | | Dictionary<int, List<TrialExchangeConfig>> trialTokenExchangeDict = new Dictionary<int, List<TrialExchangeConfig>>();
|
| | | Dictionary<int, int> lineToTokenClassDict;
|
| | | 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>(); } }
|
| | | DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
| | |
| | | if (!trialTokens.Contains(configs[i].tokenId))
|
| | | {
|
| | | trialTokens.Add(configs[i].tokenId);
|
| | | List<int> _tokens;
|
| | | if (!trialClassTokens.TryGetValue(itemConfig.LV, out _tokens))
|
| | | {
|
| | | _tokens = new List<int>();
|
| | | trialClassTokens.Add(itemConfig.LV, _tokens);
|
| | | }
|
| | | if (!_tokens.Contains(configs[i].tokenId))
|
| | | {
|
| | | _tokens.Add(configs[i].tokenId);
|
| | | }
|
| | | }
|
| | | }
|
| | | var funcConfig = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("LineToItemStage");
|
| | |
| | | private void RefreshItemCountAct(PackType packType, int arg2, int itemId)
|
| | | {
|
| | | if (packType == PackType.rptItem && trialTokens.Contains(itemId))
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | | else if (packType == PackType.rptEquip)
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
| | | {
|
| | | NewBieCenter.Instance.RemoveNewBieGuide(TRIALEXCHANGE_GUIDE);
|
| | | }
|
| | | var tokenConfig = ConfigManager.Instance.GetTemplate<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);
|
| | | });
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | | SysNotifyMgr.Instance.ShowTip("TrialExchangeLimit");
|
| | | }
|
| | |
|
| | | public int EquipCompare(int _itemId)
|
| | | {
|
| | | var config = ConfigManager.Instance.GetTemplate<ItemConfig>(_itemId);
|
| | | var equipPlace = config.EquipPlace;
|
| | | if (equipPlace == 0)
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | var singlepack = packModel.GetSinglePackModel(PackType.rptEquip);
|
| | | if (singlepack == null)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | var equipItem = singlepack.GetItemModelByIndex(equipPlace);
|
| | | if (equipItem == null)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | var compareConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(equipItem.itemId);
|
| | | if (compareConfig == null)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | if (compareConfig.ItemColor != config.ItemColor)
|
| | | {
|
| | | return compareConfig.ItemColor > config.ItemColor ? -1 : 1;
|
| | | }
|
| | | if (compareConfig.StarLevel != config.StarLevel)
|
| | | {
|
| | | return compareConfig.StarLevel > config.StarLevel ? -1 : 1;
|
| | | }
|
| | | if (compareConfig.LV != config.LV)
|
| | | {
|
| | | return compareConfig.LV > config.LV ? -1 : 1;
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | #region 红点
|
| | | void UpdateRedpoint()
|
| | | {
|
| | |
| | |
|
| | | public bool TryGetSatisfyExchange(out int maxClass)
|
| | | {
|
| | | var configs = ConfigManager.Instance.GetAllValues<TrialExchangeConfig>();
|
| | | maxClass = 0;
|
| | | for (int i = 0; i < configs.Count; i++)
|
| | | foreach (var _class in trialTokenExchangeDict.Keys)
|
| | | {
|
| | | var count = GetTrialTokenCount(configs[i].tokenId);
|
| | | if (count >= configs[i].tokenCount)
|
| | | List<TrialExchangeConfig> list;
|
| | | if (TryGetTrialExchanges(_class, out list))
|
| | | {
|
| | | var itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(configs[i].tokenId);
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | if (SatisfyExchangeBetter(list[i].id))
|
| | | {
|
| | | var itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(list[i].tokenId);
|
| | | if (itemConfig.LV > maxClass)
|
| | | {
|
| | | maxClass = itemConfig.LV;
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return maxClass != 0;
|
| | | }
|
| | |
|
| | | public bool SatisfyExchangeBetter(int _id)
|
| | | {
|
| | | var config = ConfigManager.Instance.GetTemplate<TrialExchangeConfig>(_id);
|
| | | if (config == null)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var count = GetTrialTokenCount(config.tokenId);
|
| | | if (count < config.tokenCount)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var exchangeItemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(config.exchangeItemID);
|
| | | if (exchangeItemConfig.EquipPlace == 0)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | if (EquipCompare(config.exchangeItemID) == 1)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool IsAnySatisfyExchangeBetterEquip(int _class, out int _id)
|
| | | {
|
| | | _id = -1;
|
| | | List<TrialExchangeConfig> list;
|
| | | if (TryGetTrialExchanges(_class, out list))
|
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | var itemConfig = ConfigManager.Instance.GetTemplate<ItemConfig>(list[i].exchangeItemID);
|
| | | if (SatisfyExchangeBetter(list[i].id) && itemConfig.EquipPlace != 0)
|
| | | {
|
| | | _id = list[i].id;
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool IsAnySatisfyExchangeBetter()
|
| | | {
|
| | | int _class = 0;
|
| | | return TryGetSatisfyExchange(out _class);
|
| | | }
|
| | | #endregion
|
| | | }
|
| | | } |