void DoStep() { if (_isDiving) { return; } _rigidBody.DOJump(transform.position + new Vector3(moveDistance, 0f, 0f), moveHeight, 0, moveDuration).OnComplete(() => { if (Mathf.Abs(_target.position.x - transform.position.x) > diveDistance) { return; } StartDive(); }); }
public bool GetInput(int[] commandType) { //walk if (ArrayCompare(commandType, new int[] { 1, 1, 1, 2 })) { Vector2 currentPosition = new Vector2(transform.position.x, transform.position.y); thisRigidbody.DOMove(currentPosition + (Vector2.left * moveDistance), secondsToBeats, false); sprite1Animator.SetBool("Walking", true); sprite2Animator.SetBool("Walking", true); return(true); } //jump else if (ArrayCompare(commandType, new int[] { 3, 3, 1, 2 })) { Vector2 currentPosition = new Vector2(transform.position.x, transform.position.y); thisRigidbody.DOJump(currentPosition + (Vector2.up * jumpHeight), 0.5f, 0, secondsToBeats, false); sprite1Animator.SetBool("Jumping", true); sprite2Animator.SetBool("Jumping", true); return(true); } else { unmatchedCommand.Play(); unmatchedCommandSprite.color = flashColor; return(false); } }
public override Tween GetTween(UniTween.UniTweenTarget uniTweenTarget) { Rigidbody2D rb = (Rigidbody2D)GetComponent(uniTweenTarget); switch (command) { case Rigidbody2DCommand.Move: return(rb.DOMove(vector2, duration, snapping)); case Rigidbody2DCommand.MoveX: return(rb.DOMoveX(to, duration, snapping)); case Rigidbody2DCommand.MoveY: return(rb.DOMoveY(to, duration, snapping)); case Rigidbody2DCommand.Jump: return(rb.DOJump(vector2, jumpPower, numJumps, duration, snapping)); case Rigidbody2DCommand.Rotate: return(rb.DORotate(to, duration)); default: return(null); } }
IEnumerator Start() { yield return(new WaitForSeconds(1)); r3D.DOJump(new Vector3(5f, 0, 0), 3f, 2, 2f, false); r2D.DOJump(new Vector2(5f, 0), 3f, 2, 2f, false); // r2D.transform.DOJump(new Vector2(5f, 0), 3f, 2, 2f, false); }
public void TakeDmg(int Dmg, Vector3 dir) { if (playerHealth > 0) { if (shieldOn == false && ParryWindow == false && HitSpikes == false && isInvinsable == false && playerWithShield.DashAttack == false) { soundManager.PlayOneSound("Player Taken Hit"); StartCoroutine("FreezFrame"); StartCoroutine("Blinker"); playerHealth -= Dmg; healthAnimator.SetInteger("PlayerHealthUI", playerHealth); playerWithShield.UnderImpactAnim(); playerWithShield.isDashing = false; if (!isImpect_ON && playerHealth > 0) { isImpect_ON = true; Impact = rb2d.DOJump(transform.position - dir * impact_Force, impact_JumpForce, 0, 0.5f); Impact.SetEase(Ease.Flash); } } if (HitSpikes == true) { soundManager.PlayOneSound("Player Taken Hit"); playerHealth -= Dmg; healthAnimator.SetBool("OneShot", true); } if (shieldOn == true) { ShieldCoolDown = true; shieldOn = false; Invoke("SetShieldCoolTime", 1.5f); if (dir.x <= 0) { Instantiate(ShieldHit1, hitpoint.transform.position, transform.rotation); } if (dir.x >= 0) { Instantiate(ShieldHit1, hitpoint1.transform.position, transform.rotation); } ShieldReff.HitShield(); playerWithShield.HitShield(); } if (ParryWindow == true) { Parry(); } if (playerHealth <= 0) { playerWithShield.PlayerDeath(); Invoke("Die", 1f); } } }
public override Sequence ExcuteTween(Rigidbody2D rigidbody2D, float interval, float duration) { Sequence sequence = DOTween.Sequence(); if (targetTransform.Length == 0) { Debug.LogError("Target transform not found. Where should I go?"); } for (int i = 0; i < targetTransform.Length; i++) { Tween tween = rigidbody2D.DOJump(targetTransform[i].position, jumpPower, 1, duration); sequence.Append(tween); sequence.AppendInterval(interval); } return(sequence); }
// Start is called before the first frame update void Start() { Sequence s = DOTween.Sequence(); //float randomX = Random.Range(0.0f, 0.5f); //float randomY = Random.Range(0.5f, 0.7f); //s.Join(transform.DOMove(new Vector3(transform.position.x + playerC.transform.right.normalized.x * -1 * randomX, transform.position.y + randomY),0.5f)); //s.Join(transform.DORotate(new Vector3(0,0,1800.0f),0.5f)); float randomX = Random.Range(-1.5f, -0.5f); float randomY = Random.Range(-0.6f, -0.1f); //s.Append(transform.DOMove(new Vector3(transform.position.x + playerC.transform.right.normalized.x * -1 * randomX, transform.position.y + randomY), 1.0f)); //s.Join(transform.DORotate(new Vector3(0, 0, 1800.0f), 1.0f)); s.Append(rb.DOJump(new Vector3(transform.position.x + playerC.transform.right.normalized.x * randomX, transform.position.y + randomY), 1.3f, 1, 1.0f)); s.Join(transform.DORotate(new Vector3(0, 0, 1800.0f), 1.0f)); s.AppendCallback(() => { GetComponent <SpriteRenderer>().sortingLayerName = "BackGround"; rb.velocity = new Vector2(0, 0); boxCollider.enabled = false; }); }
/// <summary> /// Creates and returns a Tween for the informed component. /// The Tween is configured based on the attribute values of this TweenData file. /// </summary> /// <param name="transform"></param> /// <returns></returns> public Tween GetTween(Rigidbody2D rb) { switch (command) { case Rigidbody2DCommand.Move: return(rb.DOMove(vector2, duration, snapping)); case Rigidbody2DCommand.MoveX: return(rb.DOMoveX(to, duration, snapping)); case Rigidbody2DCommand.MoveY: return(rb.DOMoveY(to, duration, snapping)); case Rigidbody2DCommand.Jump: return(rb.DOJump(vector2, jumpPower, numJumps, duration, snapping)); case Rigidbody2DCommand.Rotate: return(rb.DORotate(to, duration)); default: return(null); } }
private void Jump() { obj.DOJump(new Vector2(5, 0), 3, 3, 5); }
public void LaunchBomb() { Rigidbody2D bomb = GetComponent <Rigidbody2D>(); movement = bomb.DOJump(target, jumpPower, numberOfJumps, duration).OnComplete(OnTweenComplete); }
public override void OnEnter() { var _target = Fsm.GetOwnerDefaultTarget(gameObject); if (loopDontFinish.Value == true) { settingLoops = -1; } else { settingLoops = loopsQuantity.Value; } if (_target != null) { Vector2 Vector2setup = to.IsNone ? new Vector2(x.Value, y.Value) : to.Value; if (!x.IsNone) { Vector2setup.x = x.Value; } if (!y.IsNone) { Vector2setup.y = y.Value; } to.Value = Vector2setup; } rigidBody = _target.GetComponent <Rigidbody2D>(); if (rigidBody == null) { Debug.LogWarning("<b>[DotweenJumpRigidbody2dTo]</b><color=#FF9900ff>Missing Rigidbody component</color>", this.Owner); return; } setFinal = new TweenParams().SetDelay(setDelay.Value).SetAutoKill(setAutoKill.Value).SetRecyclable(setRecycle.Value).SetSpeedBased(isSpeedBased.Value).SetRelative(setRelative.Value).OnComplete(MyCallback); switch (loopTypeSelect) { case loopType.None: if (settingLoops > 0 || settingLoops < 0) { Debug.LogWarning("<b>[DotweenJumpRigidbody2dTo]</b><color=#FF9900ff>!!! Loop Time is set but no 'Loop Type' is selected !!! </color>", this.Owner); } break; case loopType.Yoyo: setFinal.SetLoops(settingLoops, LoopType.Yoyo); break; case loopType.Restart: setFinal.SetLoops(settingLoops, LoopType.Restart); break; case loopType.Incremental: setFinal.SetLoops(settingLoops, LoopType.Incremental); break; } if (!tag.IsNone) { setFinal.SetId(tag.Value); } bool _isNullOrEmpty = orInputID.IsNone || orInputID == null || string.IsNullOrEmpty(orInputID.Value); if (_isNullOrEmpty == false) { setFinal.SetId(orInputID.Value); } bool obj_isNullOrEmpty = gameObjectId.IsNone || gameObjectId.Value == false; if (obj_isNullOrEmpty == false) { setFinal.SetId(Fsm.GetOwnerDefaultTarget(gameObject)); } switch (easeTypeSelect) { case setEaseType.none: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.Linear); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.Linear)); } break; case setEaseType.InSine: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InSine); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InSine)); } break; case setEaseType.OutSine: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutSine); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutSine)); } break; case setEaseType.InOutSine: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutSine); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutSine)); } break; case setEaseType.InQuad: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InQuad); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InQuad)); } break; case setEaseType.OutQuad: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutQuad); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutQuad)); } break; case setEaseType.InOutQuad: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutQuad); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutQuad)); } break; case setEaseType.InCubic: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InCubic); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InCubic)); } break; case setEaseType.OutCubic: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutCubic); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutCubic)); } break; case setEaseType.InOutCubic: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutCubic); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutCubic)); } break; case setEaseType.InQuart: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InQuart); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InQuart)); } break; case setEaseType.OutQuart: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutQuart); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutQuart)); } break; case setEaseType.InOutQuart: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutQuart); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutQuart)); } break; case setEaseType.InQuint: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InQuint); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InQuint)); } break; case setEaseType.OutQuint: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutQuint); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutQuint)); } break; case setEaseType.InOutQuint: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutQuint); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutQuint)); } break; case setEaseType.InExpo: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InExpo); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InExpo)); } break; case setEaseType.OutExpo: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutExpo); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutExpo)); } break; case setEaseType.InOutExpo: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutExpo); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutExpo)); } break; case setEaseType.InCirc: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InCirc); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InCirc)); } break; case setEaseType.OutCirc: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutCirc); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutCirc)); } break; case setEaseType.InOutCirc: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutCirc); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutCirc)); } break; case setEaseType.InElastic: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InElastic); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InElastic)); } break; case setEaseType.OutElastic: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutElastic); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutElastic)); } break; case setEaseType.InOutElastic: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutElastic); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutElastic)); } break; case setEaseType.InBack: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InBack); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InBack)); } break; case setEaseType.OutBack: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutBack); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutBack)); } break; case setEaseType.InOutBack: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutBack); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutBack)); } break; case setEaseType.InBounce: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InBounce); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InBounce)); } break; case setEaseType.OutBounce: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutBounce); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutBounce)); } break; case setEaseType.InOutBounce: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutBounce); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutBounce)); } break; case setEaseType.Flash: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.Flash); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.Flash)); } break; case setEaseType.InFlash: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InFlash); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InFlash)); } break; case setEaseType.OutFlash: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.OutFlash); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.OutFlash)); } break; case setEaseType.InOutFlash: if (enableEaseFactory.Value == false) { setFinal.SetEase(Ease.InOutFlash); } if (enableEaseFactory.Value == true) { setFinal.SetEase(EaseFactory.StopMotion(easeFactoryFps.Value, Ease.InOutFlash)); } break; case setEaseType.AnimationCurve: setFinal.SetEase(animationCurve.curve); break; } // Update + TimeScale switch (updateTypeSelect) { case updateType.Normal: setFinal.SetUpdate(UpdateType.Normal, isTimeIndependent.Value); break; case updateType.Fixed: setFinal.SetUpdate(UpdateType.Fixed, isTimeIndependent.Value); break; case updateType.Late: setFinal.SetUpdate(UpdateType.Late, isTimeIndependent.Value); break; } // Easy part to edit for other DotTween actions ---> switch (dotweenTypeSelect) { case doTweenType.Jump: rigidBody.DOJump(to.Value, jumpPower.Value, jumpNumber.Value, duration.Value, snapping.Value).SetAs(setFinal); break; } // <--- if (startEvent != null) { Fsm.Event(startEvent); Finish(); } }