Пример #1
0
        private DynValue CommandFunction(float time = 0.4f, string colorCode = "#000000", string easingType = null)
        {
            try
            {
                var advEngine = AdvEngine.Instance;

                UnityUtility.SetActive(FadeImage, true);

                var color = colorCode.HexToColor();

                color.a = 0f;

                TweenCallback onComplete = () =>
                {
                    advEngine.Resume();
                };

                FadeImage.color = color;

                var ease = EnumExtensions.FindByName(easingType, Ease.Linear);

                var tweener = FadeImage.DOFade(1f, time)
                              .SetEase(ease)
                              .OnComplete(onComplete);

                advEngine.SetTweenTimeScale(tweener);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(YieldWait);
        }
Пример #2
0
        private DynValue CommandFunction(string identifier, float position, float duration = 0, string easingType = null, bool wait = true)
        {
            var advEngine = AdvEngine.Instance;

            var advObject = advEngine.ObjectManager.Get <AdvObject>(identifier);

            if (advObject != null)
            {
                TweenCallback onComplete = () =>
                {
                    if (wait)
                    {
                        advEngine.Resume();
                    }
                };

                var ease = EnumExtensions.FindByName(easingType, Ease.Linear);

                var tweener = advObject.transform.DOLocalMoveZ(position, duration)
                              .SetEase(ease)
                              .OnComplete(onComplete);

                advEngine.SetTweenTimeScale(tweener);
            }

            return(wait ? YieldWait : DynValue.Nil);
        }
Пример #3
0
        private DynValue CommandFunction(string identifier, float duration = 0, string easingType = null, bool wait = true)
        {
            var returnValue = DynValue.Nil;

            try
            {
                var advEngine = AdvEngine.Instance;

                var advObject = advEngine.ObjectManager.Get <AdvObject>(identifier);

                if (advObject == null)
                {
                    return(DynValue.Nil);
                }

                var canvasGroup = UnityUtility.GetComponent <CanvasGroup>(advObject);

                if (canvasGroup != null)
                {
                    if (duration != 0)
                    {
                        TweenCallback onComplete = () =>
                        {
                            UnityUtility.SetActive(advObject, false);

                            if (wait)
                            {
                                advEngine.Resume();
                            }
                        };

                        var ease = EnumExtensions.FindByName(easingType, Ease.Linear);

                        var tweener = canvasGroup.DOFade(0f, duration)
                                      .SetEase(ease)
                                      .OnComplete(onComplete);

                        advEngine.SetTweenTimeScale(tweener);

                        returnValue = wait ? YieldWait : DynValue.Nil;
                    }
                    else
                    {
                        canvasGroup.alpha = 0f;

                        UnityUtility.SetActive(advObject, false);
                    }
                }
                else
                {
                    UnityUtility.SetActive(advObject, false);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(returnValue);
        }
Пример #4
0
        private DynValue CommandFunction(string identifier, string patternName, Vector2 pos, int?priority = null,
                                         float duration = 0, string easingType = null, bool wait = true)
        {
            var returnValue = DynValue.Nil;

            try
            {
                var advEngine = AdvEngine.Instance;

                var advCharacter = advEngine.ObjectManager.Get <AdvCharacter>(identifier);

                if (advCharacter != null)
                {
                    advCharacter.SetPriority(priority.HasValue ? priority.Value : 0);

                    advCharacter.Show(patternName);

                    advCharacter.transform.localPosition = pos;
                }

                var canvasGroup = UnityUtility.GetComponent <CanvasGroup>(advCharacter);

                if (canvasGroup != null)
                {
                    if (duration != 0)
                    {
                        TweenCallback onComplete = () =>
                        {
                            if (wait)
                            {
                                advEngine.Resume();
                            }
                        };

                        var ease = EnumExtensions.FindByName(easingType, Ease.Linear);

                        canvasGroup.alpha = 0f;

                        var tweener = canvasGroup.DOFade(1f, duration)
                                      .SetEase(ease)
                                      .OnComplete(onComplete);

                        advEngine.SetTweenTimeScale(tweener);

                        returnValue = wait ? YieldWait : DynValue.Nil;
                    }
                    else
                    {
                        canvasGroup.alpha = 1f;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(returnValue);
        }
Пример #5
0
        private DynValue CommandFunction(string identifier, string fileIdentifier, Vector2?size, int?priority = null,
                                         float duration = 0, string easingType = null, bool wait = true)
        {
            var returnValue = DynValue.Nil;

            var advEngine = AdvEngine.Instance;

            var advSprite = advEngine.ObjectManager.Create <AdvSprite>(identifier);

            var fileName = advEngine.Resource.FindFileName <AdvSprite>(fileIdentifier);

            if (advSprite != null)
            {
                advSprite.SetPriority(priority.HasValue ? priority.Value : 0);

                var width  = size.HasValue ? (float?)size.Value.x : null;
                var height = size.HasValue ? (float?)size.Value.y : null;

                advSprite.Show(fileName, width, height);
            }

            var canvasGroup = UnityUtility.GetComponent <CanvasGroup>(advSprite);

            if (canvasGroup != null)
            {
                if (duration != 0)
                {
                    TweenCallback onComplete = () =>
                    {
                        if (wait)
                        {
                            advEngine.Resume();
                        }
                    };

                    var ease = EnumExtensions.FindByName(easingType, Ease.Linear);

                    canvasGroup.alpha = 0f;

                    var tweener = canvasGroup.DOFade(1f, duration)
                                  .SetEase(ease)
                                  .OnComplete(onComplete);

                    advEngine.SetTweenTimeScale(tweener);

                    returnValue = wait ? YieldWait : DynValue.Nil;
                }
                else
                {
                    canvasGroup.alpha = 1f;
                }
            }

            return(returnValue);
        }
Пример #6
0
        private DynValue CommandFunction(string identifier, float rotation, float duration = 0, string easingType = null, bool wait = true)
        {
            var returnValue = DynValue.Nil;

            try
            {
                var advEngine = AdvEngine.Instance;

                var advObject = advEngine.ObjectManager.Get <AdvObject>(identifier);

                if (advObject != null)
                {
                    TweenCallback onComplete = () =>
                    {
                        if (wait)
                        {
                            advEngine.Resume();
                        }
                    };

                    var angles = advObject.transform.localEulerAngles;

                    angles.x = rotation;

                    var ease = EnumExtensions.FindByName(easingType, Ease.Linear);

                    var tweener = advObject.transform.DOLocalRotate(angles, duration)
                                  .SetEase(ease)
                                  .OnComplete(onComplete);

                    advEngine.SetTweenTimeScale(tweener);
                }

                returnValue = wait ? YieldWait : DynValue.Nil;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(returnValue);
        }