Пример #1
0
 public void Kick()
 {
     if (tweener != null && tweener.IsPlaying())
     {
         tweener.Complete();
     }
     tweener = rb.DORotate(originalAngle * -1, Speed);
 }
Пример #2
0
    void OnGUI()
    {
        DGUtils.BeginGUI();

        if (GUILayout.Button("Rotate 2D 360"))
        {
            r2D.DORotate(360, 1);
        }
        if (GUILayout.Button("Rotate 2D 360 Relative"))
        {
            r2D.DORotate(360, 1).SetRelative();
        }

        DGUtils.EndGUI();
    }
Пример #3
0
 public void PushPlayerUp()
 {
     rb.velocity        = Vector2.zero;
     rb.angularVelocity = 0f;
     rb.DORotate(Random.Range(-360, 360), 1f);
     rb.AddForce(Vector2.up * pushForce, ForceMode2D.Force);
 }
Пример #4
0
    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);
        }
    }
Пример #5
0
    public void Move()
    {
        //UI選択中は動かさない
        if (TouchUtil.IsGetTouch())
        {
            return;
        }

        seq = DOTween.Sequence();
        Vector3 move = TouchUtil.GetTouchWorldPosition(Camera.main) - Camera.main.transform.position;

        //移動制限
        //move.x = Mathf.Clamp(move.x, -5.75f, 5.75f);
        seq.Append(rb2d.DOMove(move * speed, 2.0f));

        Vector3 dir = transform.position - move;

        if (Mathf.Abs(dir.x) > 0.8f) //誤差が0.8以上のときだけ移動する方向に向く
        {
            seq.Join(rb2d.DORotate(Mathf.Sign(dir.x) * 45, 0.5f));
            seq.Append(rb2d.DORotate(0, 0.5f));
        }
    }
Пример #6
0
    void FixedUpdate()
    {
        if (_rb != null)
        {
            _rb.DORotate(_targetRotattion, Time.fixedDeltaTime);
        }
        else
        {
//            var desiredRotQ = Quaternion.Euler(transform.eulerAngles.x, _tr.eulerAngles.y, _targetRotattion);
//            transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotQ, 0.5f);

            pivot.DOLocalRotate(new Vector3(0, 0, _targetRotattion), Time.fixedDeltaTime);
        }
    }
Пример #7
0
    private void Start()
    {
        // 全局设置
        DOTween.defaultEaseType = Ease.Linear;

        playButton.DOAnchorPosX(0, 1);
        settingsButton.DOAnchorPosX(0, 1);
        exitButton.DOAnchorPosY(-200, 1);

        // 如果用From,物体原本在场景中的位置就是目标位置
        // 如果snapping为true,只取整数值
        obj.DOMove(new Vector2(0, 3), 5).From();
        //obj.DOJump(new Vector2(5, 0), 3, 3, 5).SetEase(Ease.Linear);
        obj.DORotate(360, 5);
        Invoke("Jump", 5);
    }
Пример #8
0
    IEnumerator DoThrow(Rigidbody2D rb)
    {
        Vector2 dir;

        if (rb.GetComponent <Thing>().hasShield)
        {
            yield break;
        }

        int layer = rb.gameObject.layer;

        rb.gameObject.layer = 19;

        items[index]             = null;
        itemImages[index].sprite = empty;


        if (mouseSetPosition)
        {
            Vector2 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            dir = (mouseWorldPos - (Vector2)playerControl.transform.position).normalized;
        }
        else
        {
            dir = Vector2.up;
        }



        //TODO: 旋转

        //rb.transform.localRotation = Quaternion.Euler(0, 0, AngleBetween(Vector2.up, dir.normalized));

        if (RotateThing)
        {
            rb.transform.rotation = Quaternion.identity;
            rb.DORotate(720f, 2f);
        }
        rb.transform.position = playerControl.transform.position + (Vector3)dir * throwOffset;
        rb.gameObject.GetComponent <Rigidbody2D>().velocity = dir * throwSpeed;


        yield return(new WaitForSeconds(0.15f));

        rb.gameObject.layer = layer;
    }
Пример #9
0
    public override Sequence ExcuteTween(Rigidbody2D rigidbody2D, float interval, float duration)
    {
        Sequence sequence = DOTween.Sequence();

        if (targetDegree.Length == 0)
        {
            Debug.LogError("Target Degree not found. What direction should I turn?");
        }

        for (int i = 0; i < targetDegree.Length; i++)
        {
            Tween tween = rigidbody2D.DORotate(targetDegree[i], duration);
            tween.SetEase(ease);

            sequence.Append(tween);
            sequence.AppendInterval(interval);
        }

        return(sequence);
    }
Пример #10
0
        /// <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);
            }
        }
Пример #11
0
        public override void OnEnter()
        {
            var _target = Fsm.GetOwnerDefaultTarget(gameObject);

            if (_target != null)
            {
                rigidBody = _target.GetComponent <Rigidbody2D>();
            }

            if (loopDontFinish.Value == true)
            {
                settingLoops = -1;
            }
            else
            {
                settingLoops = loopsQuantity.Value;
            }

            setFinal = new TweenParams().SetDelay(setDelay.Value).SetAutoKill(setAutoKill.Value).SetSpeedBased(isSpeedBased.Value).SetRelative(setRelative.Value).OnComplete(MyCallback);



            switch (loopTypeSelect)
            {
            case loopType.None:
                if (settingLoops > 0 || settingLoops < 0)
                {
                    Debug.LogWarning("<b>[DotweenRotateRigidbody2dTo]</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 --->


            rigidBody.DORotate(to.Value, duration.Value).SetAs(setFinal);

            // <---


            if (startEvent != null)
            {
                Fsm.Event(startEvent);
                Finish();
            }
        }