public override float GetAxis(ControlAxis axis) { switch(axis){ case ControlAxis.THROW: #if UNITY_ANDROID || UNITY_IPHONE return aimJoystick.IsJustUp() ? 1f : 0f; #else return 0f; #endif case ControlAxis.CAMERA_SCROLL_X: float value = 0f; #if UNITY_ANDROID || UNITY_IPHONE if(windowPad.GetDeltaPositions().Count == 1){ value += windowPad.GetAnyDeltaPositions().x; } if(aimJoystick.joystickAtEdge.x == 1.0f){ value += aimJoystick.position.x * aimJoystickSensitivity.x; } #else value = Input.GetAxis("Mouse X") * mouseSenitivity.x; #endif return value; case ControlAxis.CAMERA_SCROLL_Y: float value2 = 0f; #if UNITY_ANDROID || UNITY_IPHONE if(windowPad.GetDeltaPositions().Count == 1){ value2 += windowPad.GetAnyDeltaPositions().y; } if(aimJoystick.joystickAtEdge.y == 1.0f){ value2 += aimJoystick.position.y * aimJoystickSensitivity.y; } #else value2 = Input.GetAxis("Mouse Y") * mouseSenitivity.y; #endif return value2; case ControlAxis.MOVE_X: #if UNITY_ANDROID || UNITY_IPHONE return movementJoystick.position.x; #else return Input.GetAxisRaw("Horizontal"); #endif case ControlAxis.MOVE_Y: #if UNITY_ANDROID || UNITY_IPHONE return movementJoystick.position.y; #else return Input.GetAxisRaw("Vertical"); #endif case ControlAxis.AIMING: #if UNITY_ANDROID || UNITY_IPHONE return 0f; #else return 0f; #endif case ControlAxis.DEBUG: return Input.GetButtonDown("Fire2")? 1f : 0f; } return 0f; }
float GetInput(ControlAxis axis, IMyCockpit cockpit) { // If you leave the cockpit while pressing a button, // that value stays on. This prevents that. if (!cockpit.IsUnderControl) { return(0); } switch (axis) { case ControlAxis.Forward: return(cockpit.MoveIndicator.Z); case ControlAxis.Roll: return(cockpit.RollIndicator); case ControlAxis.Up: return(cockpit.MoveIndicator.Y); case ControlAxis.Yaw: return(cockpit.RotationIndicator.Y); case ControlAxis.Pitch: return(cockpit.RotationIndicator.X); case ControlAxis.None: return(0f); } return(cockpit.MoveIndicator.X); }
public virtual void Init(ControllerIndex controllerIndex) { ControllerIndex = controllerIndex; foreach (object b in Enum.GetValues(typeof(ControlButtons))) { ControlButtons btn = (ControlButtons)b; ButtonPressedLastFrame.Add(btn, false); ButtonPressed.Add(btn, false); ButtonDown.Add(btn, false); ButtonUp.Add(btn, false); } foreach (object b in Enum.GetValues(typeof(ControlAxis))) { ControlAxis ca = (ControlAxis)b; Axises.Add(ca, 0); } }
public void Load() { _dottedLine = Engine.ContentLoader.GetLoadedTexture("DottedLine"); _camera = new Camera(GraphicsDevice.Viewport.AspectRatio, new Vector3(6f, 6f, 6f), Vector3.Zero); _snapGrid = new SnapGrid(GraphicsDevice, 10); _controlAxis = new ControlAxis(); _spriteBatch = new SpriteBatch(GraphicsDevice); const float scale = 0.13f; Cube cube = new Cube(); for (int i = 0; i < cube.VertexData.Length; i++) { Utils.VerticesOfControlVertex[i] = new VertexPositionColor(cube.VertexData[i].Position * scale, Color.White); } Engine.ActiveControlAxis = _controlAxis; Engine.ActiveCamera = _camera; Engine.SpriteBatch = _spriteBatch; }
private void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); continueEvent = new EventKey("Skip"); quitKey = new EventKey("Cancel"); horizontal = new ControlAxis("Horizontal"); vertical = new ControlAxis("Vertical"); leftAbility = new EventKey("Fire1"); rightAbility = new EventKey("Fire2"); skipTurn = new EventKey("Skip"); }
public virtual float GetAxis(ControlAxis axis) { return 0f; }
float GetInputClamped(ControlAxis axis, IMyCockpit cockpit) { return(MathHelper.Clamp(GetInput(axis, cockpit), -1, 1)); }