private IEnumerator ForceWakeUp(PetInteractibleObject pio = null) { CurrentAnimState = AnimState.wakeup; yield return new WaitForSeconds(animation["Move Die"].length); CurrentAnimState = AnimState.idle; if (pio != null) StartInteraction(pio); }
private IEnumerator Interact(PetInteractibleObject pio) { //pick a point to roam to Vector3 startPos = transform.position; //find how long it should take to get there float desiredTime = (Vector3.Distance(transform.position, pio.StandPosition))/runSpeed; float elapsedTime = 0f; //start moving CurrentAnimState = AnimState.run; transform.LookAt(pio.StandPosition); desiredRotationTarget = pio.standPosition; while(elapsedTime < desiredTime) { transform.position = Vector3.Lerp(startPos, pio.StandPosition, elapsedTime/desiredTime); desiredPos = Vector3.Lerp(startPos, pio.StandPosition, elapsedTime/desiredTime); elapsedTime += Time.deltaTime; yield return null; } //finish moving transform.LookAt(pio.LookDirection); desiredRotationTarget = pio.LookDirection; CurrentAnimState = pio.myAnimState; //start interacting yield return new WaitForSeconds(currentAnimationTime); //check interaction if (CurrentAnimState == AnimState.sleep) { //sleep forever i guess - or until whatever? yield return new WaitForSeconds(60f); CurrentAnimState = AnimState.wakeup; yield return new WaitForSeconds(animation["Move Die"].length); CurrentAnimState = AnimState.idle; } else { CurrentAnimState = AnimState.idle; } OpenTheGate("Wait"); }
public void StartInteraction(PetInteractibleObject pio) { StopAllCoroutines(); if(CurrentAnimState == AnimState.sleep) { StartCoroutine(ForceWakeUp (pio)); return; } StartCoroutine (Interact(pio)); }