Exemplo n.º 1
0
    void Awake()
    {
        Fsm = new StateMachine <Enemy>(this);
        State <Enemy> state;

        switch (this.startState)
        {
        case StartState.Wander:
            state = new WanderState(this, Fsm, 30.0f);
            break;

        case StartState.ReachGoal:
            state = new ReachGoalState(this, Fsm, target);
            break;

        case StartState.Flock:
            state = new FlockState(this, Fsm, target, group);
            break;

        case StartState.Flee:
            state = new FleeState(this, Fsm, target);
            break;

        case StartState.FleeMultiple:
            state = new FleeMultipleState(this, Fsm, group);
            break;

        default:
            state = new WanderState(this, Fsm, 30.0f);
            break;
        }
        Fsm.InitialState(state);
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        // Self references
        this.dangerHitbox  = this.transform.FindChild("Danger Zone").gameObject;
        this.targetingCone = this.transform.FindChild("Line of Sight").gameObject;
        _bodyBounds        = CreateBodyBounds();
        Fsm = new StateMachine <Enemy>(this);
        State <Enemy> state;

        switch (this.startState)
        {
        case StartState.Wander:
            state = new WanderState(this, Fsm, 30.0f);
            break;

        case StartState.ReachGoal:
            state = new ReachGoalState(this, Fsm, target);
            break;

        case StartState.Flock:
            state = new FlockState(this, Fsm, target, group);
            break;

        case StartState.Flee:
            state = new FleeState(this, Fsm, target);
            break;

        case StartState.FleeMultiple:
            state = new FleeMultipleState(this, Fsm, group);
            break;

        case StartState.FollowPath:
            Debug.Log("Setting state");
            state = new FollowPathState(this, Fsm, PathFinding.spawnGameObjectsAtPathPoints(PathFinding.generatePath(gameObject, target)));
            Debug.Log("Done setting state");
            break;

        case StartState.SeekTargetWithPath:
            state = new SeekTargetWithPathState(this, Fsm, target);
            break;

        case StartState.Patrol:
            state = new PatrolState(this, Fsm, patrolPath, patrolPauseTime);
            break;

        default:
            state = new WanderState(this, Fsm, 30.0f);
            break;
        }
        Fsm.InitialState(state);

        SetDangerous(false);
    }
Exemplo n.º 3
0
    void Awake()
    {
        Fsm = new StateMachine <Enemy>(this);
        State <Enemy> state;

        switch (this.startState)
        {
        case StartState.Wander:
            state = new DumbWanderState(this, Fsm, 30.0f);
            break;

        case StartState.ReachGoal:
            state = new ReachGoalState(this, Fsm, target);
            break;

        default:
            state = new DumbWanderState(this, Fsm, 30.0f);
            break;
        }
        Fsm.InitialState(state);

        GroupPositions = new List <GameObject>(GroupMembers.Count);
        switch (this.formation)
        {
        case Formation.V:
            generatePositions(Formations.GetVFormation(this.transform.position, spread, GroupMembers.Count));
            break;

        case Formation.Circle:
            generatePositions(Formations.GetCircleFormation(this.transform.position + spread * (new Vector3(1, 0, 0)), this.transform.position, new Vector3(0, 1, 0), GroupMembers.Count));
            break;

        case Formation.Square:
            generatePositions(Formations.GetPolygonFormation(this.transform.position + spread * (new Vector3(1, 0, 0)), this.transform.position, new Vector3(0, 1, 0), 4, GroupMembers.Count));
            break;

        case Formation.Triangle:
            generatePositions(Formations.GetPolygonFormation(this.transform.position + spread * (new Vector3(1, 0, 0)), this.transform.position, new Vector3(0, 1, 0), 3, GroupMembers.Count));
            break;

        case Formation.Polygon:
            if (formationSideCount > 3)
            {
                generatePositions(Formations.GetPolygonFormation(this.transform.position + spread * (new Vector3(1, 0, 0)), this.transform.position, new Vector3(0, 1, 0), formationSideCount, GroupMembers.Count));
            }
            break;
        }
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        _bodyBounds = CreateBodyBounds();
        Fsm         = new StateMachine <Enemy>(this);
        State <Enemy> state;

        switch (this.startState)
        {
        case StartState.Wander:
            state = new WanderState(this, Fsm, 30.0f);
            break;

        case StartState.ReachGoal:
            state = new ReachGoalState(this, Fsm, target);
            break;

        case StartState.Flock:
            state = new FlockState(this, Fsm, target, group);
            break;

        case StartState.Flee:
            state = new FleeState(this, Fsm, target);
            break;

        case StartState.FleeMultiple:
            state = new FleeMultipleState(this, Fsm, group);
            break;

        case StartState.FollowPath:
            Debug.Log("Setting state");
            state = new FollowPathState(this, Fsm, PathFinding.spawnGameObjectsAtPathPoints(PathFinding.generatePath(gameObject, target)));
            Debug.Log("Done setting state");
            break;

        case StartState.SeekTargetWithPath:
            state = new SeekTargetWithPathState(this, Fsm, target);
            break;

        default:
            state = new WanderState(this, Fsm, 30.0f);
            break;
        }
        Fsm.InitialState(state);
    }