HoloCop in progress
This commit is contained in:
1 parent
2697212f05
commit
430b250075
79 files changed
+120745
-45077
No files matched your search
@@ -2,6 +2,7 @@ using System.Threading;
|
||||
using Code.Game.Gameplay.Player;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Input;
|
||||
using Code.OfficeGame.BattleMode.Actions.Player;
|
||||
using Code.OfficeGame.BattleMode.Timeline;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using KinematicCharacterController;
|
||||
@@ -30,8 +31,10 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
[Inject]
|
||||
public void Construct(
|
||||
CameraStateMachine cameraStateMachine,
|
||||
IInputService inputService)
|
||||
IInputService inputService,
|
||||
PlayerDecisionMarker playerDecisionMarker)
|
||||
{
|
||||
_playerDecisionMarker = playerDecisionMarker;
|
||||
_cameraStateMachine = cameraStateMachine;
|
||||
_inputService = inputService;
|
||||
_movementController = GetComponent<MovementController>();
|
||||
@@ -87,7 +90,8 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
float inputMagnitude = (_currentCornerIndex == _corners.Length - 1 && distance < maxStep && maxStep > 0f)
|
||||
? distance / maxStep
|
||||
: 1f;
|
||||
|
||||
|
||||
// TODO Для последнего кадра должен быть особый Look совпадающий с маркером
|
||||
var aiInputs = new AICharacterInputs
|
||||
{
|
||||
MoveVector = moveNormal * inputMagnitude,
|
||||
@@ -116,6 +120,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
|
||||
private void StopMovementAndFinish()
|
||||
{
|
||||
Debug.Log("MovementFinished");
|
||||
var emptyInputs = new AICharacterInputs
|
||||
{
|
||||
MoveVector = Vector3.zero,
|
||||
@@ -142,15 +147,23 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
ConfirmPosition);
|
||||
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
|
||||
CancelPosition);
|
||||
_inputService.BindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Watchment,
|
||||
MarkPosition);
|
||||
|
||||
_playerDecisionMarker.Toggle(true);
|
||||
|
||||
await UniTask.WaitUntilCanceled(_waitForEnterTokenSource.Token).SuppressCancellationThrow();
|
||||
|
||||
_playerDecisionMarker.Toggle(false);
|
||||
|
||||
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Select,
|
||||
SelectPosition);
|
||||
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Confirm,
|
||||
ConfirmPosition);
|
||||
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Cancel,
|
||||
CancelPosition);
|
||||
_inputService.UnbindActionPerformed((int)ActionMappings.BattleMode, (int)BattleModeActions.Watchment,
|
||||
MarkPosition);
|
||||
|
||||
_waitForEnterTokenSource.Dispose();
|
||||
_waitForEnterTokenSource = null;
|
||||
@@ -163,6 +176,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
public override BattleActionType ActionType => BattleActionType.Move;
|
||||
|
||||
private int _totalFrames;
|
||||
private PlayerDecisionMarker _playerDecisionMarker;
|
||||
|
||||
private void CancelPosition(InputAction.CallbackContext obj)
|
||||
{
|
||||
@@ -217,18 +231,37 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
// Округляем вверх, так как последний неполный шаг тоже занимает 1 целый кадр
|
||||
return Mathf.CeilToInt(effectiveDistance / stepPerFrame);
|
||||
}
|
||||
private void SelectPosition(InputAction.CallbackContext input)
|
||||
|
||||
private RaycastHit[] _hitBuffer = new RaycastHit[1];
|
||||
private Vector3 _lastViewedPosition;
|
||||
private void MarkPosition(InputAction.CallbackContext input)
|
||||
{
|
||||
var position = _cameraStateMachine.Camera.transform.position;
|
||||
var direction = _cameraStateMachine.Camera.transform.forward;
|
||||
|
||||
var didHit = Physics.Raycast(position, direction, out RaycastHit hit, Mathf.Infinity, _navMeshMask);
|
||||
var hitCount = Physics.RaycastNonAlloc(position, direction, _hitBuffer, Mathf.Infinity, _navMeshMask);
|
||||
|
||||
if (!didHit) return;
|
||||
if (hitCount == 0) return;
|
||||
|
||||
Debug.Log($"Hit {hit.point}");
|
||||
var hit = _hitBuffer[0];
|
||||
|
||||
_playerDecisionMarker.MoveMarker(hit.point);
|
||||
|
||||
_targetPosition = hit.point;
|
||||
_lastViewedPosition = hit.point;
|
||||
}
|
||||
|
||||
private void SelectPosition(InputAction.CallbackContext input)
|
||||
{
|
||||
// var position = _cameraStateMachine.Camera.transform.position;
|
||||
// var direction = _cameraStateMachine.Camera.transform.forward;
|
||||
//
|
||||
// var didHit = Physics.Raycast(position, direction, out RaycastHit hit, Mathf.Infinity, _navMeshMask);
|
||||
//
|
||||
// if (!didHit) return;
|
||||
|
||||
Debug.Log($"Hit {_lastViewedPosition}");
|
||||
|
||||
_targetPosition = _lastViewedPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user