public IEnumerator Travel() { UnitScript voyagerUnitScript = voyager.GetComponent <UnitScript>(); //sanity check if (voyagerUnitScript == null) { Debug.LogError("Why the f**k is there no UnitScript on this Voyager??"); Log.SpawnLog("ERROR! MoveExe line22"); yield return(null); } else if (voyager is UnitFlight) { Debug.LogError("Travel used instead of fly! Why?"); Log.SpawnLog("ERROR! MoveExe line30"); yield return(null); } else //we generally HAVE TO end up here { SetTileAndUnitPair(voyager.GetComponent <UnitScript>(), path[path.Count - 1]); //basically tells FINAL tile of the path and unit 'you are now married'. voyager.CanMove = false; // player cannot move it now voyager.isMoving = true; //mostly so that you cannot use an ability on this unit untill it stops moving for (int i = 0; i < path.Count; i++) { voyager.SetDestination(path[i]); PathCreator.Instance.ClearPath(); yield return(new WaitUntil(voyager.HasStoppedMoving)); } FinishMovement(voyager); } }
IEnumerator Hop() { Log.SpawnLog("Horseman jumps above an obstacle!"); PlayAbilitySound(); GameObject lightnings = CreateVFXOn(transform, BasicVFX.transform.rotation); GetComponent <AnimController>().SetJumping(true); myMovement.SetDestination(Target.transform.position); yield return(null); FinishUsing(); // some future //yield return WaitUntil(something) yield return(new WaitUntil(IsDoneMoving)); GetComponent <AnimController>().SetJumping(false); Destroy(lightnings); Target.OnUnitEnterTile(myUnit); }
public void ReceiveOrder(Vector3 position) { movement.SetDestination(position); }
private void SetNewDestination(UnitMovement unit) { unit.SetDestination(GetRandomDestination()); }