Пример #1
0
 private void Awake()
 {
     ready = GameObject.FindObjectOfType<Ready>();
     PlayerData.instance.CheckInstance();
     if (PlayerData.instance.selectedStage == null)
         PlayerData.instance.selectedStage = "C0S1";
     SetEnemyList();
 }
Пример #2
0
    private void Awake()
    {
        JsonManager.instance.CheckInstance();
        PlayerData.instance.CheckInstance();
        ready = GameObject.FindObjectOfType<Ready>();

        SetItemList();
        SetSelectedItem();
        SetBuyButtonState(false);
    }
Пример #3
0
        public void ReplyMessageHandler_HandleMessage_HandlesReady()
        {
            var connectionMock = new Mock<IDdpConnectionSender>();
            var collectionMock = new Mock<ICollectionManager>();
            var resultHandlerMock = new Mock<IResultHandler>();

            var ready = new Ready();

            var handler = new ReplyMessageHandler();

            handler.HandleMessage(connectionMock.Object, collectionMock.Object, resultHandlerMock.Object,
                JsonConvert.SerializeObject(ready));

            Assert.IsTrue(handler.CanHandle(ready.MessageType));

            resultHandlerMock.Verify(resultHandler => resultHandler.AddResult(It.IsAny<ReturnedObject>()));
        }
            async Task StartDispatcher()
            {
                LogContext.Current = _context.LogContext;

                try
                {
                    await Ready.ConfigureAwait(false);

                    while (await _channel.Reader.WaitToReadAsync(Stopping).ConfigureAwait(false))
                    {
                        var message = await _channel.Reader.ReadAsync(Stopping).ConfigureAwait(false);

                        if (_limiter != null)
                        {
                            await _limiter.Wait(Stopping).ConfigureAwait(false);
                        }

                        _ = Task.Run(async() =>
                        {
                            var context = new GrpcReceiveContext(message, _context);
                            try
                            {
                                await _dispatcher.Dispatch(context).ConfigureAwait(false);
                            }
                            catch (Exception exception)
                            {
                                context.LogTransportFaulted(exception);
                            }
                            finally
                            {
                                _limiter?.Release();
                                context.Dispose();
                            }
                        }, Stopping);
                    }
                }
                catch (OperationCanceledException)
                {
                }
                catch (Exception exception)
                {
                    LogContext.Warning?.Log(exception, "Consumer dispatcher faulted: {Queue}", _queueName);
                }
            }
Пример #5
0
        public void ReadyToRunning()
        {
            Process p = this.HighestPriority();

            if (p == null || Ready.Count == 0)
            {
                //Console.WriteLine("No ready process.");
            }
            else
            {
                p.Status = "Running";
                p.CPU_usage++;
                Ready.Remove(p);
                Running.Add(p);
                //Console.WriteLine("ReadyToRunning");
                //Console.WriteLine("Process status: " + p.Status);
                //Console.WriteLine("Running count: "+Running.Count);
            }
        }
        public async Task Consume(InMemoryTransportMessage message, CancellationToken cancellationToken)
        {
            await Ready.ConfigureAwait(false);

            if (IsStopped)
            {
                return;
            }

            if (_receivePipe == null)
            {
                throw new ArgumentException("ReceivePipe not configured");
            }

            var context = new InMemoryReceiveContext(_inputAddress, message, _receiveObservable, _topology);

            context.GetOrAddPayload(() => _errorTransport);
            context.GetOrAddPayload(() => _deadLetterTransport);

            using (_tracker.BeginDelivery())
            {
                try
                {
                    await _receiveObservable.PreReceive(context).ConfigureAwait(false);

                    await _receivePipe.Send(context).ConfigureAwait(false);

                    await context.CompleteTask.ConfigureAwait(false);

                    await _receiveObservable.PostReceive(context).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    await _receiveObservable.ReceiveFault(context, ex).ConfigureAwait(false);

                    message.DeliveryCount++;
                }
                finally
                {
                    context.Dispose();
                }
            }
        }
