Beispiel #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();
            }
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
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);
        }
Beispiel #5
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();
            }
        }
Beispiel #6
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));
                    }
                }
            }
        }
Beispiel #7
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();
        }
Beispiel #8
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); }
        }
Beispiel #9
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);
                }
            }
        }
Beispiel #10
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();
            }
        }
Beispiel #11
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);
        }