100 lines
2.7 KiB
C#
100 lines
2.7 KiB
C#
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<PVPManager>, IInitable
|
|
{
|
|
private LevelInfo _pvpLevelInfo;
|
|
|
|
public LevelInfo PVPLevelInfo => _pvpLevelInfo;
|
|
|
|
private List<PVPEnemyInfo> _enemies = new();
|
|
|
|
//当前玩家的分数
|
|
public int score { get; private set; }
|
|
|
|
//当前玩家的排名
|
|
public int order { get; private set; }
|
|
|
|
//当前备选敌人
|
|
public IEnumerable<PVPEnemyInfo> Enemies => _enemies;
|
|
|
|
public void Init()
|
|
{
|
|
EventManager.Instance.Register<G_Clt_PvpInformation>(EventManager.EventName.OnGetPVPInformationFromServer,
|
|
OnGetPVPInformation);
|
|
EventManager.Instance.Register(EventManager.EventName.AllConfigLoad, OnAllConfigLoad);
|
|
InitFight();
|
|
}
|
|
|
|
public void Release()
|
|
{
|
|
EventManager.Instance.Register<G_Clt_PvpInformation>(EventManager.EventName.OnGetPVPInformationFromServer,
|
|
OnGetPVPInformation);
|
|
EventManager.Instance.Unregister(EventManager.EventName.AllConfigLoad, OnAllConfigLoad);
|
|
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();
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void OnGetPVPInformation(G_Clt_PvpInformation information)
|
|
{
|
|
score = (int)information.Score;
|
|
order = (int)information.Order;
|
|
_enemies.Clear();
|
|
foreach (var actor in information.Rivals)
|
|
{
|
|
PVPEnemyInfo enemyInfo = new(actor);
|
|
_enemies.Add(enemyInfo);
|
|
}
|
|
EventManager.Instance.Send(EventManager.EventName.OnGetPVPInformation);
|
|
}
|
|
} |