Example #1
0
        void CreateUpgradeBars()
        {
            var contBase = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Garage.ContBase.ResourcePath);

            // UPDGRADES
            _contUpgrade         = _root.CreateSprite();
            _contUpgrade.Texture = contBase;
            _contUpgrade.SetSize((int)(_dim.XScreenRatio * 1200), (int)(_dim.YScreenRatio * 300));
            _contUpgrade.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 750));
            _contUpgrade.ImageRect = AssetsCoordinates.Generic.Garage.ContBase.TrasparentItem;

            _performanceBar = new BorderImage();
            _contUpgrade.AddChild(_performanceBar);
            _performanceBar.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            _performanceBar.ImageRect = AssetsCoordinates.Generic.Boxes.BoxPerformanceUpgrade;
            _performanceBar.SetSize((int)(_dim.XScreenRatio * 550), (int)(_dim.YScreenRatio * 95));
            _performanceBar.SetPosition((int)(_dim.XScreenRatio * 1000), (int)(_dim.YScreenRatio * 100));



            _suspensionsBar = new BorderImage();
            _contUpgrade.AddChild(_suspensionsBar);
            _suspensionsBar.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            _suspensionsBar.ImageRect = AssetsCoordinates.Generic.Boxes.BoxSuspensionUpgrade;
            _suspensionsBar.SetSize((int)(_dim.XScreenRatio * 550), (int)(_dim.YScreenRatio * 95));
            _suspensionsBar.SetPosition((int)(_dim.XScreenRatio * 1000), (int)(_dim.YScreenRatio * 200));

            _wheelBar = new BorderImage();
            _contUpgrade.AddChild(_wheelBar);
            _wheelBar.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            _wheelBar.ImageRect = AssetsCoordinates.Generic.Boxes.BoxWheelUpgrade;
            _wheelBar.SetSize((int)(_dim.XScreenRatio * 550), (int)(_dim.YScreenRatio * 95));
            _wheelBar.SetPosition((int)(_dim.XScreenRatio * 440), (int)(_dim.YScreenRatio * 100));

            _brakeBar = new BorderImage();
            _contUpgrade.AddChild(_brakeBar);
            _brakeBar.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            _brakeBar.ImageRect = AssetsCoordinates.Generic.Boxes.BoxBrakeUpgrade;
            _brakeBar.SetSize((int)(_dim.XScreenRatio * 550), (int)(_dim.YScreenRatio * 95));
            _brakeBar.SetPosition((int)(_dim.XScreenRatio * 440), (int)(_dim.YScreenRatio * 200));

            // COMPONENTS
            _contComponents         = _root.CreateSprite();
            _contComponents.Texture = contBase;
            _contComponents.SetSize(_dim.SetX(1920), _dim.SetY(300));
            _contComponents.SetPosition(_dim.SetX(0), _dim.SetY(720));
            _contComponents.ImageRect = new IntRect(0, 0, 56, 56);

            Body = new BorderImage();
            _contComponents.AddChild(Body);
            Body.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            Body.ImageRect = AssetsCoordinates.Generic.Boxes.ComponentBodyRed;
            Body.SetSize(_dim.SetX(150), _dim.SetY(150));
            Body.SetPosition(_dim.SetX(-300), _dim.SetY(150));
            Body.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top);

            Engine = new BorderImage();
            _contComponents.AddChild(Engine);
            Engine.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            Engine.ImageRect = AssetsCoordinates.Generic.Boxes.ComponentEngineRed;
            Engine.SetSize(_dim.SetX(150), _dim.SetY(150));
            Engine.SetPosition(_dim.SetX(-130), _dim.SetY(150));
            Engine.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top);

            Suspensions = new BorderImage();
            _contComponents.AddChild(Suspensions);
            Suspensions.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            Suspensions.ImageRect = AssetsCoordinates.Generic.Boxes.ComponentSuspensionRed;
            Suspensions.SetSize(_dim.SetX(150), _dim.SetY(150));
            Suspensions.SetPosition(_dim.SetX(130), _dim.SetY(150));
            Suspensions.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top);

            Wheel = new BorderImage();
            _contComponents.AddChild(Wheel);
            Wheel.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            Wheel.ImageRect = AssetsCoordinates.Generic.Boxes.ComponentWheelRed;
            Wheel.SetSize(_dim.SetX(150), _dim.SetY(150));
            Wheel.SetPosition(_dim.SetX(300), _dim.SetY(150));
            Wheel.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top);


            // UPDGRADES
            _contUpgradeCost         = _root.CreateSprite();
            _contUpgradeCost.Texture = contBase;
            _contUpgradeCost.SetSize((int)(_dim.XScreenRatio * 1200), (int)(_dim.YScreenRatio * 300));
            _contUpgradeCost.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 750));
            _contUpgradeCost.ImageRect = AssetsCoordinates.Generic.Garage.ContBase.TrasparentItem;

            _performanceCost = new BorderImage();
            _contUpgradeCost.AddChild(_performanceCost);
            _performanceCost.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _performanceCost.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeCost;
            _performanceCost.SetSize((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 90));
            _performanceCost.SetPosition((int)(_dim.XScreenRatio * 1550), (int)(_dim.YScreenRatio * 100));

            _performanceUpBtn = new Button();
            _performanceCost.AddChild(_performanceUpBtn);
            _performanceUpBtn.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _performanceUpBtn.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeRight;
            _performanceUpBtn.SetSize((int)(_dim.XScreenRatio * 85), (int)(_dim.YScreenRatio * 90));
            _performanceUpBtn.SetPosition((int)(_dim.XScreenRatio * 100), (int)(_dim.YScreenRatio * 0));
            _performanceUpBtn.Pressed += args => {
                UpgradeComponent(0);
            };

            perCost = new Text();
            _performanceCost.AddChild(perCost);
            perCost.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 0));
            perCost.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            perCost.SetFont(_font, _dim.XScreenRatio * 20);
            perCost.SetColor(Color.Black);

            _wheelCost = new BorderImage();
            _contUpgradeCost.AddChild(_wheelCost);
            _wheelCost.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _wheelCost.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeCost;
            _wheelCost.SetSize((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 90));
            _wheelCost.SetPosition((int)(_dim.XScreenRatio * 345), (int)(_dim.YScreenRatio * 100));

            _wheelUpBtn = new Button();
            _wheelCost.AddChild(_wheelUpBtn);
            _wheelUpBtn.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _wheelUpBtn.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeLeft;
            _wheelUpBtn.SetSize((int)(_dim.XScreenRatio * 85), (int)(_dim.YScreenRatio * 90));
            _wheelUpBtn.SetPosition((int)(_dim.XScreenRatio * -100), (int)(_dim.YScreenRatio * 0));
            _wheelUpBtn.Pressed += args => {
                UpgradeComponent(1);
            };

            wheCost = new Text();
            _wheelCost.AddChild(wheCost);
            wheCost.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 0));
            wheCost.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            wheCost.SetFont(_font, _dim.XScreenRatio * 20);
            wheCost.SetColor(Color.Black);

            _suspensionsCost = new BorderImage();
            _contUpgradeCost.AddChild(_suspensionsCost);
            _suspensionsCost.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _suspensionsCost.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeCost;
            _suspensionsCost.SetSize((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 90));
            _suspensionsCost.SetPosition((int)(_dim.XScreenRatio * 1550), (int)(_dim.YScreenRatio * 200));

            _suspensionsUpBtn = new Button();
            _suspensionsCost.AddChild(_suspensionsUpBtn);
            _suspensionsUpBtn.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _suspensionsUpBtn.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeRight;
            _suspensionsUpBtn.SetSize((int)(_dim.XScreenRatio * 85), (int)(_dim.YScreenRatio * 90));
            _suspensionsUpBtn.SetPosition((int)(_dim.XScreenRatio * 100), (int)(_dim.YScreenRatio * 0));
            _suspensionsUpBtn.Pressed += args => {
                UpgradeComponent(2);
            };

            susCost = new Text();
            _suspensionsCost.AddChild(susCost);
            susCost.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 0));
            susCost.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            susCost.SetFont(_font, _dim.XScreenRatio * 20);
            susCost.SetColor(Color.Black);

            _brakeCost = new BorderImage();
            _contUpgradeCost.AddChild(_brakeCost);
            _brakeCost.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _brakeCost.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeCost;
            _brakeCost.SetSize((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 90));
            _brakeCost.SetPosition((int)(_dim.XScreenRatio * 345), (int)(_dim.YScreenRatio * 200));

            _brakeUpBtn = new Button();
            _brakeCost.AddChild(_brakeUpBtn);
            _brakeUpBtn.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _brakeUpBtn.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeLeft;
            _brakeUpBtn.SetSize((int)(_dim.XScreenRatio * 85), (int)(_dim.YScreenRatio * 90));
            _brakeUpBtn.SetPosition((int)(_dim.XScreenRatio * -100), (int)(_dim.YScreenRatio * 0));
            _brakeUpBtn.Pressed += args => {
                UpgradeComponent(3);
            };

            SetUpgrade();
            SetCollectedComponents();
            GetCarImg();
        }
