public static void ConnectToRoom(RoomMetadata roomMetadata) { ServerInformationBroker.Instance.GameServerServiceProvider.RequestQueue.Enqueue( NetworkObjectParameters.GameServerRoomListRoomEnter, roomMetadata ); }
public PopupGameResults() : base(false) { RoomMetadata room = GameInformation.Instance.RoomMetadata; //Background if (room.VictoriousTeam == PlayerTeam.Red) { Background = new Sprite("Interface/Popup/Blue/Results/Background1", layerDepth: DepthParameter.InterfacePopupBackground); background2 = new Sprite("Interface/Popup/Blue/Results/Background2", layerDepth: DepthParameter.InterfacePopupBackground); } else { Background = new Sprite("Interface/Popup/Blue/Results/Background2", layerDepth: DepthParameter.InterfacePopupBackground); background2 = new Sprite("Interface/Popup/Blue/Results/Background1", layerDepth: DepthParameter.InterfacePopupBackground); } background2.PositionOffset = Background.PositionOffset; Background.PositionOffset -= new Vector2(180, 0); background2.PositionOffset += new Vector2(180, 0); //Player - Team Red nameplateList = new List <Nameplate>(); spriteList = new List <Sprite>(); AppendPlayersToTable(room.TeamASafe, Background.PositionOffset, true); AppendPlayersToTable(room.TeamBSafe, background2.PositionOffset, false); buttonList.Add(new Button(ButtonType.Accept, DepthParameter.InterfacePopupButtons, OnAcceptAction, PositionOffset + new Vector2(325, 132))); UpdateAttatchmentPosition(); shouldRender = true; }
public GameList() { animatedButtonList = new List <AnimatedButton>(); roomButtonList = new List <RoomButton>(); requestedRoomMetadataList = new List <RoomMetadata>(); Background = new Sprite(@"Interface/InGame/Scene/GameList/Background", position: Parameter.ScreenCenter, layerDepth: DepthParameter.Background, shouldCopyAsset: false); CreateBottomBarAnimatedButtons(); CreateRoomFilteringAnimatedButtons(); //popups PopupHandler.PopupGameOptions.OnClose = OptionsCloseAction; createGamePopup = new PopupCreateGame(Vector2.Zero); createGamePopup.OnClose = (sender) => { UnlockAllInterfaceElements(); }; PopupHandler.Add(createGamePopup); //button positioning variables widthFactor = Background.SpriteWidth / 3; heightFactor = 69; buttonHeightPosition = 140 - (int)Parameter.ScreenCenter.Y; //Room Filtering roomFilter = new RoomMetadata(GameMode.Any, default, default, default, default, 0, default, default);
public LevelScene() { GameInformation.Instance.GameState = GameState.InGame; MobileList = new List <Mobile>(); WeatherHandler = new WeatherHandler(); ThorSatellite = new ThorSatellite(); MineList = new List <Mobile>(); ToBeRemovedMineList = new List <Mobile>(); //Popup related isLeaveGamePopupRendered = false; //Spawning units on the selected coordinates RoomMetadata room = GameInformation.Instance.RoomMetadata; ownedMobile = null; foreach (KeyValuePair <int, int[]> coordinate in room.SpawnPositions) { foreach (Player p in room.PlayerList) { if (p.ID == coordinate.Key) { Mobile mob = ActorBuilder.BuildMobile(p.PrimaryMobile, p, new Vector2(coordinate.Value[0], coordinate.Value[1])); MobileList.Add(mob); if (p.ID == GameInformation.Instance.PlayerInformation.ID) { ownedMobile = mob; } } } } SpawnMapElements(); ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerInGameStartMatch, StartMatchAsyncCallback); ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerInGameRequestShot, RequestShotAsyncCallback); ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerInGameRequestItemUsage, RequestItemAsyncCallback); ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerInGameRefreshSyncMobile, RefreshSyncMobileAsyncCallback); ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerInGameRequestNextPlayerTurn, RequestNextPlayerTurnAsyncCallback); ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerInGameRequestDeath, RequestDeathAsyncCallback); ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerInGameRequestGameEnd, RequestGameEndAsyncCallback); ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerInGameRequestDisconnect, RequestDisconnectAsyncCallback); //Gold Handler ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerInGameRequestDamage, ReceiveGoldUpdateRequest); //Textbox handlers ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerChatSendPlayerMessage, (o) => HUD.OnReceiveMessageAsyncCallback(o, 0)); ServerInformationBroker.Instance.ActionCallbackDictionary.AddOrReplace(NetworkObjectParameters.GameServerChatSendSystemMessage, (o) => HUD.OnReceiveMessageAsyncCallback(o, 1)); //Threads TerminateThreads = false; StartTurnRequesterThread(); }
public void CreateRoom(RoomMetadata room) { //Insert the room to the match metadata list; RoomMetadataSortedList.Add(room.ID, room); //Create and connect on the chat for the room ChatDictionary[NetworkObjectParameters.GameServerChatGameRoomIdentifier][room.ID] = new HashSet <Player>(); }
public void UpdatePlayerButtonList() { RoomMetadata room = GameInformation.Instance.RoomMetadata; RemovePlayerButtons(room.TeamASafe, room.TeamBSafe); CreatePlayerButtons(room.TeamASafe, room.TeamBSafe); UpdatePlayerButtonPositions(); }
private static void UpdateRoomMetadataAsyncCallback(object answer) { RoomMetadata room = (RoomMetadata)answer; lock (GameInformation.Instance.RoomMetadata) { GameInformation.Instance.RoomMetadata = room; } }
public static RoomButton CreateRoomButton(RoomMetadata roomMetadata, Vector2 buttonPosition, Action <object> action) { if (RoomButtonPresets == null) { Initialize(); } return(new RoomButton(roomMetadata, buttonPosition, action, RoomButtonPresets[roomMetadata.RoomOwner.PlayerStatus][roomMetadata.GameMode])); }
private bool HasBuddyInside(RoomMetadata matchMetadata) { List <Player> inGamePlayers = matchMetadata.TeamASafe.Union(matchMetadata.TeamBSafe).ToList(); #warning needs refactoring due new friend list structure //Player match = GameInformation.Instance.PlayerInformation.BefriendedFrom?.First((x) => inGamePlayers.Contains(x)); //return match != null; return(false); }
public PopupCreateGame(Vector2 positionOffset) : base(false) { Background = new Sprite("Interface/Popup/Blue/CreateRoom/Background", position: Parameter.ScreenCenter, layerDepth: DepthParameter.InterfacePopupBackground); buttonList.Add(new Button(ButtonType.CreateGame1v1, DepthParameter.InterfacePopupButtons, (sender) => { CreateGameRoomSizeButtonAction(sender, RoomSize.OneVsOne); })); buttonList.Add(new Button(ButtonType.CreateGame2v2, DepthParameter.InterfacePopupButtons, (sender) => { CreateGameRoomSizeButtonAction(sender, RoomSize.TwoVsTwo); })); buttonList.Add(new Button(ButtonType.CreateGame3v3, DepthParameter.InterfacePopupButtons, (sender) => { CreateGameRoomSizeButtonAction(sender, RoomSize.ThreeVsThree); })); buttonList.Add(new Button(ButtonType.CreateGame4v4, DepthParameter.InterfacePopupButtons, (sender) => { CreateGameRoomSizeButtonAction(sender, RoomSize.FourVsFour); })); buttonList.Add(new Button(ButtonType.CreateGameJewel, DepthParameter.InterfacePopupButtons, (sender) => { CreateGameGameModeButtonAction(sender, GameMode.Jewel); })); buttonList.Add(new Button(ButtonType.CreateGameTag, DepthParameter.InterfacePopupButtons, (sender) => { CreateGameGameModeButtonAction(sender, GameMode.Tag); })); buttonList.Add(new Button(ButtonType.CreateGameScore, DepthParameter.InterfacePopupButtons, (sender) => { CreateGameGameModeButtonAction(sender, GameMode.Score); })); buttonList.Add(new Button(ButtonType.CreateGameSolo, DepthParameter.InterfacePopupButtons, (sender) => { CreateGameGameModeButtonAction(sender, GameMode.Solo); })); buttonList.Add(new Button(ButtonType.Accept, DepthParameter.InterfacePopupButtons, CreateRoomAction)); buttonList.Add(new Button(ButtonType.Cancel, DepthParameter.InterfacePopupButtons, CloseAction)); compositeSpriteTextSentenceList = new List <SpriteText>(); compositeSpriteTextSentenceList.Add(new SpriteText(FontTextType.Consolas10, "", Color.White, Alignment.Left, DepthParameter.InterfacePopupText, outlineColor: Color.Black)); compositeSpriteTextSentenceList.Add(new SpriteText(FontTextType.Consolas10, "", Color.White, Alignment.Left, DepthParameter.InterfacePopupText, outlineColor: Color.Black)); compositeSpriteTextList.Add(CompositeSpriteText.CreateCompositeSpriteText(compositeSpriteTextSentenceList, Orientation.Vertical, Alignment.Left, new Vector2(0, 0), 5)); compositeSpriteTextList.Add(CompositeSpriteText.CreateCompositeSpriteText( new List <SpriteText>() { new SpriteText(FontTextType.Consolas10, Language.PopupCreateRoomTitle, Color.White, Alignment.Left, DepthParameter.InterfacePopupText, outlineColor: Color.Black), new SpriteText(FontTextType.Consolas10, Language.PopupCreateRoomPassword, Color.White, Alignment.Left, DepthParameter.InterfacePopupText, outlineColor: Color.Black) }, Orientation.Vertical, Alignment.Right, Vector2.Zero, 9)); //Button Texts spriteTextList.Add(new SpriteText(FontTextType.Consolas10, Language.GameModeJewel, Color.White, Alignment.Center, DepthParameter.InterfacePopupText)); spriteTextList.Add(new SpriteText(FontTextType.Consolas10, Language.GameModeTag, Color.White, Alignment.Center, DepthParameter.InterfacePopupText)); spriteTextList.Add(new SpriteText(FontTextType.Consolas10, Language.GameModeScore, Color.White, Alignment.Center, DepthParameter.InterfacePopupText)); spriteTextList.Add(new SpriteText(FontTextType.Consolas10, Language.GameModeSolo, Color.White, Alignment.Center, DepthParameter.InterfacePopupText)); //Room default configurations buttonList[3].ChangeButtonState(ButtonAnimationState.Activated, true); buttonList[7].ChangeButtonState(ButtonAnimationState.Activated, true); //Button variable helpers roomMetadata = new RoomMetadata(GameMode.Score, TurnsToSuddenDeath.Turn56, MatchSuddenDeathType.NoDeath, RoomSize.FourVsFour, GameInformation.Instance.PlayerInformation, 0, "", ""); roomSizeButtons = buttonList.GetRange(0, 4); gameTypeButtons = buttonList.GetRange(4, 4); roomSizeButtons.Union(gameTypeButtons).ToList().ForEach((x) => x.OnBeingReleased = (sender) => ((Button)sender).ChangeButtonState(ButtonAnimationState.Activated, true)); //Textfields textFieldList = new List <TextField>() { new TextField(default, 185, 14, 16, FontTextType.Consolas10, Color.White, DepthParameter.InterfacePopupText, outlineColor: Color.Black),
private void RequestGameEndAsyncCallback(object answer) { RoomMetadata room = GameInformation.Instance.RoomMetadata; lock (room) { GameInformation.Instance.RoomMetadata.VictoriousTeam = (PlayerTeam)answer; PopupHandler.Add(new PopupGameResults()); } }
public HUD(Mobile mobile, List <Mobile> mobileList) { //Attributions this.mobile = mobile; //Initializing lists RoomMetadata room = GameInformation.Instance.RoomMetadata; spriteList = new List <Sprite>(); menuButtonList = new List <Button>(); FloatingTextHandler = new FloatingTextHandler(); spriteNumericFieldList = new List <SpriteNumericField>(); //Background Sprite barBG = new Sprite("Interface/InGame/HUD/Blue/ActionBar/Background", layerDepth: DepthParameter.HUDBackground); spriteList.Add(barBG); //Defining the origin origin = new Vector2(0, (Parameter.ScreenResolution.Y / GameScene.Camera.Zoom.Y - barBG.SpriteHeight) / 2).ToIntegerDomain(); barBG.PositionOffset = origin; //Right Menu (TAG || SCORE) if (room.GameMode == GameMode.Score) { Sprite rightMenuScoreboard = new Sprite("Interface/InGame/HUD/Blue/ActionBar/RightMenuScoreBoard", layerDepth: DepthParameter.HUDForeground, sourceRectangle: (this.mobile.Owner.PlayerTeam == PlayerTeam.Red) ? new Rectangle(0, 0, 149, 63) : new Rectangle(149, 0, 149, 63)) { PositionOffset = new Vector2(401, -11) + origin }; spriteList.Add(rightMenuScoreboard); //Team Score - Left spriteNumericFieldList.Add(new NumericSpriteFont(FontType.HUDBlueScoreboard, 1, DepthParameter.HUDL5, PositionOffset: ((this.mobile.Owner.PlayerTeam == PlayerTeam.Red) ? new Vector2(318, -5) : new Vector2(392, -5)) + origin, StartingValue: 2, textAnchor: TextAnchor.Right)); //Team Score - Right spriteNumericFieldList.Add(new NumericSpriteFont(FontType.HUDBlueScoreboard, 1, DepthParameter.HUDL5, PositionOffset: ((this.mobile.Owner.PlayerTeam == PlayerTeam.Blue) ? new Vector2(318, -5) : new Vector2(392, -5)) + origin, StartingValue: 2, textAnchor: TextAnchor.Right)); } else if (room.GameMode == GameMode.Tag) { Sprite rightMenuTag = new Sprite("Interface/InGame/HUD/Blue/ActionBar/RightMenuTag", layerDepth: DepthParameter.HUDForeground) { PositionOffset = new Vector2(326, 1) + origin }; spriteList.Add(rightMenuTag); menuButtonList.Add(new Button(ButtonType.BlueTag, DepthParameter.HUDL1, default, new Vector2(288, 9) + origin));
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 void SaveRoomInfo(string roomAddress, RoomMetadata value) { var update = Update <RoomInfoValues> .Set(i => i.Id, roomAddress) .Set(i => i.Size, value.Size) .Set(i => i.BuildingId, value.BuildingId) .Set(i => i.Floor, value.Floor) .Set(i => i.DistanceFromFloorOrigin, value.DistanceFromFloorOrigin.Clone()) .Set(i => i.Equipment, value.Equipment.ToList()) .Set(i => i.GdoDeviceId, value.GdoDeviceId) .Set(i => i.LastModified, DateTime.Now); var result = this.Collection.Update(Query <RoomInfoValues> .Where(i => i.Id == roomAddress), update, UpdateFlags.Upsert, WriteConcern.Acknowledged); if (result.DocumentsAffected != 1) { throw new Exception(string.Format("Expected to affect {0} documents, but affected {1}", 1, result.DocumentsAffected)); } }
public void SetInfo(string roomAddress, RoomMetadata roomMetadata) { var room = ExchangeServiceExecuteWithImpersonationCheck(roomAddress, svc => svc.ResolveName(roomAddress).SingleOrDefault()); if (null == room) { throw new Exception(string.Format("Room \"{0}\" not found", roomAddress)); } if (roomMetadata.DistanceFromFloorOrigin == null) { roomMetadata.DistanceFromFloorOrigin = new Point(); } if (roomMetadata.Equipment == null || roomMetadata.Equipment.Count == 0) { roomMetadata.Equipment = new List <RoomEquipment>() { RoomEquipment.None, }; } _roomRepository.SaveRoomInfo(roomAddress, roomMetadata); }
private void LoadAgentMetadata(string json) { if (json == null) { throw new ArgumentNullException("json"); } JObject o = JObject.Parse(json); foreach (var equipment in o["equipment"]) { NecessityEffect necessityEffectData = null; SkillEffect skillEffectData = null; string key = equipment["key"].ToString(); string name = equipment["name"].ToString(); int price = Int32.Parse(equipment["price"].ToString()); string iconKey = equipment["icon"].ToString(); string description = equipment["description"].ToString(); foreach (var necessityEffect in equipment["necessityEffect"]) { int health = Int32.Parse(necessityEffect["health"].ToString()); int hygiene = Int32.Parse(necessityEffect["hygiene"].ToString()); int sleep = Int32.Parse(necessityEffect["sleep"].ToString()); int thirst = Int32.Parse(necessityEffect["thirst"].ToString()); int hunger = Int32.Parse(necessityEffect["hunger"].ToString()); necessityEffectData = new NecessityEffect(health, hygiene, sleep, thirst, hunger); } foreach (var skillEffect in equipment["skillEffect"]) { int intelligence = Int32.Parse(skillEffect["intelligence"].ToString()); int creativity = Int32.Parse(skillEffect["creativity"].ToString()); int communication = Int32.Parse(skillEffect["communication"].ToString()); int leadership = Int32.Parse(skillEffect["leadership"].ToString()); skillEffectData = new SkillEffect(intelligence, creativity, communication, leadership); } AgentMetadata agentMetadata = new AgentMetadata(price, name, description, iconKey, necessityEffectData, skillEffectData); agentMetadataDictionary.Add(key, agentMetadata); } foreach (var room in o["rooms"]) { NecessityEffect necessityEffectData = null; SkillEffect skillEffectData = null; string key = room["key"].ToString(); string name = room["name"].ToString(); int price = Int32.Parse(room["price"].ToString()); string iconKey = room["icon"].ToString(); string mapPathKey = room["map"].ToString(); string description = room["description"].ToString(); foreach (var necessityEffect in room["necessityEffect"]) { int health = Int32.Parse(necessityEffect["health"].ToString()); int hygiene = Int32.Parse(necessityEffect["hygiene"].ToString()); int sleep = Int32.Parse(necessityEffect["sleep"].ToString()); int thirst = Int32.Parse(necessityEffect["thirst"].ToString()); int hunger = Int32.Parse(necessityEffect["hunger"].ToString()); necessityEffectData = new NecessityEffect(health, hygiene, sleep, thirst, hunger); } foreach (var skillEffect in room["skillEffect"]) { int intelligence = Int32.Parse(skillEffect["intelligence"].ToString()); int creativity = Int32.Parse(skillEffect["creativity"].ToString()); int communication = Int32.Parse(skillEffect["communication"].ToString()); int leadership = Int32.Parse(skillEffect["leadership"].ToString()); skillEffectData = new SkillEffect(intelligence, creativity, communication, leadership); } RoomMetadata roomMetadata = new RoomMetadata(price, name, description, iconKey, necessityEffectData, skillEffectData, mapPathKey); roomMetadataDictionary.Add(key, roomMetadata); } }
private RoomButton(RoomMetadata roomMetadata, Vector2 buttonPosition, Action <object> action, ButtonPreset buttonPreset) : base(ButtonType.RoomButton, DepthParameter.InterfaceButton, action, buttonPosition, buttonPreset) { spriteList = new List <Sprite>(); spriteFontList = new List <NumericSpriteFont>(); //Since the button elements dont update, the screencenter //must be added in order to create the right position //on the elements buttonPosition += Parameter.ScreenCenter; //MAP Vector2 mapCenter = buttonPosition + new Vector2(28, 11f); Sprite map = new Sprite($"Graphics/Maps/{roomMetadata.Map.GameMap}/GameListThumb{roomMetadata.Map.GameMapType}", mapCenter, DepthParameter.InterfaceButtonIcon); spriteList.Add(map); //RoomStatus int rectangleOffset = roomMetadata.IsPlaying ? 0 : (roomMetadata.IsFull ? 2 * 91 : 91); Sprite roomStatus = new Sprite("Interface/StaticButtons/GameList/Status", mapCenter - new Vector2(100, 0), DepthParameter.InterfaceButtonIcon, new Rectangle(rectangleOffset, 0, 91, 27)) { Pivot = new Vector2(91 / 2, 27 / 2) }; spriteList.Add(roomStatus); //RoomName SpriteText[] roomName = new SpriteText[2] { new SpriteText(FontTextType.Consolas11, string.Format("{0,3}", roomMetadata.ID) + " ", Color.White, Alignment.Left, DepthParameter.InterfaceButtonText), new SpriteText(FontTextType.Consolas11, roomMetadata.Name, Color.White, Alignment.Left, DepthParameter.InterfaceButtonText) }; compositeSpriteText = CompositeSpriteText.CreateCompositeSpriteText(roomName.ToList(), Orientation.Horizontal, Alignment.Left, buttonPosition - new Vector2(115, 25), 0); //SpriteFont NumericSpriteFont nsf = new NumericSpriteFont(FontType.GameListPlayerCounter, 1, DepthParameter.InterfaceButtonText, Position: buttonPosition + new Vector2(91, -24), StartingValue: roomMetadata.NumberOfPlayers, attachToCamera: false); spriteFontList.Add(nsf); NumericSpriteFont nsf2 = new NumericSpriteFont(FontType.GameListPlayerCounter, 1, DepthParameter.InterfaceButtonText, Position: buttonPosition + new Vector2(105, -24), StartingValue: (int)roomMetadata.Size, attachToCamera: false); spriteFontList.Add(nsf2); //IsPasswordProtected if (roomMetadata.HasPassword) { Sprite passwordLock = new Sprite("Interface/StaticButtons/GameList/PasswordProtected", mapCenter, DepthParameter.InterfaceButtonAnimatedIcon); spriteList.Add(passwordLock); } //HasBuddyInRoom if (HasBuddyInside(roomMetadata)) { Sprite buddy = new Sprite("Interface/StaticButtons/GameList/BuddyInside", mapCenter + new Vector2(32, 0), DepthParameter.InterfaceButtonAnimatedIcon); spriteList.Add(buddy); } }
public MatchConfigurationGrid(Vector2 Position) { basePosition = Position; spriteList = new List <Sprite>(); interrogationSpriteList = new List <Sprite>(); numericSpriteFontList = new List <NumericSpriteFont>(); spriteTextList = new List <SpriteText>(); RoomMetadata roomMetadata = GameInformation.Instance.RoomMetadata; Vector2 sprSize = new Vector2(242, 22); Sprite sp; //Room configuration description for (int i = 0; i < 6; i++) { sp = new Sprite( "Interface/InGame/Scene/GameRoom/Information", position: Position + new Vector2(0, (sprSize.Y - 2) * i), layerDepth: DepthParameter.InterfaceButton) { Pivot = sprSize / 2f }; spriteList.Add(sp); } //Map Weather for (int i = 0; i < roomMetadata.Map.WeatherPreset.Length; i++) { Vector2 lineOffset; if (i < 8) { lineOffset = Position - new Vector2(90, 131) + new Vector2(26, 0) * i; } else { lineOffset = numericSpriteFontList[i - 5].Position + new Vector2(0, 20); } numericSpriteFontList.Add( new NumericSpriteFont(FontType.GameRoomPingCounterWhite, 1, DepthParameter.InterfaceButton, Position: lineOffset, attachToCamera: false)); interrogationSpriteList.Add(new Sprite("Interface/Spritefont/GameRoom/Interrogation", position: lineOffset + new Vector2(4, 4), layerDepth: DepthParameter.InterfaceButton)); } //Texts spriteTextList.Add(new SpriteText( FontTextType.Consolas11, "", Color.White, Alignment.Center, DepthParameter.InterfaceButtonText, Position - new Vector2(0, 45), Color.Black)); spriteTextList.Add(new SpriteText( FontTextType.Consolas11, "", Color.White, Alignment.Left, DepthParameter.InterfaceButtonText, Position - new Vector2(85, 158), Color.Black)); UpdateStatusMenu(); }
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); }