camera_system #5
@ -17,7 +17,7 @@ public async void PostInit()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ItemDataSo = await AssetManager.LoadAsset<ItemDataSo>("ItemDataSo");
|
ItemDataSo = await AssetManager.LoadAsset<ItemDataSo>(DataConstants.ItemDataSo);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -12,10 +12,10 @@ private async void Start()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var playerPrefab = await AssetManager.LoadAsset<GameObject>("RestaurantPlayer");
|
var playerPrefab = await AssetManager.LoadAsset<GameObject>(CommonConstants.RestaurantPlayer);
|
||||||
var player = Instantiate(playerPrefab, _spawnPosition, playerPrefab.transform.rotation);
|
var player = Instantiate(playerPrefab, _spawnPosition, playerPrefab.transform.rotation);
|
||||||
player.name = "RestaurantPlayer";
|
player.name = CommonConstants.RestaurantPlayer;
|
||||||
CameraManager.Instance.GetCameraGameObject("RestaurantBaseCamera").SetFollowAndLookAtTarget(player.transform);
|
CameraManager.Instance.GetCameraGameObject(CameraType.RestaurantBaseCamera).SetFollowAndLookAtTarget(player.transform);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -24,14 +24,14 @@ private void Awake()
|
|||||||
{
|
{
|
||||||
_rigidbody = GetComponent<Rigidbody>();
|
_rigidbody = GetComponent<Rigidbody>();
|
||||||
_animation = GetComponent<RestaurantCharacterAnimation>();
|
_animation = GetComponent<RestaurantCharacterAnimation>();
|
||||||
_visualLook = transform.Find("VisualLook");
|
_visualLook = transform.Find(CommonConstants.VisualLook);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Start()
|
private async void Start()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_playerData = await AssetManager.LoadAsset<RestaurantPlayerDataSo>("RestaurantPlayerDataSo");
|
_playerData = await AssetManager.LoadAsset<RestaurantPlayerDataSo>(DataConstants.RestaurantPlayerDataSo);
|
||||||
|
|
||||||
_playerData.MoveActionReference.action.performed += OnMove;
|
_playerData.MoveActionReference.action.performed += OnMove;
|
||||||
_playerData.MoveActionReference.action.canceled += OnMove;
|
_playerData.MoveActionReference.action.canceled += OnMove;
|
||||||
@ -107,7 +107,7 @@ private void Move()
|
|||||||
SetCurrentDirection(_inputDirection);
|
SetCurrentDirection(_inputDirection);
|
||||||
|
|
||||||
_isMoving = _inputDirection != Vector3.zero;
|
_isMoving = _inputDirection != Vector3.zero;
|
||||||
string animationName = _isMoving ? "RunFast" : "Idle";
|
string animationName = _isMoving ? RestaurantPlayerAnimation.Walk : RestaurantPlayerAnimation.Idle;
|
||||||
_animation.PlayAnimation(animationName, true);
|
_animation.PlayAnimation(animationName, true);
|
||||||
|
|
||||||
Vector3 finalVelocity = _inputDirection * _playerData.MoveSpeed;
|
Vector3 finalVelocity = _inputDirection * _playerData.MoveSpeed;
|
||||||
@ -134,7 +134,7 @@ private IEnumerator DashCoroutine()
|
|||||||
_isDashing = true;
|
_isDashing = true;
|
||||||
_isDashCooldown = true;
|
_isDashCooldown = true;
|
||||||
|
|
||||||
_animation.PlayAnimationDuration("Dash", false, _playerData.DashTime);
|
_animation.PlayAnimationDuration(RestaurantPlayerAnimation.Dash, false, _playerData.DashTime);
|
||||||
|
|
||||||
Vector3 dashVelocity = _currentDirection.normalized * _playerData.DashSpeed;
|
Vector3 dashVelocity = _currentDirection.normalized * _playerData.DashSpeed;
|
||||||
_rigidbody.linearVelocity = dashVelocity;
|
_rigidbody.linearVelocity = dashVelocity;
|
||||||
|
21
Assets/_DDD/_Scripts/Utilities/Constants.cs
Normal file
21
Assets/_DDD/_Scripts/Utilities/Constants.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
namespace DDD
|
||||||
|
{
|
||||||
|
public static class CommonConstants
|
||||||
|
{
|
||||||
|
public const string VisualLook = "VisualLook";
|
||||||
|
public const string RestaurantPlayer = "RestaurantPlayer";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DataConstants
|
||||||
|
{
|
||||||
|
public const string ItemDataSo = "ItemDataSo";
|
||||||
|
public const string RestaurantPlayerDataSo = "RestaurantPlayerDataSo";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RestaurantPlayerAnimation
|
||||||
|
{
|
||||||
|
public const string Idle = "Idle";
|
||||||
|
public const string Walk = "RunFast";
|
||||||
|
public const string Dash = "Dash";
|
||||||
|
}
|
||||||
|
}
|
2
Assets/_DDD/_Scripts/Utilities/Constants.cs.meta
Normal file
2
Assets/_DDD/_Scripts/Utilities/Constants.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6e8cf38ab843c9e40a94a26ba7102dc4
|
Loading…
Reference in New Issue
Block a user