Example #1
0
        public void Next()
        {
            if (!Interactive)
            {
                return;
            }
            HashSet <Cell> tmp = new HashSet <Cell>();

            foreach (Cell c in currentState)
            {
                if (survival[aliveNeighbors(c)])
                {
                    tmp.Add(c);
                }
                foreach (Cell n in c.Neighbors)
                {
                    if (!currentState.Contains(n) && birth[aliveNeighbors(n)])
                    {
                        tmp.Add(n);
                    }
                }
            }
            states.Add(tmp);
            OnStateChange.Invoke();
        }
Example #2
0
 public void Reset()
 {
     x      = y = 0; zoom = pb.Width / 20;
     states = new List <HashSet <Cell> >();
     states.Add(new HashSet <Cell>());
     OnStateChange.Invoke();
 }
Example #3
0
        /// <summary>
        /// Restores an older or newer state.
        /// </summary>
        /// <param name="direction">The direction to restore in. If less than 0, an older state will be used. If greater than 0, a newer state will be used.</param>
        public void RestoreState(int direction)
        {
            if (bulkChangesStarted > 0)
            {
                return;
            }

            if (savedStates.Count == 0)
            {
                return;
            }

            int newState = Math.Clamp(currentState + direction, 0, savedStates.Count - 1);

            if (currentState == newState)
            {
                return;
            }

            isRestoring = true;

            patcher.Patch(savedStates[currentState], savedStates[newState]);
            currentState = newState;

            isRestoring = false;

            OnStateChange?.Invoke();
            updateBindables();
        }
Example #4
0
 /// <summary> Changes the machine's state from the CurrentState to the nextState. </summary>
 public virtual void SwitchToNewState(Type nextState)
 {
     CurrentState.AfterExecution();
     availableStates[nextState].BeforeExecution();
     CurrentState = availableStates[nextState];
     OnStateChange?.Invoke(availableStates[nextState]);
 }
Example #5
0
 public void SetState(ConnectionState State)
 {
     CurrentState = State;
     OnStateChange?.Invoke(new ClientStateChangeInfo()
     {
         NewState = State, StateChangingClient = this
     });
 }
Example #6
0
        public AtemSDKStateMonitor(IBMDSwitcher switcher)
        {
            this.switcher = switcher;
            //switcher.AllowStreamingToResume();

            _root = new SwitcherPropertiesCallback(() => OnStateChange?.Invoke(this));
            switcher.AddCallback(_root);
        }
Example #7
0
 public void PushState(GameState newState)
 {
     drawOrder         += 100;
     newState.DrawOrder = drawOrder;
     AddState(newState);
     //Let everyone know we just changed states
     OnStateChange?.Invoke(this, null);
 }
 /// <summary>
 /// Set the new WebSocket connection state and propogate event
 /// </summary>
 /// <param name="state"></param>
 private void SetState(WebSocketState state)
 {
     if (state != State)
     {
         State = state;
         OnStateChange?.Invoke(state);
     }
 }
Example #9
0
        /// <summary>
        /// Pops the top Ai state instance from the state stack.
        /// </summary>
        /// <returns>Reference to the freshly popped state</returns>
        public IAiState PopState()
        {
            Messages.Add(string.Format(Resources.MSG_STATE_PUSHED, Owner.ID, Owner.Name, CurrentState.ID, CurrentState.Name));
            var state = _stateStack.Pop();

            OnStateChange?.Invoke(this, null);

            return(state);
        }
Example #10
0
        /// <summary>
        /// Pushes a new state onto the Ai state stack.
        /// </summary>
        /// <param name="state">Instance object that is implements the IAiState interface</param>
        public void PushState(IAiState state)
        {
            Validation.IsNotNull(state, "state");

            Messages.Add(string.Format(Resources.MSG_STATE_PUSHED, Owner.ID, Owner.Name, state.ID, state.Name));
            _stateStack.Push(state);

            OnStateChange?.Invoke(this, null);
        }
Example #11
0
 private void Chrome_AddressChanged(object sender, AddressChangedEventArgs e)
 {
     SetAddress(e.Address);
     if (e.Address.Contains(ALIMAMA_HOMEPAGE_URL))
     {
         OnStateChange?.Invoke(Enums.StateLogType.TaoBaoSignSuccess, "登录淘宝成功");
         chrome.Load(COUPON_DOWNLOAD_URL);
     }
 }
Example #12
0
        public void SetState(byte[] encodedState)
        {
            serializer.SetState(encodedState);

            if (OnStateChange != null)
            {
                OnStateChange.Invoke(this, new StateChangeEventArgs <T>(serializer.GetState(), true));
            }
        }
Example #13
0
 private void Pb_MouseWheel(object sender, MouseEventArgs e)
 {
     if (!Interactive)
     {
         return;
     }
     zoom = Math.Max(5, zoom + Math.Sign(e.Delta));
     OnStateChange.Invoke();
 }
Example #14
0
 /* The PopState() function checks if there's something on the stack.
  * If there is, the top GameState is removed using RemoveState(), and the currentDraw field is decremented by the interval.
  * Finally, the OnStateChange event handler is invoked so that its event runs if it's not null. */
 public void PopState()
 {
     if (gameStates.Count > 0)
     {
         RemoveState();
         currentDraw -= incrementDraw;
         OnStateChange?.Invoke(this, null);
     }
 }
