int TalkTo(Human[] humans, MovieActionObject m) { int count = 0; foreach (Human h in humans) { h._go.GetComponent <HumanController>().humanState = HumanController.HumanState.movie; h._go.GetComponent <HumanController>().StartCoroutine("TalkTo", m); count++; } return(count); }
IEnumerator Wander(MovieActionObject m) { Transform wander = m.walkTo; Vector3 position = wander.position; movieAction = ActionType.Wander; while (movieAction == ActionType.Wander && humanState == HumanState.movie) { //rb.velocity = transform.forward * 2; //turnAroundTimer += Time.deltaTime; //if ((transform.position - position).magnitude > 5 && turnAroundTimer > 1) //{ //turnAroundTimer = 0; ///.LookAt(wander); //} yield return(new WaitForEndOfFrame()); } yield return(new WaitForEndOfFrame()); }
IEnumerator WalkTo(MovieActionObject m) { Transform walkTo; if (m.action == ActionType.walkToLastHouse) { walkTo = GameController.instance.lastHouse.transform; } else if (m.action == ActionType.walkToLastCrop) { walkTo = GameController.instance.lastCrops.transform; } else { walkTo = m.walkTo; } Vector3 position = walkTo.position; movieAction = ActionType.WalkTo; float follow = 3f; if (walkTo.transform.root.GetComponent <ResourceController>() != null || walkTo.transform.root.GetComponent <BuildingController>() != null) { follow = 0f; } while ((transform.position - position).magnitude > follow && movieAction == ActionType.WalkTo) { transform.LookAt(walkTo); rb.velocity = transform.forward * 2; yield return(new WaitForEndOfFrame()); } if (buildingInside == null && resourceBeingGathered == null) { movieAction = ActionType.idle; } yield return(new WaitForEndOfFrame()); }
IEnumerator TalkTo(MovieActionObject m) { ConversationObject c = m.conversation; Human leftHuman = GameController.instance.gameManager.humanManager.FindHumanByName(c.CharacterLeftName); Human rightHuman = GameController.instance.gameManager.humanManager.FindHumanByName(c.CharacterRightName); movieAction = ActionType.Talk; int length = 0; bool left = false; if (leftHuman == human) { left = true; } length += c.Conversation_1_Left.Length; length += c.Conversation_2_Right.Length; int phrase = 0; int sentence = 0; if (left) { CreateSpeechBubble(c.Conversation_1_Left[sentence]); leftHuman._speechDone = false; sentence++; } while (phrase < length) { if ((phrase == 0 || phrase % 2 == 0)) { if (leftHuman._speechDone) { phrase++; if (rightHuman == human && phrase < length) { human._speechDone = false; movieAction = ActionType.WaitForEvent; } } } else if ((phrase % 2 != 0)) { if (rightHuman._speechDone) { phrase++; if (leftHuman == human && phrase < length) { human._speechDone = false; movieAction = ActionType.WaitForEvent; } } } if (movieAction == ActionType.WaitForEvent) { if (left) { CreateSpeechBubble(c.Conversation_1_Left[sentence]); } else { CreateSpeechBubble(c.Conversation_2_Right[sentence]); } movieAction = ActionType.Talk; sentence++; } yield return(new WaitForEndOfFrame()); } //SpeechBubbleCanvas.gameObject.SetActive(false); movieAction = ActionType.idle; human._speechDone = false; yield return(new WaitForEndOfFrame()); }