separated logic for weapon code refactored
This commit is contained in:
@@ -6,9 +6,12 @@ namespace Darkmatter.Domain
|
||||
{
|
||||
public class PlayerStateMachine : StateMachine
|
||||
{
|
||||
[Inject] public readonly IPlayerPawn playerController;
|
||||
[Inject] public readonly IPlayerPawn playerPawn;
|
||||
[Inject] public readonly IInputReader inputReader;
|
||||
[Inject] public readonly IPlayerAnim playerAnim;
|
||||
[Inject] public readonly ITargetProvider targetProvider;
|
||||
[Inject] public readonly ICameraService cameraService;
|
||||
[Inject] public readonly IWeapon GunWeapon;
|
||||
[Inject] public readonly PlayerConfigSO playerConfig;
|
||||
[Inject] public readonly CameraConfigSO cameraConfig;
|
||||
|
||||
@@ -19,8 +22,8 @@ namespace Darkmatter.Domain
|
||||
public void Move(Vector2 moveInputDir, float moveSpeed)
|
||||
{
|
||||
//player movement with reference to camera
|
||||
Vector3 cameraForward = playerController.mainCamera.transform.forward;
|
||||
Vector3 cameraRight = playerController.mainCamera.transform.right;
|
||||
Vector3 cameraForward =cameraService.mainCamera.transform.forward;
|
||||
Vector3 cameraRight = cameraService.mainCamera.transform.right;
|
||||
|
||||
cameraForward.y = 0f;
|
||||
cameraRight.y = 0f;
|
||||
@@ -30,7 +33,7 @@ namespace Darkmatter.Domain
|
||||
|
||||
moveDir = cameraRight * moveInputDir.x + cameraForward * moveInputDir.y;
|
||||
|
||||
playerController.Move(moveDir * moveSpeed);
|
||||
playerPawn.Move(moveDir * moveSpeed);
|
||||
playerAnim.PlayMovementAnim(moveInputDir);
|
||||
}
|
||||
|
||||
@@ -43,7 +46,17 @@ namespace Darkmatter.Domain
|
||||
pitch -= lookInput.y * cameraConfig.lookSensitivity * Time.deltaTime;
|
||||
}
|
||||
pitch = Mathf.Clamp(pitch, cameraConfig.bottomClampAngle, cameraConfig.topClampAngle);
|
||||
playerController.SetCameraRotation(pitch, Yaw);
|
||||
playerPawn.SetCameraRotation(pitch, Yaw);
|
||||
}
|
||||
|
||||
public void Shoot(bool isShooting)
|
||||
{
|
||||
if (!isShooting) return;
|
||||
if(GunWeapon.canAttack)
|
||||
{
|
||||
GunWeapon.Attack();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user