Example #2
0
        /// <summary>
        /// Returns the name of the UI Element
        /// </summary>
        /// <returns>Splash screen.</returns>
        /// <param name="GameInstance">Game instance.</param>
        public static string CreateSplashScreen(Game GameInstance, Node parent, bool randomLevel = false)
        {
            // Get data
            var data    = TrackManager.Instance.LoadingScreenFacts;
            var rnd     = new Random();
            var argIdx  = rnd.Next(0, data.LoadingScreens.Count);
            var arg     = data.LoadingScreens[argIdx];
            var factIdx = rnd.Next(0, arg.Facts.Count);
            var fact    = arg.Facts[factIdx];

            // get poster asset
            IntRect poster;

            switch (arg.Type)
            {
            case LoadingScreenType.CLI:
                poster = AssetsCoordinates.Backgrounds.LoadingScreen.Posters.Climate;
                break;

            case LoadingScreenType.ENV:
                poster = AssetsCoordinates.Backgrounds.LoadingScreen.Posters.Environment;
                break;

            case LoadingScreenType.RES:
                poster = AssetsCoordinates.Backgrounds.LoadingScreen.Posters.Resources;
                break;

            case LoadingScreenType.WASTE:
                poster = AssetsCoordinates.Backgrounds.LoadingScreen.Posters.Waste;
                break;

            case LoadingScreenType.WILD:
                poster = AssetsCoordinates.Backgrounds.LoadingScreen.Posters.Wild;
                break;

            default:
                poster = AssetsCoordinates.Backgrounds.LoadingScreen.Posters.Environment;
                break;
            }

            var splashscreen = new Window {
                Name                = "SplashUI",
                Position            = new IntVector2(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(0)),
                Size                = new IntVector2(GameInstance.ScreenInfo.SetX(1920), GameInstance.ScreenInfo.SetY(1080)),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Texture             = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Backgrounds.FixedBackground.ResourcePath),
                ImageRect           = AssetsCoordinates.Backgrounds.FixedBackground.ImageRect,
                Priority            = 999
            };

            GameInstance.UI.Root.AddChild(splashscreen);

            // TOP BAR
            var topBar = new Sprite();

            splashscreen.AddChild(topBar);
            topBar.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.TopBar.ResourcePath);
            topBar.ImageRect = AssetsCoordinates.Generic.TopBar.Rectangle;
            topBar.Opacity   = 0.5f;
            topBar.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(30));
            topBar.SetSize(GameInstance.ScreenInfo.SetX(2000), GameInstance.ScreenInfo.SetY(120));

            Button screenTitle = new Button();

            //screenTitle.SetStyleAuto(null);
            screenTitle.HorizontalAlignment = HorizontalAlignment.Right;
            screenTitle.VerticalAlignment   = VerticalAlignment.Center;
            screenTitle.SetPosition(GameInstance.ScreenInfo.SetX(-150), GameInstance.ScreenInfo.SetY(0));
            screenTitle.SetSize(GameInstance.ScreenInfo.SetX(400), GameInstance.ScreenInfo.SetY(95));
            screenTitle.Texture           = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            screenTitle.ImageRect         = AssetsCoordinates.Generic.Boxes.BoxTitle;
            screenTitle.Enabled           = false;
            screenTitle.UseDerivedOpacity = false;
            topBar.AddChild(screenTitle);

            Text buttonTitleText = new Text();

            screenTitle.AddChild(buttonTitleText);
            buttonTitleText.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Center);
            buttonTitleText.SetPosition(GameInstance.ScreenInfo.SetX(20), GameInstance.ScreenInfo.SetY(0));
            buttonTitleText.SetFont(GameInstance.ResourceCache.GetFont(GameInstance.defaultFont), GameInstance.ScreenInfo.SetX(35));
            buttonTitleText.Value             = "LOADING";
            buttonTitleText.UseDerivedOpacity = false;

            BorderImage wheel = new BorderImage();

            screenTitle.AddChild(wheel);
            wheel.SetAlignment(HorizontalAlignment.Right, VerticalAlignment.Center);
            wheel.SetPosition(GameInstance.ScreenInfo.SetX(-15), GameInstance.ScreenInfo.SetY(0));
            wheel.SetSize(100, 100);
            wheel.Texture           = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            wheel.ImageRect         = AssetsCoordinates.Generic.Icons.LoadingWheel;
            wheel.UseDerivedOpacity = false;

            /*
             * ValueAnimation textAnimation = new ValueAnimation();
             * textAnimation.SetKeyFrame(0.0f, Color.Blue);
             * textAnimation.SetKeyFrame(1.0f, Color.Red);
             * textAnimation.SetKeyFrame(2.0f, Color.Green);
             *
             * Debug.WriteLine($"Name: {nameof(UIElement.Position)}");
             * buttonTitleText.SetAttributeAnimation(nameof(Color), textAnimation, WrapMode.Loop);
             *
             * ValueAnimation positionAnimation = new ValueAnimation {
             *  InterpolationMethod = InterpMethod.Spline
             * };
             * positionAnimation.SetKeyFrame(0.0f, new IntVector2(-25,0));
             * positionAnimation.SetKeyFrame(1.0f, new IntVector2(-35, 0));
             * positionAnimation.SetKeyFrame(2.0f, new IntVector2(-45, 0));
             * positionAnimation.SetKeyFrame(3.0f, new IntVector2(-55, 0));
             * positionAnimation.SetKeyFrame(4.0f, new IntVector2(-65, 0));
             *
             * wheel.SetAttributeAnimation(nameof(UIElement.Position), positionAnimation);
             * wheel.AnimationEnabled = true;
             * wheel.ApplyAttributes();
             */

            // BODY
            if (randomLevel)
            {
                var text = new Text();
                text.SetFont(GameInstance.ResourceCache.GetFont(GameInstance.defaultFont), 17);
                text.SetPosition(GameInstance.ScreenInfo.SetX(20), GameInstance.ScreenInfo.SetY(172));
                text.Value             = "*Coins and items collected in the random level are not saved.";
                text.UseDerivedOpacity = false;
                splashscreen.AddChild(text);
            }

            var posterImage = new Window {
                Name                = "PosterUI",
                Position            = new IntVector2(GameInstance.ScreenInfo.SetX(200), GameInstance.ScreenInfo.SetY(50)),
                Size                = new IntVector2(GameInstance.ScreenInfo.SetX(500), GameInstance.ScreenInfo.SetY(636)),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center,
                Texture             = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Backgrounds.LoadingScreen.Posters.Path),
                ImageRect           = poster
            };

            splashscreen.AddChild(posterImage);

            var textWindow = new Window {
                Name                = "splashScreenTextWindow",
                Position            = new IntVector2(GameInstance.ScreenInfo.SetX(750), GameInstance.ScreenInfo.SetY(50)),
                Size                = new IntVector2(GameInstance.ScreenInfo.SetX(1000), GameInstance.ScreenInfo.SetY(636)),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center
            };

            textWindow.SetColor(Color.Transparent);
            splashscreen.AddChild(textWindow);

            var titleBox = new Text {
                Name                = "splashScreenTitle",
                Position            = new IntVector2(GameInstance.ScreenInfo.SetX(10), GameInstance.ScreenInfo.SetY(-20)),
                Size                = new IntVector2(GameInstance.ScreenInfo.SetX(1000), GameInstance.ScreenInfo.SetY(60)),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Wordwrap            = true
            };

            titleBox.SetFont(GameInstance.ResourceCache.GetFont(GameInstance.defaultFont), GameInstance.ScreenInfo.SetX(50));
            titleBox.Value = arg.Title;
            textWindow.AddChild(titleBox);

            var textBox = new Text {
                Name                = "splashScreenText",
                Position            = new IntVector2(GameInstance.ScreenInfo.SetX(10), GameInstance.ScreenInfo.SetY(75)),
                Size                = new IntVector2(GameInstance.ScreenInfo.SetX(1000), GameInstance.ScreenInfo.SetY(350)),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Wordwrap            = true
            };

            textBox.SetFont(GameInstance.ResourceCache.GetFont(GameInstance.defaultFont), GameInstance.ScreenInfo.SetX(30));
            textBox.Value = fact.Message;
            textWindow.AddChild(textBox);

            var btnContinue = new Button {
                Texture             = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath),
                ImageRect           = AssetsCoordinates.Generic.Boxes.GroupSelected,
                Name                = "ButtonContinue",
                Position            = new IntVector2(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(0)),
                Size                = new IntVector2(GameInstance.ScreenInfo.SetX(400), GameInstance.ScreenInfo.SetY(95)),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Bottom
            };

            btnContinue.Visible = false;
            textWindow.AddChild(btnContinue);

            Text btnContinueText = new Text();

            btnContinueText.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            btnContinueText.SetPosition(GameInstance.ScreenInfo.SetX(-10), GameInstance.ScreenInfo.SetY(0));
            btnContinueText.SetFont(GameInstance.ResourceCache.GetFont(GameInstance.defaultFont), GameInstance.ScreenInfo.SetX(35));
            btnContinueText.Value = "CONTINUE";
            btnContinue.AddChild(btnContinueText);

            return(splashscreen.Name);
        }
