Пример #1
0
        public void UpdateStatusMenu()
        {
            RoomMetadata roomMetadata = GameInformation.Instance.RoomMetadata;

            spriteList[0].SourceRectangle = GameModePreset[roomMetadata.GameMode];
            spriteList[1].SourceRectangle = RoomSizePreset[roomMetadata.Size];
            spriteList[2].SourceRectangle = GameMapTypePreset[roomMetadata.Map.GameMapType];
            spriteList[3].SourceRectangle = SlotModeTypePreset[roomMetadata.SlotModeType];
            spriteList[4].SourceRectangle = MatchSuddenDeathPreset[roomMetadata.MatchSuddenDeathType];
            spriteList[5].SourceRectangle = TurnsToSuddenDeathPreset[roomMetadata.TurnsToSuddenDeath];

            //Minimap icon
            GameMap     map  = GameInformation.Instance.RoomMetadata.Map.GameMap;
            GameMapType type = GameInformation.Instance.RoomMetadata.Map.GameMapType;

            mapThumbnail          = new Sprite($"Graphics/Maps/{map}/GameRoomThumb{type}", layerDepth: DepthParameter.WeatherEffect);
            mapThumbnail.Position = basePosition - new Vector2(1, 78f);

            //Maps Weather
            //if (matchMetadata.Map.GameMap == GameMap.Random)
            //but since I dont know the right information about all the maps
            //i'll keep it simple
            if (roomMetadata.Map.Force == -1)
            {
                numericSpriteFontList.ForEach((x) => x.HideElement());
                interrogationSpriteList.ForEach((x) => x.ShowElement());
            }
            else
            {
                numericSpriteFontList.ForEach((x) => x.ShowElement());
                interrogationSpriteList.ForEach((x) => x.HideElement());
            }

            for (int i = 0; i < roomMetadata.Map.WeatherPreset.Length; i++)
            {
                numericSpriteFontList[i].UpdateValue(roomMetadata.Map.WeatherPreset[i]);
                numericSpriteFontList[i].Update();
            }

            //MapName
            spriteTextList[0].Text = roomMetadata.Map.Name;
            spriteTextList[1].Text = $"{roomMetadata.ID} {roomMetadata.Name}";
            numericSpriteFontList.ForEach((x) => x.Update());
        }
        public static bool ServerOrSingle_MapCreate()
        {
            GameNetworkServer server = GameNetworkServer.Instance;

            Control mapLoadingWindow = null;

            //show map loading window
            mapLoadingWindow = ControlDeclarationManager.Instance.CreateControl("Gui\\MapLoadingWindow.gui");
            if (mapLoadingWindow != null)
            {
                mapLoadingWindow.Text = "Procedural map creation";
                GameEngineApp.Instance.ControlManager.Controls.Add(mapLoadingWindow);
            }

            //delete all GameWindow's
            GameEngineApp.Instance.DeleteAllGameWindows();

            MapSystemWorld.MapDestroy();

            EngineApp.Instance.RenderScene();

            //create world if need
            WorldType worldType = EntitySystemWorld.Instance.DefaultWorldType;

            if (World.Instance == null || World.Instance.Type != worldType)
            {
                WorldSimulationTypes worldSimulationType;
                EntitySystemWorld.NetworkingInterface networkingInterface = null;

                if (server != null)
                {
                    worldSimulationType = WorldSimulationTypes.ServerAndClient;
                    networkingInterface = server.EntitySystemService.NetworkingInterface;
                }
                else
                {
                    worldSimulationType = WorldSimulationTypes.Single;
                }

                if (!EntitySystemWorld.Instance.WorldCreate(worldSimulationType, worldType, networkingInterface))
                {
                    Log.Fatal("ExampleOfProceduralMapCreation: ServerOrSingle_MapCreate: EntitySystemWorld.Instance.WorldCreate failed.");
                }
            }

            //create map
            GameMapType gameMapType = EntityTypes.Instance.GetByName("GameMap") as GameMapType;

            if (gameMapType == null)
            {
                Log.Fatal("ExampleOfProceduralMapCreation: ServerOrSingle_MapCreate: \"GameMap\" type is not defined.");
            }
            GameMap gameMap = (GameMap)Entities.Instance.Create(gameMapType, World.Instance);

            gameMap.ShadowFarDistance = 60;
            gameMap.ShadowColor       = new ColorValue(.5f, .5f, .5f);

            //create MapObjects
            ServerOrSingle_CreateEntities();

            //post create map
            gameMap.PostCreate();

            //inform clients about world created
            if (server != null)
            {
                server.EntitySystemService.WorldWasCreated();
            }

            //Error
            foreach (Control control in GameEngineApp.Instance.ControlManager.Controls)
            {
                if (control is MessageBoxWindow && !control.IsShouldDetach())
                {
                    return(false);
                }
            }

            GameEngineApp.Instance.CreateGameWindowForMap();

            //play music
            if (GameMap.Instance != null)
            {
                GameMusic.MusicPlay(GameMap.Instance.GameMusic, true);
            }

            return(true);
        }
