Exemplo n.º 1
0
    private void Start()
    {
        Debug.Log("Bee");
        movementSM = new StateMachine();
        searching  = new SearchingState(this, movementSM);
        fleeing    = new FleeingState(this, movementSM);
        gathering  = new GatheringState(this, movementSM);
        dancing    = new DancingState(this, movementSM);
        atHive     = new AtHiveState(this, movementSM);

        movementSM.Initialize(searching);  // Default
    }
Exemplo n.º 2
0
    protected new void Awake()
    {
        base.Awake();

        _SM = new StateMachine();
        WayTooCloseState    s1 = new WayTooCloseState(_SM, this);
        FleeingState        s2 = new FleeingState(_SM, this);
        InSafeDistanceState s3 = new InSafeDistanceState(_SM, this);

        s1.SetTargetStates(s2);
        s2.SetTargetStates(s1, s3);
        s3.SetTargetStates(s2);
        _SM.SetStartingState(s1);
    }
Exemplo n.º 3
0
    // Use this for initialization
    protected override void Awake()
    {
        base.Awake();

        //Setup states
        PatrollingState patrollingState = gameObject.AddComponent <PatrollingState>();

        patrollingState.SetNodes(m_patrollingNodes);
        patrollingState.SetMovementVelocity(m_forwardVelocity);

        MoveTowardsState moveTowardsState = gameObject.AddComponent <MoveTowardsState>();

        moveTowardsState.SetMovementVelocity(m_forwardVelocity);

        InvestigateState investigateState = gameObject.AddComponent <InvestigateState>();

        investigateState.SetMovementVelocity(m_forwardVelocity);

        IdleState idleState = gameObject.AddComponent <IdleState>();

        idleState.SetRandomTime(m_idleMinTime, m_idleMaxTime);

        AttackingState attackingState = gameObject.AddComponent <AttackingState>();

        FleeingState fleeingState = gameObject.AddComponent <FleeingState>();

        fleeingState.SetMovementVelocity(m_forwardVelocity);
        fleeingState.SetFleeingMaxTime(m_fleeingMaxTime);

        //Assigning transitons
        patrollingState.AddInterruptTransition(TargetSightTransition.CreateComponent(gameObject, m_detectionRange), moveTowardsState);

        moveTowardsState.AddInterruptTransition(NotTransition.CreateComponent(gameObject, TargetSightTransition.CreateComponent(gameObject, m_detectionRange)), investigateState);
        moveTowardsState.AddInterruptTransition(TargetWithinRangeTransition.CreateComponent(gameObject, m_attackingRange), attackingState);

        investigateState.AddEndTransition(BaseTransition.CreateComponent(gameObject), idleState);
        investigateState.AddInterruptTransition(TargetSightTransition.CreateComponent(gameObject, m_detectionRange), moveTowardsState);

        idleState.AddEndTransition(BaseTransition.CreateComponent(gameObject), patrollingState);
        idleState.AddInterruptTransition(TargetSightTransition.CreateComponent(gameObject, m_detectionRange), moveTowardsState);

        attackingState.AddEndTransition(BaseTransition.CreateComponent(gameObject), fleeingState);

        fleeingState.AddEndTransition(BaseTransition.CreateComponent(gameObject), moveTowardsState);
        fleeingState.AddInterruptTransition(NotTransition.CreateComponent(gameObject, TargetWithinRangeTransition.CreateComponent(gameObject, m_fleeingDistance)), moveTowardsState);

        //Setup intial state
        GetComponent <StateManager>().SetInitialState(patrollingState);
    }
Exemplo n.º 4
0
 public void SetTargetStates(FleeingState fleeingState)
 {
     _fleeingState = fleeingState;
 }