Exemple #1
0
    public void Input()
    {
        inputDirection = Vector2.Zero;
        if (input[PlayerKey.Right])
        {
            inputDirection.X++;
        }
        if (input[PlayerKey.Left])
        {
            inputDirection.X--;
        }

        if (input[PlayerKey.Up])
        {
            inputDirection.Y++;
        }
        if (input[PlayerKey.Down])
        {
            inputDirection.Y--;
        }

        if (IsLocalPlayer)
        {
            //Dodging
            if (dodgeCooldown.IsDone && inputDirection != Vector2.Zero)
            {
                if ((inputDirection == lastDirection && dodgeIntervalTimer > 0 && oldInputDirection != inputDirection) || keyboard.KeyPressed(Key.LShift))
                {
                    if (inputDirection.X > 0)
                    {
                        Dodge(Direction.Right);
                    }
                    else if (inputDirection.X < 0)
                    {
                        Dodge(Direction.Left);
                    }
                    else if (inputDirection.Y > 0)
                    {
                        Dodge(Direction.Up);
                    }
                    else if (inputDirection.Y < 0)
                    {
                        Dodge(Direction.Down);
                    }
                }

                if (inputDirection != oldInputDirection)
                {
                    dodgeIntervalTimer = dodgeInterval;
                }

                lastDirection = inputDirection;
            }

            //Jumping
            if (input[PlayerKey.Jump] && (!oldInput[PlayerKey.Jump] || bufferFrame))
            {
                if (IsOnGround)
                {
                    Jump();
                }
                else if (WallTouch != 0)
                {
                    WallJump();
                }
                else if (canDoublejump)
                {
                    Jump();
                    canDoublejump = false;
                }

                SendJump();
                bufferFrame = false;
            }

            //Dash
            if (input[PlayerKey.Dash] && !oldInput[PlayerKey.Dash] && CanDash)
            {
                Dash(shadow.CurrentPosition);
            }

            //Shooting
            if (Weapon != null)
            {
                if (input[PlayerKey.Shoot] && !oldInput[PlayerKey.Shoot])
                {
                    Weapon.Press();
                }
                if (input[PlayerKey.Shoot] && oldInput[PlayerKey.Shoot])
                {
                    Weapon.Hold();
                }
                if (!input[PlayerKey.Shoot] && oldInput[PlayerKey.Shoot])
                {
                    Weapon.Release();
                }
            }
        }
        else
        {
            if (dashTargetBuffer != null)
            {
                Dash(dashTargetBuffer);
                dashTargetBuffer = null;
            }

            if (dodgeTargetBuffer != null)
            {
                Dodge(dodgeTargetBuffer);
                dodgeTargetBuffer = null;
            }
        }

        if (inputDirection.X != 0)
        {
            if (WallStickable && WallTouch == -inputDirection.X)
            {
                wallStick = 0.3f;
            }

            if (wallStick <= 0)
            {
                currentAcceleration += Acceleration * inputDirection.X;
            }
        }

        oldInputDirection = inputDirection;

        if (input[PlayerKey.Jump])
        {
            JumpHold();
        }

        bufferFrame = false;
    }
Exemple #2
0
    public void Update()
    {
        mouse.PlaneDistance = editorCamera.Position.Z;

        cameraControl.Logic();
        editorCamera.Position = CameraControl.Position;
        editorCamera.Target   = CameraControl.Position * new Vector3(1, 1, 0);

        if (keyboard.KeyPressed(Key.Tab))
        {
            SwitchSelectMode();
        }

        if (keyboard.KeyReleased(Key.Delete))
        {
            List <EMesh> meshes = new List <EMesh>();
            foreach (EMesh m in SelectedMeshes)
            {
                meshes.Add(m);
            }

            if (meshes.Count > 0)
            {
                ActiveHistory.Add(new RemoveAction(meshes, ActiveHistory));

                foreach (EMesh m in meshes)
                {
                    m.Remove();
                }

                DeselectAll();
            }
        }

        /*
         * if (manipulatorMode == ManipulatorMode.Paint)
         * {
         *      form.CursorVisible = false;
         * }
         * else
         *      form.CursorVisible = true;
         */

        foreach (Manipulator m in manipulators)
        {
            m.UpdatePivot();
        }

        //SOME HOTKEYS
        if (form.Focused && !Manipulator.Active)
        {
            if (keyboard[Key.LControl])
            {
                //OPTIONS
                if (keyboard[Key.LShift])
                {
                    if (keyboard.KeyPressed(Key.G))
                    {
                        OptionsForm.options.ShowGrid = !OptionsForm.options.ShowGrid;
                    }
                    if (keyboard.KeyPressed(Key.L))
                    {
                        OptionsForm.options.FocusLayer = !OptionsForm.options.FocusLayer;
                    }
                    if (keyboard.KeyPressed(Key.B))
                    {
                        OptionsForm.options.MeshBorders = !OptionsForm.options.MeshBorders;
                    }
                }
                else                 //OTHER EDITOR HOTKEYS
                {
                    if (keyboard.KeyPressed(Key.D))
                    {
                        CopySelected();
                        PasteSelected();
                    }

                    if (keyboard.KeyPressed(Key.C))
                    {
                        CopySelected();
                    }
                    if (keyboard.KeyPressed(Key.V))
                    {
                        PasteSelected();
                    }

                    if (keyboard.KeyPressed(Key.Z) && ActiveLayers.Count > 0)
                    {
                        ActiveLayers[0].History.Undo();
                    }
                    if (keyboard.KeyPressed(Key.Y) && ActiveLayers.Count > 0)
                    {
                        ActiveLayers[0].History.Redo();
                    }

                    if (keyboard.KeyPressed(Key.B))
                    {
                        (manipulators[(int)ManipulatorMode.Paint] as VertexPen).ShowPalette();
                    }
                }
            }
            else
            {
                //MANIPULATOR CONTROL
                if (keyboard.KeyPressed(Key.Q))
                {
                    manipulatorMode = ManipulatorMode.None;
                }
                if (keyboard.KeyPressed(Key.W))
                {
                    manipulatorMode = ManipulatorMode.Translate;
                }
                if (keyboard.KeyPressed(Key.E))
                {
                    manipulatorMode = ManipulatorMode.Rotate;
                }
                if (keyboard.KeyPressed(Key.R))
                {
                    manipulatorMode = ManipulatorMode.Scale;
                }
                if (keyboard.KeyPressed(Key.B))
                {
                    manipulatorMode = ManipulatorMode.Paint;
                }
            }
        }

        selectionBox.Logic();
        meshCreator.Logic();

        foreach (EMesh m in Meshes)
        {
            m.Logic();
        }

        Manipulator.Logic();
    }