Пример #3
0
        public Minimap(RoomMetadata roomMetadata, Vector2 position)
        {
            spawnPointList = new List <Sprite>();
            playerNameList = new List <SpriteText>();

            //Map
            Map         map     = GameInformation.Instance.RoomMetadata.Map;
            GameMap     gameMap = GameInformation.Instance.RoomMetadata.Map.GameMap;
            GameMapType type    = GameInformation.Instance.RoomMetadata.Map.GameMapType;

            Vector2 frameSize = new Vector2(750, 159); //Size of the small minimap frame on the background image

            mapBG          = new Sprite($"Graphics/Maps/{gameMap}/Background", layerDepth: DepthParameter.Background);
            mapBG.Position = position;

            float maxScale = Math.Max(frameSize.X / mapBG.SpriteWidth, frameSize.Y / mapBG.SpriteHeight);

            mapBG.Scale = new Vector2(maxScale, maxScale);

            //Find the very first pixel on the top of the central axis of sprite and the first on the bottom
            //In order to help centralizing (if possible) the sprite
            mapFG        = new Sprite($@"Graphics/Maps/{gameMap}/Foreground{type}", layerDepth: DepthParameter.LoadingScreenMinimapForeground);
            maxScale     = Math.Max(frameSize.X / mapFG.SpriteWidth, frameSize.Y / mapFG.SpriteHeight);
            mapFG.Scale  = new Vector2(maxScale, maxScale);
            basePosition = mapFG.Position = position;

            //Spawn Points
            spawnPointsOffset = new List <Vector2>();
            foreach (KeyValuePair <int, int[]> playerPos in roomMetadata.SpawnPositions.ToList())
            {
                Player player = roomMetadata.TeamASafe.Find((y) => y.ID == playerPos.Key);

                int   box       = 1;
                Color nameColor = Parameter.TextColorTeamRed;

                if (player == null)
                {
                    player = roomMetadata.TeamBSafe.Find((y) => y.ID == playerPos.Key);

                    box       = 2;
                    nameColor = Parameter.TextColorTeamBlue;
                }

                Vector2 boxPosition = mapFG.Position + (new Vector2(playerPos.Value[0], playerPos.Value[1]) - mapFG.Pivot) * mapFG.Scale;

                Sprite boxSprite = new Sprite("Interface/InGame/Scene/LoadingScreen/PlayerMapMarker",
                                              position: boxPosition, layerDepth: DepthParameter.LoadingScreenMinimapSpawnPointBox,
                                              sourceRectangle: new Rectangle(14 * box, 0, 14, 14))
                {
                    Pivot = new Vector2(7, 7)
                };

                spawnPointList.Add(boxSprite);
                spawnPointsOffset.Add(boxPosition - mapFG.Position);

                playerNameList.Add(new SpriteText(
                                       FontTextType.Consolas10, player.Nickname,
                                       nameColor, Alignment.Center,
                                       layerDepth: DepthParameter.LoadingScreenMinimapSpawnPointText, boxPosition - new Vector2(0, 20), Color.Black));
            }

            //Filter remaining spawn points and add them to remainingSpawnPoints, then add the white square sprite
            List <int[]> remainingSpawnPositions = new List <int[]>();

            foreach (int[] spawnPoints in map.SpawnPoints)
            {
                if (roomMetadata.SpawnPositions.Values.ToList().Find((x) => x[0] == spawnPoints[0] && x[1] == spawnPoints[1]) == null)
                {
                    remainingSpawnPositions.Add(spawnPoints);
                }
            }

            foreach (int[] spawnPosition in remainingSpawnPositions)
            {
                Vector2 boxOffset = (new Vector2(spawnPosition[0], spawnPosition[1]) - mapFG.Pivot) * mapFG.Scale;
                Sprite  boxSprite = new Sprite("Interface/InGame/Scene/LoadingScreen/PlayerMapMarker",
                                               position: mapFG.Position + boxOffset,
                                               layerDepth: DepthParameter.LoadingScreenMinimapSpawnPointBox,
                                               sourceRectangle: new Rectangle(0, 0, 14, 14))
                {
                    Pivot = new Vector2(7, 7)
                };

                spawnPointList.Add(boxSprite);
                spawnPointsOffset.Add(boxOffset);
            }
            ;

            mapName = new SpriteText(FontTextType.Consolas11, roomMetadata.Map.Name,
                                     Color.White, Alignment.Left, DepthParameter.InterfaceButton,
                                     position + new Vector2(-365, -72), Color.Black);

            mapHelper = new SpriteText(FontTextType.Consolas11, Language.LoadingScreenMinimapCommand, Color.White, Alignment.Right, DepthParameter.InterfaceButton, position + new Vector2(365, 67), Color.Black);

            UpdateElementPositions(Vector2.Zero);
            totalButtonPushTime = 0;

            //TacticalMap
            tacticalMapDimensions = new Vector2(750, 159) / 2f;
            miVect = mapFG.Pivot * mapFG.Scale;

            Vector2 playerPosition = roomMetadata.SpawnPositions[GameInformation.Instance.PlayerInformation.ID].ToVector2() * mapFG.Scale;

            UpdateElementPositions((miVect - playerPosition) * Vector2.UnitY);
        }
