예제 #1
0
        public void Initialize(GameObject newEnemy, EnemySpawn spawnObject, GameObject container)
        {
            if (waypoints != null)
            {
                var worldWaypoints = new Vector3[waypoints.Length];

                for (var i = 0; i < waypoints.Length; i++)
                {
                    var localWaypoint = waypoints[i];

                    worldWaypoints[i] = new Vector3(spawnObject.flipOnX ? -localWaypoint.x : localWaypoint.x,
                                                    //worldWaypoints[i] = newEnemy.transform.TransformPoint(spawnObject.flipOnX ? -localWaypoint.x : localWaypoint.x,
                                                    localWaypoint.y, localWaypoint.z);
                }

                var tweenCompletion = container.AddComponent <DisappearWhenTweenComplete>();

                var tweenParams = new TweenParams();
                tweenParams.SetSpeedBased(true).SetEase(Ease.Linear).SetLoops(0).SetAutoKill(true);
                if (tweenCompletion != null)
                {
                    tweenParams.OnComplete(tweenCompletion.OnTweenComplete);
                }

                var tween = newEnemy.transform.DOLocalPath(worldWaypoints, speed, PathType.CatmullRom, PathMode.Full3D, tweenPathResolution)
                            //newEnemy.transform.DOLocalPath(theWaypoints, speed, PathType.CatmullRom, PathMode.TopDown2D)
                            .SetAs(tweenParams).SetOptions(false).SetLookAt(lookAhead, -Vector3.forward)
                ;
            }
        }
예제 #2
0
        //creates a new tween with given arguments that moves along the path
        private void CreateTween()
        {
            //prepare DOTween's parameters, you can look them up here
            //http://dotween.demigiant.com/documentation.php

            TweenParams parms = new TweenParams();

            //differ between speed or time based tweening
            if (timeValue == TimeValue.speed)
            {
                parms.SetSpeedBased();
            }
            if (loopType == LoopType.yoyo)
            {
                parms.SetLoops(-1, DG.Tweening.LoopType.Yoyo);
            }

            //apply ease type or animation curve
            if (easeType == DG.Tweening.Ease.INTERNAL_Custom)
            {
                parms.SetEase(animEaseType);
            }
            else
            {
                parms.SetEase(easeType);
            }

            if (moveToPath)
            {
                parms.OnWaypointChange(OnWaypointReached);
            }
            else
            {
                if (loopType == LoopType.yoyo)
                {
                    parms.OnStepComplete(ReachedEnd);
                }

                transform.position = wpPos[0];

                parms.OnWaypointChange(OnWaypointChange);
                parms.OnComplete(ReachedEnd);
            }

            tween = transform.DOPath(wpPos, originSpeed, pathType, pathMode, 1)
                    .SetAs(parms)
                    .SetOptions(false, lockPosition, lockRotation)
                    .SetLookAt(lookAhead);
            if (!moveToPath && startPoint > 0)
            {
                GoToWaypoint(startPoint);
                startPoint = 0;
            }

            //continue new tween with adjusted speed if it was changed before
            if (originSpeed != speed)
            {
                ChangeSpeed(speed);
            }
        }
