using vnxbqy.UI; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class SpiritEquipModel : ILModel { const int SpiritEquRedPointID = 119; const int SpiritBagRedPointID = 11901; const int SpiritBreachRedpointID = 11902; const int FosterRedpointID = 1910239; PackModel packModel; RoleEquipType[] equTypes = new RoleEquipType[] { RoleEquipType.Guard, RoleEquipType.Wing, RoleEquipType.PeerlessWeapon1, RoleEquipType.PeerlessWeapon2, }; Redpoint spiritEquRedPoint; Redpoint spiritBagRedPoint; Redpoint spiritBreachRedPoint; Redpoint FosterRedPoint; public Redpoint breachBtnRedPoint; public Dictionary redPoints; public List showItemTable = new List(); List relatedItems = new List(); public event Action refreshShowItemEvent; public event Action UpdateShowWindow ; public RoleEquipType curEquType; public bool IsEquipBreachOpen = false; public int beforeBeachItemID; public int afterBeachItemID; public Dictionary redCheckDic = new Dictionary(); public Dictionary redBreachDic = new Dictionary(); protected override void Init() { this.SetRelatedItems(); packModel = ModelCenter.Instance.GetModel(); packModel.refreshItemCountEvent += OnRelatedItemsChange; GameEvent.playerLoginOkEvent += OnPlayerLoginOk; spiritEquRedPoint = new Redpoint(1, SpiritEquRedPointID); spiritBagRedPoint = new Redpoint(SpiritEquRedPointID, SpiritBagRedPointID); spiritBreachRedPoint = new Redpoint(SpiritEquRedPointID, SpiritBreachRedpointID); FosterRedPoint = new Redpoint(SpiritBreachRedpointID, FosterRedpointID); redPoints = new Dictionary(); for (int i = 0; i < equTypes.Length; i++) { var type = equTypes[i]; redPoints.Add((int)type, new Redpoint(SpiritBreachRedpointID,1910200 + (int)type)); redCheckDic.Add((int)type, false); redBreachDic.Add((int)type, false); } breachBtnRedPoint = new Redpoint(SpiritBreachRedpointID,1910230); for (int i = 0; i < equTypes.Length; i++) { var type = equTypes[i]; for (int j = 0; j < GeneralDefine.LingQiTrainIDList[(int)type].Count; j++) { int id = GeneralDefine.LingQiTrainIDList[(int)type][j]; if (this.relatedItems.Contains(id) == false) this.relatedItems.Add(id); } } } protected override void UnInit() { packModel.refreshItemCountEvent -= OnRelatedItemsChange; GameEvent.playerLoginOkEvent -= OnPlayerLoginOk; } void OnPlayerLoginOk() { this.RefreshShowItemTable(); DayRemind.Instance.SetDayRemind("SpiritEquipOverdueRemind"); this.UpdateRedPoint(); SinglePack singPack = packModel.GetSinglePack(PackType.Item); if (singPack == null) return; var packItemsDict = singPack.GetAllItems(); var keys = packItemsDict.Keys.ToList(); //for (var index in singPack.GetAllItems().Keys) for (int i = 0; i < keys.Count; i++) { OnRelatedItemsChange(singPack.type, keys[i], packItemsDict[keys[i]].itemId); } } public void CallUpdateShowWindow(int _ID) { if (UpdateShowWindow != null) UpdateShowWindow(_ID); } public ItemTipUtility.BaseProperty GetBaseProperty(int itemId) { var baseProperties = new List(); var config = ItemConfig.Get(itemId); if (config.Effect1 == 220) return this.GetBaseProperty(config.EffectValueA1); if (ItemLogicUtility.Instance.IsDogzEquip(itemId) == false && config.Effect1 != 0) baseProperties.Add(new Int2(config.Effect1, config.EffectValueA1)); if (config.Effect2 != 0) baseProperties.Add(new Int2(config.Effect2, config.EffectValueA2)); if (config.Effect3 != 0) baseProperties.Add(new Int2(config.Effect3, config.EffectValueA3)); if (config.Effect4 != 0) baseProperties.Add(new Int2(config.Effect4, config.EffectValueA4)); if (config.Effect5 != 0) baseProperties.Add(new Int2(config.Effect5, config.EffectValueA5)); var baseProperty = new ItemTipUtility.BaseProperty(); baseProperty.baseProperties = baseProperties; return baseProperty; } void SetRemind() { DayRemind.Instance.SetDayRemind("SpiritEquipOverdueRemind", true); this.UpdateRedPoint(); } public void UpdateRedPoint() { var bodyEquScores = new Dictionary(); var bHasEquCanUp = false; var bHasBetterEqu = false; for (int i = 0; i < equTypes.Length; i++) { var palce = new Int2(0, (int)equTypes[i]); var index = EquipSet.ClientPlaceToServerPlace(palce); var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index); var score = 0; SpiritWeaponConfig config = null; var bIsEquCanUp = false; if (itemModel != null) config = SpiritWeaponConfig.Get(itemModel.itemId); if (config != null) { score = config.AttrScore; if (config.UpCostItem.Length > 0) bIsEquCanUp = true; for (int t = 0; t < config.UpCostItem.Length; t++) { var costItemId = config.UpCostItem[t].x; var reamianCount = this.packModel.GetItemCountByID(PackType.Item, costItemId); if (reamianCount < config.UpCostItem[t].y) { bIsEquCanUp = false; break; } } } int type = (int)equTypes[i]; bodyEquScores[type] = score; if (bIsEquCanUp) { bHasEquCanUp = true; this.redPoints[type].state = RedPointState.Simple; redBreachDic[type] = true; } else { this.redPoints[type].state = RedPointState.None; redBreachDic[type] = false; } //设置培养红点 redCheckDic[type] = FosterModel.Instance.GetLingQiRedPointUpdate(type); this.redPoints[type].state = RedPointState.None; if (config == null) redCheckDic[type] = false; } var isOnlyOverdue = true; for (int i = 0; i < showItemTable.Count; i++) { var itemId = showItemTable[i].itemId; if (!ItemLogicUtility.Instance.IsOverdue(showItemTable[i].guid)) isOnlyOverdue = false; if (SpiritWeaponConfig.Has(itemId)) { var place = ItemConfig.Get(itemId).EquipPlace; var score = SpiritWeaponConfig.Get(itemId).AttrScore; if (score > bodyEquScores[place]) { bHasBetterEqu = true; break; } } } if (bHasEquCanUp) this.spiritBreachRedPoint.state = RedPointState.Simple; else this.spiritBreachRedPoint.state = RedPointState.None; if (bHasBetterEqu && isOnlyOverdue) bHasBetterEqu = !DayRemind.Instance.GetDayRemind("SpiritEquipOverdueRemind"); if (bHasBetterEqu) this.spiritBagRedPoint.state = RedPointState.Simple; else this.spiritBagRedPoint.state = RedPointState.None; FosterRedPoint.state = RedPointState.None; for (int i = 0; i < equTypes.Length; i++) { int type = (int)equTypes[i]; if (redCheckDic[type]) { FosterRedPoint.state = RedPointState.Simple; this.redPoints[type].state = RedPointState.Simple; } } } public void ShowFosterRedPoint(int EquipID) { FosterRedPoint.state = RedPointState.None; if(redCheckDic[EquipID]) FosterRedPoint.state = RedPointState.Simple; } void SetRelatedItems() { var configs = SpiritWeaponConfig.GetValues(); for (int i = 0; i < configs.Count; i++) { var config = configs[i]; if (this.relatedItems.Contains(config.ItemID) == false) this.relatedItems.Add(config.ItemID); for (int j = 0; j < config.UpCostItem.Length; j++) { var item = config.UpCostItem[j]; if (this.relatedItems.Contains(item.x) == false) this.relatedItems.Add(item.x); } } DebugEx.LogFormat("SetRelatedItems:{0}", relatedItems.Count); } void OnRelatedItemsChange(PackType type, int index, int id) { //DebugEx.LogFormat("OnRelatedItemsChange:{0},{0}", id,this.relatedItems.Contains(id)); if (!this.relatedItems.Contains(id)) return; this.RefreshShowItemTable(); this.UpdateRedPoint(); refreshShowItemEvent?.Invoke(); } void RefreshShowItemTable() { this.showItemTable.Clear(); var firstMatIndex = 0; for (int i = 0; i < this.relatedItems.Count; i++) { var item = relatedItems[i]; var itemModelList = this.packModel.GetItemsById(PackType.Item, item); for (int j = 0; j < itemModelList.Count; j++) { var model = itemModelList[j]; var bIsEqu = SpiritWeaponConfig.Has(model.itemId); if (bIsEqu == false) this.showItemTable.Add(model); else { this.showItemTable.Insert(firstMatIndex, model); firstMatIndex++; } } } } public void SendBreachInfo(RoleEquipType equType) { this.curEquType = equType; var place = new Int2(0, (int)equType); var index = EquipSet.ClientPlaceToServerPlace(place); var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index); this.beforeBeachItemID = itemModel.itemId; var info = new IL_CA318_tagCMLingQiEquipBreak(); info.ItemID = (uint)this.beforeBeachItemID; GameNetSystem.Instance.SendInfo(info); } public void ReciveBreachResult(IL_HA815_tagMCLingQiEquipBreakResult info) { this.afterBeachItemID = (int)info.MakeItemID; WindowCenter.Instance.OpenIL(); } }