Esempio n. 1
0
 public ObjectInteractionContextClass(IComponent_InteractiveObject obj, UIControl playScreen, Component_GameMode gameMode, Viewport viewport)
 {
     Obj        = obj;
     PlayScreen = playScreen;
     GameMode   = gameMode;
     Viewport   = viewport;
 }
Esempio n. 2
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);
        }
Esempio n. 3
0
 public void ObjectInteractionGetInfo(UIControl playScreen, Component_GameMode gameMode, ref IComponent_InteractiveObject_ObjectInfo info)
 {
     info = new IComponent_InteractiveObject_ObjectInfo();
     info.AllowInteract = AllowInteract;
     //info.DisplaySelectionRectangle = true;
     info.SelectionTextInfo.Add("Test message = " + Name);
 }
Esempio n. 4
0
 public void ObjectInteractionGetInfo(UIControl playScreen, Component_GameMode gameMode, ref IComponent_InteractiveObject_ObjectInfo info)
 {
     info = new IComponent_InteractiveObject_ObjectInfo();
     info.AllowInteract = AllowInteract;
     info.SelectionTextInfo.Add(Name);
     info.DisplaySelectionRectangle = false;
 }
        public virtual IComponent_InteractiveObject PickInteractiveObject(Component_GameMode gameMode, UIControl playScreen, Viewport viewport)
        {
            IComponent_InteractiveObject result = null;

            PickInteractiveObjectEvent?.Invoke(this, gameMode, playScreen, viewport, ref result);

            return(result);
        }
        public virtual bool IsNeedRenderObjectInteraction(Component_GameMode gameMode, UIControl playScreen, CanvasRenderer renderer)
        {
            bool result = true;

            IsNeedRenderObjectInteractionEvent?.Invoke(this, gameMode, playScreen, renderer, ref result);

            return(result);
        }
        public virtual bool IsNeedMouseRelativeMode(Component_GameMode gameMode)
        {
            bool result = true;

            IsNeedMouseRelativeModeEvent?.Invoke(this, gameMode, ref result);

            return(result);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public void ObjectInteractionGetInfo(UIControl playScreen, Component_GameMode gameMode, ref IComponent_InteractiveObject_ObjectInfo info)
        {
            //take by a character
            var character = gameMode.ObjectControlledByPlayer.Value as Component_Character;

            if (character != null && character.ItemGetEnabledFirst() == null)
            {
                info = new IComponent_InteractiveObject_ObjectInfo();
                info.AllowInteract = true;                //CanTake;
                info.SelectionTextInfo.Add(Name);
                info.SelectionTextInfo.Add("Click mouse button to take. Press T to drop.");
            }
        }
        public virtual Viewport.CameraSettingsClass GetCameraSettings(Component_GameMode gameMode, Viewport viewport, Component_Camera cameraDefault)
        {
            //event
            Viewport.CameraSettingsClass result = null;
            GetCameraSettingsEvent?.Invoke(this, gameMode, viewport, cameraDefault, ref result);

            //default behavior
            if (result == null)
            {
                result = new Viewport.CameraSettingsClass(viewport, cameraDefault.AspectRatio, cameraDefault.FieldOfView, cameraDefault.NearClipPlane, cameraDefault.FarClipPlane, gameMode.FreeCameraPosition, gameMode.FreeCameraDirection.GetVector(), Vector3.ZAxis, ProjectionType.Perspective, 1, cameraDefault.Exposure, cameraDefault.EmissiveFactor);
            }

            return(result);
        }
        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();
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 12
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)
                {
                    //take by a character
                    var character = gameMode.ObjectControlledByPlayer.Value as Component_Character;
                    if (character != null && character.ItemGetEnabledFirst() == null)
                    {
                        character.ItemTake(this);
                        character.ItemActivate(this);
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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 );
                //	}
                //}
            }
        }
Esempio n. 15
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 )
            //	{
            //	}
            //}
        }
        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;
            }
        }
Esempio n. 17
0
 protected virtual void OnInputMessage(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
 {
 }
Esempio n. 18
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");
     }
 }