Пример #7
0
    public void OnClickReady()
    {
        tp_Ready = Instantiate(GMReady);
        BtnReady.SetActive(false);
        Team             team = ChessGameManager.Instance.GetTeamMyself();
        List <ChessInfo> list = new List <ChessInfo>();

        foreach (var item in team.chess)
        {
            ChessInfo ci = new ChessInfo();
            ci.chess = (int)item.type;
            ci.pos   = item.Pos;
            list.Add(ci);
        }
        Ready ready = new Ready(list);

        NetWorkManagement.Instance.SendProtobufCmd((int)Stype.game_server, (int)Cmd.eReady, ready);
        tp_Ready.SetActive(true);
    }
Пример #8
0
 public void CheckWinner()
 {
     if (Ready.Count(x => x) == 1)
     {
         // Определение кто это
         for (int i = 0; i < 10; i++)
         {
             if (Ready[i])
             {
                 Count    = 0;
                 Ready[i] = false;
                 CollectMoney();
                 RewardWinner(i);
                 CurrentBank = 0;
                 return;
             }
         }
     }
 }
Пример #9
0
        public void Connect(long maxBufferSize)
        {
            _bufferSize = maxBufferSize;
            try
            {
                // Outbound connections
                if (_socket == null)
                {
                    _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                    var connect = _socket.BeginConnect(new IPEndPoint(ResolveDns(IP), Port), null, null);

                    // 30 second timeout on new connection
                    bool success = connect.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(30), true);

                    if (success)
                    {
                        _socket.EndConnect(connect);
                    }
                    else
                    {
                        _socket.Close();
                        throw new SocketException(10060);
                    }

                    // Send protocol and other information to server
                    PerformHandshake();
                }

                // Begin waiting for data
                _socket.BeginReceive(new byte[] { 0 }, 0, 0, 0, Receive, null);

                // Notify we are done handshake and good to go
                Ready?.Invoke(this);
            }
            catch (Exception e)
            {
                Logger.Error("An error occured while establisting the following connection : " + ToString());
                Logger.Debug(e.Message);

                throw;
            }
        }
Пример #10
0
        public GamePage()
        {
            Appearing += (s, e) =>
            {
                _currentSize = Height == -1 ?
                               App.ScreenSize :
                               new Size(Width, Height);

                _mainGrid = new Grid
                {
                    BackgroundColor = Color.Transparent, // Necessary for PanGestureRecognizer to read pans outside content
                    RowSpacing      = 0,
                    ColumnSpacing   = 0
                };

                BackgroundColor = Color.Black;

                _gameHeader = new GameHeader(_fontSize = CalculateHeaderFontSize());

                _gameGrid = new GameBoard(CalculateGridSize(), 4);
                _gameGrid.VerticalOptions = _gameGrid.HorizontalOptions = LayoutOptions.Center;

                _mainGrid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                _mainGrid.RowDefinitions.Add(new RowDefinition());

                _mainGrid.Children.Add(_gameHeader);
                Grid.SetRow(_gameGrid, 1);
                _mainGrid.Children.Add(_gameGrid);

                if (Device.Idiom == TargetIdiom.Desktop)
                {
                    _mainGrid.Children.Add(BuildKeyboardInputEntry());
                }

                Content = _mainGrid;
                Content.GestureRecognizers.Add(BuildSwipeRecognizer());

                Ready?.Invoke(this, EventArgs.Empty);
            };
        }
