public override void OnExit() { ColorIcon.Destroy(); BackButton.UnregisterPalette(); PlayButton.UnregisterPalette(); LevelSelectItem.LevelSelectionDetected -= HandleLevelSelectItemLevelSelectionDetected; BackButton.ButtonUpAction -= HandleBackButtonButtonUpAction; PlayButton.ButtonUpAction -= HandlePlayButtonButtonUpAction; this.SwipePanels.OnSwipeComplete -= HandleSwipePanelshandleOnSwipeComplete; base.OnExit (); MenuSystem = null; Panels.Clear(); this.SwipePanels = null; LevelSelectTitleText = null; LevelSelectInstructionsText = null; BlackBlock1 = null; BlackBlock2 = null; BackButton = null; PlayButton = null; for (int i=0; i < Icons.Length; i++){ Icons[i] = null; } Icons = null; // Solutions.Clear(); Solutions = null; }
// CONSTRUCTOR ---------------------------------------------------------------------------------------------------------------------- public LevelSelectScreen(MenuSystemScene pMenuSystem) { SelectedLevel = 0; var init = ColorIcon.Instance; MenuSystem = pMenuSystem; var pages = FMath.Ceiling((GameScene.TOTAL_LEVELS-1) / (float)LevelPage.ITEMS_PER_PAGE); Panels = new List<Node>{}; for (int i=0; i < pages; i++) { Panels.Add( new LevelPage(i) ); (Panels[i] as LevelPage).Disable(); } (Panels[0] as LevelPage).Enable(); this.SwipePanels = new SwipePanels(Panels) { Width = 457.0f, Position = new Vector2(95.0f,46.0f) }; Indicator = new LevelSelectIndicator(); // BLACK MASKS TO HIDE MORE LEVELS BEHIND BlackBlock1 = Support.UnicolorSprite("white", 255,255,255,255); BlackBlock1.Color = Support.ExtractColor("333330"); BlackBlock1.Scale = new Vector2(361.0f/16.0f, Director.Instance.GL.Context.Screen.Height/16.0f); BlackBlock1.Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f); BlackBlock2 = Support.UnicolorSprite("white", 255,255,255,255); BlackBlock2.Color = LevelManager.Instance.BackgroundColor; BlackBlock2.Position = Vector2.Zero; BlackBlock2.Scale = new Vector2(50.0f/16.0f, Director.Instance.GL.Context.Screen.Height/16.0f); BlackBlock3 = Support.UnicolorSprite("white", 255,255,255,255); BlackBlock3.Color = Support.ExtractColor("333330"); BlackBlock3.Scale = new Vector2(361.0f/16.0f, 115.0f/16.0f); BlackBlock3.Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, Director.Instance.GL.Context.Screen.Height - 115.0f); BlackBlock4 = Support.UnicolorSprite("white", 255,255,255,255); BlackBlock4.Color = Support.ExtractColor("333330"); BlackBlock4.Scale = new Vector2(361.0f/16.0f, 253.0f/16.0f); BlackBlock4.Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f); LevelNumberText = new Label(){ Text = SelectedLevel.ToString(), Position = new Vector2(Director.Instance.GL.Context.Screen.Width-339.0f, Director.Instance.GL.Context.Screen.Height-78.0f), FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 64, "Bold") ), Color = LevelManager.Instance.BackgroundColor }; // CenterText(LevelNumberText); // SolutionPanel = new HudPanel(){ // }; PossibleSolutionsText = new Label(){ Text = "possible solutions", Position = new Vector2(Director.Instance.GL.Context.Screen.Width - 339.0f, Director.Instance.GL.Context.Screen.Height-100.0f), FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ), Color = LevelManager.Instance.BackgroundColor }; Solutions = new SolutionSlider(); // Solutions = new List<SolutionIcon>(); //{ // new SolutionIcon(){ // CubeText = "99", // ScoreText = "88" // }, // new SolutionIcon(){ // CubeText = "99", // ScoreText = "88" // }, // new SolutionIcon(){ // CubeText = "99", // ScoreText = "88" // }, // new SolutionIcon(){ // CubeText = "99", // ScoreText = "88" // }, // new SolutionIcon(){ // CubeText = "99", // ScoreText = "88" // } // }; // for( int i=0; i < Solutions.Count; i++) { // Solutions[i].Visible = false; // var column = i % 4; // var row = ( i - column ) / 4; // Solutions[i].Position = new Vector2(Director.Instance.GL.Context.Screen.Width - 339.0f + 60.0f * column, // Director.Instance.GL.Context.Screen.Height - 200.0f - row * 80.0f); // this.AddChild(Solutions[i]); // } QualitiesText = new Label() { Text = "qualities", Position = new Vector2(623.0f, 223.0f), FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ), Color = LevelManager.Instance.BackgroundColor }; // CompletionPercentageText = new Label() { // Text = (1.0f).ToString("P0"), // Position = new Vector2(638.0f, 150.0f), // FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ), //// Color = new Vector4( 0.16078431f, 0.88627451f, 0.88627451f, 1.0f) // }; // CenterText(CompletionPercentageText); // this.AddChild(CompletionPercentageText); Icons = new Node[4]; IconLabels = new Label[4]; for( int i=0; i < Icons.Length; i++) { Icons[i] = Support.TiledSpriteFromFile("/Application/assets/images/icons/icons.png", 4, 2); Icons[i].Position = new Vector2(623.0f + 68.0f * (float)i, 2.0f * BUTTON_HEIGHT + 20.0f); // Icons[i].Scale = new Vector2(0.25f, 0.25f); IconLabels[i] = new Label() { FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Bold") ), Color = LevelManager.Instance.BackgroundColor }; } LevelSelectTitleText = new Label(){ Text="level select", Position = new Vector2(50.0f, 488.0f), FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Regular") ), Color = Support.ExtractColor("333330") }; LevelSelectInstructionsText = new Label(){ Text="select a cube and then press play.", Position = new Vector2(50.0f, 465.0f), FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Regular") ), Color = Support.ExtractColor("333330") }; BackButton = new BetterButton(361.0f, BUTTON_HEIGHT) { Text = "back", Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, BUTTON_HEIGHT) }; BackButton.background.RegisterPalette(2); PlayButton = new BetterButton(361.0f, BUTTON_HEIGHT) { Text = "play", Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f) }; PlayButton.background.RegisterPalette(1); // SWIPE LAYER this.AddChild(this.SwipePanels); foreach( LevelPage panel in Panels) { this.AddChild(panel); } (Panels[0] as LevelPage).Items[0].AddChild(Indicator); // UI LAYERS BackLayer = new Layer(); this.AddChild(BackLayer); FrontLayer = new Layer(); this.AddChild(FrontLayer); // BACK LAYER ELEMENTS BackLayer.AddChild(BlackBlock1); BackLayer.AddChild(BlackBlock2); BackLayer.AddChild(Solutions); // FRONT LAYER ELEMENTS FrontLayer.AddChild(BlackBlock3); FrontLayer.AddChild(BlackBlock4); FrontLayer.AddChild(LevelNumberText); FrontLayer.AddChild(PossibleSolutionsText); FrontLayer.AddChild(QualitiesText); for( int i=0; i < Icons.Length; i++) { FrontLayer.AddChild(Icons[i]); } FrontLayer.AddChild(LevelSelectTitleText); FrontLayer.AddChild(LevelSelectInstructionsText); FrontLayer.AddChild(BackButton); FrontLayer.AddChild(PlayButton); }