public bool OnKeyDown(KeyState k) { if (KeyInput.Length <= state || state < 0) { return(false); } if (k.Key == KeyInput[state]) { Pressing = EKeyList.KL_None; state++; if (state == totalState) { int target = -1; if (Check(out target)) { mOwner.ActionMgr.LinkAction(target); return(true); } else { Reset(); } } else { frame = Main.Ins.AppInfo.LinkDelay(); } } return(false); }
public void Register(EKeyList ek, KeyCode k) { GameStateMgr.Ins.gameStatus.UseGamePad = true; List <EKeyList> Keys = new List <EKeyList>(); foreach (var each in GameStateMgr.Ins.gameStatus.KeyMapping) { Keys.Add(each.Key); } for (int i = 0; i < Keys.Count; i++) { if (GameStateMgr.Ins.gameStatus.KeyMapping[Keys[i]] == k) { GameStateMgr.Ins.gameStatus.KeyMapping[Keys[i]] = KeyCode.None; } } GameStateMgr.Ins.gameStatus.KeyMapping[ek] = k; if (!enabled) { enabled = true;//触发onenable } else { Sync();//主动同步. } }
public void ReceiveInput(EKeyList key) { if (HasInput()) { UnityEngine.Debug.Log("error"); InputKeys.Add(new AIVirtualInput(key)); } }
public void RemovePressing(EKeyList key) { for (int i = 0; i < inputs.Count; i++) { if (inputs[i].Pressing == key) { inputs[i].Reset(); } } }
void RegisterInternal(EKeyList ek, KeyCode k) { if (keyMapping.ContainsKey(ek)) { keyMapping[ek].key = k; } else { keyMapping.Add(ek, new JoyKeyState(k)); } }
public void OnKeyPressing(KeyState k) { if (state == 0) { if (k.Key == KeyInput[state]) { state++; Pressing = k.Key;//等待蓄力招式后续输入 frame = Main.Ins.AppInfo.LinkDelay(); } } }
//闪亮显示一个要设置的按键.当按下任意一个按键时,与对应的动作绑定. public void FlashButton(Button btn, EKeyList vkey, string format) { if (flashing) { KillFade(); } flashButton = btn; formatString = format; flashKey = vkey; flashing = true; initializeColor = flashButton.GetComponent <Image>().color; MyPingPong(flashButton.GetComponent <Image>(), initializeColor, Color.white, 0.5f); }
//-------------------------------------------------------------------------------------- bool checkInputType(EKeyList inpuKey, EInputType inputType, float deltaTime) { int pressed = KeyStates[(int)inpuKey].Pressed; float pressedTime = KeyStates[(int)inpuKey].PressedTime; float releasedTime = KeyStates[(int)inpuKey].ReleasedTime; bool ret = false; switch (inputType) { case EInputType.EIT_Click: ret = (pressedTime == 0); break; case EInputType.EIT_DoubleClick: ret = (pressed == 2 && pressedTime == 0); break; case EInputType.EIT_Press: ret = (pressed != 0 && (pressedTime < LongPressedTime && pressedTime + deltaTime >= LongPressedTime)); break; case EInputType.EIT_Release: ret = (pressed == 0 && releasedTime == 0); break; case EInputType.EIT_Pressing: ret = (pressed != 0); break; case EInputType.EIT_Releasing: ret = (pressed == 0); break; } return(ret); }
public void PushKeyEvent(MeteorMsg.Command command, int playerId, EKeyList key) { //GameFrames t = GetFrame(FrameReplay.Instance.NextTurn); //for (int i = 0; i < t.commands.Count; i++) //{ // if ((t.commands[i].command == MeteorMsg.Command.KeyDown || // t.commands[i].command == MeteorMsg.Command.KeyUp || // t.commands[i].command == MeteorMsg.Command.KeyLast) && // playerId == t.commands[i].playerId && // t.commands[i].LogicFrame == (uint)FrameReplay.Instance.LogicFrameIndex && // (uint)key == (uint)t.commands[i].data[0]) // { // //Debug.LogError("同一帧同一个按键无法响应2次???"); // return; // } //} //FrameCommand cmd = new FrameCommand(); //cmd.command = command; //cmd.LogicFrame = (uint)FrameReplay.Instance.LogicFrameIndex; //cmd.playerId = (uint)playerId; //cmd.data = new byte[1]; //cmd.data[0] = (byte)key; //t.commands.Add(cmd); }
public void OnKeyUp(EKeyList key) { OnKeyUp(KeyStates[(int)key]); }
public void OnKeyDown(EKeyList key) { OnKeyDown(KeyStates[(int)key]); }
public void Reset() { state = 0; frame = Main.Ins.AppInfo.LinkDelay(); Pressing = EKeyList.KL_None; }
public void PushKeyDown(int playerId, EKeyList key) { PushKeyEvent(MeteorMsg.Command.KeyDown, playerId, key); }