Пример #4
0
        public void SpawnMapElements()
        {
            GameMap     map  = GameInformation.Instance.RoomMetadata.Map.GameMap;
            GameMapType type = GameInformation.Instance.RoomMetadata.Map.GameMapType;

            Background     = new Sprite($@"Graphics/Maps/{map}/Background", layerDepth: DepthParameter.Background);
            BackgroundSize = new Vector2(Background.SpriteWidth, Background.SpriteHeight);

            Foreground = new Sprite($@"Graphics/Maps/{map}/Foreground{type}",
                                    layerDepth: DepthParameter.Foreground, shouldCopyAsset: true);

            BackgroundFlipbookList       = new List <Renderable>();
            BackgroundFlipbookOffsetList = new List <Vector2>();

            int i = 1;

            switch (map)
            {
                #region Metamine/Facky
            case GameMap.Metamine:
                BackgroundFlipbookList = new List <Renderable>
                {
                    new Flipbook(Vector2.Zero, Vector2.Zero, 52, 111, $@"Graphics/Maps/{map}/BackgroundAnimation{i++}", new AnimationInstance()
                    {
                        EndingFrame = 14, TimePerFrame = 0.1f
                    }, DepthParameter.BackgroundAnim),
                    new Flipbook(Vector2.Zero, Vector2.Zero, 116, 191, $@"Graphics/Maps/{map}/BackgroundAnimation{i++}", new AnimationInstance()
                    {
                        EndingFrame = 9, TimePerFrame = 0.1f, AnimationType = AnimationType.Cycle
                    }, DepthParameter.BackgroundAnim),
                    new Flipbook(Vector2.Zero, Vector2.Zero, 64, 192, $@"Graphics/Maps/{map}/BackgroundAnimation{i++}", new AnimationInstance()
                    {
                        EndingFrame = 9, TimePerFrame = 0.1f
                    }, DepthParameter.BackgroundAnim),
                    new Flipbook(Vector2.Zero, Vector2.Zero, 100, 186, $@"Graphics/Maps/{map}/BackgroundAnimation{i++}", new AnimationInstance()
                    {
                        EndingFrame = 11, TimePerFrame = 0.2f
                    }, DepthParameter.BackgroundAnim),
                };

                BackgroundFlipbookOffsetList = new List <Vector2>()
                {
                    new Vector2(-38, -403), new Vector2(-192, -158), new Vector2(163, -270), new Vector2(124, -116)
                };
                break;

                #endregion
                #region SeaOfHero/Candy
            case GameMap.SeaOfHero:
                BackgroundFlipbookList = new List <Renderable>
                {
                    new Flipbook(Vector2.Zero, Vector2.Zero, 142, 161, $@"Graphics/Maps/{map}/BackgroundAnimation{i++}", new AnimationInstance()
                    {
                        EndingFrame = 19, TimePerFrame = 0.2f
                    }, DepthParameter.BackgroundAnim),
                    new Flipbook(Vector2.Zero, Vector2.Zero, 74, 124, $@"Graphics/Maps/{map}/BackgroundAnimation{i++}", new AnimationInstance()
                    {
                        EndingFrame = 19, TimePerFrame = 0.5f, AnimationType = AnimationType.Cycle
                    }, DepthParameter.BackgroundAnim),
                    new Flipbook(Vector2.Zero, Vector2.Zero, 86, 76, $@"Graphics/Maps/{map}/BackgroundAnimation{i++}", new AnimationInstance()
                    {
                        EndingFrame = 1, TimePerFrame = 5f
                    }, DepthParameter.BackgroundAnim),
                };

                BackgroundFlipbookOffsetList = new List <Vector2>()
                {
                    new Vector2(-415, -235), new Vector2(208, -34), new Vector2(110, 033)
                };
                break;

                #endregion
            default:
                return;
            }
        }