public IEnumerator ApplyThoughtRoutine(Thought senderThought, SpecimenBehavior receiver) { receiver.SetThought(senderThought); yield return(null); }
public IEnumerator ApplyThoughtRoutine(Thought senderThought, SpecimenBehavior receiver) { var receiverThought = receiver.GetThought(); if (senderThought == receiverThought) { switch (senderThought) { case Thought.Danger: var danger = FindObjectsOfType <DangerBehavior>().RandomElement().gameObject.transform; SetWalkingTarget(danger); receiver.SetWalkingTarget(danger); yield return(new WaitForSeconds(0.25f)); break; case Thought.Food: var foodSteps = receiver.MoveToPositionRoutine(new Vector2(transform.position.x + 0.5f, transform.position.y)); while (foodSteps.MoveNext()) { yield return(foodSteps.Current); } AudioManager.instance.PlaySound("NPCEatingNPC"); while (transform.localScale.z > 0) { transform.localScale -= 0.1f * Vector3.one; yield return(new WaitForSeconds(0.1f)); } transform.Find("Sprites").gameObject.SetActive(false); isDying = true; receiver.SetThought(Thought.Nothing); yield return(new WaitForSeconds(0.25f)); break; case Thought.Love: var loveSteps = receiver.MoveToPositionRoutine(new Vector2(transform.position.x + 1f, transform.position.y)); while (loveSteps.MoveNext()) { yield return(loveSteps.Current); } //@TODO play love-making sound here yield return(new WaitForSeconds(1.0f)); AudioManager.instance.PlaySound("SpawnNewNPC"); manager.SpawnSpecimen(transform.position + new Vector3(0, 0.5f, 0), transform.localScale); SetThought(Thought.Nothing); receiver.SetThought(Thought.Nothing); yield return(new WaitForSeconds(0.5f)); break; case Thought.Money: //@TODO ? SetThought(Thought.Nothing); receiver.SetThought(Thought.Nothing); break; case Thought.Nothing: new[] { this, receiver }.RandomElement().SetThought(new[] { Thought.Love, Thought.Money, Thought.Food }.RandomElement()); yield return(new WaitForSeconds(0.25f)); break; } } else { if (HasThought()) { if (receiver.HasThought()) { var thoughts = new[] { receiverThought, senderThought }; SetThought(thoughts.RandomElement()); receiver.SetThought(thoughts.RandomElement()); } else { receiver.SetThought(senderThought); } } else { SetThought(receiverThought); } } yield return(new WaitForSeconds(0.5f)); }