Пример #1
0
        public PlayingState(Alex alex, GraphicsDevice graphics, WorldProvider worldProvider, INetworkProvider networkProvider) : base(alex)
        {
            NetworkProvider = networkProvider;

            World       = new World(alex, graphics, Options, new FirstPersonCamera(Options.VideoOptions.RenderDistance, Vector3.Zero, Vector3.Zero), networkProvider);
            SkyRenderer = new SkyBox(alex, graphics, World);

            WorldProvider = worldProvider;
            if (worldProvider is SPWorldProvider)
            {
                World.FreezeWorldTime = true;
            }

            var chat  = new ChatComponent(World);
            var title = new TitleComponent();

            WorldProvider = worldProvider;
            WorldProvider.Init(World, chat, out var info, out var chatProvider);
            World.WorldInfo              = info;
            chat.ChatProvider            = chatProvider;
            WorldProvider.TitleComponent = title;

            _playingHud = new PlayingHud(Alex, World.Player, chat, title);
            _debugInfo  = new GuiDebugInfo();
            InitDebugInfo();
        }
Пример #2
0
        public PlayingState(Alex alex, GraphicsDevice graphics, WorldProvider worldProvider, NetworkProvider networkProvider) : base(alex)
        {
            NetworkProvider = networkProvider;

            World = new World(alex.Services, graphics, Options, networkProvider);
            World.Player.IsFirstPersonMode = true;

            WorldProvider = worldProvider;
            if (worldProvider is SPWorldProvider)
            {
                World.DoDaylightcycle = false;
                //World.Player.SetInventory(new BedrockInventory(46));
                if (ItemFactory.TryGetItem("minecraft:diamond_sword", out var sword))
                {
                    World.Player.Inventory.MainHand = sword;
                    World.Player.Inventory[World.Player.Inventory.SelectedSlot] = sword;
                }
            }

            var title = new TitleComponent();

            WorldProvider = worldProvider;
            WorldProvider.Init(World);

            WorldProvider.TitleComponent = title;

            _playingHud = new PlayingHud(Alex, World.Player, title);
            _playingHud.Chat.Network = networkProvider;

            WorldProvider.ScoreboardView = _playingHud.Scoreboard;
            WorldProvider.ChatRecipient  = _playingHud;
            //WorldProvider.ScoreboardView

            _debugInfo = new GuiDebugInfo();
            InitDebugInfo();

            MiniMap = new GuiMiniMap(World.ChunkManager)
            {
                Anchor = Alignment.TopRight
            };

            var settings = GetService <IOptionsProvider>();

            settings.AlexOptions.VideoOptions.Minimap.Bind(OnMinimapSettingChange);
            RenderMinimap = settings.AlexOptions.VideoOptions.Minimap.Value;

            if (RenderMinimap)
            {
                _playingHud.AddChild(MiniMap);
            }

            _networkDebugHud = new NetworkDebugHud(NetworkProvider);
        }
Пример #3
0
        public ModelDebugState()
        {
            _debugInfo = new GuiDebugInfo();

            Background = Color.DeepSkyBlue;

            BlockModelExplorer  = new BlockModelExplorer(Alex.Instance, null);
            EntityModelExplorer = new EntityModelExplorer(Alex.Instance, null);

            ModelExplorer = BlockModelExplorer;

            //AddChild(_wrap = new GuiStackContainer()
            //{
            //	Orientation = Orientation.Horizontal,
            //	Anchor = Alignment.Fill,
            //	ChildAnchor = Alignment.FillY
            //});

            AddChild(_modelExplorerView = new GuiModelExplorerView(ModelExplorer, new Vector3(0f, 1.85f, 6f), new Vector3(0.5f, 0.5f, 0.5f))
            {
                Anchor            = Alignment.Fill,
                Background        = Color.TransparentBlack,
                BackgroundOverlay = new Color(Color.Black, 0.15f),

                Margin = new Thickness(0),

                Width  = 92,
                Height = 128,

                AutoSizeMode = AutoSizeMode.None,

                //Anchor = Alignment.BottomRight,

                // Width = 100,
                // Height = 100
            });

            AddChild(_mainMenu = new GuiStackMenu()
            {
                Margin  = new Thickness(0, 0, 15, 0),
                Padding = new Thickness(0, 50, 0, 0),
                Width   = 125,
                Anchor  = Alignment.FillY | Alignment.MinX,

                ChildAnchor       = Alignment.CenterY | Alignment.FillX,
                BackgroundOverlay = new Color(Color.Black, 0.35f)
            });

            //_wrap.AddChild(_modelRenderer = new DebugModelRenderer(Alex)
            //{
            //	Anchor = Alignment.Fill,
            //	// Width = 100,
            //	// Height = 100
            //});



            _mainMenu.AddMenuItem("Skip", () => { Task.Run(() => { ModelExplorer.Skip(); }); });
            _mainMenu.AddMenuItem("Next", NextModel);
            _mainMenu.AddMenuItem("Previous", PrevModel);
            _mainMenu.AddMenuItem("Switch Models", () =>
            {
                SwitchModelExplorers();
                _modelExplorerView.ModelExplorer = ModelExplorer;
            });

            //AddChild(_mainMenu);

            _debugInfo.AddDebugRight(() => Alex.DotnetRuntime);
            //_debugInfo.AddDebugRight(() => MemoryUsageDisplay);
            _debugInfo.AddDebugRight(() => $"RAM: {PlayingState.GetBytesReadable(_ramUsage, 2)}");
            _debugInfo.AddDebugRight(() =>
                                     $"GPU: {PlayingState.GetBytesReadable(GpuResourceManager.GetMemoryUsage, 2)}");
            _debugInfo.AddDebugRight(() =>
            {
                return
                ($"Threads: {(_threadsUsed):00}/{_maxThreads}\nCompl.ports: {_complPortUsed:00}/{_maxComplPorts}");
            });

            _debugInfo.AddDebugRight(() =>
            {
                if (ModelExplorer == null)
                {
                    return(string.Empty);
                }

                return(ModelExplorer.GetDebugInfo());
            });

            _keyState = Keyboard.GetState();
        }
