👨💻个人主页:@元宇宙-秩沅
👨💻 hallo 欢迎 点赞👍 收藏⭐ 留言📝 加关注✅!
👨💻 本文由 秩沅 原创
👨💻 收录于专栏:就业宝典
⭐🅰️推荐专栏⭐
⭐-软件设计师高频考点大全⭐
文章目录
- ⭐前言⭐
- (==3==)PureMVC框架面板系统
- **SetPanel**
- **GamePanel**
- statePanel
- backPackPanel
- RolePanel
- SotrePanel
- TipPanel
- StartTipPanel
- NPCTipPanel
- GameOVerPanel
- GamePassPanel(Clone)
- ⭐🅰️⭐
⭐前言⭐
(3)PureMVC框架面板系统
SetPanel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 设置面板视图
//-------创建者: -------
//------------------------------
public class SetView : BasePanel
{
public Button stayBtu; //继续游戏按钮
public Slider soundSlider; //音量滑动条
}
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------
//-------功能: 设置面板视图中介
//-------创建者: -------
//------------------------------
public class SetViewMediator : Mediator
{
//铭牌名
public static string NAME = "SetViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public SetViewMediator() : base(NAME)
{
}
/// <summary>
/// 重写监听感兴趣的通知的方法
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
};
}
/// <summary>
/// 面板中组件设置(监听相关)
/// </summary>
/// <param name="stateView"></param>
public void setView(SetView seteView)
{
ViewComponent = seteView;
seteView.stayBtu.onClick.AddListener(() =>
{
SendNotification(PureNotification.HIDE_PANEL, "SetPanel");
});
//音乐滑动条
seteView.soundSlider.onValueChanged.AddListener((vlaue) =>
{
PlayerContorller.GetInstance().audioClip.volume = vlaue;
});
}
/// <summary>
/// 玩家受伤逻辑
/// </summary>
public void Hurt()
{
}
/// <summary>
/// 重写处理通知的方法,处理通知,前提是完成通知的监听
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
}
}
GamePanel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 游戏面板视图
//-------创建者: -------
//------------------------------
public class GameView : BasePanel
{
public Slider audioSliderVuale; //音量滑动条
public Button startBtu; //开始按钮
public Button tipBtu; //游戏说明按钮
}
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
//-------------------------------
//-------功能: 游戏面板视图中介
//-------创建者: -------
//------------------------------
public class GameViewMediator : Mediator
{
//铭牌名
public static string NAME = "GameViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public GameViewMediator() : base(NAME)
{
}
/// <summary>
/// 重写监听通知的方法,返回需要的监听(通知)
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
//PureNotification.UPDATA_ROLE_INFO,
//PureNotification.UPDATA_STATE_INFO
};
}
/// <summary>
/// 面板中组件设置(监听相关)
/// </summary>
/// <param name="gameView"></param>
public void SetView(GameView gameView)
{
Debug.Log(gameView+"执行SetView");
ViewComponent = gameView;
//开始按钮逻辑监听
gameView.startBtu.onClick.AddListener(()=>
{
Time.timeScale = 1;//取消游戏暂停
SendNotification(PureNotification.HIDE_PANEL, "GamePanel");
SendNotification(PureNotification.SHOW_PANEL, "StatePanel");
});
gameView.tipBtu .onClick.AddListener(() =>
{
SendNotification(PureNotification.SHOW_PANEL , "StartTipPanel");
});
//音乐滑动条
gameView.audioSliderVuale .onValueChanged.AddListener((vlaue) =>
{
PlayerContorller.GetInstance().audioClip.volume = vlaue;
});
}
/// <summary>
/// 重写处理通知的方法,处理通知
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
switch (notification.Name)
{
//case PureNotification.UPDATA_STATE_INFO:
// (ViewComponent as StateView).UpdateView(notification.Body as PlayerDataObj);
// break;
}
}
}
statePanel
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 状态面板视图
//-------创建者: -------
//------------------------------
public class StateView : BasePanel
{
//1.找控件
public TextMeshProUGUI levelText; //等级
public TextMeshProUGUI bloodValue; //当前血量
public TextMeshProUGUI attackVaule; //攻击力值
public float blood ,maxBlood, attack;
public Slider hpSlider; //玩家血条
public Slider expSlider; //经验血条
public Slider bossSlider; //Boss血条
public Button roleBtu; //角色按钮
public Button backpackBtu; //背包按钮
public Image weaponSprite;//当前武器
public Text damon; //当前钻石的数量
/// <summary>
/// 2.更新面板视图View的显示数据
/// </summary>
public void UpdateView(PlayerDataObj data) //此处选择的是MVC的思想,在这里些许有些耦合
{
Debug.Log("来更新了");
if(data != null)
{
blood = data.blood;
attack = data.attack;
maxBlood = data.maxBlood;
levelText.text = Convert.ToString(data.level);
bloodValue.text = Convert.ToString(data.blood);
attackVaule.text = Convert.ToString(data.attack);
bossSlider.value = data.blood / data.maxBlood;
weaponSprite.sprite = data.nowItem ;
damon.text = Convert.ToString(PlayerContorller.GetInstance().damonNum );
}
else
{
Debug.Log("date为空");
}
}
/// <summary>
/// 增加钻石
/// </summary>
public void UpdateDamon()
{
damon.text = PlayerContorller .GetInstance().damonNum .ToString ();
}
}
using PureMVC.Core;
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 状态面板视图中介
//-------创建者:
//------------------------------
/// <summary>
/// 状态面板视图中介
/// 固定:
/// 1.继承PureMVC的Mediator脚本
/// 2.写构造函数
/// 3.重写监听通知的方法
/// 4.重写处理通知的方法
/// 5.可选:重写注册时的方法
/// </summary>
public class StateViewMediator : Mediator
{
//铭牌名
public static string NAME = "StateViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public StateViewMediator() : base(NAME)
{
}
/// <summary>
/// 重写监听感兴趣的通知的方法
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
PureNotification.UPDATA_STATE_INFO,
PureNotification.PLAYER_INJURY ,
PureNotification.LEVEL_UP ,
PureNotification.UPDATA_WEAPON_INFO2,
PureNotification .UPDATA_EXP,
PureNotification.UPDATA_DAMON
};
}
/// <summary>
/// 面板中组件设置(监听相关)
/// </summary>
/// <param name="stateView"></param>
public void setView(StateView stateView)
{
ViewComponent = stateView;
stateView.roleBtu.onClick.AddListener(()=>
{
//SendNotification(PureNotification.HIDE_PANEL, "StatePanel");
SendNotification(PureNotification.SHOW_PANEL, "RolePanel");
});
stateView.backpackBtu.onClick.AddListener(() =>
{
//SendNotification(PureNotification.HIDE_PANEL, "StatePanel");
SendNotification(PureNotification.SHOW_PANEL, "BackpackPanel");
});
}
/// <summary>
/// 玩家受伤逻辑
/// </summary>
public void Hurt()
{
}
/// <summary>
/// 重写处理通知的方法,处理通知,前提是完成通知的监听
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
switch (notification.Name)
{
case PureNotification.UPDATA_STATE_INFO: //状态更新的处理逻辑
(ViewComponent as StateView).UpdateView(notification.Body as PlayerDataObj);
break;
case PureNotification.PLAYER_INJURY : //玩家受伤命令的处理逻辑
if (ViewComponent != null)
{
StateView stateView = ViewComponent as StateView;
int blood = Convert.ToInt32(notification.Body);
stateView.blood -= blood ;
stateView.blood = stateView.blood > stateView.maxBlood ? stateView.maxBlood : stateView.blood; //防止血条溢出
float off = stateView.blood / stateView.maxBlood;
stateView.hpSlider.value = off; //改变血条
if(off <= 0)//如果血条变成0或者小于0,则玩家死亡
{
PlayerContorller.GetInstance().isDied = true;
PlayerContorller.GetInstance().DiedEvent();//开启死亡
}
}
break;
case PureNotification.UPDATA_WEAPON_INFO2 : //玩家武器信息更新的处理逻辑
if (ViewComponent != null)
{
StateView stateView = ViewComponent as StateView;
stateView.weaponSprite.sprite = notification .Body as Sprite ;
stateView.weaponSprite.enabled = true;
}
break;
case PureNotification.UPDATA_EXP ://玩家经验信息更新的处理逻辑
if (ViewComponent != null)
{
StateView stateView = ViewComponent as StateView;
int exp = Convert.ToInt32(notification.Body);
float off = exp / 100f;
Debug.Log("来了"+off);
stateView.expSlider .value = off; //改变经验条
if(off >= 1 ) //经验条满
{
stateView.blood = stateView.maxBlood;
if (!Facade.HasProxy (PlayerProxy.NAME)) //首先判断是否有该中介,没有就new一个
{
Facade.RegisterProxy(new PlayerProxy()); //注册该视图中介
}
//获取视图对应的代理
PlayerProxy bm = Facade.RetrieveProxy(PlayerProxy.NAME) as PlayerProxy;
bm.LevUp(); //数据升级的方法
stateView.UpdateView(bm.Data as PlayerDataObj); //升级数据
stateView.expSlider.value = 0;
PlayerContorller.GetInstance().exp = 0; //经验条归位
}
}
break;
case PureNotification.UPDATA_DAMON:
{
if (ViewComponent != null)
{
StateView stateView = ViewComponent as StateView;
stateView.UpdateDamon(); //执行增加钻石的方法
}
break;
}
}
}
}
backPackPanel
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 背包系统视图
//-------创建者:
//------------------------------
public class BackpackView : BasePanel
{
public Button back; //退出按钮
public GridLayoutGroup grid;
/// <summary>
/// 更新背包中的内容
/// </summary>
/// <param name="itemBtu"></param>
public void AddItem(Button itemBtu)
{
try
{
Destroy(itemBtu.transform.GetComponent<ShopItem>()); //移除该商品的脚本
itemBtu.transform.AddComponent<PropItem>(); //重新添加脚本
}
catch { }
//将传入的按钮设置为布局下面的子物体
itemBtu.transform.SetParent (grid.gameObject.transform );
itemBtu.transform.localScale = Vector3.one ;//初始化商品道具大小
}
}
RolePanel
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 角色面板视图
//-------创建者: -------
//------------------------------
public class RoleView : BasePanel
{
//1.找控件
public Button back; //退出
public Text levelText; //等级
public Text maxBlood; //最大血量
public Text attackVaule; //攻击力值
public Text defenceVaule; //防御力值
public Text CriticalVaule; //暴击率
public Image[] item; //武器栏图
public GameObject[] role; //显示角色选择
/// <summary>
/// 2.更新面板视图View的显示数据
/// </summary>
public void UpdateView(PlayerDataObj data) //此处选择的是MVC的思想,在这里些许有些耦合
{
if (data != null)
{
levelText.text = data.level.ToString();
maxBlood.text = data.maxBlood.ToString();
attackVaule.text = data.attack.ToString();
defenceVaule.text = data.denfence.ToString();
CriticalVaule.text = data.strike.ToString();
}
else
{
Debug.Log("角色面板无法更新");
}
}
/// <summary>
/// 更新武器栏中的图片
/// </summary>
/// <param name="item"></param>
public void UpdateWeaponItem(PlayerDataObj data)
{
Debug.Log("更新武器");
if (data.index < 3 && PlayerContorller.GetInstance().curWeaponNum >0)
{
this.item[data.index].enabled = true;
this.item[data.index++].sprite = data.nowItem;
}
}
}
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------
//-------功能: 角色面板视图中介
//-------创建者: -------
//------------------------------
/// <summary>
/// 角色面板视图中介
/// 固定:
/// 1.继承PureMVC的Mediator脚本
/// 2.写构造函数
/// 3.重写监听通知的方法
/// 4.重写处理通知的方法
/// 5.可选:重写注册时的方法
/// </summary>
public class RoleViewMediator : Mediator
{
//铭牌名
public static string NAME = "RoleViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public RoleViewMediator( ) : base(NAME)
{
//可以去写创捷面板预设体的逻辑等
}
/// <summary>
/// 重写监听通知的方法,返回需要的监听(通知)
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
PureNotification.UPDATA_ROLE_INFO,
PureNotification.UPDATA_WEAPON_INFO1
};
}
public void SetView(RoleView roleView)
{
Debug.Log(roleView + "执行SetView");
ViewComponent = roleView;
//开始按钮逻辑监听
roleView.back.onClick.AddListener(() =>
{
SendNotification(PureNotification.HIDE_PANEL, "RolePanel");
});
}
/// <summary>
/// 重写处理通知的方法,处理通知
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
switch (notification.Name)
{
case PureNotification.UPDATA_ROLE_INFO:
if (ViewComponent != null)
{
(ViewComponent as RoleView).UpdateView(notification.Body as PlayerDataObj);
(ViewComponent as RoleView).UpdateWeaponItem(notification.Body as PlayerDataObj);
}
else { Debug.Log("为空"); }
break;
}
}
/// <summary>
/// 可选:重写注册方法(他们需要到Facde中注册)
/// </summary>
public override void OnRegister()
{
base.OnRegister();
}
}
SotrePanel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 商城系统
//-------创建者: -------
//------------------------------
public class StoreView : BasePanel
{
public GridLayoutGroup StoreGrid;
public GridLayoutGroup BackGrid;
public Button backBtu;
public Button bugPack;//放入背包
}
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------
//-------功能: -------
//-------创建者: -------
//------------------------------
public class StoreViewMediator : Mediator
{
//铭牌名
public static string NAME = "StoreViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public StoreViewMediator() : base(NAME)
{
}
/// <summary>
/// 重写监听感兴趣的通知的方法
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
};
}
/// <summary>
/// 面板中组件设置(监听相关)
/// </summary>
/// <param name="stateView"></param>
public void setView(StoreView storeView)
{
ViewComponent = storeView;
if(ViewComponent == null) { Debug.Log("面板是空的"); }
storeView.backBtu.onClick.AddListener(()=>
{
SendNotification(PureNotification.HIDE_PANEL, "StorePanel");
});
storeView.bugPack.onClick.AddListener(() =>
{
SendNotification(PureNotification.HIDE_PANEL, "StorePanel");
});
}
/// <summary>
/// 玩家受伤逻辑
/// </summary>
public void Hurt()
{
}
/// <summary>
/// 重写处理通知的方法,处理通知,前提是完成通知的监听
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
switch (notification.Name)
{
}
}
}
TipPanel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 余额不足提示面板视图
//-------创建者: -------
//------------------------------
public class TipView : BasePanel
{
public Button ok;
}
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------
//-------功能: 余额不足提示面板中介
//-------创建者: -------
//------------------------------
public class TipViewMediator : Mediator
{
//铭牌名
public static string NAME = "TipViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public TipViewMediator() : base(NAME)
{
}
/// <summary>
/// 重写监听感兴趣的通知的方法
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
};
}
/// <summary>
/// 面板中组件设置(监听相关)
/// </summary>
/// <param name="stateView"></param>
public void setView(TipView tipView)
{
ViewComponent = tipView;
if (ViewComponent == null) { Debug.Log("面板是空的"); }
tipView.ok.onClick.AddListener(() =>
{
SendNotification(PureNotification.HIDE_PANEL, "TipPanel");
});
}
/// <summary>
/// 玩家受伤逻辑
/// </summary>
public void Hurt()
{
}
/// <summary>
/// 重写处理通知的方法,处理通知,前提是完成通知的监听
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
switch (notification.Name)
{
}
}
}
StartTipPanel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 开始说明面板视图
//-------创建者: -------
//------------------------------
public class StartTipView : BasePanel
{
public Button startBtu;
}
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------
//-------功能: 开始说明面板视图中介
//-------创建者: -------
//------------------------------
public class StartTipViewMediator : Mediator
{
//铭牌名
public static string NAME = "StartTipViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public StartTipViewMediator() : base(NAME)
{
}
/// <summary>
/// 重写监听通知的方法,返回需要的监听(通知)
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
//PureNotification.UPDATA_ROLE_INFO,
//PureNotification.UPDATA_STATE_INFO
};
}
public void SetView(StartTipView startTipView)
{
Debug.Log(startTipView + "执行SetView");
ViewComponent = startTipView;
//按钮逻辑监听
startTipView.startBtu.onClick.AddListener(() =>
{
SendNotification(PureNotification.HIDE_PANEL, "GamePanel");
SendNotification(PureNotification.HIDE_PANEL, "startTipPanel");
SendNotification(PureNotification.SHOW_PANEL, "StatePanel");
});
}
/// <summary>
/// 重写处理通知的方法,处理通知
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
switch (notification.Name)
{
//case PureNotification.UPDATA_STATE_INFO:
// (ViewComponent as StateView).UpdateView(notification.Body as PlayerDataObj);
// break;
}
}
}
NPCTipPanel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: NPC交互面板视图
//-------创建者: -------
//------------------------------
public class NPCTipView : BasePanel
{
public Button backBtu;
}
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------
//-------功能: NPC交互面板视图中介
//-------创建者: -------
//------------------------------
/// <summary>
/// 状态面板视图中介
/// 固定:
/// 1.继承PureMVC的Mediator脚本
/// 2.写构造函数
/// 3.重写监听通知的方法
/// 4.重写处理通知的方法
/// 5.可选:重写注册时的方法
/// </summary>
public class NPCTipViewMediator : Mediator
{
//铭牌名
public static string NAME = "NPCTipViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public NPCTipViewMediator() : base(NAME)
{
}
/// <summary>
/// 面板中组件设置(监听相关)
/// </summary>
public void SetView(NPCTipView npcTipView)
{
Debug.Log(npcTipView + "执行SetView");
ViewComponent = npcTipView;
//出击按钮逻辑监听
npcTipView.backBtu.onClick.AddListener(() =>
{
SendNotification(PureNotification.HIDE_PANEL, "NPCTipPanel");
});
}
/// <summary>
/// 重写监听通知的方法,返回需要的监听(通知)
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
//PureNotification.UPDATA_ROLE_INFO,
//PureNotification.UPDATA_STATE_INFO
};
}
/// <summary>
/// 重写处理通知的方法,处理通知
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
switch (notification.Name)
{
//case PureNotification.UPDATA_STATE_INFO:
// (ViewComponent as StateView).UpdateView(notification.Body as PlayerDataObj);
// break;
}
}
}
GameOVerPanel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 失败面板视图
//-------创建者: -------
//------------------------------
public class DefeatView : BasePanel
{
public Button restartBtu; //重新开始按钮
public Button endBtu; //结束按钮
}
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
//-------------------------------
//-------功能: 失败面板视图中介
//-------创建者: -------
//------------------------------
/// <summary>
/// 状态面板视图中介
/// 固定:
/// 1.继承PureMVC的Mediator脚本
/// 2.写构造函数
/// 3.重写监听通知的方法
/// 4.重写处理通知的方法
/// 5.可选:重写注册时的方法
/// </summary>
public class DefeatViewMediator : Mediator
{
//铭牌名
public static string NAME = "DefeatViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public DefeatViewMediator() : base(NAME)
{
}
/// <summary>
/// 重写监听通知的方法,返回需要的监听(通知)
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
//PureNotification.UPDATA_ROLE_INFO,
//PureNotification.UPDATA_STATE_INFO
};
}
public void SetView(DefeatView defeatView)
{
ViewComponent = defeatView;
defeatView.restartBtu.onClick.AddListener(()=>{
SendNotification(PureNotification.HIDE_PANEL ,"DefeatPanel");
SceneManager.LoadScene(2);
});
defeatView.endBtu .onClick.AddListener(() => {
SendNotification(PureNotification.HIDE_PANEL, "DefeatPanel");
SceneManager.LoadScene(2);
});
}
/// <summary>
/// 重写处理通知的方法,处理通知
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
switch (notification.Name)
{
//case PureNotification.UPDATA_STATE_INFO:
// (ViewComponent as StateView).UpdateView(notification.Body as PlayerDataObj);
// break;
}
}
}
GamePassPanel(Clone)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 通过游戏面板视图
//-------创建者: -------
//------------------------------
public class GamePassView : BasePanel
{
public Button okenter;
}
using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
//-------------------------------
//-------功能: 通过游戏面板视图中介
//-------创建者: -------
//------------------------------
public class GamePassViewMediator : Mediator
{
//铭牌名
public static string NAME = "GamePassViewMediator";
/// <summary>
/// 构造函数
/// </summary>
public GamePassViewMediator() : base(NAME)
{
}
/// <summary>
/// 重写监听感兴趣的通知的方法
/// </summary>
/// <returns>返回你需要监听的通知的名字数组</returns>
public override string[] ListNotificationInterests()
{
return new string[] {
};
}
/// <summary>
/// 面板中组件设置(监听相关)
/// </summary>
/// <param name="stateView"></param>
public void setView(GamePassView tipView2)
{
ViewComponent = tipView2;
if (ViewComponent == null) { Debug.Log("面板是空的"); }
tipView2.okenter .onClick.AddListener(() =>
{
SendNotification(PureNotification.HIDE_PANEL, "GamePassPanel");
SceneManager.LoadScene(2);
});
}
/// <summary>
/// 玩家受伤逻辑
/// </summary>
public void Hurt()
{
}
/// <summary>
/// 重写处理通知的方法,处理通知,前提是完成通知的监听
/// </summary>
/// <param name="notification">通知</param>
public override void HandleNotification(INotification notification)
{
switch (notification.Name)
{
}
}
}
⭐🅰️⭐
⭐【Unityc#专题篇】之c#进阶篇】
⭐【Unityc#专题篇】之c#核心篇】
⭐【Unityc#专题篇】之c#基础篇】
⭐【Unity-c#专题篇】之c#入门篇】
⭐【Unityc#专题篇】—进阶章题单实践练习
⭐【Unityc#专题篇】—基础章题单实践练习
⭐【Unityc#专题篇】—核心章题单实践练习
你们的点赞👍 收藏⭐ 留言📝 关注✅是我持续创作,输出优质内容的最大动力!、