Пример #11
0
        public virtual bool OnReady(DiscordPacket Packet)
        {
            //TODO: Initialise guilds
            Dictionary <string, JsonElement> Data = Packet.d;

            User = new ClientUser(this, Data["user"]);

            ArrayEnumerator Guilds = Data["guilds"].EnumerateArray();

            foreach (JsonElement RawGuild in Guilds)
            {
                this.Guilds.CreateEntry(RawGuild);
            }

            SessionId = Data["session_id"].GetString();

            IsReady = true;
            Ready?.Invoke(this, null);
            return(true);
        }
        // Login using token, sets Authorization header and tests if the token is valid by sending a GET request to user API endpoint
        public async void Login(string token)
        {
            client.DefaultRequestHeaders.Remove("Referer");
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token);
            client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/channels/@me");

            var response = await client.GetAsync(DiscordAPI.userEndpoint);

            Debug.WriteLine($"{response.StatusCode}: {await response.Content.ReadAsStringAsync()}");
            if (response.StatusCode == HttpStatusCode.Unauthorized)
            {
                LoginError?.Invoke(new LoginErrorEventArgs(this, "Invalid token"));
                Debug.WriteLine("Invalid token");
            }
            else if (response.IsSuccessStatusCode)
            {
                DataStore.SaveToken(token);
                Ready?.Invoke(new ReadyEventArgs(this));
            }
        }
        public async void LoginMfa(string ticket, string code)
        {
            var log = new MfaRequest(code, ticket);

            var content = new JsonContent(log);

            var response = await client.PostAsync(DiscordAPI.mfaEndpoint, content);

            var responseObject = Serializer.Parse <MfaPayload>(await response.Content.ReadAsStringAsync());

            client.DefaultRequestHeaders.Remove("Referer");

            if (response.StatusCode == HttpStatusCode.BadRequest)
            {
                if (responseObject.Message != null)
                {
                    LoginError?.Invoke(new LoginErrorEventArgs(this, responseObject.Message));
                    Debug.WriteLine(responseObject.Message);
                }
            }
            else if (response.IsSuccessStatusCode)
            {
                if (string.IsNullOrEmpty(responseObject.Token))
                {
                    LoginError?.Invoke(new LoginErrorEventArgs(this, "Unknown error"));
                    Debug.WriteLine("Unknown error");
                }
                else
                {
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(responseObject.Token);
                    client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/channels/@me");
                    DataStore.SaveToken(responseObject.Token);
                    Ready?.Invoke(new ReadyEventArgs(this));
                }
            }
            else
            {
                LoginError?.Invoke(new LoginErrorEventArgs(this, "Error " + response.StatusCode));
                Debug.WriteLine("Error " + response.StatusCode);
            }
        }
Пример #14
0
        private void Ready_Request()
        {
            while (true)
            {
                byte[]     bytes  = new byte[1024 * 4];
                Stream     stream = new NetworkStream(client.Client);
                int        len    = stream.Read(bytes, 0, bytes.Length);
                CM_Library Two    = (CM_Library)CM_Library.Deserialize(bytes);
                stream.Flush();
                switch (Two.type)
                {
                case (int)CM_All.클라이언트라벨:
                {
                    Ready ready = new Ready();
                    ready = (Ready)CM_Library.Deserialize(bytes);
                    for (int i = 0; i < ready.nickNameList.Length; i++)
                    {
                        if (ready.nickNameList[i] != null)
                        {
                            this.labels[i].Text = ready.nickNameList[i].ToString();
                        }
                    }
                    break;
                }

                case (int)CM_All.자기번호:
                {
                    Ready_On ready_On = new Ready_On();
                    ready_On = (Ready_On)CM_Library.Deserialize(bytes);
                    for (int i = 0; i < 4; i++)
                    {
                        if (ready_On.On[i] == true)
                        {
                            labels[i].BackColor = Color.Blue;
                        }
                    }
                    break;
                }
                }
            }
        }
Пример #15
0
        public void Dispatch()
        {
            if (Ready.Count > 0)
            {
                Running       = Ready.Dequeue();
                Running.State = States.Running;

                memory.ChangeFramesState(Running, States.Running); // <<

                if (Running.tRsp == -1)
                {
                    Running.tRsp = GlobalTime - Running.tLle;
                }

                mW.tblReady.Rows.RemoveAt(0);
            }
            else
            {
                Running = new Process();
            }
        }
Пример #16
0
        private void OnLoaded(object sender, RoutedEventArgs args)
        {
            if (_context != null)
            {
                return;
            }

            var window     = Window.GetWindow(this);
            var baseHandle = window is null ? IntPtr.Zero : new WindowInteropHelper(window).Handle;

            _hwnd = new HwndSource(0, 0, 0, 0, 0, "GLWpfControl", baseHandle);

            _windowInfo = Utilities.CreateWindowsWindowInfo(_hwnd.Handle);

            InitOpenGL();

            _imageRectangle     = new Rect(0, 0, RenderSize.Width, RenderSize.Height);
            _translateTransform = new TranslateTransform(0, RenderSize.Height);

            Ready?.Invoke();
        }
Пример #17
0
        public void Go()
        {
            object[] localArray = new object[_arraySize];

            Random rand = new Random();

            for (int i = 0; i < _arraySize; i++)
            {
                staticArray[i] = GetNewObject(rand.Next(0, 4));
                localArray[i]  = GetNewObject(rand.Next(0, 4));
            }

            Ready?.Invoke(this, new EventArgs());

            //Console.WriteLine("Use PerfView to examine heap now. Press any key to exit...");
            //Console.ReadKey();

            // This will prevent localArray from being garbage collected before you take the snapshot
            Console.WriteLine(staticArray.Length);
            Console.WriteLine(localArray.Length);
        }