Пример #4
0
        public TitleState()
        {
            FpsMonitor        = new FpsMonitor();
            _backgroundSkyBox = new GuiPanoramaSkyBox(Alex);

            Background.Texture    = _backgroundSkyBox;
            Background.RepeatMode = TextureRepeatMode.Stretch;

            #region Create MainMenu

            _mainMenu = new GuiStackMenu()
            {
                Margin  = new Thickness(15, 0, 15, 0),
                Padding = new Thickness(0, 50, 0, 0),
                Width   = 125,
                Anchor  = Alignment.FillY | Alignment.MinX,

                ChildAnchor       = Alignment.CenterY | Alignment.FillX,
                BackgroundOverlay = new Color(Color.Black, 0.35f)
            };

            _mainMenu.AddMenuItem("Multiplayer", JavaEditionButtonPressed, EnableMultiplayer);
            _mainMenu.AddMenuItem("SinglePlayer", OnSinglePlayerPressed);

            _mainMenu.AddMenuItem("Options", () => { Alex.GameStateManager.SetActiveState("options"); });
            _mainMenu.AddMenuItem("Exit", () => { Alex.Exit(); });
            #endregion

            #region Create DebugMenu

            _debugMenu = new GuiStackMenu()
            {
                Margin  = new Thickness(15, 0, 15, 0),
                Padding = new Thickness(0, 50, 0, 0),
                Width   = 125,
                Anchor  = Alignment.FillY | Alignment.MinX,

                ChildAnchor       = Alignment.CenterY | Alignment.FillX,
                BackgroundOverlay = new Color(Color.Black, 0.35f),
            };

            _debugMenu.AddMenuItem("Debug Blockstates", DebugWorldButtonActivated);
            _debugMenu.AddMenuItem("Debug Flatland", DebugFlatland);
            //_debugMenu.AddMenuItem("Debug Anvil", DebugAnvil);
            _debugMenu.AddMenuItem("Debug Chunk", DebugChunkButtonActivated);
            //	_debugMenu.AddMenuItem("Debug XBL Login", BedrockEditionButtonPressed);
            _debugMenu.AddMenuItem("Go Back", DebugGoBackPressed);

            #endregion

            #region Create SPMenu

            _spMenu = new GuiStackMenu()
            {
                Margin  = new Thickness(15, 0, 15, 0),
                Padding = new Thickness(0, 50, 0, 0),
                Width   = 125,
                Anchor  = Alignment.FillY | Alignment.MinX,

                ChildAnchor       = Alignment.CenterY | Alignment.FillX,
                BackgroundOverlay = new Color(Color.Black, 0.35f),
            };

            _spMenu.AddMenuItem("SinglePlayer", () => {}, false);
            _spMenu.AddMenuItem("Debug Worlds", OnDebugPressed);

            _spMenu.AddMenuItem("Return to main menu", SpBackPressed);

            #endregion

            CreateProtocolMenu();

            AddChild(_mainMenu);

            AddChild(_logo = new GuiImage(GuiTextures.AlexLogo)
            {
                Margin = new Thickness(95, 25, 0, 0),
                Anchor = Alignment.TopCenter
            });

            AddChild(_splashText = new GuiTextElement()
            {
                TextColor = TextColor.Yellow,
                Rotation  = 17.5f,

                Margin = new Thickness(240, 15, 0, 0),
                Anchor = Alignment.TopCenter,

                Text = "Who liek minecwaf?!",
            });

            _debugInfo = new GuiDebugInfo();
            _debugInfo.AddDebugRight(() => $"GPU Memory: {API.Extensions.GetBytesReadable(GpuResourceManager.GetMemoryUsage)}");
            _debugInfo.AddDebugLeft(() => $"FPS: {FpsMonitor.Value:F0}");

            _playerProfileService = Alex.Services.GetService <IPlayerProfileService>();
            _playerProfileService.ProfileChanged += PlayerProfileServiceOnProfileChanged;

            Alex.GameStateManager.AddState("options", new OptionsState(_backgroundSkyBox));
        }