예제 #3
0
    private static int OnComplete(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            TweenParams   tweenParams = (TweenParams)ToLua.CheckObject(L, 1, typeof(TweenParams));
            LuaTypes      luaTypes    = LuaDLL.lua_type(L, 2);
            TweenCallback action;
            if (luaTypes != LuaTypes.LUA_TFUNCTION)
            {
                action = (TweenCallback)ToLua.CheckObject(L, 2, typeof(TweenCallback));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                action = (DelegateFactory.CreateDelegate(typeof(TweenCallback), func) as TweenCallback);
            }
            TweenParams o = tweenParams.OnComplete(action);
            ToLua.PushObject(L, o);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
예제 #4
0
        private void NextNode()
        {
            if (indexNodePath == nodePath.Length)
            {
                gameObject.SetActive(false);
                return;
            }

            Vector3 previousDirection = nodePath[indexNodePath - 1].GetPosition();
            Vector3 nextDirection     = indexNodePath + 1 < nodePath.Length ? nodePath[indexNodePath + 1].GetPosition() : transform.position;

            Vector3[] waypoints = nodePath[indexNodePath].GetWaypoint(previousDirection, nextDirection);

            node = nodePath[indexNodePath++];
            if (waypoints == null)
            {
                Debug.LogWarning("No Path on Node : " + nodePath[indexNodePath - 1]);
                return;
            }
            TweenParams tParam = new TweenParams().SetSpeedBased(true).SetEase(Ease.Linear);

            tParam.OnComplete(NextNode);
            pathTween = transform.DOPath(waypoints, speed, PathType.CatmullRom).SetLookAt(0f).SetAs(tParam);
        }
예제 #5
0
        //creates a new tween with given arguments that moves along the path
        private void CreateTween()
        {
            //prepare DOTween's parameters, you can look them up here
            //http://dotween.demigiant.com/documentation.php

            TweenParams parms = new TweenParams();

            //differ between speed or time based tweening
            if (timeValue == TimeValue.speed)
            {
                parms.SetSpeedBased();
            }
            if (loopType == LoopType.yoyo)
            {
                parms.SetLoops(-1, DG.Tweening.LoopType.Yoyo);
            }

            //apply ease type or animation curve
            if (easeType == DG.Tweening.Ease.Unset)
            {
                parms.SetEase(animEaseType);
            }
            else
            {
                parms.SetEase(easeType);
            }

            if (moveToPath)
            {
                parms.OnWaypointChange(OnWaypointReached);
            }
            else
            {
                //on looptype random initialize random order of waypoints
                if (loopType == LoopType.random)
                {
                    RandomizeWaypoints();
                }
                else if (loopType == LoopType.yoyo)
                {
                    parms.OnStepComplete(ReachedEnd);
                }

                Vector3 startPos = wpPos[0];
                if (local)
                {
                    startPos = pathContainer.transform.TransformPoint(startPos);
                }
                transform.position = startPos;

                parms.OnWaypointChange(OnWaypointChange);
                parms.OnComplete(ReachedEnd);
            }

            if (pathMode == DG.Tweening.PathMode.Ignore &&
                waypointRotation != RotationType.none)
            {
                if (rotationTarget == null)
                {
                    rotationTarget = transform;
                }
                parms.OnUpdate(OnWaypointRotation);
            }

            if (local)
            {
                tween = transform.DOLocalPath(wpPos, originSpeed, pathType, pathMode)
                        .SetAs(parms)
                        .SetOptions(closeLoop, lockPosition, lockRotation)
                        .SetLookAt(lookAhead);
            }
            else
            {
                tween = transform.DOPath(wpPos, originSpeed, pathType, pathMode)
                        .SetAs(parms)
                        .SetOptions(closeLoop, lockPosition, lockRotation)
                        .SetLookAt(lookAhead);
            }

            if (!moveToPath && startPoint > 0)
            {
                GoToWaypoint(startPoint);
                startPoint = 0;
            }

            //continue new tween with adjusted speed if it was changed before
            if (originSpeed != speed)
            {
                ChangeSpeed(speed);
            }
        }
예제 #6
0
    void PlayAnimation(bool isEnter = true, Action callback = null)
    {
        if (m_CurrentTweener != null && m_CurrentTweener.IsPlaying())
        {
            m_CurrentTweener.Kill();
        }

        float overDisRatio = 1.2f;

        float   aniTime = isEnter ? 1f : 0.5f;
        Vector2 endPos  = m_StartAnchorePos;

        TweenParams aniParams = new TweenParams();

        aniParams.SetEase(isEnter ? Ease.OutBack : Ease.OutCubic);
        aniParams.SetDelay(isEnter ? 0.1f * m_Priority : 0);
        aniParams.OnComplete(() =>
        {
            if (null != callback)
            {
                callback();
            }
        });
        if (!isEnter)
        {
            m_MainObjRectTrans.anchoredPosition = m_StartAnchorePos;
        }

        switch (m_DirType)
        {
        case SideButtonDirType.Left_Top:
        case SideButtonDirType.Left_Bottom:
            Vector2 tempLeftPos = new Vector2(-m_ContentRect.anchoredPosition.x - m_MainObjRectTrans.rect.width, m_StartAnchorePos.y);
            if (isEnter)
            {
                m_MainObjRectTrans.anchoredPosition = tempLeftPos;
            }
            else
            {
                endPos = tempLeftPos;
            }
            break;

        case SideButtonDirType.Right:
            Vector2 tempRightPos = new Vector2(m_StartAnchorePos.x + m_ContentRect.rect.width * overDisRatio, m_StartAnchorePos.y);
            if (isEnter)
            {
                m_MainObjRectTrans.anchoredPosition = tempRightPos;
            }
            else
            {
                endPos = tempRightPos;
            }
            break;

        case SideButtonDirType.Bottom:

            Vector2 tempBottomPos = new Vector2(m_StartAnchorePos.x, m_StartAnchorePos.y - m_ContentRect.rect.width * overDisRatio);
            if (isEnter)
            {
                m_MainObjRectTrans.anchoredPosition = tempBottomPos;
            }
            else
            {
                endPos = tempBottomPos;
            }

            break;
        }

        m_CurrentTweener = m_MainObjRectTrans.DOAnchorPos(endPos, aniTime).SetAs(aniParams);
    }
예제 #7
0
        // Token: 0x06000749 RID: 1865 RVA: 0x00030738 File Offset: 0x0002EB38
        private void CreateTween()
        {
            TweenParams tweenParams = new TweenParams();

            if (this.timeValue == splineMove.TimeValue.speed)
            {
                tweenParams.SetSpeedBased(true);
            }
            if (this.loopType == splineMove.LoopType.yoyo)
            {
                tweenParams.SetLoops(-1, new DG.Tweening.LoopType?(DG.Tweening.LoopType.Yoyo));
            }
            if (this.easeType == Ease.INTERNAL_Custom)
            {
                tweenParams.SetEase(this.animEaseType);
            }
            else
            {
                tweenParams.SetEase(this.easeType, null, null);
            }
            if (this.moveToPath)
            {
                tweenParams.OnWaypointChange(new TweenCallback <int>(this.OnWaypointReached));
            }
            else
            {
                if (this.loopType == splineMove.LoopType.random)
                {
                    this.RandomizeWaypoints();
                }
                else if (this.loopType == splineMove.LoopType.yoyo)
                {
                    tweenParams.OnStepComplete(new TweenCallback(this.ReachedEnd));
                }
                Vector3 position = this.wpPos[0];
                if (this.local)
                {
                    position = this.pathContainer.transform.TransformPoint(position);
                }
                base.transform.position = position;
                tweenParams.OnWaypointChange(new TweenCallback <int>(this.OnWaypointChange));
                tweenParams.OnComplete(new TweenCallback(this.ReachedEnd));
            }
            if (this.local)
            {
                this.tween = base.transform.DOLocalPath(this.wpPos, this.originSpeed, this.pathType, this.pathMode, 10, null).SetAs(tweenParams).SetOptions(this.closeLoop, this.lockPosition, this.lockRotation).SetLookAt(this.lookAhead, null, null);
            }
            else
            {
                this.tween = base.transform.DOPath(this.wpPos, this.originSpeed, this.pathType, this.pathMode, 10, null).SetAs(tweenParams).SetOptions(this.closeLoop, this.lockPosition, this.lockRotation).SetLookAt(this.lookAhead, null, null);
            }
            if (!this.moveToPath && this.startPoint > 0)
            {
                this.GoToWaypoint(this.startPoint);
                this.startPoint = 0;
            }
            if (this.originSpeed != this.speed)
            {
                this.ChangeSpeed(this.speed);
            }
        }