diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_HPWork.cs b/Assets/PerfectWorld/Scripts/Managers/EC_HPWork.cs index 4e52b0c9df..367f7042a7 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_HPWork.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_HPWork.cs @@ -816,6 +816,27 @@ namespace BrewMonster.Scripts { return IsWorkRunning(CECHPWork.Host_work_ID.WORK_PICKUP); } + + public bool IsMoving() + { + bool result = false; + if (ValidatePriority(m_iCurPriority)) + { + WorkList workList = m_WorkStack[m_iCurPriority]; + if(workList != null) + { + for (int i = 0; i < workList.Count; ++ i) + { + if (workList[i].IsMoving()) + { + result = true; + break; + } + } + } + } + return result; + } } public abstract class CECHPWorkPostTickCommand { diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_HostInputFilter.cs b/Assets/PerfectWorld/Scripts/Managers/EC_HostInputFilter.cs index 58efffce4d..bf231e0f26 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_HostInputFilter.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_HostInputFilter.cs @@ -116,149 +116,149 @@ namespace BrewMonster // Note: This would require GetMouseOnPateTextNPC implementation // For now, we'll proceed with raycast - if (Physics.Raycast(ray, out hit)) - { - // Check if hit terrain, building, or forest (no CECObject component) - if (!hit.collider.gameObject.TryGetComponent(out CECObject clickedObject)) + if (Physics.RaycastNonAlloc(ray, hits) > 0) { - //ENABLE LATER - CURRENT WORKING FINE - // Hit terrain / building / forest / Hit terrain - // if (m_pWorkMan.IsSitting()) - // { - // UnityGameSession.c2s_CmdStandUp(); - // return; - // } - // if (!CanDo(ActionCanDo.CANDO_MOVETO)) - // return; - // - // // Calculate move destination / Hit terrain - // Vector3 vMoveDest = hit.point; - // A3DVECTOR3 a3dMoveDest = EC_Utility.ToA3DVECTOR3(vMoveDest); - // - // if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) - // { - // // Ctrl pressed - direct goto / Ctrl pressed - // // Note: c2s_CmdGoto not implemented, using work system instead - // // UnityGameSession.c2s_CmdGoto(a3dMoveDest.x, a3dMoveDest.y, a3dMoveDest.z); - // // For now, use work system even with Ctrl - // } - // // else removed - always use work system - // { - // CECHPWork pWork = m_pWorkMan.GetWork(CECHPWork.Host_work_ID.WORK_MOVETOPOS); - // if (pWork != null) - // { - // CECHPWorkMove pWorkMove = pWork as CECHPWorkMove; - // if (pWorkMove != null) - // { - // pWorkMove.SetDestination(CECHPWorkMove.DestTypes.DEST_2D, a3dMoveDest); - // pWorkMove.SetUseAutoMoveDialog(false); - // // Note: PlayMoveTargetGFX would go here if implemented - // } - // } - // else if (m_pWorkMan.CanStartWork(CECHPWork.Host_work_ID.WORK_MOVETOPOS)) - // { - // // If destination is too near, ignore it. / If destination is too near, ignore it. - // A3DVECTOR3 vDist = a3dMoveDest - GetPos(); - // float fDistH = (float)Math.Sqrt(vDist.x * vDist.x + vDist.z * vDist.z); - // if (fDistH > 0.5f) - // { - // CECHPWorkMove pWorkMove = (CECHPWorkMove)m_pWorkMan.CreateWork(CECHPWork.Host_work_ID.WORK_MOVETOPOS); - // pWorkMove.SetDestination(CECHPWorkMove.DestTypes.DEST_2D, a3dMoveDest); - // // Note: PlayMoveTargetGFX would go here if implemented - // m_pWorkMan.StartWork_p1(pWorkMove); - // } - // } - // } - return; - } - - // Hit an object / Hit a object - int idObject = CECObject.GetObjectID(clickedObject); - if (idObject != 0) - { - // Check if it's a matter object / Check if it's a matter object - if (clickedObject.IsMatter()) + // Check if hit terrain, building, or forest (no CECObject component) + if (!hits[0].collider.gameObject.TryGetComponent(out CECObject clickedObject)) { - CECMatter pMatter = clickedObject as CECMatter; - if (pMatter != null) - { - idTraceTarget = pMatter.GetMatterID(); - // Check if it's a mine (gather) or item (pickup) / Check if it's a mine (gather) or item (pickup) - bool bIsMine = pMatter.IsMine(); - iTraceReason = bIsMine ? CECHPWorkTrace.Trace_reason.TRACE_GATHER : CECHPWorkTrace.Trace_reason.TRACE_PICKUP; - } + //ENABLE LATER - CURRENT WORKING FINE + // Hit terrain / building / forest / Hit terrain + // if (m_pWorkMan.IsSitting()) + // { + // UnityGameSession.c2s_CmdStandUp(); + // return; + // } + // if (!CanDo(ActionCanDo.CANDO_MOVETO)) + // return; + // + // // Calculate move destination / Hit terrain + // Vector3 vMoveDest = hit.point; + // A3DVECTOR3 a3dMoveDest = EC_Utility.ToA3DVECTOR3(vMoveDest); + // + // if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) + // { + // // Ctrl pressed - direct goto / Ctrl pressed + // // Note: c2s_CmdGoto not implemented, using work system instead + // // UnityGameSession.c2s_CmdGoto(a3dMoveDest.x, a3dMoveDest.y, a3dMoveDest.z); + // // For now, use work system even with Ctrl + // } + // // else removed - always use work system + // { + // CECHPWork pWork = m_pWorkMan.GetWork(CECHPWork.Host_work_ID.WORK_MOVETOPOS); + // if (pWork != null) + // { + // CECHPWorkMove pWorkMove = pWork as CECHPWorkMove; + // if (pWorkMove != null) + // { + // pWorkMove.SetDestination(CECHPWorkMove.DestTypes.DEST_2D, a3dMoveDest); + // pWorkMove.SetUseAutoMoveDialog(false); + // // Note: PlayMoveTargetGFX would go here if implemented + // } + // } + // else if (m_pWorkMan.CanStartWork(CECHPWork.Host_work_ID.WORK_MOVETOPOS)) + // { + // // If destination is too near, ignore it. / If destination is too near, ignore it. + // A3DVECTOR3 vDist = a3dMoveDest - GetPos(); + // float fDistH = (float)Math.Sqrt(vDist.x * vDist.x + vDist.z * vDist.z); + // if (fDistH > 0.5f) + // { + // CECHPWorkMove pWorkMove = (CECHPWorkMove)m_pWorkMan.CreateWork(CECHPWork.Host_work_ID.WORK_MOVETOPOS); + // pWorkMove.SetDestination(CECHPWorkMove.DestTypes.DEST_2D, a3dMoveDest); + // // Note: PlayMoveTargetGFX would go here if implemented + // m_pWorkMan.StartWork_p1(pWorkMove); + // } + // } + // } + return; } - // Check if it's a dynamic object / Check if it's a dynamic object - // else if (clickedObject.gameObject.CompareTag("DynamicObject")) // ECENT_DYN_OBJ - // { - // return; // Dynamic objects are not clickable - // } - else + + // Hit an object / Hit a object + int idObject = CECObject.GetObjectID(clickedObject); + if (idObject != 0) { - // NPC or Player / NPC or Player - CECNPC pNPC = EC_ManMessageMono.Instance.CECNPCMan.GetNPC(idObject); - if (pNPC != null) + // Check if it's a matter object / Check if it's a matter object + if (clickedObject.IsMatter()) { - // Msg.dwParam4 is double click flag / Msg.dwParam4 is double click flag - if (!pNPC.IsDead() && m_idSelTarget == idObject) + CECMatter pMatter = clickedObject as CECMatter; + if (pMatter != null) { - idTraceTarget = idObject; + idTraceTarget = pMatter.GetMatterID(); + // Check if it's a mine (gather) or item (pickup) / Check if it's a mine (gather) or item (pickup) + bool bIsMine = pMatter.IsMine(); + iTraceReason = bIsMine ? CECHPWorkTrace.Trace_reason.TRACE_GATHER : CECHPWorkTrace.Trace_reason.TRACE_PICKUP; + } + } + // Check if it's a dynamic object / Check if it's a dynamic object + // else if (clickedObject.gameObject.CompareTag("DynamicObject")) // ECENT_DYN_OBJ + // { + // return; // Dynamic objects are not clickable + // } + else + { + // NPC or Player / NPC or Player + CECNPC pNPC = EC_ManMessageMono.Instance.CECNPCMan.GetNPC(idObject); + if (pNPC != null) + { + // Msg.dwParam4 is double click flag / Msg.dwParam4 is double click flag + if (!pNPC.IsDead() && m_idSelTarget == idObject) + { + idTraceTarget = idObject; + } + else + { + idSelTarget = idObject; + } + + if (idTraceTarget != 0) + { + // bForceAttack = glb_GetForceAttackFlag(&Msg.dwParam3); + if (AttackableJudge(idObject, bForceAttack) == 1) + iTraceReason = CECHPWorkTrace.Trace_reason.TRACE_ATTACK; + else if (pNPC.IsServerNPC()) + { + if (!IsInBattle() || InSameBattleCamp(pNPC)) + iTraceReason = CECHPWorkTrace.Trace_reason.TRACE_TALK; + } + } } else { - idSelTarget = idObject; - } + // pCDS.m_RayTraceRt.iEntity == ECENT_PLAYER / pCDS.m_RayTraceRt.iEntity == ECENT_PLAYER + CECPlayer pPlayer = EC_ManMessageMono.Instance.EC_ManPlayer.GetPlayer(idObject); - if (idTraceTarget != 0) - { - // bForceAttack = glb_GetForceAttackFlag(&Msg.dwParam3); - if (AttackableJudge(idObject, bForceAttack) == 1) - iTraceReason = CECHPWorkTrace.Trace_reason.TRACE_ATTACK; - else if (pNPC.IsServerNPC()) + // 1. Msg.dwParam4 is double click flag. / 1. Msg.dwParam4 is double click flag. + // 2. Buddy player counld't be traced / 2. Buddy player counld't be traced + if (pPlayer != null && !pPlayer.IsDead() /*&& pPlayer.GetCharacterID() != m_iBuddyId*/ && + (m_idSelTarget == idObject /*|| (Msg.dwParam4 && m_idUCSelTarget == idObject)*/)) { - if (!IsInBattle() || InSameBattleCamp(pNPC)) + idTraceTarget = idObject; + //bForceAttack = glb_GetForceAttackFlag(&Msg.dwParam3); + + if (AttackableJudge(idObject, bForceAttack) == 1) + iTraceReason = CECHPWorkTrace.Trace_reason.TRACE_ATTACK; + else if (pPlayer.GetBoothState() != 0) iTraceReason = CECHPWorkTrace.Trace_reason.TRACE_TALK; } + else if (pPlayer != null) + { + idSelTarget = idObject; + } } - } - else - { - // pCDS.m_RayTraceRt.iEntity == ECENT_PLAYER / pCDS.m_RayTraceRt.iEntity == ECENT_PLAYER - CECPlayer pPlayer = EC_ManMessageMono.Instance.EC_ManPlayer.GetPlayer(idObject); - // 1. Msg.dwParam4 is double click flag. / 1. Msg.dwParam4 is double click flag. - // 2. Buddy player counld't be traced / 2. Buddy player counld't be traced - if (pPlayer != null && !pPlayer.IsDead() /*&& pPlayer.GetCharacterID() != m_iBuddyId*/ && - (m_idSelTarget == idObject /*|| (Msg.dwParam4 && m_idUCSelTarget == idObject)*/)) + // cancel this action if not selectable / cancel this action if not selectable + if (!CanSelectTarget(idTraceTarget)) { - idTraceTarget = idObject; - //bForceAttack = glb_GetForceAttackFlag(&Msg.dwParam3); - - if (AttackableJudge(idObject, bForceAttack) == 1) - iTraceReason = CECHPWorkTrace.Trace_reason.TRACE_ATTACK; - else if (pPlayer.GetBoothState() != 0) - iTraceReason = CECHPWorkTrace.Trace_reason.TRACE_TALK; + return; } - else if (pPlayer != null) - { - idSelTarget = idObject; - } - } - // cancel this action if not selectable / cancel this action if not selectable - if (!CanSelectTarget(idTraceTarget)) - { - return; + // Check for wiki monster / Check for wiki monster + // Note: CDlgAutoHelp::IsAutoHelp() check would go here if implemented + // if (CDlgAutoHelp.IsAutoHelp() && pNPC != null && pNPC.IsMonsterNPC()) + // bWikiMonster = true; } - - // Check for wiki monster / Check for wiki monster - // Note: CDlgAutoHelp::IsAutoHelp() check would go here if implemented - // if (CDlgAutoHelp.IsAutoHelp() && pNPC != null && pNPC.IsMonsterNPC()) - // bWikiMonster = true; } } } - } /*else { // Nothing is clicked / Nothing is clicked diff --git a/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs b/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs index e934330b0b..bc6ca91f7a 100644 --- a/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs +++ b/Assets/PerfectWorld/Scripts/Move/CECPlayer.cs @@ -171,7 +171,7 @@ namespace BrewMonster m_PlayerActions = _default_actions; m_iShape = 0; m_aEquips = new int[(int)IndexOfIteminEquipmentInventory.SIZE_ALL_EQUIPIVTR]; - queueActionEvent = new QueueActionEvent("", null, false, null,200); + queueActionEvent = new QueueActionEvent("", null, false, null, 200); } /// This function will get the coressponding model player for the player based on the profession and gender @@ -263,7 +263,7 @@ namespace BrewMonster { return m_PlayerInfo.cid; } - + private static void BuildActionList() { if (_default_actions == null) @@ -389,7 +389,7 @@ namespace BrewMonster { return PlayActionWithConfig(iAction, 0, bRestart, iTransTime, bQueue); } - public bool PlayAction(int iAction,int actionConfigID, bool bRestart = true, int iTransTime = 200, bool bQueue = false) + public bool PlayAction(int iAction, int actionConfigID, bool bRestart = true, int iTransTime = 200, bool bQueue = false) { return PlayActionWithConfig(iAction, actionConfigID, bRestart, iTransTime, bQueue); } @@ -596,9 +596,9 @@ namespace BrewMonster // “起�? 动作(挥起) szAct = EC_Utility.BuildActionName(action, weapon_type, "起"); int iTransTime = 200; - EventBus.PublishChannel(m_PlayerInfo.cid, new PlayActionEvent(szAct,iTransTime)); + EventBus.PublishChannel(m_PlayerInfo.cid, new PlayActionEvent(szAct, iTransTime)); szAct = EC_Utility.BuildActionName(action, weapon_type, "落"); - queueActionEvent.SetData(szAct, SetApplyDamage, true, attackEvent,iTransTime); + queueActionEvent.SetData(szAct, SetApplyDamage, true, attackEvent, iTransTime); EventBus.PublishChannelClass(m_PlayerInfo.cid, queueActionEvent); //PlayNonSkillActionWithName(iAction, szAct, true, 200, true, ref pActFlag, COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX);gagága /* @@ -659,7 +659,7 @@ namespace BrewMonster PLAYER_ACTION stand_action = m_PlayerActions[(int)PLAYER_ACTION_TYPE.ACT_FIGHTSTAND]; szAct = EC_Utility.BuildActionName(stand_action, 0); int iTranstime = 200; - queueActionEvent.SetData(szAct, SetApplyDamage, false, attackEvent,iTranstime); + queueActionEvent.SetData(szAct, SetApplyDamage, false, attackEvent, iTranstime); EventBus.PublishChannelClass(m_PlayerInfo.cid, queueActionEvent); /* QueueNonSkillActionWithName(ACT_FIGHTSTAND, szAct, 300, false, bHideFX, true); @@ -1520,24 +1520,24 @@ namespace BrewMonster m_ExtProps.df = (ROLEEXTPROP_DEF)pData; break; - default: - //ASSERT(0); - return; + default: + //ASSERT(0); + return; + } } - } - #region Team + #region Team - // Get team to which this player belongs to - // public CECTeam GetTeam() { return m_pTeam; } + // Get team to which this player belongs to + // public CECTeam GetTeam() { return m_pTeam; } - #endregion - - public static bool IsMoveStandAction(int action) - { - // tương đương: const static int s_MoveStandAction[] - PLAYER_ACTION_TYPE[] s_MoveStandAction = + #endregion + + public static bool IsMoveStandAction(int action) { + // tương đương: const static int s_MoveStandAction[] + PLAYER_ACTION_TYPE[] s_MoveStandAction = + { PLAYER_ACTION_TYPE.ACT_RUN, PLAYER_ACTION_TYPE.ACT_WALK, PLAYER_ACTION_TYPE.ACT_FLY, @@ -1551,22 +1551,58 @@ namespace BrewMonster PLAYER_ACTION_TYPE.ACT_HANGINWATER, }; - int begin = 0; - int end = s_MoveStandAction.Length - 1; + int begin = 0; + int end = s_MoveStandAction.Length - 1; - for (int i = begin; i < end; i++) - { - if ((int)s_MoveStandAction[i] == action) - return true; + for (int i = begin; i < end; i++) + { + if ((int)s_MoveStandAction[i] == action) + return true; + } + + return false; } - return false; + public int GetLowerBodyAction() + { + return m_pActionController?.GetLowerBodyAction() ?? -1; + } + + // Check water moving environment + public bool CheckWaterMoveEnv(A3DVECTOR3 vPos, float fWaterHei, float fGndHei) + { + + bool bRet = false; + /* if (vPos.y < fWaterHei - m_MoveConst.fShoreDepth) + bRet = true; + else if (vPos.y < fWaterHei && fWaterHei - fGndHei > m_MoveConst.fShoreDepth) + bRet = true; + */ + // if (vPos.y < fWaterHei - m_MoveConst.fWaterSurf - m_aabb.Extents.y) + // if (vPos.y < fWaterHei - m_MoveConst.fWaterSurf + 0.01f) + + /* + if (vPos.y < fWaterHei - m_MoveConst.fShoreDepth) + bRet = true; + else if (vPos.y < fWaterHei - m_MoveConst.fWaterSurf + 0.01f && fWaterHei - fGndHei > m_MoveConst.fShoreDepth) + bRet = true; + */ + + //@note : modify the water test. By Kuiwu[12/10/2005] + if (vPos.y + m_aabbServer.Extents.y= 0.2f ) + else if (vPos.y + m_aabbServer.Extents.y= 0.01f ) + { + bRet = true; + } + + return bRet; + + } } - public int GetLowerBodyAction() - { - return m_pActionController?.GetLowerBodyAction() ?? -1; - } -} public struct PlayActionEvent { @@ -1592,23 +1628,23 @@ namespace BrewMonster public bool IsHitAnim; public QueueActionEvent(string animationName, Action setFlag, bool isHitAnim, - CECAttackEvent attackEvent,int iTransTime) + CECAttackEvent attackEvent, int iTransTime) { this.AnimationName = animationName; SetFlag = setFlag; IsHitAnim = isHitAnim; AttackEvent = attackEvent; - ITransTime = iTransTime; + ITransTime = iTransTime; } public void SetData(string animationName, Action setFlag, bool isHitAnim, - CECAttackEvent attackEvent,int iTransTime) + CECAttackEvent attackEvent, int iTransTime) { this.AnimationName = animationName; SetFlag = setFlag; IsHitAnim = isHitAnim; AttackEvent = attackEvent; - ITransTime = iTransTime; + ITransTime = iTransTime; } } public enum PLAYER_ACTION_TYPE diff --git a/Assets/Scenes/a61.unity b/Assets/Scenes/a61.unity index 2f694c887f..eb56b17010 100644 --- a/Assets/Scenes/a61.unity +++ b/Assets/Scenes/a61.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:107cb05c7bf60ae1c799ecf263afb7aaa491784495f6dafc9daf900f23396195 -size 200763028 +oid sha256:6bfb2c87e34e7367378cc1fd29debe319ccba7a1b9da2ebe55840de35cbbdeb9 +size 200764152 diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index fefe598b68..2ffc155f5b 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -136,10 +136,10 @@ namespace BrewMonster // cache tùy chọn (không bắt buộc) float ccRadius, ccSkin; - RaycastHit lastGroundHit; + //RaycastHit lastGroundHit; Camera mainCam; Ray ray; - RaycastHit hit; + RaycastHit[] hits = new RaycastHit[5]; private BaseVfxObject m_pSelectedGFX; private BaseVfxObject m_pHoverGFX; @@ -339,51 +339,51 @@ namespace BrewMonster m_MoveCtrl.SendStopMoveCmd(playerTransform.position, 5f, (int)GPMoveMode.GP_MOVE_WALK); } - public void HandleMovement() - { - // 1) Kiểm tra grounded bằng SphereCast ngắn dựa trên radius + skinWidth - isGrounded = GroundCheck(out lastGroundHit); - m_GndInfo.bOnGround = isGrounded; - // 2) Input tạm thời: giữ nguyên như bạn - //if (UnityEngine.Input.GetKeyDown(KeyCode.LeftShift)) SetStatusRun(true); - //if (UnityEngine.Input.GetKeyUp(KeyCode.LeftShift)) SetStatusRun(false); - //if (UnityEngine.Input.GetKeyDown(KeyCode.Space)) HandleJump(); + //public void HandleMovement() + //{ + // // 1) Kiểm tra grounded bằng SphereCast ngắn dựa trên radius + skinWidth + // isGrounded = GroundCheck(out lastGroundHit); + // m_GndInfo.bOnGround = isGrounded; + // // 2) Input tạm thời: giữ nguyên như bạn + // //if (UnityEngine.Input.GetKeyDown(KeyCode.LeftShift)) SetStatusRun(true); + // //if (UnityEngine.Input.GetKeyUp(KeyCode.LeftShift)) SetStatusRun(false); + // //if (UnityEngine.Input.GetKeyDown(KeyCode.Space)) HandleJump(); - // 3) Trọng lực / sticky - if (isGrounded && playerVelocity.y < 0f) - { - // Đè nhẹ để bám đất (tránh nhấp-nháy) - playerVelocity.y = -2f; - } - else - { - playerVelocity.y += gravityValue * Time.deltaTime; - } + // // 3) Trọng lực / sticky + // if (isGrounded && playerVelocity.y < 0f) + // { + // // Đè nhẹ để bám đất (tránh nhấp-nháy) + // playerVelocity.y = -2f; + // } + // else + // { + // playerVelocity.y += gravityValue * Time.deltaTime; + // } - // 4) Chuyển động phẳng - float x = joystick.Horizontal; - float z = joystick.Vertical; + // // 4) Chuyển động phẳng + // float x = joystick.Horizontal; + // float z = joystick.Vertical; - Vector3 move = new Vector3(x, 0, z); - move = Vector3.ClampMagnitude(move, 1f); - if (move != Vector3.zero) - { - Vector3 finalMove = (move * playerSpeed) + (playerVelocity.y * Vector3.up); - controller.Move(finalMove * Time.deltaTime); - transform.forward = move; - m_MoveCtrl.GroundMove(Time.deltaTime); - m_MoveCtrl.SendMoveCmd(playerTransform.position, controller.velocity, (int)GPMoveMode.GP_MOVE_RUN); - m_aabb.Center = EC_Utility.ToA3DVECTOR3(playerTransform.position) + - new A3DVECTOR3(0.0f, m_aabb.Extents.y, 0.0f); - m_aabb.CompleteMinsMaxs(); - m_aabbServer.Center = EC_Utility.ToA3DVECTOR3(playerTransform.position) + - new A3DVECTOR3(0.0f, m_aabbServer.Extents.y, 0.0f); - m_aabbServer.CompleteMinsMaxs(); - } - else - { - } - } + // Vector3 move = new Vector3(x, 0, z); + // move = Vector3.ClampMagnitude(move, 1f); + // if (move != Vector3.zero) + // { + // Vector3 finalMove = (move * playerSpeed) + (playerVelocity.y * Vector3.up); + // controller.Move(finalMove * Time.deltaTime); + // transform.forward = move; + // m_MoveCtrl.GroundMove(Time.deltaTime); + // m_MoveCtrl.SendMoveCmd(playerTransform.position, controller.velocity, (int)GPMoveMode.GP_MOVE_RUN); + // m_aabb.Center = EC_Utility.ToA3DVECTOR3(playerTransform.position) + + // new A3DVECTOR3(0.0f, m_aabb.Extents.y, 0.0f); + // m_aabb.CompleteMinsMaxs(); + // m_aabbServer.Center = EC_Utility.ToA3DVECTOR3(playerTransform.position) + + // new A3DVECTOR3(0.0f, m_aabbServer.Extents.y, 0.0f); + // m_aabbServer.CompleteMinsMaxs(); + // } + // else + // { + // } + //} private void JoystickRelease(JoystickRealeaseEvent joystickRealeaseEvent) { @@ -2859,15 +2859,15 @@ namespace BrewMonster Vector3 startPoint = EC_Utility.ToVector3(vPos); Vector3 dir = EC_Utility.ToVector3(vPos) + Vector3.down; float fTerrainHeight = 0f; - if (Physics.Raycast(startPoint, dir, out hit, layerGround)) + if (Physics.RaycastNonAlloc(startPoint, dir, hits, layerGround) > 0) { - fTerrainHeight = Vector3.Distance(hit.point, startPoint); + fTerrainHeight = Vector3.Distance(hits[0].point, startPoint); } float fWaterHeight = 0f; - if (Physics.Raycast(startPoint, dir, out hit, layerWater)) + if (Physics.RaycastNonAlloc(startPoint, dir, hits, layerWater) > 0) { - fWaterHeight = Vector3.Distance(hit.point, startPoint); + fWaterHeight = Vector3.Distance(hits[0].point, startPoint); } if (fWaterHeight <= fTerrainHeight) break; @@ -4221,11 +4221,11 @@ namespace BrewMonster return m_pWorkMan.IsPassiveMoving(); } - public void SetGroundInfoClient() - { - isGrounded = GroundCheck(out lastGroundHit); - m_GndInfo.bOnGround = isGrounded; - } + //public void SetGroundInfoClient() + //{ + // isGrounded = GroundCheck(out lastGroundHit); + // m_GndInfo.bOnGround = isGrounded; + //} public void SetRotationHP(Vector3 dir) { @@ -5068,13 +5068,19 @@ namespace BrewMonster A3DVECTOR3 vTestPos = vPos + EC_Utility.ToA3DVECTOR3(g_vAxisY) * m_aabbServer.Extents.y; VertRayTrace(EC_Utility.ToVector3(vTestPos), ref vGndPos, ref m_GndInfo.vGndNormal, 1000f); m_GndInfo.fGndHei = vGndPos.y; - //m_GndInfo.fWaterHei = pWorld.GetWaterHeight(vTestPos); + + if(Physics.RaycastNonAlloc(EC_Utility.ToVector3(vTestPos), Vector3.down, hits, 1000f, 1<<8) > 0) + { + m_GndInfo.fWaterHei = hits[0].point.y; + } VertAABBTrace(EC_Utility.ToVector3(vTestPos), EC_Utility.ToVector3(m_aabbServer.Extents), ref vAABBGnd, ref m_GndInfo.vGndNormal, 1000f); vAABBGnd.y -= m_aabbServer.Extents.y; int iNewEnv = Move_environment.MOVEENV_GROUND; + if (CheckWaterMoveEnv(vPos, m_GndInfo.fWaterHei, vAABBGnd.y)) + iNewEnv = Move_environment.MOVEENV_WATER; if (iNewEnv == Move_environment.MOVEENV_GROUND && GetPos().y - vAABBGnd.y < 0.2f && bIsInAir && EC_Utility.ToVector3(GetPos()) != m_MoveCtrl.GetLastSevPos()) @@ -5137,18 +5143,18 @@ namespace BrewMonster } } } - //else if (iNewEnv == MOVEENV_WATER) - //{ - // m_CDRInfo.fYVel = 0.0f; + else if (iNewEnv == Move_environment.MOVEENV_WATER) + { + m_CDRInfo.fYVel = 0.0f; - // if (m_iMoveMode == MOVE_SLIDE) - // { - // if (m_pWorkMan.IsMoving()) - // m_iMoveMode = MOVE_MOVE; - // else - // m_iMoveMode = MOVE_STAND; - // } - //} + if (m_iMoveMode == (int)MoveMode.MOVE_SLIDE) + { + if (m_pWorkMan.IsMoving()) + m_iMoveMode = (int)MoveMode.MOVE_MOVE; + else + m_iMoveMode = (int)MoveMode.MOVE_STAND; + } + } m_iMoveEnv = iNewEnv; } @@ -5163,13 +5169,13 @@ namespace BrewMonster LayerMask layerMaskTerrain = 1 << 6; LayerMask layerMaskBush = 1 << 7; - if (Physics.Raycast(vPos, (vPos + Vector3.down), out hit, layerMaskTerrain)) + if (Physics.RaycastNonAlloc(vPos, (vPos + Vector3.down), hits, layerMaskTerrain) > 0) { - vTerrainPos = hit.point; - vTerrainNormal = hit.normal; + vTerrainPos = hits[0].point; + vTerrainNormal = hits[0].normal; } - if (Physics.Raycast(vPos, (vPos + Vector3.down), out hit, DeltaY, layerMaskTerrain)) + if (Physics.RaycastNonAlloc(vPos, (vPos + Vector3.down), hits, DeltaY, layerMaskTerrain) > 0) { if (vBuildingPos.y > vTerrainPos.y) { @@ -5197,16 +5203,16 @@ namespace BrewMonster vHitPos.y -= DeltaY; LayerMask layerMask = 1 << 6 | 1 << 7; - if (!Physics.BoxCast(vCenter, vExt, (vCenter + Vector3.down).normalized, - out hit, transform.rotation, DeltaY, layerMask)) + if (Physics.BoxCastNonAlloc(vCenter, vExt, (vCenter + Vector3.down).normalized, + hits, transform.rotation, DeltaY, layerMask) == 0) { vHitPos = vCenter; vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up); } else { - vHitPos = hit.point; - vHitNormal = EC_Utility.ToA3DVECTOR3(hit.normal); + vHitPos = hits[0].point; + vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal); } }