public override void Invoke() { Up.Clear(); bool inputexists = false; foreach (var key in Input) { inputexists = true; break; } if (inputexists) { Up.AddRange(Pressed); } else { Up.AddRange(Pressed.Where(k => Input.All(kk => k.KeyCode != kk.KeyCode))); } Down.Clear(); if (Pressed.Count == 0) { Down.AddRange(Input); } else { Down.AddRange(Input.Where(k => Pressed.All(kk => k.KeyCode != kk.KeyCode))); } Pressed.Clear(); Pressed.AddRange(Input); Execute = Enabled && (Up.Count > 0 || Down.Count > 0); base.Invoke(); }
//public void Update() { //if (Main.Ins.GameBattleEx != null && Main.Ins.GameBattleEx.BattleFinished()) // return; //if (CombatData.Ins.Replay && FrameReplay.Instance.Started) { //} else { // if (Main.Ins.LocalPlayer != null) { // if (Main.Ins.LocalPlayer.meteorController.InputLocked) // return; // } // getButtons(); //} //getAxis(); //} public void ProcessKey(KeyState keyState) { Pressed.Clear(); Released.Clear(); Pressing.Clear(); if (keyMapping.ContainsKey(keyState.Key)) { JoyKeyState js = keyMapping[keyState.Key]; bool old = js.PointDown; js.PointDown = Input.GetKey(js.key); if (old && !js.PointDown) { Released.Add(js); } if (!old && js.PointDown) { Pressed.Add(js); } if (old && js.PointDown) { Pressing.Add(js); } //先按下 for (int i = 0; i < Pressed.Count; i++) { if (Pressed[i].OnPress != null) { Pressed[i].OnPress.Invoke(); } } //再蓄力 for (int i = 0; i < Pressing.Count; i++) { if (Pressing[i].OnPressing != null) { Pressing[i].OnPressing.Invoke(); } } //再弹起 for (int i = 0; i < Released.Count; i++) { if (Released[i].OnRelease != null) { Released[i].OnRelease.Invoke(); } } } }