예제 #1
0
        private void Initialize()
        {
            FontMap map = FontManager.Instance.GetMap( FontManager.Instance.GetInGame("Bariol", 25, "Bold") );
            FontMap bigMap = FontManager.Instance.GetMap( FontManager.Instance.GetInGame("Bariol", 44, "Bold") );

            // CREATE PAUSE MENU
            pausePanel = new PausePanel(_scene);
            _scene.DialogLayer.AddChild(pausePanel);
            pausePanel.Hide();

            // CREATE THE HUD BAR AT THE TOP OF THE SCREEN
            GameHudBar = new Node(){
                Position = new Vector2(0.0f, 473.0f)
            };
            this.AddChild(GameHudBar);

            HudBarMask = Support.UnicolorSprite("white", 255, 255, 255, 255);
            HudBarMask.Color = LevelManager.Instance.BackgroundColor;
            HudBarMask.Scale = new Vector2(60.0f, 4.4375f);
            GameHudBar.AddChild(HudBarMask);

            // CREATE THE LEVEL TITLE HUD
            levelTitle = new LevelTitleMkTwo() {
                SlideInDirection = SlideDirection.RIGHT,
                SlideOutDirection = SlideDirection.LEFT,
                Offset = new Vector2(0.0f, 0.0f),
            //				Lifetime = 4.0f
            };
            this.AddChild(levelTitle, -1);

            // CREATE THE END-OF-LEVEL DROP-DOWN PANEL
            if (GameScene.currentLevel == 999) {
                // INFINITE MODE VERSION
                _nextLevelPanel = new InfiniteModeEndPanel(){
                    Offset = new Vector2(Director.Instance.GL.Context.Screen.Width-248.0f, 0.0f),

                };
            } else {
                // PUZZLE/TUTORIAL MODE VERSION
                _nextLevelPanel = new NextLevelPanel(){
                    Offset = new Vector2(510.0f, 0.0f),

                };
            }
            GameHudBar.AddChild(_nextLevelPanel, -1);

            // CREATE MESSAGE PANEL
            _messagePanel = new MessagePanel(920.0f, 148.0f ){
                SourceObject = this,
                Offset = new Vector2(20.0f, 0.0f),
                Position = new Vector2(0.0f, -148.0f),
                Lifetime = 0.0f
            };
            this.AddChild(_messagePanel);
            _messagePanel.body = GamePhysics.Instance.RegisterPhysicsBody(GamePhysics.Instance.SceneShapes[4], float.MaxValue, 0.0f, _messagePanel.Position / GamePhysics.PtoM);
            _messagePanel.AdHocDraw += () => {
                _messagePanel.body.Position = _messagePanel.Position / GamePhysics.PtoM;
            };

            // SCORE STUFF
            //			ScoreIcon = Support.SpriteFromFile("/Application/assets/images/handIcon.png");
            ScoreIcon = Support.SpriteFromAtlas("crystallonUI", "handIcon.png");
            ScoreIcon.Position = new Vector2(184.0f, 16.0f);
            ScoreIcon.RegisterPalette(1);
            GameHudBar.AddChild(ScoreIcon);

            ScoreTitleText = new Label("score", map);
            ScoreTitleText.Position = new Vector2(287, 25.0f);
            ScoreTitleText.RegisterPalette(1);

            BlueBox = Support.UnicolorSprite("white", 255,255,255,255);
            BlueBox.Scale = new Vector2(6.25f, 4.4375f);
            BlueBox.Position = new Vector2(354.0f, 0.0f);
            BlueBox.RegisterPalette(2);

            ScoreText = new Label("", bigMap) {
                Position = SCORE_TEXT_POS
            };
            ScoreText.RegisterPalette(1);
            GameHudBar.AddChild(ScoreText);

            // CUBE STUFF
            //			CubeIcon = Support.SpriteFromFile("/Application/assets/images/stopIcon.png");
            CubeIcon = Support.SpriteFromAtlas("crystallonUI", "stopIcon.png");
            CubeIcon.Position = new Vector2(20.0f,16.0f);
            CubeIcon.RegisterPalette(2);
            GameHudBar.AddChild(CubeIcon);

            CubesTitleText = new Label("cubes", map);
            CubesTitleText.Position = new Vector2(63.0f, 25.0f);
            CubesTitleText.RegisterPalette(2);

            RedBox = Support.UnicolorSprite("white", 255,255,255,255);
            RedBox.Position = new Vector2(130.0f, 0.0f);
            RedBox.Scale = new Vector2(6.25f, 4.4375f);
            RedBox.RegisterPalette(1);

            CubeText = new Label("", bigMap){
                Position = CUBES_TEXT_POS
            };
            CubeText.RegisterPalette(2);
            GameHudBar.AddChild(CubeText);

            // TIMER & STRIKES STUFF
            GameTimer = new TimerEntity();
            if (GameScene.currentLevel == 999) {	// ------------------- IF CHALLENGE MODE
                if(GameScene.gameTimeLimit > 0.0f) {
                    GameTimer.Position = new Vector2(348.0f, 16.0f);	// ----- ADD THE TIME BAR
                    GameHudBar.AddChild(GameTimer);
                } else {
                    BonusBar = new BonusTimer() {
            //						Position = new Vector2(348.0f, 44.0f)
                        Position = new Vector2(348.0f, 16.0f)
                    };
                    GameHudBar.AddChild(BonusBar);
                }

                Strikes = new StrikeHud() {
                    Position = new Vector2(395.0f, 44.0f)
                };
                GameHudBar.AddChild(Strikes);
            }

            // PAUSE BUTTON
            PauseButton = new BetterButton("/Application/assets/images/UI/BetterButtonTransparent.png", 115.0f, 71.0f) {
                Text = "",
            //				Icon = Support.SpriteFromFile("Application/assets/images/UI/pause.png"),
                Icon = Support.SpriteFromAtlas("crystallonUI", "pause.png"),
            //				Position = new Vector2(845.0f, 473.0f),
                Position = new Vector2(845.0f, 0.0f)
            };
            //			this.AddChild(PauseButton);
            GameHudBar.AddChild(PauseButton);
            PauseButton.background.RegisterPalette(2);
            PauseButton.background.Scale = new Vector2(115.0f/32.0f, 71.0f/16.0f);
            PauseButton.Icon.RegisterPalette(2);
            PauseButton.ButtonUpAction += HandlePauseButtonButtonUpAction;

            // HIT ME BUTTON
            HitMeButton = new BetterButton("/Application/assets/images/UI/BetterButtonTransparent.png", 115.0f, 71.0f) {
                Text = "",
            //				Icon = Support.SpriteFromFile("Application/assets/images/UI/plus.png"),
                Icon = Support.SpriteFromAtlas("crystallonUI", "plus.png"),
            //				Position = new Vector2(720.0f, 473.0f),
                Position = new Vector2(720.0f, 0.0f)
            };
            HitMeButton.On(!LevelManager.Instance.HitMeDisabled);
            //			this.AddChild(HitMeButton);
            GameHudBar.AddChild(HitMeButton);
            HitMeButton.background.RegisterPalette(1);
            HitMeButton.background.Scale = new Vector2(115.0f/32.0f, 71.0f/16.0f);
            HitMeButton.Icon.RegisterPalette(1);
            HitMeButton.ButtonUpAction += HandleHitMeButtonButtonUpAction;

            HudBarLine = Support.UnicolorSprite("white", 255, 255, 255, 255);
            HudBarLine.RegisterPalette(0);
            HudBarLine.Scale = new Vector2(60.0f, 0.125f);
            GameHudBar.AddChild(HudBarLine);

            _initialized = true;
        }
