protected override void Awake()
    {
        base.Awake();
        OnDeath += onDeath;

        navAgent      = GetComponent <NavMeshAgent>();
        stackOfStates = GetComponent <StackFSM>();

        if (PotentialStates.Length > 0)
        {
            State patrol = PotentialStates.FirstOrDefault(x => x.StateName == StateNames.PatrolState);
            State idle   = PotentialStates.FirstOrDefault(x => x.StateName == StateNames.IdleState);
            if (patrol)
            {
                stackOfStates.PushState(patrol);
            }
            else if (idle)
            {
                stackOfStates.PushState(idle);
            }
        }

        GetPlayer();

        //TODO when speed changes also set the navAgentSpeed
        navAgent.speed = Speed;
    }
Example #2
0
 public override void OnUpdate(ref StackFSM stackStates)
 {
     base.OnUpdate(ref stackStates);
     stateExpireTime -= Time.deltaTime;
     if (stateExpireTime <= 0.0f)
     {
         stackStates.PopState();
     }
 }
 public override void OnUpdate(ref StackFSM stackStates)
 {
     if (stackStates.aiBase.LineSightToPlayer())
     {
         State follow = stackStates.aiBase.PotentialStates.FirstOrDefault(x => x.StateName == StateNames.FollowState);
         if (follow)
         {
             stackStates.PushState(follow);
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        State currentState = GetCurrentState();

        if (currentState != null)
        {
            if (!aiBase.BossStopped)
            {
                StackFSM stackfsm = gameObject.GetComponent <StackFSM>();
                currentState.OnUpdate(ref stackfsm);
            }
        }
    }
Example #5
0
    private void Awake()
    {
        _anim     = GetComponent <Animator>();
        _navAgent = GetComponent <NavMeshAgent>();
        _collider = GetComponent <SphereCollider>();

        _stateMachine      = new StackFSM();
        _nearbyTargets     = new List <Agent>();
        _target            = null;
        _lastKnownPosition = Vector3.zero;
        _speed             = _navAgent.speed;
        _navAgent.speed    = 0.0f;
        _health            = new Health(MaxHealth);
    }
    void Awake()
    {
        instance    = this;
        LevelStates = new State[] {
            new TransitState(StateType.Transit),
            new JumpState(StateType.Jump),
            new StationArrivalState(StateType.StationArrival),
            new StationInsideState(StateType.StationInside),
            new StationExitState(StateType.StationExit),
            new MissionCompleteState(StateType.MissionComplete)
        };
        stateMachine = new StackFSM();

        // Create Json data loader
        new JsonLoader();
        // and Writer
        new JsonWriter();
        // and ID Generator
        new ID_Generator();
    }
Example #7
0
 public override void OnUpdate(ref StackFSM stackStates)
 {
     ref AIBase aiBase = ref stackStates.aiBase;
Example #8
0
 public RoamingPresence(IZone zone, PresenceConfiguration configuration) : base(zone, configuration)
 {
     _fsm = new StackFSM();
     _fsm.Push(new SpawnState(this));
 }
Example #9
0
 public Npc(TagHelper tagHelper)
 {
     _tagHelper     = tagHelper;
     _threatManager = new ThreatManager();
     AI             = new StackFSM();
 }
Example #10
0
 public void Init()
 {
     StateMachine = new StackFSM();
     PushState(StateType.Idle);
 }
Example #11
0
 protected Egg()
 {
     _fsm = new StackFSM();
     _fsm.Push(new WaitForSummonersState(this));
 }
 public abstract void OnUpdate(ref StackFSM stackStates);
 public override void OnUpdate(ref StackFSM stackStates)
 {
     base.OnUpdate(ref stackStates);
     Patrol(ref stackStates);
 }
 void Patrol(ref StackFSM stackStates)
 {
     ref AIBase   aiBase   = ref stackStates.aiBase;