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

163 lines
5.9 KiB
C#
Raw Normal View History

using Cal.DataTable;
2021-04-08 20:09:59 +08:00
using ET;
using System;
using System.Collections.Generic;
2021-05-02 23:18:14 +08:00
using ET.EventType;
2021-04-11 19:50:39 +08:00
using FairyGUI;
2021-04-08 20:09:59 +08:00
namespace ET
{
public class ButlerUIAwakeSyatem: AwakeSystem<ButlerUI>
2021-04-08 20:09:59 +08:00
{
public override void Awake(ButlerUI self)
{
self.Awake();
}
}
public class ButlerUIDestroySyatem: DestroySystem<ButlerUI>
2021-04-08 20:09:59 +08:00
{
public override void Destroy(ButlerUI self)
{
self.Destroy();
}
}
public class ButlerUI: Entity
2021-04-08 20:09:59 +08:00
{
private FUI_NPCTaskUI ui;
private Scene zoneScene;
2021-04-08 20:09:59 +08:00
public void Awake()
{
zoneScene = this.ZoneScene();
2021-04-08 20:09:59 +08:00
ui = GetParent<FUI_NPCTaskUI>();
AwakeAsync().Coroutine();
}
2021-04-08 20:09:59 +08:00
private async ETVoid AwakeAsync()
{
//!切换控制器
ui.m_contrl.selectedIndex = 0;
//!显示第一页内容
2021-04-11 19:50:39 +08:00
NPCBase npcBase = DataTableHelper.Get<NPCBase>(1004);
2021-04-08 20:09:59 +08:00
//!窗口名字
ui.m_frame.self.title = npcBase.Name;
//!对话内容
ui.m_txtDialog.text = " " + npcBase.Dialog;
ui.m_taskList.RemoveChildrenToPool();
2021-04-11 19:50:39 +08:00
GButton btn = ui.m_taskList.AddItemFromPool().asButton;
2021-04-08 20:09:59 +08:00
btn.title = "仓库";
btn.onClick.Set(() => { Game.EventSystem.Publish(new ET.EventType.OpenStoreUI { zoneScene = ui.ZoneScene(), }).Coroutine(); });
2021-04-08 20:09:59 +08:00
btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "手工";
btn.onClick.Set(() => { Game.EventSystem.Publish(new ET.EventType.OpenManulEquipUI { zoneScene = ui.ZoneScene(), }).Coroutine(); });
2021-04-08 20:09:59 +08:00
btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "强化";
btn.onClick.Set(() => { Game.EventSystem.Publish(new ET.EventType.OpenStrengthEquipUI { zoneScene = ui.ZoneScene(), }).Coroutine(); });
2021-04-08 20:09:59 +08:00
btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "洗练";
btn.onClick.Set(() => { Game.EventSystem.Publish(new ET.EventType.OpenRefreshEquipUIUI { zoneScene = ui.ZoneScene(), }).Coroutine(); });
AddMapCointCount();
ChangeName();
TrialReword();
2021-05-02 23:18:14 +08:00
StarSoulUpgradeUI();
2021-05-15 14:29:48 +08:00
AddMultiShopUI();
await ETTask.CompletedTask;
}
2021-05-15 14:29:48 +08:00
private void AddMultiShopUI()
{
var btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "杂货店";
btn.onClick.Set(() =>
{
Game.EventSystem.Publish(new OpenMultiShopUI() { zoneScene = this.zoneScene });
this.ui.GetComponent<FUIWindowComponent>().Hide();
});
}
2021-05-02 23:18:14 +08:00
private void StarSoulUpgradeUI()
{
var btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "升级星魂";
btn.onClick.Set(() =>
{
Game.EventSystem.Publish(new OpenStartSoulUpgradeUI() { zoneScene = this.zoneScene });
this.ui.GetComponent<FUIWindowComponent>().Hide();
});
}
private void AddMapCointCount()
{
var btn = ui.m_taskList.AddItemFromPool().asButton;
2021-04-08 20:09:59 +08:00
btn.title = "增加随机地图金币次数";
btn.onClick.Set(() =>
{
2021-04-11 19:50:39 +08:00
FUI_TipUI tip = TipHelper.OpenUI("是否花费20代金券增加一次拾取地图中随机金币的次数当天有效", tipType: TipType.Double);
tip.m_btnYes.self.onClick.Set(async () =>
2021-04-08 20:09:59 +08:00
{
M2C_AddMapCoinCount ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_AddMapCoinCount>(new C2M_AddMapCoinCount { });
2021-04-08 20:09:59 +08:00
if (!ret.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(ret.Message);
return;
}
});
});
}
private void ChangeName()
{
var btn = ui.m_taskList.AddItemFromPool().asButton;
2021-04-08 20:09:59 +08:00
btn.title = "改名";
btn.onClick.Set(() =>
{
2021-04-11 19:50:39 +08:00
FUI_TipUI tip = TipHelper.OpenUI("是否花费1000代金券改名", tipType: TipType.DoubleInput);
2021-04-08 20:09:59 +08:00
tip.m_btnYes.self.onClick.Set(async () =>
{
string name = tip.m_IptTxt.text.Trim();
if (name.IsNullOrEmpty()) return;
2021-04-08 20:09:59 +08:00
if (IllegalWordHelper.DetectIllegalWords(name).Count != 0)
{
TipHelper.OpenUI("不能包含违禁字!");
return;
}
M2C_ChangeNickName ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_ChangeNickName>(new C2M_ChangeNickName { name = name });
2021-04-08 20:09:59 +08:00
if (!ret.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(ret.Message);
return;
}
});
});
}
private void TrialReword()
2021-04-08 20:09:59 +08:00
{
var btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "领取最高奖励";
btn.onClick.Set(() =>
{
FUI_TipUI tip = TipHelper.OpenUI("是否领取试炼之地的所有奖励?一日只有一次机会,可以使用经验卡,在挑战了最高层之后使用!", tipType: TipType.Double);
tip.m_btnYes.self.onClick.Set(async () =>
{
var ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_GetAllTrialCopyReword>(new C2M_GetAllTrialCopyReword() { });
if (!ret.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(ret.Message);
return;
}
});
});
}
2021-04-08 20:09:59 +08:00
public void Destroy()
{
2021-04-08 20:09:59 +08:00
}
}
}