예제 #2
0
        public override void OnExit()
        {
            base.OnExit();

            HitMeButton.ButtonUpAction -= HandleHitMeButtonButtonUpAction;
            PauseButton.ButtonUpAction -= HandlePauseButtonButtonUpAction;
            QualityManager.MatchScoreDetected -= HandleQualityManagerMatchScoreDetected;
            QualityManager.FailedMatchDetected -= HandleQualityManagerFailedMatchDetected;
            CardManager.Instance.NoMatchesPossibleDetected -= HandleCardManagerInstanceNoMatchesPossibleDetected;
            GameScene.LevelChangeDetected -= HandleGameSceneLevelChangeDetected;
            GroupCrystallonEntity.BreakDetected -= HandleGroupCrystallonEntityBreakDetected;
            PausePanel.QuitButtonPressDetected -= HandlePausePanelQuitButtonPressDetected;
            PausePanel.ResetButtonPressDetected -= HandlePausePanelResetButtonPressDetected;
            CubeCrystallonEntity.CubeCompleteDetected -= HandleCubeCrystallonEntityCubeCompleteDetected;
            CardManager.Instance.CardSpawned -= HandleCardManagerInstanceCardSpawned;
            if(GameScene.currentLevel == 999) {
                GameTimer.BarEmptied -= HandleGameTimerBarEmptied;
                GameTimer.BarFilled -= HandleGameTimerBarFilled;
                if (BonusBar != null) {
                    BonusBar.BarFilled -= HandleBonusBarBarFilled;
                    BonusBar.BarEmptied -= HandleBonusBarBarEmptied;
                }
                (_nextLevelPanel as InfiniteModeEndPanel).RetryDetected -= HandlePausePanelResetButtonPressDetected;
                (_nextLevelPanel as InfiniteModeEndPanel).QuitDetected -= Handle_nextLevelPanelQuitButtonPressDetected;
            } else {
                (_nextLevelPanel as NextLevelPanel).ReplayDetected -= HandlePausePanelResetButtonPressDetected;
                (_nextLevelPanel as NextLevelPanel).NextLevelDetected -= Handle_nextLevelPanelButtonButtonUpAction;
                (_nextLevelPanel as NextLevelPanel).QuitDetected -= Handle_nextLevelPanelQuitButtonPressDetected;
                (_nextLevelPanel as NextLevelPanel).LevelSelectDetected -= Handle_nextLevelPanelLevelSelectDetected;
            }

            _nextLevelPanel = null;
            HitMeButton = null;
            PauseButton = null;
            pausePanel = null;
            levelTitle = null;
            _messagePanel = null;
            _scene = null;

            #if METRICS
            if(ExitCode == LevelExitCode.NULL){
                DataStorage.CollectMetrics();
            }
            DataStorage.RemoveMetric("Goal");
            DataStorage.RemoveMetric("Score");
            DataStorage.RemoveMetric("Time");
            DataStorage.RemoveMetric("No-Match Time");
            DataStorage.RemoveMetric("Met-Goal Time");
            DataStorage.RemoveMetric("Breaks");
            DataStorage.RemoveMetric("Hit Me");
            DataStorage.RemoveMetric("Exit Code");
            #endif
        }