示例#1
0
        internal void OnUpdate(out AtsHandles vehicleOperations, AtsVehicleState vehicleState, IntPtr panelArray, IntPtr soundArray)
        {
            PanelOperations.SetSource(panelArray);
            SoundOperations.SetSource(soundArray);

            LastStates.CopyFrom(CurrentStates);
            if (WasJustInitialized)
            {
                LastStates.SetVehicleState(vehicleState);
            }

            CurrentStates.SetVehicleState(vehicleState);

            this.UpdateVelocityFromDeltaLocation();


            ControlHandle.Update();


            foreach (var behaviour in BehaviourArray)
            {
                behaviour.Update();
            }

            LastKeyStates.CopyFrom(CurrentKeyStates);

            vehicleOperations = ControlHandle.Operation;

            WasJustInitialized = false;
        }
示例#2
0
 /// <summary>
 /// Päivittää stateja
 /// </summary>
 public void Update()
 {
     foreach (ButtonProvider cacher in Cachers)
     {
         cacher.Update();
     }
     OldStates = (GamePadState[])CurrentStates.Clone();
     GetNewState();
 }
示例#3
0
 /// <summary>
 /// Add new state, this method check if the
 /// state <see cref="T"/> exists, if not
 /// add the state.
 /// </summary>
 /// <param name="state"></param>
 public void AddState(NfaState <Q> state)
 {
     if (!IsExists(state.Id))
     {
         if (state.StateType == StateType.StartState)
         {
             CurrentStates.Add(state);
         }
         States.Add(state);
     }
 }
示例#4
0
        public void PaintStates()
        {
            var   mood         = CalculateStatesMood();
            float?mostNegative = mood.Values.Min();
            float?mostPositive = mood.Values.Max();

            for (int i = 0; i < CurrentStates.Count(); i++)
            {
                PaitPolygons(CurrentStates[i], GetColor(CurrentStates[i].weight /*, mostNegative, mostPositive*/));
            }
        }
示例#5
0
        private void PopChoice()
        {
            CurrentStates[0].ClearState();
            CurrentStates.Clear();
            if (_statesStack.Count == 0)
            {
                throw new Exception("Choice stack is empty. Unable to fallback to another state.");
            }

            StateMemento memento = _statesStack.Pop();

            _inx  = memento.TokenIndex;
            _move = memento.Move + 1;
            CurrentStates.Add(memento.State);
        }
示例#6
0
        internal void OnDoorStateChanged(bool isClosed)
        {
            if (isClosed)
            {
                CurrentStates.SetDoorState(AtsSimulationStates.DoorStateType.Close);
            }
            else
            {
                CurrentStates.SetDoorState(AtsSimulationStates.DoorStateType.Open);
            }

            foreach (IAtsBehaviour behaviour in Behaviours)
            {
                behaviour.OnDoorStateChanged(CurrentStates.DoorState);
            }
        }
示例#7
0
        internal void OnUpdate(out AtsHandles vehicleOperations, AtsVehicleState vehicleState, IntPtr panelArray, IntPtr soundArray)
        {
            PanelOperations.SetSource(panelArray);
            SoundOperations.SetSource(soundArray);

            LastStates.CopyFrom(CurrentStates);
            CurrentStates.SetVehicleState(vehicleState);

            foreach (IAtsBehaviour behaviour in Behaviours)
            {
                behaviour.Update();
            }

            LastKeyStates.CopyFrom(CurrentKeyStates);

            vehicleOperations = ControlHandle.Handles;
        }
示例#8
0
        public void PerformStep()
        {
            ProcessedWord += Word[CurrentPosition];

            char symbol = Word[CurrentPosition];

            var possibleNextStates = new List <State>();

            foreach (var state in CurrentStates)
            {
                var nextStates = state.PossibleNextStates
                                 .Where(x => x.Value.Invoke(symbol))
                                 .Select(pair => pair.Key);

                nextStates
                .ForEach(s => possibleNextStates.Add(s));
            }


            CurrentStates.Clear();

            foreach (var state in possibleNextStates)
            {
                CurrentStates.Add(state);
            }

            //foreach (var state in CurrentStates)
            //{
            //    for (int i = 0; i < StateTraces.Count; i++)
            //    {
            //        var trace = StateTraces[i];
            //        var brandNewTrace = new StateTrace(trace);
            //        brandNewTrace.Add(state);

            //        if (!StateTraces.Contains(brandNewTrace))
            //            StateTraces.Add(trace);
            //    }
            //}

            CurrentPosition++;
        }
示例#9
0
        /// <summary>
        /// Set state type
        /// </summary>
        /// <param name="key">The state key</param>
        /// <param name="type">The type to  be set</param>
        public void SetStateType(Q key, StateType type)
        {
            NfaState <Q> state = null;

            if ((state = GetState(key)) != null)
            {
                state.StateType = type;
                if (state.StateType == StateType.StartState)
                {
                    CurrentStates.Add(state);
                }
                else
                {
                    CurrentStates.RemoveState(key);
                }
            }
            else
            {
                throw new Exception("State doesn't exists");
            }
        }
示例#10
0
        private void UpdateDisplay(CurrentStates newState, DisplayActions displayAction)
        {
            ShowLoading();
            if (!displayWorker.IsBusy)
            {
                displayState.CurrentState = newState;

                var request = new DisplayRequest()
                {
                    DisplayState       = displayState,
                    CurrentDisplayItem = ItemScroller.CurrentDataItem,
                    DisplayAction      = displayAction
                };

                displayWorker.RunWorkerAsync(request);
            }
            else
            {
                Beep();
            }
        }
示例#11
0
 public void PrepareState()
 {
     CurrentStates.Clear();
     CurrentSpeed  = Speed;
     CurrentDamage = Damage;
 }
示例#12
0
 /// <summary>
 /// Reset the the start states to its origin
 /// </summary>
 public void ResetStartStates()
 {
     CurrentStates.Clear();
     CurrentStates.AddRange(
         States.FindAll(st => st.StateType == StateType.StartState));
 }
示例#13
0
 //save state that reset will revert to
 public void SaveGrid()
 {
     CurrentStates.CopyTo(StartStates, 0);
 }
示例#14
0
        private void UpdateDisplay(CurrentStates newState, DisplayActions displayAction)
        {
            ShowLoading();
            if (!displayWorker.IsBusy)
            {
                displayState.CurrentState = newState;

                var request = new DisplayRequest()
                {
                    DisplayState = displayState,
                    CurrentDisplayItem = ItemScroller.CurrentDataItem,
                    DisplayAction = displayAction
                };

                displayWorker.RunWorkerAsync(request);
            }
            else
            {
                Beep();
            }
        }