Example #1
0
        protected override void LoadContent()
        {
            base.LoadContent();

            Vector2 size = GetScreenPosition(new Vector2(0.3f, 0.6f));
            Bounds = new Rectangle(0, 0, (int)size.X, (int)size.Y);

            List<Tuple<String, GameState>> itemInfo = new List<Tuple<string, GameState>>();
            itemInfo.Add(new Tuple<String, GameState>("Resume", GameState.Gameplay));
            itemInfo.Add(new Tuple<String, GameState>("Main menu", GameState.MainMenu));
            itemInfo.Add(new Tuple<String, GameState>("Quit", GameState.Exiting));

            foreach (var info in itemInfo)
            {
                MenuItem item = new StateActionMenuItem(info.Item1, info.Item2);
                item.Background = ButtonBackground;
                item.Font = MenuFont;
                item.FontColorSelected = ItemColorSelected;
                item.SetWidth(Bounds.Width);
                AddMenuItem(item);
            }
        }
Example #2
0
        private void Disconnect()
        {
            gameInstance.GetService<ServerClient>().Disconnect();

            MenuItem item = new ActionMenuItem("Connect", ConnectToServer, "connect");
            item.Background = ButtonBackground;
            item.Font = MenuFont;
            item.FontColor = ItemColor;
            item.FontColorSelected = ItemColorSelected;
            item.SetWidth(Bounds.Width);
            SetMenuItem("start", item);

            item = new StateActionMenuItem("Cancel", GameState.MainMenu, "cancel");
            item.Background = ButtonBackground;
            item.Font = MenuFont;
            item.FontColor = ItemColor;
            item.FontColorSelected = ItemColorSelected;
            item.SetWidth(Bounds.Width);
            SetMenuItem("disconnect", item);
        }
Example #3
0
        private void ConnectToServer()
        {
            string server = (GetMenuItem("server") as TextInputMenuItem).EnteredText;
            gameInstance.GetService<ServerClient>().Connect(System.Net.IPAddress.Parse(server));

            MenuItem start = new StateActionMenuItem("Connecting...", GameState.CarChooser, "start");
            start.Background = ButtonBackground;
            start.Font = MenuFont;
            start.Enabled = false;
            start.FontColor = ItemColor;
            start.FontColorSelected = ItemColorSelected;
            start.SetWidth(Bounds.Width);
            SetMenuItem("connect", start);

            MenuItem disconnect = new ActionMenuItem("Disconnect", Disconnect, "disconnect");
            disconnect.Background = ButtonBackground;
            disconnect.Font = MenuFont;
            disconnect.FontColor = ItemColor;
            disconnect.FontColorSelected = ItemColorSelected;
            disconnect.SetWidth(Bounds.Width);
            SetMenuItem("cancel", disconnect);
        }
Example #4
0
        protected override void LoadContent()
        {
            base.LoadContent();

            Vector2 size = GetScreenPosition(new Vector2(0.5f, 0.5f));
            Bounds = new Rectangle(0, 0, (int)size.X, (int)size.Y);

            serverInput = new TextInputMenuItem("Server IP", "server");
            serverInput.Bounds = Bounds;
            serverInput.Font = MenuFont;
            serverInput.Background = OptionSelected;
            serverInput.FontColor = ItemColor;
            serverInput.FontColorSelected = Color.Black;
            AddMenuItem(serverInput);

            MenuItem item = new ActionMenuItem("Connect", ConnectToServer, "connect");
            item.Background = ButtonBackground;
            item.Font = MenuFont;
            item.FontColor = ItemColor;
            item.FontColorSelected = ItemColorSelected;
            item.SetWidth(Bounds.Width);
            AddMenuItem(item);

            item = new StateActionMenuItem("Cancel", GameState.MainMenu, "cancel");
            item.Background = ButtonBackground;
            item.Font = MenuFont;
            item.FontColor = ItemColor;
            item.FontColorSelected = ItemColorSelected;
            item.SetWidth(Bounds.Width);
            AddMenuItem(item);
        }
