protected override Vector2 _Invoke(Vector2 input) { var v = base._Invoke(input); value.Invoke(v); return(v); }
private void LateUpdate() { // Add the current position of the transform to offset the destination in world space. currentDestination = (currentDestination.normalized * 15) + (Vector2)transform.position; OnSafePointCalculated.Invoke(currentDestination); currentDestination = Vector2.zero; }
void OnUp() { float difT = endTime - startTime; Vector2 difP = endPos - startPos; float ratio = .01f * difP.magnitude / difT; if (ratio > 3) { OnSwipe.Invoke(difP); if (Mathf.Abs(difP.x) > Mathf.Abs(difP.y)) { OnSwipeHorizontal.Invoke(difP.x); if (difP.x < 0) { OnSwipeLeft.Invoke(); } else { OnSwipeRight.Invoke(); } } } //print( difT ); //print( difP ); //print( ratio ); }
public virtual void OnJoystickChange(Vector2 joystickVector) { if (onJoystickVectorChange != null) { onJoystickVectorChange.Invoke(joystickVector); } }
protected virtual void Update() { // Get fingers var fingers = Use.GetFingers(); if (fingers.Count > 0) { var screenFrom = LeanGesture.GetStartScreenCenter(fingers); var screenTo = LeanGesture.GetScreenCenter(fingers); var finalDelta = screenTo - screenFrom; var timeScale = 1.0f; if (ScaleByTime == true) { timeScale = Time.deltaTime; } switch (Coordinate) { case CoordinateType.ScaledPixels: finalDelta *= LeanTouch.ScalingFactor; break; case CoordinateType.ScreenPercentage: finalDelta *= LeanTouch.ScreenFactor; break; } finalDelta *= Multiplier; if (onVector != null) { onVector.Invoke(finalDelta * timeScale); } if (onDistance != null) { onDistance.Invoke(finalDelta.magnitude * timeScale); } var worldFrom = ScreenDepth.Convert(screenFrom, gameObject); var worldTo = ScreenDepth.Convert(screenTo, gameObject); if (onWorldFrom != null) { onWorldFrom.Invoke(worldFrom); } if (onWorldTo != null) { onWorldTo.Invoke(worldTo); } if (onWorldDelta != null) { onWorldDelta.Invoke((worldTo - worldFrom) * timeScale); } if (onWorldFromTo != null) { onWorldFromTo.Invoke(worldFrom, worldTo); } } }
protected virtual void Update() { // Get fingers var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable); if (fingers.Count > 0) { // Get delta var delta = LeanGesture.GetScreenDelta(fingers); // Ignore? if (delta.sqrMagnitude == 0.0f) { return; } // Scale? if (DeltaCoordinates == DeltaCoordinatesType.Scaled) { delta *= LeanTouch.ScalingFactor; } // Call events if (OnSetCenter != null) { OnSetCenter.Invoke(LeanGesture.GetScreenCenter(fingers)); } if (OnSetDelta != null) { OnSetDelta.Invoke(delta); } } }
protected virtual void UpdateFingers(List <LeanFinger> fingers) { if (fingers.Count > 0) { // Get delta var delta = LeanGesture.GetScreenDelta(fingers); // Ignore? if (delta.sqrMagnitude == 0.0f) { return; } // Scale? if (DeltaCoordinates == DeltaCoordinatesType.Scaled) { delta *= LeanTouch.ScalingFactor; } // Call events if (OnSetCenter != null) { OnSetCenter.Invoke(LeanGesture.GetScreenCenter(fingers)); } if (OnSetDelta != null) { OnSetDelta.Invoke(delta); } } }
protected virtual void HandleFingerDown(LeanFinger finger) { if (IgnoreStartedOverGui == true && finger.IsOverGui == true) { return; } if (RequiredSelectable != null && RequiredSelectable.IsSelected == false) { return; } if (onFinger != null) { onFinger.Invoke(finger); } if (onWorld != null) { var position = ScreenDepth.Convert(finger.StartScreenPosition, gameObject); onWorld.Invoke(position); } if (onScreen != null) { onScreen.Invoke(finger.ScreenPosition); } }
private void HandleFingerOld(LeanFinger finger) { // Ignore? if (ignoreStartedOverGui == true && finger.StartedOverGui == true) { return; } if (ignoreIsOverGui == true && finger.IsOverGui == true) { return; } if (requiredSelectable != null && requiredSelectable.IsSelected == false) { return; } if (onFinger != null) { onFinger.Invoke(finger); } if (onWorld != null) { var position = ScreenDepth.Convert(finger.ScreenPosition, gameObject); onWorld.Invoke(position); } if (onScreen != null) { onScreen.Invoke(finger.ScreenPosition); } }
private void Submit(Vector3 value) { if (onValueX != null) { onValueX.Invoke(value.x); } if (onValueY != null) { onValueY.Invoke(value.y); } if (onValueZ != null) { onValueZ.Invoke(value.z); } if (onValueXY != null) { onValueXY.Invoke(value); } if (onValueXYZ != null) { onValueXYZ.Invoke(value); } }
private void HandleFingerUp(LeanFinger finger) { if (fingers.Remove(finger) == true) { if (fingers.Count + 1 == RequiredCount) { if (onFingers != null) { onFingers.Invoke(fingers); } var screenPosition = LeanGesture.GetScreenCenter(fingers); if (onWorld != null) { var worldPosition = ScreenDepth.Convert(screenPosition, gameObject); onWorld.Invoke(worldPosition); } if (onScreen != null) { onScreen.Invoke(screenPosition); } } } }
void Update() { angle += circleSpeed * Time.deltaTime; if (player != null) { playerPosition = player.transform.position; } var pos = transform.position; var activeRadius = radius; var overlaps = new List <Collider2D>(); var contactFilter = new ContactFilter2D(); contactFilter.layerMask = floorLayers; contactFilter.useLayerMask = true; contactFilter.useTriggers = true; var limit = 100; do { overlaps.Clear(); pos = playerPosition + (Quaternion.Euler(0, 0, angle) * Vector2.right).xy() * activeRadius; activeRadius *= .95f; limit -= 1; } while (Physics2D.OverlapPoint(pos, contactFilter, overlaps) == 0 && limit != 0); trackPos.Invoke(pos); }
private void Start() { tilePositions = GetPositionsFromTexture(noiseMap); GenerateMesh(tilePositions); onTileSize?.Invoke(new Vector2(tileXSize, tileYSize)); onBoardCompletion?.Invoke(tilePositions); }
private void FixedUpdate() { move?.Invoke(moveVector.normalized); if (actBool) { act?.Invoke(); } }
void Update() { if (player != null) { playerPosition = player.transform.position; } playerPos.Invoke(playerPosition); }
///// Visuals private void UpdateVisuals() { _onMovementChange.Invoke(_rb.velocity); //if (_changedDirection) _onFacingRightChange.Invoke(_isRight); _onDashChange.Invoke(_isDashing); _onGroundedChange.Invoke(grounded); _onJumpingChange.Invoke(_isJumping); _onAirDashChange.Invoke(_aerialDash); _onClingChange.Invoke(_isClinging); }
//public Vector2 debugOutput; public void ClampNegativeYtoX(Vector2 input) { if (input.y < 0) { input.x = input.x < 0 ? -1 : 1; input.y = 0; } //debugOutput = input; OnOutput.Invoke(input); }
public void OnPointerClick(PointerEventData eventData) { if (eventData.button == PointerEventData.InputButton.Left) { onLeftClick?.Invoke(eventData.position); } else if (eventData.button == PointerEventData.InputButton.Right) { onRightClick?.Invoke(eventData.position); } }
// Update is called once per frame void Update() { foreach (var touch in Input.touches) { if (touch.phase == TouchPhase.Began) { _startPosition = touch.position; if (View) { View.Show(); } } if (touch.phase == TouchPhase.Moved) { _endPosition = _endPosition + touch.deltaPosition; Vector2 value = GetAxisValue(_endPosition); OnChange.Invoke(value); _didMove = true; if (View) { View.MoveButtonImage(_startPosition, value, _maxDistance); } } if (touch.phase == TouchPhase.Ended) { if (_didMove) { _didMove = false; // call function _startPosition = Vector2.zero; _endPosition = Vector2.zero; OnChange.Invoke(Vector2.zero); if (View) { View.MoveButtonImage(Vector2.zero, Vector2.zero, _maxDistance); View.Hide(); } } } } }
void Update() { switch (_dataType) { case DataType.None: while (_bangCount > 0) { _event.Invoke(); _bangCount--; } break; case DataType.Int: while (_intQueue.Count > 0) _intEvent.Invoke(DequeueInt()); break; case DataType.Float: while (_floatQueue.Count > 0) _floatEvent.Invoke(DequeueFloat()); break; case DataType.String: while (_stringQueue.Count > 0) _stringEvent.Invoke(DequeueString()); break; case DataType.Vector2: while (_floatQueue.Count > 0) _vector2Event.Invoke(DequeueVector2()); break; case DataType.Vector3: while (_floatQueue.Count > 0) _vector3Event.Invoke(DequeueVector3()); break; case DataType.Vector4: while (_floatQueue.Count > 0) _vector4Event.Invoke(DequeueVector4()); break; case DataType.Vector2Int: while (_intQueue.Count > 0) _vector2IntEvent.Invoke(DequeueVector2Int()); break; case DataType.Vector3Int: while (_intQueue.Count > 0) _vector3IntEvent.Invoke(DequeueVector3Int()); break; } }
public void FadeOut() { if (spellTimer + spellFirerate < Time.time && attackJoystick) { spellTimer = Time.time; i = 0f; spellCooldownFill = 1; spellCooldown.GetComponent <Image>().fillAmount = spellCooldownFill; playerControl.anim.SetBool("castSpell", true); weaponFired.Invoke(this.direction); } this.targetAlpha = 0.0f; }
protected virtual void Update() { var delta = Current - Previous; if (Threshold > 0.0f) { var stepX = (int)(delta.x / Threshold); var stepY = (int)(delta.y / Threshold); var stepZ = (int)(delta.z / Threshold); if (stepX == 0 && stepY == 0 && stepZ == 0) { return; } if (Step == true) { Previous.x -= stepX * Threshold; Previous.y -= stepY * Threshold; Previous.z -= stepZ * Threshold; } else { Previous = Current; } } else { if (delta.x == 0.0f && delta.y == 0.0f && delta.z == 0.0f) { return; } Previous = Current; } if (onPositionX != null) { onPositionX.Invoke(Previous.x); } if (onPositionXY != null) { onPositionXY.Invoke(Previous); } if (onPositionXYZ != null) { onPositionXYZ.Invoke(Previous); } }
void Update() { if (PupilGazeTracker.Exists) { _eyePos = PupilGazeTracker.Instance.EyePos; Position.Invoke(_eyePos); _leftEyePos = PupilGazeTracker.Instance.LeftEyePos; LeftPosition.Invoke(_leftEyePos); _rightEyePos = PupilGazeTracker.Instance.RightEyePos; RightPosition.Invoke(_rightEyePos); } }
private void Awake() { controls = new InputManager(); controls.Enable(); controls.Player.Interact.performed += ctx => interactEvent.Invoke(); controls.Player.Interact.performed += ctx => Possess(); controls.Player.Movement.performed += ctx => movementEvent.Invoke(ctx.ReadValue <Vector2>()); controls.Player.Movement.canceled += ctx => movementEvent.Invoke(new Vector2(0, 0)); controls.Player.MouseMovement.performed += ctx => mouseMovementEvent.Invoke(ctx.ReadValue <Vector2>().normalized); controls.Player.Jump.performed += ctx => jumpEvent.Invoke(); }
private void HandleFingerTap(LeanFinger finger) { // Ignore? if (IgnoreStartedOverGui == true && finger.StartedOverGui == true) { return; } if (IgnoreIsOverGui == true && finger.IsOverGui == true) { return; } if (RequiredTapCount > 0 && finger.TapCount != RequiredTapCount) { return; } if (RequiredTapInterval > 0 && (finger.TapCount % RequiredTapInterval) != 0) { return; } if (RequiredSelectable != null && RequiredSelectable.IsSelected == false) { return; } if (onFinger != null) { onFinger.Invoke(finger); } if (onCount != null) { onCount.Invoke(finger.TapCount); } if (onWorld != null) { var position = ScreenDepth.Convert(finger.ScreenPosition, gameObject); onWorld.Invoke(position); } if (onScreen != null) { onScreen.Invoke(finger.ScreenPosition); } }
void onUp() { OnUp.Invoke(); float difT = endTime - startTime; Vector2 difP = endPos - startPos; float ratio = .01f * difP.magnitude / difT; if (ratio > 3) { OnSwipe.Invoke(difP); if (Mathf.Abs(difP.x) > Mathf.Abs(difP.y)) { OnSwipeHorizontal.Invoke(difP.x); if (difP.x < 0) { OnSwipeLeft.Invoke(); } else { OnSwipeRight.Invoke(); } } else { OnSwipeVertical.Invoke(difP.y); if (difP.x < 0) { OnSwipeUp.Invoke(); } else { OnSwipeDown.Invoke(); } } } else { OnTap.Invoke(); } currentHitName = null; //print( difT ); //print( difP ); //print( ratio ); }
public void OnDrag(PointerEventData eventData) { RectTransformUtility.ScreenPointToLocalPointInRectangle(Bind, Input.mousePosition, null, out Vector2 mousePosition); Vector2 resize = Bind.sizeDelta; if (ResizeX) { resize.x = mousePosition.x >= MinSizeX ? mousePosition.x : MinSizeX; } if (ResizeY) { resize.y = -mousePosition.y >= MinSizeY ? -mousePosition.y : MinSizeY; } Bind.sizeDelta = resize; OnResize.Invoke(resize); }
protected override void updateSwitch(float time, bool immediately = false) { if (IsInterpolatable(propertyType)) { if (propertyType == PropertyType.Float) { updateFloatValue.Invoke(Mathf.Lerp(offFloatValue, onFloatValue, interpolationCurve.Evaluate(time))); } else if (propertyType == PropertyType.Int) { updateIntValue.Invoke(Mathf.RoundToInt(Mathf.Lerp(offIntValue, onIntValue, interpolationCurve.Evaluate(time)))); } else if (propertyType == PropertyType.Vector2) { updateVector2Value.Invoke(Vector2.Lerp(offVector2Value, onVector2Value, interpolationCurve.Evaluate(time))); } else if (propertyType == PropertyType.Vector3) { updateVector3Value.Invoke(Vector3.Lerp(offVector3Value, onVector3Value, interpolationCurve.Evaluate(time))); } } else { if (propertyType == PropertyType.Bool) { if (GetIsOnOrTurningOn()) { updateBoolValue.Invoke(onBoolValue); } else { updateBoolValue.Invoke(offBoolValue); } } else if (propertyType == PropertyType.String) { if (GetIsOnOrTurningOn()) { updateStringValue.Invoke(onStringValue); } else { updateStringValue.Invoke(offStringValue); } } } }
void FixedUpdate() { if (!gamePauzed) { float input_x = movementInput.x; float input_y = movementInput.y; float calibratedSpeed = this.GetCalibratedSpeed(input_x, input_y); movementEvent.Invoke(movementInput); rigidbody2D.MovePosition(new Vector2( (transform.position.x + input_x * calibratedSpeed), (transform.position.y + input_y * calibratedSpeed)) ); } }
public void SetValue(Vector2 pos) { Vector2 clampedValue = new Vector2(Mathf.Clamp(pos.x, MinValue, MaxValue), Mathf.Clamp(pos.y, MinValue, MaxValue)); if (WholeNumbers) { clampedValue = new Vector2(Mathf.Round(clampedValue.x), Mathf.Round(clampedValue.y)); } if (_Value.Equals(clampedValue)) { return; } _Value = clampedValue; UpdateHandle(); OnValueChanged.Invoke(Value); }