private void Awake() { _currentPositionOnGrid = new Vector2Int(5, 5); _moveTimerCurrent = _moveTimerMax; _currentDirection = Direction.Right; _movePositionList = new List <MovePosition>(); Signaler.Instance.Subscribe <EngageEnemySequenceFinish>(this, OnEngageEnemySequenceFinished); _isCaravanActive = true; }
private void MoveForward() { MovePosition previousPositionOnGrid = null; if (_movePositionList.Count > 0) { previousPositionOnGrid = _movePositionList[0]; } var movePosition = new MovePosition(previousPositionOnGrid, _currentPositionOnGrid, _currentDirection); _movePositionList.Insert(0, movePosition); var gridMoveDirectionVector = ProcessMoveStep(); _currentPositionOnGrid += gridMoveDirectionVector; var directionChange = _levelGrid.ValidateGridPosition(_currentPositionOnGrid); if (directionChange != null) { RemoveCurrentHero(); if (_heroInCaravans.Count <= 0) { TriggerGameOver(); PauseCaravan(); return; } _currentPositionOnGrid -= gridMoveDirectionVector; _currentDirection = (Direction)directionChange; var changeDirectionStep = ProcessMoveStep(); _currentPositionOnGrid += changeDirectionStep; CollisionChecks(); AppliedPositionAndRotation(changeDirectionStep); } else { CollisionChecks(); AppliedPositionAndRotation(gridMoveDirectionVector); } UpdateCaravanMemberPosition(); }
private void ProcessMovementInput() { if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) { if (_currentDirection == Direction.Up) { _currentDirection = Direction.Left; } else if (_currentDirection == Direction.Down) { _currentDirection = Direction.Right; } else if (_currentDirection == Direction.Left) { _currentDirection = Direction.Down; } else if (_currentDirection == Direction.Right) { _currentDirection = Direction.Up; } } if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) { if (_currentDirection == Direction.Down) { _currentDirection = Direction.Left; } else if (_currentDirection == Direction.Up) { _currentDirection = Direction.Right; } else if (_currentDirection == Direction.Right) { _currentDirection = Direction.Down; } else if (_currentDirection == Direction.Left) { _currentDirection = Direction.Up; } } }