Example #1
0
        /// <summary>
        /// Draws controls for testing vehicle response.
        /// </summary>
        public void DrawDebugControls()
        {
            var debugInfo = new Window();

            UI.Root.AddChild(debugInfo);

            // Remove Focus or game will think pause menu is open
            UI.SetFocusElement(null);
            Font font = ResourceCache.GetFont("Fonts/OpenSans-Bold.ttf");

            // Set Window size and layout settings
            debugInfo.SetPosition(ScreenInfo.SetX(0), ScreenInfo.SetY(0));
            debugInfo.SetSize(ScreenInfo.SetX(1920), ScreenInfo.SetY(540));
            debugInfo.SetColor(Color.Transparent);
            debugInfo.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Top);
            debugInfo.Name = "GameDebugWindow";

            Text suspension = GameText.CreateText(debugInfo, ScreenInfo, font, 20, 210, 50, HorizontalAlignment.Left, VerticalAlignment.Top);
            //var comp = GameVehicle.Wheel1.OtherBody.GetComponent<CollisionCircle2D>();
            //var comp2 = GameVehicle.Wheel2.OtherBody.GetComponent<CollisionCircle2D>();

            //suspension.Value = string.Format("suspensions: {0}, {1}", comp.Restitution, comp2.Restitution);

            // SUSPENTIONS - plus button
            var susButtonPlus = GameButton.CreateButton(debugInfo, ScreenInfo, 100, 0, 100, 100, HorizontalAlignment.Left, VerticalAlignment.Top);

            Text buttonText = GameText.CreateText(susButtonPlus, ScreenInfo, font, 40, 0, 0, HorizontalAlignment.Center, VerticalAlignment.Center);

            buttonText.Value = "+";

            susButtonPlus.Pressed += args => {
                Debug.WriteLine("pressed suspension +");
            };

            // SUSPENTIONS - minus button
            var susButtonMinus = GameButton.CreateButton(debugInfo, ScreenInfo, 0, 0, 100, 100, HorizontalAlignment.Left, VerticalAlignment.Top);

            Text susTextMinus = GameText.CreateText(susButtonMinus, ScreenInfo, font, 40, 0, 0, HorizontalAlignment.Center, VerticalAlignment.Center);

            susTextMinus.Value = "-";

            susButtonMinus.Pressed += args => {
                Debug.WriteLine("pressed suspension -");
            };
        }
Example #2
0
        void ComingSoon()
        {
            var quitWindow = new Window();

            GameInstance.UI.Root.AddChild(quitWindow);
            GameInstance.UI.SetFocusElement(null);

            // Set Window size and layout settings
            quitWindow.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(0));
            quitWindow.SetSize(GameInstance.ScreenInfo.SetX(1920), GameInstance.ScreenInfo.SetY(1080));
            quitWindow.SetColor(Color.FromHex("#22000000"));
            quitWindow.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            quitWindow.Name = "QuitWindow";

            Sprite windowSprite = new Sprite();

            quitWindow.AddChild(windowSprite);
            windowSprite.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.TopBar.ResourcePath);
            windowSprite.Opacity   = 0.75f;
            windowSprite.ImageRect = AssetsCoordinates.Generic.TopBar.Rectangle;
            windowSprite.SetSize((int)(dim.XScreenRatio * 1920), (int)(dim.YScreenRatio * 1080));
            windowSprite.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Top);
            windowSprite.SetPosition(0, 0);

            Font font = GameInstance.ResourceCache.GetFont(GameInstance.defaultFont);

            Window rectangle = new Window();

            quitWindow.AddChild(rectangle);
            rectangle.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(0));
            rectangle.UseDerivedOpacity = true;
            rectangle.SetSize(GameInstance.ScreenInfo.SetX(800), GameInstance.ScreenInfo.SetY(200));
            rectangle.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            rectangle.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            rectangle.ImageRect = AssetsCoordinates.Generic.Boxes.BoxConfirmation;

            Text warningText = GameText.CreateText(rectangle, GameInstance.ScreenInfo, font, 35, 250, 0, HorizontalAlignment.Left, VerticalAlignment.Center, "COMING SOON!");

            warningText.Wordwrap = true;
            warningText.SetSize(GameInstance.ScreenInfo.SetX(750 - 270), GameInstance.ScreenInfo.SetY(240));
            warningText.SetColor(Color.White);

            var continueButton = new Button();

            continueButton.SetPosition(GameInstance.ScreenInfo.SetX(245), GameInstance.ScreenInfo.SetY(180));
            continueButton.SetSize(GameInstance.ScreenInfo.SetX(285), GameInstance.ScreenInfo.SetY(130));
            continueButton.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            continueButton.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            continueButton.ImageRect = AssetsCoordinates.Generic.Boxes.SelectionPositive;
            quitWindow.AddChild(continueButton);

            Text cancelText = GameText.CreateText(continueButton, GameInstance.ScreenInfo, font, 50, 145, -5, HorizontalAlignment.Left, VerticalAlignment.Center, "OK");

            cancelText.SetColor(Color.White);


            Action <PressedEventArgs> select = new Action <PressedEventArgs>((PressedEventArgs a) => {
                quitWindow.Visible = false;
                quitWindow.Remove();
                GameInstance.LaunchScene(GameScenesEnumeration.MENU);
            });

            continueButton.Pressed += select;
        }