Пример #18
0
        /// <summary>
        /// Create a Twitch chatbot.
        /// </summary>
        public ChatController(AuthInfo info)
        {
            var _state = _stateMachine = new StateMachine <State, Trigger>(State.SignedOff);

            _state.OnTransitioned((transition =>
            {
                _log.DebugFormat("{0} => {1}", transition.Source.ToString("G"), transition.Destination.ToString("G"));
            }));

            _state.Configure(State.Conceived)
            .Permit(Trigger.DisconnectRequested, State.SignedOff);

            _state.Configure(State.SignedOff)
            .SubstateOf(State.Conceived)
            .OnEntry(() => Task.Run(() => Whisperer.Stop()))
            .OnEntry(() => Task.Run(() => Talker.Stop()))
            .Ignore(Trigger.ChatbotsUnready)
            .Permit(Trigger.ConnectRequested, State.Connecting);

            _state.Configure(State.Connecting)
            .SubstateOf(State.Conceived)
            .OnEntry(() => Task.Run(() => Whisperer.Start()))
            .OnEntry(() => Task.Run(() => Talker.Start()))
            .Ignore(Trigger.ConnectRequested)
            .Ignore(Trigger.ChatbotsUnready)
            .Permit(Trigger.ChatbotsReady, State.Ready);

            _state.Configure(State.Ready)
            .SubstateOf(State.Conceived)
            .Ignore(Trigger.ChatbotsReady)
            .OnEntry(() => Ready?.Invoke(this, EventArgs.Empty))
            .OnExit(() => Unready?.Invoke(this, EventArgs.Empty));

            Whisperer          = new ChatBot(info, true);
            Whisperer.Ready   += CheckBotStates;
            Whisperer.Unready += CheckBotStates;
            Talker             = new ChatBot(info, false);
            Talker.Ready      += CheckBotStates;
            Talker.Unready    += CheckBotStates;
        }
Пример #19
0
        public async Task RunAsync()
        {
            var sw = Stopwatch.StartNew();

            await LoginAsync(Credentials.Token).ConfigureAwait(false);

            Mention = Client.CurrentUser.Mention;
            Log.Information("Shard {ShardId} loading services...", Client.ShardId);
            try
            {
                AddServices();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error adding services");
                Helpers.ReadErrorAndExit(9);
            }

            sw.Stop();
            Log.Information("Shard {ShardId} connected in {Elapsed:F2}s", Client.ShardId, sw.Elapsed.TotalSeconds);

            var stats = Services.GetService <IStatsService>();

            stats.Initialize();
            var commandHandler = Services.GetService <CommandHandler>();
            var CommandService = Services.GetService <CommandService>();

            // start handling messages received in commandhandler
            await commandHandler.StartHandling().ConfigureAwait(false);

            _ = await CommandService.AddModulesAsync(this.GetType().GetTypeInfo().Assembly, Services)
                .ConfigureAwait(false);

            HandleStatusChanges();
            StartSendingData();
            Ready.TrySetResult(true);
            _ = Task.Run(ExecuteReadySubscriptions);
            Log.Information("Shard {ShardId} ready", Client.ShardId);
        }
Пример #20
0
        protected sealed override void Initialize()
        {
            var mainModule = typeof(VeldridPanel).Module;
            var hinstance  = Marshal.GetHINSTANCE(mainModule);

            VeldridSwapchainSource = SwapchainSource.CreateWin32(Hwnd, hinstance);
            Ready?.Invoke(this, EventArgs.Empty);
            var here = Parent as FrameworkElement;

            while (here != null)
            {
                if (here is Window window)
                {
                    window.Closing += Window_Closing;
                    here            = null;
                }
                else
                {
                    here = here.Parent as FrameworkElement;
                }
            }
        }
