protected override void LoadScene()
        {
            // Preload stars
            starSpriteIndices.Add(MainSceneImages.FindImageIndex("star0"));
            starSpriteIndices.Add(MainSceneImages.FindImageIndex("star1"));
            starSpriteIndices.Add(MainSceneImages.FindImageIndex("star2"));
            starSpriteIndices.Add(MainSceneImages.FindImageIndex("star3"));
            borderStarSpriteIndices.Add(MainSceneImages.FindImageIndex("bstar0"));
            borderStarSpriteIndices.Add(MainSceneImages.FindImageIndex("bstar1"));
            borderStarSpriteIndices.Add(MainSceneImages.FindImageIndex("bstar2"));
            borderStarSpriteIndices.Add(MainSceneImages.FindImageIndex("bstar3"));

            // Create space ships
            var random = new Random();

            for (var i = 0; i < ShipNameList.Count; i++)
            {
                shipList.Add(new SpaceShip
                {
                    Name     = ShipNameList[i],
                    Power    = random.Next(MaximumStar + 1),
                    Control  = random.Next(MaximumStar + 1),
                    Speed    = random.Next(MaximumStar + 1),
                    IsLocked = (i % 3) == 2,
                });
            }

            // Initialize UI
            page = Entity.Get <UIComponent>().Page;
            InitializeMainPage();
            InitializeShipSelectionPopup();
            InitializeWelcomePopup();

            // Add pop-ups to the overlay
            var overlay = (UniformGrid)page.RootElement;

            overlay.Children.Add(shipSelectPopup);
            overlay.Children.Add(welcomePopup);

            Script.AddTask(FillLifeBar);
        }
        private UIElement CreateShipSelectionItem(SpaceShip spaceShip)
        {
            var shipPanel  = UILibrary.InstantiateElement <Panel>("ShipButton");
            var shipButton = shipPanel.FindVisualChildOfType <ButtonBase>("shipButton");
            var shipImage  = shipButton.FindVisualChildOfType <ImageElement>("shipImage");

            // Update spaceship
            spaceShip.PowerImageElement   = shipButton.FindVisualChildOfType <ImageElement>("powerImage");
            spaceShip.ControlImageElement = shipButton.FindVisualChildOfType <ImageElement>("controlImage");
            spaceShip.SpeedImageElement   = shipButton.FindVisualChildOfType <ImageElement>("speedImage");

            var shipIndex = MainSceneImages.FindImageIndex(spaceShip.Name);

            ((SpriteFromSheet)shipImage.Source).CurrentFrame = shipIndex;

            shipButton.Click += delegate
            {
                activeShipIndex = shipList.FindIndex(w => w.Name == spaceShip.Name);
                ((SpriteFromSheet)currentShipImage.Source).CurrentFrame = shipIndex;

                PowerStatus   = spaceShip.Power;
                ControlStatus = spaceShip.Control;
                SpeedStatus   = spaceShip.Speed;

                CloseShipSelectPopup();
            };
            shipButton.IsEnabled = !spaceShip.IsLocked;

            if (spaceShip.IsLocked)
            {
                var lockIconElement = shipPanel.FindVisualChildOfType <ImageElement>("lockIcon");
                lockIconElement.Visibility = Visibility.Visible;
            }

            return(shipPanel);
        }