protected override void Update(GameTime gameTime) { CurrentGameTime = gameTime; InputKeyboard.UpdateState(); InputMouse.UpdateState(); if (InputKeyboard.KeyNowPressed(Keys.I)) { StatusText.DrawStatus = !StatusText.DrawStatus; } if (InputKeyboard.KeyNowPressed(Keys.H)) { StatusText.DrawControls = !StatusText.DrawControls; } StatusText.Update(); ManipulationMenu.Update(); if (Pause) { PausedActions(); } else { RunningActions(); } CamControl.Update(); }
protected bool ReadInput(InputMouse input) { if (!haveControl) { return(false); } input.ReadInput(flickAccumulationFactor, flickThreshold); return(true); }
public void Capture() { CreateInputDevices(); InputKeyboard.Capture(); InputMouse.Capture(); if (InputJoyStick != null) { InputJoyStick.Capture(); } }
/** * Creates a player with the given settings at the given position */ public GameObject CreatePlayer(Vector3 pos, PlayerSettings settings) { // Create the player GameObject player = Instantiate(prefab, pos, Quaternion.identity); PlayerLimbs limbs = player.GetComponent <PlayerLimbs> (); // Setting the player customisation using player limbs GameObject hat = skins.hats [settings.indices.hatIndex]; GameObject playerHat = Instantiate(hat, limbs.head.transform.position, limbs.head.transform.rotation); playerHat.transform.parent = limbs.head.transform; Mesh lance = skins.lances [settings.indices.lanceIndex].GetComponentInChildren <MeshFilter>().sharedMesh; Mesh playerLance = Instantiate(lance); limbs.lance.GetComponent <MeshFilter> ().sharedMesh = playerLance; player.GetComponent <PlayerLimbs> ().character.GetComponent <Renderer> ().material = skins.outfits [settings.indices.outfitIndex]; PlayerInput input = new InputKeyboard(); switch (settings.input) { case InputType.Keyboard: input = new InputKeyboard(); (input as InputKeyboard).RefreshInputs(settings.keyboardID); break; case InputType.Mouse: input = new InputMouse(); break; case InputType.Controller: input = new InputController(); (input as InputController).RefreshInputs(settings.controllerID); break; } // Tell the movement script to add the appropriate input type PlayerMovement m = player.GetComponentInChildren <PlayerMovement>(); m.SetInput(input); m.settings = settings; //CurrentPrefab.GetComponentInChildren<SetMaterial>().setMat(newMat); return(player); }
public static InputBase GetInput() { InputBase oInputImplementation = null; if (Input.touchSupported) { oInputImplementation = new InputPlayerTouch(); } else { oInputImplementation = new InputMouse(); } if (oInputImplementation == null) { Debug.LogError("Input implementation not available!"); } return(oInputImplementation); }
public static InputBase GetInput(InputManager.eInputSource eInputType) { InputBase oInputImplementation = null; switch (eInputType) { case InputManager.eInputSource.PLAYER: if (Input.touchSupported) { oInputImplementation = new InputPlayerTouch(); } else { oInputImplementation = new InputMouse(); } break; case InputManager.eInputSource.AI: Debug.LogWarning("AI input not yet available - Replay fallback"); oInputImplementation = new InputReplay(); break; case InputManager.eInputSource.NETWORK: Debug.LogWarning("AI network not yet available - Replay fallback"); oInputImplementation = new InputReplay(); break; case InputManager.eInputSource.REPLAY: oInputImplementation = new InputReplay(); break; } ; if (oInputImplementation == null) { Debug.LogError("Input implementation not available!"); } return(oInputImplementation); }
public static InputBase GetInput(InputManager.eInputSource eInputType) { InputBase oInputImplementation = null; switch(eInputType) { case InputManager.eInputSource.PLAYER: if(Input.touchSupported) { oInputImplementation = new InputPlayerTouchContinuous(); } else { oInputImplementation = new InputMouse(); } break; case InputManager.eInputSource.AI: Debug.LogWarning("AI input not yet available - Replay fallback"); oInputImplementation = new InputReplay(); break; case InputManager.eInputSource.NETWORK: Debug.LogWarning("AI network not yet available - Replay fallback"); oInputImplementation = new InputReplay(); break; case InputManager.eInputSource.REPLAY: oInputImplementation = new InputReplay(); break; }; if(oInputImplementation == null) { Debug.LogError("Input implementation not available!"); } return oInputImplementation; }
protected override void Initialize() { SpriteBatch = new SpriteBatch(GraphicsDevice); graphics.PreferredBackBufferWidth = ScreenWidth; graphics.PreferredBackBufferHeight = ScreenHeight; #if !DEBUG graphics.IsFullScreen = true; #endif graphics.ApplyChanges(); InputKeyboard.Initialize(); InputMouse.Initialize(); StatusText = new StatusText(this); ManipulationMenu = new ManipulationMenu(this); CamControl = new CameraControl(this); BuilderMenu = new BuildMenu(this); m_universes[0] = new Universe(this, 0); CurrentUniverse = m_universes[0]; base.Initialize(); }
private void Awake() { inputMouse = new InputMouse(); }
private void Handle(DateTime time, RawMouseButtons state, InputMouse data) { IPoint coords = new Point(data.X, data.Y, !data.Flags.HasFlag(RawMouseFlags.MoveAbsolute)); int delta = data.Data.WheelDelta; switch (state) { case RawMouseButtons.None when data.X != 0 || data.Y != 0 || !coords.IsRelative: { IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Movement, coords, delta, MouseButtons.None, KeyState.None, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseMove?.Invoke(this, eventArgs); break; } case RawMouseButtons.LeftDown: { int currentTime = (int)Kernel32.DateTimeToTicks(time); bool isDoubleClick = currentTime - LastLeftClick <= User32.DoubleClickTime; Interlocked.Exchange(ref LastLeftClick, currentTime - (isDoubleClick ? User32.DoubleClickTime + 1 : 0)); IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Key, coords, delta, MouseButtons.Left, KeyState.Down, isDoubleClick, time, false); OnEvent?.Invoke(this, eventArgs); MouseDown?.Invoke(this, eventArgs); MouseClick?.Invoke(this, eventArgs); if (isDoubleClick) { MouseDoubleClick?.Invoke(this, eventArgs); } break; } case RawMouseButtons.MiddleDown: case RawMouseButtons.RightDown: case RawMouseButtons.Button4Down: case RawMouseButtons.Button5Down: { MouseButtons button = state switch { RawMouseButtons.MiddleDown => MouseButtons.Middle, RawMouseButtons.RightDown => MouseButtons.Right, RawMouseButtons.Button4Down => MouseButtons.XButton1, RawMouseButtons.Button5Down => MouseButtons.XButton2, _ => MouseButtons.None }; IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Key, coords, delta, button, KeyState.Down, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseDown?.Invoke(this, eventArgs); MouseClick?.Invoke(this, eventArgs); break; } case RawMouseButtons.LeftUp: case RawMouseButtons.MiddleUp: case RawMouseButtons.RightUp: case RawMouseButtons.Button4Up: case RawMouseButtons.Button5Up: { MouseButtons button = state switch { RawMouseButtons.LeftUp => MouseButtons.Left, RawMouseButtons.MiddleUp => MouseButtons.Middle, RawMouseButtons.RightUp => MouseButtons.Right, RawMouseButtons.Button4Up => MouseButtons.XButton1, RawMouseButtons.Button5Up => MouseButtons.XButton2, _ => MouseButtons.None }; IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Key, coords, delta, button, KeyState.Up, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseUp?.Invoke(this, eventArgs); break; } case RawMouseButtons.Wheel: { IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.Wheel, coords, delta, MouseButtons.Wheel, delta > 0 ? KeyState.Up : KeyState.Down, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseWheel?.Invoke(this, eventArgs); break; } case RawMouseButtons.HWheel: { IMouseEventArgs eventArgs = new MouseEventArgs(MouseEventType.HorizontalWheel, coords, delta, MouseButtons.Wheel, delta > 0 ? KeyState.Up : KeyState.Down, false, time, false); OnEvent?.Invoke(this, eventArgs); MouseHorizontalWheel?.Invoke(this, eventArgs); break; } default: break; } }