Example #5
0
        protected override void LoadContent()
        {
            base.LoadContent();

            Vector2 size = GetScreenPosition(new Vector2(0.5f, 0.6f));
            Bounds = new Rectangle(0, 0, (int)size.X, (int)size.Y);

            List<Tuple<String, GameState>> itemInfo = new List<Tuple<string, GameState>>();
            itemInfo.Add(new Tuple<String, GameState>("Back", GameState.MainMenu));
            itemInfo.Add(new Tuple<String, GameState>("Start", GameState.Gameplay));

            foreach (var info in itemInfo)
            {
                MenuItem item = new StateActionMenuItem(info.Item1, info.Item2);
                item.Background = ButtonBackground;
                item.Font = MenuFont;
                item.FontColor = ItemColor;
                item.FontColorSelected = ItemColorSelected;
                item.SetWidth(ButtonBackground.Bounds.Width);
                AddMenuItem(item);
            }

            directionalLight = new DirectionalLight(
                new Vector3(-1.25f, -2f, 5.0f), // Direction
                new Vector3(.1f, .1f, .1f),//new Vector3(.15f, .14f, .29f), // Ambient
                new Vector3(1f, 1f, 1f)); // Diffuse

            MakeCar();
            cameraPosition = new Vector3(0, 100f, 300f);

            projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 0.01f, 500f);

            if (availableColors.Exists(c => c == GameSettings.Default.CarColor)) {
                diffuseColor = GameSettings.Default.CarColor;
            }
        }
Example #6
0
        protected override void LoadContent()
        {
            base.LoadContent();

            Vector2 size = GetScreenPosition(new Vector2(0.6f, 0.75f));
            Bounds = new Rectangle(0, 0, (int)size.X, (int)size.Y);

            OptionMenuItem<Tuple<int, int>> resolution = new OptionMenuItem<Tuple<int, int>>("Resolution", "res");
            foreach (var res in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Select(m => new Tuple<int,int>(m.Width, m.Height)).Distinct().OrderBy(r => r.Item1))
                resolution.AddOption(res.Item1 + "x" + res.Item2, res);
            resolution.SetStartOption(new Tuple<int, int>(gameInstance.Graphics.PreferredBackBufferWidth, gameInstance.Graphics.PreferredBackBufferHeight));
            resolution.Bounds = Bounds;
            resolution.Font = MenuFont;
            resolution.ArrowLeft = ArrowLeft;
            resolution.ArrowRight = ArrowRight;
            resolution.Background = OptionSelected;
            resolution.FontColor = ItemColor;
            resolution.FontColorSelected = Color.Black;
            AddMenuItem(resolution);

            OptionMenuItem<int> displayMode = new OptionMenuItem<int>("Display Mode", "display");
            displayMode.AddOption("Fullscreen", 1);
            displayMode.AddOption("Windowed", 2);
            displayMode.SetStartOption(gameInstance.Graphics.IsFullScreen ? 1 : 2);
            displayMode.Bounds = Bounds;
            displayMode.Font = MenuFont;
            displayMode.ArrowLeft = ArrowLeft;
            displayMode.ArrowRight = ArrowRight;
            displayMode.Background = OptionSelected;
            displayMode.FontColor = ItemColor;
            displayMode.FontColorSelected = Color.Black;
            AddMenuItem(displayMode);

            TextInputMenuItem playerName = new TextInputMenuItem("Player Name", "name");
            playerName.Bounds = Bounds;
            playerName.Font = MenuFont;
            playerName.EnteredText = GameSettings.Default.PlayerName;
            playerName.Background = OptionSelected;
            playerName.FontColor = ItemColor;
            playerName.FontColorSelected = Color.Black;
            AddMenuItem(playerName);

            BoolOptionMenuItem shadows = new BoolOptionMenuItem("Shadows", "shadows");
            shadows.Bounds = Bounds;
            shadows.Font = MenuFont;
            shadows.SetStartOption(GameSettings.Default.Shadows);
            shadows.ArrowLeft = ArrowLeft;
            shadows.ArrowRight = ArrowRight;
            shadows.Background = OptionSelected;
            shadows.FontColor = ItemColor;
            shadows.FontColorSelected = Color.Black;
            AddMenuItem(shadows);

            BoolOptionMenuItem bloom = new BoolOptionMenuItem("Bloom", "bloom");
            bloom.Bounds = Bounds;
            bloom.Font = MenuFont;
            bloom.SetStartOption(GameSettings.Default.Bloom);
            bloom.ArrowLeft = ArrowLeft;
            bloom.ArrowRight = ArrowRight;
            bloom.Background = OptionSelected;
            bloom.FontColor = ItemColor;
            bloom.FontColorSelected = Color.Black;
            AddMenuItem(bloom);

            MenuItem item = new StateActionMenuItem("Cancel", GameState.MainMenu);
            item.Background = ButtonBackground;
            item.Font = MenuFont;
            item.FontColor = ItemColor;
            item.FontColorSelected = ItemColorSelected;
            item.SetWidth(Bounds.Width);
            AddMenuItem(item);

            item = new ActionMenuItem("Apply", ApplySettings);
            item.Background = ButtonBackground;
            item.Font = MenuFont;
            item.FontColor = ItemColor;
            item.FontColorSelected = ItemColorSelected;
            item.SetWidth(Bounds.Width);
            AddMenuItem(item);
        }