private void RefreshDebugInfo_ret() { for (int i = 0; i < this.eList.Count; i++) { ControlEvent controlEvent = this.eList[i]; if (controlEvent != null) { if (controlEvent.id == 0) { this.ret1 = controlEvent.ToString(); this.labelRet1.text = this.ret1; } else { this.ret2 = controlEvent.ToString(); this.labelRet2.text = this.ret2; } } } if (this.eList.Count > 0 && this.eList[0] != null) { this.ret = "ret= " + this.eList[0].ToString(); this.labelRet.text = this.ret; } }
/// <summary> /// 添加新事件到事件列表 /// </summary> /// <param name="newEvent"></param> public void AddEvent(ControlEvent newEvent) { if (newEvent != null) { this.rowEventList.Add(newEvent); } }
/// <summary> /// 事件列表排序,取出第一优先事件 /// </summary> /// <returns></returns> private ControlEvent GetFirstPirorityEvent() { this.rowEventList.Sort((ControlEvent x, ControlEvent y) => ControlEvent.CompareTouchEvent(x, y)); if (this.rowEventList.Count > 0) { return(this.rowEventList[0]); } return(null); }
private void TriggerEvent(ControlEvent tEvent) { if (tEvent == null) { return; } TriggerParamTouch triggerParamTouch = new TriggerParamTouch(); triggerParamTouch.EventID = (int)tEvent.type; triggerParamTouch.Trigger = this; triggerParamTouch.Pos = tEvent.position; triggerParamTouch.FingerID = tEvent.id; TriggerManager2.Instance.Trigger2(triggerParamTouch); }
/// <summary> /// 根据优先级获取一个待处理事件 /// </summary> /// <returns></returns> private ControlEvent HandleEvent() { ControlEvent firstPirorityEvent = this.GetFirstPirorityEvent(); if (this.isDebug) { this.tDebug.UpdateList(this.rowEventList); } if (firstPirorityEvent != null && this.IsEventChanged(firstPirorityEvent) && !this.IsTouchUI(firstPirorityEvent.position)) { this.lastTriggerEvent = firstPirorityEvent; return(firstPirorityEvent); } return(null); }
private bool IsEventChanged(ControlEvent cEvent) { bool result = true; if (cEvent == null) { result = false; } else if (this.lastTriggerEvent != null) { if (cEvent.type == EControlType.ePress && this.lastTriggerEvent.type == EControlType.ePress) { if (cEvent.id == this.lastTriggerEvent.id) { if (Mathf.Abs(cEvent.position.x - this.lastTriggerEvent.position.x) < 2f && Mathf.Abs(cEvent.position.y - this.lastTriggerEvent.position.y) < 2f && cEvent.createTimeStamp - this.lastTriggerEvent.createTimeStamp < 0.2f) { result = false; } } } } return(result); }
/// <summary> /// 触摸事件排序对比 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static int CompareTouchEvent(ControlEvent a, ControlEvent b) { if (a == null && b == null) { return(0); } if (a == null) { return(1); } if (b == null) { return(-1); } if (a.type == EControlType.eDown) { if (b.type != EControlType.eDown) { return(-1); } if (a.id > b.id) { return(-1); } return(1); } else if (a.type == EControlType.ePress) { if (b.type == EControlType.eDown) { return(1); } if (b.type == EControlType.ePress) { if (a.touchDownTimeStamp > b.touchDownTimeStamp) { return(-1); } if (a.touchDownTimeStamp < b.touchDownTimeStamp) { return(1); } return(0); } else { if (b.type == EControlType.eUp) { return(-1); } return(-1); } } else if (a.type == EControlType.eUp) { if (b.type == EControlType.eDown) { return(1); } if (b.type == EControlType.ePress) { return(1); } if (b.type != EControlType.eUp) { return(0); } if (a.id > b.id) { return(-1); } return(1); } else { if (b.type == EControlType.eNull) { return(0); } return(1); } }