using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
using System;
|
using System.Linq;
|
using Snxxz.UI;
|
|
namespace Snxxz.UI
|
{
|
[XLua.Hotfix]
|
[XLua.LuaCallCSharp]
|
public class MagicianModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
public event Action onSelectUpdate;
|
|
PlayerPackModel packModel
|
{
|
get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); }
|
}
|
|
bool serverInited = false;
|
|
public override void Init()
|
{
|
ParseConfig();
|
packModel.RefreshItemCountAct += RefreshPackItem;
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
|
}
|
|
private void OnFuncStateChangeEvent(int func)
|
{
|
if (func == (int)FuncOpenEnum.GodWeapon)
|
{
|
UpdateRedPoint();
|
}
|
}
|
|
private void RefreshPackItem(PackType packType, int index, int id)
|
{
|
if (packType != PackType.Item)
|
{
|
return;
|
}
|
UpdateRedPoint();
|
}
|
|
private void PlayerDataRefreshInfoEvent(PlayerDataRefresh refreshType)
|
{
|
if (refreshType == PlayerDataRefresh.LV)
|
{
|
UpdateRedPoint();
|
}
|
}
|
|
public override void UnInit()
|
{
|
packModel.RefreshItemCountAct -= RefreshPackItem;
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerDataRefreshInfoEvent;
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
serverInited = false;
|
foreach (var godWeapon in godWeaponInfoDict.Values)
|
{
|
godWeapon.level = 0;
|
godWeapon.exp = 0;
|
}
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
serverInited = true;
|
UpdateRedPoint();
|
CheckGodWeaponEffectOn();
|
}
|
|
private Dictionary<int, int[]> godWeaponLevelUpCost = new Dictionary<int, int[]>();
|
public List<int> godWeaponTypes { get; private set; }
|
public Dictionary<int, int> godWeaponBoxDict { get; private set; } //key 神兵石礼包 value 神兵类型
|
public List<int> godWeaponEffectTypes { get; private set; }
|
public Dictionary<int, string> godWeaponIcons { get; private set; }
|
public Dictionary<int, Dictionary<int, int>> godWeaponSkillDict = new Dictionary<int, Dictionary<int, int>>();
|
Dictionary<int, List<GodWeaponCondition>> godWeaponConditions = new Dictionary<int, List<GodWeaponCondition>>();
|
Dictionary<int, int> playerLevelConditions = new Dictionary<int, int>();
|
public List<int> godWeaponSorts = new List<int>();
|
Dictionary<int, AutoHammerCost> autoHammerCostDict = new Dictionary<int, AutoHammerCost>();
|
Dictionary<int, List<int>> godWeaponStageDict = new Dictionary<int, List<int>>();
|
Dictionary<int, int> exteriorPowerDict = new Dictionary<int, int>();
|
Dictionary<int, int> godWeaponSkillEffect = new Dictionary<int, int>();
|
Dictionary<int, int> singleHarmmerExp = new Dictionary<int, int>();
|
Dictionary<int, List<GodWeaponEffectProperty>> effectPropertyDict =
|
new Dictionary<int, List<GodWeaponEffectProperty>>();
|
Dictionary<int, Dictionary<int, int>> effectFightPower = new Dictionary<int, Dictionary<int, int>>();
|
Dictionary<int, int> godWeaponEffectEquipDict = new Dictionary<int, int>();
|
Dictionary<int, List<GodWeaponEffectInfo>> godWeaponEffectInfos = new Dictionary<int, List<GodWeaponEffectInfo>>();
|
int[] autoHammerExpArea { get; set; }
|
int[] autoHammerCount { get; set; }
|
|
int m_SelectType = 0;
|
public int selectType
|
{
|
get { return m_SelectType; }
|
set
|
{
|
if (m_SelectType != value)
|
{
|
m_SelectType = value;
|
if (onSelectUpdate != null)
|
{
|
onSelectUpdate();
|
}
|
}
|
}
|
}
|
|
public int selectItemIndex = 0;
|
public int gotoType = 0;
|
|
public int autoHammerLevel { get; set; }
|
|
public int hammerAudioId { get; private set; }
|
public int audioLength { get; private set; }
|
void ParseConfig()
|
{
|
var godWeaponBox = FuncConfigConfig.Get("GodWeaponBox");
|
godWeaponBoxDict = ConfigParse.GetDic<int, int>(godWeaponBox.Numerical1);
|
|
godWeaponTypes = GodWeaponConfig.GetGodWeaponType();
|
for (int i = 0; i < godWeaponTypes.Count; i++)
|
{
|
GodWeaponInfo godWeapon = new GodWeaponInfo()
|
{
|
exp = 0,
|
level = 0,
|
type = godWeaponTypes[i],
|
};
|
godWeaponInfoDict.Add(godWeapon.type, godWeapon);
|
|
if (!redpointDict.ContainsKey(godWeapon.type))
|
{
|
Redpoint redpoint = new Redpoint(MAGICAIN_REDPOINT, MAGICAIN_REDPOINT * MAGICAIN_INTERVAL + godWeapon.type);
|
redpointDict.Add(godWeapon.type, redpoint);
|
redpoint.state = RedPointState.None;
|
}
|
|
var config = FuncConfigConfig.Get(string.Format("GodWeapon{0}", godWeaponTypes[i]));
|
int[] itemarray = ConfigParse.GetMultipleStr<int>(config.Numerical1);
|
godWeaponLevelUpCost.Add(godWeaponTypes[i], itemarray);
|
}
|
|
godWeaponIcons = new Dictionary<int, string>();
|
var _cfg = FuncConfigConfig.Get("GodModel");
|
var _godWeaponJson = LitJson.JsonMapper.ToObject(_cfg.Numerical2);
|
foreach (var _key in _godWeaponJson.Keys)
|
{
|
var _godWeaponType = int.Parse(_key);
|
if (!godWeaponIcons.ContainsKey(_godWeaponType))
|
{
|
godWeaponIcons.Add(_godWeaponType, _godWeaponJson[_key].ToString());
|
}
|
}
|
|
var configs = GodWeaponConfig.GetValues();
|
for (int i = 0; i < configs.Count; i++)
|
{
|
if (configs[i].SkillID != 0)
|
{
|
Dictionary<int, int> _dict = null;
|
if (!godWeaponSkillDict.TryGetValue(configs[i].Type, out _dict))
|
{
|
_dict = new Dictionary<int, int>();
|
godWeaponSkillDict.Add(configs[i].Type, _dict);
|
}
|
_dict.Add(configs[i].Lv, configs[i].SkillID);
|
}
|
}
|
|
var conditionConfig = FuncConfigConfig.Get("GodWeaponActive");
|
var json = LitJson.JsonMapper.ToObject(conditionConfig.Numerical2);
|
foreach (var key in json.Keys)
|
{
|
var type = int.Parse(key);
|
List<GodWeaponCondition> list;
|
if (!godWeaponConditions.TryGetValue(type, out list))
|
{
|
list = new List<GodWeaponCondition>();
|
godWeaponConditions.Add(type, list);
|
}
|
int[][] conditions = LitJson.JsonMapper.ToObject<int[][]>(json[key].ToJson());
|
for (int i = 0; i < conditions.Length; i++)
|
{
|
var condition = conditions[i];
|
list.Add(new GodWeaponCondition()
|
{
|
type = condition[0],
|
level = condition[1],
|
});
|
}
|
}
|
|
json = LitJson.JsonMapper.ToObject(conditionConfig.Numerical3);
|
foreach (var key in json.Keys)
|
{
|
var type = int.Parse(key);
|
playerLevelConditions.Add(type, int.Parse(json[key].ToString()));
|
}
|
|
var sortConfig = FuncConfigConfig.Get("GodWeaponSort");
|
godWeaponSorts.AddRange(ConfigParse.GetMultipleStr<int>(sortConfig.Numerical1));
|
|
var autoHammerConfig = FuncConfigConfig.Get("GodWeaponAutoHammer");
|
if (autoHammerConfig != null)
|
{
|
autoHammerExpArea = ConfigParse.GetMultipleStr<int>(autoHammerConfig.Numerical1);
|
autoHammerCount = ConfigParse.GetMultipleStr<int>(autoHammerConfig.Numerical2);
|
singleHarmmerExp = ConfigParse.GetDic<int, int>(autoHammerConfig.Numerical3);
|
}
|
|
var funcConfig = FuncConfigConfig.Get("GodMagicExp");
|
json = LitJson.JsonMapper.ToObject(funcConfig.Numerical1);
|
foreach (var key in json.Keys)
|
{
|
var type = int.Parse(key);
|
var array = LitJson.JsonMapper.ToObject<int[]>(json[key].ToJson());
|
autoHammerCostDict.Add(type, new AutoHammerCost()
|
{
|
cost = array[0],
|
exp = array[1],
|
});
|
}
|
|
godWeaponEffectTypes = new List<int>();
|
var godWeaponEffects = GodWeaponEffectConfig.GetValues();
|
for (int i = 0; i < godWeaponEffects.Count; i++)
|
{
|
var config = godWeaponEffects[i];
|
List<int> stages;
|
if (!godWeaponStageDict.TryGetValue(config.type, out stages))
|
{
|
stages = new List<int>();
|
godWeaponStageDict.Add(config.type, stages);
|
}
|
stages.Add(config.level);
|
List<GodWeaponEffectProperty> list;
|
if (!effectPropertyDict.TryGetValue(config.type, out list))
|
{
|
list = new List<GodWeaponEffectProperty>();
|
effectPropertyDict.Add(config.type, list);
|
}
|
list.Add(new GodWeaponEffectProperty()
|
{
|
level = config.level,
|
propertyDict = ConfigParse.GetDic<int, int>(config.attr),
|
});
|
Dictionary<int, int> dict;
|
if (!effectFightPower.TryGetValue(config.type, out dict))
|
{
|
dict = new Dictionary<int, int>();
|
effectFightPower.Add(config.type, dict);
|
}
|
dict.Add(config.level, config.fightPower);
|
|
if (!godWeaponEffectTypes.Contains(config.type))
|
{
|
godWeaponEffectTypes.Add(config.type);
|
}
|
|
List<GodWeaponEffectInfo> effectInfos;
|
if (!godWeaponEffectInfos.TryGetValue(config.type, out effectInfos))
|
{
|
effectInfos = new List<GodWeaponEffectInfo>();
|
godWeaponEffectInfos.Add(config.type, effectInfos);
|
}
|
Dictionary<int, string> skillIconDict = new Dictionary<int, string>();
|
var iconJson = LitJson.JsonMapper.ToObject(config.icon);
|
foreach (var key in iconJson.Keys)
|
{
|
var job = int.Parse(key);
|
skillIconDict.Add(job, iconJson[key].ToString());
|
}
|
effectInfos.Add(new GodWeaponEffectInfo()
|
{
|
level = config.level,
|
skillIconDict = skillIconDict,
|
});
|
}
|
|
funcConfig = FuncConfigConfig.Get("MagicExterior");
|
json = LitJson.JsonMapper.ToObject(funcConfig.Numerical1);
|
foreach (var key in json.Keys)
|
{
|
var type = int.Parse(key);
|
var power = int.Parse(json[key].ToString());
|
exteriorPowerDict.Add(type, power);
|
}
|
|
funcConfig = FuncConfigConfig.Get("GodWeaponSkillEffect");
|
if (funcConfig != null)
|
{
|
json = LitJson.JsonMapper.ToObject(funcConfig.Numerical1);
|
foreach (var key in json.Keys)
|
{
|
var skillId = int.Parse(key);
|
if (!godWeaponSkillEffect.ContainsKey(skillId))
|
{
|
godWeaponSkillEffect.Add(skillId, int.Parse(json[key].ToString()));
|
}
|
}
|
}
|
|
funcConfig = FuncConfigConfig.Get("Godvideo");
|
hammerAudioId = int.Parse(funcConfig.Numerical1);
|
audioLength = int.Parse(funcConfig.Numerical2);
|
}
|
|
public int[] GetLevelUpItemByType(int type)
|
{
|
return godWeaponLevelUpCost[type];
|
}
|
|
public bool TryGetMagicType(int itemId,out int type)
|
{
|
type = 0;
|
foreach(var key in godWeaponLevelUpCost.Keys)
|
{
|
var costlist = godWeaponLevelUpCost[key];
|
if(costlist.Contains(itemId))
|
{
|
type = key;
|
return true;
|
}
|
}
|
|
if(godWeaponBoxDict.ContainsKey(itemId))
|
{
|
type = godWeaponBoxDict[itemId];
|
return true;
|
}
|
return false;
|
}
|
|
#region 红点
|
public const int MAGICAIN_REDPOINT = 10103;
|
public const int MAGICAIN_INTERVAL = 100;
|
public Dictionary<int, Redpoint> redpointDict = new Dictionary<int, Redpoint>();
|
Redpoint magicianPoint = new Redpoint(101, MAGICAIN_REDPOINT);
|
public Redpoint magicianRedpoint { get { return magicianPoint; } }
|
public void UpdateRedPoint()
|
{
|
foreach (var redpoint in redpointDict.Values)
|
{
|
redpoint.state = RedPointState.None;
|
}
|
if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.GodWeapon))
|
{
|
return;
|
}
|
foreach (var key in redpointDict.Keys)
|
{
|
if (IsGodWeaponMaxLevel(key))
|
{
|
continue;
|
}
|
if (!IsGodWeaponUnlock(key) && ContainsCondition(key))
|
{
|
if (SatisfyUnlockCondition(key))
|
{
|
redpointDict[key].state = RedPointState.Simple;
|
}
|
continue;
|
}
|
int[] items = GetLevelUpItemByType((int)key);
|
for (int i = 0; i < items.Length; i++)
|
{
|
if (packModel.GetItemCountByID(PackType.Item, items[i]) > 0)
|
{
|
redpointDict[key].state = RedPointState.Simple;
|
break;
|
}
|
}
|
}
|
}
|
|
public bool GetRedpointLightByType(int _type)
|
{
|
if (redpointDict.ContainsKey(_type))
|
{
|
return redpointDict[_type].state == RedPointState.Simple;
|
}
|
return false;
|
}
|
#endregion
|
|
public void HammerGodWeapon(int type)
|
{
|
GodWeaponInfo godWeaponInfo = GetGodWeaponInfo(type);
|
if (godWeaponInfo == null)
|
{
|
return;
|
}
|
if (IsGodWeaponMaxLevel(type))
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("L1054"));
|
return;
|
}
|
int[] items = GetLevelUpItemByType(type);
|
if (selectItemIndex >= items.Length)
|
{
|
return;
|
}
|
var itemId = items[selectItemIndex];
|
ItemConfig itemConfig = ItemConfig.Get(itemId);
|
var count = packModel.GetItemCountByID(PackType.Item, itemId);
|
if (count < 1)
|
{
|
ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(itemId);
|
if (!IsGodWeaponHammerItem(3, itemId) && !NewBieCenter.Instance.completeGuidesBuf.Contains(85))
|
{
|
NewBieCenter.Instance.StartNewBieGuide(85);
|
}
|
return;
|
}
|
CA555_tagCMGodWeaponPlus pak = new CA555_tagCMGodWeaponPlus();
|
pak.WeaponType = (uint)type;
|
pak.ItemID = (uint)itemId;
|
pak.ItemCount = 1;
|
pak.IsAutoBuy = 0;
|
GameNetSystem.Instance.SendInfo(pak);
|
PlayHammerAudio();
|
}
|
|
DateTime lastAudioTime = DateTime.Now;
|
public void PlayHammerAudio()
|
{
|
var seconds = (float)audioLength / 1000;
|
if ((DateTime.Now - lastAudioTime).TotalSeconds < seconds)
|
{
|
return;
|
}
|
lastAudioTime = DateTime.Now;
|
SoundPlayer.Instance.PlayUIAudio(hammerAudioId);
|
}
|
|
public event Action godWeaponUpdate;
|
private Dictionary<int, GodWeaponInfo> godWeaponInfoDict = new Dictionary<int, GodWeaponInfo>();
|
public void UpdateGodWeaponInfo(HA31D_tagMCGodWeaponLVList package)
|
{
|
for (byte i = 0; i < package.WeaponNum; i++)
|
{
|
HA31D_tagMCGodWeaponLVList.tagMCGodWeaponLVInfo data = package.WeaponInfoList[i];
|
GodWeaponInfo godWeaponInfo = GetGodWeaponInfo(data.WeaponType);
|
if (godWeaponInfo != null)
|
{
|
var beforeLevel = godWeaponInfo.level;
|
godWeaponInfo.exp = data.WeaponExp;
|
godWeaponInfo.level = data.WeaponLV;
|
CheckActivate(godWeaponInfo.type, beforeLevel, data.WeaponLV);
|
}
|
}
|
UpdateRedPoint();
|
if (godWeaponUpdate != null)
|
{
|
godWeaponUpdate();
|
}
|
}
|
|
void CheckActivate(int _type, int _beforeLv, int _nowLv)
|
{
|
if (serverInited)
|
{
|
var stage = 0;
|
if (_beforeLv != _nowLv && TryGetUnlockStage(_type, _beforeLv, _nowLv, out stage))
|
{
|
EquipShowSwitch.SendGodWeaponEffectOn(_type, stage, true);
|
if (WindowCenter.Instance.IsOpen<MagicianWin>()
|
&& !NewBieCenter.Instance.inGuiding)
|
{
|
if (WindowCenter.Instance.IsOpen<GodWeaponPreviewWin>())
|
{
|
WindowCenter.Instance.Close<GodWeaponPreviewWin>();
|
}
|
if (WindowCenter.Instance.IsOpen<HowToPlayWin>())
|
{
|
WindowCenter.Instance.Close<HowToPlayWin>();
|
}
|
ActivateShow.GodWeaponStage(_type, _nowLv, _beforeLv, stage);
|
}
|
return;
|
}
|
}
|
var _skillId = 0;
|
if (serverInited && _beforeLv != _nowLv
|
&& (_beforeLv == 0 || TryGetUnlockSkill(_type, _beforeLv, _nowLv, out _skillId)))
|
{
|
if (WindowCenter.Instance.IsOpen<MagicianWin>()
|
&& !NewBieCenter.Instance.inGuiding)
|
{
|
if (WindowCenter.Instance.IsOpen<GodWeaponPreviewWin>())
|
{
|
WindowCenter.Instance.Close<GodWeaponPreviewWin>();
|
}
|
if (WindowCenter.Instance.IsOpen<HowToPlayWin>())
|
{
|
WindowCenter.Instance.Close<HowToPlayWin>();
|
}
|
ActivateShow.GodWeaponActivate(_type, _nowLv, _beforeLv);
|
}
|
}
|
}
|
|
public bool TryGetUnlockStage(int _type, int _beforeLv, int _nowLv, out int stage)
|
{
|
stage = 0;
|
List<int> stages = null;
|
if (TryGetGodWeaponStages(_type, out stages))
|
{
|
var beforeStage = 0;
|
for (int i = 0; i < stages.Count; i++)
|
{
|
if (stages[i] <= _beforeLv)
|
{
|
beforeStage = i + 1;
|
}
|
}
|
for (int i = 0; i < stages.Count; i++)
|
{
|
if (stages[i] <= _nowLv)
|
{
|
stage = i + 1;
|
}
|
}
|
return stage > beforeStage;
|
}
|
return false;
|
}
|
|
public bool TryGetUnlockSkill(int _type, int _beforeLv, int _nowLv,out int _skillid)
|
{
|
_skillid = 0;
|
if (godWeaponSkillDict.ContainsKey(_type))
|
{
|
var _dict = godWeaponSkillDict[_type];
|
foreach (var _lv in _dict.Keys)
|
{
|
if (_beforeLv < _lv && _lv <= _nowLv)
|
{
|
_skillid = _dict[_lv];
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
|
public bool TryGetGodWeaponSkills(int type, out Dictionary<int, int> skills)
|
{
|
return godWeaponSkillDict.TryGetValue(type, out skills);
|
}
|
|
public GodWeaponInfo GetGodWeaponInfo(int type)
|
{
|
GodWeaponInfo data = null;
|
godWeaponInfoDict.TryGetValue(type, out data);
|
return data;
|
}
|
|
public bool IsGodWeaponMaxLevel(int _type)
|
{
|
var _data = GetGodWeaponInfo(_type);
|
var config = GodWeaponConfig.GetConfig(_type, _data.level + 1);
|
return config == null;
|
}
|
|
public bool IsGodWeaponHammerItem(int _type,int _itemId)
|
{
|
var items = GetLevelUpItemByType(_type);
|
if (items == null)
|
{
|
return false;
|
}
|
for (int i = 0; i < items.Length; i++)
|
{
|
if (items[i] == _itemId)
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public bool IsGodWeaponUnlock(int type)
|
{
|
var godWeaponInfo = GetGodWeaponInfo(type);
|
if (godWeaponInfo != null && godWeaponInfo.level >= 1)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
public bool SatisfyUnlockCondition(int type)
|
{
|
if (!playerLevelConditions.ContainsKey(type)
|
&& !godWeaponConditions.ContainsKey(type))
|
{
|
return true;
|
}
|
List<GodWeaponCondition> list;
|
bool satisfyCondition = false;
|
if (godWeaponConditions.TryGetValue(type, out list))
|
{
|
bool satisfy = true;
|
for (int i = 0; i < list.Count; i++)
|
{
|
var godWeaponInfo = GetGodWeaponInfo(list[i].type);
|
if (godWeaponInfo == null || godWeaponInfo.level < list[i].level)
|
{
|
satisfy = false;
|
break;
|
}
|
}
|
if (satisfy)
|
{
|
satisfyCondition = true;
|
}
|
}
|
var playerLevelLimit = 0;
|
if (TryGetPlayerLevelCondition(type, out playerLevelLimit))
|
{
|
if (PlayerDatas.Instance.baseData.LV >= playerLevelLimit)
|
{
|
satisfyCondition = true;
|
}
|
}
|
return satisfyCondition;
|
}
|
|
public int GetAutoHammerCount(int type)
|
{
|
ulong totalExp = 0;
|
var godWeaponInfo = GetGodWeaponInfo(type);
|
if (godWeaponInfo == null || autoHammerExpArea == null || autoHammerCount == null)
|
{
|
return 1;
|
}
|
var config = GodWeaponConfig.GetConfig(type, godWeaponInfo.level);
|
totalExp = (ulong)config.NeedExp;
|
var index = 0;
|
for (int i = 0; i < autoHammerExpArea.Length; i++)
|
{
|
if (totalExp < (ulong)autoHammerExpArea[i])
|
{
|
index = i;
|
break;
|
}
|
else
|
{
|
index++;
|
}
|
}
|
if (index < autoHammerCount.Length)
|
{
|
return autoHammerCount[index];
|
}
|
return autoHammerCount[autoHammerCount.Length - 1];
|
}
|
|
public int GetAutoHammerCount(int type, int index)
|
{
|
var items = GetLevelUpItemByType(type);
|
var moneyCount = GetAutoHammerCount(type);
|
AutoHammerCost autoHammerCost;
|
var totalExp = 0;
|
if (TryGetAutoHammerCost(type, out autoHammerCost))
|
{
|
totalExp = moneyCount * autoHammerCost.exp;
|
}
|
else if (singleHarmmerExp.ContainsKey(type))
|
{
|
totalExp = moneyCount * singleHarmmerExp[type];
|
}
|
var itemId = items[index];
|
var itemConfig = ItemConfig.Get(itemId);
|
var expCount = Mathf.CeilToInt((float)totalExp / itemConfig.EffectValueA1);
|
var packCount = packModel.GetItemCountByID(PackType.Item, itemId);
|
return Mathf.Min(expCount, packCount);
|
}
|
|
public bool ContainsCondition(int type)
|
{
|
return godWeaponConditions.ContainsKey(type) || playerLevelConditions.ContainsKey(type);
|
}
|
|
public bool TryGetConditions(int type, out List<GodWeaponCondition> list)
|
{
|
return godWeaponConditions.TryGetValue(type, out list);
|
}
|
|
public bool TryGetPlayerLevelCondition(int type,out int level)
|
{
|
return playerLevelConditions.TryGetValue(type, out level);
|
}
|
|
public int GetGodWeaponStage(int type)
|
{
|
var stage = 0;
|
var godWeaponInfo = GetGodWeaponInfo(type);
|
if (godWeaponInfo != null)
|
{
|
var godWeaponStages = godWeaponStageDict[type];
|
for (int i = 0; i < godWeaponStages.Count; i++)
|
{
|
if (godWeaponInfo.level >= godWeaponStages[i])
|
{
|
stage = i + 1;
|
}
|
else
|
{
|
break;
|
}
|
}
|
}
|
return stage;
|
}
|
|
public int GetGodWeaponStageRequireLevel(int type, int stage)
|
{
|
var godWeaponStages = godWeaponStageDict[type];
|
if (stage > 0 && stage - 1 < godWeaponStages.Count)
|
{
|
return godWeaponStages[stage - 1];
|
}
|
return 0;
|
}
|
|
public bool TryGetGodWeaponStage(int type, int level, out int stage)
|
{
|
List<int> list;
|
stage = 0;
|
if (TryGetGodWeaponStages(type, out list))
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
if (list[i] == level)
|
{
|
stage = i + 1;
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
|
public bool TryGetGodWeaponStages(int type, out List<int> stages)
|
{
|
return godWeaponStageDict.TryGetValue(type, out stages);
|
}
|
|
public bool IsGodWeaponMaxLevelByItem(int _itemId)
|
{
|
foreach (var _key in godWeaponLevelUpCost.Keys)
|
{
|
for (int i = 0; i < godWeaponLevelUpCost[_key].Length; i++)
|
{
|
if (godWeaponLevelUpCost[_key][i] == _itemId)
|
{
|
return IsGodWeaponMaxLevel(_key);
|
}
|
}
|
}
|
return false;
|
}
|
|
public bool TryGetAutoHammerCost(int type,out AutoHammerCost autoHammerCost)
|
{
|
return autoHammerCostDict.TryGetValue(type, out autoHammerCost);
|
}
|
|
public bool TryGetExteriorPower(int type, out int power)
|
{
|
return exteriorPowerDict.TryGetValue(type, out power);
|
}
|
|
public bool TryGetGodWeaponSkillEffect(int skillId, out int effect)
|
{
|
return godWeaponSkillEffect.TryGetValue(skillId, out effect);
|
}
|
|
public bool TryGetEffectProperty(int type, int level, out Dictionary<int, int> dict)
|
{
|
dict = null;
|
if (effectPropertyDict.ContainsKey(type))
|
{
|
var effectProperty = effectPropertyDict[type].Find((x) =>
|
{
|
return x.level == level;
|
});
|
if (!effectProperty.Equals(default(GodWeaponEffectProperty)))
|
{
|
dict = effectProperty.propertyDict;
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public int TryGetEffectFightPower(int type, int stage)
|
{
|
var previousFightPower = 0;
|
if (stage - 1 > 0)
|
{
|
var previousLevel = GetGodWeaponStageRequireLevel(type, stage - 1);
|
if (effectFightPower.ContainsKey(type)
|
&& effectFightPower[type].ContainsKey(previousLevel))
|
{
|
previousFightPower = effectFightPower[type][previousLevel];
|
}
|
}
|
var level = GetGodWeaponStageRequireLevel(type, stage);
|
if (effectFightPower.ContainsKey(type)
|
&& effectFightPower[type].ContainsKey(level))
|
{
|
return effectFightPower[type][level] - previousFightPower;
|
}
|
return 0;
|
}
|
|
public int GetEffectRealFightPower(int type, int stage)
|
{
|
var level = GetGodWeaponStageRequireLevel(type, stage);
|
if (effectFightPower.ContainsKey(type)
|
&& effectFightPower[type].ContainsKey(level))
|
{
|
return effectFightPower[type][level];
|
}
|
return 0;
|
}
|
|
Dictionary<int, int> propertyCacheDict = new Dictionary<int, int>();
|
public Dictionary<int, int> GetEffectPropertyUpper(int type, int stage)
|
{
|
propertyCacheDict.Clear();
|
Dictionary<int, int> previousPropertyDict = null;
|
if (stage - 1 > 0)
|
{
|
var level = GetGodWeaponStageRequireLevel(type, stage - 1);
|
TryGetEffectProperty(type, level, out previousPropertyDict);
|
}
|
var requireLevel = GetGodWeaponStageRequireLevel(type, stage);
|
Dictionary<int, int> dict;
|
if (TryGetEffectProperty(type, requireLevel, out dict))
|
{
|
foreach (var key in dict.Keys)
|
{
|
if (previousPropertyDict != null && previousPropertyDict.ContainsKey(key))
|
{
|
propertyCacheDict.Add(key, dict[key] - previousPropertyDict[key]);
|
}
|
else
|
{
|
propertyCacheDict.Add(key, dict[key]);
|
}
|
}
|
}
|
return propertyCacheDict;
|
}
|
|
public List<int> TryGetDisplaySkillLevels(int type)
|
{
|
List<int> displaySkillLevels = new List<int>();
|
Dictionary<int, int> dict;
|
if (TryGetGodWeaponSkills(type, out dict))
|
{
|
displaySkillLevels.AddRange(dict.Keys);
|
}
|
List<int> list;
|
if (TryGetGodWeaponStages(type, out list))
|
{
|
displaySkillLevels.AddRange(list);
|
}
|
displaySkillLevels.Sort();
|
return displaySkillLevels;
|
}
|
|
public string GetEffectSkillIcon(int type, int level)
|
{
|
var job = PlayerDatas.Instance.baseData.Job;
|
if (godWeaponEffectInfos.ContainsKey(type))
|
{
|
var list = godWeaponEffectInfos[type];
|
var index = list.FindIndex((x) =>
|
{
|
return x.level == level;
|
});
|
if (index != -1)
|
{
|
if (list[index].skillIconDict.ContainsKey(job))
|
{
|
return list[index].skillIconDict[job];
|
}
|
}
|
}
|
return string.Empty;
|
}
|
|
void CheckGodWeaponEffectOn()
|
{
|
var value = PlayerDatas.Instance.baseData.equipShowSwitch;
|
if (value == 7)
|
{
|
value = 0;
|
foreach (var type in godWeaponEffectTypes)
|
{
|
var stage = GetGodWeaponStage(type);
|
if (stage != 0 && stage <= 3)
|
{
|
var index = EquipShowSwitch.GetGodWeaponEquipShowIndex(type, stage);
|
value = (uint)MathUtility.SetBitValue((int)value, index, true);
|
}
|
}
|
}
|
else
|
{
|
foreach (var type in godWeaponEffectTypes)
|
{
|
var requireLevel = 0;
|
var godWeapon = GetGodWeaponInfo(type);
|
if (EquipShowSwitch.IsGodWeaponEffectOn(value, type, out requireLevel)
|
&& (godWeapon == null || godWeapon.level < requireLevel))
|
{
|
var stage = 0;
|
if (TryGetGodWeaponStage(type, requireLevel, out stage))
|
{
|
var index = EquipShowSwitch.GetGodWeaponEquipShowIndex(type, stage);
|
value = (uint)MathUtility.SetBitValue((int)value, index, false);
|
}
|
}
|
}
|
}
|
if (value != PlayerDatas.Instance.baseData.equipShowSwitch)
|
{
|
EquipShowSwitch.SendPackage(value);
|
}
|
}
|
}
|
|
public class GodWeaponInfo
|
{
|
public int type;
|
public int level;
|
public uint exp;
|
}
|
|
public struct GodWeaponCondition
|
{
|
public int type;
|
public int level;
|
}
|
|
public struct AutoHammerCost
|
{
|
public int cost;
|
public int exp;
|
}
|
|
public struct GodWeaponEffectProperty
|
{
|
public int level;
|
public Dictionary<int, int> propertyDict;
|
}
|
|
public struct GodWeaponEffectInfo
|
{
|
public int level;
|
public Dictionary<int, string> skillIconDict;
|
}
|
}
|
|