using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
using System;
|
using System.Linq;
|
using vnxbqy.UI;
|
|
public class WingsRefined : MonoBehaviour
|
{
|
//羽翼精炼
|
public int LINE = 6;//需要生成的行数
|
[SerializeField] ScrollerController m_ScrollerController;
|
[SerializeField] Image WingsBG;//背景框
|
[SerializeField] Button WingsImage;//(没有翅膀按钮点击)
|
[SerializeField] Button IconButton;//有翅膀按钮和图
|
[SerializeField] Text WText;//翅膀资质
|
[SerializeField] GameObject EquipFirstTxt;//没有翅膀提示框
|
[SerializeField] Text PlusNum;//预览比值1
|
[SerializeField] Text PlusNum1;//预览比值2
|
[SerializeField] Text PlusNum2;//预览比值3
|
[SerializeField] GameObject FullTxt;//满级显示提示本文
|
[SerializeField] Button _refiningBtn;//精炼按钮
|
[SerializeField] Button _KeyRefiningBtn;//一键精炼按钮;
|
[SerializeField] Button _RefineStopBtn;//停止精炼按钮
|
[SerializeField] GameObject _ManagementFrame;//羽翼精炼面板框
|
[SerializeField] RawImage _wingRawImage;//翅膀模型创建
|
[SerializeField] RawImage _wingRawImage2;//翅膀模型创建2
|
[SerializeField] Text _AttrNameTextNum1;//增加的伤害值
|
[SerializeField] Text _AttrNameTextNum2;//增加的生命值
|
[SerializeField] Slider _Pmgressbar;//精炼值
|
[SerializeField] Text _PmgressText;//精炼数值
|
[SerializeField] UIEffect m_UIEffect1;//翅膀特效1
|
[SerializeField] UIEffect m_UIEffect2;//翅膀特效2
|
private Dictionary<int, int> _wingItemDic = new Dictionary<int, int>();//获取翅膀字典
|
private Dictionary<int, bool> _DevourDIc = new Dictionary<int, bool>();//需要吞噬的物品
|
private Dictionary<int, ItemModel> WingDic = new Dictionary<int, ItemModel>();//获取翅膀属性
|
private List<int> intPetAbsorbTyp = new List<int>();
|
Dictionary<int, WingRefineAttrModel> _DicWingRe = new Dictionary<int, WingRefineAttrModel>();//获取属性上限值
|
|
PackModel _playerPack;
|
PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); } }
|
|
WingsRedDotModel M_WingsRedDotModel;
|
WingsRedDotModel wingsRedDotModel { get { return M_WingsRedDotModel ?? (M_WingsRedDotModel = ModelCenter.Instance.GetModel<WingsRedDotModel>()); } }
|
|
private bool IsOpen = false;
|
class WingRefineAttrModel
|
{
|
public int Ability1;//属性值1
|
public int Ability1Value;//数值1
|
public int Ability2;//属性值2
|
public int Ability2Value;//数值2
|
}
|
|
public class EquippedClass
|
{
|
public int ItemId;//物品ID
|
public string Index;//索引下标
|
public int BackpackIndex;//所对应背包的索引
|
}
|
|
|
|
private int _currentRefining = 0;//当前精炼度
|
private int _currentRefiningAll = 1;//总精炼度
|
private float _RefiningRatio;//精炼比值
|
|
private int Lifevalue = 0;//生命值
|
private float Damagevalue = 0;//伤害值
|
private bool AutomaticBool = false;//自动精炼
|
private bool CoroutinesBool = true;//协程控制
|
|
public Dictionary<int, int> wingLv2GenerDict = new Dictionary<int, int>();
|
List<WingRefineAttrConfig> wingRefineAttrConfigs = new List<WingRefineAttrConfig>();
|
private void Awake()
|
{
|
var _funcCfg = FuncConfigConfig.Get("WingLV");
|
LitJson.JsonData _json = LitJson.JsonMapper.ToObject(_funcCfg.Numerical1);
|
foreach (var _wingLv in _json.Keys)
|
{
|
wingLv2GenerDict.Add(int.Parse(_wingLv), int.Parse(_json[_wingLv].ToString()));
|
}
|
WingRefine();
|
}
|
|
void OnEnable()
|
{
|
wingsRedDotModel.IsBoolOpenWingeWin = true;
|
AutomaticBool = false;
|
CoroutinesBool = true;
|
IsOpen = false;
|
_wingRawImage.SetActive(false);
|
_wingRawImage2.SetActive(false);
|
_DevourDIc.Clear();
|
m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
|
|
playerPack.refrechPackEvent += ItemsToRefresh;//背包物品刷新
|
playerPack.itemCntReduceEvent += BackpackRefresh;//背包物品清理
|
playerPack.itemCntAddEvent += EquippedWithRefresh;//角色装备刷新
|
|
EquipmentPositionJudgment();//判断是否有穿戴翅膀
|
WingClassify();
|
SortAll();
|
_RefineStopBtn.SetActive(false);
|
_KeyRefiningBtn.SetActive(true);
|
_refiningBtn.SetActive(true);
|
OnCreateGridLineCell(m_ScrollerController);
|
PreviewTheValue();
|
}
|
|
|
void Start()
|
{
|
WingsImage.onClick.AddListener(WingsBGButton);
|
_refiningBtn.onClick.AddListener(RefiningButton);
|
_KeyRefiningBtn.onClick.AddListener(KeyRefiningButton);
|
_RefineStopBtn.onClick.AddListener(RefineStopButton);
|
}
|
|
void OnDisable()
|
{
|
wingsRedDotModel.IsBoolOpenWingeWin = false;
|
IsOpen = false;
|
_DevourDIc.Clear();
|
// _wingItemDic.Clear();
|
PlusNum.SetActive(false);
|
PlusNum1.SetActive(false);
|
PlusNum2.SetActive(false);
|
StopCoroutine("AkeyRefining");
|
UI3DModelExhibition.Instance.StopShow();
|
// RoleCameraCtrl.GetInstance().OnDestroyModel();
|
playerPack.refrechPackEvent -= ItemsToRefresh;//背包物品刷新
|
playerPack.itemCntReduceEvent -= BackpackRefresh;//背包物品清理
|
playerPack.itemCntAddEvent -= EquippedWithRefresh;//角色装备刷新
|
m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
|
}
|
private void OnCreateGridLineCell(ScrollerController gridCtrl)
|
{
|
gridCtrl.Refresh();
|
int code = 0;
|
for (code = 0; code < LINE; code++)
|
{
|
gridCtrl.AddCell(ScrollerDataType.Header, code);
|
}
|
gridCtrl.Restart();
|
}
|
|
private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
|
{
|
int gridlineIndex = cell.index;
|
int childCode = 0;
|
for (childCode = 0; childCode < cell.transform.childCount; childCode++)
|
{
|
ChildNodes _ChildNodes = cell.transform.GetChild(childCode).GetComponent<ChildNodes>();
|
_ChildNodes._ItemIcon.SetActive(false);
|
_ChildNodes._Elect.SetActive(false);
|
int cellCount = (cell.transform.childCount) * gridlineIndex + (childCode + 1);
|
if (cellCount - 1 < intPetAbsorbTyp.Count)
|
{
|
int _index = cellCount - 1;
|
_ChildNodes._ItemIcon.SetActive(true);
|
ItemModel model = playerPack.GetItemByIndex(PackType.Item, intPetAbsorbTyp[cellCount - 1]);
|
_ChildNodes._ItemIcon.GetComponent<ItemCell>().Init(model);
|
_ChildNodes._ItemButton.onceClick = null;
|
if (_DevourDIc.ContainsKey(intPetAbsorbTyp[cellCount - 1]))
|
{
|
_ChildNodes._Elect.SetActive(true);
|
|
}
|
|
_ChildNodes._ItemButton.onceClick = (int info) =>
|
{
|
if (_ChildNodes._Elect.activeSelf)
|
{
|
_ChildNodes._Elect.SetActive(false);
|
_DevourDIc.Remove(intPetAbsorbTyp[_index]);
|
}
|
else
|
{
|
if (IsAbsorb())
|
{
|
_ChildNodes._Elect.SetActive(true);
|
_DevourDIc.Add(intPetAbsorbTyp[_index], true);
|
}
|
else
|
{
|
|
SysNotifyMgr.Instance.ShowTip("WingRefineisFull");
|
}
|
}
|
m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
|
PreviewTheValue();
|
};
|
}
|
}
|
}
|
|
bool IsAbsorb()//判断能否吸收
|
{
|
int expValue = 0;
|
expValue += (int)_currentRefining;
|
if (_DevourDIc.Count != 0)
|
{
|
foreach (var key in _DevourDIc.Keys)
|
{
|
expValue += Sort2(key);
|
//ItemModel model = playerPack.GetItemModelByIndex(PackType.rptItem, key);
|
//expValue += WingRefineExpConfig.Get(model.itemId).EXPupper;
|
}
|
}
|
return _currentRefiningAll > expValue;
|
}
|
|
void RefineStopButton()//停止精炼
|
{
|
_RefineStopBtn.SetActive(false);
|
_KeyRefiningBtn.SetActive(true);
|
_refiningBtn.SetActive(true);
|
StopCoroutine("AkeyRefining");
|
}
|
|
void RefiningButton()//精炼按钮
|
{
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
|
if (itemModel == null)
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("EquipReinforceWin_WingRefLv_2"));
|
return;
|
}
|
|
if (_DevourDIc.Count == 0)
|
{
|
if (!JudgeConditions())
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("Z1018"));//翅膀精炼已到达满级无法继续精炼
|
}
|
else
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("EquipReinforceWin_WingHText_1"));//所需材料不足
|
}
|
|
return;
|
}
|
if (JudgeConditions())
|
{
|
CA32E_tagCMWingUp _CA32E = new CA32E_tagCMWingUp();
|
byte[] _byte = new byte[1];
|
_byte[0] = (byte)_DevourDIc.Keys.First();
|
_CA32E.Count = (byte)_byte.Length;
|
_CA32E.WingIndexList = _byte;
|
GameNetSystem.Instance.SendInfo(_CA32E);
|
}
|
else
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("Z1018"));//翅膀精炼已到达满级无法继续精炼
|
}
|
}
|
|
|
void PreviewTheValue()//预览值
|
{
|
if (_DevourDIc.Count == 0)
|
{
|
PlusNum.SetActive(false);
|
PlusNum1.SetActive(false);
|
PlusNum2.SetActive(false);
|
}
|
else
|
{
|
PlusNum.SetActive(true);
|
PlusNum1.SetActive(true);
|
PlusNum2.SetActive(true);
|
}
|
|
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
if (itemModel == null)
|
{
|
return;
|
}
|
var WingItem = WingRefineExpConfig.Get(itemModel.itemId);
|
if (WingItem == null)
|
{
|
return;
|
}
|
int YRefiningRatioMin = 0;//预览生命比值
|
int YRefiningRatioMax = 0;//预览生命比值
|
float _RefiningDegreesMin = 0;
|
float _RefiningDegreesMaX = 0;
|
int Min = 0;
|
int Max = 0;
|
|
foreach (var key in _DevourDIc.Keys)
|
{
|
var wingConfig = WingRefineExpConfig.Get(_wingItemDic[key]);
|
if (WingDic[key].GetUseData((int)ItemUseDataKey.wingProgressValue) != null || WingDic[key].GetUseData((int)ItemUseDataKey.wingMaterialItemID) != null)
|
{
|
|
Min += wingConfig.EXPlower + GetWingRefiningValue(WingDic[key]); ;
|
Max += wingConfig.EXPupper + GetWingRefiningValue(WingDic[key]); ;
|
}
|
else
|
{
|
ItemModel model = playerPack.GetItemByIndex(PackType.Item, key);
|
|
for (int i = 0; i < model.count; i++)
|
{
|
if (wingConfig.EXPmaterial != null && !wingConfig.EXPmaterial.Equals(string.Empty))
|
{
|
Dictionary<int, int> dicExp = ConfigParse.GetDic<int, int>(wingConfig.EXPmaterial);
|
Min += dicExp[itemModel.config.LV];
|
Max += dicExp[itemModel.config.LV];
|
}
|
else
|
{
|
Min += wingConfig.EXPlower;
|
Max += wingConfig.EXPupper;
|
}
|
}
|
}
|
}
|
|
int PreviewMin = _currentRefining + Min;//最大下限
|
int PreviewMax = _currentRefining + Max;//最大上限值
|
if (PreviewMin >= _currentRefiningAll)
|
{
|
PreviewMin = _currentRefiningAll;
|
}
|
if (PreviewMax >= _currentRefiningAll)
|
{
|
PreviewMax = _currentRefiningAll;
|
}
|
var config = WingRefineExpConfig.Get((int)itemModel.itemId);
|
_RefiningDegreesMin = (float)Math.Round((itemModel.config.EffectValueA2 +
|
_DicWingRe[config.WingsPhase].Ability2Value *
|
((float)PreviewMin / _currentRefiningAll)) / 100, 2);
|
|
_RefiningDegreesMaX = (float)Math.Round((itemModel.config.EffectValueA2 +
|
_DicWingRe[config.WingsPhase].Ability2Value *
|
((float)PreviewMax / _currentRefiningAll)) / 100, 2);
|
|
YRefiningRatioMin = (Mathf.CeilToInt(_DicWingRe[config.WingsPhase]
|
.Ability1Value * ((float)PreviewMin / _currentRefiningAll) + itemModel.config.EffectValueA1));
|
YRefiningRatioMax = (Mathf.CeilToInt(_DicWingRe[config.WingsPhase]
|
.Ability1Value * ((float)PreviewMax / _currentRefiningAll) + itemModel.config.EffectValueA1));
|
|
PlusNum1.text = "+" + ((float)Math.Round(_RefiningDegreesMin - Damagevalue, 1)).ToString("f2") + "% ~ " + ((float)Math.Round(_RefiningDegreesMaX - Damagevalue, 1)).ToString("f2") + "%";
|
PlusNum2.text = "+" + (YRefiningRatioMin - Lifevalue) + " ~ " + (YRefiningRatioMax - Lifevalue);
|
PlusNum.text = "+" + Min.ToString() + " ~ " + Max.ToString();
|
}
|
|
bool JudgeConditions()//执行判断条件
|
{
|
|
if (_currentRefiningAll > _currentRefining)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
|
}
|
Dictionary<int, int> dicWingUseDateValue = new Dictionary<int, int>();
|
private int GetWingRefiningValue(ItemModel ItemModel)
|
{
|
dicWingUseDateValue.Clear();
|
int GetUseDateValue = 0;
|
if (ItemModel.GetUseData((int)ItemUseDataKey.wingMaterialItemID) != null
|
|| ItemModel.GetUseData((int)ItemUseDataKey.wingMaterialItemCount) != null)
|
{
|
for (int i = 0; i < ItemModel.GetUseData((int)ItemUseDataKey.wingMaterialItemID).Count; i++)
|
{
|
dicWingUseDateValue.Add(ItemModel.GetUseData((int)ItemUseDataKey.wingMaterialItemID)[i], ItemModel.GetUseData((int)ItemUseDataKey.wingMaterialItemCount)[i]);
|
}
|
}
|
if (ItemModel.GetUseData((int)ItemUseDataKey.wingProgressValue) != null)
|
{
|
GetUseDateValue += ItemModel.GetUseData((int)ItemUseDataKey.wingProgressValue)[0];
|
}
|
int WingLv1 = ItemModel.config.LV;
|
foreach (var key in dicWingUseDateValue.Keys)
|
{
|
var wingConfig = WingRefineExpConfig.Get(key);
|
if (wingConfig.EXPmaterial != null && !wingConfig.EXPmaterial.Equals(string.Empty))
|
{
|
Dictionary<int, int> dicExp = ConfigParse.GetDic<int, int>(wingConfig.EXPmaterial);
|
GetUseDateValue -= dicExp[WingLv1] * dicWingUseDateValue[key];
|
}
|
|
}
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
int WingLv2 = itemModel.config.LV;
|
foreach (var key in dicWingUseDateValue.Keys)
|
{
|
var wingConfig = WingRefineExpConfig.Get(key);
|
if (wingConfig.EXPmaterial != null && !wingConfig.EXPmaterial.Equals(string.Empty))
|
{
|
Dictionary<int, int> dicExp = ConfigParse.GetDic<int, int>(wingConfig.EXPmaterial);
|
GetUseDateValue += dicExp[WingLv2] * dicWingUseDateValue[key];
|
}
|
}
|
return GetUseDateValue;
|
}
|
|
void KeyRefiningButton()//一键精炼
|
{
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
if (itemModel == null)
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("EquipReinforceWin_WingRefLv_2"));
|
return;
|
}
|
|
if (_DevourDIc.Count > 0 && JudgeConditions())
|
{
|
AutomaticBool = true;
|
StartCoroutine("AkeyRefining");
|
}
|
else
|
{
|
if (!JudgeConditions())
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("Z1018"));//翅膀精炼已到达满级无法继续精炼
|
}
|
else if (_DevourDIc.Count <= 0)
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("EquipReinforceWin_WingHText_1"));//所需材料不足
|
}
|
|
}
|
|
}
|
IEnumerator AkeyRefining()//一键精炼协成
|
{
|
while (true)
|
{
|
if (JudgeConditions() && _DevourDIc.Count > 0)
|
{
|
if (CoroutinesBool)
|
{
|
_RefineStopBtn.SetActive(true);
|
_KeyRefiningBtn.SetActive(false);
|
_refiningBtn.SetActive(false);
|
CA32E_tagCMWingUp _CA32E = new CA32E_tagCMWingUp();
|
byte[] _byte = new byte[1];
|
_byte[0] = (byte)_DevourDIc.Keys.First();
|
_CA32E.Count = (byte)_byte.Length;
|
_CA32E.WingIndexList = _byte;
|
GameNetSystem.Instance.SendInfo(_CA32E);
|
CoroutinesBool = false;
|
yield return null;
|
}
|
}
|
if (!JudgeConditions())
|
{
|
RefineStopButton();//停止精炼按钮
|
ServerTipDetails.DisplayNormalTip(Language.Get("Z1018"));//翅膀精炼已到达满级无法继续精炼
|
yield break;
|
}
|
if (_DevourDIc.Count <= 0)
|
{
|
RefineStopButton();//停止精炼按钮
|
yield break;
|
}
|
yield return null;
|
}
|
}
|
void WingsBGButton()//点击翅膀背景框按钮
|
{
|
|
bool markingbbol = false;
|
SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
|
if (singlePack == null || singlePack.GetAllItems().Count == 0)
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("WingsRefine_NoWing"));
|
return;
|
}
|
Dictionary<int, ItemModel> backpack_dic = singlePack.GetAllItems();
|
foreach (int index in backpack_dic.Keys)
|
{
|
int _id = (int)backpack_dic[index].itemId;
|
if (!ItemLogicUtility.Instance.IsWing(_id))
|
{
|
continue;
|
}
|
|
var wingConfig = ItemConfig.Get(_id);
|
if (wingConfig.Type == 113 && ItemLogicUtility.Instance.IsJobCompatibleItem(_id))
|
{
|
markingbbol = true;
|
}
|
}
|
if (markingbbol)
|
{
|
WindowCenter.Instance.Open<WingsBouncedWin>();
|
}
|
else
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("WingsRefine_NoWing"));
|
}
|
|
}
|
|
void Backpacking()//物品读取
|
{
|
_wingItemDic.Clear();
|
intPetAbsorbTyp.Clear();
|
WingDic.Clear();
|
//背包字典
|
|
SinglePack rptItemPack = playerPack.GetSinglePack(PackType.Item);
|
ItemModel putOnModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
if (rptItemPack == null || rptItemPack.GetAllItems().Count == 0 || putOnModel == null)
|
{
|
return;
|
}
|
int itemID = putOnModel.itemId;//物品ID
|
var WingItem = WingRefineExpConfig.Get(itemID);
|
if (WingItem == null)
|
{
|
return;
|
}
|
|
var items = rptItemPack.GetAllItems();
|
foreach (var itemIndex in items.Keys)
|
{
|
var item = items[itemIndex];
|
if (WingRefineExpConfig.Has(item.itemId))
|
{
|
if (ItemLogicUtility.Instance.IsWing(item.itemId))
|
{
|
_wingItemDic.Add(itemIndex, item.itemId);
|
WingDic.Add(itemIndex, item);
|
}
|
}
|
}
|
|
if (_wingItemDic.Count != 0)
|
{
|
foreach (var key in _wingItemDic.Keys)
|
{
|
intPetAbsorbTyp.Add(key);
|
}
|
}
|
}
|
|
void EquipmentPositionJudgment()//判断是否有穿戴翅膀
|
{
|
Backpacking();//物品读取
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
int itemID = 0;
|
if (itemModel != null)
|
{
|
itemID = itemModel.itemId;//物品ID
|
}
|
var WingItem = WingRefineExpConfig.Get(itemID);
|
if (itemModel != null && WingItem != null)
|
{
|
WingsImage.SetActive(false);
|
IconButton.SetActive(true);
|
WingsBG.SetItemBackGround(ItemLogicUtility.Instance.GetItemQuality(itemModel.itemId, itemModel.useDataDict));
|
IconButton.GetComponent<Image>().SetSprite(itemModel.config.IconKey);
|
IconButton.RemoveAllListeners();
|
IconButton.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemModel.guid);
|
});
|
ModelCreationDisplay();//模型展示创建
|
RefiningDegrees();//精炼度(刷新)
|
}
|
else
|
{
|
EquipFirstTxt.SetActive(true);
|
_wingRawImage.SetActive(false);
|
_wingRawImage2.SetActive(false);
|
WingsImage.SetActive(true);
|
IconButton.SetActive(false);
|
WingsBG.SetItemBackGround(1);//翅膀框默认颜色值
|
DegreeOfRefining();//精炼度初始没翅膀时
|
}
|
}
|
|
void ModelCreationDisplay()//模型展示创建
|
{
|
if (_wingRawImage.gameObject.activeSelf || _wingRawImage2.gameObject.activeSelf)
|
{
|
return;
|
}
|
EquipFirstTxt.SetActive(false);
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
var config = WingRefineExpConfig.Get((int)itemModel.itemId);
|
int _modelID = config.Model;
|
if (itemModel.itemId == 3724)
|
{
|
_wingRawImage2.SetActive(true);
|
_wingRawImage.SetActive(false);
|
UI3DModelExhibition.Instance.ShowWing(_modelID, _wingRawImage2);
|
}
|
else
|
{
|
_wingRawImage.SetActive(true);
|
_wingRawImage2.SetActive(false);
|
UI3DModelExhibition.Instance.ShowWing(_modelID, _wingRawImage);
|
}
|
|
}
|
|
void DegreeOfRefining()//精炼度初始没翅膀时
|
{
|
WText.SetActive(true);
|
_AttrNameTextNum1.text = "0.00%";
|
Damagevalue = 0;
|
Lifevalue = 0;
|
_AttrNameTextNum2.text = "0";
|
_Pmgressbar.value = 0f;
|
_PmgressText.text = "0/0";
|
WText.text = Language.Get("EquipReinforceWin_WingRefLv_2");
|
}
|
|
void RefiningDegrees()//精炼度(刷新)
|
{
|
WText.SetActive(true);
|
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
|
if (itemModel.GetUseData((int)ItemUseDataKey.wingProgressValue) != null)
|
{
|
_currentRefining = itemModel.GetUseData((int)ItemUseDataKey.wingProgressValue)[0];//当前精炼度
|
}
|
else
|
{
|
_currentRefining = 0;//当前精炼度
|
}
|
if (wingRefineAttrConfigs.Count <= 0)
|
{
|
wingRefineAttrConfigs = WingRefineAttrConfig.GetValues();
|
}
|
// var wingRefineAttrConfigs = WingRefineAttrConfig.GetValues();
|
foreach (var config in wingRefineAttrConfigs)
|
{
|
if (itemModel.config.LV == config.wingsPhase)
|
{
|
_currentRefiningAll = config.EXPupper;//总精炼度
|
_PmgressText.text = _currentRefining.ToString() + "/" + _currentRefiningAll.ToString();
|
if (_currentRefining >= _currentRefiningAll)
|
{
|
_currentRefining = _currentRefiningAll;
|
FullTxt.SetActive(true);
|
}
|
else
|
{
|
FullTxt.SetActive(false);
|
}
|
if (IsOpen)
|
{
|
EffectMgr.Instance.PlayUIEffect(1070, 2500, m_UIEffect1.transform, false);
|
}
|
|
if (_currentRefining >= _currentRefiningAll && IsOpen)
|
{
|
m_UIEffect2.Play();
|
}
|
if (!IsOpen)
|
{
|
IsOpen = true;
|
}
|
_Pmgressbar.value = (float)_currentRefining / _currentRefiningAll;
|
_RefiningRatio = (float)_currentRefining / _currentRefiningAll;//精炼比值
|
int Number = Mathf.CeilToInt(((float)_currentRefining / _currentRefiningAll) * 100);
|
WText.text = string.Format(Language.Get("EquipReinforceWin_WingRefLv_1"), Number) + "%";
|
float _RefiningDegrees = (float)Math.Round((double)(itemModel.config.EffectValueA2 + _DicWingRe[itemModel.config.LV].Ability2Value * _RefiningRatio) / 100, 1);
|
_AttrNameTextNum1.text = _RefiningDegrees.ToString("f2") + "%";
|
Damagevalue = _RefiningDegrees;
|
_AttrNameTextNum2.text = (Mathf.CeilToInt(_DicWingRe[itemModel.config.LV].Ability1Value * _RefiningRatio + itemModel.config.EffectValueA1)).ToString();
|
Lifevalue = Mathf.CeilToInt(_DicWingRe[itemModel.config.LV].Ability1Value * _RefiningRatio + itemModel.config.EffectValueA1);
|
}
|
}
|
|
|
}
|
void ItemSX(int _Equipped)//用于精炼度和边框变色的刷新
|
{
|
if (_Equipped == (int)RoleEquipType.Wing)
|
{
|
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
;
|
int ItemColor = ItemLogicUtility.Instance.GetItemQuality(itemModel.itemId, itemModel.useDataDict);
|
WingsBG.SetItemBackGround(ItemColor);
|
IconButton.GetComponent<Image>().SetSprite(itemModel.config.IconKey);
|
int Number = Mathf.CeilToInt(((float)_currentRefining / _currentRefiningAll) * 100);
|
WText.text = string.Format(Language.Get("EquipReinforceWin_WingRefLv_1"), Number) + "%";
|
}
|
}
|
|
void WingRefine()//精炼属性值获取
|
{
|
if (wingRefineAttrConfigs.Count <= 0)
|
{
|
wingRefineAttrConfigs = WingRefineAttrConfig.GetValues();
|
}
|
// var wingConfigs = WingRefineAttrConfig.GetValues();
|
foreach (var config in wingRefineAttrConfigs)
|
{
|
if (!_DicWingRe.ContainsKey(config.wingsPhase))
|
{
|
WingRefineAttrModel _wingRefineAttrModel = new WingRefineAttrModel();
|
int[] array = ConfigParse.GetKeyValueKeys<int>(config.attrupper);
|
int[] intarray = ConfigParse.GetKeyValueValues<int>(config.attrupper);
|
_wingRefineAttrModel.Ability1 = array[0];
|
_wingRefineAttrModel.Ability2 = array[1];
|
_wingRefineAttrModel.Ability1Value = intarray[0];
|
_wingRefineAttrModel.Ability2Value = intarray[1];
|
_DicWingRe.Add(config.wingsPhase, _wingRefineAttrModel);
|
}
|
}
|
}
|
|
|
|
void ItemsToRefresh(PackType type)//背包刷新
|
{
|
Backpacking();
|
if (AutomaticBool)
|
{
|
CoroutinesBool = true;
|
}
|
|
m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
|
|
}
|
|
void BackpackRefresh(PackType type, int itemPlace, int id)//背包物品清理
|
{
|
if (_DevourDIc.ContainsKey(itemPlace))
|
{
|
ItemModel model = playerPack.GetItemByIndex(PackType.Item, itemPlace);
|
if (model == null)
|
{
|
_DevourDIc.Remove(itemPlace);
|
}
|
}
|
|
Backpacking();
|
if (AutomaticBool)
|
{
|
CoroutinesBool = true;
|
}
|
|
m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
|
PreviewTheValue();
|
}
|
|
void EquippedWithRefresh(PackType type, int index, int id)//角色装备刷新
|
{
|
//临时条件判断
|
if (type != PackType.Equip)
|
{
|
return;
|
}
|
|
|
if (index == (int)RoleEquipType.Wing)
|
{
|
WingsImage.SetActive(false);
|
IconButton.SetActive(true);
|
ModelCreationDisplay();
|
ItemSX(index);
|
RefiningDegrees();//精炼度(刷新)
|
}
|
|
}
|
|
|
private int GetMaxOrderWing()
|
{
|
int MaxMaxOrder = 0;
|
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
if (itemModel != null)
|
{
|
WingRefineExpConfig wingRefineExpConfig = WingRefineExpConfig.Get(itemModel.itemId);
|
if (wingRefineExpConfig != null)
|
{
|
if (wingLv2GenerDict.ContainsKey(wingRefineExpConfig.WingsPhase) && wingLv2GenerDict[wingRefineExpConfig.WingsPhase] > MaxMaxOrder)
|
{
|
MaxMaxOrder = wingLv2GenerDict[wingRefineExpConfig.WingsPhase];
|
}
|
|
}
|
}
|
|
if (intPetAbsorbTyp.Count > 0)
|
{
|
for (int i = 0; i < intPetAbsorbTyp.Count; i++)
|
{
|
ItemModel model = playerPack.GetItemByIndex(PackType.Item, intPetAbsorbTyp[i]);
|
WingRefineExpConfig wingRefineExpConfig = WingRefineExpConfig.Get(model.itemId);
|
if (wingRefineExpConfig != null)
|
{
|
if (wingLv2GenerDict.ContainsKey(wingRefineExpConfig.WingsPhase) && wingLv2GenerDict[wingRefineExpConfig.WingsPhase] > MaxMaxOrder)
|
{
|
MaxMaxOrder = wingLv2GenerDict[wingRefineExpConfig.WingsPhase];
|
}
|
|
}
|
}
|
|
}
|
|
return MaxMaxOrder;
|
}
|
List<int> ClassifyList = new List<int>();//存背包位置
|
private void WingClassify()
|
{
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
if (itemModel == null)
|
{
|
return;
|
}
|
int MaxMaxOrder = GetMaxOrderWing();
|
ClassifyList.Clear();
|
if (MaxMaxOrder <= 2)//最高阶的翅膀或翅膀材料阶数为1阶或者2阶
|
{
|
for (int i = 0; i < intPetAbsorbTyp.Count; i++)
|
{
|
ItemModel model = playerPack.GetItemByIndex(PackType.Item, intPetAbsorbTyp[i]);
|
WingRefineExpConfig wingRefineExpConfig = WingRefineExpConfig.Get(model.itemId);
|
if (wingRefineExpConfig.WingsPhase <= 0 || (wingLv2GenerDict.ContainsKey(wingRefineExpConfig.WingsPhase) && wingLv2GenerDict[wingRefineExpConfig.WingsPhase] <= 1))
|
{
|
ClassifyList.Add(intPetAbsorbTyp[i]);
|
}
|
}
|
}
|
else//最高阶的翅膀或翅膀材料阶数3阶及以上
|
{
|
for (int i = 0; i < intPetAbsorbTyp.Count; i++)
|
{
|
ItemModel model = playerPack.GetItemByIndex(PackType.Item, intPetAbsorbTyp[i]);
|
WingRefineExpConfig wingRefineExpConfig = WingRefineExpConfig.Get(model.itemId);
|
if (wingRefineExpConfig.WingsPhase <= 0 || (wingLv2GenerDict.ContainsKey(wingRefineExpConfig.WingsPhase) && wingLv2GenerDict[wingRefineExpConfig.WingsPhase] <= MaxMaxOrder - 2))
|
{
|
ClassifyList.Add(intPetAbsorbTyp[i]);
|
}
|
}
|
}
|
ClassifyList.Sort(Compare);
|
for (int j = 0; j < ClassifyList.Count; j++)
|
{
|
if (IsAbsorb())
|
{
|
_DevourDIc.Add(ClassifyList[j], true);
|
}
|
}
|
}
|
int Compare(int x, int y)//数组排列
|
{
|
bool havex = Sort1(x);
|
bool havey = Sort1(y);
|
if (havex.CompareTo(havey) != 0)
|
{
|
return -havex.CompareTo(havey);
|
}
|
var _sort_x = Sort2(x);
|
var _sort_y = Sort2(y);
|
return -_sort_x.CompareTo(_sort_y);
|
}
|
|
private bool Sort1(int Index)
|
{
|
ItemModel model = playerPack.GetItemByIndex(PackType.Item, Index);
|
if (model.itemId == 3807 || model.itemId == 3808)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
private int Sort2(int Index)
|
{
|
int Max = 0;
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, SpiritWeaponModel.WING_EQUIPINDEX);
|
if (itemModel == null)
|
{
|
return 0;
|
}
|
var wingConfig = WingRefineExpConfig.Get(_wingItemDic[Index]);
|
if (WingDic[Index].GetUseData((int)ItemUseDataKey.wingProgressValue) != null || WingDic[Index].GetUseData((int)ItemUseDataKey.wingMaterialItemID) != null)
|
{
|
Max = wingConfig.EXPupper + GetWingRefiningValue(WingDic[Index]);
|
}
|
else
|
{
|
ItemModel model = playerPack.GetItemByIndex(PackType.Item, Index);
|
for (int i = 0; i < model.count; i++)
|
{
|
if (wingConfig.EXPmaterial != null && !wingConfig.EXPmaterial.Equals(string.Empty))
|
{
|
Dictionary<int, int> dicExp = ConfigParse.GetDic<int, int>(wingConfig.EXPmaterial);
|
Max = dicExp[itemModel.config.LV];
|
}
|
else
|
{
|
Max = wingConfig.EXPupper;
|
}
|
}
|
}
|
return Max;
|
}
|
|
private void SortAll()//翅膀总的排序
|
{
|
intPetAbsorbTyp.Sort(CompareAll);
|
|
}
|
int CompareAll(int x, int y)//数组排列
|
{
|
bool IsBoolx = ClassifyList.Contains(x);
|
bool IsBooly = ClassifyList.Contains(y);
|
if (IsBoolx.CompareTo(IsBooly) != 0)
|
{
|
return -IsBoolx.CompareTo(IsBooly);
|
}
|
if (ClassifyList.Contains(x) && ClassifyList.Contains(y))
|
{
|
var _sort_x1 = ClassifyList.IndexOf(x);
|
var _sort_y1 = ClassifyList.IndexOf(y);
|
return _sort_x1.CompareTo(_sort_y1);
|
}
|
else
|
{
|
var _sort_x = Sort2(x);
|
var _sort_y = Sort2(y);
|
return -_sort_x.CompareTo(_sort_y);
|
}
|
|
}
|
}
|