fix: fix bug show else player.
This commit is contained in:
Binary file not shown.
@@ -2,8 +2,10 @@
|
||||
using BrewMonster.Network;
|
||||
using CSNetwork;
|
||||
using CSNetwork.GPDataType;
|
||||
using PerfectWorld.Scripts.Player;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -15,6 +17,9 @@ namespace PerfectWorld.Scripts.Managers
|
||||
{
|
||||
public class EC_ManPlayer : IMsgHandler
|
||||
{
|
||||
Dictionary<int, int> m_UkPlayerTab = new Dictionary<int, int>();
|
||||
Dictionary<int, EC_ElsePlayer> m_PlayerTab = new Dictionary<int, EC_ElsePlayer>();
|
||||
private readonly object m_csPlayerTab = new object();
|
||||
public int HandlerId => (int)MANAGER_INDEX.MAN_PLAYER;
|
||||
public bool ProcessMessage(ECMSG Msg)
|
||||
{
|
||||
@@ -56,7 +61,8 @@ namespace PerfectWorld.Scripts.Managers
|
||||
byteArray[i] = data[i];
|
||||
}
|
||||
int cid = BitConverter.ToInt32(byteArray);
|
||||
switch (Convert.ToInt32(Msg.dwParam2))
|
||||
int commandID = Convert.ToInt32(Msg.dwParam2);
|
||||
switch (commandID)
|
||||
{
|
||||
case CommandID.PLAYER_INFO_1:
|
||||
case CommandID.PLAYER_ENTER_WORLD:
|
||||
@@ -64,6 +70,8 @@ namespace PerfectWorld.Scripts.Managers
|
||||
{
|
||||
if (cid != iHostID)
|
||||
{
|
||||
info_player_1 info_Player_1 = GPDataTypeHelper.FromBytes<info_player_1>((byte[])Msg.dwParam1);
|
||||
ElsePlayerEnter(info_Player_1, commandID);
|
||||
GameController.Instance.Log("ElsePlayer has join");
|
||||
}
|
||||
break;
|
||||
@@ -118,58 +126,110 @@ namespace PerfectWorld.Scripts.Managers
|
||||
return true;
|
||||
}
|
||||
|
||||
public EC_ElsePlayer ElsePlayerEnter()
|
||||
public EC_ElsePlayer ElsePlayerEnter(info_player_1 info, int iCmd)
|
||||
{
|
||||
|
||||
return null;
|
||||
// If this player's id is in unknown table, remove it because this player
|
||||
// won't be unknown anymore
|
||||
if (m_UkPlayerTab.TryGetValue(info.cid, out int value))
|
||||
{
|
||||
if (value != 0) // Pair.second != 0
|
||||
{
|
||||
m_UkPlayerTab.Remove(info.cid);
|
||||
}
|
||||
}
|
||||
|
||||
int iAppearFlag = (iCmd == (int)CommandID.PLAYER_ENTER_WORLD) ?
|
||||
(int)PlayerAppearFlag.APPEAR_ENTERWORLD : (int)PlayerAppearFlag.APPEAR_RUNINTOVIEW;
|
||||
|
||||
// Has player been in active player table ?
|
||||
EC_ElsePlayer pPlayer = GetElsePlayer(info.cid);
|
||||
if (pPlayer)
|
||||
{
|
||||
// This player has existed in player table, call special initial function
|
||||
// TODO: fix after pPlayer init
|
||||
//pPlayer.Init(Info, iAppearFlag, true);
|
||||
return pPlayer;
|
||||
}
|
||||
|
||||
// Create a new player
|
||||
if (!(pPlayer = CreateElsePlayer(info, iAppearFlag)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private EC_ElsePlayer CreateElsePlayer(info_player_1 info, int iAppearFlag)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private EC_ElsePlayer GetElsePlayer(int cid, long dwBornStamp = 0)
|
||||
{
|
||||
lock (m_csPlayerTab)
|
||||
{
|
||||
if (!m_PlayerTab.TryGetValue(cid, out var player))
|
||||
return null;
|
||||
if (dwBornStamp != 0)
|
||||
{
|
||||
//TO DO: fix after GetBornStamp() is create in code
|
||||
//if (player.GetBornStamp() != dwBornStamp)
|
||||
return null;
|
||||
}
|
||||
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
private EC_ElsePlayer SeekOutElsePlayer(int cid)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private cmd_object_move ConvertToStruct(byte[] bytes)
|
||||
{
|
||||
if (bytes.Length < Marshal.SizeOf<cmd_object_move>())
|
||||
{
|
||||
return default;
|
||||
}
|
||||
//private cmd_object_move ConvertToStruct(byte[] bytes)
|
||||
//{
|
||||
// if (bytes.Length < Marshal.SizeOf<cmd_object_move>())
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
|
||||
cmd_object_move result = new cmd_object_move();
|
||||
int preLenghtData = 0;
|
||||
int lenghtDataType = Marshal.SizeOf<int>();
|
||||
byte[] arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
result.id = BitConverter.ToInt32(arrByteData);
|
||||
// cmd_object_move result = new cmd_object_move();
|
||||
// int preLenghtData = 0;
|
||||
// int lenghtDataType = Marshal.SizeOf<int>();
|
||||
// byte[] arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
// result.id = BitConverter.ToInt32(arrByteData);
|
||||
|
||||
preLenghtData += lenghtDataType;
|
||||
lenghtDataType = Marshal.SizeOf<float>();
|
||||
arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
result.dest_X = BitConverter.ToSingle(arrByteData);
|
||||
// preLenghtData += lenghtDataType;
|
||||
// lenghtDataType = Marshal.SizeOf<float>();
|
||||
// arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
// result.dest_X = BitConverter.ToSingle(arrByteData);
|
||||
|
||||
preLenghtData += lenghtDataType;
|
||||
lenghtDataType = Marshal.SizeOf<float>();
|
||||
arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
result.dest_Y = BitConverter.ToSingle(arrByteData);
|
||||
// preLenghtData += lenghtDataType;
|
||||
// lenghtDataType = Marshal.SizeOf<float>();
|
||||
// arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
// result.dest_Y = BitConverter.ToSingle(arrByteData);
|
||||
|
||||
preLenghtData += lenghtDataType;
|
||||
lenghtDataType = Marshal.SizeOf<float>();
|
||||
arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
result.dest_Z = BitConverter.ToSingle(arrByteData);
|
||||
// preLenghtData += lenghtDataType;
|
||||
// lenghtDataType = Marshal.SizeOf<float>();
|
||||
// arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
// result.dest_Z = BitConverter.ToSingle(arrByteData);
|
||||
|
||||
preLenghtData += lenghtDataType;
|
||||
lenghtDataType = Marshal.SizeOf<ushort>();
|
||||
arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
result.use_time = BitConverter.ToUInt16(arrByteData);
|
||||
// preLenghtData += lenghtDataType;
|
||||
// lenghtDataType = Marshal.SizeOf<ushort>();
|
||||
// arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
// result.use_time = BitConverter.ToUInt16(arrByteData);
|
||||
|
||||
preLenghtData += lenghtDataType;
|
||||
lenghtDataType = Marshal.SizeOf<short>();
|
||||
arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
result.sSpeed = BitConverter.ToInt16(arrByteData);
|
||||
// preLenghtData += lenghtDataType;
|
||||
// lenghtDataType = Marshal.SizeOf<short>();
|
||||
// arrByteData = GetBytes(bytes, lenghtDataType, preLenghtData);
|
||||
// result.sSpeed = BitConverter.ToInt16(arrByteData);
|
||||
|
||||
preLenghtData += lenghtDataType;
|
||||
result.move_mode = bytes[preLenghtData + 1];
|
||||
return result;
|
||||
}
|
||||
// preLenghtData += lenghtDataType;
|
||||
// result.move_mode = bytes[preLenghtData + 1];
|
||||
// return result;
|
||||
//}
|
||||
|
||||
private byte[] GetBytes(byte[] bytes, int length, int index)
|
||||
{
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class NPCManager : MonoBehaviour
|
||||
namespace PerfectWorld.Scripts.Managers
|
||||
{
|
||||
private static NPCManager instance;
|
||||
|
||||
[SerializeField] private GameObject modelPlayerCharacter;
|
||||
|
||||
public static NPCManager Instance
|
||||
public class NPCManager : MonoBehaviour
|
||||
{
|
||||
get
|
||||
private static NPCManager instance;
|
||||
|
||||
[SerializeField] private GameObject modelPlayerCharacter;
|
||||
|
||||
public static NPCManager Instance
|
||||
{
|
||||
if (instance == null)
|
||||
get
|
||||
{
|
||||
instance = FindAnyObjectByType<NPCManager>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
if (instance == null)
|
||||
{
|
||||
instance = FindAnyObjectByType<NPCManager>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject GetModelPlayer()
|
||||
{
|
||||
var player = Instantiate(modelPlayerCharacter);
|
||||
player.SetActive(true);
|
||||
return player;
|
||||
public GameObject GetModelPlayer()
|
||||
{
|
||||
var player = Instantiate(modelPlayerCharacter);
|
||||
player.SetActive(true);
|
||||
return player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class EC_ElsePlayer : MonoBehaviour
|
||||
namespace PerfectWorld.Scripts.Player
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
public class EC_ElsePlayer : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
// Player appear flag
|
||||
public enum PlayerAppearFlag
|
||||
{
|
||||
|
||||
}
|
||||
APPEAR_DISAPPEAR = -1, // Player disappear
|
||||
APPEAR_ENTERWORLD = 0, // Player join world
|
||||
APPEAR_RUNINTOVIEW, // Player run into view
|
||||
APPEAR_GHOST, // Player is in ghost state, in player list but not active
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BrewMonster.UI;
|
||||
using CSNetwork.Protocols.RPCData;
|
||||
using PerfectWorld.Scripts.Managers;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using CSNetwork.GPDataType;
|
||||
using CSNetwork.Protocols;
|
||||
using CSNetwork.Protocols.RPCData;
|
||||
using PerfectWorld.Scripts.Managers;
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UnityEditor.SearchService;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
@@ -4,60 +4,63 @@ using System.Data;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameController : MonoBehaviour
|
||||
namespace PerfectWorld.Scripts.Managers
|
||||
{
|
||||
private static GameController instance;
|
||||
public class GameController : MonoBehaviour
|
||||
{
|
||||
private static GameController instance;
|
||||
|
||||
[SerializeField] private CharacterCtrl characterPrefab;
|
||||
//[SerializeField] private Transform ground;
|
||||
[SerializeField] private CharacterCtrl characterPrefab;
|
||||
//[SerializeField] private Transform ground;
|
||||
|
||||
Camera camera;
|
||||
Camera camera;
|
||||
|
||||
public static GameController Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
public static GameController Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
instance = FindAnyObjectByType<GameController>();
|
||||
if (instance == null)
|
||||
{
|
||||
instance = FindAnyObjectByType<GameController>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if(instance == null)
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
if(instance == null)
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
camera = Camera.main;
|
||||
}
|
||||
|
||||
public void Log(string s)
|
||||
{
|
||||
Debug.LogError(s);
|
||||
}
|
||||
|
||||
public void InitCharacter(cmd_self_info_1 info)
|
||||
{
|
||||
if(characterPrefab == null)
|
||||
private void Start()
|
||||
{
|
||||
Debug.LogError("null prefab");
|
||||
return;
|
||||
camera = Camera.main;
|
||||
}
|
||||
|
||||
public void Log(string s)
|
||||
{
|
||||
Debug.LogError(s);
|
||||
}
|
||||
|
||||
public void InitCharacter(cmd_self_info_1 info)
|
||||
{
|
||||
if(characterPrefab == null)
|
||||
{
|
||||
Debug.LogError("null prefab");
|
||||
return;
|
||||
}
|
||||
CharacterCtrl character = Instantiate(characterPrefab, transform);
|
||||
character.InitCharacter(info);
|
||||
//Vector3 pos = new Vector3(info.pos.x, info.pos.y, info.pos.z);
|
||||
//Vector3 posCam = pos;
|
||||
//posCam.z -= 10f;
|
||||
//camera.transform.position = posCam;
|
||||
//Vector3 posGround = pos;
|
||||
//posGround.y -= 2f;
|
||||
//ground.transform.position = posGround;
|
||||
}
|
||||
CharacterCtrl character = Instantiate(characterPrefab, transform);
|
||||
character.InitCharacter(info);
|
||||
//Vector3 pos = new Vector3(info.pos.x, info.pos.y, info.pos.z);
|
||||
//Vector3 posCam = pos;
|
||||
//posCam.z -= 10f;
|
||||
//camera.transform.position = posCam;
|
||||
//Vector3 posGround = pos;
|
||||
//posGround.y -= 2f;
|
||||
//ground.transform.position = posGround;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user