public void OnValueChanged(CardController card, int newValue, CardValueType type) { TextMeshProUGUI textToChange = null; switch (type) { case CardValueType.Cost: textToChange = CostText; break; case CardValueType.Attack: textToChange = AttackText; break; case CardValueType.Defense: textToChange = DefenseText; break; } textToChange.text = newValue.ToString(); _canvas.sortingOrder += 3; // Bring the card to the top. // Animate the number. DOTween.Punch(() => { return(textToChange.transform.localScale); }, (Vector3 newScale) => { textToChange.transform.localScale = newScale; }, new Vector3(1.0f, 1.0f), 0.5f, 5); }
public static XTween Punch(LuaFunction getter, LuaFunction setter, Vector3 direction, float duration, int vibrato, float elasticity) { return(new XTween(DOTween.Punch( () => { return (Vector3)getter.call(); }, (v) => { setter.call(v); }, direction, duration, vibrato, elasticity))); }
void Update() { if (isDrawing) { // Update line endPos = GetWorldMousePos(); currLine.SetPosition(1, endPos); } if (Input.GetMouseButtonDown(0)) { // Start new line CreateLine(); isDrawing = true; } else if (Input.GetMouseButtonUp(0) && isDrawing) { // End line and add collider isDrawing = false; EdgeCollider2D col = currLine.gameObject.AddComponent <EdgeCollider2D>(); col.points = new Vector2[] { startPos, endPos }; // Tween line ending // Find max bounce distance (along the correct axis) // Change the last value (0.65f) to increase or decrease the bounce distance (inverse) Vector3 bouncePoint = (endPos - startPos) - ((endPos - startPos) * 0.65f); Vector3 tweenP = endPos; LineRenderer tweenedL = currLine; // The last 3 parameters indicate: // - the duration of the tween // - the vibration (how much it will oscillate) // - if the bounce should go beyond the end point or not (0 means not) DOTween.Punch(() => tweenP, x => tweenP = x, -bouncePoint, 0.6f, 8, 0) .OnUpdate(() => tweenedL.SetPosition(1, tweenP)); } }
public void Collide() { if (this.tweener == null || !this.tweener.IsPlaying()) { this.tweener = DOTween.Punch(this.GetPosition, this.SetPosition, this.power, POWER.w); } }
public static Tweener DOPunchRotation(this Transform target, Vector3 punch, float duration, int vibrato = 10, float elasticity = 1f) { return(DOTween.Punch(() => target.localEulerAngles, delegate(Vector3 x) { target.localRotation = Quaternion.Euler(x); }, punch, duration, vibrato, elasticity).SetTarget(target)); }
public static Tweener DOPunchScale(this Transform target, Vector3 punch, float duration, int vibrato = 10, float elasticity = 1f) { return(DOTween.Punch(() => target.localScale, delegate(Vector3 x) { target.localScale = x; }, punch, duration, vibrato, elasticity).SetTarget(target)); }
public static Tweener DOPunchPosition(this Transform target, Vector3 punch, float duration, int vibrato = 10, float elasticity = 1f, bool snapping = false) { return(DOTween.Punch(() => target.localPosition, delegate(Vector3 x) { target.localPosition = x; }, punch, duration, vibrato, elasticity).SetTarget(target).SetOptions(snapping)); }
// Update is called once per frame void Update() { // update score: var sv = scoreValue.GetComponent <TextMeshPro>(); var newText = PlayfieldManager.Playfield.Stats.TotalScore.ToString(); #if TEXTPRO_CRAP if (newText != sv.text) { sv.text = newText; DOTween.Punch(() => new Vector3(sv.fontSize, sv.fontSize, sv.fontSize), v => sv.fontSize = v.x, new Vector3(1.0f, 0.1f, 1.0f), 0.5f, scoreValueVibrato, scoreValueElasticity); } #endif }
private TweenerCore <Vector3, Vector3[], Vector3ArrayOptions> CreateNewTween() { return(DOTween.Punch(valueGetter, valueSetter, data.endPos, data.Duration, data.vibrato, data.elasticity).SetUpdate(data.IgnoreTimeScale)); }
/// <summary>Punches a RectTransform's anchoredPosition towards the given direction and then back to the starting one /// as if it was connected to the starting position via an elastic. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// <param name="punch">The direction and strength of the punch (added to the RectTransform's current position)</param> /// <param name="duration">The duration of the tween</param> /// <param name="vibrato">Indicates how much will the punch vibrate</param> /// <param name="elasticity">Represents how much (0 to 1) the vector will go beyond the starting position when bouncing backwards. /// 1 creates a full oscillation between the punch direction and the opposite direction, /// while 0 oscillates only between the punch and the start position</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static Tweener DOPunchAnchorPos(this RectTransform target, Vector2 punch, float duration, int vibrato = 10, float elasticity = 1, bool snapping = false) { return(DOTween.Punch(() => target.anchoredPosition, x => target.anchoredPosition = x, punch, duration, vibrato, elasticity) .SetTarget(target).SetOptions(snapping)); }