Last active
December 17, 2015 15:39
-
-
Save AlexTiTanium/5633132 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using UnityEngine; | |
| using System.Collections; | |
| public class VictoryDialog : GuiDialog | |
| { | |
| const string ANIMATOR_ACTION = "AnimatorAction"; | |
| //************************************************************************** | |
| // | |
| // MonoBehaviour | |
| // | |
| //************************************************************************** | |
| //************************************************************************** | |
| // | |
| // Events | |
| // | |
| //************************************************************************** | |
| void OnGameAction(GameAction action) | |
| { | |
| if(action == GameAction.ShowMenu) { | |
| SlideDown(); | |
| } | |
| } | |
| //************************************************************************** | |
| // Victory btn restart | |
| void VictoryRestart() | |
| { | |
| CloseDialogAndDoAction(() => | |
| { | |
| GameObject.FindWithTag(Const.TAG_LEVEL).SendMessage("HideMenu"); | |
| GameObject.FindWithTag(Const.TAG_LEVEL).SendMessage("Restart"); | |
| }); | |
| } | |
| //************************************************************************** | |
| // | |
| // Abstract | |
| // | |
| //************************************************************************** | |
| protected override void OnSlideDownComplite() | |
| { | |
| OpenDialog(); | |
| } | |
| //************************************************************************** | |
| // | |
| // Private | |
| // | |
| //************************************************************************** | |
| private void CloseDialogAndDoAction(Action onComplete) | |
| { | |
| SlideUpStarsBlock(() => SlideUpBottomBlock(onComplete)); | |
| } | |
| private void OpenDialog() | |
| { | |
| SlideDownBottomBlock(() => SlideDownStarsBlock()); | |
| } | |
| //************************************************************************** | |
| // | |
| // Animations bottom block, where buttons | |
| // | |
| //************************************************************************** | |
| private void SlideDownBottomBlock(Action onComplete) | |
| { | |
| AnimatorConfig animatorConf = new AnimatorConfig("bottom_block", "SlideDown"); | |
| animatorConf.setOnStartHandler(tween => { | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_bobbins_left", "BeginRotation")); | |
| }); | |
| animatorConf.setOnCompleteHandler(tween => { | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_bobbins_left", "StopRotation")); | |
| onComplete.Invoke(); | |
| }); | |
| BroadcastMessage(ANIMATOR_ACTION, animatorConf); | |
| } | |
| private void SlideUpBottomBlock(Action onComplete) | |
| { | |
| AnimatorConfig animatorConf = new AnimatorConfig("bottom_block", "SlideUp"); | |
| animatorConf.setOnStartHandler(tween => { | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_bobbins_left", "BeginRotationBackward")); | |
| }); | |
| animatorConf.setOnCompleteHandler(tween => { | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_bobbins_left", "StopRotation")); | |
| SlideUp(onComplete.Invoke); | |
| }); | |
| BroadcastMessage(ANIMATOR_ACTION, animatorConf); | |
| } | |
| //************************************************************************** | |
| // | |
| // Animations stars and time block | |
| // | |
| //************************************************************************** | |
| private void SlideDownStarsBlock() | |
| { | |
| AnimatorConfig animatorConf = new AnimatorConfig("star_block", "SlideDown"); | |
| animatorConf.setOnStartHandler(tween => { | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_bobbins_right", "BeginRotation")); | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("stars_left_cogwheels", "BeginRotation")); | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_star_rope", "BeginOffsetAnimation")); | |
| }); | |
| animatorConf.setOnCompleteHandler(tween => { | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_bobbins_right", "StopRotation")); | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("stars_left_cogwheels", "StopRotation")); | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_star_rope", "Stop")); | |
| }); | |
| BroadcastMessage(ANIMATOR_ACTION, animatorConf); | |
| } | |
| private void SlideUpStarsBlock(Action onComplete) | |
| { | |
| AnimatorConfig animatorConf = new AnimatorConfig("star_block", "SlideUp"); | |
| animatorConf.setOnStartHandler(tween => { | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_bobbins_right", "BeginRotationBackward")); | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("stars_left_cogwheels", "BeginRotationBackward")); | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_star_rope", "BeginOffsetAnimationBackward")); | |
| }); | |
| animatorConf.setOnCompleteHandler(tween => { | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_bobbins_right", "StopRotation")); | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("stars_left_cogwheels", "StopRotation")); | |
| BroadcastMessage(ANIMATOR_ACTION, new AnimatorConfig("top_star_rope", "Stop")); | |
| onComplete.Invoke(); | |
| }); | |
| BroadcastMessage(ANIMATOR_ACTION, animatorConf); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment