private void ChangeState(StateInterface _newState, bool additive) { if (!additive && _currentStates.Count != 0) { _currentStates.Pop().Unload(); } _currentStates.Push(_newState); _currentStates.Peek().Load(); }
public void ChangeState(StateInterface <T> newState) { PreviousState = CurrentState; if (CurrentState != null) { CurrentState.Exit(Owner); } CurrentState = newState; if (CurrentState != null) { CurrentState.Enter(Owner); } }
public static bool Contains(StateInterface element, StateInterface[] array) { foreach (var state in array) { if (state == null) { return(false); } if (string.Compare(state.Return_GDP() + " " + state.Return_Name(), element.Return_GDP() + " " + element.Return_Name(), StringComparison.Ordinal) == 0) { return(true); } } return(false); }
//Создать массив public static StateInterface[] CreateArray(int size) { var state = new StateInterface[size]; var i = 0; while (i < state.Length) { var check = Rnd.Next(1, 4); StateInterface currentState; if (check == 1) { currentState = new Monarchy(monarchyTypes[Rnd.Next(0, monarchyTypes.Length)], NAME[Rnd.Next(0, NAME.Length)], Rnd.Next(277, 833)); } else { if (check == 2) { currentState = new Kingdom(monarchyTypes[Rnd.Next(0, monarchyTypes.Length)], NAME[Rnd.Next(0, NAME.Length)], Rnd.Next(277, 833), MONARCH[Rnd.Next(0, MONARCH.Length)], CONTINENT[Rnd.Next(0, CONTINENT.Length)]); } else { currentState = new Republic(republicTypes[Rnd.Next(0, republicTypes.Length)], NAME[Rnd.Next(0, NAME.Length)], Rnd.Next(344, 966)); } } if (Contains(currentState, state)) { } else { state[i] = currentState; i++; } } return(state); }
private void Start() { if (gameObject.activeSelf == true) { agent = new TrackableObject(agentType, transform.parent.gameObject, transform.position); Tracking.activeObjects.Add(agent); for (int i = 0; i < damageOutput.Length; i++) { damageOutput[i].minDamage = minDamage; damageOutput[i].maxDamage = maxDamage; } currentHealth = maxHealth; currentSatisfaction = maxSatisfaction; currentEnergy = maxEnergy; healthTimer = healthTickTime; energyTimer = energyTickTime; hungerTimer = hungerTickTime; currentState = idle; } }
// Use this for initialization public void Awake() { CurrentState = null; PreviousState = null; GlobalState = null; }
public void Configure(T owner, StateInterface <T> initialState) { Owner = owner; ChangeState(initialState); }
//StateMachine Specific//////////////// public void ChangeState(StateInterface <ZombieMachine> e) { myMachine.ChangeState(e); }
/** Calculate and add transitions to the successor state. * @param from the source stuttered_state * @param da_from the source DA state * @param elem the edge label */ void calc_delta(TreeWithAcceptance from, DA_State da_from, APElement elem) { //StateMapper<SafraTree, int , ptr_hash<algo_state_t>> intermediate_state_map_t; //, PtrComparator<algo_state_t> Dictionary <StateInterface, int> state_map = new Dictionary <StateInterface, int>(); List <StateInterface> state_vector = new List <StateInterface>(); StateInterface start_tree = from.getTree(); //state_map[start_tree] = null; state_map.Add(start_tree, 0); state_vector.Add(start_tree); //push_back #if STUTTERED_VERBOSE std::cerr << "Calculate from state [" << da_from->getName() << "], " << (unsigned int ) elem << ":" << std::endl; std::cerr << start_tree->toString() << std::endl; #endif StateInterface cur_tree = start_tree; while (true) { StateInterface next_tree = _algo.delta(cur_tree as SafraTree, elem).getState(); //typename intermediate_state_map_t::iterator it; //int it = state_map.find(next_tree); //if (it == state_map.end()) if (!state_map.ContainsKey(next_tree)) { // tree doesn't yet exist... // add tree //state_map[next_tree] = state_vector.size(); state_map.Add(next_tree, state_vector.Count); state_vector.Add(next_tree); //push_back cur_tree = next_tree; continue; } else { // found the cycle! int cycle_point = state_map[next_tree]; #if STUTTERED_VERBOSE std::cerr << "-----------------------\n"; for (unsigned int i = 0; i < state_vector.size(); i++) { std::cerr << "[" << i << "] "; if (cycle_point == i) { std::cerr << "* "; } std::cerr << "\n" << state_vector[i]->toString() << std::endl; } std::cerr << "-----------------------\n"; #endif prefix_and_cycle_state_t pac = calculate_prefix_and_cycle_state(state_vector, cycle_point); //DA_State da_prefix = null; DA_State da_cycle = null; if (pac.prefix_state != null && !(pac.prefix_state == pac.cycle_state)) { DA_State da_prefix = add_transition(da_from, pac.prefix_state, elem); da_cycle = add_transition(da_prefix, pac.cycle_state, elem); } else { da_cycle = add_transition(da_from, pac.cycle_state, elem); } da_cycle.edges().set(elem, da_cycle); return; } } }
public List <State> select() { StateInterface ti = ds.CreateState(); return(ti.Select()); }