/// <summary> /// Update the idle state /// </summary> private void UpdateIdle(float dt) { Vector3 pos = CalcPlayerPositionOverTile(currTile); transform.position = Vector3.SmoothDamp(transform.position, pos, ref snapIdlePlayerToTileVel, snapIdlePlayerToTileSmooth); if (stateTimer < minTimeToWaitBeforeMovingAgain) { return; } bool shouldEnterMovingToTile = (tileMovingTo != null && !BlockedDir(movingDir)); bool shouldEnterSolveDoorEnigma = (tileMovingTo != null && BlockedDir(movingDir)); if (shouldEnterMovingToTile) { // is going to clash with an enemy? // if so, we may want to join the InLevelShowingDescription state of the game manager bool clashWithEnemy = IsGoingToClashWithEnemy(out enemyClashedWith); GameManager.Instance.EnemyEvent = clashWithEnemy; if (clashWithEnemy) { enemyClashedWith.TextActivated = true; GameManager.Instance.SetDescriptionText(enemyClashedWith.descriptionText.displayedText); GameManager.Instance.NextPlayerTile = tileMovingTo; GameManager.Instance.SwitchState(GameState.InLevelShowingDescription, false); tileMovingTo = null; } else { SwitchState(PlayerState.MovingToTile, false); } } else if (shouldEnterSolveDoorEnigma) { currDoor = GetDirDoor(movingDir); currDoor.ActivateDoorBehaviour(); GameManager.Instance.SwitchState(GameState.InLevelShowingDescription, false); // get the door description and set the ui desc with it GameManager.Instance.SetDescriptionText(currDoor.text.displayedText); GameManager.Instance.NextPlayerTile = tileMovingTo; tileMovingTo = null; } }