public void Perceive(Perception perception) { //Debug.Log("PerceptionListener.Perceive()" + name + " is perceiving!"); GameObject source = perception.GetSource(); ImpressionAdjuster adjuster = perception.GetImpressionAdjuster(); Action action = perception.GetAction(gameObject); if (adjuster != null){ impressionMemory.ImpressionAdjusted(source, adjuster); } if (action != null){ actionRunner.ResetRoutine(action, false); } }
//private PerceptionManager instance; /*public void Start(){ //instance = this; enabled=false; }*/ public static void BroadcastPerception(Perception perception) { //Debug.Log("Broadcasting perception."); foreach (GameObject npc in CharacterManager.GetMajorNPCs()){ //Debug.Log("Iterating broadcast: " + npc.name); CharacterState sourceState = perception.GetSource().GetComponent(typeof(CharacterState)) as CharacterState; Area sourceArea = sourceState.GetCurrentArea(); PerceptionListener perceptionListener = npc.GetComponent(typeof(PerceptionListener)) as PerceptionListener; float distance = Vector3.Distance(perception.GetPosition(), npc.transform.position); //Debug.Log("Distance okay? " + (distance < sourceArea.GetPerceptionDistance())); //Debug.Log("Vision okay?" + (perceptionListener.CanSee(perception.GetPosition()))); if (distance < sourceArea.GetEasyPerceptionDistance() || (distance < sourceArea.GetPerceptionDistance() && perceptionListener.CanSee(perception.GetPosition()))){ //Debug.Log("PerceptionManager.BroadcastPerception(): " + npc.name); perceptionListener.Perceive(perception); } } }