private void OnButtonClick(Vector2 tappos, TapState tapState) { var intersect = CheckIntersect(tappos); if (intersect) { if (tapState == TapState.Down) { if (!_active) { _originalColor = _srender.color; _srender.color = ClickColor; if (ButtonSound != null) { ButtonSound.Play(); } } _active = true; } else { OnButtonRelease(); Activate(); _active = false; } } else if (_active) { OnButtonRelease(); } }
public void Construct(GameBalance gameBalance, SignalBus signalBus, TapState tapState, int indexOfLayer) { this.gameBalance = gameBalance; this.indexOfLayer = indexOfLayer; this.signalBus = signalBus; this.tapState = tapState; }
/// <summary> /// Directly inform control of touch down event /// </summary> /// <param name="sender">Object sending the event</param> /// <param name="point">Point on screen touch event is occurring</param> public void SendTouchDown(object sender, point point) { // Exit if needed if (!_enabled || !_visible || _suspended) { return; } bool bHandled = false; // Allow Override TouchDownMessage(sender, point, ref bHandled); // Exit if handled if (bHandled) { return; } // Set down state _mDown = true; // Begin Tap/Hold _ptTapHold = point; _eTapHold = TapState.TapHoldWaiting; _lStop = DateTime.Now.Ticks + (500 * TimeSpan.TicksPerMillisecond); if (_thHold == null || !_thHold.IsAlive) { _thHold = new Thread(TapHoldWaiter); _thHold.Start(); } // Raise Event OnTouchDown(sender, point); }
public void OnTap(Vector2 pos, TapState tapState) { if (tapState != TapState.Tapped) { return; } if (TutSound != null) { TutSound.Play(); } _tutText.CurrentIndex++; _circleIndex++; _handIndex++; _a1Index++; _a2Index++; _a3Index++; if (_handIndex < AnimationQueueH.Length) { Hand.animation.Play(AnimationQueueH[_handIndex]); } if (_a1Index < AnimationQueueA1.Length) { Arrow1.animation.Play(AnimationQueueA1[_a1Index]); } if (_a2Index < AnimationQueueA2.Length) { Arrow2.animation.Play(AnimationQueueA2[_a2Index]); } if (_a3Index < AnimationQueueA2.Length) { Arrow3.animation.Play(AnimationQueueA3[_a3Index]); } if (_circleIndex < AnimationQueueCircle.Length) { Circle.animation.Play(AnimationQueueCircle[_circleIndex]); } if (_tutText.CurrentIndex >= PlayButtonAppearIndex) { PlayGameButton.SetActive(true); } }
public void ChangeTapState() { if (WaterTotalManager.instance.totalWaterUsagePercentage >= 59) { currState = TapState.Flow; } else if (WaterTotalManager.instance.totalWaterUsagePercentage > 4) { currState = TapState.Drip; } else { currState = TapState.Dry; } }
protected virtual void OnTap(Vector2 tappos, TapState tapState) { var handler = Tap; if (handler == null) { return; } //if (tapState == TapState.Tapped) //{ // foreach (var VARIABLE in handler.GetInvocationList()) // { // Debug.Log(VARIABLE.ToString()); // } //} handler(tappos, tapState); }
/// <summary> /// Directly inform control of touch up event /// </summary> /// <param name="sender">Object sending the event</param> /// <param name="point">Point on screen touch event is occurring</param> public void SendTouchUp(object sender, point point) { if (!_enabled || !_visible || _suspended) { _mDown = false; return; } bool bHandled = false; // Check Tap Hold _eTapHold = TapState.Normal; // Allow Override TouchUpMessage(sender, point, ref bHandled); // Exit if handled if (bHandled) { return; } // Perform normal tap if (_mDown) { if (new rect(Left, Top, Width, Height).Contains(point)) { if (DateTime.Now.Ticks - _lastTap < (TimeSpan.TicksPerMillisecond * 500)) { OnDoubleTap(this, new point(point.X - Left, point.Y - Top)); _lastTap = 0; } else { OnTap(this, new point(point.X - Left, point.Y - Top)); _lastTap = DateTime.Now.Ticks; } } _mDown = false; OnTouchUp(this, point); } }
/// <summary> /// Method for detecting Tap & Hold /// </summary> private void TapHoldWaiter() { while (DateTime.Now.Ticks < _lStop) { Thread.Sleep(10); if (_eTapHold == TapState.Normal) { return; } } if (_eTapHold == TapState.Normal || !_enabled || !_visible || _suspended) { return; } //_mDown = false; _eTapHold = TapState.Normal; OnTapHold(this, _ptTapHold); }
/// <summary> /// Directly inform control of touch move event /// </summary> /// <param name="sender">Object sending the event</param> /// <param name="point">Point on screen touch event is occurring</param> public void SendTouchMove(object sender, point point) { if (!_enabled || !_visible || _suspended) { return; } bool bHandled = false; // Allow Override TouchMoveMessage(sender, point, ref bHandled); // Exit if handled if (bHandled) { return; } _eTapHold = TapState.Normal; OnTouchMove(this, point); }
private void UpdateTapState() { tapState = TapState.NONE; if(Input.GetMouseButtonDown(0)){ tapState = TapState.ON_TAP_DOWN; } else if(Input.GetMouseButton(0)){ tapState = TapState.ON_SWIPING; } else if(Input.GetMouseButtonUp(0)){ tapState = TapState.ON_TAP_UP; } }