Beispiel #1
0
        public virtual bool ObjectInteractionInputMessage(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
        {
            var mouseDown = message as InputMessageMouseButtonDown;

            if (mouseDown != null)
            {
                if (mouseDown.Button == EMouseButtons.Left || mouseDown.Button == EMouseButtons.Right)
                {
                    //ClickingBegin();

                    log("InteractionInputMessage");
                    return(true);
                }
            }

            return(false);
        }
        public virtual bool ObjectInteractionInputMessage(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
        {
            var mouseDown = message as InputMessageMouseButtonDown;

            if (mouseDown != null)
            {
                if (mouseDown.Button == EMouseButtons.Left || mouseDown.Button == EMouseButtons.Right)
                {
                    //take by a character
                    var character = gameMode.ObjectControlledByPlayer.Value as Component_Character2D;
                    if (character != null && character.ItemGetEnabledFirst() == null)
                    {
                        character.ItemTake(this);
                        character.ItemActivate(this);
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #3
0
        protected override void OnInputMessage(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
        {
            base.OnInputMessage(playScreen, gameMode, message);

            if (!gameMode.FreeCamera && InputEnabled)
            {
                //key down
                var keyDown = message as InputMessageKeyDown;
                if (keyDown != null)
                {
                    if (gameMode.UseBuiltInCamera.Value == Component_GameMode.BuiltInCameraEnum.None || gameMode.UseBuiltInCamera.Value == Component_GameMode.BuiltInCameraEnum.ThirdPerson)
                    {
                        //jump
                        if (Character.JumpSupport && keyDown.Key == EKeys.Space)
                        {
                            Character.TryJump();
                        }

                        //drop item
                        if (keyDown.Key == EKeys.T)
                        {
                            var item = Character.ItemGetEnabledFirst();
                            if (item != null)
                            {
                                Transform newTransform = null;

                                //drop to ground. it is simple implementation
                                //var obj = item as Component_ObjectInSpace;
                                //if( obj != null )
                                //{
                                //	var scaleFactor = Character.GetScaleFactor();
                                //	newTransform = new Transform( Character.TransformV.Position + new Vector3( 0, 0.2 * scaleFactor - Character.PositionToGroundHeight * scaleFactor, 0 ), Character.TransformV.Rotation, obj.TransformV.Scale );
                                //}

                                Character.ItemDrop(item, newTransform);
                            }
                        }
                    }
                }

                //mouse down
                var mouseDown = message as InputMessageMouseButtonDown;
                if (mouseDown != null && mouseDown.Button == EMouseButtons.Left)
                {
                    if (gameMode.UseBuiltInCamera.Value == Component_GameMode.BuiltInCameraEnum.None || gameMode.UseBuiltInCamera.Value == Component_GameMode.BuiltInCameraEnum.ThirdPerson)
                    {
                        var item = Character.ItemGetEnabledFirst();
                        if (item != null)
                        {
                            var weapon = item as Component_Weapon2D;
                            if (weapon != null)
                            {
                                firing = true;
                                weapon.FiringBegin();
                            }
                        }
                    }
                }

                //mouse up
                var mouseUp = message as InputMessageMouseButtonUp;
                if (mouseUp != null && mouseUp.Button == EMouseButtons.Left)
                {
                    firing = false;
                }

                ////mouse move
                //var mouseMove = message as InputMessageMouseMove;
                //if( mouseMove != null && MouseRelativeMode )
                //{
                //	if( gameMode.UseBuiltInCamera.Value == Component_GameMode.BuiltInCameraEnum.None || gameMode.UseBuiltInCamera.Value == Component_GameMode.BuiltInCameraEnum.ThirdPerson )
                //	{
                //		var mouseOffset = mouseMove.Position;

                //		var fpsCamera = gameMode.UseBuiltInCamera.Value == Component_GameMode.BuiltInCameraEnum.FirstPerson;

                //		//!!!!
                //		Vector2 sens = new Vector2( 1, 1 ) * 2;
                //		//Vector2 sens = GameControlsManager.Instance.MouseSensitivity * 2;

                //		lookDirection.Horizontal -= mouseOffset.X * sens.X;
                //		lookDirection.Vertical -= mouseOffset.Y * sens.Y;

                //		double limit = fpsCamera ? 0.1 : Math.PI / 8;
                //		if( lookDirection.Vertical < -( Math.PI / 2 - limit ) )
                //			lookDirection.Vertical = -( Math.PI / 2 - limit );
                //		if( lookDirection.Vertical > ( Math.PI / 2 - limit ) )
                //			lookDirection.Vertical = ( Math.PI / 2 - limit );
                //	}
                //}
            }
        }
Beispiel #4
0
        public bool ObjectInteractionInputMessage(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
        {
            if (createdViewport != null)
            {
                var mouseDown = message as InputMessageMouseButtonDown;
                if (mouseDown != null && createdViewport.UIContainer.PerformMouseDown(mouseDown.Button))
                {
                    return(true);
                }

                var mouseDoubleClick = message as InputMessageMouseDoubleClick;
                if (mouseDoubleClick != null && createdViewport.UIContainer.PerformMouseDoubleClick(mouseDoubleClick.Button))
                {
                    return(true);
                }

                var mouseUp = message as InputMessageMouseButtonUp;
                if (mouseUp != null && createdViewport.UIContainer.PerformMouseUp(mouseUp.Button))
                {
                    return(true);
                }

                var keyDown = message as InputMessageKeyDown;
                if (keyDown != null && createdViewport.UIContainer.PerformKeyDown(new KeyEvent(keyDown.Key)))
                {
                    return(true);
                }

                var keyPress = message as InputMessageKeyPress;
                if (keyPress != null && createdViewport.UIContainer.PerformKeyPress(new KeyPressEvent(keyPress.KeyChar)))
                {
                    return(true);
                }

                var keyUp = message as InputMessageKeyUp;
                if (keyUp != null && createdViewport.UIContainer.PerformKeyUp(new KeyEvent(keyUp.Key)))
                {
                    return(true);
                }

                var mouseWheel = message as InputMessageMouseWheel;
                if (mouseWheel != null && createdViewport.UIContainer.PerformMouseWheel(mouseWheel.Delta))
                {
                    return(true);
                }

                //PerformJoystickEvent
                //PerformSpecialInputDeviceEvents
            }

            return(false);
        }
Beispiel #5
0
        bool ProcessInputMessageBefore(UIControl playScreen, InputMessage message)
        {
            //input enabled changed
            {
                var m = message as InputMessageInputEnabledChanged;
                if (m != null)
                {
                    inputEnabled = m.Value;
                }
            }

            //key down
            {
                var m = message as InputMessageKeyDown;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    if (keys == null)
                    {
                        keys = new bool[GetEKeysMaxIndex() + 1];
                    }
                    keys[(int)m.Key] = true;
                    //}
                }
            }

            //key up
            {
                var m = message as InputMessageKeyUp;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    if (keys == null)
                    {
                        keys = new bool[GetEKeysMaxIndex() + 1];
                    }

                    if (keys[(int)m.Key])
                    {
                        keys[(int)m.Key] = false;
                    }
                    //}
                }
            }

            //mouse button down
            {
                var m = message as InputMessageMouseButtonDown;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    mouseButtons[(int)m.Button] = true;
                    //}
                }
            }

            //mouse button up
            {
                var m = message as InputMessageMouseButtonUp;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    mouseButtons[(int)m.Button] = false;
                    //}
                }
            }

            //mouse move
            {
                var m = message as InputMessageMouseMove;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    mousePosition = m.Position;
                    //}
                }
            }

            //mouse relative mode
            {
                var m = message as InputMessageMouseRelativeModeChanged;
                if (m != null)
                {
                    mouseRelativeMode = m.Value;
                }
            }

            var keyDown = message as InputMessageKeyDown;

            if (keyDown != null && FreeCameraHotKey && FreeCameraHotKeyValue.Value == keyDown.Key)
            {
                //all keys and mouse buttons up
                var viewport = playScreen.ParentContainer.Viewport;
                viewport.KeysAndMouseButtonUpAll();

                //change free camera
                FreeCamera = !FreeCamera;

                //show screen message
                if (FreeCamera)
                {
                    ScreenMessages.Add($"Free camera is activated.");
                }
                else
                {
                    ScreenMessages.Add($"Free camera is deactivated.");
                }

                return(true);
            }

            var mouseDown = message as InputMessageMouseButtonDown;

            if (mouseDown != null)
            {
                //free camera rotating
                if (mouseDown.Button == EMouseButtons.Right && FreeCamera)
                {
                    freeCameraMouseRotating          = true;
                    freeCameraMouseRotatingActivated = false;
                    freeCameraRotatingStartPos       = MousePosition;
                }
            }

            var mouseUp = message as InputMessageMouseButtonUp;

            if (mouseUp != null)
            {
                //free camera rotating
                if (mouseUp.Button == EMouseButtons.Right && freeCameraMouseRotating)
                {
                    var viewport = playScreen.ParentContainer.Viewport;
                    //viewport.MouseRelativeMode = false;
                    freeCameraMouseRotating          = false;
                    freeCameraMouseRotatingActivated = false;
                }
            }

            var mouseMove = message as InputMessageMouseMove;

            if (mouseMove != null)
            {
                //free camera rotating
                if (FreeCamera && freeCameraMouseRotating)
                {
                    var viewport = playScreen.ParentContainer.Viewport;

                    if (!viewport.MouseRelativeMode)
                    {
                        var diffPixels = (MousePosition - freeCameraRotatingStartPos) * viewport.SizeInPixels.ToVector2();
                        if (Math.Abs(diffPixels.X) >= 3 || Math.Abs(diffPixels.Y) >= 3)
                        {
                            freeCameraMouseRotatingActivated = true;
                            //viewport.MouseRelativeMode = true;
                        }
                    }
                    else
                    {
                        var dir = freeCameraDirection;
                        dir.Horizontal -= MousePosition.X;                      // * cameraRotateSensitivity;
                        dir.Vertical   -= MousePosition.Y;                      // * cameraRotateSensitivity;

                        dir.Horizontal = MathEx.RadianNormalize360(dir.Horizontal);

                        const double vlimit = Math.PI / 2 - .01f;
                        if (dir.Vertical > vlimit)
                        {
                            dir.Vertical = vlimit;
                        }
                        if (dir.Vertical < -vlimit)
                        {
                            dir.Vertical = -vlimit;
                        }

                        freeCameraDirection = dir;
                    }
                }
            }

            if (FreeCamera && !EngineConsole.Active && InputEnabled)
            {
                //key down
                {
                    var m = message as InputMessageKeyDown;
                    if (m != null)
                    {
                        if (m.Key == EKeys.W || m.Key == EKeys.Up || m.Key == EKeys.S || m.Key == EKeys.Down || m.Key == EKeys.A || m.Key == EKeys.Left || m.Key == EKeys.D || m.Key == EKeys.Right || m.Key == EKeys.E || m.Key == EKeys.Q)
                        {
                            return(true);
                        }
                    }
                }

                //up down
                {
                    var m = message as InputMessageKeyUp;
                    if (m != null)
                    {
                        if (m.Key == EKeys.W || m.Key == EKeys.Up || m.Key == EKeys.S || m.Key == EKeys.Down || m.Key == EKeys.A || m.Key == EKeys.Left || m.Key == EKeys.D || m.Key == EKeys.Right || m.Key == EKeys.E || m.Key == EKeys.Q)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #6
0
 protected virtual void OnInputMessage(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
 {
 }
Beispiel #7
0
        //!!!!protected virtual? event?
        void InputMessageBefore(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
        {
            //input enabled changed
            {
                var m = message as InputMessageInputEnabledChanged;
                if (m != null)
                {
                    inputEnabled = m.Value;
                }
            }

            //key down
            {
                var m = message as InputMessageKeyDown;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    if (keys == null)
                    {
                        keys = new bool[GetEKeysMaxIndex() + 1];
                    }
                    keys[(int)m.Key] = true;
                    //}
                }
            }

            //key up
            {
                var m = message as InputMessageKeyUp;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    if (keys == null)
                    {
                        keys = new bool[GetEKeysMaxIndex() + 1];
                    }

                    if (keys[(int)m.Key])
                    {
                        keys[(int)m.Key] = false;
                    }
                    //}
                }
            }

            //mouse button down
            {
                var m = message as InputMessageMouseButtonDown;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    mouseButtons[(int)m.Button] = true;
                    //}
                }
            }

            //mouse button up
            {
                var m = message as InputMessageMouseButtonUp;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    mouseButtons[(int)m.Button] = false;
                    //}
                }
            }

            //mouse move
            {
                var m = message as InputMessageMouseMove;
                if (m != null)
                {
                    //lock( lockerKeysMouse )
                    //{
                    mousePosition = m.Position;
                    //}
                }
            }

            //mouse relative mode
            {
                var m = message as InputMessageMouseRelativeModeChanged;
                if (m != null)
                {
                    mouseRelativeMode = m.Value;
                }
            }

            //joystick
            {
                var m = message as InputMessageJoystick;
                if (m != null)
                {
                    //button down
                    {
                        var m2 = m.InputEvent as JoystickButtonDownEvent;
                        if (m2 != null)
                        {
                            var index = m2.Button.Index;
                            if (index >= 0 && index < joystickButtons.Length)
                            {
                                joystickButtons[index] = true;
                            }
                        }
                    }

                    //button up
                    {
                        var m2 = m.InputEvent as JoystickButtonUpEvent;
                        if (m2 != null)
                        {
                            var index = m2.Button.Index;
                            if (index >= 0 && index < joystickButtons.Length)
                            {
                                joystickButtons[index] = false;
                            }
                        }
                    }

                    //axis
                    {
                        var m2 = m.InputEvent as JoystickAxisChangedEvent;
                        if (m2 != null)
                        {
                            var index = (int)m2.Axis.Name;
                            if (index >= 0 && index < joystickAxes.Length)
                            {
                                joystickAxes[index] = m2.Axis.Value;
                            }
                        }
                    }

                    //POV
                    {
                        var m2 = m.InputEvent as JoystickPOVChangedEvent;
                        if (m2 != null)
                        {
                            var index = (int)m2.POV.Name;
                            if (index >= 0 && index < joystickPOVs.Length)
                            {
                                joystickPOVs[index] = m2.POV.Value;
                            }
                        }
                    }

                    //slider
                    {
                        var m2 = m.InputEvent as JoystickSliderChangedEvent;
                        if (m2 != null)
                        {
                            var index = (int)m2.Slider.Name;
                            if (index >= 0 && index < joystickPOVs.Length)
                            {
                                joystickSliders[index] = m2.Slider.Value;
                            }
                        }
                    }
                }
            }

            ////special input device
            //{
            //	var m = message as InputMessageSpecialInputDevice;
            //	if( m != null )
            //	{
            //	}
            //}
        }
Beispiel #8
0
        public bool PerformMessage(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
        {
            InputMessageBefore(playScreen, gameMode, message);
            if (message.Handled)
            {
                return(true);
            }

            OnInputMessage(playScreen, gameMode, message);
            if (message.Handled)
            {
                return(true);
            }

            InputMessageEvent?.Invoke(this, playScreen, gameMode, message);
            if (message.Handled)
            {
                return(true);
            }

            return(false);
        }
        public void InputProcessing_InputMessageEvent(NeoAxis.Component_InputProcessing sender, NeoAxis.UIControl playScreen, NeoAxis.Component_GameMode gameMode, NeoAxis.InputMessage message)
        {
            var car = Owner.Parent.Parent;

            if (car == null)
            {
                return;
            }
        }
        public void InputProcessing_InputMessageEvent(NeoAxis.Component_InputProcessing sender, UIControl playScreen, NeoAxis.InputMessage message)
        {
            //get access to the ship
            var ship = sender.Parent;

            if (ship == null)
            {
                return;
            }
            //var keyDown = message as InputMessageKeyDown;
            //if(keyDown != null)
            //{
            //	if(keyDown.Key == EKeys.Space)
            //	{
            //		//var body = ship.GetComponent<Component_RigidBody2D>();
            //		//if (body != null)
            //		//{
            //		//	body.ApplyForce(new Vector2(1, 0));
            //		//}
            //	}
            //}
        }
Beispiel #11
0
        public virtual bool ObjectInteractionInputMessage(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
        {
            var mouseDown = message as InputMessageMouseButtonDown;

            if (mouseDown != null)
            {
                if (mouseDown.Button == EMouseButtons.Left || mouseDown.Button == EMouseButtons.Right)
                {
                    ChangingBegin(mouseDown.Button == EMouseButtons.Left);
                    return(true);
                }
            }

            var mouseUp = message as InputMessageMouseButtonUp;

            if (mouseUp != null)
            {
                if (mouseUp.Button == EMouseButtons.Left && Changing && ChangingForward)
                {
                    ChangingEnd();
                    return(true);
                }
                if (mouseUp.Button == EMouseButtons.Right && Changing && !ChangingForward)
                {
                    ChangingEnd();
                    return(true);
                }
            }

            return(false);
        }
Beispiel #12
0
 public void InputMessageEvent(NeoAxis.Component_InputProcessing sender, NeoAxis.UIControl playScreen, NeoAxis.Component_GameMode gameMode, NeoAxis.InputMessage message)
 {
     if (sender.IsKeyPressed(EKeys.Space) && message.GetType().ToString() == "NeoAxis.InputMessageKeyPress")
     {
         lifeValue = lifeValue + 1;
         OnSignal?.Invoke(lifeValue);
         //ScreenMessages.Add("Space");
     }
 }