private IEnumerator MovePlayer(int moves) { Animator.ToggleWalk(); for (int i = 0; i < moves; i++) { if (Player.CurrentPosition <= waypoints.Length - 1) { var currentPos = Player.transform.position; var t = 0f; while (t < 1) { t += Time.deltaTime / timeToMove; Player.transform.position = Vector3.Lerp(currentPos, waypoints[Player.CurrentPosition + 1].transform.position, t); Player.transform.rotation = Quaternion.Lerp(Player.transform.rotation, waypoints[Player.CurrentPosition].transform.rotation, t); yield return(null); } Player.CurrentPosition = Player.CurrentPosition + 1; if (Player.CurrentPosition == 63) { yield break; //Animator.ToggleWalk(); //if (moves - (i - 1) != 0) //{ // StartCoroutine(MoveBackwards(i)); // yield break; //} } MechanicControl passThruMechanic = waypoints[Player.CurrentPosition].GetComponent <MechanicControl>(); if (passThruMechanic != null) { passThruMechanic.PassThroughMechanic(); } } } Animator.ToggleWalk(); Debug.Log("Stop Walking"); MechanicControl mechanic = waypoints[Player.CurrentPosition].GetComponent <MechanicControl>(); if (mechanic != null) { mechanic.DoMechanic(Player, moves); } if (skipTurn.IndexOf(Player.CurrentPosition) != -1) { skipNextTurn = true; } }
public void Move(int moves) { MechanicControl allowanceMechanic = waypoints[Player.CurrentPosition].GetComponent <MechanicControl>(); if (allowanceMechanic != null) { if (!allowanceMechanic.IsAllowed()) { // UI STUFF return; } } Debug.Log(moves); StartCoroutine(MovePlayer(moves)); }