using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using LitJson; namespace vnxbqy.UI { public class EquipModel : Model, IAfterPlayerDataInitialize, IPlayerLoginOk { public static readonly List realmEquipTypes = new List() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; public int showedUnLockLevel { get { return LocalSave.GetInt(StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, "EquipSetUnLockHasShowed"), 1); } set { LocalSave.SetInt(StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, "EquipSetUnLockHasShowed"), value); } } public readonly List showedSuitPlaceEffect = new List(); public readonly List showedSuitLevelEffect = new List(); public readonly List remindedSuitSetAppearances = new List(); public readonly LogicInt selectedLevel = new LogicInt(); public readonly LogicString selectedEquip = new LogicString(); public readonly LogicInt selectedStarLevel = new LogicInt(); public readonly LogicStruct appearance = new LogicStruct(); public readonly LogicInt fightPoint = new LogicInt(); public readonly LogicList candidateEquips = new LogicList(); public readonly LogicList getWays = new LogicList(); public readonly LogicBool isAppearanceLevel = new LogicBool(); public readonly LogicList suitPlaces = new LogicList(); public readonly LogicStruct suitProperty = new LogicStruct(); public readonly LogicList suitPlaceCollectEffects = new LogicList(); public readonly LogicStruct suitActive = new LogicStruct(); public bool isOpenSuiteAttrRect = false; //用于升星可激活套装属性时 static Dictionary equipSetNames = new Dictionary(); Dictionary equipSets = new Dictionary(); List sortedLevels = new List(); public uint[] suitActiveState; //套装手动点击激活状态 public Dictionary equipAddEffect = new Dictionary(); //额外的全身特效 PackModel packModel { get { return ModelCenter.Instance.GetModel(); } } EquipStarModel starModel { get { return ModelCenter.Instance.GetModel(); } } EquipStrengthModel strengthModel { get { return ModelCenter.Instance.GetModel(); } } EquipTrainModel trainModel { get { return ModelCenter.Instance.GetModel(); } } public event Action appearanceChangeEvent; public event Action OnSelectSetEvent; public event Action OnSelectFuncSetEvent; // 装备功能选中阶(如锻造) public void OnPlayerLoginOk() { UpdateRedpoints(); UpdateSuitRedPoints(); } public override void Init() { ParseConfig(); packModel.refrechPackEvent += OnItemPackRefresh; packModel.refreshItemCountEvent += OnItemCountRefresh; PlayerDatas.Instance.playerDataRefreshEvent += OnPlayerDataRefresh; } public override void UnInit() { packModel.refrechPackEvent -= OnItemPackRefresh; packModel.refreshItemCountEvent -= OnItemCountRefresh; PlayerDatas.Instance.playerDataRefreshEvent -= OnPlayerDataRefresh; refreshAllSuitPoint = false; } public Dictionary EquipLevelFuncID = new Dictionary(); public void ParseEquipLevelFuncID() { var textConfig = FuncConfigConfig.Get("EquipPlusByFuncID"); var json = JsonMapper.ToObject(textConfig.Numerical1); foreach (var key in json.Keys) { var funcid = int.Parse(key); EquipLevelFuncID[funcid] = (int)json[key]; } } public void OnAfterPlayerDataInitialize() { var playerId = PlayerDatas.Instance.baseData.PlayerID; showedSuitPlaceEffect.Clear(); var showedSuitPlaceEffectsRecord = LocalSave.GetIntArray(StringUtility.Contact(playerId, "_showedSuitPlaceEffect")); if (showedSuitPlaceEffectsRecord != null) { showedSuitPlaceEffect.AddRange(showedSuitPlaceEffectsRecord); } showedSuitLevelEffect.Clear(); var showedSuitLevelEffectsRecord = LocalSave.GetIntArray(StringUtility.Contact(playerId, "_showedSuitLevelEffect")); if (showedSuitLevelEffectsRecord != null) { showedSuitLevelEffect.AddRange(showedSuitLevelEffectsRecord); } remindedSuitSetAppearances.Clear(); var remindedSetAppearancesRecord = LocalSave.GetIntArray(StringUtility.Contact(playerId, "_reminedSuitLevelSetAppearance")); if (remindedSetAppearancesRecord != null) { remindedSuitSetAppearances.AddRange(remindedSetAppearancesRecord); } } public bool IsLevelUnLocked(int level) { if (!equipSets.ContainsKey(level)) { return false; } return equipSets[level].unLocked; } public int GetLastestUnLockEquipSet() { for (int i = sortedLevels.Count - 1; i >= 0; i--) { var level = sortedLevels[i]; if (equipSets[level].unLocked) { return level; } } return 1; } public int GetFirstRedpointEquipSet() { for (int i = 0; i < sortedLevels.Count; i++) { var level = sortedLevels[i]; if (equipSets[level].redpoint.state != RedPointState.None) { return level; } } return GetLastestUnLockEquipSet(); } public void OneKeyPutOn(int level) { var items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams() { levels = level == 0 ? null : new List() { level }, equipTypes = realmEquipTypes, jobs = new List() { PlayerDatas.Instance.baseData.Job, 0 }, }); items.Sort((x, y) => { return -x.score.CompareTo(y.score); }); var exceptEquips = new Dictionary(); for (int i = 0; i < items.Count; i++) { var item = items[i]; if (!exceptEquips.ContainsKey(item.config.EquipPlace) && CompareToCurrent(item.guid) > 0) { exceptEquips[item.config.EquipPlace] = item.guid; } } if (exceptEquips.Count > 0) { foreach (var guid in exceptEquips.Values) { ItemOperateUtility.Instance.PutOnItem(guid); } } else { SysNotifyMgr.Instance.ShowTip("WearRealmEquip"); } } public int GetSuitRepoindStar(int level) { var equipSet = GetEquipSet(level); int i = 0; foreach (int star in EquipStarModel.StarList) { if (equipSet.suitRepoints[star].state == RedPointState.Simple) return i; i++; } return -1; } // 装备功能选中阶(如锻造) // 20191126 装备阶标签独立提取出来方便操作 public void SelectFuncSet(int level) { if (OnSelectFuncSetEvent != null) OnSelectFuncSetEvent(level); if (WindowCenter.Instance.IsOpen()) { SelectSet(level); } } public void SelectSet(int level) { selectedLevel.value = level; if (selectedLevel.dirty) { selectedStarLevel.value = 0; selectedStarLevel.dirty = true; appearance.value = GetAppearance(level); fightPoint.value = GetFightPoint(level); } if (selectedLevel.dirty) { RefreshCandidateEquips(level); } foreach (var item in equipSets.Values) { item.selected.value = item.level == selectedLevel.value; } UpdateAppearanceState(level); UpdateSuitPlaces(level, selectedStarLevel.value); UpdateSuitProperty(level, selectedStarLevel.value); if (OnSelectSetEvent != null) OnSelectSetEvent(level); } public void SelectSuitStarLevel(int star) { selectedStarLevel.value = star; UpdateSuitPlaces(selectedLevel.value, star); UpdateSuitProperty(selectedLevel.value, star); } public void ResetOperateParams() { selectedLevel.value = 0; selectedStarLevel.value = 0; fightPoint.value = 0; appearance.value = default(EquipAppearance); suitProperty.value = default(EquipSuitProperty); suitPlaces.Clear(); candidateEquips.Clear(); getWays.Clear(); suitPlaceCollectEffects.Clear(); suitActive.value = default(EquipSuitActive); } public void UpdatePack(HA3B2_tagMCEquipPartSuiteActivateInfo netData) { suitActiveState = netData.SuiteActivateStateInfo; if (selectedLevel.value > 0) { UpdateSuitProperty(selectedLevel.value, selectedStarLevel.value); UpdateRedpoint(selectedLevel.value); UpdateSuitRedPoint(selectedLevel.value); } } public bool IsSuitActiveByHand(int activeIndex) { if (suitActiveState == null) return false; int index = activeIndex / 31; //每个数按位存31个激活索引 if (index > suitActiveState.Length) return false; //suitActiveState[index]&(2< 0 ? true : false; } private void RefreshCandidateEquips(int level) { candidateEquips.Clear(); var levels = new List() { level }; foreach (var set in equipSets) { if (!set.Value.unLocked && !levels.Contains(set.Key)) { levels.Add(set.Key); } } var items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams() { levels = levels, equipTypes = realmEquipTypes, jobs = new List() { PlayerDatas.Instance.baseData.Job, 0 }, }); if (items != null) { foreach (var item in items) { candidateEquips.Add(new CandidateEquip(item.guid)); } //candidateEquips.Sort((x, y) => // { // var betterX = CompareToCurrent(x.guid); // var betterY = CompareToCurrent(y.guid); // if (betterX > 0 && betterY < 0) // { // return -1; // } // else if (betterX < 0 && betterY > 0) // { // return 1; // } // else // { // var a = packModel.GetItemByGuid(x.guid); // var b = packModel.GetItemByGuid(y.guid); // return -a.score.CompareTo(b.score); // } // }); } } public bool HasSamePlaceCandidateEquip(Int2 equipPosition) { for (int i = 0; i < candidateEquips.Count; i++) { var item = packModel.GetItemByGuid(candidateEquips[i].guid); if (item != null && item.config.LV == equipPosition.x && item.config.EquipPlace == equipPosition.y) { return true; } } return false; } public void RecommendCandidateEquip(Int2 equipPosition) { var highestScore = 0; var highestScoreEquip = string.Empty; for (int i = 0; i < candidateEquips.Count; i++) { var candidate = candidateEquips[i]; var item = packModel.GetItemByGuid(candidate.guid); if (equipPosition.x == item.config.LV && item.config.EquipPlace == equipPosition.y) { if (item.score > highestScore) { highestScore = item.score; highestScoreEquip = candidate.guid; } } } if (!string.IsNullOrEmpty(highestScoreEquip)) { candidateEquips.Sort((CandidateEquip x, CandidateEquip y) => { if (x.guid == highestScoreEquip && y.guid != highestScoreEquip) { return -1; } else if (x.guid != highestScoreEquip && y.guid == highestScoreEquip) { return 1; } else { var betterX = CompareToCurrent(x.guid); var betterY = CompareToCurrent(y.guid); if (betterX > 0 && betterY < 0) { return -1; } else if (betterX < 0 && betterY > 0) { return 1; } else { var a = packModel.GetItemByGuid(x.guid); var b = packModel.GetItemByGuid(y.guid); return -a.score.CompareTo(b.score); } } }); } for (int i = 0; i < candidateEquips.Count; i++) { candidateEquips[i].selected.value = candidateEquips[i].guid == highestScoreEquip; } } public void ClearRecommendCandidateEquip() { for (int i = 0; i < candidateEquips.Count; i++) { candidateEquips[i].selected.value = false; } } public List GetAllEquipSets() { return new List(equipSets.Keys); } public List GetUnLockedEquipSets() { var sets = new List(); for (var i = 0; i < sortedLevels.Count; i++) { var level = sortedLevels[i]; var set = equipSets[level]; if (set.unLocked) { sets.Add(set.level); } else { break; } } return sets; } public List GetUnLockedEquipSetsByFuncID(int funcID) { var sets = new List(); int limitLevel = 0; if (EquipLevelFuncID != null && EquipLevelFuncID.ContainsKey(funcID)) limitLevel = EquipLevelFuncID[funcID]; for (var i = 0; i < sortedLevels.Count; i++) { if (i < (limitLevel-1)) continue; var level = sortedLevels[i]; var set = equipSets[level]; if (set.unLocked) { sets.Add(set.level); } else { break; } } return sets; } public EquipSet GetEquipSet(int level) { if (!equipSets.ContainsKey(level)) { return null; } return equipSets[level]; } public string GetEquip(Int2 equipPosition) { var set = GetEquipSet(equipPosition.x); if (set == null) { return string.Empty; } return set.GetEquip(equipPosition.y); } public bool IsDressedInSuit(Int2 equipPosition) { var equipGuid = GetEquip(equipPosition); var equip = packModel.GetItemByGuid(equipGuid); return equip != null && equip.config.SuiteiD > 0; } public void SetAppearance(int level) { if (!equipSets.ContainsKey(level)) { return; } var pak = new C032F_tagCRequestEquipShowHide(); pak.EquipShowSwitch = (uint)level; GameNetSystem.Instance.SendInfo(pak); } public EquipAppearance GetAppearance() { var level = PlayerDatas.Instance.baseData.suitLevel; return GetAppearance(level); } public EquipAppearance GetAppearance(int level) { if (!equipSets.ContainsKey(level)) { return default(EquipAppearance); } var appearance = equipSets[level].GetAppearance(); var equipIndex = 0; equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.Wing)); var wings = packModel.GetItemByIndex(PackType.Equip, equipIndex); appearance.wings = wings == null ? 0 : wings.itemId; equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.Mount)); var mount = packModel.GetItemByIndex(PackType.Equip, equipIndex); appearance.mount = mount == null ? 0 : mount.itemId; equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.Guard)); var guard1 = packModel.GetItemByIndex(PackType.Equip, equipIndex); appearance.guard1 = guard1 == null ? 0 : guard1.itemId; equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.FashionClothes)); var fashionClothes = packModel.GetItemByIndex(PackType.Equip, equipIndex); appearance.fashionClothes = fashionClothes == null ? 0 : fashionClothes.itemId; equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.FashionWeapon)); var fashWeapon = packModel.GetItemByIndex(PackType.Equip, equipIndex); appearance.fashionWeapon = fashWeapon == null ? 0 : fashWeapon.itemId; equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.FashionWeapon2)); var fashionSecondary = packModel.GetItemByIndex(PackType.Equip, equipIndex); appearance.fashionSecondary = fashionSecondary == null ? 0 : fashionSecondary.itemId; var isSuit = true; for (var i = 1; i <= 8; i++) { var guid = GetEquip(new Int2(level, i)); var item = packModel.GetItemByGuid(guid); if (item == null || !ItemLogicUtility.Instance.IsSuitEquip(item.itemId)) { isSuit = false; break; } } appearance.isSuit = isSuit; return appearance; } public int GetSuitLevel(int level, EquipSuitType type) { if (!equipSets.ContainsKey(level)) { return -1; } var targetCount = (int)type; var maxLevel = starModel.GetTotalStarLevel(level) / targetCount; for (var targetStar = maxLevel; targetStar >= 0; targetStar--) { var count = 0; for (int place = 1; place <= 8; place++) { var equipPosition = new Int2(level, place); var isSuit = IsDressedInSuit(equipPosition); var star = starModel.GetEquipStarLevel(equipPosition); if (isSuit && star >= targetStar) { count++; if (count >= targetCount) { return targetStar; } } } } return -1; } public int GetFightPoint(int level) { if (equipSets.ContainsKey(level)) { return equipSets[level].fightPower; } else { return 0; } } public void RefreshGetWays(Int2 equipPosition) { getWays.Clear(); if (equipPosition.x != 0 && equipPosition.y != 0) { var config = EquipControlConfig.Get(equipPosition.x, equipPosition.y); getWays.AddRange(config.getWays); } } public void ClearGetWays() { getWays.Clear(); } public int CompareToCurrent(string equipGuid) { var item = packModel.GetItemByGuid(equipGuid); if (item == null) { return 0; } var level = item.config.LV; if (!equipSets.ContainsKey(level)) { return 0; } var set = equipSets[level]; return set.CompareToCurrent(equipGuid); } public bool ExistBetterEquip(int level, List places) { if (!equipSets.ContainsKey(level)) { return false; } var items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams() { levels = new List() { level }, equipTypes = places, jobs = new List() { PlayerDatas.Instance.baseData.Job, 0 }, }); var hasBetterEquip = false; var set = equipSets[level]; foreach (var equip in items) { if (CompareToCurrent(equip.guid) > 0) { hasBetterEquip = true; break; } } return hasBetterEquip; } public bool ExistBetterEquip(int level) { return ExistBetterEquip(level, realmEquipTypes); } public EquipSuitPropertyEntry GetEquipSuitEntry(int level, int star, EquipSuitType type) { var configs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, type); var suitLevel = GetSuitLevel(level, type); var actived = suitLevel >= star; var properties = new List(); foreach (var item in configs) { if (item.star == star) { properties.AddRange(item.attr); break; } } var entry = new EquipSuitPropertyEntry() { actived = actived, type = type, properties = properties }; return entry; } public bool IsSuitPlaceEffectPlayed(Int2 equipPosition) { var place = EquipSet.ClientPlaceToServerPlace(equipPosition); return showedSuitPlaceEffect.Contains(place); } public void RecordSuitPlaceEffectPlay(Int2 equipPosition) { var place = EquipSet.ClientPlaceToServerPlace(equipPosition); if (!showedSuitPlaceEffect.Contains(place)) { showedSuitPlaceEffect.Add(place); var playerId = PlayerDatas.Instance.baseData.PlayerID; LocalSave.SetIntArray(StringUtility.Contact(playerId, "_showedSuitPlaceEffect"), showedSuitPlaceEffect.ToArray()); } } public bool IsSuitLevelEffectPlayed(Int3 info) { var place = info.x * 100 + info.y * 10 + info.z; return showedSuitLevelEffect.Contains(place); } public void RecordSuitLevelEffectPlay(Int3 info) { var place = info.x * 100 + info.y * 10 + info.z; if (!showedSuitLevelEffect.Contains(place)) { showedSuitLevelEffect.Add(place); var playerId = PlayerDatas.Instance.baseData.PlayerID; LocalSave.SetIntArray(StringUtility.Contact(playerId, "_showedSuitLevelEffect"), showedSuitLevelEffect.ToArray()); } } public bool IsSetAppearanceHinted(int level) { return remindedSuitSetAppearances.Contains(level); } public void RecordSuitSetAppearanceHint(int level) { if (!remindedSuitSetAppearances.Contains(level)) { remindedSuitSetAppearances.Add(level); var playerId = PlayerDatas.Instance.baseData.PlayerID; LocalSave.SetIntArray(StringUtility.Contact(playerId, "_reminedSuitLevelSetAppearance"), remindedSuitSetAppearances.ToArray()); } } private void OnPlayerDataRefresh(PlayerDataType type) { switch (type) { case PlayerDataType.RealmLevel: UpdateRedpoints(); break; case PlayerDataType.EquipShowSwitch: UpdateAppearanceState(selectedLevel.value); var level = (int)PlayerDatas.Instance.baseData.suitLevel; if (level != 0 && level == selectedLevel.value) { var equipSet = GetEquipSet(level); if (equipSet != null) { var config = RealmConfig.Get(equipSet.realm); SysNotifyMgr.Instance.ShowTip("WearRealmEquip1", config.Name); } } break; default: break; } } private void OnItemPackRefresh(PackType type) { switch (type) { case PackType.Item: //UpdateRedpoints(); if (selectedLevel.value > 0) { RefreshCandidateEquips(selectedLevel.value); } break; case PackType.Equip: foreach (var set in equipSets.Values) { for (var i = 1; i <= 12; i++) { set.UpdateEquipSlot(i, string.Empty); } } var items = packModel.GetItems(PackType.Equip, new SinglePack.FilterParams() { }); foreach (var item in items) { var clientPlace = EquipSet.ServerPlaceToClientPlace(item.gridIndex); if (equipSets.ContainsKey(clientPlace.x)) { equipSets[clientPlace.x].UpdateEquipSlot(clientPlace.y, item.guid); } } if (selectedLevel.value > 0) { appearance.value = GetAppearance(selectedLevel.value); RefreshCandidateEquips(selectedLevel.value); UpdateSuitPlaces(selectedLevel.value, selectedStarLevel.value); UpdateSuitProperty(selectedLevel.value, selectedStarLevel.value); UpdateSuitRedPoint(selectedLevel.value); } break; default: break; } } private void OnItemCountRefresh(PackType type, int index, int itemId) { var itemDirty = false; var equipDirty = false; switch (type) { case PackType.Item: if (ItemLogicUtility.Instance.IsRealmEquip(itemId)) { var config = ItemConfig.Get(itemId); var level = config.LV; UpdateRedpoint(level); UpdateSuitRedPoint(level); if (selectedLevel.value > 0 && selectedLevel.value == level) { itemDirty = true; } } break; case PackType.Equip: var clientPlace = EquipSet.ServerPlaceToClientPlace(index); if (equipSets.ContainsKey(clientPlace.x)) { selectedLevel.value = clientPlace.x; var equip = packModel.GetItemByIndex(PackType.Equip, index); equipSets[clientPlace.x].UpdateEquipSlot(clientPlace.y, equip == null ? string.Empty : equip.guid); appearance.value = GetAppearance(selectedLevel.value); if (clientPlace.x == selectedLevel.value) { equipDirty = true; } if (clientPlace.x == PlayerDatas.Instance.baseData.suitLevel) { if (appearanceChangeEvent != null) { appearanceChangeEvent(); } } if (selectedLevel.value > 0) { UpdateSuitRedPoint(selectedLevel.value); } } break; } if (itemDirty) { RefreshCandidateEquips(selectedLevel.value); } if (equipDirty) { UpdateSuitPlaces(selectedLevel.value, selectedStarLevel.value); UpdateSuitProperty(selectedLevel.value, selectedStarLevel.value); fightPoint.value = GetFightPoint(selectedLevel.value); } } public void UpdateSuitRedPoint(int level) { var CountList = new List { 2, 5, 8 }; var redDict = new Dictionary(); var equipSet = GetEquipSet(level); foreach (int count in CountList) { var configs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, (EquipSuitType)count); for (int i = 0; i < configs.Count; i++) { var config = configs[i]; equipSet.suitRepoints[config.star].state = RedPointState.None; bool isRed; redDict.TryGetValue(config.star, out isRed); if (isRed) { continue; } var handActived = IsSuitActiveByHand(config.activateIndex); if (!handActived && GetSuitLevel(level, (EquipSuitType)count) >= config.star) { redDict[config.star] = true; //equipSet.suitRepoints[config.star].state = RedPointState.Simple; } } } foreach (int key in redDict.Keys) { if (redDict[key]) { equipSet.suitRepoints[key].state = RedPointState.Simple; } } } bool refreshAllSuitPoint = false; public void UpdateSuitRedPoints() { if (refreshAllSuitPoint) return; var unLockedLevels = GetUnLockedEquipSets(); foreach (var level in unLockedLevels) { UpdateSuitRedPoint(level); } refreshAllSuitPoint = true; } private void UpdateRedpoints() { var unLockedLevels = GetUnLockedEquipSets(); var hints = new Dictionary(); foreach (var item in unLockedLevels) { hints[item] = false; } var items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams() { levels = unLockedLevels, equipTypes = realmEquipTypes, jobs = new List() { PlayerDatas.Instance.baseData.Job, 0 }, }); foreach (var equip in items) { var level = equip.config.LV; if (hints.ContainsKey(level) && !hints[level]) { if (CompareToCurrent(equip.guid) > 0) { hints[level] = true; } } } foreach (var level in hints.Keys) { equipSets[level].redpoint.state = hints[level] ? RedPointState.Simple : RedPointState.None; } } private void UpdateRedpoint(int level) { if (!equipSets.ContainsKey(level)) { return; } var set = equipSets[level]; if (!set.unLocked) { set.redpoint.state = RedPointState.None; return; } var items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams() { levels = new List() { level }, equipTypes = realmEquipTypes, jobs = new List() { PlayerDatas.Instance.baseData.Job, 0 }, }); var hasBetterEquip = false; foreach (var equip in items) { if (CompareToCurrent(equip.guid) > 0) { hasBetterEquip = true; break; } } set.redpoint.state = hasBetterEquip ? RedPointState.Simple : RedPointState.None; } private void UpdateAppearanceState(int level) { isAppearanceLevel.value = level == PlayerDatas.Instance.baseData.suitLevel; } private void UpdateSuitPlaces(int level, int star) { suitPlaces.Clear(); suitPlaceCollectEffects.Clear(); for (int i = 1; i <= 8; i++) { var equip = packModel.GetItemByGuid(GetEquip(new Int2(level, i))); var starLevel = starModel.GetEquipStarLevel(new Int2(level, i)); var hasSuit = equip != null && equip.config.SuiteiD > 0 && starLevel >= star; if (hasSuit) { suitPlaces.Add(i); if (!IsSuitPlaceEffectPlayed(new Int2(level, i))) { suitPlaceCollectEffects.Add(i); } } } } private void UpdateSuitProperty(int level, int star) { var property = new EquipSuitProperty(); property.star = star; property.level = level; property.twoSuit = GetEquipSuitEntry(level, star, EquipSuitType.TwoSuit); property.fiveSuit = GetEquipSuitEntry(level, star, EquipSuitType.FiveSuit); var configs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.TwoSuit); for (int i = 0; i < configs.Count; i++) { var config = configs[i]; if (config.star == star) { property.handActived2 = IsSuitActiveByHand(config.activateIndex); } if (i == 0) property.suitID = config.suiteID; } configs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.FiveSuit); for (int i = 0; i < configs.Count; i++) { var config = configs[i]; if (config.star == star) { property.handActived5 = IsSuitActiveByHand(config.activateIndex); } } configs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.EightSuit); for (int i = 0; i < configs.Count; i++) { var config = configs[i]; if (config.star == star) { property.eightSuitId = config.id; property.handActived8 = IsSuitActiveByHand(config.activateIndex); } } property.eightActived = GetSuitLevel(level, EquipSuitType.EightSuit) >= star; this.suitProperty.value = property; var suitActive = new EquipSuitActive(); suitActive.level = level; suitActive.star = star; if (property.twoSuit.actived && !IsSuitLevelEffectPlayed(new Int3(level, star, 2))) { suitActive.twoActived = true; } if (property.fiveSuit.actived && !IsSuitLevelEffectPlayed(new Int3(level, star, 5))) { suitActive.fiveActived = true; } if (property.eightActived && !IsSuitLevelEffectPlayed(new Int3(level, star, 8))) { suitActive.eightActived = true; } this.suitActive.value = suitActive; } private void ParseConfig() { var configs = EquipControlConfig.GetValues(); var setLevelToRealms = new Dictionary(); foreach (var item in configs) { var level = item.level; var currentRealm = setLevelToRealms.ContainsKey(level) ? setLevelToRealms[level] : 9999; if (item.realm < currentRealm) { setLevelToRealms[level] = item.realm; } } foreach (var item in setLevelToRealms) { equipSets[item.Key] = new EquipSet(item.Key, item.Value); sortedLevels.Add(item.Key); } sortedLevels.Sort((int a, int b) => { return a.CompareTo(b); }); var equipSetNameConfig = FuncConfigConfig.Get("EquipSuitFirstName"); var json = JsonMapper.ToObject(equipSetNameConfig.Numerical1); foreach (var key in json.Keys) { var level = int.Parse(key); var name = json[key].ToString(); equipSetNames[level] = name; } ParseEquipLevelFuncID(); var equipEff = FuncConfigConfig.Get("shediaoEffect"); json = JsonMapper.ToObject(equipEff.Numerical1); foreach (var key in json.Keys) { equipAddEffect[int.Parse(key)] = int.Parse(json[key].ToString()); } } public static int GetItemServerEquipPlace(int itemId) { var config = ItemConfig.Get(itemId); if (config == null) { return -1; } var serverEquipPlace = -1; switch ((RoleEquipType)config.EquipPlace) { case RoleEquipType.Weapon: case RoleEquipType.Weapon2: case RoleEquipType.Hat: case RoleEquipType.Clothes: case RoleEquipType.Belt: case RoleEquipType.Trousers: case RoleEquipType.Shoes: case RoleEquipType.Neck: case RoleEquipType.FairyCan1: case RoleEquipType.FairyCan2: case RoleEquipType.Glove: case RoleEquipType.Jade: serverEquipPlace = EquipSet.ClientPlaceToServerPlace(new Int2(config.LV, config.EquipPlace)); break; case RoleEquipType.Wing: case RoleEquipType.Guard: case RoleEquipType.PeerlessWeapon1: case RoleEquipType.PeerlessWeapon2: serverEquipPlace = EquipSet.ClientPlaceToServerPlace(new Int2(0, config.EquipPlace)); break; } return serverEquipPlace; } public static string GetSuitName(int level) { return equipSetNames.ContainsKey(level) ? equipSetNames[level] : string.Empty; } public static bool IsRealmEquip(int equipPlace) { return realmEquipTypes.Contains(equipPlace); } //获得符合条件的装备件数(8件套) public int GetEquipCountByCond(int level, int color = 0, bool isSuit = false) { int count = 0; for (int i = 1; i <= 8; i++) { var equipGuid = GetEquip(new Int2(level, i)); var itemModel = packModel.GetItemByGuid(equipGuid); if (itemModel != null) { if (itemModel.config.ItemColor < color) continue; if (isSuit && itemModel.config.SuiteiD == 0) continue; count++; } } return count; } //获得符合条件的装备部位数(8件套) public int GetEquipSetCountByCond(int level, int star = 0, int plusLV = 0, int trainLV = 0) { int count = 0; for (int i = 1; i <= 8; i++) { if (starModel.GetStarLevel(new Int2(level, i)) < star) continue; if (strengthModel.GetStrengthLevel(level, i) < plusLV) continue; if (trainModel.GetTrainLevelEx(new Int2(level, i)) < trainLV) continue; count++; } return 0; } } public struct EquipSuitPropertyEntry { public EquipSuitType type; public bool actived; public List properties; } public struct EquipSuitProperty { public int star; public int level; public int suitID; public EquipSuitPropertyEntry twoSuit; public EquipSuitPropertyEntry fiveSuit; public int eightSuitId; public bool eightActived; public bool handActived2; public bool handActived5; public bool handActived8; } public struct EquipSuitActive { public int level; public int star; public bool twoActived; public bool fiveActived; public bool eightActived; } }