Ejemplo n.º 1
0
        private void OnGameStateUpdated(IGameState newGameState, IReadOnlyList <IStateChangeEvent> changeEvents)
        {
            CurrentGameState = newGameState;

            foreach (IStateChangeEvent stateChangeEvent in changeEvents)
            {
                Console.WriteLine($"[Event] {stateChangeEvent.Description}");
                _stateChangeRecord.Add(stateChangeEvent);
                StateChangeEvent?.Invoke(stateChangeEvent);
            }

            NeedsToRender?.Invoke();
        }
Ejemplo n.º 2
0
        public static void Start()
        {
            network.Start(config.MulticastInterface);
            redistribution.UpdateStart      += () => UpdateStart?.Invoke();
            redistribution.UpdateComplete   += () => UpdateComplete?.Invoke();
            redistribution.StateChangeEvent += (s) => StateChangeEvent?.Invoke(s);

            redistribution.HandleLogEvent   += _client_HandleLogEvent;
            redistribution.HandleErrorEvent += _client_HandleErrorEvent;

            _client = new Client(network, config, redistribution);
            _client.StateChangeEvent += (s) => StateChangeEvent?.Invoke(s);
        }
Ejemplo n.º 3
0
        public async Task Initalize()
        {
            if (_State != STATE.Running)
            {
                await Task.Run(() => Thread.Sleep(5000));

                _State = STATE.Running;
                StateChangeEvent?.Invoke(this, STATE.Running);
            }
            else
            {
                // S1.output("Controller is already Running");
            }
        }
Ejemplo n.º 4
0
        private void UpdateRoles()
        {
            try
            {
                taskinprogress = true;
                UpdateStart?.Invoke();
                do
                {
                    Tuple <CommandId, RoleSet, IPAddress> request;
                    lock (_requeststatemutex)
                    {
                        request = requeststate;
                    }

                    UpdateStart?.Invoke();
                    StateChangeEvent?.Invoke("Perform update operation");
                    Stop();
                    BuildFromConfig(request.Item2);
                    if (request.Item1 == CommandId.DryRun) //do total repositori cleanup
                    {
                        try
                        {
                            DirectoryUtils.TryDeleteDirectory(_repositorystoragepath);
                        }
                        catch (Exception e)
                        {
                            OnErrorEvent(e.Message);
                        }
                        Directory.CreateDirectory(_repositorystoragepath);
                    }

                    RunCommandOnNodes(request.Item1, request.Item3);
                    UpdateComplete?.Invoke();
                    StateChangeEvent?.Invoke("update operation finished");
                    lock (_requeststatemutex)
                    {
                        var checkrequest = requeststate;
                        if (checkrequest.Item1 == requeststate.Item1 && checkrequest.Item2 == requeststate.Item2 &&
                            Equals(checkrequest.Item3, requeststate.Item3))
                        {
                            taskinprogress = false; //finish operation
                        }
                    }
                } while (taskinprogress);
            }
            catch (Exception e)
            {
                taskinprogress = false;
            }
        }
Ejemplo n.º 5
0
Archivo: Unit.cs Proyecto: PavIlija/RTS
    void SetState(UnitState toState)
    {
        state = toState;

        if (onStateChange != null)
        {
            onStateChange.Invoke(state);
        }

        if (toState == UnitState.Idle)
        {
            navAgent.isStopped = true;
            navAgent.ResetPath();
        }
    }
Ejemplo n.º 6
0
 public void Spawn()
 {
     for (int i = 0; i < Waypoints.Length; i++)
     {
         NavMeshHit Hit;
         if (NavMesh.SamplePosition(Triangulation.vertices[Random.Range(0, Triangulation.vertices.Length)], out Hit, 2f, Agent.areaMask))
         {
             Waypoints[i] = Hit.position;
         }
         else
         {
             Debug.LogError("Unable to find position for navmesh near Triangulation vertex!");
         }
     }
     OnStateChange?.Invoke(EnemyState.Spawn, DefaultState);
 }
