Example #1
0
    void Update()
    {
        IGuardState newState = state.Update();

        if (newState != null)
        {
            state.Exit();
            state = newState;
            state.Enter(this);
        }
    }
Example #2
0
 void Start()
 {
     Random.InitState((int)System.DateTime.Now.Ticks);
     agent       = GetComponent <NavMeshAgent>();
     audioSource = GetComponent <AudioSource>();
     sensingComp = GetComponent <PawnSensingComponent>();
     PawnSensingComponent.OnSeePawn   += OnSeePawnHandler;
     PawnSensingComponent.OnHearNoise += OnHearNoise;
     state = new PatrollingState();
     state.Enter(this);
 }
Example #3
0
    private void OnHearNoise(GameObject instigator, float loudness, Vector3 noisePosition)
    {
        Debug.Log(gameObject.name + " heard a sound at position " + noisePosition);
        IGuardState newState = state.OnHearNoise(instigator, loudness, noisePosition);

        if (newState != null)
        {
            state.Exit();
            state = newState;
            state.Enter(this);
        }
    }
Example #4
0
    private void OnSeePawnHandler(GameObject gameObject)
    {
        // Debug.Log("Sensed: " + gameObject.name);
        IGuardState newState = state.OnSeePawnHandler(gameObject);

        if (newState != null)
        {
            state.Exit();
            state = newState;
            state.Enter(this);
        }
    }