예제 #1
0
 /// <summary>
 /// Callback that occurs when a trigger event occurs in the underlying Sensor via it's collider.
 /// This is a custom callback that Gary built that can handle any of the collider trigger events
 /// (enter, stay, exit) that were originally configured in the AiSensor script.  Whenever that
 /// script receives a trigger event in one of the configured monobeharior trigger callbacks, it will push
 /// those events to the associated AiStateMachine and this method will delegate the handling to the child
 /// AiStates.
 /// </summary>
 /// <param name="type">The event type that matches the three monobehavior callback types.</param>
 /// <param name="other">The collider that triggered the event.</param>
 public virtual void OnTriggerEvent(AiTriggerEventType type, Collider other)
 {
     if (currentState != null)
     {
         currentState.OnTriggerEvent(type, other);
     }
 }
예제 #2
0
    /// <summary>
    /// Provides the handling of trigger events that occur whenever the AiEntity Sensor Collider collides
    /// with another collider it is sensitive to.
    /// </summary>
    /// <param name="eventType">The event type that occured</param>
    /// <param name="other">The collider that triggered the event</param>
    public override void OnTriggerEvent(AiTriggerEventType eventType, Collider other)
    {
        base.OnTriggerEvent(eventType, other); // at the moment, the parent doesn't do anything

        /*
         * The very first time this is called, at the start of a physics update (i.e. FixedUpdate),
         * visual and audio threats are cleared.  So any threat we set here will override it anyways.
         */

        // process most important threats first
        if (eventType != AiTriggerEventType.Exit)
        {
            if (other.CompareTag("Player"))
            {
                HandlePlayerThreat(other);
            }
            else if (!zombieStateMachine.ThreatManager.DoesPlayerThreatExist())
            {
                if (other.CompareTag("Flashlight"))
                {
                    HandleFlashlightThreat((BoxCollider)other);
                }
                else if (other.CompareTag("AI Sound Emitter"))
                {
                    HandleAudioThreat(other);
                }
                else if (other.CompareTag("AI Food") &&
                         !zombieStateMachine.ThreatManager.DoesLightThreatExist() &&
                         !zombieStateMachine.ThreatManager.DoesAudioThreatExist() &&
                         this.zombieStateMachine.IsHungery()
                         )
                {
                    HandleHungerThreat(other);
                }
            }
        }
    }
예제 #3
0
 /// <summary>
 /// Default callback that can handle AI Trigger events.
 /// </summary>
 /// <param name="eventType">The type of event that was triggered</param>
 /// <param name="other">The collider that triggered the event.</param>
 public virtual void OnTriggerEvent(AiTriggerEventType eventType, Collider other)
 {
 }