Beispiel #1
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (OnClick != null)
     {
         var classInfo = ClassSelectInfo.Find(_className);
         OnClick(classInfo);
     }
 }
Beispiel #2
0
 public void OnPointerExit(PointerEventData eventData)
 {
     ToggleHover(false);
     if (OnExit != null)
     {
         var classInfo = ClassSelectInfo.Find(_className);
         OnExit(classInfo);
     }
 }
Beispiel #3
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     ToggleHover(true);
     if (OnEnter != null)
     {
         var classInfo = ClassSelectInfo.Find(_className);
         OnEnter(classInfo);
     }
 }
Beispiel #4
0
        private void Awake()
        {
            _className     = name;
            _rectTransform = GetComponent <RectTransform>();

            var classAnimationInfo            = ClassSelectInfo.Find(_className);
            var classPath                     = $@"{BasePath}\{classAnimationInfo.ClassName}\{classAnimationInfo.Token}";
            var backTransitionSprites         = Spritesheet.Load($"{classPath}BW", PaletteType.Fechar);
            var backIdleSprites               = Spritesheet.Load($"{classPath}NU1", PaletteType.Fechar);
            var backIdleHoverSprites          = Spritesheet.Load($"{classPath}NU2", PaletteType.Fechar);
            var backTransitionOverlaySprites  = classAnimationInfo.HasBackTransitionOverlay ? Spritesheet.Load($@"{classPath}BWs", PaletteType.Fechar) : null;
            var frontTransitionSprites        = Spritesheet.Load($"{classPath}FW", PaletteType.Fechar);
            var frontIdleSprites              = Spritesheet.Load($"{classPath}NU3", PaletteType.Fechar);
            var frontTransitionOverlaySprites = classAnimationInfo.HasFrontTransitionOverlay ? Spritesheet.Load($@"{classPath}FWs", PaletteType.Fechar) : null;
            var frontIdleOverlaySprites       = classAnimationInfo.HasFrontIdleOverlay ? Spritesheet.Load($@"{classPath}NU3s", PaletteType.Fechar) : null;
            var frontTransitionSfxPath        = $@"data\global\sfx\cursor\intro\{classAnimationInfo.ClassName} select.wav";
            var backTransitionSfxPath         = $@"data\global\sfx\cursor\intro\{classAnimationInfo.ClassName} deselect.wav";

            _states = new Dictionary <ClassSelectorState, ClassSelectorStateInfo>
            {
                {
                    ClassSelectorState.BackIdle,
                    new ClassSelectorStateInfo
                    {
                        Sprites           = backIdleSprites.GetSprites(0),
                        HoverSprites      = backIdleHoverSprites.GetSprites(0),
                        OverlaySprites    = null,
                        Loop              = true,
                        HideOnFinish      = false,
                        SortingOrderShift = -10,
                        Fps = classAnimationInfo.BackIdleFps
                    }
                },
                {
                    ClassSelectorState.FrontIdle,
                    new ClassSelectorStateInfo
                    {
                        Sprites           = frontIdleSprites.GetSprites(0),
                        OverlaySprites    = frontIdleOverlaySprites?.GetSprites(0),
                        Loop              = true,
                        HideOnFinish      = false,
                        SortingOrderShift = 0,
                        Material          = classAnimationInfo.OverlayMaterial,
                        Fps = classAnimationInfo.FrontIdleFps
                    }
                },
                {
                    ClassSelectorState.BackTransition,
                    new ClassSelectorStateInfo
                    {
                        Sprites           = backTransitionSprites.GetSprites(0),
                        OverlaySprites    = backTransitionOverlaySprites?.GetSprites(0),
                        Loop              = false,
                        HideOnFinish      = true,
                        SortingOrderShift = 0,
                        Material          = classAnimationInfo.OverlayMaterial,
                        SfxPath           = backTransitionSfxPath,
                        Fps = 25
                    }
                },
                {
                    ClassSelectorState.FrontTransition,
                    new ClassSelectorStateInfo
                    {
                        Sprites           = frontTransitionSprites.GetSprites(0),
                        OverlaySprites    = frontTransitionOverlaySprites?.GetSprites(0),
                        Loop              = false,
                        HideOnFinish      = true,
                        SortingOrderShift = 10,
                        Material          = classAnimationInfo.OverlayMaterial,
                        SfxPath           = frontTransitionSfxPath,
                        Fps = 25
                    }
                }
            };

            var position = _rectTransform.position;

            _main = UiHelper.CreateAnimatedObject("main", loop: false, sortingOrder: classAnimationInfo.BaseSortingOrder);
            _main.transform.position = UiHelper.ScreenToWorldPoint(position);
            _main.transform.parent   = _rectTransform;

            _overlay = UiHelper.CreateAnimatedObject("overlay", loop: false, sortingOrder: classAnimationInfo.BaseSortingOrder + classAnimationInfo.OverlaySortingOrder);
            _overlay.transform.position = UiHelper.ScreenToWorldPoint(position);
            _overlay.transform.parent   = _rectTransform;

            _mainAnimator           = _main.GetComponent <SpriteAnimator>();
            _mainAnimator.OnFinish += MainAnimatorOnFinish;

            _overlayAnimator = _overlay.GetComponent <SpriteAnimator>();

            _sound = new GameObject("sound");
            _sound.transform.parent = _rectTransform;

            _audioSource      = _sound.AddComponent <AudioSource>();
            _audioSource.loop = false;

            ChangeState(ClassSelectorState.BackIdle);
        }