/// 基础UI窗体 public class BaseUIForm : MonoBehaviour { protected string MsgTypeName = ""; // 该类的消息名
private void Awake() { //初始化基础信息 Initialization(); //初始化UI信息 InitUIInfo(); //初始化UI按钮点击事件 InitButtonClickEvent();
if (MsgTypeName != "") { ReceiveMessage(MsgTypeName, ReceiveMsg); }
LanguageManager.Instance.AddRefreshUI(RefreshUIText); }
}
-------------------------------------------------------------------------------------------------------------
// 窗体子类
public class MissionInfoUI : BaseUIForm
{
protected override void InitButtonClickEvent() { //注册开始任务按钮 RegisterButtonObjectEvent("StartMissionButton", p=> { CloseUIForm(); }); //注册改变任务按钮 RegisterButtonObjectEvent("ChangeMissionButton", p => { //判断是否有足够的钱刷新任务 if (MainManager.CostCoins(100)) { StartCoroutine(GetMissionIE(true)); } }); }
protected override void ReceiveMsg(KeyValuesUpdate KV) { switch (KV.Key) { //刷新任务 case SysDefine.SYS_MSG_KIND_RefreshMission: { StartCoroutine( GetMissionIE() ); } break; } }
IEnumerator GetMissionIE(bool IsChangeMission = false) { GetMission(IsChangeMission);
//隐藏背景和任务UI GetComponent().color = new Color(GetComponent().color.r, GetComponent().color.g, GetComponent().color.b, 0);
trans_MissionBox.Hide(); //transform.FindChild("TTTT").SetSprite(); FindChild(this.gameObject, "MissionTitle").Hide(); ChangeMissionButton.Hide();
// 显示接取任务的滑条动画(只显示根节点即可) trans_MissionSlider.Show(); Image FillArea = FindChild(trans_MissionSlider.gameObject, "FillArea");
// 滑条从0开始填充到1结束,用时1.5秒 FillArea.fillAmount = 0f;
// 插件DOTween方法 DOFillAmount( this Image target, float endValue, float duration ) FillArea.DOFillAmount(1f, 1.5f); yield return new WaitForSeconds(1.5f);
//隐藏任务滑条 trans_MissionSlider.Hide();
//显示任务信息 GetComponent().color = new Color(GetComponent().color.r, GetComponent().color.g, GetComponent().color.b, 1);
trans_MissionBox.Show(); FindChild(this.gameObject, "MissionTitle").Show(); ChangeMissionButton.Show(); }
}