Пример #21
0
 /// <summary>
 /// Adds a player to the raid group.
 /// If the user is already in the raid group, their party size is updated.
 /// Will update attend size or remote size, not both
 /// </summary>
 /// <param name="player">Player to add.</param>
 /// <param name="attendSize">Number of accounts attending in person.</param>
 /// <param name="remoteSize">Number of accounts attending via remote.</param>
 public void AddPlayer(SocketGuildUser player, int attendSize, int remoteSize)
 {
     if (!Invited.ContainsKey(player))
     {
         if (Attending.ContainsKey(player))
         {
             if (remoteSize == Global.NO_ADD_VALUE)
             {
                 Attending[player] = SetValue(attendSize, GetRemote(Attending[player]));
             }
             else if (attendSize == Global.NO_ADD_VALUE)
             {
                 Attending[player] = SetValue(GetAttending(Attending[player]), remoteSize);
             }
         }
         else if (Ready.ContainsKey(player))
         {
             if (remoteSize == Global.NO_ADD_VALUE)
             {
                 Ready[player] = SetValue(attendSize, GetRemote(Ready[player]));
             }
             else if (attendSize == Global.NO_ADD_VALUE)
             {
                 Ready[player] = SetValue(GetAttending(Ready[player]), remoteSize);
             }
         }
         else
         {
             int attend    = (attendSize == Global.NO_ADD_VALUE) ? 0 : attendSize;
             int remote    = (remoteSize == Global.NO_ADD_VALUE) ? 0 : remoteSize;
             int partySize = (remote << Global.REMOTE_SHIFT) | attend;
             if (partySize != 0)
             {
                 Attending.Add(player, partySize);
             }
         }
     }
 }
Пример #22
0
        public void Terminate()
        {
            if (wasInterru == false && Running.tTra < Running.TME)
            {
                Ready.Enqueue(Running);
                memory.ChangeFramesState(Running, States.Ready); // <<

                mW.tblReady.Rows.Add(Running.Id, Running.TME, Running.tRst);
            }
            else
            {
                Running.tFin  = GlobalTime;
                Running.tRet  = Running.tEsp + Running.tTra;
                Running.State = States.Terminated;
                Exit.Enqueue(Running);

                memory.FreeFrames += Running.TotalPages;
                memory.ChangeFramesState(Running, States.New); // <<

                // --------- WINDOW ----------- //
                mW.tblTerminated.Rows.Add(Running.Id, Running.Ope.ToString(), Running.Ope.Result);
            }
        }
Пример #23
0
        private void PayerExec()
        {
            Mediator <bool> .Instance.Send(false);

            Commande x = new Commande(IsBenevol);

            ServiceClientLocator.Instance.Commande.Insert(x);
            foreach (var item in Ready)
            {
                LigneDeCommande Ligne = new LigneDeCommande(0, item.ProduitId, item.Quantite, item.TestPrix);
                InsterDb.Add(Ligne);
                if (Ready.Count == InsterDb.Count)
                {
                    foreach (var Insert in InsterDb)
                    {
                        ServiceClientLocator.Instance.LigneDeCommand.Insert(Insert);
                    }
                }
            }
            Ready.Clear();
            InsterDb.Clear();
            PrixTotal = 0;
        }
Пример #24
0
        private async void SendFrame(Command command, ServerEvent e, object obj)
        {
            PipeFrame    frame   = new PipeFrame();
            EventPayload payload = new EventPayload(nonce);

            payload.Command = command;
            payload.Event   = e;
            Ready ready = new Ready();

            payload.Data = JObject.FromObject(obj);
            using (MemoryStream stream = new MemoryStream())
            {
                //Write the stream and the send it to the pipe
                frame.Opcode = Opcode.Frame;
                frame.SetObject(payload);
                frame.WriteStream(stream);
                frame.Opcode = Opcode.Frame;
                //Get the bytes and send it
                byte[] bytes = stream.ToArray();
                await server.SendToAllAsync(bytes);
            }
            nonce++;
        }