Ejemplo n.º 7
0
        public void Press()
        {
            switch (buttonCursorIndex)
            {
            case 2:
                StateChangeEvent?.Invoke(0);
                break;

            case 1:
                Console.Write("Loading");
                _previousState.Map.LoadFromFile("Map.txt");
                break;

            default:
                _previousState.Map.SaveToFile("Map.txt");
                break;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Force the state to enter specific state
        /// </summary>
        /// <param name="newActivestate"></param>
        protected virtual void SetCurrentState(GameStateType newActivestate)
        {
            if (newActivestate == null)
            {
                return;
            }

            if (currentState != null)
            {
                currentState.OnExitState();
            }

            currentState = newActivestate;
            newActivestate.OnEnterState();

            onStateChange.Invoke(currentState);

            Debug.Log($"[{this.ToString()}]: Changed state to '{currentState.ToString()}'");
        }
Ejemplo n.º 9
0
        public void ProcessInput()
        {
            previousButtonStates = new Dictionary <Keys, bool>(currentButtonStates);
            var keyState = Keyboard.GetState();

            currentButtonStates[Keys.Up]     = keyState.IsKeyDown(Keys.Up);
            currentButtonStates[Keys.Down]   = keyState.IsKeyDown(Keys.Down);
            currentButtonStates[Keys.Enter]  = keyState.IsKeyDown(Keys.Enter);
            currentButtonStates[Keys.Escape] = keyState.IsKeyDown(Keys.Escape);

            //if the up button was pressed
            if (currentButtonStates[Keys.Up] && !previousButtonStates[Keys.Up])
            {
                if (buttonCursorIndex != 0)
                {
                    buttonCursorIndex--;
                }
            }
            //else if the down button was pressed
            else if (currentButtonStates[Keys.Down] && !previousButtonStates[Keys.Down])
            {
                if (buttonCursorIndex != Menu.buttons.Count - 1)
                {
                    buttonCursorIndex++;
                }
            }
            //else if the enter button was pressed
            else if (currentButtonStates[Keys.Enter] && !previousButtonStates[Keys.Enter])
            {
                Press();
            }

            if (currentButtonStates[Keys.Escape] && !previousButtonStates[Keys.Escape] && !isFirstFrame)
            {
                Console.Write("escape pressed");
                StateChangeEvent?.Invoke(2);
            }
            isFirstFrame = false;
        }
Ejemplo n.º 10
0
        public void Run()
        {
            while (true)
            {
                if (_state && HoldingKey(VK_SPACE) && Player.GetHealth() > 0 && Player.GetVelocity() > 1f)
                {
                    int jumpState = (Player.GetFlag() & (1 << 0)) > 0 ? 5 : 4;
                    if (Player.GetJumpState() != jumpState)
                    {
                        Player.SetJumpState(jumpState);
                    }
                }

                if (HoldingKey(VK_DELETE))
                {
                    _state = !_state;
                    StateChangeEvent?.Invoke(_state);
                    Thread.Sleep(300);
                }

                Thread.Sleep(1);
            }
        }
Ejemplo n.º 11
0
 void IDataDistributionMastershipCallbackLow.OnStateChange(IntPtr IDataDistribution_nativePtr, DDM_INSTANCE_STATE newState, DDM_INSTANCE_STATE oldState)
 {
     OnStateChange(newState, oldState);
     StateChangeEvent?.Invoke(this, new StateChangeEventArgs(newState, oldState));
 }
Ejemplo n.º 12
0
 public override void OnExit()
 {
     onExit.Invoke(Parent);
 }
Ejemplo n.º 13
0
 public override void OnEnter()
 {
     onEnter.Invoke(Parent);
 }
Ejemplo n.º 14
0
 public void Press()
 {
     StateChangeEvent?.Invoke(buttonCursorIndex + 1);
 }
Ejemplo n.º 15
0
 private void NotifyCurrentState()
 {
     onStateChange.Invoke(state);
 }