This commit is contained in:
Le Duc Anh
2025-09-08 16:29:40 +07:00
9 changed files with 255 additions and 76 deletions
Binary file not shown.
@@ -1,25 +1,64 @@
using BrewMonster;
using CSNetwork;
using CSNetwork;
using CSNetwork.GPDataType;
using System;
using System.Runtime.InteropServices;
namespace PerfectWorld.Scripts.Managers
{
namespace BrewMonster.Managers
{
public class EC_ManPlayer : IMsgHandler, IAutoInitialize
public class EC_ManPlayer : IMsgHandler
{
public void Initialize()
{
EC_ManMessage.RegisterHandler(this); // add to the message handler list
}
public int HandlerId => MANAGER_INDEX.MAN_PLAYER;
public int HandlerId => (int)MANAGER_INDEX.MAN_PLAYER;
public bool ProcessMessage(ECMSG Msg)
{
if (Msg.iSubID == 0)
{
}
else if (Msg.iSubID < 0)
{
switch ((int)Msg.dwMsg)
{
case int value when value == EC_MsgDef.MSG_PM_PLAYERINFO:
{
OnMsgPlayerInfo(Msg);
break;
}
}
}
else
{
}
return true;
}
public void OnMsgPlayerInfo(ECMSG Msg)
{
int iHostID = (int)Msg.dwParam3;
int lenghtByte = Marshal.SizeOf<int>();
byte[] byteArray = new byte[lenghtByte];
byte[] data = (byte[])Msg.dwParam1;
for (int i = 0; i < lenghtByte; i++)
{
byteArray[i] = data[i];
}
int cid = BitConverter.ToInt32(byteArray);
switch (Convert.ToInt32(Msg.dwParam2))
{
case CommandID.PLAYER_INFO_1:
case CommandID.PLAYER_ENTER_WORLD:
case CommandID.PLAYER_ENTER_SLICE:
{
if (cid != iHostID)
{
GameController.Instance.Log("ElsePlayer has join");
}
break;
}
}
}
}
}
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8511a50fc48e2cf4bbd9a6bf91442d50
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,16 @@
using UnityEngine;
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()
{
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0feb504dc7975e84dab03230dd3277a8
+44 -42
View File
@@ -11,9 +11,9 @@ GameObject:
- component: {fileID: 3412441340983701579}
- component: {fileID: 4963688309523522575}
- component: {fileID: 8371471143466595520}
- component: {fileID: 8750866330409519469}
- component: {fileID: 2579337816850146009}
- component: {fileID: 7639115115142978997}
- component: {fileID: 8960181021787475507}
- component: {fileID: 1591670752219322405}
m_Layer: 0
m_Name: Character
m_TagString: Untagged
@@ -90,8 +90,26 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!136 &8750866330409519469
CapsuleCollider:
--- !u!114 &7639115115142978997
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2013293210786114121}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c0525de198450e14f9f6ad854b95ec99, type: 3}
m_Name:
m_EditorClassIdentifier:
txtName: {fileID: 0}
controller: {fileID: 8960181021787475507}
animator: {fileID: 1591670752219322405}
joystick: {fileID: 0}
btnJump: {fileID: 0}
btnRun: {fileID: 0}
--- !u!143 &8960181021787475507
CharacterController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
@@ -105,54 +123,38 @@ CapsuleCollider:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
serializedVersion: 3
m_Height: 2
m_Direction: 1
m_Radius: 0.5
m_SlopeLimit: 45
m_StepOffset: 0.3
m_SkinWidth: 0.08
m_MinMoveDistance: 0.001
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &2579337816850146009
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2013293210786114121}
serializedVersion: 4
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_CenterOfMass: {x: 0, y: 0, z: 0}
m_InertiaTensor: {x: 1, y: 1, z: 1}
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_ImplicitCom: 1
m_ImplicitTensor: 1
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &7639115115142978997
MonoBehaviour:
--- !u!95 &1591670752219322405
Animator:
serializedVersion: 7
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2013293210786114121}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dd1a1ec750c69604fafb72e91fd8e7b4, type: 3}
m_Name:
m_EditorClassIdentifier:
txtName: {fileID: 2889286251427577339}
m_Avatar: {fileID: 0}
m_Controller: {fileID: 0}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_AnimatePhysics: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!1 &5363758751412688596
GameObject:
m_ObjectHideFlags: 0
+83
View File
@@ -2966,6 +2966,7 @@ GameObject:
m_Component:
- component: {fileID: 1018020456}
- component: {fileID: 1018020457}
- component: {fileID: 1018020458}
m_Layer: 0
m_Name: Game
m_TagString: Untagged
@@ -2987,6 +2988,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 626090657}
- {fileID: 2034856886}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1018020457
@@ -3003,6 +3005,18 @@ MonoBehaviour:
m_EditorClassIdentifier:
characterPrefab: {fileID: 7639115115142978997, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
ground: {fileID: 626090657}
--- !u!114 &1018020458
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1018020455}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 96073aa22df0eda49b4d56c0580aa806, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1137567878
GameObject:
m_ObjectHideFlags: 0
@@ -3786,6 +3800,75 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 98}
m_SizeDelta: {x: 0, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1001 &2034856885
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1018020456}
m_Modifications:
- target: {fileID: 2013293210786114121, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_Name
value: Character
objectReference: {fileID: 0}
- target: {fileID: 2013293210786114121, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalPosition.y
value: 2.73
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 5363758751412688596, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
insertIndex: -1
addedObject: {fileID: 0}
m_SourcePrefab: {fileID: 100100000, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
--- !u!4 &2034856886 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3412441340983701579, guid: 633f7b514d73bdb459636883927e2b1b, type: 3}
m_PrefabInstance: {fileID: 2034856885}
m_PrefabAsset: {fileID: 0}
--- !u!1 &2082488502
GameObject:
m_ObjectHideFlags: 0
+23 -23
View File
@@ -93,32 +93,32 @@ public class CharacterCtrl : MonoBehaviour
playerVelocity.y = 0f;
}
float x = joystick.Horizontal;
float z = joystick.Vertical;
//float x = joystick.Horizontal;
//float z = joystick.Vertical;
Vector3 move = new Vector3(x, 0, z);
move = Vector3.ClampMagnitude(move, 1f);
//Vector3 move = new Vector3(x, 0, z);
//move = Vector3.ClampMagnitude(move, 1f);
if (move != Vector3.zero)
{
transform.forward = move;
if (isRun)
{
SetAnimRun();
}
else
{
SetAnimWalk();
}
}
else
{
SetAnimIdle();
}
//if (move != Vector3.zero)
//{
// transform.forward = move;
// if (isRun)
// {
// SetAnimRun();
// }
// else
// {
// SetAnimWalk();
// }
//}
//else
//{
// SetAnimIdle();
//}
playerVelocity.y += gravityValue * Time.deltaTime;
Vector3 finalMove = (move * playerSpeed) + (playerVelocity.y * Vector3.up);
controller.Move(finalMove * Time.deltaTime);
//playerVelocity.y += gravityValue * Time.deltaTime;
//Vector3 finalMove = (move * playerSpeed) + (playerVelocity.y * Vector3.up);
//controller.Move(finalMove * Time.deltaTime);
}
+29
View File
@@ -1,18 +1,47 @@
using CSNetwork.Protocols.RPCData;
using System.Data;
using Unity.VisualScripting;
using UnityEngine;
public class GameController : MonoBehaviour
{
private static GameController instance;
[SerializeField] private CharacterCtrl characterPrefab;
[SerializeField] private Transform ground;
Camera camera;
public static GameController Instance
{
get
{
if (instance == null)
{
instance = new GameController();
}
return instance;
}
}
private void Awake()
{
if(instance == null)
{
instance = this;
}
}
private void Start()
{
camera = Camera.main;
}
public void Log(string s)
{
Debug.LogError(s);
}
public void InitCharacter(RoleInfo roleInfo)
{
CharacterCtrl character = Instantiate(characterPrefab, transform);