public GameStateController()
    {
        gameFsm       = new FSM("GameFSM");
        preStartState = gameFsm.AddState((byte)GameState.PreStart);
        idleState     = gameFsm.AddState((byte)GameState.Idle);
        playState     = gameFsm.AddState((byte)GameState.Play);
        pauseState    = gameFsm.AddState((byte)GameState.Pause);
        gameOverState = gameFsm.AddState((byte)GameState.GameOver);

        preStartAction = new PreStartAction(preStartState);
        playingAction  = new PlayAction(playState);
        pauseAction    = new PauseAction(pauseState);
        gameOverAction = new GameOverAction(gameOverState);
        idleAction     = new IdleAction(idleState);

        preStartState.AddTransition((byte)FSMTransition.ToIdle, idleState);
        idleState.AddTransition((byte)FSMTransition.ToPlay, playState);
        playState.AddTransition((byte)FSMTransition.ToPause, pauseState);
        playState.AddTransition((byte)FSMTransition.ToGameOver, gameOverState);
        gameOverState.AddTransition((byte)FSMTransition.ToIdle, idleState);

        preStartAction.Init();
        idleAction.Init();
        playingAction.Init();
        pauseAction.Init();
        gameOverAction.Init();
    }
Esempio n. 2
0
        private void Start()
        {
            fsm          = new FiniteStateMachine("AITest FSM");
            IdleState    = fsm.AddState("IdleState");
            ScanState    = fsm.AddState("ScanState");
            PatrolState  = fsm.AddState("WanderState");
            PatrolAction = new WanderAction(PatrolState);
            IdleAction   = new IdleAction(IdleState);
            ScanAction   = new ScanningAction(ScanState);
            deathState   = fsm.AddState("DeathState");
            DeathAction  = new DeathState(deathState);
            //This adds the actions to the state and add state to it's transition map
            PatrolState.AddAction(PatrolAction);
            IdleState.AddAction(IdleAction);

            PatrolState.AddTransition("ToIdle", IdleState);
            IdleState.AddTransition("ToPatrol", PatrolState);
            ScanState.AddTransition("ToScanning", ScanState);
            deathState.AddTransition("ToDeath", deathState);
            PatrolAction.Init(target, 3.0f, gameObject.GetComponent <EnemyAstar>(), "ToIdle");
            IdleAction.Init(target, "AI on Idle", 3.0f, gameObject.GetComponent <EnemyAstar>(), "ToPatrol");
            DeathAction.Init(3.0f, gameObject.GetComponent <EnemyAstar>());
            ScanAction.Init(3.0f);
            fsm.StartMachine("IdleState");
        }
        public override void Start()
        {
            base.Start();


            m_HitPoints   = HitPoints;
            objectScanner = new ObjectScanner(this, onObjectFound);

            //Initialise all actions
            idleAction.Init(Animator, "ToFollow");
            followMoveAction.Init(transform, Animator, MovementTypes.MOVE_RUN, "ToIdle", unit);
            patrolMoveAction.Init(transform, Animator, MovementTypes.MOVE_WALK, "ToIdle", unit);
            patrolAction.Init(transform, Animator, "ToIdle");
            attackAction.Init(Animator);
            fsm.Start(CharacterStates.STATE_IDLE);
        }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        fsm        = new Core.FSM.FSM("PlayerFSM");
        moveState  = fsm.AddState("MoveState");
        idleState  = fsm.AddState("IdleState");
        moveAction = new MoveAction(moveState);
        idleAction = new IdleAction(idleState);

        moveState.AddAction(moveAction);
        idleState.AddAction(idleAction);

        PlayerRB  = gameObject.GetComponent <Rigidbody>();
        playerObj = GameObject.Find("Player");

        moveAction.Init(gameObject.transform, PlayerRB, velocity, sprintVelocity, jumpSpeed, "ToIdle");
        idleAction.Init();

        idleState.AddTransition("ToMove", moveState);
        moveState.AddTransition("ToIdle", idleState);

        fsm.Start("IdleState");
    }