Пример #25
0
        //It is completely possible to allow another thread here, such a thread would be soley responsible for issuing the data to the handlers of the RtpClient's events and would provide better performance in some cases.
        //It's also possible to Multicast the source resulting in the network handling the aggregation (See Sink)

        #endregion

        #region Unused [Example of how an implementation would begin to propagate the realization that may have to actually do some type of work]

        //Asked by a user here how they would save a rtsp stream to disk....
        //RtpTools, MediaFileWriter, FFMPEG, Media Foundation................................................................
        //http://stackoverflow.com/questions/37285323/how-to-record-a-rtsp-stream-to-disk-using-net7mma

        //System.Drawing.Image m_lastDecodedFrame;
        //internal virtual void DecodeFrame(Rtp.RtpClient sender, Rtp.RtpFrame frame)
        //{
        //    if (RtpClient == null || RtpClient != sender) return;
        //    try
        //    {
        //        //Get the MediaDescription (by ssrc so dynamic payload types don't conflict
        //        Media.Sdp.MediaDescription mediaDescription = RtpClient.GetContextBySourceId(frame.SynchronizationSourceIdentifier).MediaDescription;
        //        if (mediaDescription.MediaType == MediaType.audio)
        //        {
        //            //Could have generic byte[] handlers OnAudioData OnVideoData OnEtc
        //            //throw new NotImplementedException();
        //        }
        //        else if (mediaDescription.MediaType == MediaType.video)
        //        {
        //            if (mediaDescription.MediaFormat == 26)
        //            {
        //                OnFrameDecoded(m_lastDecodedFrame = (new RFC2435Stream.RFC2435Frame(frame)).ToImage());
        //            }
        //            else if (mediaDescription.MediaFormat >= 96 && mediaDescription.MediaFormat < 128)
        //            {
        //                //Dynamic..
        //                //throw new NotImplementedException();
        //            }
        //            else
        //            {
        //                //0 - 95 || >= 128
        //                //throw new NotImplementedException();
        //            }
        //        }
        //    }
        //    catch
        //    {
        //        return;
        //    }
        //}

        #endregion

        #endregion

        #region ILoggingReference

        public override bool TrySetLogger(ILogging logger)
        {
            if (Ready.Equals(false))
            {
                return(false);
            }

            try
            {
                //Set the logger
                RtpClient.Logger = logger;

                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                //
            }
        }
Пример #26
0
    // 初期化
    void Start()
    {
        input = InputController.Instance;

        if (m_boardObj == null)
        {
            Debug.LogError("Boardがありません。");
        }
        if (m_foxObj == null)
        {
            Debug.LogError("Foxがありません。");
        }
        if (m_pivot == null)
        {
            Debug.LogError("RotationPivotがありません。");
        }
        if (m_viewController == null)
        {
            Debug.LogError("PhotonViewControllerがありません。");
        }

        m_borad = m_boardObj.GetComponent <StageBoard>();
        m_boardObj.SetActive(false);

        m_fox = m_foxObj.GetComponent <Fox2DAnimation>();

        m_pivot.Stop = StopAction;

        m_photonView = GetComponent <PhotonView>();

        PhotonNetwork.isMessageQueueRunning = true;

        startReady = GameObject.Find("StartReady").GetComponent <Ready>();
        gameReady  = GameObject.Find("GameReady").GetComponent <Ready>();

        gameReady.SetReadyNum(100);
    }
        private void OnLoaded(object sender, RoutedEventArgs args)
        {
            if (_context != null)
            {
                return;
            }
            if (_settings.ContextToUse == null)
            {
                var window     = Window.GetWindow(this);
                var baseHandle = window is null ? IntPtr.Zero : new WindowInteropHelper(window).Handle;
                _hwnd       = new HwndSource(0, 0, 0, 0, 0, "GLWpfControl", baseHandle);
                _windowInfo = Utilities.CreateWindowsWindowInfo(_hwnd.Handle);

                var mode = new GraphicsMode(ColorFormat.Empty, 0, 0, 0, 0, 0, false);
                _context = new GraphicsContext(mode, _windowInfo, _settings.MajorVersion, _settings.MinorVersion,
                                               _settings.GraphicsContextFlags);
                _context.LoadAll();
                _context.MakeCurrent(_windowInfo);
            }
            else
            {
                _context = _settings.ContextToUse;
            }

            if (_renderer == null)
            {
                var width  = (int)RenderSize.Width;
                var height = (int)RenderSize.Height;
                _renderer = new GLWpfControlRenderer(width, height, _image, _settings.UseHardwareRender, _settings.PixelBufferObjectCount);
            }

            _imageRectangle     = new Rect(0, 0, RenderSize.Width, RenderSize.Height);
            _translateTransform = new TranslateTransform(0, RenderSize.Height);

            GL.Viewport(0, 0, (int)RenderSize.Width, (int)RenderSize.Height);
            Ready?.Invoke();
        }
