IndexDirection2 DetermineActualMoveDirection(IndexDirection2 desiredMoveDirection) { Vector3 desiredMoveDirection_Vec = desiredMoveDirection.ToVector3(); IndexDirection2 chosenDirection; bool canMove; float turnAngle = 0; do { Vector3 v = Quaternion.Euler(0, turnAngle, 0) * desiredMoveDirection_Vec; chosenDirection = new IndexDirection2(v); if (WorldInfo.Instance.IsOverworld) { // TODO: Use IndexDirection2.AllValidDirections instead of turnAngle += 90 canMove = CanMoveInDirection_Overworld(chosenDirection); } else { canMove = !DetectObstructions(chosenDirection, feelerLength); } turnAngle += 90; }while (!canMove && turnAngle < 360); return(chosenDirection); }
protected IndexDirection2 EnforceBoundary(IndexDirection2 desiredMoveDirection) { Vector3 vec = desiredMoveDirection.ToVector3(); vec = EnforceBoundary(vec); return(new IndexDirection2(vec)); }
void Start() { _enemyMove.Mode = EnemyMove.MovementMode.Destination; _enemyMove.AlwaysFaceTowardsMoveDirection = false; _enemyMove.targetPositionReached_Callback += OnTargetPositionReached; _forwardTileDirection = IndexDirection2.FromDirectionEnum(forwardDirection); transform.forward = _forwardTileDirection.ToVector3(); MoveDirection_Tile = _forwardTileDirection; }
void Slide(IndexDirection2 dir) { if (!CanSlideInDirection(dir)) { return; } Vector3 targetPos = transform.position + dir.ToVector3(); SlideToPosition(targetPos); }
void OnTargetPositionReached(EnemyMove sender, Vector3 moveDirection) { if (moveDirection == _forwardTileDirection.ToVector3()) { Attack(); MoveDirection_Tile = _forwardTileDirection.Reversed; } else { MoveDirection_Tile = _forwardTileDirection; } }
void Jump(IndexDirection2 dir) { MoveDirection_Tile = dir; _enemyMove.enabled = false; _enemy.Jump(MoveDirection_Tile.ToVector3()); }
protected bool DetectObstructions(IndexDirection2 dir, float distance) { return(DetectObstructions(dir.ToVector3(), distance)); }