diff --git a/Assets/ModelRenderer/Art/Animations/models/npcs/怪物/2014/小星星/tcks_小星星/小星星.controller b/Assets/ModelRenderer/Art/Animations/models/npcs/怪物/2014/小星星/tcks_小星星/小星星.controller index 0e218041a2..3b5e2c42dd 100644 --- a/Assets/ModelRenderer/Art/Animations/models/npcs/怪物/2014/小星星/tcks_小星星/小星星.controller +++ b/Assets/ModelRenderer/Art/Animations/models/npcs/怪物/2014/小星星/tcks_小星星/小星星.controller @@ -11,61 +11,61 @@ AnimatorStateMachine: m_ChildStates: - serializedVersion: 1 m_State: {fileID: -6285969934229156280} - m_Position: {x: 455.36108, y: 264.42014, z: 0} + m_Position: {x: 330, y: 110, z: 0} - serializedVersion: 1 m_State: {fileID: -4252315827055087943} - m_Position: {x: 465.36108, y: 274.42014, z: 0} + m_Position: {x: 520, y: 210, z: 0} - serializedVersion: 1 m_State: {fileID: -997835969750185444} - m_Position: {x: 475.36108, y: 284.42014, z: 0} + m_Position: {x: 670, y: 240, z: 0} - serializedVersion: 1 m_State: {fileID: -297738448578785112} - m_Position: {x: 485.36108, y: 294.42014, z: 0} + m_Position: {x: 300, y: 410, z: 0} - serializedVersion: 1 m_State: {fileID: -21581216766130947} - m_Position: {x: 495.36108, y: 304.42014, z: 0} + m_Position: {x: 400, y: 470, z: 0} - serializedVersion: 1 m_State: {fileID: -1450879891330382429} - m_Position: {x: 505.36108, y: 314.42014, z: 0} + m_Position: {x: 640, y: 480, z: 0} - serializedVersion: 1 m_State: {fileID: -275573418084303450} - m_Position: {x: 515.3611, y: 324.42014, z: 0} + m_Position: {x: 850, y: 380, z: 0} - serializedVersion: 1 m_State: {fileID: -3213767302789210916} - m_Position: {x: 525.3611, y: 334.42014, z: 0} + m_Position: {x: 750, y: 310, z: 0} - serializedVersion: 1 m_State: {fileID: -4009867014747250876} - m_Position: {x: 535.3611, y: 344.42014, z: 0} + m_Position: {x: 800, y: 340, z: 0} - serializedVersion: 1 m_State: {fileID: -7892350631820069961} - m_Position: {x: 545.3611, y: 354.42014, z: 0} + m_Position: {x: 760, y: 440, z: 0} - serializedVersion: 1 m_State: {fileID: -6751172458481695137} - m_Position: {x: 555.3611, y: 364.42014, z: 0} + m_Position: {x: 830, y: 310, z: 0} - serializedVersion: 1 m_State: {fileID: -5765868619016982603} - m_Position: {x: 565.3611, y: 374.42014, z: 0} + m_Position: {x: 500, y: 270, z: 0} - serializedVersion: 1 m_State: {fileID: 6724503580119005640} - m_Position: {x: 575.3611, y: 384.42014, z: 0} + m_Position: {x: 670, y: 530, z: 0} - serializedVersion: 1 m_State: {fileID: -7214666250062047012} - m_Position: {x: 585.3611, y: 394.42014, z: 0} + m_Position: {x: 470, y: 530, z: 0} - serializedVersion: 1 m_State: {fileID: 8477285733522029458} - m_Position: {x: 595.3611, y: 404.42014, z: 0} + m_Position: {x: 570, y: 340, z: 0} - serializedVersion: 1 m_State: {fileID: 6050031586796907562} - m_Position: {x: 605.3611, y: 414.42014, z: 0} + m_Position: {x: 560, y: 380, z: 0} - serializedVersion: 1 m_State: {fileID: -5308827600921104159} - m_Position: {x: 615.3611, y: 424.42014, z: 0} + m_Position: {x: 550, y: 410, z: 0} - serializedVersion: 1 m_State: {fileID: -2194804601847838025} - m_Position: {x: 625.3611, y: 434.42014, z: 0} + m_Position: {x: 560, y: 430, z: 0} - serializedVersion: 1 m_State: {fileID: 4925054926420708456} - m_Position: {x: 635.3611, y: 444.42014, z: 0} + m_Position: {x: 260, y: 530, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: [] diff --git a/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll b/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll index 368d4eb1fc..4695f2e8e3 100644 Binary files a/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll and b/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll differ diff --git a/Assets/PerfectWorld/Scripts/Common/CECObject.cs b/Assets/PerfectWorld/Scripts/Common/CECObject.cs index cd9215eb53..8a05d8a83f 100644 --- a/Assets/PerfectWorld/Scripts/Common/CECObject.cs +++ b/Assets/PerfectWorld/Scripts/Common/CECObject.cs @@ -2,10 +2,18 @@ using UnityEngine; public class CECObject : MonoBehaviour { - private uint m_dwBornStamp; - private bool m_bBornInSight; - private bool m_bSelectable; + protected uint m_dwBornStamp; + protected bool m_bBornInSight; + protected bool m_bSelectable; + protected int m_iCID; + public virtual void SetUpCECObject() + { + m_dwBornStamp = 0; + m_bBornInSight = false; + m_bSelectable = false; + m_iCID = (int)ClassID.OCID_OBJECT; + } public void SetBornStamp(uint dwStamp) { m_dwBornStamp = dwStamp; } public void SetBornInSight(bool bFlag) { m_bBornInSight = bFlag; } public void SetSelectable(bool bSelectable) { m_bSelectable = bSelectable; } diff --git a/Assets/PerfectWorld/Scripts/Managers/CECNPCMan.cs b/Assets/PerfectWorld/Scripts/Managers/CECNPCMan.cs index 6410d93783..919fbd74e7 100644 --- a/Assets/PerfectWorld/Scripts/Managers/CECNPCMan.cs +++ b/Assets/PerfectWorld/Scripts/Managers/CECNPCMan.cs @@ -7,13 +7,22 @@ using System.Buffers.Binary; using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; +using UnityEngine.LightTransport; +using static CECNPC; +using static CECObject; -public class CECNPCMan : IMsgHandler +public class CECNPCMan : CECObject, IMsgHandler { private Dictionary m_NPCTab = new Dictionary(512); private Dictionary m_UkNPCTab = new Dictionary(32); + Vector3 m_vServerPos; public int HandlerId => (int)MANAGER_INDEX.MAN_NPC; + public CECNPCMan() + { + m_vServerPos = Vector3.zero; + m_iCID = (int)ClassID.OCID_MONSTER; + } public bool ProcessMessage(ECMSG Msg) { if (Msg.iSubID == 0) @@ -21,75 +30,102 @@ public class CECNPCMan : IMsgHandler switch (Msg.dwMsg) { case long value when value == EC_MsgDef.MSG_NM_NPCINFO: OnMsgNPCInfo(Msg); break; + case long value when value == EC_MsgDef.MSG_NM_NPCMOVE: OnMsgNPCMove(Msg); break; } } return true; } + private bool OnMsgNPCMove(ECMSG msg) + { + cmd_object_move pCmd = (cmd_object_move)msg.dwParam1; + + if (pCmd.use_time == 0) + return true; + + CECNPC pNPC = SeekOutNPC(pCmd.id); + if (pNPC) + pNPC.MoveTo(pCmd); + + return true; + } + public CECNPC SeekOutNPC(int nid) + { + if (!m_NPCTab.TryGetValue(nid, out var npc)) + { + // Couldn't find this NPC, put it into unknown NPC table + m_UkNPCTab[nid] = nid; + return null; + } + + return npc; + } private bool OnMsgNPCInfo(ECMSG msg) { - switch (msg.dwParam2) // Msg.dwParam2 giữ nguyên như C++ + switch (Convert.ToInt32(msg.dwParam2)) { - case CommandID.NPC_INFO_LIST: { - // Msg.dwParam1: giả sử đã được cast thành byte[] - var buffer = (byte[])msg.dwParam1; - int offset = 0; + // msg.dwParam1 chính là buffer chứa placeholder data (không có header cmd_npc_info_list) + cmd_npc_info_list pCmd = MemoryMarshal.Read( + ((byte[])msg.dwParam1).AsSpan()); - // Đọc count (2 byte đầu tiên) - if (buffer.Length < 2) return false; - ushort count = BinaryPrimitives.ReadUInt16LittleEndian(buffer.AsSpan(offset, 2)); - offset += 2; + int offset = Marshal.OffsetOf("placeholder").ToInt32(); + byte[] buffer = (byte[])msg.dwParam1; + Span pDataBuf = buffer.AsSpan(offset); - for (int i = 0; i < count; i++) + for (int i = 0; i < pCmd.count; i++) { - if (buffer.Length - offset < info_npc.HEADER_SIZE) - return false; - - // đọc info_npc từ buffer - info_npc info = MemoryMarshal.Read( - buffer.AsSpan(offset, info_npc.HEADER_SIZE)); + // giống const info_npc& Info = *(const info_npc*)pDataBuf; + info_npc info = MemoryMarshal.Read(pDataBuf); int iSize = info_npc.HEADER_SIZE; - if ((info.state & PlayerNPCState.GP_STATE_EXTEND_PROPERTY) != 0) iSize += sizeof(uint) * NumberDWORDsPlayerNPC.OBJECT_EXT_STATE_COUNT; - if ((info.state & PlayerNPCState.GP_STATE_NPC_PET) != 0) iSize += sizeof(int); - if ((info.state & PlayerNPCState.GP_STATE_NPC_NAME) != 0) { - if (buffer.Length < offset + iSize + 1) return false; - byte len = buffer[offset + iSize]; + byte len = pDataBuf[iSize]; iSize += 1 + len; } - if ((info.state & PlayerNPCState.GP_STATE_MULTIOBJ_EFFECT) != 0) { - if (buffer.Length < offset + iSize + sizeof(int)) return false; int countEff = BinaryPrimitives.ReadInt32LittleEndian( - buffer.AsSpan(offset + iSize, sizeof(int))); - iSize += sizeof(int); - iSize += countEff * (sizeof(int) + 1); + pDataBuf.Slice(iSize, sizeof(int))); + iSize += sizeof(int) + countEff * (sizeof(int) + 1); } - if ((info.state & PlayerNPCState.GP_STATE_NPC_MAFIA) != 0) iSize += sizeof(int); - Console.WriteLine( - $"HoangDev: NPC_INFO_LIST, nid: {info.nid}, tid: {info.tid}, vis_tid: {info.vis_tid}, pos: {info.pos.x} {info.pos.y} {info.pos.z}"); - - NPCEnter(info, false,buffer,offset); + NPCEnter(info, false, buffer, offset); + // dịch pDataBuf về sau (giống pDataBuf += iSize) + pDataBuf = pDataBuf.Slice(iSize); offset += iSize; } break; } + + case CommandID.NPC_ENTER_SLICE: + { + var buffer = (byte[])msg.dwParam1; + info_npc info = MemoryMarshal.Read(buffer.AsSpan(0, info_npc.HEADER_SIZE)); + NPCEnter(info, false, buffer, info_npc.HEADER_SIZE); + break; + } + + case CommandID.NPC_ENTER_WORLD: + { + var buffer = (byte[])msg.dwParam1; + info_npc info = MemoryMarshal.Read(buffer.AsSpan(0, info_npc.HEADER_SIZE)); + NPCEnter(info, true, buffer, info_npc.HEADER_SIZE); + break; + } } - return false; + return true; } + public bool NPCEnter(in info_npc Info, bool bBornInSight, ReadOnlySpan packet, int infoOffset) { var npc = GetNPC(Info.nid); @@ -106,7 +142,7 @@ public class CECNPCMan : IMsgHandler // Tạo NPC mới npc = CreateNPC(Info, bBornInSight, packet, infoOffset); - if (npc == null) + if (object.ReferenceEquals(npc, null)) { BrewMonster.Logger.LogError($"Failed to create NPC ({Info.tid})"); return false; @@ -144,7 +180,6 @@ public class CECNPCMan : IMsgHandler tid = 4249; dataType = edm.get_data_type((uint)tid, ID_SPACE.ID_SPACE_ESSENCE); } - if (bPet) { //pNPC = new CECPet(this); @@ -153,9 +188,13 @@ public class CECNPCMan : IMsgHandler { switch (dataType) { - //case DATA_TYPE.DT_NPC_ESSENCE: pNPC = new CECNPCServer(this); break; - case DATA_TYPE.DT_MONSTER_ESSENCE: pNPC = new CECMonster(this); break; - //case DATA_TYPE.DT_PET_ESSENCE: pNPC = new CECPet(this); break; + case DATA_TYPE.DT_NPC_ESSENCE: /*pNPC = new CECNPCServer(this);*/ break; + case DATA_TYPE.DT_MONSTER_ESSENCE: + + pNPC = GameController.Instance.GetMonster(); + + break; + case DATA_TYPE.DT_PET_ESSENCE:/* pNPC = new CECPet(this);*/ break; default: UnityEngine.Debug.Assert(false, "Invalid DATA_TYPE in CreateNPC"); return null; @@ -164,13 +203,21 @@ public class CECNPCMan : IMsgHandler // Set born stamp & born-in-sight (giữ nguyên semantics) uint bornStamp = CECWorld.Instance.GetBornStamp(); - pNPC.SetBornStamp(bornStamp); - pNPC.SetBornInSight(bBornInSight); + if (!object.ReferenceEquals(pNPC, null)) + { + pNPC.SetBornStamp(bornStamp); + pNPC.SetBornInSight(bBornInSight); + } + else + { + return null; + } // Init với tid + Info như C++ - if (pNPC == null || !pNPC.Init(tid, Info, packet, infoOffset)) + if (!pNPC.Init(tid, Info, packet, infoOffset)) { + // đảm bảo giải phóng nếu bạn có tài nguyên kèm theo //pNPC?.Release(); pNPC = null; diff --git a/Assets/PerfectWorld/Scripts/NPC/CECMonster.cs b/Assets/PerfectWorld/Scripts/NPC/CECMonster.cs index 2fe323302c..a9cc79ee47 100644 --- a/Assets/PerfectWorld/Scripts/NPC/CECMonster.cs +++ b/Assets/PerfectWorld/Scripts/NPC/CECMonster.cs @@ -8,28 +8,24 @@ using UnityEngine; public class CECMonster : CECNPC { MONSTER_ESSENCE m_pDBEssence; - int m_iCID; - public CECMonster(CECNPCMan pNPCMan) - : base(pNPCMan) // gọi constructor của CECNPC + public override void SetUpCECNPC(CECNPCMan pNPCMan) { - + base.SetUpCECNPC(pNPCMan); m_iCID = (int)ClassID.OCID_MONSTER; m_pDBEssence = default; - - m_fTouchRad = m_pDBEssence.size; - m_BasicProps.iLevel = m_pDBEssence.level; - QueueLoadNPCModel(); } public override bool Init(int tid, in info_npc info, ReadOnlySpan packet, int infoOffset) { base.Init(tid, info, packet,infoOffset); - + BrewMonster.Logger.Log("HoangDev: MonsterInit"); var pDB = ElementDataManProvider.GetElementDataMan(); DATA_TYPE DataType = default ; m_pDBEssence = (MONSTER_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE,ref DataType); + m_fTouchRad = m_pDBEssence.size; + m_BasicProps.iLevel = m_pDBEssence.level; - + QueueLoadNPCModel(); return true; } } diff --git a/Assets/PerfectWorld/Scripts/NPC/CECNPC.cs b/Assets/PerfectWorld/Scripts/NPC/CECNPC.cs index 763fc91923..c3cd64fea6 100644 --- a/Assets/PerfectWorld/Scripts/NPC/CECNPC.cs +++ b/Assets/PerfectWorld/Scripts/NPC/CECNPC.cs @@ -6,6 +6,7 @@ using UnityEngine; using BrewMonster; using CSNetwork; using ModelRenderer.Scripts.Common; +using System.IO; public class CECNPC : CECObject { @@ -23,13 +24,26 @@ public class CECNPC : CECObject protected OtherPlayer_Move_Info m_cdr; protected float m_fTouchRad; protected ROLEBASICPROP m_BasicProps; + protected A3DVECTOR3 m_vMoveDir; + protected int m_iPassiveMove; + protected bool m_bStopMove; + protected int[] m_aWorks = new int[4]; + protected int m_iAction; + [SerializeField] protected float m_fMoveSpeed; - public CECNPC(CECNPCMan pNPCMan) + protected static CECStringTab m_ActionNames; + + + public virtual void SetUpCECNPC(CECNPCMan pNPCMan) { - + base.SetUpCECObject(); + m_vServerPos = new A3DVECTOR3(); + m_iCID = (int)ClassID.OCID_NPC; } public virtual bool Init(int tid, in info_npc info, ReadOnlySpan packet, int infoOffset) { + BrewMonster.Logger.Log("HoangDev: NPCInit"); + m_NPCInfo.nid = info.nid; m_NPCInfo.tid = tid; m_NPCInfo.vis_tid = info.vis_tid; @@ -44,7 +58,7 @@ public class CECNPC : CECObject // 2) Cắt “đuôi” ngay sau phần cố định info_npc int fixedSize = System.Runtime.InteropServices.Marshal.SizeOf(); - var tail = packet.Slice(infoOffset + fixedSize); + var tail = packet.Slice(infoOffset); var r = new ByteReader(tail); @@ -107,6 +121,14 @@ public class CECNPC : CECObject return true; } + public static bool InitStaticRes() + { + // Load action names from file + if (!m_ActionNames.IsInitialized()) + m_ActionNames.Init("actions_npc.txt", false); + + return true; + } public void QueueLoadNPCModel() { /* if (ShouldUseMasterModel()) @@ -118,10 +140,17 @@ public class CECNPC : CECObject }*/ int tid = 0; string szModelFile = ""; - if (!GetVisibleModel( out tid, out szModelFile)) + if (!GetVisibleModel(out tid, out szModelFile)) { return; } + var nameMonster = Path.GetFileNameWithoutExtension(szModelFile); + BrewMonster.Logger.Log("HoangDev: nameMonster :" + nameMonster); + var model = NPCBuilder.Instance.GetModelByName(nameMonster); + + BrewMonster.Logger.Log("HoangDev: model.name :" + model.name); + var monsterModel = Instantiate(model, transform); + monsterModel.SetActive(true); //QueueECModelForLoad(MTL_ECM_NPC, GetNPCInfo().nid, GetBornStamp(), GetServerPos(), szModelFile, tid); } public bool GetVisibleModel(out int tid, out string szModelFile) @@ -163,7 +192,7 @@ public class CECNPC : CECObject case DATA_TYPE.DT_MONSTER_ESSENCE: { var ess = (MONSTER_ESSENCE)pDBEssence; - szModelFile = ByteToStringUtils.ByteArrayToCP936String( ess.file_model); + szModelFile = ByteToStringUtils.ByteArrayToCP936String(ess.file_model); Debug.Log($"HoangDev : MONSTER_ESSENCE path : {szModelFile}"); break; } @@ -187,7 +216,133 @@ public class CECNPC : CECObject Debug.Log($"HoangDev : path 99 : {szModelFile}"); return ret; } + public static void ReleaseStaticRes() + { + m_ActionNames.Release(); + } + public void MoveTo(cmd_object_move Cmd) + { + if (Cmd.use_time == 0) + return; + + m_vServerPos = Cmd.dest; + m_vMoveDir = Cmd.dest - EC_Utility.ToA3DVECTOR3(transform.position); + float fDist = m_vMoveDir.Normalize(); // giả sử Normalize() trả về độ dài trước khi chuẩn hóa + + // If destination position is too far, forcely pull player + if (IsLag(fDist)) + { + transform.position = EC_Utility.ToVector3(Cmd.dest); + return; + } + + int iMoveMode = Cmd.move_mode & (int)GPMoveMode.GP_MOVE_MASK; + + m_bStopMove = false; + + if (iMoveMode == (int)GPMoveMode.GP_MOVE_PUSH || iMoveMode == (int)GPMoveMode.GP_MOVE_PULL) + { + // Push back or pull should occur in stop move command + UnityEngine.Debug.Assert(false, "Invalid move mode: push/pull inside MoveTo"); + return; + } + + m_cdr.bTraceGround = true; + + if ((Cmd.move_mode & (int)GPMoveMode.GP_MOVE_AIR) != 0) + { + m_iMoveEnv = (int)MoveEnvironment.MOVEENV_AIR; + m_cdr.bTraceGround = false; + } + else if ((Cmd.move_mode & (int)GPMoveMode.GP_MOVE_WATER) != 0) + { + m_iMoveEnv = (int)MoveEnvironment.MOVEENV_WATER; + m_cdr.bTraceGround = false; + } + else + { + m_iMoveEnv = (int)MoveEnvironment.MOVEENV_GROUND; + + int iTemp = iMoveMode & (int)GPMoveMode.GP_MOVE_MASK; + if (iTemp == (int)GPMoveMode.GP_MOVE_FALL || iTemp == (int)GPMoveMode.GP_MOVE_FLYFALL) + m_cdr.bTraceGround = false; + } + + m_fMoveSpeed = fDist / (Cmd.use_time * 0.001f); + // float fSpeed = FIX8TOFLOAT(Cmd.sSpeed); + // m_fMoveSpeed = Mathf.Clamp(m_fMoveSpeed, 0.0f, fSpeed * 1.2f); + + // Adjust NPC's direction + /* if (!IsDirFixed()) + { + var vDir = m_vMoveDir; + vDir.y = 0.0f; + if (!vDir.IsZero()) + { + vDir.Normalize(); + SetDestDirAndUp(vDir, g_vAxisY, 150); + } + } + */ + /* if (m_aWorks[(int)WorkType.WT_NORMAL] != (int)WorkID.WORK_MOVE || ShouldPlayNewActionFor(iMoveMode)) + { + StartWork(WT_NORMAL, WORK_MOVE); + // Play run or walk action + PlayMoveAction(iMoveMode); + }*/ + } + public void PlayMoveAction(int iMoveMode) + { + // Play run or walk aciton + if (iMoveMode == (int)GPMoveMode.GP_MOVE_RUN || iMoveMode == (int)GPMoveMode.GP_MOVE_RETURN) + { + /*if (IsMonsterOrPet()) + PlayModelAction(ACT_RUN, false); + else + PlayModelAction(ACT_NPC_RUN, false);*/ + } + else + { + PlayModelAction((int)NPCActionIndex.ACT_WALK, false); + /* if (IsMonsterOrPet()) + PlayModelAction(ACT_WALK, false); + else + PlayModelAction(ACT_NPC_WALK, false);*/ + } + } + public void PlayModelAction(int iAction, bool bRestart/* =true */) + { + m_iAction = iAction; + /* if (IsDead()) + { + // ¼ì²éËÀÍö״̬£¬ÒÔÆÁ±ÎÆäËü¶¯×÷ + // ËÀÍö״̬ÉèÖúó£¬Ö»ÔÊÐí²¥·ÅËÀÍö¶¯×÷ + // Íæ¼Ò¹¥»÷NPCʱ£¬»áÊ×ÏȲ¥·ÅÍæ¼ÒµÄ¹¥»÷¶¯×÷£¬Íê³Éºó²¥·Å¹ÖÎïµÄÊÜÉ˶¯×÷ + // µ«ÔÚÍæ¼Ò×ÔÉíµÄ¹¥»÷¶¯×÷δÍê³Éʱ£¬¿ÉÄܾÍÊÕµ½NPCËÀÍöµÄÏûÏ¢ + // Òò´Ë£¬¿ÉÄÜ»áÏȲ¥·ÅËÀÍö¶¯×÷£¬¶øºóÓÖ²¥·ÅÊÜÉ˶¯×÷£¬µ¼ÖÂËÀÍö¶¯×÷²»ÄÜÕý³£²¥·ÅµÄ±íÏÖ½á¹û + // ²»·ûºÏÆÚÍû + if (IsMonsterOrPet()) + { + if (iAction != CECNPC::ACT_DIE) + { + return; + } + } + else + { + if (iAction != CECNPC::ACT_NPC_DIE) + { + return; + } + } + }*/ + } + + bool IsLag(float fDist) + { + return m_iPassiveMove == 0 && fDist > MAX_LAGDIST; + } public INFO GetNPCInfo() { return m_NPCInfo; } public struct INFO @@ -196,7 +351,58 @@ public class CECNPC : CECObject public int tid; // Template id public int vis_tid;// template id for shape }; + public const float MAX_LAGDIST = 25.0f; } +public enum WorkType +{ + WT_NOTHING = 0, // Do thing + WT_NORMAL, // Normal type work + WT_INTERRUPT, // Interrupt type work + NUM_WORKTYPE, +}; +// Work ID +public enum WorkID + +{ + WORK_STAND = 1, // Stand and do nothing + WORK_FIGHT, // Fighting + WORK_SPELL, // Monster is cast skill + WORK_DEAD, // Monster is dead + WORK_MOVE, // Move to a destination terrain position + WORK_POLICYACTION, // Is playing policy action£¬WT_INTERRUPT +}; +public enum NPCActionIndex + +{ + ACT_STAND = 0, + ACT_IDLE, + ACT_GUARD, + ACT_SKILL1, + ACT_WALK, + ACT_ATTACK1, + ACT_ATTACK2, + ACT_RUN, + ACT_DIE, + ACT_JUMP_START, + ACT_JUMP_LAND, + ACT_JUMP_LOOP, + ACT_MAGIC1, + ACT_WOUNDED, + ACT_NPC_CHAT1, + ACT_NPC_CHAT2, + ACT_NPC_CHATLOOP, + ACT_NPC_IDLE1, + ACT_NPC_IDLE2, + ACT_NPC_STAND, + ACT_NPC_WALK, + ACT_NPC_RUN, + ACT_NPC_ATTACK, + ACT_NPC_DIE, + ACT_COMMON_BORN, + ACT_NPC_DISAPPEAR, + ACT_WOUNDED2, + ACT_MAX, +}; public ref struct ByteReader { private ReadOnlySpan _span; diff --git a/Assets/PerfectWorld/Scripts/NPC/NPCBuilder.cs b/Assets/PerfectWorld/Scripts/NPC/NPCBuilder.cs new file mode 100644 index 0000000000..3b3ca99d29 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/NPC/NPCBuilder.cs @@ -0,0 +1,24 @@ +using BrewMonster; +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +public class NPCBuilder : MonoSingleton +{ + [SerializeField] List modelNPCList; + [SerializeField] Dictionary modleNPCDic; + + private void Awake() + { + if (modelNPCList.Count == 0) + { + Debug.LogError("modelList empty"); + } + + modleNPCDic = modelNPCList.GroupBy(obj => obj.name) + .ToDictionary(g => g.Key, g => g.First()); + } + public GameObject GetModelByName(string name) => + modleNPCDic.TryGetValue(name, out var model) ? model : null; +} diff --git a/Assets/PerfectWorld/Scripts/NPC/NPCBuilder.cs.meta b/Assets/PerfectWorld/Scripts/NPC/NPCBuilder.cs.meta new file mode 100644 index 0000000000..2ccafddb43 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/NPC/NPCBuilder.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c410036615d7e2f4fb76258c665dc6ee \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs b/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs new file mode 100644 index 0000000000..21e1be24c0 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs @@ -0,0 +1,16 @@ +using UnityEngine; + +public class NPCVisual : 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() + { + + } +} diff --git a/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs.meta b/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs.meta new file mode 100644 index 0000000000..015848fe0d --- /dev/null +++ b/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8c7b669b45068cf469ae3116991b9026 \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs b/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs index 628152052a..d2f4925ad3 100644 --- a/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs +++ b/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs @@ -12,11 +12,11 @@ namespace BrewMonster { private static EC_ManMessageMono instance; - public static EC_ManMessageMono Instance + public static EC_ManMessageMono Instance { get { - if(instance == null) + if (instance == null) { instance = FindAnyObjectByType(); } @@ -25,14 +25,17 @@ namespace BrewMonster } public EC_ManPlayer EC_ManPlayer; - public EC_ManPlayer GetECManPlayer { get => EC_ManPlayer;} + public EC_ManPlayer GetECManPlayer { get => EC_ManPlayer; } + public CECNPCMan _CECNPCMan { get; private set; } private void Awake() { instance = this; //TODO: Remove later EC_ManPlayer = new EC_ManPlayer(); + _CECNPCMan = new CECNPCMan(); EC_ManMessage.RegisterHandler(EC_ManPlayer); + EC_ManMessage.RegisterHandler(_CECNPCMan); Debug.Log($"EC_ManMessage RegisterHandlerRegisterHandlerRegisterHandler"); } diff --git a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs index 6451a0935a..67935b33a7 100644 --- a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs @@ -32,6 +32,10 @@ namespace BrewMonster.Network Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); base.Awake(); } + private void Start() + { + CECNPC.InitStaticRes(); + } /// /// Send a /// @@ -193,6 +197,7 @@ namespace BrewMonster.Network void OnDestroy() { _gameSession.Disconnect(); + CECNPC.ReleaseStaticRes(); } } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs b/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs index f2dc05e6cb..f5ef7667a9 100644 --- a/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs +++ b/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs @@ -115,6 +115,11 @@ namespace BrewMonster.UI isDoneNPCRender = value; actLoadChar?.Invoke(); }); + UnityGameSession.Instance.LoadScene("MonsterRender", LoadSceneMode.Additive, (value) => + { + isDoneNPCRender = value; + actLoadChar?.Invoke(); + }); nameScene = "WorldRender"; UnityGameSession.Instance.LoadScene(nameScene, LoadSceneMode.Additive, (value) => { diff --git a/Assets/PerfectWorld/Scripts/World/CECWorld.cs b/Assets/PerfectWorld/Scripts/World/CECWorld.cs index 6138d8b35f..779918373f 100644 --- a/Assets/PerfectWorld/Scripts/World/CECWorld.cs +++ b/Assets/PerfectWorld/Scripts/World/CECWorld.cs @@ -3,7 +3,7 @@ using UnityEngine; public class CECWorld : MonoSingleton { - uint m_dwBornStamp; + uint m_dwBornStamp = 0; public uint GetBornStamp() { return m_dwBornStamp++; } } diff --git a/Assets/Prefabs/MonsterPrefab.prefab b/Assets/Prefabs/MonsterPrefab.prefab new file mode 100644 index 0000000000..d8762b184a --- /dev/null +++ b/Assets/Prefabs/MonsterPrefab.prefab @@ -0,0 +1,46 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6975799234359536760 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3521696612905468212} + - component: {fileID: 2542060226037108388} + m_Layer: 0 + m_Name: MonsterPrefab + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3521696612905468212 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6975799234359536760} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &2542060226037108388 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6975799234359536760} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2cd22b82fc76bed46ac948cef9c7119d, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Prefabs/MonsterPrefab.prefab.meta b/Assets/Prefabs/MonsterPrefab.prefab.meta new file mode 100644 index 0000000000..dd66f8a1d5 --- /dev/null +++ b/Assets/Prefabs/MonsterPrefab.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 244942d3fb9382846b82581ce24fbf4e +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/NPCPrefab.prefab b/Assets/Prefabs/NPCPrefab.prefab new file mode 100644 index 0000000000..4e4bf9cf48 --- /dev/null +++ b/Assets/Prefabs/NPCPrefab.prefab @@ -0,0 +1,46 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6975799234359536760 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3521696612905468212} + - component: {fileID: 2999449018738386437} + m_Layer: 0 + m_Name: NPCPrefab + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3521696612905468212 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6975799234359536760} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &2999449018738386437 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6975799234359536760} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e7f08b1c572f8f140b1f25edb7e5dd47, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Prefabs/NPCPrefab.prefab.meta b/Assets/Prefabs/NPCPrefab.prefab.meta new file mode 100644 index 0000000000..17c47cb6fa --- /dev/null +++ b/Assets/Prefabs/NPCPrefab.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7422b778d3b9d72478c6384051493e59 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/actions_npc.txt b/Assets/Resources/actions_npc.txt new file mode 100644 index 0000000000..d395f69d73 --- /dev/null +++ b/Assets/Resources/actions_npc.txt @@ -0,0 +1,31 @@ +#_begin + +// +"վ" +"" +"䱸" +"1" +"ƶ" +"չ1" +"չ2" +"ƶ" +"" +"Ծ" +"Ծ" +"Ծѭ" +"ħ1" +"˵" +// NPC +"ؽ̸" +"̸ֽ" +"̸ѭ" +"ж1" +"ж2" +"վ" +"" +"ܶ" +"" +"" +"" +"ʧ" +"" diff --git a/Assets/Resources/actions_npc.txt.meta b/Assets/Resources/actions_npc.txt.meta new file mode 100644 index 0000000000..e6df756a39 --- /dev/null +++ b/Assets/Resources/actions_npc.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ea9f0a1a66333d64c9f96d973a19b51e +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/MonsterRender.unity b/Assets/Scenes/MonsterRender.unity index ba13d77769..4bc9357860 100644 --- a/Assets/Scenes/MonsterRender.unity +++ b/Assets/Scenes/MonsterRender.unity @@ -672,7 +672,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &94307045 Transform: m_ObjectHideFlags: 0 @@ -777,7 +777,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 188517152} serializedVersion: 2 - m_LocalRotation: {x: -0, y: -1, z: -0, w: 0} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -815,7 +815,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 219056132} - m_LocalEulerAnglesHint: {x: 3.3875408, y: 4.57245, z: 41.83547} + m_LocalEulerAnglesHint: {x: 37.509544, y: 4.471659, z: 7.4814105} --- !u!1 &219056131 GameObject: m_ObjectHideFlags: 0 @@ -847,7 +847,7 @@ Transform: m_Children: - {fileID: 200271003} m_Father: {fileID: 1842494812} - m_LocalEulerAnglesHint: {x: -2.086577, y: 14.222059, z: 23.294022} + m_LocalEulerAnglesHint: {x: -11.090817, y: 18.145458, z: 0.06438049} --- !u!1 &229829660 GameObject: m_ObjectHideFlags: 0 @@ -1326,6 +1326,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 506364218} + - component: {fileID: 506364219} m_Layer: 0 m_Name: NPCBuilder m_TagString: Untagged @@ -1351,6 +1352,21 @@ Transform: - {fileID: 2107333969} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &506364219 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 506364216} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c410036615d7e2f4fb76258c665dc6ee, type: 3} + m_Name: + m_EditorClassIdentifier: + modelNPCList: + - {fileID: 94307044} + - {fileID: 2107333968} --- !u!1 &538814801 GameObject: m_ObjectHideFlags: 0 @@ -1412,7 +1428,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1448902965} - m_LocalEulerAnglesHint: {x: 29.86581, y: 59.18345, z: 63.383167} + m_LocalEulerAnglesHint: {x: -48.88787, y: -4.7707734, z: 6.976117} --- !u!1 &612684905 GameObject: m_ObjectHideFlags: 0 @@ -1444,7 +1460,7 @@ Transform: m_Children: - {fileID: 1060394198} m_Father: {fileID: 1685763910} - m_LocalEulerAnglesHint: {x: 0.5529412, y: -16.666517, z: 10.319766} + m_LocalEulerAnglesHint: {x: 5.186275, y: -17.310516, z: 1.0528536} --- !u!1 &613875936 GameObject: m_ObjectHideFlags: 0 @@ -1507,7 +1523,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 770801495} - m_LocalEulerAnglesHint: {x: 1.397163, y: -89.999954, z: -89.99999} + m_LocalEulerAnglesHint: {x: -0.21815334, y: -90.06328, z: -89.40538} --- !u!1 &632580734 GameObject: m_ObjectHideFlags: 0 @@ -1538,7 +1554,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 943395042} - m_LocalEulerAnglesHint: {x: 0.9706951, y: 1.7439737, z: 20.198053} + m_LocalEulerAnglesHint: {x: 22.354374, y: -25.943213, z: 3.8724716} --- !u!1 &681084483 GameObject: m_ObjectHideFlags: 0 @@ -1788,7 +1804,7 @@ Transform: - {fileID: 628919915} - {fileID: 1328669174} m_Father: {fileID: 188517153} - m_LocalEulerAnglesHint: {x: 0.000099265104, y: 0.00001730286, z: -179.99998} + m_LocalEulerAnglesHint: {x: 84.099976, y: 17.95178, z: -179.30626} --- !u!1 &803947884 GameObject: m_ObjectHideFlags: 0 @@ -1820,7 +1836,7 @@ Transform: m_Children: - {fileID: 1448902965} m_Father: {fileID: 770801495} - m_LocalEulerAnglesHint: {x: -1.4183443, y: -43.638645, z: -3.4403713} + m_LocalEulerAnglesHint: {x: 1.8517389, y: -22.36275, z: -7.9142075} --- !u!1 &850759206 GameObject: m_ObjectHideFlags: 0 @@ -1915,7 +1931,7 @@ Transform: m_Children: - {fileID: 632580735} m_Father: {fileID: 983481364} - m_LocalEulerAnglesHint: {x: -0.6232226, y: 17.338112, z: 10.922086} + m_LocalEulerAnglesHint: {x: -7.5288367, y: 25.086956, z: 1.3219217} --- !u!1 &983481363 GameObject: m_ObjectHideFlags: 0 @@ -1947,7 +1963,7 @@ Transform: m_Children: - {fileID: 943395042} m_Father: {fileID: 770801495} - m_LocalEulerAnglesHint: {x: 0.000008025883, y: 118.44946, z: -2.0906146} + m_LocalEulerAnglesHint: {x: -6.4957175, y: 80.435165, z: -11.533503} --- !u!1 &1060394197 GameObject: m_ObjectHideFlags: 0 @@ -1978,7 +1994,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 612684906} - m_LocalEulerAnglesHint: {x: 0.064075604, y: 3.43463, z: 16.437746} + m_LocalEulerAnglesHint: {x: 14.689643, y: -8.259342, z: -0.91933274} --- !u!1 &1065610873 GameObject: m_ObjectHideFlags: 0 @@ -2490,7 +2506,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 770801495} - m_LocalEulerAnglesHint: {x: 0.84252733, y: 90.00003, z: 89.99999} + m_LocalEulerAnglesHint: {x: 0.8425137, y: 90.00004, z: 89.99999} --- !u!1 &1340697009 GameObject: m_ObjectHideFlags: 0 @@ -2515,14 +2531,14 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1340697009} serializedVersion: 2 - m_LocalRotation: {x: -0, y: -1, z: -0, w: 0} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 754682930} m_Father: {fileID: 1295080370} - m_LocalEulerAnglesHint: {x: -0.000020490566, y: 90, z: 90} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1404017967 GameObject: m_ObjectHideFlags: 0 @@ -2553,7 +2569,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1780738119} - m_LocalEulerAnglesHint: {x: -2.0199573, y: -7.415275, z: 28.032448} + m_LocalEulerAnglesHint: {x: -24.606922, y: 6.2258244, z: -10.96086} --- !u!1 &1448902964 GameObject: m_ObjectHideFlags: 0 @@ -2585,7 +2601,7 @@ Transform: m_Children: - {fileID: 576944855} m_Father: {fileID: 803947885} - m_LocalEulerAnglesHint: {x: 1.2044154, y: -3.4631538, z: 34.009506} + m_LocalEulerAnglesHint: {x: 7.964184, y: -11.823143, z: -0.58464885} --- !u!1 &1450575681 GameObject: m_ObjectHideFlags: 0 @@ -2649,7 +2665,7 @@ Transform: m_Children: - {fileID: 1780738119} m_Father: {fileID: 770801495} - m_LocalEulerAnglesHint: {x: 0.00003438256, y: -123.71548, z: -2.2651362} + m_LocalEulerAnglesHint: {x: 8.413775, y: -70.44155, z: -12.913373} --- !u!1 &1497564909 GameObject: m_ObjectHideFlags: 0 @@ -3771,7 +3787,7 @@ Transform: m_Children: - {fileID: 612684906} m_Father: {fileID: 770801495} - m_LocalEulerAnglesHint: {x: 0.0000017399288, y: -179.28978, z: -1.9273593} + m_LocalEulerAnglesHint: {x: 0.00016876556, y: -177.35884, z: -20.993475} --- !u!1 &1761919879 GameObject: m_ObjectHideFlags: 0 @@ -3893,7 +3909,7 @@ Transform: m_Children: - {fileID: 1404017968} m_Father: {fileID: 1480888600} - m_LocalEulerAnglesHint: {x: 0.08734549, y: -2.2111988, z: 14.637986} + m_LocalEulerAnglesHint: {x: 2.530177, y: -7.828605, z: 1.7663156} --- !u!1 &1790343736 GameObject: m_ObjectHideFlags: 0 @@ -3957,7 +3973,7 @@ Transform: m_Children: - {fileID: 219056132} m_Father: {fileID: 770801495} - m_LocalEulerAnglesHint: {x: 1.3997761, y: 48.10262, z: -3.013983} + m_LocalEulerAnglesHint: {x: -0.65920687, y: 26.516863, z: -7.996199} --- !u!1 &1970311151 GameObject: m_ObjectHideFlags: 0 @@ -4223,7 +4239,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &2107333969 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/WorldRender.unity b/Assets/Scenes/WorldRender.unity index 340082d818..8019ff8c38 100644 --- a/Assets/Scenes/WorldRender.unity +++ b/Assets/Scenes/WorldRender.unity @@ -392997,6 +392997,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: characterPrefab: {fileID: 2038764726549499828, guid: 1f80fef119a826b4a826baf52a8f92d7, type: 3} + monsterPrefab: {fileID: 2542060226037108388, guid: 244942d3fb9382846b82581ce24fbf4e, type: 3} cinemachineCamera: {fileID: 1235489763} --- !u!1 &1567601032 GameObject: diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 2d6e256ce5..371c59dcf3 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -4,19 +4,21 @@ using System.Data; using Unity.Cinemachine; using Unity.VisualScripting; using UnityEngine; +using UnityEngine.UIElements; public class GameController : MonoBehaviour { private static GameController instance; [SerializeField] private CECHostPlayer characterPrefab; + [SerializeField] private CECMonster monsterPrefab; [SerializeField] private CinemachineCamera cinemachineCamera; //[SerializeField] private Transform ground; CECHostPlayer hostPlayer; - public static GameController Instance - { - get + public static GameController Instance + { + get { if (instance == null) { @@ -27,7 +29,7 @@ public class GameController : MonoBehaviour } private void Awake() { - if(instance == null) + if (instance == null) { instance = this; } @@ -39,7 +41,7 @@ public class GameController : MonoBehaviour } public CECHostPlayer GetHostPlayer() { - if(hostPlayer == null) + if (hostPlayer == null) { hostPlayer = FindAnyObjectByType(); } @@ -48,7 +50,7 @@ public class GameController : MonoBehaviour } public void InitCharacter(cmd_self_info_1 info) { - if(characterPrefab == null) + if (characterPrefab == null) { Debug.LogError("null prefab"); return; @@ -66,7 +68,10 @@ public class GameController : MonoBehaviour //posGround.y -= 2f; //ground.transform.position = posGround; } - + public CECMonster GetMonster() + { + return Instantiate(monsterPrefab, transform); + } public GameObject InitCharacter(info_player_1 info) { if (characterPrefab == null) diff --git a/Assets/Scripts/Move/EC_Player.cs b/Assets/Scripts/Move/EC_Player.cs index 6b920f491c..830d7710fc 100644 --- a/Assets/Scripts/Move/EC_Player.cs +++ b/Assets/Scripts/Move/EC_Player.cs @@ -121,7 +121,6 @@ public abstract class EC_Player : MonoBehaviour PLAYER_ACTION action = actionConfig; var szAct = EC_Utility.BuildActionName(action, 0); - BrewMonster.Logger.Log("HoangDev szActszAct: " + szAct); EventBus.PublishChannel(m_PlayerInfo.cid, new PlayActionEvent(szAct)); return true; } diff --git a/Build.rar b/Build.rar new file mode 100644 index 0000000000..c68af05cc2 Binary files /dev/null and b/Build.rar differ