Пример #28
0
 public StoreControllerTest()
 {
     _faker        = new Faker();
     _storeService = new Mock <IStoreService>();
     _topicBus     = new Mock <ITopicBus>();
     _option       = Options.Create(new ServiceBusOption
     {
         ResourceGroup    = _faker.Random.AlphaNumeric(10),
         NamespaceName    = _faker.Random.AlphaNumeric(10),
         ConnectionString = _faker.Random.AlphaNumeric(10),
         ClientId         = _faker.Random.AlphaNumeric(10),
         ClientSecret     = _faker.Random.AlphaNumeric(10),
         SubscriptionId   = _faker.Random.AlphaNumeric(10),
         TenantId         = _faker.Random.AlphaNumeric(10),
         ServiceBus       = new ServiceBus
         {
             Store    = _faker.Name.FindName(),
             TopicLog = _faker.Random.AlphaNumeric(10),
             Product  = new ServiceBusFilter
             {
                 Topic        = _faker.Name.FirstName(),
                 Subscription = _faker.Name.FirstName()
             },
             ProductionArea = new ServiceBusFilter
             {
                 Topic        = _faker.Name.FirstName(),
                 Subscription = _faker.Name.FirstName()
             }
         }
     });
     _storeController = new StoreController(_storeService.Object, _topicBus.Object, _option);
     _ready           = new Ready
     {
         IsReady = _faker.Random.Bool(),
         StoreId = _faker.Random.Guid()
     };
 }
Пример #29
0
 public bool addShip(Ship s)
 {
     if (CheckCollision(s) && checkMaxShips(s.size))
     {
         if (!addShipToField(s))
         {
             return(false);
         }
         ships.Add(s);
         if (fieldReady())
         {
             EventHandler tmp = Ready;
             if (tmp != null)
             {
                 Ready.Invoke(this, EventArgs.Empty);
             }
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #30
0
 void State()
 {
     if (slider.value >= .70f && slider.value <= .75f)
     {
         success = true;
         Ready.SetActive(true);
     }
     else if (slider.value > .75f)
     {
         Burnt.SetActive(true);
         Ready.SetActive(false);
         success = false;
     }
     else if (slider.value > .35f)
     {
         KindOf.SetActive(true);
         UnCooked.SetActive(false);
         success = false;
     }
     else
     {
         success = false;
     }
 }
Пример #31
0
        public async Task BOT()
        {
            Program.Client = new DiscordSocketClient(new DiscordSocketConfig {
                LogLevel = LogSeverity.Debug
            });
            Program.Commands = new CommandService(new CommandServiceConfig
            {
                CaseSensitiveCommands = false,
                DefaultRunMode        = RunMode.Async,
                LogLevel = LogSeverity.Debug,
            });

            await Program.Commands.AddModulesAsync(Assembly.GetEntryAssembly(), null);

            Message_Received.Load();
            Ready.Load();
            Log.Load();

            await Program.Client.LoginAsync(TokenType.Bot, Hidden_Info.Tokens.Bot);

            await Program.Client.StartAsync();

            await Task.Delay(-1);
        }
Пример #32
0
        /// <summary>
        /// Creates a new ConsoleControl
        /// </summary>
        public ConsoleControl()
        {
            CanFocus    = true;
            this.Bitmap = new ConsoleBitmap(1, 1);
            this.SubscribeForLifetime(nameof(Bounds), () =>
            {
                if (Width > 0 && Height > 0)
                {
                    this.Bitmap.Resize(Width, Height);
                }
            }, this);
            Background      = DefaultColors.BackgroundColor;
            this.Foreground = DefaultColors.ForegroundColor;
            this.IsVisible  = true;
            this.Id         = GetType().FullName + "-" + Guid.NewGuid().ToString();
            this.SubscribeForLifetime(ObservableObject.AnyProperty, () =>
            {
                if (Application != null && Application.IsRunning && Application.IsDrainingOrDrained == false)
                {
                    ConsoleApp.AssertAppThread(Application);
                    Application.Paint();
                }
            }, this);

            this.AddedToVisualTree.SubscribeOnce(() =>
            {
                if (Application.IsRunning)
                {
                    Ready.Fire();
                }
                else
                {
                    Application.InvokeNextCycle(Ready.Fire);
                }
            });
        }
Пример #33
0
 void Discord_Ready(Ready ready)
 {
     Puts("Discord Connected");
 }