Ejemplo n.º 1
0
        public void RunTick()
        {
            // Handle Key Presses
            InputClient input = Systems.input;

            // Check if the menu should be closed:
            if (input.LocalKeyPressed(Keys.Escape))
            {
                UIHandler.SetMenu(null, false);
                return;
            }

            // Tab Between Options
            if (input.LocalKeyPressed(Keys.Tab))
            {
                UIComponent.ComponentSelected = this.worldIdInput;
            }

            this.textBox.RunTick();
            this.worldIdInput.RunTick();
            this.loadButton.RunTick();

            // Press Enter
            if (input.LocalKeyPressed(Keys.Enter))
            {
                this.LoadWorldAttempt();
                return;
            }

            // Clicked on Load World Button.
            if (UIComponent.ComponentWithFocus == this.loadButton && Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
            {
                this.LoadWorldAttempt();
            }
        }
Ejemplo n.º 2
0
    /**
     * Is invoked when application launches. Connects the Client to the Server
     */
    public void OnUserConnect(string address, int port)
    {
        ChannelDispatcher dispatcher = new ChannelDispatcher();

        this.transport = new TransportClient(dispatcher);

        sessionClient = new SessionClient(this.transport, this);
        dispatcher.RegisterChannel(sessionClient);

        surfaceClient = new SurfaceClient(this, this.transport);
        dispatcher.RegisterChannel(surfaceClient);

        inputClient = new InputClient(this.transport);
        dispatcher.RegisterChannel(inputClient);

        try
        {
            this.transport.Connect(address, port);
            DisplayStatusText("Welcome! You are connected to Screenary server at " + address + " : " + port);
        }
        catch (TransportException e)
        {
            ExceptionDialog exception = new ExceptionDialog("Operation Fail", "Could not connect to Screenary server at "
                                                            + address + " : " + port + "\nVerify connections.");
        }
    }
Ejemplo n.º 3
0
 public void SendInputMouseWheel(int MouseDelta)
 {
     byte[] Sw = new byte[4];
     byte[] Xp = new byte[4];
     Sw = BitConverter.GetBytes(8);
     Xp = BitConverter.GetBytes(MouseDelta);
     InputClient.Send(Sw);
     InputClient.Send(Xp);
 }
Ejemplo n.º 4
0
        public void RunTick()
        {
            // Mouse Handling
            this.MouseOver = this.GetMouseOverState();
            if (this.MouseOver == UIMouseOverState.On)
            {
                UIComponent.ComponentWithFocus = this;

                // Mouse Clicked
                if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
                {
                    UIComponent.ComponentSelected = this;
                }
            }

            // If the Mouse just exited this component:
            //else if(this.MouseOver == UIMouseOverState.Exited) {}

            // Key Handling
            if (UIComponent.ComponentSelected == this)
            {
                InputClient input = Systems.input;

                // Get Characters Pressed (doesn't assist with order)
                string charsPressed = input.GetCharactersPressed();

                UICreoInput comp = (UICreoInput)UIComponent.ComponentSelected;

                if (charsPressed.Length > 0)
                {
                    comp.SetInputText(comp.text + charsPressed);
                }

                // Backspace (+Shift, +Control)
                if (input.LocalKeyDown(Keys.Back) && this.lastBack < Systems.timer.UniFrame)
                {
                    if (input.LocalKeyPressed(Keys.Back))
                    {
                        this.lastBack = Systems.timer.UniFrame + 10;
                    }
                    else
                    {
                        this.lastBack = Systems.timer.UniFrame + 4;
                    }

                    if (input.LocalKeyDown(Keys.LeftShift) || input.LocalKeyDown(Keys.RightShift) || input.LocalKeyDown(Keys.LeftControl) || input.LocalKeyDown(Keys.RightControl))
                    {
                        comp.SetInputText("");
                    }
                    else if (comp.text.Length > 0)
                    {
                        comp.SetInputText(comp.text.Substring(0, comp.text.Length - 1));
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public void SendInputUp(int KeyValue)
 {
     byte[] Sw = new byte[4];
     byte[] Xp = new byte[4];
     Sw = BitConverter.GetBytes(1);
     Xp = BitConverter.GetBytes(KeyValue);
     InputClient.Send(Sw);
     InputClient.Send(Xp);
     //InputClient.Send(Yp);
 }
Ejemplo n.º 6
0
        public override void RunTick()
        {
            // Update Timer
            Systems.timer.RunTick();

            // Loop through every player and update inputs for this frame tick:
            foreach (var player in Systems.localServer.players)
            {
                //player.Value.input.UpdateKeyStates(Systems.timer.Frame);
                player.Value.input.UpdateKeyStates(0);                 // TODO: Update LocalServer so frames are interpreted and assigned here.
            }

            // Update UI
            UIComponent.ComponentWithFocus = null;
            Cursor.UpdateMouseState();
            UIHandler.cornerMenu.RunTick();

            // Menu State
            if (UIHandler.uiState == UIState.Menu)
            {
                UIHandler.menu.RunTick();
                return;
            }

            // Play UI is active:

            // Open Menu (Start)
            InputClient input = Systems.input;

            // Open Menu
            if (input.LocalKeyPressed(Keys.Tab) || input.LocalKeyPressed(Keys.Escape) || playerInput.isPressed(IKey.Start) || playerInput.isPressed(IKey.Select))
            {
                UIHandler.SetMenu(UIHandler.mainMenu, true);
            }

            // Open Console (Tilde)
            else if (Systems.input.LocalKeyPressed(Keys.OemTilde))
            {
                UIHandler.worldConsole.Open();
            }

            // Run World UI Updates
            this.worldUI.RunTick();

            // Update Character
            this.character.RunTick();

            // Update Camera
            Systems.camera.Follow(this.character.posX, this.character.posY, 100);
            Systems.camera.StayBounded(0, this.xCount * (byte)WorldmapEnum.TileWidth, 0, this.yCount * (byte)WorldmapEnum.TileHeight);

            // Check Input Updates
            this.RunInputCheck();
        }
Ejemplo n.º 7
0
 public void SendInputMouseUp(int X, int Y)
 {
     byte[] Sw = new byte[4];
     byte[] Xp = new byte[4];
     byte[] Yp = new byte[4];
     Sw = BitConverter.GetBytes(3);
     Xp = BitConverter.GetBytes(X);
     Yp = BitConverter.GetBytes(Y);
     InputClient.Send(Sw);
     InputClient.Send(Xp);
     InputClient.Send(Yp);
 }
Ejemplo n.º 8
0
        public override void RunTick()
        {
            // Loop through every player and update inputs for this frame tick:
            foreach (var player in Systems.localServer.players)
            {
                player.Value.input.UpdateKeyStates(0);
            }

            // Update Timer
            Systems.timer.RunTick();

            // Update UI
            UIComponent.ComponentWithFocus = null;
            Cursor.UpdateMouseState();
            UIHandler.cornerMenu.RunTick();

            // Run the Tutorial
            this.tutorial.RunTick();

            // Menu State
            if (UIHandler.uiState == UIState.Menu)
            {
                UIHandler.menu.RunTick();
                return;                 // Prevents editor ui, editor input, etc.
            }

            // Playing State
            else
            {
                InputClient input       = Systems.input;
                PlayerInput playerInput = Systems.localServer.MyPlayer.input;

                // Open Menu
                if (input.LocalKeyPressed(Keys.Escape) || playerInput.isPressed(IKey.Start) || playerInput.isPressed(IKey.Select))
                {
                    UIHandler.SetMenu(UIHandler.mainMenu, true);
                }

                // Open Console (Tilde)
                else if (input.LocalKeyPressed(Keys.OemTilde))
                {
                    UIHandler.editorConsole.Open();
                }
            }

            // Update UI Components
            this.editorUI.RunTick();

            // Run Input for Full Editor and Current Room
            this.EditorInput();
            this.CurrentRoom.RunTick();
        }
Ejemplo n.º 9
0
        public void EditorInput()
        {
            InputClient input = Systems.input;

            // Release TempTool Control every tick:
            if (EditorTools.tempTool != null)
            {
                EditorTools.ClearTempTool();
            }

            // Get the Local Keys Held Down
            Keys[] localKeys = input.GetAllLocalKeysDown();
            if (localKeys.Length == 0)
            {
                return;
            }

            // Key Presses that AREN'T using control keys:
            if (!input.LocalKeyDown(Keys.LeftControl) && !input.LocalKeyDown(Keys.RightControl))
            {
                // Func Tool Key Binds
                if (FuncTool.funcToolKey.ContainsKey(localKeys[0]))
                {
                    EditorTools.SetTempTool(FuncTool.funcToolMap[FuncTool.funcToolKey[localKeys[0]]]);
                }

                // Tile Tool Key Binds
                else if (EditorUI.currentSlotGroup > 0)
                {
                    this.CheckTileToolKeyBinds(localKeys[0]);
                }
            }

            // Open Wheel Menu
            if (input.LocalKeyPressed(Keys.Tab))
            {
                this.editorUI.contextMenu.OpenMenu();
            }

            // Button Mappings
            else if (input.LocalKeyPressed(Keys.P))
            {
                FuncButton.funcButtonMap[(byte)FuncButtonEnum.Play].ActivateFuncButton();
            }

            // If holding shift down, increase camera movement speed by 3.
            byte moveMult = (input.LocalKeyDown(Keys.LeftShift) || input.LocalKeyDown(Keys.RightShift)) ? (byte)3 : (byte)1;

            // Camera Movement
            Systems.camera.MoveWithInput(Systems.localServer.MyPlayer.input, moveMult);
            Systems.camera.StayBoundedAuto(350, 250);
        }
Ejemplo n.º 10
0
        public void RunTick()
        {
            // Handle Key Presses
            InputClient input = Systems.input;

            // Check if the menu should be closed:
            if (input.LocalKeyPressed(Keys.Escape))
            {
                UIHandler.SetMenu(null, false);
                return;
            }

            // Tab Between Options
            if (input.LocalKeyPressed(Keys.Tab))
            {
                if (UIComponent.ComponentSelected == this.loginInput)
                {
                    UIComponent.ComponentSelected = this.emailInput;
                }
                else if (UIComponent.ComponentSelected == this.emailInput)
                {
                    UIComponent.ComponentSelected = this.passInput;
                }
                else
                {
                    UIComponent.ComponentSelected = this.loginInput;
                }
            }

            this.textBox.RunTick();
            this.loginInput.RunTick();
            this.emailInput.RunTick();
            this.passInput.RunTick();
            this.loginButton.RunTick();

            // Clicked on Login Button.
            if (UIComponent.ComponentWithFocus == this.loginButton && Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
            {
                UIHandler.AddNotification(UIAlertType.Warning, "Attempting Login", "Please wait while a login is attempted...", 180);
                this.RunLoginAttemmpt();
            }

            this.registerButton.RunTick();

            // Clicked on Register Button.
            if (UIComponent.ComponentWithFocus == this.registerButton && Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
            {
                UIHandler.AddNotification(UIAlertType.Warning, "Attempting Registration", "Please wait while registration is attempted...", 180);
                this.RunRegisterAttemmpt();
            }
        }
Ejemplo n.º 11
0
        protected void DebugToggles()
        {
            // Change Active Debug Mode (press F8)
            InputClient input = Systems.input;

            if (input.LocalKeyPressed(Keys.F1))
            {
                UIHandler.levelConsole.SendCommand(Systems.settings.input.macroF1);
            }
            else if (input.LocalKeyPressed(Keys.F2))
            {
                UIHandler.levelConsole.SendCommand(Systems.settings.input.macroF2);
            }
            else if (input.LocalKeyPressed(Keys.F3))
            {
                UIHandler.levelConsole.SendCommand(Systems.settings.input.macroF3);
            }
            else if (input.LocalKeyPressed(Keys.F4))
            {
                UIHandler.levelConsole.SendCommand(Systems.settings.input.macroF4);
            }
            else if (input.LocalKeyPressed(Keys.F5))
            {
                UIHandler.levelConsole.SendCommand(Systems.settings.input.macroF5);
            }
            else if (input.LocalKeyPressed(Keys.F6))
            {
                UIHandler.levelConsole.SendCommand(Systems.settings.input.macroF6);
            }
            else if (input.LocalKeyPressed(Keys.F7))
            {
                UIHandler.levelConsole.SendCommand(Systems.settings.input.macroF7);
            }
            else if (input.LocalKeyPressed(Keys.F8))
            {
                UIHandler.levelConsole.SendCommand(Systems.settings.input.macroF8);
            }

            //else if(input.LocalKeyPressed(Keys.F5)) { DebugConfig.ResetDebugValues(); }
            //else if(input.LocalKeyPressed(Keys.F6)) { DebugConfig.ToggleDebugFrames(); }
            //else if(input.LocalKeyPressed(Keys.F7)) { DebugConfig.ToggleTickSpeed(true); }
            //else if(input.LocalKeyPressed(Keys.F8)) { DebugConfig.ToggleTickSpeed(false); }
        }
Ejemplo n.º 12
0
        public void RunTick()
        {
            // Handle Key Presses
            InputClient input       = Systems.input;
            PlayerInput playerInput = Systems.localServer.MyPlayer.input;

            // Check if the menu should be closed:
            if (input.LocalKeyPressed(Keys.Escape) || input.LocalKeyPressed(Keys.Tab) || playerInput.isPressed(IKey.Start))
            {
                UIHandler.SetMenu(null, false);
                return;
            }

            // If we clicked off of the menu, exit.
            //if(Cursor.LeftMouseState == Cursor.MouseDownState.Clicked && this.textBox.MouseOver != UIMouseOverState.On) {
            //	UIHandler.SetMenu(null, false);
            //}

            this.textBox.RunTick();
        }
Ejemplo n.º 13
0
 private void CloseAll(object sender, FormClosingEventArgs e)
 {
     try
     {
         if (Client[0].Connected)
         {
             Client[0].Close();
         }
         if (InputClient.Connected)
         {
             InputClient.Close();
         }
         if (ImageClient.Connected)
         {
             ImageClient.Close();
         }
         ServerOpenThread.Abort();
         ReceiveImageThread.Abort();
     }
     catch (Exception E)
     {
     }
 }
Ejemplo n.º 14
0
 private void CloseAll(object sender, FormClosingEventArgs e)
 {
     try
     {
         if (Client.Connected)
         {
             Client.Close();
         }
         if (ImageClient.Connected)
         {
             ImageClient.Close();
         }
         if (InputClient.Connected)
         {
             InputClient.Close();
         }
         GetData_From_Client.Abort();
         SendImage_To_Server_Thread.Abort();
         GetInput_Thread.Abort();
     }
     catch (Exception E)
     {
     }
 }
Ejemplo n.º 15
0
        public override void RunTick()
        {
            // Update Timer
            Systems.timer.RunTick();

            // Loop through every player and update inputs for this frame tick:
            foreach (var player in Systems.localServer.players)
            {
                //player.Value.input.UpdateKeyStates(Systems.timer.Frame);
                player.Value.input.UpdateKeyStates(0);                 // TODO: Update LocalServer so frames are interpreted and assigned here.
            }

            // Paging Input (only when in the paging area)
            InputClient input = Systems.input;

            // Update UI
            UIComponent.ComponentWithFocus = null;
            Cursor.UpdateMouseState();
            UIHandler.cornerMenu.RunTick();

            // Playing State
            if (UIHandler.uiState == UIState.Playing)
            {
                PagingPress pageInput = this.paging.PagingInput(playerInput);

                if (pageInput != PagingPress.None)
                {
                    Systems.sounds.click2.Play(0.5f, 0, 0.5f);

                    if (pageInput == PagingPress.PageChange)
                    {
                        // Apply New Level Data
                        for (short i = this.paging.MinVal; i < this.paging.MaxVal; i++)
                        {
                            this.ApplyLevelDataByNumber(i);
                        }
                    }
                }

                // Check if the mouse is hovering over a planet (and draw accordingly if so)
                this.CheckPlanetHover();

                // Activate Level
                if (playerInput.isPressed(IKey.AButton) == true)
                {
                    short curVal = this.paging.CurrentSelectionVal;
                    SceneTransition.ToLevelEditor("", "__" + curVal.ToString(), curVal);
                    return;
                }

                // Open Menu
                if (input.LocalKeyPressed(Keys.Escape) || playerInput.isPressed(IKey.Start) || playerInput.isPressed(IKey.Select))
                {
                    UIHandler.SetMenu(UIHandler.mainMenu, true);
                }
            }

            // Menu State
            else
            {
                UIHandler.menu.RunTick();
            }
        }
Ejemplo n.º 16
0
        static void InputServer(InputClient client)
        {
            Console.Error.WriteLine("Start input server");
            HashSet<byte> keysDown = new HashSet<byte>();

            CloseHandler.SetCloseHandler(() =>
            {
                System.IO.File.WriteAllText("serverCloseLog.txt", "Server closing, resetting keys:\r\n");
                foreach (byte keycode in keysDown)
                {
                    client.KeyUp(keycode);
                    System.IO.File.AppendAllText("serverCloseLog.txt", "KeyCode: " + keycode + "\r\n");
                }

                client.MouseUp(MouseButton.Left);
                client.MouseUp(MouseButton.Right);
                client.MouseUp(MouseButton.Middle);
            });

            // we work on a line by line basis
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                client.ResetScreenSaver();
                // we can process multiple commands in a single line separated by ;
                foreach (string linePart in line.Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries))
                {
                    // Add to history
                    s_events.Add(linePart);
                    while (s_events.Count > MAX_EVENTS_HISTORY) s_events.RemoveAt(0);

                    // split by space
                    string[] parts = linePart.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);

                    switch (parts[0])
                    {
                        case "mm":
                            // Mouse move
                            // x = parts[1], y = parts[2]
                            double x = double.Parse(parts[1]);
                            double y = double.Parse(parts[2]);
                            int width, height;
                            client.GetScreenSize(out width, out height);

                            int xPixel = (int)(x * width);
                            int yPixel = (int)(y * height);

                            if (xPixel > width) xPixel = width;
                            if (yPixel > height) yPixel = height;

                            client.MouseMove(xPixel, yPixel);
                            break;
                        case "mmr":
                            // Relative mouse move
                            // x change = parts[1], y change = parts[2]

                            int xDiff = int.Parse(parts[1]);
                            int yDiff = int.Parse(parts[2]);

                            client.MouseMoveRelative(xDiff, yDiff);
                            break;
                        case "m":
                        case "md":
                        case "mu":
                            // Mouse click
                            // clickType == parts[1], l = left, m = middle, r = right

                            MouseButton btn = MouseButton.Left;
                            if (parts[1] == "m") {
                                btn = MouseButton.Middle;
                            }
                            else if (parts[1] == "r")
                            {
                                btn = MouseButton.Right;
                            }

                            if (parts[0] == "m")
                            {
                                client.MouseClick(btn);
                            }
                            else if (parts[0] == "md")
                            {
                                client.MouseDown(btn);
                            }
                            else if (parts[0] == "mu")
                            {
                                client.MouseUp(btn);
                            }
                            else
                            {
                                throw new Exception("Forgot to update some strings somewhere?");
                            }

                            break;
                        case "k":
                        case "kd":
                        case "ku":
                            // Keyboard button
                            byte keycode = byte.Parse(parts[1]);

                            if (parts[0] == "k")
                            {
                                client.KeyDown(keycode);
                                client.KeyUp(keycode);
                            }
                            else if (parts[0] == "kd")
                            {
                                keysDown.Add(keycode);
                                client.KeyDown(keycode);
                            }
                            else if (parts[0] == "ku")
                            {
                                if (keysDown.Contains(keycode)) keysDown.Remove(keycode);
                                client.KeyUp(keycode);
                            }
                            else
                            {
                                throw new Exception("Forgot to update some strings somewhere?");
                            }

                            break;
                        case "sy":
                        case "sx":
                            int scrollDelta = (int)(double.Parse(parts[1]) * 120);
                            client.MouseScroll(scrollDelta, parts[0] == "sx");
                            break;
                        case "s":
                            // Get screen size
                            int screenW, screenH;

                            client.GetScreenSize(out screenW, out screenH);
                            Console.WriteLine("{0} {1}", screenW, screenH);
                            break;
                        case "ss":
                            // Take screenshot - dir to save is first param, returns file saved (including dir name)
                            // image width/height are 2nd and 3rd params, anything <= 0 means ignore it and use native res
                            int sWidth = int.Parse(parts[2]);
                            int sHeight = int.Parse(parts[3]);

                            ThreadPool.QueueUserWorkItem(o =>
                            {
                                Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
                                string filename = APPPATH + System.IO.Path.DirectorySeparatorChar + client.Screenshot(parts[1], sWidth, sHeight);
                                Console.WriteLine("==screenshot==");
                                Console.WriteLine(filename);
                                Console.WriteLine("<><>");
                            });
                            break;
                        case "clear":
                            // Reset all the current keys that are down

                            foreach (byte keyCode in keysDown)
                            {
                                client.KeyUp(keyCode);
                            }
                            keysDown.Clear();
                            break;
                        case "debug":
                            // start of output
                            Console.WriteLine("==debug==");
                            Console.WriteLine("Event History:");
                            foreach (string e in s_events)
                            {
                                Console.WriteLine(" " + e);
                            }

                            Console.WriteLine("Key Downs:");
                            foreach (byte k in keysDown)
                            {
                                Console.WriteLine(" " + k);
                            }

                            // end of output
                            Console.WriteLine("<><>");
                            break;
                        default:
                            throw new InvalidOperationException("Protocol Violation");
                    }
                }
            }
            Console.Error.WriteLine("Input server closed");
        }
Ejemplo n.º 17
0
        public void GetInput()
        {
            byte[] SwB = new byte[4];
            int    sw;

            try
            {
                while (InputClient.Connected)
                {
                    InputClient.Receive(SwB, 4, SocketFlags.None);
                    sw = BitConverter.ToInt32(SwB, 0);
                    if (sw == 0)
                    {
                        byte[] KeyValue = new byte[4];
                        InputClient.Receive(KeyValue, 4, SocketFlags.None);
                        int KeyCode = BitConverter.ToInt32(KeyValue, 0);
                        InterceptKeyBoard.InputKeyDown(KeyCode);
                    }
                    else if (sw == 1)
                    {
                        byte[] KeyValue = new byte[4];
                        InputClient.Receive(KeyValue, 4, SocketFlags.None);
                        int KeyCode = BitConverter.ToInt32(KeyValue, 0);
                        InterceptKeyBoard.InputKeyUp(KeyCode);
                    }
                    else if (sw == 2)
                    {
                        byte[] Xp = new byte[4];
                        byte[] Yp = new byte[4];
                        InputClient.Receive(Xp, 4, SocketFlags.None);
                        InputClient.Receive(Yp, 4, SocketFlags.None);
                        int X, Y;
                        X = BitConverter.ToInt32(Xp, 0);
                        Y = BitConverter.ToInt32(Yp, 0);
                        InterceptMouse.MouseDown_Left(X, Y);
                        ChatBox.Items.Add("MouseDown " + X + " " + Y);
                    }
                    else if (sw == 3)
                    {
                        byte[] Xp = new byte[4];
                        byte[] Yp = new byte[4];
                        InputClient.Receive(Xp, 4, SocketFlags.None);
                        InputClient.Receive(Yp, 4, SocketFlags.None);
                        int X, Y;
                        X = BitConverter.ToInt32(Xp, 0);
                        Y = BitConverter.ToInt32(Yp, 0);
                        InterceptMouse.MouseUp_Left(X, Y);
                        ChatBox.Items.Add("Mouseup " + X + " " + Y);
                    }
                    else if (sw == 6)
                    {
                        byte[] Xp = new byte[4];
                        byte[] Yp = new byte[4];
                        InputClient.Receive(Xp, 4, SocketFlags.None);
                        InputClient.Receive(Yp, 4, SocketFlags.None);
                        int X, Y;
                        X = BitConverter.ToInt32(Xp, 0);
                        Y = BitConverter.ToInt32(Yp, 0);
                        InterceptMouse.MouseDown_Right(X, Y);
                        ChatBox.Items.Add("MouseRightDown " + X + " " + Y);
                    }
                    else if (sw == 7)
                    {
                        byte[] Xp = new byte[4];
                        byte[] Yp = new byte[4];
                        InputClient.Receive(Xp, 4, SocketFlags.None);
                        InputClient.Receive(Yp, 4, SocketFlags.None);
                        int X, Y;
                        X = BitConverter.ToInt32(Xp, 0);
                        Y = BitConverter.ToInt32(Yp, 0);
                        InterceptMouse.MouseUp_Right(X, Y);
                        ChatBox.Items.Add("MouseRightUp " + X + " " + Y);
                    }
                    else if (sw == 8)
                    {
                        byte[] Xp = new byte[4];
                        InputClient.Receive(Xp, 4, SocketFlags.None);
                        int X;
                        X = BitConverter.ToInt32(Xp, 0);
                        InterceptMouse.MouseWheel(X);
                        ChatBox.Items.Add("MouseWheel " + X);
                    }
                }
            }
            catch (Exception Ex)
            {
            }
        }
Ejemplo n.º 18
0
        public void RunTick()
        {
            InputClient input = Systems.input;

            // Get Characters Pressed (doesn't assist with order)
            string charsPressed = input.GetCharactersPressed();

            if (charsPressed.Length > 0)
            {
                ConsoleTrack.instructionText += charsPressed;
            }

            // Backspace
            else if (input.LocalKeyDown(Keys.Back) && ConsoleTrack.instructionText.Length > 0)
            {
                // After a hard delete (just pressed), wait 10 frames rather than 3.
                if (input.LocalKeyPressed(Keys.Back))
                {
                    ConsoleTrack.instructionText = ConsoleTrack.instructionText.Substring(0, ConsoleTrack.instructionText.Length - 1);
                    this.backspaceFrame          = Systems.timer.UniFrame + 10;

                    // If held shift or control, remove the full line.
                    if (input.LocalKeyDown(Keys.LeftShift) || input.LocalKeyDown(Keys.RightShift) || input.LocalKeyDown(Keys.LeftControl) || input.LocalKeyDown(Keys.RightControl))
                    {
                        ConsoleTrack.instructionText = "";
                    }
                }

                else if (this.backspaceFrame < Systems.timer.UniFrame)
                {
                    ConsoleTrack.instructionText = ConsoleTrack.instructionText.Substring(0, ConsoleTrack.instructionText.Length - 1);

                    // Delete a character every 3 frames.
                    this.backspaceFrame = Systems.timer.UniFrame + 3;
                }
            }

            // Up + Down - Scroll through Console Text
            else if (input.LocalKeyPressed(Keys.Up))
            {
                this.ScrollConsoleText(-1);
            }
            else if (input.LocalKeyPressed(Keys.Down))
            {
                this.ScrollConsoleText(1);
            }

            // Tab - Appends the tab lookup to the current instruction text.
            else if (input.LocalKeyDown(Keys.Tab))
            {
                ConsoleTrack.instructionText += ConsoleTrack.tabLookup;
            }

            // Enter - Process the instruction.
            else if (input.LocalKeyPressed(Keys.Enter))
            {
                ConsoleTrack.activate = true;                 // The instruction is meant to run (rather than just reveal new text hints).
            }

            // Close Console (Tilde, Escape)
            else if (input.LocalKeyPressed(Keys.OemTilde) || input.LocalKeyPressed(Keys.Escape))
            {
                UIHandler.SetMenu(null, false);
            }

            // If there was no input provided, end here.
            else
            {
                return;
            }

            // Process the Instruction
            this.SendCommand(ConsoleTrack.instructionText, false);
        }
Ejemplo n.º 19
0
        public override void RunTick()
        {
            // Scene Loop will perform scene-specific critical checks, such as identifying all players' input.
            // Single Player will only retrieve one player, while MP will review all players connected.
            this.RunSceneLoop();

            InputClient input       = Systems.input;
            PlayerInput playerInput = Systems.localServer.MyPlayer.input;

            // Update UI
            UIComponent.ComponentWithFocus = null;
            Cursor.UpdateMouseState();
            UIHandler.cornerMenu.RunTick();

            // Menu State
            if (UIHandler.uiState == UIState.Menu)
            {
                UIHandler.menu.RunTick();
                return;
            }

            // Playing State
            else
            {
                // Open Menu
                if (input.LocalKeyPressed(Keys.Escape) || playerInput.isPressed(IKey.Start) || playerInput.isPressed(IKey.Select))
                {
                    UIHandler.SetMenu(UIHandler.levelMenu, true);
                }

                // Open Console (Tilde)
                else if (Systems.input.LocalKeyPressed(Keys.OemTilde))
                {
                    UIHandler.levelConsole.Open();
                }
            }

            // Some Scenes will disable this, or limit behavior (such as for multiplayer).
            if (this.RunLocalDebugFeatures())
            {
                return;
            }

            // Update Timer
            Systems.timer.RunTick();

            // Run Each Room in Level
            this.RunRoomLoop();

            // If the time runs out:
            int framesRemain = Systems.handler.levelState.FramesRemaining;

            if (framesRemain <= 600)
            {
                Character mychar = Systems.localServer.MyCharacter;

                // Play Tick Sounds to Alert Player
                if (framesRemain <= 300)
                {
                    int m8 = Systems.timer.frame60Modulus % 15;

                    if (m8 == 0)
                    {
                        mychar.room.PlaySound(Systems.sounds.timer1, 1f, Systems.camera.posX + Systems.camera.halfWidth, Systems.camera.posY + Systems.camera.halfHeight);
                    }
                    else if (m8 == 8)
                    {
                        mychar.room.PlaySound(Systems.sounds.timer2, 1f, Systems.camera.posX + Systems.camera.halfWidth, Systems.camera.posY + Systems.camera.halfHeight);
                    }
                }

                else if (Systems.timer.IsBeatFrame)
                {
                    if (Systems.timer.beat4Modulus % 2 == 0)
                    {
                        mychar.room.PlaySound(Systems.sounds.timer1, 1f, Systems.camera.posX + Systems.camera.halfWidth, Systems.camera.posY + Systems.camera.halfHeight);
                    }
                    else
                    {
                        mychar.room.PlaySound(Systems.sounds.timer2, 1f, Systems.camera.posX + Systems.camera.halfWidth, Systems.camera.posY + Systems.camera.halfHeight);
                    }
                }

                if (framesRemain <= 0)
                {
                    mychar.wounds.ReceiveWoundDamage(DamageStrength.InstantKill, true);
                }
            }
        }