private void GetKey(RightEvent rightEvent, LeftEvent leftEvent, UpEvent upEvent) { timeVal -= Time.deltaTime; float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); if (h > 0) { if (timeVal <= 0) { timeVal = DELTIME; rightEvent(); } } else if (h < 0) { if (timeVal <= 0) { timeVal = DELTIME; leftEvent(); } } if (v > 0) { if (timeVal <= 0) { timeVal = DELTIME; upEvent(); } } }
public void Initialize(LeftEvent leftEvent, RightEvent rightEvent, UpEvent upEvent, DownEvent downEvent) { Initialize(); this._leftEvent = leftEvent; this._rightEvent = rightEvent; this._upEvent = upEvent; this._downEvent = downEvent; }
private async Task SendUpNotifications() { while (true) { await Task.Delay(_random.Next(3000)); Application.Current.Dispatcher?.Invoke(() => UpEvent?.Invoke(this, EventArgs.Empty)); } }
void UpClick() { IEvent eve = new UpEvent(); SfAddEvent.Instance.Trigger((int)ProtocalID.Move_Main, eve); string str = string.Format("向前 mainID:{0}", eve.Type); Debug.Log(str); }
// Start is called before the first frame update void Start() { Debug.Log("running"); rEvent = new RightEvent(this.NextRoad); lEvent = new LeftEvent(this.LastRoad); uEvent = new UpEvent(this.Act); client = new UnityClient(); if (client.Init("192.168.16.112", 9100) < 0) { Debug.Log("Connect peer failed"); return; } Debug.Log("Init ok"); }
public static IntPtr proc(int nCode, uint wParam, IntPtr lParam) { if (nCode >= 0) { if (wParam == WM_KEYDOWN) { KBDLLHOOKSTRUCT hookStruct = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT)); States[hookStruct.vkCode - 1] = true; if (DownEvent != null) { Delegate[] receivers = DownEvent.GetInvocationList(); foreach (DownEventHandler receiver in receivers) { receiver.BeginInvoke(new DownEventArgs(hookStruct.vkCode), EndDownEvent, null); } } } else if (wParam == WM_KEYUP) { KBDLLHOOKSTRUCT hookStruct = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT)); States[hookStruct.vkCode - 1] = false; if (UpEvent != null) { Delegate[] receivers = UpEvent.GetInvocationList(); foreach (UpEventHandler receiver in receivers) { receiver.BeginInvoke(new UpEventArgs(hookStruct.vkCode), EndUpEvent, null); } } } } return(CallNextHookEx(hook, nCode, wParam, lParam)); }
private void MouseUp() { UpEvent?.Invoke(); }