using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using System;
|
using LitJson;
|
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
public class EquipModel : Model, IAfterPlayerDataInitialize
|
{
|
public static readonly List<int> realmEquipTypes = new List<int>() { 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<int> showedSuitPlaceEffect = new List<int>();
|
public readonly List<int> showedSuitLevelEffect = new List<int>();
|
public readonly List<int> remindedSuitSetAppearances = new List<int>();
|
|
public readonly LogicInt selectedLevel = new LogicInt();
|
public readonly LogicString selectedEquip = new LogicString();
|
public readonly LogicInt selectedStarLevel = new LogicInt();
|
public readonly LogicStruct<EquipAppearance> appearance = new LogicStruct<EquipAppearance>();
|
public readonly LogicInt fightPoint = new LogicInt();
|
public readonly LogicList<CandidateEquip> candidateEquips = new LogicList<CandidateEquip>();
|
public readonly LogicList<int> getWays = new LogicList<int>();
|
public readonly LogicBool isAppearanceLevel = new LogicBool();
|
public readonly LogicList<int> suitPlaces = new LogicList<int>();
|
public readonly LogicStruct<EquipSuitProperty> suitProperty = new LogicStruct<EquipSuitProperty>();
|
|
public readonly LogicList<int> suitPlaceCollectEffects = new LogicList<int>();
|
public readonly LogicStruct<EquipSuitActive> suitActive = new LogicStruct<EquipSuitActive>();
|
|
static Dictionary<int, string> equipSetNames = new Dictionary<int, string>();
|
Dictionary<int, EquipSet> equipSets = new Dictionary<int, EquipSet>();
|
List<int> sortedLevels = new List<int>();
|
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
EquipStarModel starModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
|
public event Action appearanceChangeEvent;
|
|
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;
|
}
|
|
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<int>() { level },
|
equipTypes = realmEquipTypes,
|
jobs = new List<int>() { PlayerDatas.Instance.baseData.Job, 0 },
|
});
|
|
items.Sort((x, y) =>
|
{
|
return -x.score.CompareTo(y.score);
|
});
|
|
var exceptEquips = new Dictionary<int, string>();
|
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 void SelectSet(int level)
|
{
|
selectedLevel.value = level;
|
if (selectedLevel.dirty)
|
{
|
selectedStarLevel.value = 0;
|
selectedStarLevel.dirty = true;
|
|
appearance.value = GetAppearance(level);
|
UpdateFightPower(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);
|
UpdateSuitProperty(level, selectedStarLevel.value);
|
}
|
|
public void SelectSuitStarLevel(int star)
|
{
|
selectedStarLevel.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);
|
}
|
|
private void RefreshCandidateEquips(int level)
|
{
|
candidateEquips.Clear();
|
var levels = new List<int>() { 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<int>() { 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<int> GetAllEquipSets()
|
{
|
return new List<int>(equipSets.Keys);
|
}
|
|
public List<int> GetViewableEquipSets()
|
{
|
var sets = new List<int>();
|
var index = 0;
|
for (index = 0; index < sortedLevels.Count; index++)
|
{
|
var level = sortedLevels[index];
|
var set = equipSets[level];
|
if (set.unLocked)
|
{
|
sets.Add(set.level);
|
}
|
else
|
{
|
break;
|
}
|
}
|
|
if (index <= sortedLevels.Count - 1)
|
{
|
sets.Add(equipSets[sortedLevels[index]].level);
|
}
|
|
return sets;
|
}
|
|
public List<int> GetUnLockedEquipSets()
|
{
|
var sets = new List<int>();
|
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 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.equipShowSwitch / 10;
|
var isSuit = PlayerDatas.Instance.baseData.equipShowSwitch % 10 > 0;
|
|
var appearance = GetAppearance((int)level);
|
appearance.isSuit = isSuit;
|
return appearance;
|
}
|
|
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.Guard1));
|
var guard1 = packModel.GetItemByIndex(PackType.Equip, equipIndex);
|
appearance.guard1 = guard1 == null ? 0 : guard1.itemId;
|
|
equipIndex = EquipSet.ClientPlaceToServerPlace(new Int2(0, (int)RoleEquipType.Guard2));
|
var guard2 = packModel.GetItemByIndex(PackType.Equip, equipIndex);
|
appearance.guard2 = guard2 == null ? 0 : guard2.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;
|
|
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 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<Int2>();
|
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:
|
var lastUnLockRealm = 1;
|
UpdateRedpoint(lastUnLockRealm);
|
break;
|
case PlayerDataType.EquipShowSwitch:
|
UpdateAppearanceState(selectedLevel.value);
|
|
var level = (int)PlayerDatas.Instance.baseData.equipShowSwitch / 10;
|
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);
|
UpdateSuitProperty(selectedLevel.value, selectedStarLevel.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.IsEquip(itemId))
|
{
|
var config = ItemConfig.Get(itemId);
|
var level = config.LV;
|
UpdateRedpoint(level);
|
if (selectedLevel.value > 0 && selectedLevel.value == level)
|
{
|
itemDirty = true;
|
}
|
}
|
break;
|
case PackType.Equip:
|
var clientPlace = EquipSet.ServerPlaceToClientPlace(index);
|
if (equipSets.ContainsKey(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.equipShowSwitch / 10)
|
{
|
if (appearanceChangeEvent != null)
|
{
|
appearanceChangeEvent();
|
}
|
}
|
}
|
|
break;
|
}
|
|
if (itemDirty)
|
{
|
RefreshCandidateEquips(selectedLevel.value);
|
}
|
|
if (equipDirty)
|
{
|
UpdateSuitPlaces(selectedLevel.value);
|
UpdateSuitProperty(selectedLevel.value, selectedStarLevel.value);
|
|
UpdateFightPower(selectedLevel.value);
|
fightPoint.value = GetFightPoint(selectedLevel.value);
|
}
|
}
|
|
private void UpdateRedpoints()
|
{
|
var unLockedLevels = GetUnLockedEquipSets();
|
var hints = new Dictionary<int, bool>();
|
foreach (var item in unLockedLevels)
|
{
|
hints[item] = false;
|
}
|
|
var items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams()
|
{
|
levels = unLockedLevels,
|
equipTypes = realmEquipTypes,
|
jobs = new List<int>() { 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 items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams()
|
{
|
levels = new List<int>() { level },
|
equipTypes = realmEquipTypes,
|
jobs = new List<int>() { 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;
|
}
|
}
|
|
set.redpoint.state = hasBetterEquip ? RedPointState.Simple : RedPointState.None;
|
}
|
|
private void UpdateAppearanceState(int level)
|
{
|
isAppearanceLevel.value = level == PlayerDatas.Instance.baseData.equipShowSwitch / 10;
|
}
|
|
private void UpdateSuitPlaces(int level)
|
{
|
suitPlaces.Clear();
|
suitPlaceCollectEffects.Clear();
|
for (int i = 1; i <= 8; i++)
|
{
|
var equip = packModel.GetItemByGuid(GetEquip(new Int2(level, i)));
|
var hasSuit = equip != null && equip.config.SuiteiD > 0;
|
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.twoSuit = GetEquipSuitEntry(level, star, EquipSuitType.TwoSuit);
|
property.fiveSuit = GetEquipSuitEntry(level, star, EquipSuitType.FiveSuit);
|
|
var 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.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 UpdateFightPower(int level)
|
{
|
if (equipSets.ContainsKey(level))
|
{
|
equipSets[level].fightPower = EquipFightPower.Instance.CalculatePower(level);
|
}
|
}
|
|
private void ParseConfig()
|
{
|
var configs = EquipControlConfig.GetValues();
|
var setLevelToRealms = new Dictionary<int, int>();
|
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;
|
}
|
|
}
|
|
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.Guard1:
|
case RoleEquipType.Guard2:
|
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);
|
}
|
|
}
|
|
public struct EquipSuitPropertyEntry
|
{
|
public EquipSuitType type;
|
public bool actived;
|
public List<Int2> properties;
|
}
|
|
public struct EquipSuitProperty
|
{
|
public int star;
|
public EquipSuitPropertyEntry twoSuit;
|
public EquipSuitPropertyEntry fiveSuit;
|
public int eightSuitId;
|
public bool eightActived;
|
}
|
|
public struct EquipSuitActive
|
{
|
public int level;
|
public int star;
|
|
public bool twoActived;
|
public bool fiveActived;
|
public bool eightActived;
|
}
|
|
}
|