143 演武场-客户端 只在“没有战斗”和“主线战斗道中”时弹结算界面
| | |
| | | /// </summary> |
| | | /// <param name="name">窗口名称</param> |
| | | /// <param name="functionId">功能ID,用于指定窗口的具体功能或显示模式</param> |
| | | public void Add(string name, int functionId = 0) |
| | | public void Add(string name, bool isNeedHomeWin = true, int functionId = 0) |
| | | { |
| | | var popupWindow = new PopupWindow() |
| | | { |
| | | window = name, |
| | | isNeedHomeWin = isNeedHomeWin, |
| | | functionId = functionId, |
| | | }; |
| | | |
| | |
| | | } |
| | | |
| | | popupWindowQueue.Add(popupWindow); |
| | | popupWindowQueue.Sort((x, y) => y.isNeedHomeWin.CompareTo(x.isNeedHomeWin)); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="name">窗口名称</param> |
| | | /// <param name="functionId">功能ID</param> |
| | | public void Remove(string name, int functionId = 0) |
| | | public void Remove(string name, bool isNeedHomeWin = true, int functionId = 0) |
| | | { |
| | | var popupWindow = new PopupWindow() |
| | | { |
| | | window = name, |
| | | isNeedHomeWin = isNeedHomeWin, |
| | | functionId = functionId, |
| | | }; |
| | | |
| | |
| | | if (UIManager.Instance.IsOpened<LoadingWin>()) |
| | | return; |
| | | |
| | | if (!UIManager.Instance.IsOpened<HomeWin>()) |
| | | if (!UIManager.Instance.IsOpened<HomeWin>() && popupWindowQueue[0].isNeedHomeWin) |
| | | return; |
| | | |
| | | // 第一次打开HomeWin时记录时间 |
| | | // 进入游戏第一次推送做延迟处理 |
| | | if (!homeWinFirstOpened) |
| | | { |
| | | firstTime = Time.realtimeSinceStartup; |
| | |
| | | } |
| | | // 等待x秒 |
| | | if (Time.realtimeSinceStartup - firstTime < stayTime) |
| | | return; |
| | | |
| | | // 只在“没有战斗”和“主线战斗”时允许弹窗 |
| | | string activeBattleName = BattleManager.Instance.GetActiveBattleName(); |
| | | if (activeBattleName != "" && activeBattleName != "StoryBattleField") |
| | | return; |
| | | |
| | | if (UIManager.Instance.IsOpened(popupWindowQueue[0].window)) |
| | |
| | | if (UIManager.Instance.ExistAnyFullScreenOrMaskWin(popupWindowQueue[0].window)) |
| | | return; |
| | | |
| | | |
| | | |
| | | if (currentWindow.window != null) |
| | | if (currentWindow != null && currentWindow.window != null) |
| | | { |
| | | //判断上一个推送是否关闭 |
| | | UIBase ui = UIManager.Instance.GetUI(currentWindow.window); |
| | | if (ui != null && ui.IsActive()) |
| | | return; |
| | | |
| | | } |
| | | |
| | | currentWindow = popupWindowQueue[0]; |
| | |
| | | /// 弹窗结构体,用于表示一个待处理的弹窗请求 |
| | | /// 包含窗口名称和功能ID,通过这两个字段可以唯一标识一个弹窗请求 |
| | | /// </summary> |
| | | public struct PopupWindow |
| | | public class PopupWindow |
| | | { |
| | | // 窗口名称 |
| | | public string window; |
| | |
| | | // 功能ID,用于指定窗口的具体功能或显示模式 |
| | | public int functionId; |
| | | |
| | | public static bool operator ==(PopupWindow lhs, PopupWindow rhs) |
| | | { |
| | | return lhs.window == rhs.window && lhs.functionId == rhs.functionId; |
| | | } |
| | | |
| | | public static bool operator !=(PopupWindow lhs, PopupWindow rhs) |
| | | { |
| | | return lhs.window != rhs.window || lhs.functionId != rhs.functionId; |
| | | } |
| | | |
| | | // 添加GetHashCode和Equals方法以确保结构体可以正确比较 |
| | | public override bool Equals(object obj) |
| | | { |
| | | if (obj is PopupWindow) |
| | | { |
| | | PopupWindow other = (PopupWindow)obj; |
| | | return this.window == other.window && this.functionId == other.functionId; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public override int GetHashCode() |
| | | { |
| | | return window.GetHashCode() ^ functionId.GetHashCode(); |
| | | } |
| | | public bool isNeedHomeWin; |
| | | } |
| | | |
| | | } |
| | |
| | | [SerializeField] TextEx txtFuncName; |
| | | [SerializeField] ScrollerController scroller; |
| | | JsonData jsonData; |
| | | string guid; |
| | | |
| | | string battleName = "ArenaBattleField"; |
| | | protected override void InitComponent() |
| | | { |
| | | |
| | |
| | | protected override void OnPreOpen() |
| | | { |
| | | scroller.OnRefreshCell += OnRefreshCell; |
| | | guid = BattleSettlementManager.Instance.notifyGuid; |
| | | jsonData = BattleSettlementManager.Instance.GetBattleSettlement(guid); |
| | | jsonData = BattleSettlementManager.Instance.GetBattleSettlement(battleName); |
| | | if (jsonData == null) |
| | | { |
| | | DelayCloseWindow().Forget(); |
| | |
| | | protected override void OnPreClose() |
| | | { |
| | | scroller.OnRefreshCell -= OnRefreshCell; |
| | | BattleSettlementManager.Instance.WinShowOver(guid); |
| | | BattleSettlementManager.Instance.WinShowOver(battleName); |
| | | } |
| | | |
| | | // B4 20 回合制战斗状态 #tagMCTurnFightState 通用的结算状态 State 4-结算奖励 |
| | |
| | | [SerializeField] TextEx txtFuncName; |
| | | [SerializeField] ScrollerController scroller; |
| | | JsonData jsonData; |
| | | string guid; |
| | | string battleName = "ArenaBattleField"; |
| | | protected override void OnPreOpen() |
| | | { |
| | | scroller.OnRefreshCell += OnRefreshCell; |
| | | guid = BattleSettlementManager.Instance.notifyGuid; |
| | | jsonData = BattleSettlementManager.Instance.GetBattleSettlement(guid); |
| | | jsonData = BattleSettlementManager.Instance.GetBattleSettlement(battleName); |
| | | if (jsonData == null) |
| | | { |
| | | DelayCloseWindow().Forget(); |
| | |
| | | protected override void OnPreClose() |
| | | { |
| | | scroller.OnRefreshCell -= OnRefreshCell; |
| | | BattleSettlementManager.Instance.WinShowOver(guid); |
| | | BattleSettlementManager.Instance.WinShowOver(battleName); |
| | | } |
| | | // B4 20 回合制战斗状态 #tagMCTurnFightState 通用的结算状态 State 4-结算奖励 |
| | | // Msg 中额外信息 |
| | |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | // 获取当前正在显示的战斗场景,如果没有则返回null |
| | | public BattleField GetActiveBattleFieldByName(string battleName) |
| | | { |
| | | foreach (var kvp in battleFields) |
| | | { |
| | | BattleField battleField = kvp.Value; |
| | | if (battleField == null) |
| | | continue; |
| | | |
| | | var name = battleField.ToString(); |
| | | if (name == battleName) |
| | | return battleField; |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | |
| | | [SerializeField] Button tipEquipBtn; |
| | | [SerializeField] Button tipHeroPosBtn; |
| | | |
| | | string guid; |
| | | |
| | | string battleName = "ArenaBattleField"; |
| | | protected override void InitComponent() |
| | | { |
| | | tipEquipBtn.AddListener(() => |
| | |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | guid = BattleSettlementManager.Instance.notifyGuid; |
| | | } |
| | | |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | BattleSettlementManager.Instance.WinShowOver(guid); |
| | | BattleSettlementManager.Instance.WinShowOver(battleName); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using LitJson; |
| | | |
| | | public partial class BattleSettlementManager : GameSystemManager<BattleSettlementManager> |
| | | { |
| | | //结算后需清除 |
| | | //结算后需清除 <battleName,JsonData> |
| | | Dictionary<string, JsonData> battleSettlementDic = new Dictionary<string, JsonData>(); |
| | | public string notifyGuid = string.Empty; |
| | | |
| | | // public string notifyGuid = string.Empty; |
| | | |
| | | public override void Init() |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public void OnBeforePlayerDataInitialize() |
| | | { |
| | | battleSettlementDic.Clear(); |
| | | } |
| | | |
| | | |
| | | //"Msg":{"itemInfo":[{"ItemID":5,"Count":2},{"ItemID":3,"Count":40}],"winFaction":1,"statInfo":{"1":{"1":{"1":{"NPCID":0,"DefHurt":727,"CureHP":0,"AtkHurt":1891,"ObjID":1,"HeroID":530004},"3":{"NPCID":0,"DefHurt":483,"CureHP":1511,"AtkHurt":782,"ObjID":6,"HeroID":520001},"2":{"NPCID":0,"DefHurt":953,"CureHP":0,"AtkHurt":1712,"ObjID":5,"HeroID":510003}}},"2":{"1":{"1":{"NPCID":10101091,"DefHurt":638,"CureHP":0,"AtkHurt":140,"ObjID":2,"HeroID":610001},"3":{"NPCID":10101092,"DefHurt":625,"CureHP":0,"AtkHurt":126,"ObjID":3,"HeroID":610001},"5":{"NPCID":10101093,"DefHurt":3122,"CureHP":0,"AtkHurt":1897,"ObjID":4,"HeroID":510003}}}}} |
| | | public void OnSettlement(string _guid, JsonData _data) |
| | | public void AddPop(string battleName, int result) |
| | | { |
| | | if (string.Empty == _guid) |
| | | return; |
| | | |
| | | battleSettlementDic[_guid] = _data; |
| | | notifyGuid = _guid; |
| | | if (_data.ContainsKey("winFaction")) |
| | | bool isWin = result == 1; |
| | | switch (battleName) |
| | | { |
| | | var result = (int)_data["winFaction"]; |
| | | case "ArenaBattleField": |
| | | PopupWindowsProcessor.Instance.Add(isWin ? "ArenaBattleVictoryWin" : "ArenaBattleFailWin", false); |
| | | break; |
| | | default: |
| | | PopupWindowsProcessor.Instance.Add(isWin ? "BattleVictoryWin" : "BattleFailWin", false); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | var battle = BattleManager.Instance.GetBattleField(_guid); |
| | | if (battle == null) |
| | | return; |
| | | if (battle is ArenaBattleField) |
| | | { |
| | | if (result == 1) |
| | | public void ShowResultWin(string battleName, int result) |
| | | { |
| | | bool isWin = result == 1; |
| | | switch (battleName) |
| | | { |
| | | case "ArenaBattleField": |
| | | if (isWin) |
| | | { |
| | | UIManager.Instance.OpenWindow<ArenaBattleVictoryWin>(); |
| | | } |
| | |
| | | { |
| | | UIManager.Instance.OpenWindow<ArenaBattleFailWin>(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (result == 1) |
| | | break; |
| | | default: |
| | | if (isWin) |
| | | { |
| | | UIManager.Instance.OpenWindow<BattleVictoryWin>(); |
| | | } |
| | |
| | | { |
| | | UIManager.Instance.OpenWindow<BattleFailWin>(); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | public void WinShowOver(string _guid) |
| | | //"Msg":{"itemInfo":[{"ItemID":5,"Count":2},{"ItemID":3,"Count":40}],"winFaction":1,"statInfo":{"1":{"1":{"1":{"NPCID":0,"DefHurt":727,"CureHP":0,"AtkHurt":1891,"ObjID":1,"HeroID":530004},"3":{"NPCID":0,"DefHurt":483,"CureHP":1511,"AtkHurt":782,"ObjID":6,"HeroID":520001},"2":{"NPCID":0,"DefHurt":953,"CureHP":0,"AtkHurt":1712,"ObjID":5,"HeroID":510003}}},"2":{"1":{"1":{"NPCID":10101091,"DefHurt":638,"CureHP":0,"AtkHurt":140,"ObjID":2,"HeroID":610001},"3":{"NPCID":10101092,"DefHurt":625,"CureHP":0,"AtkHurt":126,"ObjID":3,"HeroID":610001},"5":{"NPCID":10101093,"DefHurt":3122,"CureHP":0,"AtkHurt":1897,"ObjID":4,"HeroID":510003}}}}} |
| | | public void OnSettlement(string _guid, JsonData _data) |
| | | { |
| | | battleSettlementDic.Remove(_guid); |
| | | if (string.Empty == _guid) |
| | | return; |
| | | var battle = BattleManager.Instance.GetBattleField(_guid); |
| | | if (battle == null) |
| | | return; |
| | | var battleName = battle.ToString(); |
| | | battleSettlementDic[battleName] = _data; |
| | | |
| | | string activeBattleName = BattleManager.Instance.GetActiveBattleName(); |
| | | |
| | | if (_data.ContainsKey("winFaction")) |
| | | { |
| | | var result = (int)_data["winFaction"]; |
| | | if (battleName == activeBattleName) |
| | | { |
| | | //自己场景结算 |
| | | ShowResultWin(battleName, result); |
| | | } |
| | | else |
| | | { |
| | | AddPop(battleName, result); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | public void WinShowOver(string battleName) |
| | | { |
| | | battleSettlementDic.Remove(battleName); |
| | | |
| | | var battle = BattleManager.Instance.GetActiveBattleFieldByName(battleName); |
| | | if (battle != null) |
| | | battle.WhaleFall(); |
| | | } |
| | | |
| | | public JsonData GetBattleSettlement(string _guid) |
| | | public JsonData GetBattleSettlement(string battleName) |
| | | { |
| | | if (!battleSettlementDic.ContainsKey(_guid)) |
| | | if (!battleSettlementDic.ContainsKey(battleName)) |
| | | { |
| | | return null; |
| | | } |
| | | return battleSettlementDic[_guid]; |
| | | return battleSettlementDic[battleName]; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | [SerializeField] ScrollerController scroller; |
| | | |
| | | string guid; |
| | | string battleName = "StoryBossBattleField"; |
| | | protected override void OnPreOpen() |
| | | { |
| | | guid = BattleSettlementManager.Instance.notifyGuid; |
| | | scroller.OnRefreshCell += OnRefreshCell; |
| | | CreateScroller(); |
| | | } |
| | |
| | | protected override void OnPreClose() |
| | | { |
| | | scroller.OnRefreshCell -= OnRefreshCell; |
| | | BattleSettlementManager.Instance.WinShowOver(guid); |
| | | BattleSettlementManager.Instance.WinShowOver(battleName); |
| | | } |
| | | |
| | | List<Item> showItems = new List<Item>(); |
| | | void CreateScroller() |
| | | { |
| | | var jsonData = BattleSettlementManager.Instance.GetBattleSettlement(guid); |
| | | var jsonData = BattleSettlementManager.Instance.GetBattleSettlement(battleName); |
| | | if (jsonData == null) |
| | | { |
| | | DelayCloseWindow().Forget(); |