using System;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
namespace Snxxz.UI
|
{
|
[XLua.Hotfix]
|
public static class ActivateShow
|
{
|
public static ActivateFunc activateType { get; private set; }
|
public static List<PropertyCompare> propertyCompares = new List<PropertyCompare>();
|
public static int fightPower { get; private set; }
|
public static string titleIconKey { get; private set; }
|
public static List<int> skills = new List<int>();
|
public static int currentLv { get; private set; }
|
public static int beforeLv { get; private set; }
|
public static int godWeaponType { get; private set; }
|
public static int godWeaponStage { get; private set; }
|
public static int treasureSoulId { get; private set; }
|
|
private static Dictionary<int, int> lastPropertyDict = new Dictionary<int, int>();
|
private static Dictionary<int, int> currentPropertyDict = new Dictionary<int, int>();
|
|
public static event Action<ActivateFunc, int> prepareFlySkillEvent;
|
public static event Action<ActivateFunc> complelteFlySkillEvent;
|
|
public static void RealmActivate(int _lv)
|
{
|
activateType = ActivateFunc.Realm;
|
propertyCompares.Clear();
|
currentPropertyDict.Clear();
|
lastPropertyDict.Clear();
|
beforeLv = _lv - 1;
|
currentLv = _lv;
|
var _beforeConfig = RealmConfig.Get(_lv - 1);
|
List<int> _beforeProperties = new List<int>();
|
if (_beforeConfig != null)
|
{
|
_beforeProperties.AddRange(_beforeConfig.AddAttrType);
|
for (int i = 0; i < _beforeConfig.AddAttrType.Length; i++)
|
{
|
lastPropertyDict.Add(_beforeConfig.AddAttrType[i], _beforeConfig.AddAttrNum[i]);
|
}
|
}
|
var config = RealmConfig.Get(_lv);
|
for (int i = 0; i < config.AddAttrType.Length; i++)
|
{
|
var _index = _beforeProperties.IndexOf(config.AddAttrType[i]);
|
if (_index == -1 || config.AddAttrNum[i] > _beforeConfig.AddAttrNum[_index])
|
{
|
propertyCompares.Add(new PropertyCompare()
|
{
|
key = config.AddAttrType[i],
|
beforeValue = _index == -1 ? 0 : _beforeConfig.AddAttrNum[_index],
|
currentValue = config.AddAttrNum[i]
|
});
|
}
|
|
currentPropertyDict.Add(config.AddAttrType[i], config.AddAttrNum[i]);
|
}
|
fightPower = UIHelper.GetFightPower(currentPropertyDict) - UIHelper.GetFightPower(lastPropertyDict);
|
titleIconKey = "UI_JH_3";
|
|
if (!WindowCenter.Instance.IsOpen<RealmPropertyUpWin>())
|
{
|
WindowCenter.Instance.Open<RealmPropertyUpWin>();
|
}
|
}
|
|
public static void GodWeaponActivate(int _type, int _lv, int _beforeLv)
|
{
|
activateType = ActivateFunc.GodWeapon;
|
currentLv = _lv;
|
godWeaponType = _type;
|
beforeLv = _beforeLv;
|
skills.Clear();
|
propertyCompares.Clear();
|
lastPropertyDict.Clear();
|
currentPropertyDict.Clear();
|
|
var _model = ModelCenter.Instance.GetModel<MagicianModel>();
|
if (_model.godWeaponSkillDict.ContainsKey(_type))
|
{
|
var _dict = _model.godWeaponSkillDict[_type];
|
var _skillid = 0;
|
if (_beforeLv == 0)
|
{
|
foreach (var _key in _dict.Keys)
|
{
|
skills.Add(_dict[_key]);
|
}
|
}
|
else if (_model.TryGetUnlockSkill(godWeaponType, _beforeLv, _lv, out _skillid))
|
{
|
skills.Add(_skillid);
|
}
|
}
|
|
var _beforeConfig = GodWeaponConfig.GetConfig(_type, _beforeLv);
|
List<int> _beforeProperties = new List<int>();
|
if (_beforeConfig != null)
|
{
|
_beforeProperties.AddRange(_beforeConfig.AttrType);
|
for (int i = 0; i < _beforeConfig.AttrType.Length; i++)
|
{
|
lastPropertyDict.Add(_beforeConfig.AttrType[i], _beforeConfig.AttrNum[i]);
|
}
|
}
|
var config = GodWeaponConfig.GetConfig(_type, currentLv);
|
for (int i = 0; i < config.AttrType.Length; i++)
|
{
|
var _index = _beforeProperties.IndexOf(config.AttrType[i]);
|
if (_index == -1 || config.AttrNum[i] > _beforeConfig.AttrNum[_index])
|
{
|
propertyCompares.Add(new PropertyCompare()
|
{
|
key = config.AttrType[i],
|
beforeValue = _index == -1 ? 0 : _beforeConfig.AttrNum[_index],
|
currentValue = config.AttrNum[i]
|
});
|
}
|
|
currentPropertyDict.Add(config.AttrType[i], config.AttrNum[i]);
|
}
|
|
fightPower = UIHelper.GetFightPower(currentPropertyDict) - UIHelper.GetFightPower(lastPropertyDict);
|
if (_beforeLv != 0)
|
{
|
for (int i = 0; i < skills.Count; i++)
|
{
|
var skillConfig = SkillConfig.Get(skills[i]);
|
fightPower += skillConfig.FightPower;
|
}
|
}
|
|
titleIconKey = _beforeLv == 0 ? "UI_JH_12" : "UI_JH_6";
|
|
if (_beforeLv == 0)
|
{
|
var exteriorPower = 0;
|
if (_model.TryGetExteriorPower(_type, out exteriorPower))
|
{
|
fightPower += exteriorPower;
|
}
|
}
|
|
if (!WindowCenter.Instance.IsOpen<RealmPropertyUpWin>())
|
{
|
WindowCenter.Instance.Open<RealmPropertyUpWin>();
|
}
|
}
|
|
public static void GodWeaponStage(int _type, int _level, int _beforeLevel,int stage)
|
{
|
activateType = ActivateFunc.GodWeaponEffect;
|
currentLv = _level;
|
godWeaponType = _type;
|
godWeaponStage = stage;
|
beforeLv = _beforeLevel;
|
skills.Clear();
|
propertyCompares.Clear();
|
lastPropertyDict.Clear();
|
currentPropertyDict.Clear();
|
|
var _model = ModelCenter.Instance.GetModel<MagicianModel>();
|
if (_model.godWeaponSkillDict.ContainsKey(_type))
|
{
|
var _dict = _model.godWeaponSkillDict[_type];
|
var _skillid = 0;
|
if (beforeLv == 0)
|
{
|
foreach (var _key in _dict.Keys)
|
{
|
skills.Add(_dict[_key]);
|
}
|
}
|
else if (_model.TryGetUnlockSkill(godWeaponType, beforeLv, _level, out _skillid))
|
{
|
skills.Add(_skillid);
|
}
|
}
|
|
var _beforeConfig = GodWeaponConfig.GetConfig(_type, beforeLv);
|
if (_beforeConfig != null)
|
{
|
for (int i = 0; i < _beforeConfig.AttrType.Length; i++)
|
{
|
lastPropertyDict.Add(_beforeConfig.AttrType[i], _beforeConfig.AttrNum[i]);
|
}
|
}
|
var config = GodWeaponConfig.GetConfig(_type, currentLv);
|
for (int i = 0; i < config.AttrType.Length; i++)
|
{
|
currentPropertyDict.Add(config.AttrType[i], config.AttrNum[i]);
|
}
|
|
fightPower = UIHelper.GetFightPower(currentPropertyDict) - UIHelper.GetFightPower(lastPropertyDict);
|
if (beforeLv != 0)
|
{
|
for (int i = 0; i < skills.Count; i++)
|
{
|
var skillConfig = SkillConfig.Get(skills[i]);
|
fightPower += skillConfig.FightPower;
|
}
|
}
|
var dict = _model.GetEffectPropertyUpper(_type, stage);
|
fightPower += UIHelper.GetFightPower(dict);
|
var requireLevel = _model.GetGodWeaponStageRequireLevel(_type, stage);
|
fightPower += _model.TryGetEffectFightPower(_type, stage);
|
|
titleIconKey = "GodWeaponEffectTitle";
|
|
if (!WindowCenter.Instance.IsOpen<RealmPropertyUpWin>())
|
{
|
WindowCenter.Instance.Open<RealmPropertyUpWin>();
|
}
|
}
|
|
public static void StoveUpgrade(int stoveLv)
|
{
|
activateType = ActivateFunc.Stove;
|
propertyCompares.Clear();
|
currentPropertyDict.Clear();
|
lastPropertyDict.Clear();
|
skills.Clear();
|
beforeLv = stoveLv - 1;
|
currentLv = stoveLv;
|
|
var model = ModelCenter.Instance.GetModel<BlastFurnaceModel>();
|
for(int i = 0; i < model.alchemyModellist.Count; i++)
|
{
|
if(stoveLv == model.alchemyModellist[i].BlastFurnaceLV)
|
{
|
skills.Add(model.alchemyModellist[i].AlchemyID);
|
}
|
}
|
|
var _beforeConfig = RefineStoveConfig.Get(beforeLv);
|
List<int> _beforeProperties = new List<int>();
|
if (_beforeConfig != null)
|
{
|
_beforeProperties.AddRange(_beforeConfig.AttrID);
|
for (int i = 0; i < _beforeConfig.AttrID.Length; i++)
|
{
|
lastPropertyDict.Add(_beforeConfig.AttrID[i], _beforeConfig.AttrValue[i]);
|
}
|
}
|
var config = RefineStoveConfig.Get(stoveLv);
|
for (int i = 0; i < config.AttrID.Length; i++)
|
{
|
var _index = _beforeProperties.IndexOf(config.AttrID[i]);
|
if (_index == -1 || config.AttrValue[i] > _beforeConfig.AttrValue[_index])
|
{
|
propertyCompares.Add(new PropertyCompare()
|
{
|
key = config.AttrID[i],
|
beforeValue = _index == -1 ? 0 : _beforeConfig.AttrValue[_index],
|
currentValue = config.AttrValue[i]
|
});
|
}
|
|
currentPropertyDict.Add(config.AttrID[i], config.AttrValue[i]);
|
}
|
fightPower = UIHelper.GetFightPower(currentPropertyDict) - UIHelper.GetFightPower(lastPropertyDict);
|
titleIconKey = "XT_LD_01";
|
|
if (!WindowCenter.Instance.IsOpen<StoveUpgradWin>())
|
{
|
WindowCenter.Instance.Open<StoveUpgradWin>();
|
}
|
|
}
|
|
public static void TreasureSoulGetReward(int id, int _beforeLevel, int _currentLevel)
|
{
|
activateType = ActivateFunc.TreasureSoul;
|
treasureSoulId = id;
|
titleIconKey = "XT_FBZH_11";
|
propertyCompares.Clear();
|
lastPropertyDict.Clear();
|
currentPropertyDict.Clear();
|
var model = ModelCenter.Instance.GetModel<TreasureSoulModel>();
|
TreasureSpecialData special;
|
if (model.TryGetTreasureSoul(treasureSoulId, out special))
|
{
|
switch (special.type)
|
{
|
case TreasurePrivilege.StrengthenAdd:
|
var configs = Config.Instance.GetAllValues<ItemPlusSumAttrConfig>();
|
var before = -1;
|
var present = 0;
|
for (int i = 0; i < configs.Count; i++)
|
{
|
if (_beforeLevel >= configs[i].countNeed)
|
{
|
before = i;
|
}
|
if (_currentLevel >= configs[i].countNeed)
|
{
|
present = i;
|
}
|
}
|
ItemPlusSumAttrConfig _beforeConfig = null;
|
if (before >= 0 && before < configs.Count)
|
{
|
_beforeConfig = configs[before];
|
}
|
List<int> _beforeProperties = new List<int>();
|
if (_beforeConfig != null)
|
{
|
_beforeProperties.AddRange(_beforeConfig.attType);
|
for (int i = 0; i < _beforeConfig.attType.Length; i++)
|
{
|
lastPropertyDict.Add(_beforeConfig.attType[i], _beforeConfig.attValue[i]);
|
}
|
}
|
var config = (present < 0 || present >= configs.Count) ? null : configs[present];
|
if (config == null)
|
{
|
return;
|
}
|
for (int i = 0; i < config.attType.Length; i++)
|
{
|
var _index = _beforeProperties.IndexOf(config.attType[i]);
|
if (_index == -1 || config.attValue[i] > _beforeConfig.attValue[_index])
|
{
|
propertyCompares.Add(new PropertyCompare()
|
{
|
key = config.attType[i],
|
beforeValue = _index == -1 ? 0 : _beforeConfig.attValue[_index],
|
currentValue = config.attValue[i]
|
});
|
}
|
|
currentPropertyDict.Add(config.attType[i], config.attValue[i]);
|
}
|
break;
|
case TreasurePrivilege.DemonJarAtk:
|
case TreasurePrivilege.MountAtk:
|
case TreasurePrivilege.PetHp:
|
case TreasurePrivilege.Sp:
|
foreach (var _key in special.propertyDict.Keys)
|
{
|
var beforeValue = special.propertyDict[_key] * _beforeLevel / special.progress;
|
var nowValue = special.propertyDict[_key] * _currentLevel / special.progress;
|
lastPropertyDict.Add(_key, beforeValue);
|
currentPropertyDict.Add(_key, nowValue);
|
propertyCompares.Add(new PropertyCompare()
|
{
|
key = _key,
|
beforeValue = beforeValue,
|
currentValue = nowValue
|
});
|
}
|
break;
|
}
|
fightPower = UIHelper.GetFightPower(currentPropertyDict) - UIHelper.GetFightPower(lastPropertyDict);
|
if (!WindowCenter.Instance.IsOpen<RealmPropertyUpWin>())
|
{
|
WindowCenter.Instance.Open<RealmPropertyUpWin>();
|
}
|
}
|
}
|
|
public static void JadeDynastySkillUnlock(int skillId)
|
{
|
activateType = ActivateFunc.JadeDynastySkill;
|
skills.Clear();
|
fightPower = 0;
|
skills.Add(skillId);
|
titleIconKey = "UI_JH_6";
|
|
var config = SkillConfig.Get(skillId);
|
if (config != null)
|
{
|
fightPower = config.FightPower;
|
}
|
|
if (!WindowCenter.Instance.IsOpen<RealmPropertyUpWin>())
|
{
|
WindowCenter.Instance.Open<RealmPropertyUpWin>();
|
}
|
}
|
|
public static void PrepareSkillFly()
|
{
|
if (prepareFlySkillEvent != null)
|
{
|
prepareFlySkillEvent(activateType, skills.Count > 0 ? skills[0] : 0);
|
}
|
}
|
|
public static void CompleteSkillFly()
|
{
|
if (complelteFlySkillEvent != null)
|
{
|
complelteFlySkillEvent(activateType);
|
}
|
}
|
|
public enum ActivateFunc
|
{
|
Realm,
|
GodWeapon,
|
Stove, //炼丹炉升级
|
TreasureSoul,//法宝魂领取属性
|
GodWeaponEffect,
|
JadeDynastySkill,
|
}
|
|
public struct PropertyCompare
|
{
|
public int key;
|
public int beforeValue;
|
public int currentValue;
|
}
|
}
|
}
|