Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts
| | |
| | | public class DTC0102_tagCDBPlayer : DtcBasic
|
| | | {
|
| | |
|
| | | public static event Action beforePlayerDataInitializeEvent;
|
| | | public static event Action beforePlayerDataInitializeEvent; //重登切换账号 或者 短暂的断线重连 都会触发
|
| | | public static event Action beforePlayerDataInitializeEventOnRelogin; //重登切换账号触发
|
| | | public static event Action beforePlayerDataInitializeEventOnReconnect; //断线重连触发
|
| | | public static event Action afterPlayerDataInitializeEvent;
|
| | | public static event Action switchAccountEvent;
|
| | | public static bool isAfterPlayerDataInitialize = false; //可区分断线重连还是完全重登; 切到登录场景会重置为false,故可判断断线重连
|
| | |
| | | beforePlayerDataInitializeEvent();
|
| | | }
|
| | |
|
| | | if (isAfterPlayerDataInitialize)
|
| | | { |
| | | beforePlayerDataInitializeEventOnReconnect?.Invoke();
|
| | | }
|
| | | else
|
| | | {
|
| | | beforePlayerDataInitializeEventOnRelogin?.Invoke();
|
| | | }
|
| | |
|
| | |
|
| | | try
|
| | | {
|
| | | RedpointCenter.Instance.ResetAllRedpointState();
|
| | |
| | | managers.Add(BlessLVManager.Instance);
|
| | | managers.Add(AutoFightModel.Instance);
|
| | | managers.Add(MainLevelManager.Instance);
|
| | | managers.Add(BattleSettlementManager.Instance);
|
| | |
|
| | | foreach (var manager in managers)
|
| | | {
|
| | |
| | | using System; |
| | | using LitJson; |
| | | using DG.Tweening; |
| | | using Codice.Client.BaseCommands; |
| | | |
| | | |
| | | public class BattleField |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | //各个战场没有场景概念,且可以共存,同时存在战场和结算的情况 |
| | | //内部结算需要处理的逻辑,不含UI |
| | | protected virtual void OnSettlement(JsonData turnFightStateData) |
| | | { |
| | | |
| | | } |
| | | |
| | | //UI结算后回调需要处理的逻辑 |
| | | public virtual void WhaleFall() |
| | | { |
| | | Destroy(); |
| | | } |
| | | |
| | | public virtual void OnBattleEnd(JsonData turnFightStateData) |
| | | { |
| | | BattleEndAction battleEndAction = new BattleEndAction(this, turnFightStateData, () => |
| | | { |
| | | BattleDebug.LogError(turnFightStateData.ToJson()); |
| | | // 这里可以添加战斗结束的具体逻辑 |
| | | // 战场自身的结束逻辑,不含结算等外部逻辑 |
| | | OnSettlement(turnFightStateData); |
| | | |
| | | int winFaction = (int)turnFightStateData["winFaction"]; |
| | |
| | | |
| | | IsBattleFinish = true; |
| | | |
| | | |
| | | //提供外部 胜利等奖励显示 |
| | | EventBroadcast.Instance.Broadcast<string, JsonData>(EventName.BATTLE_END, guid, turnFightStateData); |
| | | |
| | | |
| | | //提供外部 胜利等奖励显示 |
| | | if (guid != "") |
| | | EventBroadcast.Instance.Broadcast<string, JsonData>(EventName.BATTLE_END, guid, turnFightStateData); |
| | | |
| | | |
| | | }); |
| | | recordPlayer.PlayRecord(battleEndAction); |
| | | // 处理战斗结束逻辑 |
| | | // IsBattleFinish = true; |
| | | // 结算逻辑 |
| | | |
| | | // { |
| | | // "itemInfo": [], |
| | | // "winFaction": 1,//获胜阵营: 一般为1或者2,当玩家发起的战斗时,如果获胜阵营不等于1代表玩家失败了 |
| | | // "statInfo": { |
| | | // "1": { |
| | | // "1": { |
| | | // "5": { |
| | | // "NPCID": 0, |
| | | // "DefHurt": 633, |
| | | // "CureHP": 0, |
| | | // "AtkHurt": 169247, |
| | | // "ObjID": 1, |
| | | // "HeroID": 510006 |
| | | // } |
| | | // } |
| | | // }, |
| | | // "2": { |
| | | // "1": { |
| | | // "2": { |
| | | // "NPCID": 10101001, |
| | | // "DefHurt": 169246, |
| | | // "CureHP": 143096, |
| | | // "AtkHurt": 999952, |
| | | // "ObjID": 2, |
| | | // "HeroID": 0 |
| | | // }, |
| | | // "4": { |
| | | // "NPCID": 10101001, |
| | | // "DefHurt": 0, |
| | | // "CureHP": 0, |
| | | // "AtkHurt": 0, |
| | | // "ObjID": 3, |
| | | // "HeroID": 0 |
| | | // }, |
| | | // "6": { |
| | | // "NPCID": 10101001, |
| | | // "DefHurt": 1, |
| | | // "CureHP": 0, |
| | | // "AtkHurt": 0, |
| | | // "ObjID": 4, |
| | | // "HeroID": 0 |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | public virtual void HaveRest() |
| | |
| | | protected override void OnSettlement(JsonData turnFightStateData) |
| | | { |
| | | base.OnSettlement(turnFightStateData); |
| | | |
| | | |
| | | } |
| | | |
| | | private void WhaleFall() |
| | | public override void WhaleFall() |
| | | { |
| | | // YYL TODO 应该需要一个结算界面来做这些内容 |
| | | UIManager.Instance.CloseWindow<FullScreenBattleWin>(); |
| | | AutoFightModel.Instance.isPause = false; |
| | | Destroy(); |
| | | } |
| | | |
| | | public override void OnBattleEnd(JsonData turnFightStateData) |
| | | { |
| | | BattleEndAction battleEndAction = new BattleEndAction(this, turnFightStateData, () => |
| | | { |
| | | BattleDebug.LogError(turnFightStateData.ToJson()); |
| | | // 这里可以添加战斗结束的具体逻辑 |
| | | OnSettlement(turnFightStateData); |
| | | |
| | | int winFaction = (int)turnFightStateData["winFaction"]; |
| | | //获胜阵营: 一般为1或者2,当玩家发起的战斗时,如果获胜阵营不等于1代表玩家失败了 |
| | | |
| | | if (winFaction == 1) |
| | | { |
| | | Debug.LogError(guid + " : 战斗胜利"); |
| | | // 战斗胜利 |
| | | } |
| | | else |
| | | { |
| | | // 战斗失败 |
| | | Debug.LogError(guid + " : 战斗失败"); |
| | | } |
| | | |
| | | IsBattleFinish = true; |
| | | |
| | | |
| | | //提供外部 胜利等奖励显示 |
| | | EventBroadcast.Instance.Broadcast<string, JsonData>(EventName.BATTLE_END, guid, turnFightStateData); |
| | | WhaleFall(); |
| | | |
| | | }); |
| | | recordPlayer.PlayRecord(battleEndAction); |
| | | } |
| | | |
| | | |
| | | public override void HaveRest() |
| | | { |
| | |
| | | public override void Init() |
| | | { |
| | | DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent += OnEquipResult; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerDataInitialize; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += BeforePlayerDataInitialize; |
| | | EventBroadcast.Instance.AddListener<string, BattleDrops, Action>(EventName.BATTLE_DROP_ITEMS, OnDropEvent); |
| | | ParseConfig(); |
| | | } |
| | |
| | | public override void Release() |
| | | { |
| | | DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent -= OnEquipResult; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerDataInitialize; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= BeforePlayerDataInitialize; |
| | | EventBroadcast.Instance.RemoveListener<string, BattleDrops, Action>(EventName.BATTLE_DROP_ITEMS, OnDropEvent); |
| | | } |
| | | |
| | |
| | | |
| | | void BeforePlayerDataInitialize() |
| | | { |
| | | //断线重连不处理 |
| | | if (DTC0102_tagCDBPlayer.isAfterPlayerDataInitialize) |
| | | return; |
| | | selectFloorEquip = null; |
| | | waitEquipOP.Clear(); |
| | | lastShowEquipIndex = -1; |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 0df38c52ea781994ea7170717d52ad96 |
| | | folderAsset: yes |
| | | DefaultImporter: |
| | | externalObjects: {} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using LitJson; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | //战场结算界面,存在多个的情况 |
| | | public class BattleFailWin : UIBase |
| | | { |
| | | |
| | | [SerializeField] Button tipEquipBtn; |
| | | [SerializeField] Button tipHeroPosBtn; |
| | | |
| | | string guid; |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | tipEquipBtn.AddListener(() => |
| | | { |
| | | CloseWindow(); |
| | | }); |
| | | |
| | | tipHeroPosBtn.AddListener(() => |
| | | { |
| | | CloseWindow(); |
| | | UIManager.Instance.OpenWindow<HeroPosWin>(); |
| | | }); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | guid = BattleSettlementManager.Instance.notifyGuid; |
| | | } |
| | | |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | BattleSettlementManager.Instance.WinShowOver(guid); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 981f35a8769fa4c4f8910ae337288f72 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | |
| | | |
| | | using System.Collections.Generic; |
| | | using LitJson; |
| | | |
| | | public partial class BattleSettlementManager : GameSystemManager<BattleSettlementManager> |
| | | { |
| | | //结算后需清除 |
| | | Dictionary<string, JsonData> battleSettlementDic = new Dictionary<string, JsonData>(); |
| | | public string notifyGuid = string.Empty; |
| | | |
| | | public override void Init() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitialize; |
| | | EventBroadcast.Instance.AddListener<string, JsonData>(EventName.BATTLE_END, OnSettlement); |
| | | |
| | | } |
| | | |
| | | public override void Release() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= OnBeforePlayerDataInitialize; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | 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) |
| | | { |
| | | battleSettlementDic[_guid] = _data; |
| | | notifyGuid = _guid; |
| | | if (_data.ContainsKey("winFaction")) |
| | | { |
| | | var result = (int)_data["winFaction"]; |
| | | if (result == 1) |
| | | { |
| | | UIManager.Instance.OpenWindow<BattleVictoryWin>(); |
| | | } |
| | | else |
| | | { |
| | | UIManager.Instance.OpenWindow<BattleFailWin>(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void WinShowOver(string _guid) |
| | | { |
| | | battleSettlementDic.Remove(_guid); |
| | | var battle = BattleManager.Instance.GetBattleField(_guid); |
| | | if (battle != null) |
| | | battle.WhaleFall(); |
| | | } |
| | | |
| | | public JsonData GetBattleSettlement(string _guid) |
| | | { |
| | | if (!battleSettlementDic.ContainsKey(_guid)) |
| | | { |
| | | return null; |
| | | } |
| | | return battleSettlementDic[_guid]; |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: ebb1b354e336d354eb5efe98c94596ab |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Cysharp.Threading.Tasks; |
| | | using LitJson; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | // 【战斗结算】 |
| | | // 当收到 // B4 20 回合制战斗状态 #tagMCTurnFightState State 为 4-结算,时,代表本场战斗已结束并结算 |
| | | // char Msg[Len]; //size = Len Msg信息为 |
| | | // {"winFaction":获胜阵营, "statInfo":统计信息, “itemInfo“:[奖励物品信息列表]} |
| | | // 获胜阵营: 一般为1或者2,当玩家发起的战斗时,如果获胜阵营不等于1代表玩家失败了 |
| | | // 统计信息: 格式 {"阵营编号":{"阵容编号":{"站位编号":{该武将统计信息字典}, ...}, ...}, ...} |
| | | // 阵营编号: 一般时1或2, 对应 B424 同步下去的阵营 |
| | | // 阵容编号: 隶属于某个阵营的阵容编号,一般是从1开始,一个阵营在多V多的情况下可以有多个阵容 |
| | | // 站位编号: 某个阵容中武将战斗实例的站位编号,一般从1开始,代表站位1 |
| | | // 武将统计信息字典: 格式: {"ObjID":实例ID, "HeroID":玩家阵容武将ID, "NPCID":npc表ID, "AtkHurt":总输出, "DefHurt":总承伤, "CureHP":总治疗} |
| | | |
| | | // 处理战斗结束逻辑 |
| | | // IsBattleFinish = true; |
| | | // 结算逻辑 |
| | | |
| | | // { |
| | | // "itemInfo": [], |
| | | // "winFaction": 1,//获胜阵营: 一般为1或者2,当玩家发起的战斗时,如果获胜阵营不等于1代表玩家失败了 |
| | | // "statInfo": { |
| | | // "1": { |
| | | // "1": { |
| | | // "5": { |
| | | // "NPCID": 0, |
| | | // "DefHurt": 633, |
| | | // "CureHP": 0, |
| | | // "AtkHurt": 169247, |
| | | // "ObjID": 1, |
| | | // "HeroID": 510006 |
| | | // } |
| | | // } |
| | | // }, |
| | | // "2": { |
| | | // "1": { |
| | | // "2": { |
| | | // "NPCID": 10101001, |
| | | // "DefHurt": 169246, |
| | | // "CureHP": 143096, |
| | | // "AtkHurt": 999952, |
| | | // "ObjID": 2, |
| | | // "HeroID": 0 |
| | | // }, |
| | | // "4": { |
| | | // "NPCID": 10101001, |
| | | // "DefHurt": 0, |
| | | // "CureHP": 0, |
| | | // "AtkHurt": 0, |
| | | // "ObjID": 3, |
| | | // "HeroID": 0 |
| | | // }, |
| | | // "6": { |
| | | // "NPCID": 10101001, |
| | | // "DefHurt": 1, |
| | | // "CureHP": 0, |
| | | // "AtkHurt": 0, |
| | | // "ObjID": 4, |
| | | // "HeroID": 0 |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | //"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 class BattleVictoryWin : UIBase |
| | | { |
| | | |
| | | [SerializeField] ScrollerController scroller; |
| | | |
| | | string guid; |
| | | protected override void OnPreOpen() |
| | | { |
| | | guid = BattleSettlementManager.Instance.notifyGuid; |
| | | scroller.OnRefreshCell += OnRefreshCell; |
| | | CreateScroller(); |
| | | } |
| | | |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | scroller.OnRefreshCell -= OnRefreshCell; |
| | | BattleSettlementManager.Instance.WinShowOver(guid); |
| | | } |
| | | |
| | | List<Item> showItems = new List<Item>(); |
| | | void CreateScroller() |
| | | { |
| | | var jsonData = BattleSettlementManager.Instance.GetBattleSettlement(guid); |
| | | if (jsonData == null) |
| | | { |
| | | DelayCloseWindow().Forget(); |
| | | return; |
| | | } |
| | | showItems.Clear(); |
| | | scroller.Refresh(); |
| | | |
| | | if (!jsonData.ContainsKey("itemInfo")) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var resultStr = jsonData["itemInfo"]; |
| | | for (int i = 0; i < resultStr.Count; i++) |
| | | { |
| | | showItems.Add(new Item((int)resultStr[i]["ItemID"], (long)resultStr[i]["Count"])); |
| | | } |
| | | |
| | | showItems.Sort(SortItem); |
| | | for (int i = 0; i < showItems.Count; i++) |
| | | { |
| | | scroller.AddCell(ScrollerDataType.Header, i); |
| | | } |
| | | scroller.Restart(); |
| | | } |
| | | |
| | | |
| | | |
| | | int SortItem(Item itemA, Item itemB) |
| | | { |
| | | var itemConfigA = ItemConfig.Get(itemA.id); |
| | | var itemConfigB = ItemConfig.Get(itemB.id); |
| | | return itemConfigB.ItemColor - itemConfigA.ItemColor; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | void OnRefreshCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell as SettlementAwardCell; |
| | | var item = showItems[cell.index]; |
| | | _cell?.Display(item.id, item.countEx); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 07f0dc21f424e6b4aa2c451e8b77a895 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
New file |
| | |
| | | using UnityEngine;
|
| | |
|
| | | public class SettlementAwardCell : CellView
|
| | | {
|
| | | [SerializeField] ItemCell itemCell;
|
| | | [SerializeField] TextEx txtItemName;
|
| | |
|
| | | public void Display(int itemID, long count)
|
| | | {
|
| | |
|
| | | itemCell.Init(new ItemCellModel(itemID, false, count));
|
| | | txtItemName.text = ItemConfig.Get(itemID).ItemName;
|
| | | itemCell.button.SetListener(() =>
|
| | | {
|
| | | ItemTipUtility.Show(itemID);
|
| | | });
|
| | | }
|
| | | }
|
New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: eb5f5e472d8ba234290fd09921b0ec86 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |
| | |
| | | UIManager.Instance.CloseWindow(this, false); |
| | | } |
| | | |
| | | public async UniTask DelayCloseWindow(int delayTime = 30) |
| | | { |
| | | await UniTask.Delay(delayTime); |
| | | CloseWindow(); |
| | | } |
| | | |
| | | // 刷新UI |
| | | public virtual void Refresh() |
| | | { |