private static void EventCall(Message msg)
        {
            //MelonLogger.Msg($"VibratorControllerMessage recieved");
            //MelonLogger.Msg(msg);

            if (msg.TimeStamp.Ticks > lastTick)
            {
                lastTick = msg.TimeStamp.Ticks;
                var messagecontent = msg.GetContentAs <VibratorControllerMessage>();
                if (messagecontent != null)
                {
                    VibratorController.message(messagecontent, msg.Target);
                }
            }
        }
Esempio n. 2
0
        private static async Task Receive(ClientWebSocket webSocket)
        {
            byte[] buffer = new byte[256];
            while (webSocket.State == WebSocketState.Open)
            {
                Array.Clear(buffer, 0, buffer.Length);
                var result = await webSocket.ReceiveAsync(new ArraySegment <byte>(buffer), CancellationToken.None);

                if (result.MessageType == WebSocketMessageType.Close)
                {
                    await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None);
                }
                else
                {
                    String text = Encoding.ASCII.GetString(buffer);
                    VibratorController.message(text);
                }
            }
        }
Esempio n. 3
0
        private void createMenu()
        {
            toys = new ButtonGroup("Toy" + id, name);
            int step = (int)(maxSpeed * ((float)VibratorController.buttonStep / 100));


            changeMode = new SingleButton(() => changeHand(), VibratorController.CreateSpriteFromTexture2D(GetTexture()), $"Mode\n{hand}", "mode", "Change Mode");
            inc        = new SingleButton(() => { if (lastSpeed + step <= maxSpeed)
                                                  {
                                                      setSpeed(lastSpeed + step);
                                                  }
                                          }, VibratorController.CreateSpriteFromTexture2D(GetTexture()), "Inc", "inc", "Increment Speed");
            dec = new SingleButton(() => { if (lastSpeed - step >= 0)
                                           {
                                               setSpeed(lastSpeed - step);
                                           }
                                   }, VibratorController.CreateSpriteFromTexture2D(GetTexture()), "Dec", "dec", "Decrement Speed");
            label = new Label($"Current Speed: {lastSpeed}", "Battery not available", "BatteryStatus");

            label.TextComponent.fontSize = 24;
            toys.AddButton(changeMode);
            toys.AddButton(inc);
            toys.AddButton(dec);
            toys.AddButton(label);

            menu.AddButtonGroup(toys);


            //fix if added after init phase
            toys.gameObject.transform.localScale        = Vector3.one;
            toys.Header.gameObject.transform.localScale = Vector3.one;

            toys.gameObject.transform.localRotation        = Quaternion.Euler(0, 0, 0);
            toys.Header.gameObject.transform.localRotation = Quaternion.Euler(0, 0, 0);

            var pos  = toys.gameObject.transform.localPosition;
            var pos2 = toys.Header.gameObject.transform.localPosition;

            toys.gameObject.transform.localPosition        = new Vector3(0, pos.y, 0);
            toys.Header.gameObject.transform.localPosition = new Vector3(0, pos2.y, 0);
        }