Ejemplo n.º 1
0
 public virtual void KeyUp(GameKey e)
 {
     if (isInstance)
     {
         _currentScreen.KeyReleased(e);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 强制标记放开
 /// </summary>
 /// <param name="key"></param>
 public static void releaseKey(GameKey code)
 {
     if (keyStatus.ContainsKey(code))
     {
         keyStatus.Remove(code);
     }
 }
Ejemplo n.º 3
0
 public virtual void KeyDown(GameKey e)
 {
     if (isInstance)
     {
         _currentScreen.KeyPressed(e);
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
    /// <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;
        }
    }
Ejemplo n.º 6
0
 public virtual void KeyTyped(GameKey e)
 {
     if (isInstance)
     {
         _currentScreen.KeyTyped(e);
     }
 }
Ejemplo n.º 7
0
        protected override void OnSubModuleLoad()
        {
            base.OnSubModuleLoad();

            playerZoomKey = HotKeyManager.GetCategory("CombatHotKeyCategory").RegisteredGameKeys
                            .SingleOrDefault(x => x != null && x.StringId == "Zoom");
        }
Ejemplo n.º 8
0
        public static NetDataWriter GetKeyValue(GameKey value)
        {
            NetDataWriter writer = new NetDataWriter();

            writer.Put((byte)value);
            return(writer);
        }
Ejemplo n.º 9
0
        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"));
        }
Ejemplo n.º 10
0
        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
     });
 }
Ejemplo n.º 12
0
        protected bool OnKeyPressed(GameKey key)
        {
            if (KeyPressed != null)
            {
                return(KeyPressed(key));
            }

            return(false);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 15
0
        /// <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)));
        }
Ejemplo n.º 16
0
        public bool OnKeyPressed(GameKey key)
        {
            // Задание кнопки для игрока (в настройках)
            if (_activePlayerButtonCommand == _setPlayerButton && Settings.UsePlayersKeys == PlayerKeysModes.Keyboard)
            {
                return(ProcessNewPlayerButton(key));
            }

            return(false);
        }
Ejemplo n.º 17
0
        public FreneticKeys this[GameKey gamekey]
        {
            get 
            {
                if (!this.Mapping.ContainsKey(gamekey))
                    this.Mapping.Add(gamekey, new FreneticKeys());

                return this.Mapping[gamekey];
            }
        }
Ejemplo n.º 18
0
        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]);
        }
Ejemplo n.º 19
0
    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());
    }
Ejemplo n.º 20
0
    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());
    }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 26
0
 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;
 }
Ejemplo n.º 27
0
        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;
            }
        }
Ejemplo n.º 28
0
 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();
 }
Ejemplo n.º 29
0
        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());
        }
Ejemplo n.º 30
0
 public bool HandleInput(GameKey key)
 {
     if (!currentScene.HandleInput(key))
     {
         if (currentScene == game)
         {
             currentScene = menu;
             logic.ResetLevel();
         }
         else if (currentScene == menu)
         {
             currentScene = game;
         }
     }
     return(true);
 }
Ejemplo n.º 31
0
        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);
        }
Ejemplo n.º 34
0
 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;
     }
 }
Ejemplo n.º 35
0
        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);
            }
        }
Ejemplo n.º 36
0
 public bool IsKeyUpOnce(GameKey key)
 {
     return keyList[key].IsReleasedOnce;
 }
Ejemplo n.º 37
0
 private Keys TranslateToKeyboard(GameKey key)
 {
     return gameKeyboard[(int)key];
 }
Ejemplo n.º 38
0
 private ControlPad TranslateToControlPad(GameKey key)
 {       
     return gameControlPad[(int)key];
 }
Ejemplo n.º 39
0
 public bool IsKeyDownOnce(GameKey key)
 {
     return keyList[key].IsPressedOnce;
 }
Ejemplo n.º 40
0
 public bool IsKeyDown(GameKey key)
 {
     return keyList[key].IsPressed;
 }
Ejemplo n.º 41
0
 public float GetPressTime(GameKey key)
 {
     return keyList[key].TimeScale;
 }
Ejemplo n.º 42
0
 public int GetKeyMapping(GameKey gameKey)
 {
     return keyMap[(int) gameKey];
 }
Ejemplo n.º 43
0
 /// <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;
 }
Ejemplo n.º 44
0
 /// <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;
 }
Ejemplo n.º 45
0
        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;
            }
        }
Ejemplo n.º 46
0
 public void SetKeyMapping(GameKey gameKey, int value)
 {
     keyMap[(int) gameKey] = value;
 }
Ejemplo n.º 47
0
 /**
  * Global interactions
  * For things like Menu's
  */
 public bool isKeyPressed(GameKey k, PlayerIndex? player)
 {
     return im.isKeyPressed(k, player);
 }
Ejemplo n.º 48
0
 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]);
 }
Ejemplo n.º 49
0
 public bool IsKeyPressed(GameKey key)
 {
     return IsKeyPressedCallback?.Invoke(key) ?? false;
 }
Ejemplo n.º 50
0
 public bool isKeyUp(GameKey k, PlayerIndex? player)
 {
     return im.isKeyUp(k, player);
 }
Ejemplo n.º 51
0
 public abstract bool isKeyUp(GameKey k, PlayerIndex? player);
Ejemplo n.º 52
0
 /// <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));
 }
Ejemplo n.º 53
0
 public virtual void onKeyPress(GameKey gkey)
 {
 }
Ejemplo n.º 54
0
 public abstract bool isKeyPressed(GameKey k, PlayerIndex? player);
Ejemplo n.º 55
0
 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);
     }
 }