CTT/Unity/Assets/HotfixView/UI/StrengthEquipUI/StrengthEquipUI.cs

136 lines
4.6 KiB
C#

using Cal.DataTable;
using ET;
using FairyGUI;
using System;
using static ET.C2M_MakeMunalEquip;
namespace ET
{
public class StrengthEquipUIAwakeSyatem : AwakeSystem<StrengthEquipUI>
{
public override void Awake(StrengthEquipUI self)
{
self.Awake();
}
}
public class StrengthEquipUIDestroySyatem : DestroySystem<StrengthEquipUI>
{
public override void Destroy(StrengthEquipUI self)
{
self.Destroy();
}
}
public class StrengthEquipUI : Entity
{
public FUI_StrengthEquipUI ui;
private int bagIndex;
private ClientItemData data;
private Window window;
private Scene zoneScene;
public void Awake()
{
zoneScene = this.ZoneScene();
ui = GetParent<FUI_StrengthEquipUI>();
AwakeAsync().Coroutine();
ui.m_animFail.visible = false;
ui.m_animSuccess.visible = false;
window = ui.GetComponent<FUIWindowComponent>().Window;
}
private async ETVoid AwakeAsync()
{
ui.m_btnEquip.self.icon = null;
ui.m_txtMaterial.text = null;
bagIndex = 1;
ui.m_btnEquip.self.onDrop.Set1(context =>
{
if (context.data is UIDragArgs args)
{
int index = args.index;
args.Release();
if (ClientItemDataComponent.Instance.ItemDic.TryGetValueByKey1(index, out data))
{
if (data.ItemType != ItemType.EquipItem)
{
TipHelper.OpenUI("只能对装备进行炼化!");
return;
}
bagIndex = index;
EquipBase equipBase = DataTableHelper.Get<EquipBase>(data.ItemId);
ui.m_btnEquip.self.icon = UIPackage.GetItemURL(FUIPackage.Bag, equipBase.IconName.ToString());
ShowMaterial();
}
}
});
ui.m_btnMake.self.onClick.Set(async () =>
{
if (bagIndex == -1) return;
window.ShowModalWait(1);
M2C_StrengthEquip ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_StrengthEquip>(new C2M_StrengthEquip { bagIndex = bagIndex });
if (!ret.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(ret.Message);
window.CloseModalWait(1);
return;
}
if (ret.isSuccess)
{
End(ui.m_animSuccess);
}
else
{
End(ui.m_animFail);
}
});
await ETTask.CompletedTask;
}
private void End(GMovieClip m_animSuccess)
{
m_animSuccess.visible = true;
m_animSuccess.SetPlaySettings(0, -1, 1, -1);
m_animSuccess.playing = true;
m_animSuccess.onPlayEnd.Set(async () =>
{
M2C_GetBag getBag = await zoneScene.GetComponent<SessionComponent>().Call<M2C_GetBag>(new C2M_GetBag());
Game.EventSystem.Publish_Sync(new ET.EventType.UpdateBagUI
{
list = getBag.BagMapList,
});
ShowMaterial();
window.CloseModalWait(1);
m_animSuccess.visible = false;
});
}
private void ShowMaterial()
{
if (!ClientItemDataComponent.Instance.ItemDic.TryGetValueByKey1(bagIndex, out data))
{
return;
}
Strengthentable strengthentable = StrengthentableCategory.Instance.Get(data.Equip.level + 1, false);
if (strengthentable == null)
{
ui.m_txtMaterial.text = "无法强化";
return;
}
string str = null;
str += $"装备等级:{data.Equip.level}\n";
str += $"强化几率:{strengthentable.Probability:p2}\n";
str += "-------------------------------\n";
foreach (Strengthentable.NeedMaterial item in strengthentable.NeedMaterialArr)
{
str += $"{BagHelper.GetIconName(item._Id).Item1} X {item.Count}\n";
}
str += $"{strengthentable.NeedCoin}金币";
ui.m_txtMaterial.text = str;
}
public void Destroy()
{
}
}
}