Exemplo n.º 1
0
        public override void LoadContent()
        {
            _walkableAreaMap = new WalkableAreaMap(File.ReadAllBytes(Path.Combine(Game.Content.RootDirectory, "map_converted", _roomData.WalkableAreaMap.WamFile + "c")));

            _backgroundTexture2D =
                Game.Content.Load <Texture2D>("visual/" + _roomData.BildDatei.Substring(0, _roomData.BildDatei.Length - 4));
            _music = Game.Content.Load <Song>("audio/" + _roomData.MusikDatei.Substring(1));

            Game.Music.PlaySong(_music);
        }
Exemplo n.º 2
0
        protected virtual void DrawDebugMenu()
        {
            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    ImGui.MenuItem("Draw button rects", string.Empty, ref Debug.DrawButtonRects);

                    if (ImGui.MenuItem("Toggle Fullscreen"))
                    {
                        _graphics.ToggleFullScreen();
                    }

                    if (ImGui.MenuItem("Kill"))
                    {
                        Process.GetCurrentProcess().Kill();
                    }
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("WAM"))
                {
                    ImGui.MenuItem("Draw EdnaRoom WAMs", string.Empty, ref Debug.DrawWalkableAreaMap);
                    if (ImGui.MenuItem("Open Viewer"))
                    {
                        _debugDrawWamView = true;
                        var wamList = new List <string>()
                        {
                            "None"
                        };
                        wamList.AddRange(Directory.GetFiles(Path.Combine(Content.RootDirectory, "map_converted")));
                        _debugWamList = wamList.ToArray();
                    }


                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Raum"))
                {
                    ImGui.MenuItem("Draw RaumObjekt rects", string.Empty, ref Debug.DrawRaumObjektRects);
                    if (ImGui.MenuItem("Load..."))
                    {
                        _debugDrawRoomView = true;
                        var roomList = new List <string>()
                        {
                            " -- Select -- "
                        };
                        roomList.AddRange(Database.Room.Select(x => $"{x.Bezeichnung} ({x.Id})"));
                        _debugRoomList = roomList.ToArray();
                    }


                    ImGui.EndMenu();
                }

                ImGui.EndMainMenuBar();
            }

            if (_debugDrawWamView && ImGui.Begin("WAM TEST", ref _debugDrawWamView))
            {
                ImGui.Combo("Select WAM", ref _debugCurrentWamIndex, _debugWamList, _debugWamList.Length);
                if (ImGui.Button("Load"))
                {
                    _debugCurrentWam     = new WalkableAreaMap(File.ReadAllBytes(_debugWamList[_debugCurrentWamIndex]));
                    _debugCurrentWamPath = null;
                }

                ImGui.Separator();

                ImGui.InputFloat2("Start Pos", ref _debugCurrentWamStartPos);
                ImGui.SameLine();
                if (ImGui.Button("Pick"))
                {
                    _debugIsPickingStart = true;
                }

                ImGui.InputFloat2("End Pos", ref _debugCurrentWamEndPos);
                ImGui.SameLine();
                if (ImGui.Button("Pick##PickEnd"))
                {
                    _debugIsPickingEnd = true;
                }

                if (ImGui.Button("Find Path"))
                {
                    _debugCurrentWamPath = _debugCurrentWam?.FindPath(
                        new Point((int)_debugCurrentWamStartPos.X, (int)_debugCurrentWamStartPos.Y),
                        new Point((int)_debugCurrentWamEndPos.X, (int)_debugCurrentWamEndPos.Y));
                }
            }

            if (_debugDrawRoomView && ImGui.Begin("ROOM TEST", ref _debugDrawRoomView))
            {
                ImGui.Combo("Select Room", ref _debugCurrentRoomIndex, _debugRoomList, _debugRoomList.Length);

                if (_debugCurrentRoomIndex != 0)
                {
                    var curRoom = Database.Room.Include(x => x.WalkableAreaMap)
                                  .AsEnumerable().ElementAt(_debugCurrentRoomIndex - 1);
                    ImGui.Text($"WAM: {curRoom.WalkableAreaMap.WamFile}({curRoom.WalkableAreaMap.Id})");
                    if (ImGui.Button("Load"))
                    {
                        LoadRoom(curRoom.Id);
                    }
                }
            }

            var mouseState = Mouse.GetState();

            if (mouseState.MiddleButton == ButtonState.Pressed)
            {
                if (_debugIsPickingStart)
                {
                    _debugCurrentWamStartPos = new System.Numerics.Vector2(mouseState.X, mouseState.Y);
                }

                if (_debugIsPickingEnd)
                {
                    _debugCurrentWamEndPos = new System.Numerics.Vector2(mouseState.X, mouseState.Y);
                }

                _debugIsPickingStart = false;
                _debugIsPickingEnd   = false;
            }
        }