2021-04-08 20:09:59 +08:00
|
|
|
|
using Cal;
|
|
|
|
|
using Cal.DataTable;
|
|
|
|
|
using ET;
|
|
|
|
|
using FairyGUI;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public class MeltingUIAwakeSyatem : AwakeSystem<MeltingUI>
|
|
|
|
|
{
|
|
|
|
|
public override void Awake(MeltingUI self)
|
|
|
|
|
{
|
|
|
|
|
self.Awake();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class MeltingUIDestroySyatem : DestroySystem<MeltingUI>
|
|
|
|
|
{
|
|
|
|
|
public override void Destroy(MeltingUI self)
|
|
|
|
|
{
|
|
|
|
|
self.Destroy();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class MeltingUI : Entity
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private static readonly float[] _meltingPrice = { 1.0f, 1.2f, 1.5f, 2.0f };
|
|
|
|
|
|
|
|
|
|
public FUI_MeltingUI meltingUI;
|
|
|
|
|
|
|
|
|
|
private Equip equip;
|
|
|
|
|
private MaterialBase materialBase;
|
|
|
|
|
private bool isDismount;
|
2021-04-20 00:25:04 +08:00
|
|
|
|
private Scene zoneScene;
|
|
|
|
|
|
2021-04-08 20:09:59 +08:00
|
|
|
|
public void Awake()
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
zoneScene = this.ZoneScene();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
meltingUI = GetParent<FUI_MeltingUI>();
|
|
|
|
|
AwakeAsync().Coroutine();
|
|
|
|
|
}
|
|
|
|
|
private async ETVoid AwakeAsync()
|
|
|
|
|
{
|
|
|
|
|
//!临时变量
|
|
|
|
|
int equipIndex = -1, gemIndex = -1;
|
|
|
|
|
isDismount = false;
|
|
|
|
|
//!按钮置空
|
|
|
|
|
meltingUI.m_btnEquip.self.icon = null;
|
|
|
|
|
meltingUI.m_btnGem.self.icon = null;
|
|
|
|
|
meltingUI.m_ItemList.RemoveChildrenToPool();
|
|
|
|
|
EquipBase equipBase = null;
|
|
|
|
|
//!放入事件
|
|
|
|
|
meltingUI.m_btnEquip.self.onDrop.Set1(concent =>
|
|
|
|
|
{
|
|
|
|
|
if (concent.data is UIDragArgs args)
|
|
|
|
|
{
|
|
|
|
|
int index = args.index;
|
|
|
|
|
args.Release();
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (ClientItemDataComponent.Instance.ItemDic.TryGetValueByKey1(index, out ClientItemData data))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (data.ItemType != ItemType.EquipItem)
|
|
|
|
|
{
|
|
|
|
|
TipHelper.OpenUI("只能对装备进行炼化!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
equipIndex = index;
|
|
|
|
|
equipBase = DataTableHelper.Get<EquipBase>(data.ItemId);
|
|
|
|
|
meltingUI.m_btnEquip.self.icon = UIPackage.GetItemURL(FUIPackage.Bag, equipBase.IconName.ToString());
|
|
|
|
|
//!属性按钮列表
|
|
|
|
|
UpdateAttribteList(meltingUI, data.Equip.gemList);
|
|
|
|
|
equip = data.Equip;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
meltingUI.m_btnGem.self.onDrop.Set1(concent =>
|
|
|
|
|
{
|
|
|
|
|
if (concent.data is UIDragArgs args)
|
|
|
|
|
{
|
|
|
|
|
int index = args.index;
|
|
|
|
|
args.Release();
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (ClientItemDataComponent.Instance.ItemDic.TryGetValueByKey1(index, out ClientItemData data))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
materialBase = DataTableHelper.Get<MaterialBase>(data.ItemId);
|
|
|
|
|
if (data.ItemType != ItemType.MaterialsItem || materialBase.MaterialType != (int)MaterialsType.宝石)
|
|
|
|
|
{
|
|
|
|
|
TipHelper.OpenUI("只能放入宝石!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
gemIndex = index;
|
|
|
|
|
meltingUI.m_btnGem.self.icon = UIPackage.GetItemURL(FUIPackage.Bag, materialBase.IconName.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
meltingUI.m_ItemList.onClickItem.Set1(concent =>
|
|
|
|
|
{
|
|
|
|
|
GButton btn = concent.data as GButton;
|
|
|
|
|
int index = meltingUI.m_ItemList.GetChildIndex(btn);
|
|
|
|
|
int price = 0;
|
|
|
|
|
if (isDismount)
|
|
|
|
|
{
|
|
|
|
|
if (equip == null) return;
|
|
|
|
|
int itemId = equip.gemList[index];
|
|
|
|
|
if (itemId == 0) price = 0;
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
MaterialBase _materialBase = MaterialBaseCategory.Instance.Get(itemId);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
GemPriceConfig priceConfig = GemPriceConfigCategory.Instance.Get(_materialBase.GemLevel);
|
|
|
|
|
price = priceConfig.DiscountPrice;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (materialBase == null) return;
|
|
|
|
|
GemPriceConfig priceConfig = GemPriceConfigCategory.Instance.Get(materialBase.GemLevel);
|
|
|
|
|
price = priceConfig.InlayPrice;
|
|
|
|
|
}
|
|
|
|
|
long coin = (long)(price * 10000 * _meltingPrice[index]);
|
2021-04-11 19:50:39 +08:00
|
|
|
|
(long, int, int) arr = TabHelper.GetCoinFormat(coin);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
meltingUI.m_txtGold.text = (arr.Item1 * _meltingPrice[index]).ToString();
|
|
|
|
|
meltingUI.m_txtSliver.text = (arr.Item2 * _meltingPrice[index]).ToString();
|
|
|
|
|
meltingUI.m_txtCoin.text = (arr.Item3 * _meltingPrice[index]).ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
//!开始炼化
|
|
|
|
|
meltingUI.m_btnMelt.self.onClick.Set(() =>
|
|
|
|
|
{
|
|
|
|
|
if (meltingUI.m_ItemList.selectedIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
TipHelper.OpenUI("请选择一个宝石孔!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!isDismount)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
FUI_TipUI tip = TipHelper.OpenUI("同一种宝石不能镶嵌多个在一件装备上,否则不生效!", tipType: TipType.Double);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
tip.m_btnYes.self.onClick.Set(Melt);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Dismount().Coroutine();
|
|
|
|
|
}
|
|
|
|
|
async ETVoid Dismount()
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
M2C_DismountGem ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_DismountGem>(new C2M_DismountGem() { bagIndex = equipIndex, gemIndex = meltingUI.m_ItemList.selectedIndex });
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
TipHelper.OpenUI(ret.Message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
M2C_GetBag getBag = await zoneScene.GetComponent<SessionComponent>().Call<M2C_GetBag>(new C2M_GetBag());
|
2021-04-08 20:09:59 +08:00
|
|
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.UpdateBagUI
|
|
|
|
|
{
|
|
|
|
|
list = getBag.BagMapList,
|
|
|
|
|
});
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (ClientItemDataComponent.Instance.ItemDic.TryGetValueByKey1(equipIndex, out ClientItemData data))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
UpdateAttribteList(meltingUI, data.Equip.gemList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async void Melt()
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
M2C_MeltEquip ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_MeltEquip>(new C2M_MeltEquip() { EquipIndex = equipIndex, GemIndex = gemIndex, AttributeIndex = meltingUI.m_ItemList.selectedIndex });
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
TipHelper.OpenUI(ret.Message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.UpdateBagUI
|
|
|
|
|
{
|
|
|
|
|
list = ret.BagMapList
|
|
|
|
|
});
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (ClientItemDataComponent.Instance.ItemDic.TryGetValueByKey1(equipIndex, out ClientItemData data))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
UpdateAttribteList(meltingUI, data.Equip.gemList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
meltingUI.m_btnIsDismount.self.onClick.Set(() =>
|
|
|
|
|
{
|
|
|
|
|
isDismount = meltingUI.m_btnIsDismount.self.selected;
|
|
|
|
|
meltingUI.m_btnMelt.self.title = isDismount ? "拆卸" : "炼化";
|
|
|
|
|
});
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
private static void UpdateAttribteList(FUI_MeltingUI meltingUI, List<int> list)
|
|
|
|
|
{
|
|
|
|
|
meltingUI.m_ItemList.RemoveChildrenToPool();
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (int item in list)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
GButton btn = meltingUI.m_ItemList.AddItemFromPool(FUI_ButtonMeltingItem.URL).asButton;
|
|
|
|
|
if (item == 0)
|
|
|
|
|
{
|
|
|
|
|
btn.title = $"{TabHelper.SliverStar} [size=12][color=#99ff99]【暂无宝石】[/color][/size] [color=#99cc99]空宝石槽 [/color]";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
MaterialBase materialBase = DataTableHelper.Get<MaterialBase>(item);
|
|
|
|
|
btn.title = $"{TabHelper.YellowStar} [size=12][color=#99ff99]【{(GemType)materialBase.GemType}】[/color][/size] [color=#99cc99]{TabHelper.GteGemValue((AttributeType)materialBase.GemKey, materialBase.GemValue)}[/color]";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Destroy()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|