Esempio n. 1
0
    public IEnumerator Go(StateInstance stateInstance, MonoBehaviour behaviour)
    {
        if(actions != null) {
            int i = 0;
            int len = actions.Count;
            while(!stateInstance.terminate && i < len) {
                SequencerAction action = actions[i];

                if(action.delay > 0) {
                    yield return new WaitForSeconds(action.delay);
                }

                //ensure nothing is started when we pause or terminate early
                while(stateInstance.pause) {
                    yield return new WaitForFixedUpdate();

                    if(stateInstance.terminate)
                        break;
                    else
                        continue;
                }

                if(!stateInstance.terminate) {
                    stateInstance.startTime = Time.time;
                    action.Start(behaviour, stateInstance);

                    while(!stateInstance.terminate && !action.Update(behaviour, stateInstance)) {
                        yield return new WaitForFixedUpdate();

                        //ensure we wait until unpaused before updating again
                        //warning: state from start might change.........
                        //look at this comment if shit hits the fan in game
                        //however...we don't want finish or update to happen when we
                        //rely on certain state to be consistent outside...
                        while(!stateInstance.terminate && stateInstance.pause) {
                            yield return new WaitForFixedUpdate();
                            continue;
                        }
                    }

                    action.Finish(behaviour, stateInstance);

                    i++;
                    if(loop && i == len) {
                        i = 0;
                        yield return new WaitForFixedUpdate();
                    }
                }
                else {
                    break;
                }
            }
        }

        yield break;
    }
Esempio n. 2
0
        public static IState Instance(String message, StateInstance <String> ConfirmState, StateInstance CancelState)
        {
            input         = new StringBuilder();
            Label.LastKey = -1;
            sequence      = 0;
            cashierMsg    = message;
            DisplayAdapter.Cashier.Show(cashierMsg);

            //TODO: Cursor satirbasi olmali - overwrite mode
            ReturnConfirm = ConfirmState;
            ReturnCancel  = CancelState;
            return(state);
        }
Esempio n. 3
0
 public static new IState Instance(String message, StateInstance <decimal> ConfirmState)
 {
     return(Instance(message, ConfirmState, null));
 }
Esempio n. 4
0
        public static new IState Instance(String message, decimal defaultValue, StateInstance <decimal> ConfirmState, StateInstance CancelState)
        {
            IState baseState = EnterDecimal.Instance(message, defaultValue, ConfirmState, CancelState);

            return(state);
        }
Esempio n. 5
0
 public abstract AgentInput Execute(StateInstance instance, BehaviourContext context);
Esempio n. 6
0
 public override void Enter()
 {
     ReturnCancel = null;
     ProcessSelected((MenuLabel)ie.Current);
 }
Esempio n. 7
0
 /// <summary>
 /// EnterInteger Instance
 /// </summary>
 /// <param name="message">
 /// Cashier message.
 /// </param>
 /// <param name="ConfirmState">
 /// ConfirmState:what state the machine should assume after user hits Enter key.
 /// </param>
 /// <param name="CancelState">
 /// CancelState:what state the machine should assume after user hits Escape key.
 /// </param>
 /// <returns>
 /// EnterInteger State.
 /// </returns>
 public static IState Instance(String message, StateInstance <int> ConfirmState, StateInstance CancelState)
 {
     input = new Number();
     ((EnterInteger)state).defaultValueOn = false;
     cashierMsg = message;
     DisplayAdapter.Cashier.Show(message);
     ReturnConfirm = ConfirmState;
     ReturnCancel  = CancelState;
     return(state);
 }
Esempio n. 8
0
        /// <summary>
        /// EnterInteger instance.
        /// </summary>
        /// <param name="message">
        /// Cashier message.
        /// </param>
        /// <param name="defaultValue">
        /// Default input string that will be appended.
        /// </param>
        /// <param name="ConfirmState">
        /// ConfirmState:what state the machine should assume after user hits Enter key.
        /// </param>
        /// <param name="CancelState">
        /// CancelState:what state the machine should assume after user hits Escape key.
        /// </param>
        /// <returns>
        /// EnterInteger State
        /// </returns>
        public static IState Instance(String message, decimal defaultValue, StateInstance <int> ConfirmState, StateInstance CancelState)
        {
            input = new Number(defaultValue);
            ((EnterInteger)state).defaultValueOn = true;
            cashierMsg = message;
            DisplayAdapter.Cashier.Show("{0}\n{1}\t", cashierMsg, input.ToString());


            DisplayAdapter.Cashier.Append(input.ToString());

            //TODO: Cursor satirbasi olmali - overwrite mode
            ReturnConfirm = ConfirmState;
            ReturnCancel  = CancelState;
            return(state);
        }
