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;
    }
示例#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);
            }
        }
    }
示例#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();
    }
示例#7
0
 public override void OnUpdate(ref StackFSM stackStates)
 {
     ref AIBase aiBase = ref stackStates.aiBase;
示例#8
0
 public RoamingPresence(IZone zone, PresenceConfiguration configuration) : base(zone, configuration)
 {
     _fsm = new StackFSM();
     _fsm.Push(new SpawnState(this));
 }
示例#9
0
 public Npc(TagHelper tagHelper)
 {
     _tagHelper     = tagHelper;
     _threatManager = new ThreatManager();
     AI             = new StackFSM();
 }
示例#10
0
 public void Init()
 {
     StateMachine = new StackFSM();
     PushState(StateType.Idle);
 }
示例#11
0
 protected Egg()
 {
     _fsm = new StackFSM();
     _fsm.Push(new WaitForSummonersState(this));
 }
示例#12
0
 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;