Example #15
0
 public override void Close()
 {
     if (null != client)
     {
         client.Close();
         connectionState = false;
         OnStateChange?.Invoke(false);
     }
 }
Example #16
0
 /// <summary>
 /// Updates the state of a process and fires events.
 /// </summary>
 /// <param name="state"></param>
 internal void UpdateState(ProcessState state)
 {
     State = state;
     OnStateChange?.Invoke(this, new StateEventArgs(Id, State));
     if (ParentId > 0)
     {
         OnChildStateChange?.Invoke(this, new StateEventArgs(Id, State));
     }
 }
Example #17
0
        public void PrevState()
        {
            if (statesQueue.Count() > 1)
            {
                statesQueue.Pop();
            }

            OnStateChange?.Invoke(this, new EventArgs());
        }
Example #18
0
        protected void Patch(byte[] delta)
        {
            serializer.Patch(delta);

            if (OnStateChange != null)
            {
                OnStateChange.Invoke(this, new StateChangeEventArgs <T>(serializer.GetState()));
            }
        }
Example #19
0
 void OnDisable()
 {
     allDimensionObjects.Remove(this);
     isBeingDestroyed = true;
     visibilityState  = VisibilityState.visible;
     OnStateChangeImmediate?.Invoke(this);
     OnStateChange?.Invoke(this);
     OnStateChangeSimple?.Invoke();
     SetChannelValuesInMaterials(false);
 }
Example #20
0
 public void TurnOff()
 {
     if (canvasGroup == null)
     {
         canvasGroup = GetComponent <CanvasGroup>();
     }
     canvasGroup.TurnOff(visibility, interaction, blocksRays);
     CurrentState = false;
     OnStateChange?.Invoke(false);
 }
Example #21
0
 /* This function adds a state to the stack and handles draw order incrementing. */
 public void PushState(GameState newState)
 {
     /* First, the current draw order is incremented by the correct interval.
      * Then, the new state's DrawOrder property is set to the currentDraw field (meaning it will get drawn at the top).
      * The state is added to the stack using AddState, and then the OnStateChange event handler is invoked so its event is executed if it isn't null. */
     currentDraw       += incrementDraw;
     newState.DrawOrder = currentDraw;
     AddState(newState);
     OnStateChange?.Invoke(this, null);
 }
Example #22
0
 private void visitor_SendCookie(Cookie obj)
 {
     if (obj.Name == "MGJToken")
     {
         var token = JsonConvert.DeserializeObject <MoGuJie.Token>(obj.Value);
         mgj.Token = token;
         OnStateChange?.Invoke(Enums.StateLogType.MoGuJieSignSuccess, "蘑菇街授权成功");
         new Task(() => { LoadCoupon(); }).Start();
     }
 }
Example #23
0
        public void AddState(string pStateName, OnStateChange pOnEnterState, OnStateChange pOnLeaveState)
        {
            SStateEntry e = new SStateEntry();

            e.name         = pStateName;
            e.OnEnterState = pOnEnterState;
            e.OnLeaveState = pOnLeaveState;

            mUIStates.Add(e);
        }
Example #24
0
 public void PopState()
 {
     if (!(_gameStates?.Count > 0))
     {
         return;
     }
     RemoveState();
     _drawOrder -= DrawOrderInc;
     OnStateChange?.Invoke(this, EventArgs.Empty);
 }
Example #25
0
 public void SetGameState(GameState state)
 {
     Debug.Log($"GameState changed: {state}");
     GameState = state;
     OnStateChange?.Invoke(state);
     if (GameState == GameState.WaitForStart)
     {
         OnRestartLevel?.Invoke();
     }
 }
Example #26
0
        private void UpdateState(ConnectionState state)
        {
            if (state == State)
            {
                return;
            }

            State = state;
            OnStateChange?.Invoke(state);
        }
        protected void SetState(T state)
        {
            CurrentState = state;
            OnStateChange?.Invoke(CurrentState);

            if (_transitions.TryGetValue(state, out var callback))
            {
                callback();
            }
        }
Example #28
0
 public void Connect()
 {
     if (connectOnce)
     {
         OnStateChange?.Invoke(State == ClientExState.Connected ? 0 : 1, "只能連線一次");
         return;
     }
     connectOnce = true;
     m_Connect();
 }
Example #29
0
 public void ChangeState(GameState newState)
 {
     while (states.Count > 0)
     {
         RemoveState();
     }
     newState.DrawOrder = drawOrder = initialDrawOrder;
     AddState(newState);
     OnStateChange?.Invoke(this, null);
 }
Example #30
0
    public void SetCurrentState(State state)
    {
        Debug.Log("state: " + state);
        var prev = Cur;

        Cur = state;
        if (OnStateChange != null)
        {
            OnStateChange.Invoke(prev, state);
        }
    }
Example #31
0
    protected override void OnDestroy()
    {
        base.OnDestroy();

        stateCallback = null;
    }