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

163 lines
5.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Cal.DataTable;
using ET;
using System;
using System.Collections.Generic;
using ET.EventType;
using FairyGUI;
namespace ET
{
public class ButlerUIAwakeSyatem: AwakeSystem<ButlerUI>
{
public override void Awake(ButlerUI self)
{
self.Awake();
}
}
public class ButlerUIDestroySyatem: DestroySystem<ButlerUI>
{
public override void Destroy(ButlerUI self)
{
self.Destroy();
}
}
public class ButlerUI: Entity
{
private FUI_NPCTaskUI ui;
private Scene zoneScene;
public void Awake()
{
zoneScene = this.ZoneScene();
ui = GetParent<FUI_NPCTaskUI>();
AwakeAsync().Coroutine();
}
private async ETVoid AwakeAsync()
{
//!切换控制器
ui.m_contrl.selectedIndex = 0;
//!显示第一页内容
NPCBase npcBase = DataTableHelper.Get<NPCBase>(1004);
//!窗口名字
ui.m_frame.self.title = npcBase.Name;
//!对话内容
ui.m_txtDialog.text = " " + npcBase.Dialog;
ui.m_taskList.RemoveChildrenToPool();
GButton btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "仓库";
btn.onClick.Set(() => { Game.EventSystem.Publish(new ET.EventType.OpenStoreUI { zoneScene = ui.ZoneScene(), }).Coroutine(); });
btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "手工";
btn.onClick.Set(() => { Game.EventSystem.Publish(new ET.EventType.OpenManulEquipUI { zoneScene = ui.ZoneScene(), }).Coroutine(); });
btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "强化";
btn.onClick.Set(() => { Game.EventSystem.Publish(new ET.EventType.OpenStrengthEquipUI { zoneScene = ui.ZoneScene(), }).Coroutine(); });
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();
StarSoulUpgradeUI();
AddMultiShopUI();
await ETTask.CompletedTask;
}
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();
});
}
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;
btn.title = "增加随机地图金币次数";
btn.onClick.Set(() =>
{
FUI_TipUI tip = TipHelper.OpenUI("是否花费20代金券增加一次拾取地图中随机金币的次数当天有效", tipType: TipType.Double);
tip.m_btnYes.self.onClick.Set(async () =>
{
M2C_AddMapCoinCount ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_AddMapCoinCount>(new C2M_AddMapCoinCount { });
if (!ret.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(ret.Message);
return;
}
});
});
}
private void ChangeName()
{
var btn = ui.m_taskList.AddItemFromPool().asButton;
btn.title = "改名";
btn.onClick.Set(() =>
{
FUI_TipUI tip = TipHelper.OpenUI("是否花费1000代金券改名", tipType: TipType.DoubleInput);
tip.m_btnYes.self.onClick.Set(async () =>
{
string name = tip.m_IptTxt.text.Trim();
if (name.IsNullOrEmpty()) return;
if (IllegalWordHelper.DetectIllegalWords(name).Count != 0)
{
TipHelper.OpenUI("不能包含违禁字!");
return;
}
M2C_ChangeNickName ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_ChangeNickName>(new C2M_ChangeNickName { name = name });
if (!ret.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(ret.Message);
return;
}
});
});
}
private void TrialReword()
{
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;
}
});
});
}
public void Destroy()
{
}
}
}