public override bool Update(GameTime gameTime, float percent) { bool retVal = State.Action(percent, gameTime); if (Visible) { retVal |= base.Update(gameTime, percent); } return(retVal); }
public void Action() { if (_current != null) { _current.Action(); _current = _current.Next(); //Generic transitions if (_animal != null && !_isDead && (_animal.animal.happiness == 0 || _animal.animal.hunger == 100)) { _isDead = true; _current = new StateDead(this); } } }
private void Update() { if (state == TankAIState.waiting) { return; } if (Time.time - lastCheckTime > configs.checkInterval) { sensoringSimulator.FindEnemyTanksWithinDistance( transform.position, configs.findingDistance, ObservedEnemyTanks, tank.seatID); sensoringSimulator.LoseEnemyTanksWithoutDistance( transform.position, configs.findingDistance, ObservedEnemyTanks); if (ObservedEnemyTanks.Contains(TargetTank) && TryIfShootable(TargetTank.transform.position) && (targetTank.transform.position - transform.position).magnitude > keepingDistance) { if (currentMotionState == MotionStates[(int)MotionStateIndices.going]) { currentMotionState = MotionStates[(int)MotionStateIndices.stopping]; currentMotionState.Start(); } } else if (ObservedEnemyTanks.Contains(TargetTank) && (!TryIfShootable(TargetTank.transform.position) || (targetTank.transform.position - transform.position).magnitude > keepingDistance)) { DestinationPosition = TargetTank.transform.position; currentMotionState = MotionStates[(int)MotionStateIndices.going]; currentMotionState.Start(); } else { for (int i = 0; i < ObservedEnemyTanks.Count; i++) { if (TryIfShootable(ObservedEnemyTanks[i].transform.position)) { TargetTank = ObservedEnemyTanks[i]; currentShootingState = ShootingStates[(int)ShootingStateIndices.shooting]; currentShootingState.Start(); break; } } } lastCheckTime = Time.time; } currentMotionState.Action(); State nextState = currentMotionState.Decide(); if (nextState != currentMotionState) { tankStateInfo_motion.lastState = currentMotionState; currentMotionState = nextState; currentMotionState.Start(); } currentShootingState.Action(); nextState = currentShootingState.Decide(); if (nextState != currentShootingState) { currentShootingState = nextState; currentShootingState.Start(); } }
public void Action(ButtonPayload payload) { State.Action(payload); }
public override bool Update(GameTime gameTime, float percent) { base.Update(gameTime, percent); return(State.Action(percent, gameTime)); }
private void Update() { _currentState.Action(); _currentState.Reaction(); }
private void Update() { _state.Action(); }
public int Action(int index, Menu m, GameObject guiTextLink) { return(State.Action(index, m, guiTextLink)); }
/// <summary> /// Update FSM and check for a new state. /// </summary> public void Update() { currentState.Action(); currentState = currentState.GetNextState(); }
public bool ToState(int name) { if (!stateMap.ContainsKey(name)) return false; if (crtState != null && name == crtState.GetStateName()) return false; if (crtState != null) { crtState.Action(StateState.LEAVE); } crtState = stateMap[name]; crtState.Action(StateState.ENTER); return true; }