Esempio n. 9
0
        public static IState Instance(String message, StateInstance <decimal> ConfirmState, StateInstance CancelState, StateInstance <decimal> RepeatState)
        {
            IState baseState = EnterInteger.Instance(message, null, CancelState);

            ReturnConfirm = ConfirmState;
            ReturnRepeat  = RepeatState;
            firstTime     = true;
            return(state);
        }
Esempio n. 10
0
        public static IState ShowMenu()
        {
            try
            {
                cr.Printer.EnterServiceMode(lastPassword);
            }
            catch (CmdSequenceException ex)
            {
                cr.Log.Error("CmdSequenceException occured. {0}", ex);
            }
            catch (MissingCashierException mce)
            {
                cr.Log.Error("MissingCashierException occured. {0}", mce);
                Confirm wrongPassword = new Confirm(PosMessage.SERVICE_PASSWORD_INVALID,
                                                    new StateInstance(Instance));
                return(AlertCashier.Instance(wrongPassword));
            }
            catch (SVCPasswordOrPointException ex)
            {
                cr.Log.Error("SVCPasswordOrPointException occured. {0}", ex);
                return(ConfirmCashier.Instance(new Confirm(PosMessage.ATTACH_JUMPER_AND_TRY_AGAIN,
                                                           new StateInstance(ShowMenu),
                                                           new StateInstance(ShowMenu))));
            }
            catch (BlockingException ex)
            {
                cr.Log.Error("BlockingException occured. {0}", ex);
                return(ConfirmCashier.Instance(new Confirm(PosMessage.ATTACH_JUMPER_AND_RESTART_FPU,
                                                           new StateInstance(ShowMenu),
                                                           new StateInstance(ShowMenu))));
            }


            ReturnCancel = new StateInstance(Login.Instance);
            MenuList menuHeaders = new MenuList();
            int      index       = 1;

            //menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
            //    PosMessage.SERVICE, index++, PosMessage.MENU_LOGO)));
            //menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
            //    PosMessage.SERVICE, index++, PosMessage.MENU_VAT_RATES)));
            menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
                                                        PosMessage.SERVICE, index++, PosMessage.MENU_DAILY_MEMORY_FORMAT)));
            menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
                                                        PosMessage.SERVICE, index++, PosMessage.MENU_DATE_AND_TIME)));
            menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
                                                        PosMessage.SERVICE, index++, PosMessage.MENU_CREATE_DB)));
            menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
                                                        PosMessage.SERVICE, index++, PosMessage.MENU_PRINT_LOGS)));
            menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
                                                        PosMessage.SERVICE, index++, PosMessage.MENU_FACTORY_SETTING)));
            menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
                                                        PosMessage.SERVICE, index++, PosMessage.MENU_CLOSE_FM)));
            menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
                                                        PosMessage.SERVICE, index++, PosMessage.MENU_EXTERNAL_DEV_SETTINGS)));
            menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
                                                        PosMessage.SERVICE, index++, PosMessage.MENU_UPDATE_FIRMWARE)));
            //menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
            //    PosMessage.SERVICE, index++, PosMessage.MENU_START_FM_TEST)));
            menuHeaders.Add(new MenuLabel(String.Format("{0}\t{1,2}\n{2}",
                                                        PosMessage.SERVICE, index++, PosMessage.MENU_EXIT_SERVICE)));



            List.Instance(menuHeaders);
            return(state);
        }
Esempio n. 11
0
 internal Error(Exception ex, StateInstance <Hashtable> ConfirmState, StateInstance CancelState)
     : this(ex, ConfirmState)
 {
     ReturnCancel = CancelState;
 }
Esempio n. 12
0
 internal Error(Exception ex, StateInstance <Hashtable> ConfirmState)
     : this(ex)
 {
     Data = new Hashtable();
     ReturnConfirmWithArgs = ConfirmState;
 }
Esempio n. 13
0
 internal Error(Exception ex, StateInstance ConfirmState)
     : this(ex)
 {
     ReturnConfirm = ConfirmState;
 }
