using System.Collections; using System.Collections.Generic; using Framework; using Gameplay; using Gameplay.Level; using Gameplay.Net; using Gameplay.SubSystems; using NLDPB; using PhxhSDK; using UnityEngine; public class PVPEnemyInfo { public uint actorID { get; private set; } public string nickName { get; private set; } public int score { get; private set; } public int order { get; private set; } public PVPDefenderData pvpDefenderData { get; private set; } public PVPEnemyInfo(MSG_PvpActor pvpActor) { actorID = pvpActor.ActorId; nickName = pvpActor.Nickname; score = (int)pvpActor.Socre; order = (int)pvpActor.Order; MSG_PvpDefenceData defenceData = MSG_PvpDefenceData.Parser.ParseFrom(pvpActor.DefenceData); pvpDefenderData = new PVPDefenderData(defenceData); } } public partial class PVPManager : Singlenton, IInitable { private LevelInfo _pvpLevelInfo; public LevelInfo PVPLevelInfo => _pvpLevelInfo; private List _enemies = new(); //当前玩家的分数 public int score { get; private set; } //当前玩家的排名 public int order { get; private set; } //当前备选敌人 public IEnumerable Enemies => _enemies; public void Init() { EventManager.Instance.Register(EventManager.EventName.OnGetPVPInformationFromServer, OnGetPVPInformation); EventManager.Instance.Register(EventManager.EventName.AllConfigLoad, OnAllConfigLoad); EventManager.Instance.Register(EventManager.EventName.OnGetPVPRankInfo, OnGetPVPRankInfo); InitFight(); } public void Release() { EventManager.Instance.Unregister(EventManager.EventName.OnGetPVPInformationFromServer, OnGetPVPInformation); EventManager.Instance.Unregister(EventManager.EventName.AllConfigLoad, OnAllConfigLoad); EventManager.Instance.Unregister(EventManager.EventName.OnGetPVPRankInfo, OnGetPVPRankInfo); ReleaseFight(); } private void OnAllConfigLoad() { var pvpLevelID = TableManager.Instance.Tables.GlobalConfig.PVPLevelID; _pvpLevelInfo = LevelManager.Instance.GetLevelInfoByID(pvpLevelID); if (_pvpLevelInfo == null) { DebugUtil.LogError($"找不到关卡配置,id:{pvpLevelID}"); return; } } #region API public void GetPVPInformation() { NetHelper.GetPVPInformation(); } public void GetPVPRankInfo(int page) { NetHelper.GetPvpOrderList((uint)page); } #endregion private void OnGetPVPInformation(G_Clt_PvpInformation information) { score = (int)information.Score; order = (int)information.Order; _enemies.Clear(); foreach (var actor in information.Rivals) { DebugUtil.LogError($"construct PVP Enemy, actor id:{actor.ActorId}"); PVPEnemyInfo enemyInfo = new(actor); _enemies.Add(enemyInfo); } EventManager.Instance.Send(EventManager.EventName.OnGetPVPInformation); } private void OnGetPVPRankInfo(Mg_Clt_PvpOrderListData pb) { } }