private void Awake() { _fire = UiHelper.CreateAnimatedObject("fire", @"data\global\ui\FrontEnd\fire", PaletteType.Fechar, Materials.SoftAdditive, sortingOrder: 15); _fire.transform.position = UiHelper.ScreenToWorldPoint(firePlaceholder.position); _fire.transform.parent = firePlaceholder; foreach (var classSelector in FindObjectsOfType <ClassSelector>()) { classSelector.OnEnter += info => { if (_selected == null) { classNameText.text = info.ClassName; classDescriptionText.text = info.Description; } }; classSelector.OnExit += info => { if (_selected == null) { classNameText.text = string.Empty; classDescriptionText.text = string.Empty; } }; classSelector.OnClick += info => { if (!_clickable) { return; } _clickable = false; if (_selected != null) { if (Equals(_selected, classSelector)) { UpdateUi(classSelector, string.Empty, string.Empty, null, true); return; } _selected.Toggle(); } UpdateUi(classSelector, info.ClassName, info.Description, classSelector, false); }; classSelector.OnStateChanged += sender => { if (_selected == null || Equals(_selected, sender)) { _clickable = true; } }; } okButton.OnClick += OnOkClick; okButton.Disabled = true; }
private static GameObject CreateLogo() { var logo = new GameObject("logo"); var left = UiHelper.CreateAnimatedObject("leftLogo", @"data\global\ui\FrontEnd\d2LogoFireLeft", material: Materials.softAdditive, sortingOrder: 1); var right = UiHelper.CreateAnimatedObject("rightLogo", @"data\global\ui\FrontEnd\d2LogoFireRight", material: Materials.softAdditive, sortingOrder: 1); left.transform.SetParent(logo.transform, false); right.transform.SetParent(logo.transform, false); return(logo); }
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); }