mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Set different default speed for player and NPC actor
This commit is contained in:
1 parent
478b8f7f7a
commit
dfdc33c222
8 files changed
+38
-10
No files matched your search
@@ -268,7 +268,7 @@ namespace Core.DataReader.Scn
|
||||
public uint LoopAction;
|
||||
|
||||
// 移动速度
|
||||
public uint Speed;
|
||||
public uint GameBoxMoveSpeed;
|
||||
|
||||
[JsonIgnore]
|
||||
public uint[] Reserved; // 29 DWORDs
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Core.DataReader.Scn
|
||||
},
|
||||
NoTurn = reader.ReadUInt32(),
|
||||
LoopAction = reader.ReadUInt32(),
|
||||
Speed = reader.ReadUInt32(),
|
||||
GameBoxMoveSpeed = reader.ReadUInt32(),
|
||||
Reserved = reader.ReadUInt32Array(29),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
namespace Pal3.Actor
|
||||
{
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Data;
|
||||
using MetaData;
|
||||
using UnityEngine;
|
||||
@@ -105,6 +106,27 @@ namespace Pal3.Actor
|
||||
value : null;
|
||||
}
|
||||
|
||||
public float GetMoveSpeed(MovementMode movementMode)
|
||||
{
|
||||
if (Info.GameBoxMoveSpeed > 0)
|
||||
{
|
||||
return Info.GameBoxMoveSpeed / GameBoxInterpreter.GameBoxUnitToUnityUnit;
|
||||
}
|
||||
|
||||
if (Info.Kind == ScnActorKind.MainActor)
|
||||
{
|
||||
return movementMode == MovementMode.Run
|
||||
? ActorConstants.PlayerActorRunSpeed
|
||||
: ActorConstants.PlayerActorWalkSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
return movementMode == MovementMode.Run
|
||||
? ActorConstants.NpcActorRunSpeed
|
||||
: ActorConstants.NpcActorWalkSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
public float GetInteractionMaxDistance()
|
||||
{
|
||||
return Info.Kind switch
|
||||
|
||||
@@ -467,8 +467,7 @@ namespace Pal3.Actor
|
||||
Transform currentTransform = transform;
|
||||
Vector3 currentPosition = currentTransform.position;
|
||||
|
||||
// TODO: Use speed info from datascript\scene.txt file when _actor.Info.Speed == 0
|
||||
var moveSpeed = _actor.Info.Speed <= 0 ? (movementMode == MovementMode.Run ? 11f : 5f) : _actor.Info.Speed / 11f;
|
||||
float moveSpeed = _actor.GetMoveSpeed(movementMode);
|
||||
|
||||
if (!_actor.IsMainActor()) moveSpeed /= 2f;
|
||||
|
||||
|
||||
@@ -972,7 +972,7 @@ namespace Pal3.GamePlay
|
||||
var currentHeight = 0f;
|
||||
while (currentHeight < climbableHeight)
|
||||
{
|
||||
var delta = Time.deltaTime * ActorConstants.ActorClimbSpeed;
|
||||
var delta = Time.deltaTime * ActorConstants.PlayerActorClimbSpeed;
|
||||
currentHeight += delta;
|
||||
_playerActorGameObject.transform.position += new Vector3(0f, delta, 0f);
|
||||
yield return null;
|
||||
@@ -990,7 +990,7 @@ namespace Pal3.GamePlay
|
||||
var currentHeight = climbableHeight;
|
||||
while (currentHeight > 0f)
|
||||
{
|
||||
var delta = Time.deltaTime * ActorConstants.ActorClimbSpeed;
|
||||
var delta = Time.deltaTime * ActorConstants.PlayerActorClimbSpeed;
|
||||
currentHeight -= delta;
|
||||
_playerActorGameObject.transform.position -= new Vector3(0f, delta, 0f);
|
||||
yield return null;
|
||||
|
||||
@@ -196,7 +196,11 @@ namespace Pal3.MetaData
|
||||
{
|
||||
public const int PlayerActorVirtualID = -1; // or 255 as byte value
|
||||
|
||||
public const float ActorClimbSpeed = 2f;
|
||||
public const float PlayerActorClimbSpeed = 2f;
|
||||
public const float PlayerActorWalkSpeed = 5f;
|
||||
public const float PlayerActorRunSpeed = 10f;
|
||||
public const float NpcActorWalkSpeed = 5f;
|
||||
public const float NpcActorRunSpeed = 9f;
|
||||
|
||||
#if PAL3
|
||||
public const string LongKuiBlueModeActorName = "105";
|
||||
|
||||
@@ -352,11 +352,14 @@ namespace Pal3
|
||||
private void Start()
|
||||
{
|
||||
Debug.Log($"[{nameof(Pal3)}] Game started.");
|
||||
|
||||
_mainMenu.ShowInitView();
|
||||
_mainMenu.ShowMenu();
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
// Check latest version and notify if a newer version is found.
|
||||
StartCoroutine(CheckLatestVersionAndNotify());
|
||||
#endif
|
||||
}
|
||||
|
||||
private IEnumerator CheckLatestVersionAndNotify()
|
||||
|
||||
@@ -61,10 +61,10 @@ namespace Pal3.Scene.SceneObjects
|
||||
movementController.CancelMovement();
|
||||
|
||||
var actorController = playerActorGameObject.GetComponent<ActorController>();
|
||||
uint originalSpeed = actorController.GetActor().Info.Speed;
|
||||
uint originalSpeed = actorController.GetActor().Info.GameBoxMoveSpeed;
|
||||
|
||||
// Temporarily set the speed to a higher value to make the actor slide
|
||||
actorController.GetActor().Info.Speed = ACTOR_SLIDE_SPEED;
|
||||
actorController.GetActor().Info.GameBoxMoveSpeed = ACTOR_SLIDE_SPEED;
|
||||
|
||||
movementController.SetupPath(waypoints, MovementMode.Run, EndOfPathActionType.Idle, ignoreObstacle: true);
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
}
|
||||
|
||||
// Restore the original speed
|
||||
actorController.GetActor().Info.Speed = originalSpeed;
|
||||
actorController.GetActor().Info.GameBoxMoveSpeed = originalSpeed;
|
||||
|
||||
ExecuteScriptIfAny();
|
||||
_isInteractionInProgress = false;
|
||||
|
||||
Reference in new issue
Block a user