174 lines
6.8 KiB
C#
174 lines
6.8 KiB
C#
using Cal.DataTable;
|
||
using ET;
|
||
using FairyGUI;
|
||
using static ET.C2M_MakeMunalEquip;
|
||
|
||
namespace ET
|
||
{
|
||
public class ManulEquipUIAwakeSyatem : AwakeSystem<ManulEquipUI>
|
||
{
|
||
public override void Awake(ManulEquipUI self)
|
||
{
|
||
self.Awake();
|
||
}
|
||
}
|
||
public class ManulEquipUIDestroySyatem : DestroySystem<ManulEquipUI>
|
||
{
|
||
public override void Destroy(ManulEquipUI self)
|
||
{
|
||
self.Destroy();
|
||
}
|
||
}
|
||
public class ManulEquipUI : Entity
|
||
{
|
||
public FUI_ManulEquipUI ui;
|
||
private StoneType rare;
|
||
private MunalStoneType munalStoneType;
|
||
private Scene zoneScene;
|
||
|
||
public void Awake()
|
||
{
|
||
zoneScene = this.ZoneScene();
|
||
ui = GetParent<FUI_ManulEquipUI>();
|
||
AwakeAsync().Coroutine();
|
||
rare = StoneType.Nomal;
|
||
ui.m_comRare.self.selectedIndex = 0;
|
||
}
|
||
private async ETVoid AwakeAsync()
|
||
{
|
||
ui.m_comRare.self.onChanged.Set1(concent =>
|
||
{
|
||
if (!int.TryParse(ui.m_comRare.self.value, out int index)) return;
|
||
rare = (StoneType)index;
|
||
OnChangeEquiptype();
|
||
});
|
||
ui.m_comEquipType.self.onChanged.Set1(concent =>
|
||
{
|
||
if (!int.TryParse(ui.m_comEquipType.self.value, out int index)) return;
|
||
munalStoneType = (MunalStoneType)index;
|
||
OnChangeEquiptype();
|
||
});
|
||
ui.m_btnMake.self.onClick.Set(async () =>
|
||
{
|
||
M2C_MakeMunalEquip ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_MakeMunalEquip>(new C2M_MakeMunalEquip { Type = (int)munalStoneType, IsRare = rare });
|
||
if (!ret.Message.IsNullOrEmpty())
|
||
{
|
||
TipHelper.OpenUI(ret.Message);
|
||
return;
|
||
}
|
||
});
|
||
|
||
await ETTask.CompletedTask;
|
||
}
|
||
|
||
private void OnChangeEquiptype()
|
||
{
|
||
EquipType equipType = EquipType.项链;
|
||
switch (munalStoneType)
|
||
{
|
||
case MunalStoneType.Red:
|
||
equipType = EquipType.项链;
|
||
break;
|
||
case MunalStoneType.White:
|
||
equipType = EquipType.护腕;
|
||
break;
|
||
case MunalStoneType.Green:
|
||
equipType = EquipType.帽子;
|
||
break;
|
||
case MunalStoneType.Black:
|
||
equipType = EquipType.戒指;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
ManulEquip manulEquip = ManulEquipCategory.Instance.Get((long)equipType);
|
||
string icon = null;
|
||
var bagDic = ClientItemDataComponent.Instance.ItemDic;
|
||
if (rare == StoneType.Rare)
|
||
{
|
||
//!判断材料
|
||
for (int i = manulEquip.RareMaterialArr.Length - 1; i >= 0; i--)
|
||
{
|
||
int materialCount = 0;
|
||
ManulEquip.RareMaterial needMaterial = manulEquip.RareMaterialArr[i];
|
||
int count = needMaterial.Count;
|
||
if (!bagDic.TryGetValueByKey2(needMaterial.MaterialId, out var itemList) || itemList.Count == 0)
|
||
{ }
|
||
else
|
||
{
|
||
foreach (ClientItemData item in itemList)
|
||
materialCount += item.Count;
|
||
}
|
||
string name = BagHelper.GetIconName(needMaterial.MaterialId).Item1;
|
||
string color = count > materialCount ? "FF0000" : "FFFFFF";
|
||
icon += $"[color=#{color}]{name} x{count}(持有{materialCount})[/color]\n";
|
||
}
|
||
}
|
||
else if(rare == StoneType.Nomal)
|
||
{
|
||
for (int i = manulEquip.MaterialArr.Length - 1; i >= 0; i--)
|
||
{
|
||
int materialCount = 0;
|
||
ManulEquip.Material needMaterial = manulEquip.MaterialArr[i];
|
||
int count = needMaterial.Count;
|
||
if (!bagDic.TryGetValueByKey2(needMaterial.MaterialId, out var itemList) || itemList.Count == 0)
|
||
{ }
|
||
else
|
||
{
|
||
foreach (ClientItemData item in itemList)
|
||
materialCount += item.Count;
|
||
}
|
||
string name = BagHelper.GetIconName(needMaterial.MaterialId).Item1;
|
||
string color = count > materialCount ? "FF0000" : "FFFFFF";
|
||
icon += $"[color=#{color}]{name} x{count}(持有{materialCount})[/color]\n";
|
||
}
|
||
}
|
||
else if (rare == StoneType.UpgradeRare)
|
||
{
|
||
//!判断材料
|
||
for (int i = manulEquip.UpgradeRareMaterialArr.Length - 1; i >= 0; i--)
|
||
{
|
||
int materialCount = 0;
|
||
ManulEquip.UpgradeRareMaterial needMaterial = manulEquip.UpgradeRareMaterialArr[i];
|
||
int count = needMaterial.Count;
|
||
if (!bagDic.TryGetValueByKey2(needMaterial.MaterialId, out var itemList) || itemList.Count == 0)
|
||
{ }
|
||
else
|
||
{
|
||
foreach (ClientItemData item in itemList)
|
||
materialCount += item.Count;
|
||
}
|
||
string name = BagHelper.GetIconName(needMaterial.MaterialId).Item1;
|
||
string color = count > materialCount ? "FF0000" : "FFFFFF";
|
||
icon += $"[color=#{color}]{name} x{count}(持有{materialCount})[/color]\n";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
for (int i = manulEquip.EpicMaterialArr.Length - 1; i >= 0; i--)
|
||
{
|
||
int materialCount = 0;
|
||
ManulEquip.EpicMaterial needMaterial = manulEquip.EpicMaterialArr[i];
|
||
int count = needMaterial.Count;
|
||
if (!bagDic.TryGetValueByKey2(needMaterial.MaterialId, out var itemList) || itemList.Count == 0)
|
||
{ }
|
||
else
|
||
{
|
||
foreach (ClientItemData item in itemList)
|
||
materialCount += item.Count;
|
||
}
|
||
string name = BagHelper.GetIconName(needMaterial.MaterialId).Item1;
|
||
string color = count > materialCount ? "FF0000" : "FFFFFF";
|
||
icon += $"[color=#{color}]{name} x{count}(持有{materialCount})[/color]\n";
|
||
}
|
||
}
|
||
ui.m_txtMaterial.text = icon;
|
||
}
|
||
|
||
public void Destroy()
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|