Example #3
0
        void ConfirmationWindow(string text, bool unavailableVehicle, bool reloadGarage = false)
        {
            var window = new Window();

            GameInstance.UI.Root.AddChild(window);

            // Set Window size and layout settings
            window.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(0));
            window.SetSize(GameInstance.ScreenInfo.SetX(1920), GameInstance.ScreenInfo.SetY(1080));
            window.SetColor(Color.FromHex("#22000000"));
            window.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            window.Name = "ConfirmationWindow";

            Sprite windowSprite = new Sprite();

            window.AddChild(windowSprite);
            windowSprite.Name      = "confirmationWindowSprite";
            windowSprite.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.TopBar.ResourcePath);
            windowSprite.Opacity   = 0.75f;
            windowSprite.ImageRect = AssetsCoordinates.Generic.TopBar.Rectangle;
            windowSprite.SetSize((int)(_dim.XScreenRatio * 1920), (int)(_dim.YScreenRatio * 1080));
            windowSprite.SetAlignment(HorizontalAlignment.Left, VerticalAlignment.Top);
            windowSprite.SetPosition(0, 0);

            Window rectangle = new Window();

            window.AddChild(rectangle);
            rectangle.Name = "confirmationWindowRectangle";
            rectangle.SetPosition(GameInstance.ScreenInfo.SetX(0), GameInstance.ScreenInfo.SetY(0));
            rectangle.SetSize(GameInstance.ScreenInfo.SetX(800), GameInstance.ScreenInfo.SetY(200));
            rectangle.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            rectangle.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            rectangle.ImageRect = AssetsCoordinates.Generic.Boxes.BoxConfirmation;

            Text warningText = GameText.CreateText(rectangle, GameInstance.ScreenInfo, _font, 30, 250, 0, HorizontalAlignment.Left, VerticalAlignment.Center, text);

            warningText.Name     = "confirmationWindowText";
            warningText.Wordwrap = true;
            warningText.SetSize(GameInstance.ScreenInfo.SetX(750 - 270), GameInstance.ScreenInfo.SetY(240));
            warningText.SetColor(Color.White);

            var closeButton = new Button();

            window.AddChild(closeButton);
            closeButton.Name = "confirmationWindowButton";
            closeButton.SetPosition(GameInstance.ScreenInfo.SetX(245), GameInstance.ScreenInfo.SetY(180));
            closeButton.SetSize(GameInstance.ScreenInfo.SetX(285), GameInstance.ScreenInfo.SetY(130));
            closeButton.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center);
            closeButton.Texture   = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath);
            closeButton.ImageRect = AssetsCoordinates.Generic.Boxes.SelectionPositive;

            Text confirmText = GameText.CreateText(closeButton, GameInstance.ScreenInfo, _font, 50, 145, -5, HorizontalAlignment.Left, VerticalAlignment.Center, "Ok");

            confirmText.Name = "confirmationWindowConfirmText";
            confirmText.SetColor(Color.White);

            closeButton.Pressed += (PressedEventArgs args) => {
                window.Remove();
                if (unavailableVehicle)
                {
                    return;
                }

                if (VehicleManager.Instance.UnlockedVehicles.VehicleModel.Count == 1)
                {
                    GameInstance.LaunchScene(GameScenesEnumeration.MENU);
                    return;
                }
                if (reloadGarage)
                {
                    GameInstance.LaunchScene(GameScenesEnumeration.GARAGE);
                }
            };
        }