mycj_demo/mycj/Assets/Game/Scripts/FB-Framework/FB-MVC/FBView.cs
2024-12-02 09:37:47 +08:00

61 lines
1.8 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Felix-BangFBView
//   へ     /|
//  /7    ∠_/
//  / │    
//  Z _,    /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │
//  / へ   / ノ<|
//  ヽ_ノ  (_  │//
//  7       |
//  ―r ̄ ̄`ー―_
// Describe界面的基类(需要挂载到游戏对象)
// 1. 查询模型(调用模型的方法),接收模型发送的消息
// 2. 处理消息
// 3. 向控制器发送消息
// Createtime2018/9/19
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace FBFramework
{
public abstract class FBView : MonoBehaviour
{
/// <summary> 名称:用于检索 </summary>
public abstract string Name { get; }
/// <summary> View相关的事件列表 </summary>
[HideInInspector]
public List<string> EventLists = new List<string>();
/// <summary>
/// 事件处理
/// </summary>
/// <param name="eventName">事件名称</param>
/// <param name="data">携带信息</param>
public abstract void HandleEvent(string eventName, object data = null);
// 注册关心的事件
public virtual void RegisterEvents() {}
/// <summary> 获取模型 </summary>
protected T GetModel<T>()
where T : FBModel
{
return FBMVC.GetModel<T>() as T;
}
// 发送事件
protected void SendEvent(string eventName, object data = null)
{
FBMVC.SendEvent(eventName, data);
}
}
}