Beispiel #1
0
    protected override void ConstructFSM()
    {
        aiType = AIManager.AITypes.Swarmer;
        Flock swarm = transform.parent.GetComponent <Flock>();
        //States
        SpawnState             spawn  = new SpawnState(this);
        SwarmLeaderPatrolState patrol = new SwarmLeaderPatrolState(this, swarm);
        SwarmLeaderAttackState attack = new SwarmLeaderAttackState(this, swarm);
        SwarmLeaderDefendState defend = new SwarmLeaderDefendState(this, swarm);

        spawn.AddTransition(Transition.Defend, FSMStateID.Defend);

        //Transitions
        patrol.AddTransition(Transition.Attack, FSMStateID.Attacking);
        patrol.AddTransition(Transition.Patrol, FSMStateID.Patrolling);

        attack.AddTransition(Transition.Patrol, FSMStateID.Patrolling);
        attack.AddTransition(Transition.Defend, FSMStateID.Defend);

        defend.AddTransition(Transition.Patrol, FSMStateID.Patrolling);

        //Add states
        AddFSMState(spawn);
        AddFSMState(defend);
        AddFSMState(patrol);
        AddFSMState(attack);
    }
Beispiel #2
0
    protected override void ConstructFSM()
    {
        base.aiType = AIManager.AITypes.Charger;
        DeadState          deadState  = new DeadState(this);
        SpawnState         spawnState = new SpawnState(this);
        ChargerPatrolState patrol     = new ChargerPatrolState(this, true);

        attack = new ChargerAttackState(this);

        spawnState.AddTransition(Transition.Patrol, FSMStateID.Patrolling);

        patrol.AddTransition(Transition.NoHealth, FSMStateID.Dead);
        patrol.AddTransition(Transition.SawPlayer, FSMStateID.Attacking); //Change this

        attack.AddTransition(Transition.NoHealth, FSMStateID.Dead);
        attack.AddTransition(Transition.Patrol, FSMStateID.Patrolling);
        //What's the difference between saw player and attack transition?

        AddFSMState(spawnState);
        AddFSMState(patrol);
        AddFSMState(deadState);
        AddFSMState(attack);
    }