Esempio n. 14
0
 public static IState Instance(IDoubleEnumerator ide, ProcessSelectedItem psi, StateInstance returnCancel)
 {
     ProcessSelected = psi;
     ReturnCancel    = returnCancel;
     return(Instance(ide));
 }
Esempio n. 15
0
 public static IState Instance(Exception e, StateInstance RetInstance)
 {
     ReturnInstance = RetInstance;
     return(Instance(e));
 }
Esempio n. 16
0
        public static IState Instance(String message, String defaultValue, StateInstance <String> ConfirmState, StateInstance CancelState)
        {
            IState returnState = Instance(message, ConfirmState, CancelState);

            input.Append(defaultValue);
            DisplayAdapter.Cashier.Append(defaultValue);
            return(returnState);
        }
Esempio n. 17
0
 /// <summary>
 /// EnterInteger instance.
 /// </summary>
 /// <param name="message">
 /// Cashier message.
 /// </param>
 /// <param name="defaultValue">
 ///  Default input value.
 /// </param>
 /// <param name="ConfirmState">
 /// ConfirmState:what state the machine should assume after user hits Enter key.
 /// </param>
 /// <param name="CancelState">
 /// CancelState:what state the machine should assume after user hits Escape key.
 /// </param>
 /// <returns>
 /// EnterInteger State.
 /// </returns>
 public static IState Instance(String message, int defaultValue, StateInstance <int> ConfirmState, StateInstance CancelState)
 {
     return(Instance(message, new Decimal(defaultValue), ConfirmState, CancelState));
 }
Esempio n. 18
0
 public static IState Instance(String message, decimal defaultValue, StateInstance <decimal> ConfirmState)
 {
     return(Instance(message, defaultValue, ConfirmState, null));
 }
Esempio n. 19
0
 /// <summary>
 /// EnterInteger Instance
 /// </summary>
 /// <param name="message">
 /// Cashier message.
 /// </param>
 /// <param name="ConfirmState">
 /// ConfirmState:what state the machine should assume after user hits Enter key.
 /// </param>
 /// <returns>
 /// EnterInteger State.
 /// </returns>
 public static IState Instance(String message, StateInstance <int> ConfirmState)
 {
     return(Instance(message, ConfirmState, null));
 }
Esempio n. 20
0
        public static IState Instance(String message, decimal defaultValue, StateInstance <decimal> ConfirmState, StateInstance CancelState)
        {
            IState baseState = EnterInteger.Instance(message, defaultValue, null, CancelState);

            ReturnConfirm = ConfirmState;
            return(state);
        }
Esempio n. 21
0
    public IEnumerator Go(StateInstance stateInstance, MonoBehaviour behaviour)
    {
        if (actions != null)
        {
            int i   = 0;
            int len = actions.Count;
            while (!stateInstance.terminate && i < len)
            {
                SequencerAction action = actions[i];

                if (action.delay > 0)
                {
                    yield return(new WaitForSeconds(action.delay));
                }

                //ensure nothing is started when we pause or terminate early
                while (stateInstance.pause)
                {
                    yield return(new WaitForFixedUpdate());

                    if (stateInstance.terminate)
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }

                if (!stateInstance.terminate)
                {
                    stateInstance.startTime = Time.time;
                    action.Start(behaviour, stateInstance);

                    while (!stateInstance.terminate && !action.Update(behaviour, stateInstance))
                    {
                        yield return(new WaitForFixedUpdate());

                        //ensure we wait until unpaused before updating again
                        //warning: state from start might change.........
                        //look at this comment if shit hits the fan in game
                        //however...we don't want finish or update to happen when we
                        //rely on certain state to be consistent outside...
                        while (!stateInstance.terminate && stateInstance.pause)
                        {
                            yield return(new WaitForFixedUpdate());

                            continue;
                        }
                    }

                    action.Finish(behaviour, stateInstance);

                    i++;
                    if (loop && i == len)
                    {
                        i = 0;
                        yield return(new WaitForFixedUpdate());
                    }
                }
                else
                {
                    break;
                }
            }
        }

        yield break;
    }
Esempio n. 22
0
 public static IState Instance(IDoubleEnumerator ide, ProcessSelectedItem <MenuLabel> psi, StateInstance returnCancel)
 {
     ReturnCancel = returnCancel;
     return(Instance(ide, psi));
 }