Exemple #1
0
    private void SetupStatemachine()
    {
        sm = new StateMachine();
        sm.Add(new State("Start", "Idle", () => {
            return(true);
        }));

        sm.Add(new State("Idle", "Chase", () => {
            return(CanSeePlayer());
        }));

        sm.Add(new State("Chase", "Idle", () => {
            return(!CanSeePlayer() && currentPosition == lastSeenPlayerAt);
        }));

        sm.Add(new State("Any", "Attack", () => {
            return(CanSeePlayer() && currentPosition.IsAdjacentTo(GameManagerScript.stage.Player.Position));
        }));

        sm.Add(new State("Attack", "Idle", () => {
            return(!currentPosition.IsAdjacentTo(GameManagerScript.stage.Player.Position));
        }));

        sm.StateChanged += OnStateChanged;
    }