Example #3
0
        void DefineCurrVehicle()
        {
            if (_selectedVehicle != null)
            {
                _selectedVehicle.Remove();
            }

            _selectedVehicle = new Button();
            _vehicleBar.AddChild(_selectedVehicle);
            _selectedVehicle.UseDerivedOpacity = false;
            _selectedVehicle.Texture           = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Garage.FullVehicles.ResourcePath);
            _currentVehicleModel = VehicleManager.Instance.GetVehicleFromId(_idDVehicle);
            _selectedVehicle.SetSize((int)(_dim.XScreenRatio * 600), (int)(_dim.YScreenRatio * 600));
            _selectedVehicle.SetPosition((int)(_dim.XScreenRatio * 650), (int)(_dim.YScreenRatio * -100));

            _selectedVehicle.Pressed += args => {
                if (VehicleManager.Instance.UnlockedVehicles.VehicleModel.Count == 0)
                {
                    if (_currentVehicleModel.UnlockCost == -1)
                    {
                        ConfirmationWindow(string.Format("You can't select this vehicle at this moment."), true);
                    }
                    else
                    {
                        // Unlock vehicle
                        VehicleManager.Instance.SelectedVehicleModel = VehicleManager.Instance.Vehicles.VehicleModel.First(v => v.IdVehicle == _idDVehicle);
                        VehicleManager.Instance.UnlockVehicle();

                        Debug.WriteLine("Unlocked vehicle " + _currentVehicleModel.IdVehicle);
                        ConfirmationWindow(string.Format("{0} unlocked!", _selectedVehicle.Name), false, true);
                    }
                }
                else if (!VehicleManager.Instance.UnlockedVehicles.VehicleModel.Exists(v => v.IdVehicle == _currentVehicleModel.IdVehicle))
                {
                    // If selected and vehicle needs to be unlocked, unlock vehicle without changing scene
                    if (_currentVehicleModel.UnlockCost != -1)
                    {
                        if (CharacterManager.Instance.Wallet >= _currentVehicleModel.UnlockCost)
                        {
                            CharacterManager.Instance.Wallet -= _currentVehicleModel.UnlockCost;
                            _wallet.Value = CharacterManager.Instance.Wallet.ToString();
                            // Unlock vehicle
                            VehicleManager.Instance.SelectedVehicleModel = VehicleManager.Instance.Vehicles.VehicleModel.First(v => v.IdVehicle == _idDVehicle);
                            VehicleManager.Instance.UnlockVehicle();

                            Debug.WriteLine("Unlocked vehicle " + _currentVehicleModel.IdVehicle);
                            ConfirmationWindow(string.Format("{0} unlocked!", _selectedVehicle.Name), false, true);
                        }
                        else
                        {
                            ConfirmationWindow(string.Format("Collect more coins to unlock this vehicle."), true);
                        }
                    }
                    else
                    {
                        var components = VehicleManager.Instance.CollectedComponentsForVehicle(_currentVehicleModel.IdVehicle).VehicleComponents;
                        if (components.Brakes && components.Performance && components.Suspensions && components.Wheels)
                        {
                            // Unlock vehicle
                            VehicleManager.Instance.SelectedVehicleModel = VehicleManager.Instance.Vehicles.VehicleModel.First(v => v.IdVehicle == _idDVehicle);
                            VehicleManager.Instance.UnlockVehicle();

                            Debug.WriteLine("Unlocked vehicle " + _currentVehicleModel.IdVehicle);
                            ConfirmationWindow(string.Format(_selectedVehicle.Name + "unlocked!"), false, true);
                        }
                        else
                        {
                            ConfirmationWindow(string.Format("Collect all four components to unlock this vehicle."), true);
                        }
                    }
                }
                else
                {
                    VehicleManager.Instance.SelectedVehicleModel = VehicleManager.Instance.Vehicles.VehicleModel.First(v => v.IdVehicle == _idDVehicle);
                    GameInstance.LaunchScene(GameScenesEnumeration.MENU);
                }
            };

            _carName = new Text();
            _selectedVehicle.AddChild(_carName);
            _carName.SetPosition(_dim.SetX(0), _dim.SetY(-80));
            _carName.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Bottom);
            _carName.SetFont(_font, _dim.SetX(40));

            _unlockCost = new Text();
            _selectedVehicle.AddChild(_unlockCost);
            _unlockCost.SetPosition(_dim.SetX(40), _dim.SetY(-30));
            _unlockCost.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Bottom);
            _unlockCost.SetFont(_font, _dim.SetX(30));
            _unlockCost.Visible = false;

            _coinIcon = new BorderImage();
            _selectedVehicle.AddChild(_coinIcon);
            _coinIcon.SetPosition(_dim.SetX(-50), _dim.SetY(-30));
            _coinIcon.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Bottom);
            _coinIcon.Visible = false;
            _coinIcon.SetSize(_dim.SetX(50), _dim.SetY(50));
            _coinIcon.Texture           = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _coinIcon.ImageRect         = AssetsCoordinates.Generic.Icons.IconCoin;
            _coinIcon.UseDerivedOpacity = false;

            _lockedVehicle = new Sprite();
            _selectedVehicle.AddChild(_lockedVehicle);
            _lockedVehicle.SetPosition((int)(_dim.XScreenRatio * 630), (int)(_dim.YScreenRatio * 200));
            _lockedVehicle.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath);
            _lockedVehicle.ImageRect = AssetsCoordinates.Generic.Icons.IconLocked;
            _lockedVehicle.SetSize(_dim.SetX(100), _dim.SetY(100));
        }