diff --git a/Assets/PerfectWorld/Scripts/Common/CinemachineTouchOrbit.cs b/Assets/PerfectWorld/Scripts/Common/CinemachineTouchOrbit.cs new file mode 100644 index 0000000000..22f8dd93c2 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Common/CinemachineTouchOrbit.cs @@ -0,0 +1,99 @@ +using BrewMonster; +using System.Collections; +using Unity.Cinemachine; +using UnityEngine; + +public class CinemachineTouchOrbit : MonoSingleton +{ + public CinemachineCamera cineCam; + public Transform player; + + [Header("Settings")] + public float inputSpeed = 0.2f; + public float clampPitchMin = -30f; + public float clampPitchMax = 60f; + public float distance = 5f; // khoảng cách camera phía sau + + float yawOffset = 0f; // phần xoay do input + float pitchOffset = 0f; + + Vector2 lastPointerPos; + bool isDragging = false; + + void LateUpdate() + { + if (player == null || cineCam == null) return; + + // 1. Lấy hướng player (yaw) + float playerYaw = player.eulerAngles.y; + + // 2. Lấy input delta (chuột / touch) để xoay camera thêm + Vector2 delta = GetInputDelta(); + yawOffset += delta.x * inputSpeed; + pitchOffset -= delta.y * inputSpeed; + pitchOffset = Mathf.Clamp(pitchOffset, clampPitchMin, clampPitchMax); + + // 3. Tính rotation cuối = playerYaw + yawOffset + float finalYaw = playerYaw + yawOffset; + float finalPitch = pitchOffset; + + // 4. Cập nhật vị trí + hướng camera + Quaternion rot = Quaternion.Euler(finalPitch, finalYaw, 0f); + Vector3 offset = rot * new Vector3(0, 0, -distance); + cineCam.transform.position = player.position + offset; + cineCam.transform.rotation = rot; + } + + Vector2 GetInputDelta() + { + // Nếu test trên editor / PC +#if UNITY_EDITOR || UNITY_STANDALONE + if (Input.GetMouseButtonDown(0)) + { + lastPointerPos = Input.mousePosition; + isDragging = true; + } + if (Input.GetMouseButtonUp(0)) + { + isDragging = false; + } + if (isDragging && Input.GetMouseButton(0)) + { + Vector2 cur = Input.mousePosition; + Vector2 delta = cur - lastPointerPos; + lastPointerPos = cur; + // Nếu chạm vùng joystick thì ignore + return delta; + } + return Vector2.zero; +#else + // Mobile: xử lý touch tương tự code bạn đã có + foreach (Touch t in Input.touches) + { + if (t.phase == TouchPhase.Began) + { + lastPointerPos = t.position; + isDragging = true; + } + else if (t.phase == TouchPhase.Moved && isDragging) + { + Vector2 cur = t.position; + Vector2 delta = cur - lastPointerPos; + lastPointerPos = cur; + if (RectTransformUtility.RectangleContainsScreenPoint(joystickArea, cur)) + return Vector2.zero; + return delta; + } + else if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled) + { + isDragging = false; + } + } + return Vector2.zero; +#endif + } + public void SetOrbitTarget(Transform target) + { + player = target; + } +} diff --git a/Assets/PerfectWorld/Scripts/Common/CinemachineTouchOrbit.cs.meta b/Assets/PerfectWorld/Scripts/Common/CinemachineTouchOrbit.cs.meta new file mode 100644 index 0000000000..f96c46f2f5 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Common/CinemachineTouchOrbit.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 21b5e267b2aeb7a46bf94bf71ca31c26 \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs b/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs index 70ef68c201..844721d8a3 100644 --- a/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs +++ b/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs @@ -1,4 +1,4 @@ -using BrewMonster; +using BrewMonster; using CSNetwork.GPDataType; using ModelRenderer.Scripts.GameData; using PerfectWorld.Scripts.Managers; @@ -39,6 +39,7 @@ public abstract class CECPlayer : CECObject public int m_iGender; // Gender protected bool m_bFashionMode; + protected int NUM_WEAPON_TYPE = 15; @@ -394,8 +395,8 @@ public abstract class CECPlayer : CECObject public void PlayAttackEffect(int idTarget, int idSkill, int skillLevel, int nDamage, uint dwModifier, int nAttackSpeed, ref int piAttackTime/* NULL */, int nSection = 0) { - /* if (!IsAllResReady()) - return;*/ + /* if (!IsAllResReady()) + return;*/ if (idSkill == 0) { @@ -535,8 +536,8 @@ public abstract class CECPlayer : CECObject szAct = EC_Utility.BuildActionName(action, 0, "Æð"); EventBus.PublishChannel(m_PlayerInfo.cid, new PlayActionEvent(szAct)); szAct = EC_Utility.BuildActionName(action, 0, "Âä"); - EventBus.PublishChannel(m_PlayerInfo.cid, new QueueActionEvent(szAct)); - //PlayNonSkillActionWithName(iAction, szAct, true, 200, true, ref pActFlag, COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX); + EventBus.PublishChannel(m_PlayerInfo.cid, new QueueActionEvent(szAct, ref pActFlag,true)); + //PlayNonSkillActionWithName(iAction, szAct, true, 200, true, ref pActFlag, COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX);gagága /* if (pRightHandWeapon != null && IsUsingMagicWeapon()) pRightHandWeapon.PlayActionByName(_GenWeaponActionName(szAct, m_iGender), 1.0f, true, 200, true, iAction, bHideFX); @@ -594,7 +595,7 @@ public abstract class CECPlayer : CECObject // ============================== PLAYER_ACTION stand_action = m_PlayerActions[(int)PLAYER_ACTION_TYPE.ACT_FIGHTSTAND]; szAct = EC_Utility.BuildActionName(stand_action, 0); - EventBus.PublishChannel(m_PlayerInfo.cid, new QueueActionEvent(szAct)); + EventBus.PublishChannel(m_PlayerInfo.cid, new QueueActionEvent(szAct, ref pActFlag,false)); /* QueueNonSkillActionWithName(ACT_FIGHTSTAND, szAct, 300, false, bHideFX, true); @@ -798,9 +799,13 @@ public struct PlayActionEvent public struct QueueActionEvent { public string AnimationName; - public QueueActionEvent(string animationName) + public bool PActFlag; + public bool IsHitAnim; + public QueueActionEvent(string animationName, ref bool pActFlag, bool isHitAnim) { this.AnimationName = animationName; + PActFlag = pActFlag; + IsHitAnim = isHitAnim; } } [Serializable] diff --git a/Assets/PerfectWorld/Scripts/NPC/CECNPCModelDefaultPolicy.cs b/Assets/PerfectWorld/Scripts/NPC/CECNPCModelDefaultPolicy.cs index 81e8d828fb..beb5d38035 100644 --- a/Assets/PerfectWorld/Scripts/NPC/CECNPCModelDefaultPolicy.cs +++ b/Assets/PerfectWorld/Scripts/NPC/CECNPCModelDefaultPolicy.cs @@ -22,7 +22,7 @@ public class CECNPCModelDefaultPolicy // Nếu là attack action thì thêm hậu tố if (CECNPC.IsAttackAction(iAct)) { - sb.Append(bAttackStart ? "Æð" : "Âä"); + sb.Append(bAttackStart ? EC_Utility.FixGBKString("Æð") : EC_Utility.FixGBKString("Âä")); } // Xử lý loại bỏ dấu nháy kép (nếu có) diff --git a/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs b/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs index a1d89d59de..75c2e54822 100644 --- a/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs +++ b/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs @@ -5,14 +5,23 @@ using UnityEngine; public class NPCVisual : MonoBehaviour { [SerializeField] NamedAnimancerComponent namedAnimancer; +#if UNITY_EDITOR + [SerializeField] bool isDebug; + public void DEBUG(string text) + { + if(!isDebug) return; + BMLogger.LogError(text); + } +#endif public bool TryPlayAction(string animationName) { - BMLogger.LogError("HoangDev: TryPlayAction: " + animationName); + DEBUG("HoangDev: TryPlayAction: " + animationName); if (namedAnimancer == null) return false; if (namedAnimancer.IsPlaying(animationName)) return false; return namedAnimancer.TryPlay(animationName) == null; } + public void InitNPCEventDoneHandler() { namedAnimancer = GetComponentInChildren(); diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index 147f6f09bc..f3e9204c67 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -319,7 +319,7 @@ namespace CSNetwork } var pCmdHeader = BitConverter.ToUInt16(byteArrHeader); //sss - BMLogger.LogError($"### GameDataSend: CMDID {pCmdHeader}"); + //BMLogger.LogError($"### GameDataSend: CMDID {pCmdHeader}"); int iHostID = _selectedRole.roleid; switch (pCmdHeader) { diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/NetworkManager.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/NetworkManager.cs index 459516adf6..ce7d352b98 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/NetworkManager.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/NetworkManager.cs @@ -430,8 +430,15 @@ namespace CSNetwork goto EndProcessing; // Use goto to jump to buffer compacting } + if (consumedBytes == -1) + { + _logger.Log(LogType.Info, + $"Protocol Decode returned -1 EOF {processingStream.IsEof}" + ); + } + // Check consumed bytes: If 0, it means Decode couldn't read a complete message (e.g. insufficient data) - if (consumedBytes == 0) + if (consumedBytes <= 0) { // No full protocol read, break and wait for more data processingStream.Position = streamPosBeforeDecode; // Reset position to before the failed Decode attempt @@ -445,7 +452,7 @@ namespace CSNetwork if (p != null) { // Successfully decoded a protocol - // _logger.Log(LogType.Info, $"Decoded: {p.GetType().Name}, consumed {consumedBytes} bytes (processed stream)"); + _logger.Log(LogType.Info, $"Decoded: {p.GetType().Name}, consumed {consumedBytes} bytes (processed stream)"); ProtocolReceived?.Invoke(p); // Fire event } // else: p is null, but consumedBytes > 0. This means a type 0 protocol was consumed successfully. diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/Protocol.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/Protocol.cs index 4b9e2b4607..f2228129c9 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/Protocol.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/Protocol.cs @@ -63,7 +63,7 @@ namespace CSNetwork.Protocols public static (Protocol? protocol, int consumedBytes) Decode(OctetsStream stream, int ignoreBytes = 0) { if (stream.IsEof) // Check if stream is already at end - return (null, 0); + return (null, -1); int initialPosition = stream.Position; // Store initial position for rollback diff --git a/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs b/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs index 36d0d24ca4..195131274a 100644 --- a/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs +++ b/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs @@ -54,7 +54,7 @@ namespace BrewMonster.UI } if (Input.GetKeyUp(KeyCode.Tab)) { - _usernameInputField.text = "test005"; + _usernameInputField.text = "test002"; _passwordInputField.text = "123456"; OnLoginButtonClicked(); } diff --git a/Assets/Scenes/NPCRender.unity b/Assets/Scenes/NPCRender.unity index 3b99004f1b..6ba66f0769 100644 --- a/Assets/Scenes/NPCRender.unity +++ b/Assets/Scenes/NPCRender.unity @@ -817,6 +817,10 @@ MonoBehaviour: - {fileID: 7400000, guid: 211cf985d64485e4ca42f7d8d6509e87, type: 2} - {fileID: 7400000, guid: caa9485da71a78b4da087ae69bf7120d, type: 2} - {fileID: 7400000, guid: 233ca05b3510f614e8b2ea31731dc298, type: 2} + - {fileID: 7400000, guid: e45130cf176245344a417eb0ddb79826, type: 2} + - {fileID: 7400000, guid: 3e4c04d71f4e90041b63b23d8537a208, type: 2} + - {fileID: 7400000, guid: c2fb725802130e449a0636acf8b1815d, type: 2} + - {fileID: 7400000, guid: b8a2d2fdc3fbd5a4ca393badcb53bbea, type: 2} --- !u!21 &19752687 Material: serializedVersion: 8 @@ -6791,7 +6795,9 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 96894795} - - component: {fileID: 96894794} + - component: {fileID: 96894799} + - component: {fileID: 96894798} + - component: {fileID: 96894797} m_Layer: 0 m_Name: Virtual Camera m_TagString: Untagged @@ -6799,59 +6805,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &96894794 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 96894793} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 45e653bab7fb20e499bda25e1b646fea, type: 3} - m_Name: - m_EditorClassIdentifier: - Priority: - Enabled: 0 - m_Value: 0 - OutputChannel: 1 - StandbyUpdate: 2 - m_StreamingVersion: 20241001 - m_LegacyPriority: 0 - m_LookAt: {fileID: 0} - m_Follow: {fileID: 0} - m_Lens: - FieldOfView: 40 - OrthographicSize: 10 - NearClipPlane: 0.1 - FarClipPlane: 5000 - Dutch: 0 - ModeOverride: 0 - GateFit: 2 - m_SensorSize: {x: 21.946, y: 16.002} - LensShift: {x: 0, y: 0} - FocusDistance: 10 - Iso: 200 - ShutterSpeed: 0.005 - Aperture: 16 - BladeCount: 5 - Curvature: {x: 2, y: 11} - BarrelClipping: 0.25 - Anamorphism: 0 - BlendHint: 0 - m_OnCameraLiveEvent: - m_PersistentCalls: - m_Calls: [] - m_ExcludedPropertiesInInspector: - - m_Script - m_LockStageInInspector: - m_LegacyTransitions: - m_BlendHint: 0 - m_InheritPosition: 0 - m_OnCameraLive: - m_PersistentCalls: - m_Calls: [] - m_ComponentOwner: {fileID: 294636156} --- !u!4 &96894795 Transform: m_ObjectHideFlags: 0 @@ -6864,10 +6817,100 @@ Transform: m_LocalPosition: {x: -769.91, y: 55.8, z: -268.54} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 294636156} + m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &96894797 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 96894793} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f38bda98361e1de48a4ca2bd86ea3c17, type: 3} + m_Name: + m_EditorClassIdentifier: + Composition: + ScreenPosition: {x: 0, y: 0} + DeadZone: + Enabled: 1 + Size: {x: 0, y: 0} + HardLimits: + Enabled: 1 + Size: {x: 0.8, y: 0.8} + Offset: {x: 0, y: 0} + CenterOnActivate: 1 + TargetOffset: {x: 0, y: 0, z: 0} + Damping: {x: 0.5, y: 0.5} + Lookahead: + Enabled: 0 + Time: 0 + Smoothing: 0 + IgnoreY: 0 +--- !u!114 &96894798 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 96894793} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b617507da6d07e749b7efdb34e1173e1, type: 3} + m_Name: + m_EditorClassIdentifier: + TrackerSettings: + BindingMode: 1 + PositionDamping: {x: 1, y: 1, z: 1} + AngularDampingMode: 0 + RotationDamping: {x: 0, y: 0, z: 0} + QuaternionDamping: 0 + FollowOffset: {x: 0, y: 0, z: -10} +--- !u!114 &96894799 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 96894793} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f9dfa5b682dcd46bda6128250e975f58, type: 3} + m_Name: + m_EditorClassIdentifier: + Priority: + Enabled: 0 + m_Value: 0 + OutputChannel: 1 + StandbyUpdate: 2 + m_StreamingVersion: 20241001 + m_LegacyPriority: 0 + Target: + TrackingTarget: {fileID: 0} + LookAtTarget: {fileID: 0} + CustomLookAtTarget: 0 + Lens: + FieldOfView: 40 + OrthographicSize: 10 + NearClipPlane: 0.1 + FarClipPlane: 5000 + Dutch: 0 + ModeOverride: 0 + PhysicalProperties: + GateFit: 2 + SensorSize: {x: 21.946, y: 16.002} + LensShift: {x: 0, y: 0} + FocusDistance: 10 + Iso: 200 + ShutterSpeed: 0.005 + Aperture: 16 + BladeCount: 5 + Curvature: {x: 2, y: 11} + BarrelClipping: 0.25 + Anamorphism: 0 + BlendHint: 0 --- !u!1 &96929143 GameObject: m_ObjectHideFlags: 0 @@ -20209,101 +20252,6 @@ Transform: m_Children: [] m_Father: {fileID: 1997511859} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &294636155 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 294636156} - - component: {fileID: 294636159} - - component: {fileID: 294636158} - - component: {fileID: 294636157} - m_Layer: 0 - m_Name: cm - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &294636156 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 294636155} - 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: 96894795} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &294636157 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 294636155} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fa7155796051b734daa718462081dc5f, type: 3} - m_Name: - m_EditorClassIdentifier: - m_BindingMode: 1 - m_FollowOffset: {x: 0, y: 0, z: -10} - m_XDamping: 1 - m_YDamping: 1 - m_ZDamping: 1 - m_AngularDampingMode: 0 - m_PitchDamping: 0 - m_YawDamping: 0 - m_RollDamping: 0 - m_AngularDamping: 0 ---- !u!114 &294636158 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 294636155} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f4044717213e31446939f7bd49c896ea, type: 3} - m_Name: - m_EditorClassIdentifier: - m_TrackedObjectOffset: {x: 0, y: 0, z: 0} - m_LookaheadTime: 0 - m_LookaheadSmoothing: 0 - m_LookaheadIgnoreY: 0 - m_HorizontalDamping: 0.5 - m_VerticalDamping: 0.5 - m_ScreenX: 0.5 - m_ScreenY: 0.5 - m_DeadZoneWidth: 0 - m_DeadZoneHeight: 0 - m_SoftZoneWidth: 0.8 - m_SoftZoneHeight: 0.8 - m_BiasX: 0 - m_BiasY: 0 - m_CenterOnActivate: 1 ---- !u!114 &294636159 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 294636155} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!28 &295683104 Texture2D: m_ObjectHideFlags: 0 @@ -138448,7 +138396,6 @@ GameObject: - component: {fileID: 1801883898} - component: {fileID: 1801883901} - component: {fileID: 1801883900} - - component: {fileID: 1801883902} m_Layer: 0 m_Name: CinemachineBrain m_TagString: Untagged @@ -138496,7 +138443,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1801883897} serializedVersion: 2 - m_LocalRotation: {x: 0.3826835, y: 7.6020495e-10, z: -3.1488723e-10, w: 0.92387956} + m_LocalRotation: {x: 0.3826835, y: 7.6020484e-10, z: -3.1488695e-10, w: 0.9238795} m_LocalPosition: {x: -769.91, y: 55.8, z: -268.54} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -138598,18 +138545,6 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: 0.022 ---- !u!114 &1801883902 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1801883897} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e4f309bde4ab64e6aafea4a0ca023b05, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &1803755932 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/WorldRender.unity b/Assets/Scenes/WorldRender.unity index e92e7951bb..3855a74db4 100644 --- a/Assets/Scenes/WorldRender.unity +++ b/Assets/Scenes/WorldRender.unity @@ -313127,6 +313127,7 @@ GameObject: - component: {fileID: 1235489763} - component: {fileID: 1235489762} - component: {fileID: 1235489761} + - component: {fileID: 1235489765} m_Layer: 0 m_Name: CinemachineCamera m_TagString: Untagged @@ -313240,6 +313241,26 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1235489765 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1235489760} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 21b5e267b2aeb7a46bf94bf71ca31c26, type: 3} + m_Name: + m_EditorClassIdentifier: + cineCam: {fileID: 1235489763} + joystickArea: {fileID: 0} + orbitTarget: {fileID: 0} + rotationSpeedX: 0.2 + rotationSpeedY: 0.15 + minPitch: -30 + maxPitch: 70 + distance: 10 --- !u!21 &1235671555 Material: serializedVersion: 8 diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 1a1f7dcfe9..0e080492fd 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -59,6 +59,7 @@ public class GameController : MonoBehaviour hostPlayer.InitCharacter(info); cinemachineCamera.Follow = hostPlayer.transform; cinemachineCamera.ForceCameraPosition(hostPlayer.transform.position, Quaternion.identity); + CinemachineTouchOrbit.Instance.SetOrbitTarget(hostPlayer.transform); //Vector3 pos = new Vector3(info.pos.x, info.pos.y, info.pos.z); //Vector3 posCam = pos; //posCam.z -= 10f; diff --git a/Assets/Scripts/PlayerVisual.cs b/Assets/Scripts/PlayerVisual.cs index 3b9d526de7..d999f85314 100644 --- a/Assets/Scripts/PlayerVisual.cs +++ b/Assets/Scripts/PlayerVisual.cs @@ -1,38 +1,40 @@ -using Animancer; +using Animancer; using BrewMonster; using System; +using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerVisual : MonoBehaviour { - [SerializeField] NamedAnimancerComponent namedAnimancer; + [SerializeField] NamedAnimancerComponent namedAnimancer; [SerializeField] private INFO _playerInfo; - [SerializeField] private AnimancerState _currentState; private readonly Queue _animationQueue = new Queue(); + [SerializeField] private bool pActFlag; + [SerializeField] private bool isHit; + private void PlayActionEventHandler(PlayActionEvent @event) { _currentState = namedAnimancer.TryPlay(@event.AnimationName); - if(_currentState == null) + if (_currentState == null) { - BMLogger.LogError("HoangDev: PlayActionEventHandler Failed "); + BMLogger.LogError("HoangDev: PlayActionEventHandler Failed " + @event.AnimationName); } } - public void InitHostPlayerEventDoneHandler() { namedAnimancer = GetComponentInChildren(); - if(namedAnimancer == null) + if (namedAnimancer == null) { BrewMonster.BMLogger.LogError("animancer == null"); return; } var player = GetComponentInParent(); - if(player == null) + if (player == null) { BrewMonster.BMLogger.LogError("player == null"); return; @@ -44,39 +46,49 @@ public class PlayerVisual : MonoBehaviour private void QueueActionEventHandler(QueueActionEvent @event) { - if(!EnqueueAnimation(@event.AnimationName)) + if (!EnqueueAnimation(@event)) { BMLogger.LogError("HoangDev : EnqueueAnimation Failed"); } } - public bool EnqueueAnimation(string animName) + private void Update() + { + PlayNext(); + } + public bool EnqueueAnimation(QueueActionEvent @event) { if (namedAnimancer == null) return false; - _animationQueue.Enqueue(animName); - if (!namedAnimancer.IsPlaying()) - PlayNext(); - else - { - if (_currentState == null) return false; - _currentState.Events.OnEnd = PlayNext; - } + BMLogger.LogError("HoangDev : @event.PActFlag1 :" + @event.PActFlag); + + _animationQueue.Enqueue(@event.AnimationName); + pActFlag = @event.PActFlag; + isHit = @event.IsHitAnim; return true; } - private void PlayNext() { if (_animationQueue.Count == 0) { return; } - + if(_currentState == null) return; + if(_currentState.IsPlaying) return; + if(isHit) + { + SetpActFlagTrue(); + isHit = false; + return; + } string animName = _animationQueue.Dequeue(); var state = namedAnimancer.TryPlay(animName); - // Khi clip kết thúc thì gọi tiếp cái kế tiếp - state.Events.OnEnd = PlayNext; } + private void SetpActFlagTrue() + { + pActFlag = true; + BMLogger.LogError("HoangDev : SetpActFlagTrue :"); + } private void OnDestroy() { EventBus.UnsubscribeAllInChannel(_playerInfo.cid);