public override void StartFSM()
    {
        _idleState   = new IdleState <states>(this, flags, _treeStartPoint);
        _followState = new FollowState <states>(this, myLeader, flags, _treeStartPoint, stopDist);
        _attackState = new AttackState <states>(this, flags, _treeStartPoint);
        _escapeState = new EscapeState <states>(this, flags, _treeStartPoint);
        _reloadState = new ReloadState <states>(this, flags, _treeStartPoint);

        fsm = new FSM <states>(_idleState);

        _idleState.AddTransition(states.Follow, _followState);
        _idleState.AddTransition(states.Attack, _attackState);
        _idleState.AddTransition(states.Escape, _escapeState);
        _idleState.AddTransition(states.Reload, _reloadState);

        _followState.AddTransition(states.Idle, _idleState);
        _followState.AddTransition(states.Attack, _attackState);
        _followState.AddTransition(states.Escape, _escapeState);
        _followState.AddTransition(states.Reload, _reloadState);

        _attackState.AddTransition(states.Idle, _idleState);
        _attackState.AddTransition(states.Follow, _followState);
        _attackState.AddTransition(states.Escape, _escapeState);
        _attackState.AddTransition(states.Reload, _reloadState);

        _reloadState.AddTransition(states.Idle, _idleState);
        _reloadState.AddTransition(states.Attack, _attackState);
        _reloadState.AddTransition(states.Follow, _followState);
        _reloadState.AddTransition(states.Escape, _escapeState);

        _escapeState.AddTransition(states.Idle, _idleState);
        _escapeState.AddTransition(states.Follow, _followState);

        fsm.SetState(_idleState);
    }
Пример #2
0
    // The tile has 3 states: idle, wrapping and moving
    // If it's on idle and userSwipe transition is fired, it changes to moving
    // If it's on moving and reachedGoal transition is fired, it returns to idle
    // If it's on moving and offGrid is fired, it changes to wrapping
    // If it's on wrapping and finished wrap is fired, it changes to idle
    private void MakeFSM()
    {

        IdleState idle = new IdleState(this);
        idle.AddTransition(Transition.UserSwiped, StateID.Follow);

        FollowState follow = new FollowState(this);
        follow.AddTransition(Transition.FinishedFollow, StateID.Snapping);

        SnappingState snap = new SnappingState(this);
        snap.AddTransition(Transition.FinishedSnapping, StateID.Idle);
        snap.AddTransition(Transition.OffGrid, StateID.Wrapping);

        WrapState wrap = new WrapState(this);
        wrap.AddTransition(Transition.FinishedWrap, StateID.Idle);

        SetupState setup = new SetupState(this);
        setup.AddTransition(Transition.FinishedSetup, StateID.Idle);

        fsm = new FSMSystem();
        fsm.AddState(setup);
        fsm.AddState(idle);
        fsm.AddState(follow);
        fsm.AddState(snap);
        fsm.AddState(wrap);
    }
Пример #3
0
    private void makeFSM()
    {
        fsm = new FSMSystem();

        FollowState followState = new FollowState(GameManager.Instance.Player,
                                                  GameManager.Instance.Player.GetComponent <Ship>(), speed, NpcType.Enemy);

        followState.AddTransition(Transition.Follow_Attack, StateID.EnemyAttackStateID);

        attackState = new AttackState(gunTipPosition, Vector3.forward * speed,
                                      Resources.Load("Prefabs/shot_prefab") as GameObject, id);
        attackState.AddTransition(Transition.Attack_Follow, StateID.BotFollowStateID);

        fsm.AddState(followState);
        fsm.AddState(attackState);
    }