public virtual void KeyUp(GameKey e) { if (isInstance) { _currentScreen.KeyReleased(e); } }
/// <summary> /// 强制标记放开 /// </summary> /// <param name="key"></param> public static void releaseKey(GameKey code) { if (keyStatus.ContainsKey(code)) { keyStatus.Remove(code); } }
public virtual void KeyDown(GameKey e) { if (isInstance) { _currentScreen.KeyPressed(e); } }
private bool IsKeyPressed(GameKey gameKey) { if (!_gameWindow.Focused) { return(false); } switch (gameKey) { case GameKey.Jump: return(_keyboardState.IsKeyDown(OpenTK.Input.Key.Space)); case GameKey.Forwards: return(_keyboardState.IsKeyDown(OpenTK.Input.Key.W)); case GameKey.Left: return(_keyboardState.IsKeyDown(OpenTK.Input.Key.A)); case GameKey.Backwards: return(_keyboardState.IsKeyDown(OpenTK.Input.Key.S)); case GameKey.Right: return(_keyboardState.IsKeyDown(OpenTK.Input.Key.D)); case GameKey.Primary: return(_mouseState.LeftButton == ButtonState.Pressed); case GameKey.Secondary: return(_mouseState.RightButton == ButtonState.Pressed); default: return(false); } }
/// <summary> /// 输入命令监听 /// </summary> /// <param name="data"></param> private void CommandListener(EventData data) { int playerId = (int)data.Param; if (playerId != GetPlayerId()) { return; //不是本玩家的指令 } GameKey key = (GameKey)data.Param2; switch (key) { case GameKey.Attack: Attack(); break; case GameKey.Jump: Jump(); break; default: Move(key); break; } }
public virtual void KeyTyped(GameKey e) { if (isInstance) { _currentScreen.KeyTyped(e); } }
protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); playerZoomKey = HotKeyManager.GetCategory("CombatHotKeyCategory").RegisteredGameKeys .SingleOrDefault(x => x != null && x.StringId == "Zoom"); }
public static NetDataWriter GetKeyValue(GameKey value) { NetDataWriter writer = new NetDataWriter(); writer.Put((byte)value); return(writer); }
public async Task <IActionResult> AddKey(GameKey gameKey, IFormFile uploadFile) { if (uploadFile == null) { return(RedirectToAction("Index")); } //Uploading the file to the server string path = uploadFile.FileName; using (var fs = new FileStream(_appEnvironment.WebRootPath + path, FileMode.Create)) { await uploadFile.CopyToAsync(fs); fs.Close(); } using (var fs = new StreamReader(_appEnvironment.WebRootPath + path)) { var game = _db.Games.FirstOrDefault(item => item.Id == gameKey.GameId); if (game == null) { return(NotFound()); } while (true) { string s = await fs.ReadLineAsync(); if (s == null) { break; } //Creating the model var gk = new GameKey() { Game = game, KeyToGame = s, }; await _db.GameKeys.AddAsync(gk); await _db.SaveChangesAsync(); } fs.Close(); } //Check for the presence of a file, if there is one, delete it FileInfo fi = new FileInfo(_appEnvironment.WebRootPath + path); if (fi.Exists) { fi.Delete(); } return(RedirectToAction("Index")); }
public Statistics(GameKey gameKey) { InitializeComponent(); this.gameKey = gameKey; this.updateUi(); this.setupKeyboardShortcuts(); }
public static SerializedGameKey FromGameKey(GameKey gameKey) { return(new SerializedGameKey { StringId = gameKey.StringId, Key = gameKey.KeyboardKey.InputKey }); }
protected bool OnKeyPressed(GameKey key) { if (KeyPressed != null) { return(KeyPressed(key)); } return(false); }
public void AddGameKey(GameKey gameKey) { if (gameKey.Id < 0 || gameKey.Id >= GameKeys.Count) { return; } GameKeys[gameKey.Id] = gameKey; }
public async Task <MetaData> GetMetaData(GameKey gameKey, string id) { if (!await CheckLookup(gameKey)) { return(null); } return(_replayLookup[gameKey].MetaData); }
/// <summary> /// checks whether specified key has been pressed. /// </summary> /// <param name="key">game key in the game</param> /// <returns></returns> public bool IsPressKey(GameKey key) { if (input.IsConnectedControlPad && input.IsPressControlPad(TranslateToControlPad(key))) { return(true); } return(input.IsPressKey(TranslateToKeyboard(key))); }
public bool OnKeyPressed(GameKey key) { // Задание кнопки для игрока (в настройках) if (_activePlayerButtonCommand == _setPlayerButton && Settings.UsePlayersKeys == PlayerKeysModes.Keyboard) { return(ProcessNewPlayerButton(key)); } return(false); }
public FreneticKeys this[GameKey gamekey] { get { if (!this.Mapping.ContainsKey(gamekey)) this.Mapping.Add(gamekey, new FreneticKeys()); return this.Mapping[gamekey]; } }
static public GameData getGame(GameKey key) { if (!Data.DATA.data.ContainsKey(key)) { Data.DATA.data[key] = new GameData { bestTime = 0, totalWins = 0 }; } return(Data.DATA.data[key]); }
private void ReleaseKey(GameKey gameKey) { Logger.LogTrace($"Released key {gameKey}", Category.UserInput); foreach (var key in gameKey.Keys) { pressedKeys.Remove(key); justReleased.Add(key); } StartCoroutine(ClearReleased()); }
private void PressKey(GameKey gameKey) { Logger.LogTrace("Pressed key " + gameKey, Category.UI); foreach (var key in gameKey.Keys) { pressedKeys.Add(key); justPressed.Add(key); } StartCoroutine(ClearPressed()); }
public IEnumerable <ILogicalComponent> ReadComponents(ComponentsFolder componentsFolder) { var installerContent = ReadInstallerContent(); var components = new List <ILogicalComponent>(); foreach (var coreComponent in installerContent.CoreComponents) { if (coreComponent.Name == Folders.PackagesFolder.WellKnownName) { components.Add(_componentsFactory.CreatePackagesComponent(componentsFolder.Packages, new MemoryBasedComponentUniqueID(coreComponent.ComponentUniqueId))); } else { components.Add(_componentsFactory.CreateCoreComponent(componentsFolder.Core.CoreComponent(coreComponent.Name), new MemoryBasedComponentUniqueID(coreComponent.ComponentUniqueId))); } } foreach (var gameEngine in installerContent.GameEngines) { components.Add(_componentsFactory.CreateGameEngineComponent(componentsFolder.EnginesAndGames.GameEngine(gameEngine.Name).Engine, new MemoryBasedComponentUniqueID(gameEngine.ComponentUniqueId))); } var gameLimits = installerContent.GamesLimits.ToDictionary(item => new GameKey(new GameEngineName(item.EngineName), item.Name)); foreach (var gameMath in installerContent.GamesMaths) { var gameKey = new GameKey(new GameEngineName(gameMath.EngineName), gameMath.Name); var mathUniqueId = new MemoryBasedComponentUniqueID(gameMath.ComponentUniqueId); var limitsUniqueId = new MemoryBasedComponentUniqueID(); if (gameLimits.ContainsKey(gameKey)) { limitsUniqueId = new MemoryBasedComponentUniqueID(gameLimits[gameKey].ComponentUniqueId); } components.Add(_componentsFactory.CreateGameComponent(componentsFolder.EnginesAndGames .GameEngine(gameMath.EngineName) .Games .Game(gameMath.Name), mathUniqueId, limitsUniqueId)); } return(components); }
public bool HandleInput(GameKey key) { switch (key) { case GameKey.Right: ++logic.LevelNr; break; case GameKey.Left: --logic.LevelNr; break; case GameKey.Accept: return(false); } ; return(true); }
private async Task <bool> CheckLookup(GameKey gameKey) { if (!_replayLookup.ContainsKey(gameKey)) { await UpdateLookup(); if (!_replayLookup.ContainsKey(gameKey)) { return(false); } } return(true); }
private bool ProcessNewPlayerButton(GameKey key) { if (!PlatformManager.Instance.IsEscapeKey(key) && !Settings.PlayerKeys2.Contains(key)) { Settings.PlayerKeys2.Add(key); UpdateCanAddPlayerButton(); ActivePlayerButtonCommand = _addPlayerButton; return(true); } ActivePlayerButtonCommand = _addPlayerButton; return(false); }
public async Task <byte[]> GetKeyFrame(GameKey gameKey, int id) { if (!await CheckLookup(gameKey)) { return(null); } if (!_replayCache.ContainsKey(gameKey)) { await CacheReplay(_replayLookup[gameKey].Uri); } return(_replayCache[gameKey].Replay.KeyFrames.Find(x => x.id == id).data); }
public bool IsGameKeyDown(GameKey gamekey) { var mapping = this.KeyMapping[gamekey]; foreach (var keyboardKey in mapping.Keyboard) { if (this.Keyboard.IsKeyDown(keyboardKey)) return true; } foreach (var mouseKey in mapping.Mouse) { if (this.Mouse.IsKeyDown(mouseKey)) return true; } return false; }
private void ControlMove(GameKey key) { switch (key) { case GameKey.Left: head.Vector = head.Vector == Vector.Right ? Vector.Right : Vector.Left; break; case GameKey.Right: head.Vector = head.Vector == Vector.Left ? Vector.Left : Vector.Right; break; case GameKey.Up: head.Vector = head.Vector == Vector.Down ? Vector.Down : Vector.Up; break; case GameKey.Down: head.Vector = head.Vector == Vector.Up ? Vector.Up : Vector.Down; break; default: break; } }
public TouchInput() : base(GameRoot.Instance) { camManager = CamManager.Instance; PressedKeys = new GameKey[1]; switch (Device.Instance.DeviceType) { case DType.Android: case DType.IOS: case DType.Win10_Phone: IsConnected = true; Game.Components.Add(this); break; } ClearInput(); }
public override byte[] Build() { MemoryStream ms = new MemoryStream(Size); Writer writer = new Writer(ms); writer.Write(Id); writer.WriteString(Login, Encoding.Unicode); writer.Write(GameKey.Skip(4).ToArray()); writer.Write(LoginKey.Take(4).ToArray()); writer.Write(GameKey.Take(4).ToArray()); writer.Write(LoginKey.Skip(4).ToArray()); writer.Write((Int32)1); return(ms.GetBuffer()); }
public bool HandleInput(GameKey key) { if (!currentScene.HandleInput(key)) { if (currentScene == game) { currentScene = menu; logic.ResetLevel(); } else if (currentScene == menu) { currentScene = game; } } return(true); }
public override int GetKeyNumber(GameKey key) { var key2 = (Key)key; int code = -1; if (key2 >= Key.D1 && key2 <= Key.D9) { code = key2 - Key.D1; } else if (key2 >= Key.NumPad1 && key2 <= Key.NumPad9) { code = key2 - Key.NumPad1; } return(code); }
public Keys getKeyForAction(GameKey k, PlayerIndex? player) { if (k == GameKey.BACK) return Keys.Escape; if (k == GameKey.SELECT) return Keys.Enter; if (k == GameKey.UP) { if (player.HasValue && player == PlayerIndex.One) return Keys.W; if (player.HasValue && player == PlayerIndex.Two) return Keys.Up; if (player.HasValue && player == PlayerIndex.Three) return Keys.NumPad8; if (player.HasValue && player == PlayerIndex.Four) return Keys.I; return Keys.W; } if (k == GameKey.DOWN) { if (player.HasValue && player == PlayerIndex.One) return Keys.S; if (player.HasValue && player == PlayerIndex.Two) return Keys.Down; if (player.HasValue && player == PlayerIndex.Three) return Keys.NumPad5; if (player.HasValue && player == PlayerIndex.Four) return Keys.K; return Keys.S; } if (k == GameKey.LEFT) { if (player.HasValue && player == PlayerIndex.One) return Keys.A; if (player.HasValue && player == PlayerIndex.Two) return Keys.Left; if (player.HasValue && player == PlayerIndex.Three) return Keys.NumPad4; if (player.HasValue && player == PlayerIndex.Four) return Keys.J; return Keys.A; } if (k == GameKey.RIGHT) { if (player.HasValue && player == PlayerIndex.One) return Keys.D; if (player.HasValue && player == PlayerIndex.Two) return Keys.Right; if (player.HasValue && player == PlayerIndex.Three) return Keys.NumPad4; if (player.HasValue && player == PlayerIndex.Four) return Keys.L; return Keys.D; } if (k == GameKey.FIRE) { if (player.HasValue && player == PlayerIndex.One) return Keys.Space; if (player.HasValue && player == PlayerIndex.Two) return Keys.RightControl; if (player.HasValue && player == PlayerIndex.Three) return Keys.Enter; if (player.HasValue && player == PlayerIndex.Four) return Keys.OemSemicolon; return Keys.Space; } return Keys.F16; }
public async Task <LastChunkInfo> GetLastChunkInfo(GameKey gameKey, int id, IPAddress ip) { var session = new Session() { IP = ip, GameKey = gameKey }; if (!await CheckLookup(gameKey)) { return(null); } if (!_replayCache.ContainsKey(gameKey)) { await CacheReplay(_replayLookup[gameKey].Uri); } if (!_chunkInfos.ContainsKey(session)) { _chunkInfos.Add(session, new LastChunkInfo() { ChunkId = 1, AvailableSince = 30000, NextAvailableChunk = 100, KeyFrameId = 1, NextChunkId = 1, EndStartupChunkId = _replayCache[gameKey].Replay.EndStartupChunkId, StartGameChunkId = _replayCache[gameKey].Replay.StartGameChunkId, EndGameChunkId = _replayCache[gameKey].Replay.EndGameChunkId, Duration = 30000 }); } else { _chunkInfos[session].Update(_replayCache[gameKey].Replay.EndGameChunkId, _replayCache[gameKey].Replay.KeyFrames.Count); } var chunkInfo = _chunkInfos[session]; if (chunkInfo.EndGameChunkId == chunkInfo.ChunkId) { _chunkInfos.Remove(session); } return(chunkInfo); }
public Buttons getButtonForAction(GameKey k) { switch (k) { case GameKey.BACK: return Buttons.B; case GameKey.SELECT: return Buttons.A; case GameKey.FIRE: return Buttons.RightTrigger; case GameKey.UP: return Buttons.DPadUp; case GameKey.DOWN: return Buttons.DPadDown; case GameKey.LEFT: return Buttons.DPadLeft; case GameKey.RIGHT: return Buttons.DPadRight; default: return Buttons.BigButton; } }
public override bool isKeyDown(GameKey k, PlayerIndex? player) { Buttons bb = getButtonForAction(k); if (player.HasValue) { if(LastGamepadStates[(int)(player.Value)].IsButtonUp(bb) && CurrentGamepadStates[(int)(player.Value)].IsButtonDown(bb)) { return true; } else { bool l = getAxisForAction(LastGamepadStates[(int)(player.Value)], bb); bool c = getAxisForAction(CurrentGamepadStates[(int)(player.Value)], bb); return ((!l) && c); } } else { return isKeyDown(k, PlayerIndex.One) || isKeyDown(k, PlayerIndex.Two); } }
public bool IsKeyUpOnce(GameKey key) { return keyList[key].IsReleasedOnce; }
private Keys TranslateToKeyboard(GameKey key) { return gameKeyboard[(int)key]; }
private ControlPad TranslateToControlPad(GameKey key) { return gameControlPad[(int)key]; }
public bool IsKeyDownOnce(GameKey key) { return keyList[key].IsPressedOnce; }
public bool IsKeyDown(GameKey key) { return keyList[key].IsPressed; }
public float GetPressTime(GameKey key) { return keyList[key].TimeScale; }
public int GetKeyMapping(GameKey gameKey) { return keyMap[(int) gameKey]; }
/// <summary> /// configures the keyboard setting. /// </summary> /// <param name="gameKey">game key in the game</param> /// <param name="setKey">a key of keyboard</param> public void SetGameKey(GameKey gameKey, Keys setKey) { gameKeyboard[(int)gameKey] = setKey; }
/// <summary> /// configures the Xbox 360 controller setting. /// </summary> /// <param name="gameKey">game key in the game</param> /// <param name="setKey">a key of Xbox 360 controller</param> public void SetGameControlPad(GameKey gameKey, ControlPad setKey) { gameControlPad[(int)gameKey] = setKey; }
private bool IsKeyPressed(GameKey gameKey) { if (!_gameWindow.Focused) return false; switch (gameKey) { case GameKey.Jump: return _keyboardState.IsKeyDown(OpenTK.Input.Key.Space); case GameKey.Forwards: return _keyboardState.IsKeyDown(OpenTK.Input.Key.W); case GameKey.Left: return _keyboardState.IsKeyDown(OpenTK.Input.Key.A); case GameKey.Backwards: return _keyboardState.IsKeyDown(OpenTK.Input.Key.S); case GameKey.Right: return _keyboardState.IsKeyDown(OpenTK.Input.Key.D); case GameKey.Primary: return _mouseState.LeftButton == ButtonState.Pressed; case GameKey.Secondary: return _mouseState.RightButton == ButtonState.Pressed; default: return false; } }
public void SetKeyMapping(GameKey gameKey, int value) { keyMap[(int) gameKey] = value; }
/** * Global interactions * For things like Menu's */ public bool isKeyPressed(GameKey k, PlayerIndex? player) { return im.isKeyPressed(k, player); }
public bool KeyReleased(GameKey key) { if (this.curKeyState == 0) { return (!this.keyStates[keyMap[(int) key], 0] && this.keyStates[keyMap[(int) key], 1]); } return (!this.keyStates[keyMap[(int) key], 1] && this.keyStates[keyMap[(int) key], 0]); }
public bool IsKeyPressed(GameKey key) { return IsKeyPressedCallback?.Invoke(key) ?? false; }
public bool isKeyUp(GameKey k, PlayerIndex? player) { return im.isKeyUp(k, player); }
public abstract bool isKeyUp(GameKey k, PlayerIndex? player);
/// <summary> /// checks whether specified key has been pressed. /// </summary> /// <param name="key">game key in the game</param> /// <returns></returns> public bool IsPressKey(GameKey key) { if (input.IsConnectedControlPad && input.IsPressControlPad(TranslateToControlPad(key))) { return true; } return input.IsPressKey(TranslateToKeyboard(key)); }
public virtual void onKeyPress(GameKey gkey) { }
public abstract bool isKeyPressed(GameKey k, PlayerIndex? player);
public bool KeyUp(GameKey key) { return !this.keyStates[keyMap[(int) key], this.curKeyState]; }
public override bool isKeyDown(GameKey k, PlayerIndex? player) { if (player.HasValue) { Keys kk = getKeyForAction(k, player); return (CurrentKeyboardState.IsKeyDown(kk) && LastKeyboardState.IsKeyUp(kk)); } else { return isKeyDown(k, PlayerIndex.One) || isKeyDown(k, PlayerIndex.Two); } }