コード例 #1
0
        private void UpdateArenaGames(XElement existingArenaXmlElement, XElement newArenaXmlElement, ArenaGameCollection games)
        {
            var existingGamesXmlElements = new Dictionary <string, XElement>();

            if (existingArenaXmlElement != null)
            {
                foreach (var gameXmlElement in existingArenaXmlElement.Elements(XmlNames.game))
                {
                    var gameType = gameXmlElement.GetAttributeValue(XmlNames.gameType);
                    if (!existingGamesXmlElements.ContainsKey(gameType))
                    {
                        existingGamesXmlElements.Add(gameType, gameXmlElement);
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Duplicated game " + gameType);
                    }
                }
            }


            foreach (var game in games)
            {
                XElement newGameXmlElement = null;
                if (existingGamesXmlElements.ContainsKey(game.GameType.ToString()))
                {
                    newGameXmlElement = existingGamesXmlElements[game.GameType.ToString()];
                }
                else
                {
                    newGameXmlElement = new XElement(XmlNames.game);
                    newGameXmlElement.AddOrUpdateAttributeValue(XmlNames.gameType, game.GameType);
                    newGameXmlElement.AddOrUpdateAttributeValue(XmlNames.templateId, XmlValues.btnArenaTexedTemplate);
                    newGameXmlElement.AddOrUpdateAttributeValue(XmlNames.rect, ArenaGame.GameTypeToRect(game.GameType));
                }

                RemovePlaceHolderAttribute(newGameXmlElement);


                AddOrRemoveNewGameAttribute(game, newGameXmlElement);

                if (game.UserMode != UserModes.Both)
                {
                    newGameXmlElement.AddOrUpdateAttributeValue(XmlNames.userMode, game.UserMode);
                }

                newArenaXmlElement.Add(new XComment(game.Name));
                newArenaXmlElement.Add(newGameXmlElement);
            }
        }
コード例 #2
0
        private void UpdateArenaGames(ArenaGameCollection games, dynamic newArenaElement)
        {
            var gamesArray = new JArray();

            foreach (var game in games)
            {
                dynamic gameElement = new JObject();

                gameElement.arenaType            = newArenaElement.type;
                gameElement.arenaTextName        = "";
                gameElement.gametype             = game.GameType;
                gameElement.isGameHasImageStates = false;
                gameElement.displayMode          = 3;
                gameElement.templateId           = JsonValues.btnArenaTexedTemplate;
                gameElement.rectId = ArenaGame.GameTypeToRect(game.GameType);

                gamesArray.Add((JObject)gameElement);
            }

            newArenaElement.games = gamesArray;
        }
コード例 #3
0
        private dynamic CreateLobbyArenaElement(Lobby lobby, ArenaCollection arenas)
        {
            dynamic newLobbyArenaElement = new JObject();


            newLobbyArenaElement.playerStatus = BuildPlayerStatusArray(lobby.PlayerStatus);
            newLobbyArenaElement.arenaLabelId = "";
            newLobbyArenaElement.type         = JsonValues.lobby;
            newLobbyArenaElement.jpVisible    = false;

            newLobbyArenaElement.favoritesSize = lobby.FavoriteSize;

            var lobbyItemsArray = new JArray();

            for (int i = 0; i < lobby.Items.Count; i++)
            {
                var lobbyItem = lobby.Items[i];



                dynamic lobbyItemXmlElement = new JObject();
                lobbyItemXmlElement.arenaType            = JsonValues.lobby;
                lobbyItemXmlElement.arenaTextName        = "";
                lobbyItemXmlElement.gametype             = lobbyItem.Id;
                lobbyItemXmlElement.iconSizeName         = JsonValues.BIG_ICON;
                lobbyItemXmlElement.isGameHasImageStates = false;
                lobbyItemXmlElement.displayMode          = 3;
                lobbyItemXmlElement.userMode             = 3;

                if (lobbyItem.JackpotVisible /*|| arenas.IsJackpotVisible(lobbyItem.Id, lobby.PlayerStatus)*/)
                {
                    lobbyItemXmlElement.templateId = JsonValues.mcDynamicTextedButtonPersonalize;
                }
                else
                {
                    lobbyItemXmlElement.templateId = JsonValues.btnDynamicTexted;
                }

                lobbyItemXmlElement.rectId = ArenaGame.GameTypeToRect(lobbyItem.Id);

                dynamic iconParamsElement = new JObject();
                if (JsonValues.x.ContainsKey(lobby.Items.Count))
                {
                    iconParamsElement.x = JsonValues.x[lobby.Items.Count][i];
                }
                else
                {
                    var oneArenaWidth = 996 / lobby.Items.Count;
                    iconParamsElement.x = oneArenaWidth * i + 1;
                }
                iconParamsElement.y            = JsonValues.y;
                iconParamsElement.width        = 166;
                iconParamsElement.height       = 200;
                lobbyItemXmlElement.iconParams = iconParamsElement;

                lobbyItemsArray.Add(lobbyItemXmlElement);
            }

            newLobbyArenaElement.games = lobbyItemsArray;

            return(newLobbyArenaElement);
        }
コード例 #4
0
        private XElement CreateLobbyArenaXmlElement(XElement[] existingArenasXmlElements, Lobby lobby, ArenaCollection arenas)
        {
            XElement existingLobbyArenaXmlElement = null;

            if (string.IsNullOrEmpty(lobby.PlayerStatus))
            {
                existingLobbyArenaXmlElement = existingArenasXmlElements.FirstOrDefault(element => element.GetAttributeValue(XmlNames.type) == XmlValues.lobby);
            }
            else
            {
                existingLobbyArenaXmlElement = existingArenasXmlElements.FirstOrDefault(element => element.GetAttributeValue(XmlNames.type) == XmlValues.lobby &&
                                                                                        element.GetAttributeValue(XmlNames.playerStatus) == lobby.PlayerStatus);
            }


            XElement newLobbyArenaXmlElement = new XElement(XmlNames.arena);

            if (existingLobbyArenaXmlElement != null)
            {
                existingLobbyArenaXmlElement.CopyAttributesTo(newLobbyArenaXmlElement);
            }


            newLobbyArenaXmlElement.AddOrUpdateAttributeValue(XmlNames.type, XmlValues.lobby);


            if (!string.IsNullOrEmpty(lobby.PlayerStatus))
            {
                newLobbyArenaXmlElement.AddOrUpdateAttributeValue(XmlNames.playerStatus, lobby.PlayerStatus);
            }

            newLobbyArenaXmlElement.AddOrUpdateAttributeValue(XmlNames.favoritesSize, lobby.FavoriteSize);

            int placeHolder = 0;

            for (int i = 0; i < lobby.Items.Count; i++)
            {
                var lobbyItem = lobby.Items[i];



                var lobbyItemXmlElement = new XElement(XmlNames.game);
                lobbyItemXmlElement.AddOrUpdateAttributeValue(XmlNames.placeHolder, placeHolder.ToString().PadLeft(2, '0'));
                lobbyItemXmlElement.AddOrUpdateAttributeValue(XmlNames.gameType, lobbyItem.Id);
                if (lobbyItem.JackpotVisible /* || arenas.IsJackpotVisible(lobbyItem.Id, lobby.PlayerStatus)*/)
                {
                    lobbyItemXmlElement.AddOrUpdateAttributeValue(XmlNames.templateId, XmlValues.mcDynamicTextedButtonPersonalize);
                }
                else
                {
                    lobbyItemXmlElement.AddOrUpdateAttributeValue(XmlNames.templateId, XmlValues.btnDynamicTexted);
                }
                if (XmlValues.x.ContainsKey(lobby.Items.Count))
                {
                    lobbyItemXmlElement.AddOrUpdateAttributeValue(XmlNames.x, XmlValues.x[lobby.Items.Count][i]);
                }
                else
                {
                    var oneArenaWidth = 996 / lobby.Items.Count;
                    lobbyItemXmlElement.AddOrUpdateAttributeValue(XmlNames.x, oneArenaWidth * i + 1);
                }
                lobbyItemXmlElement.AddOrUpdateAttributeValue(XmlNames.y, XmlValues.y);
                lobbyItemXmlElement.AddOrUpdateAttributeValue(XmlNames.iconSize, XmlValues.BIG_ICON);
                var rect = ArenaGame.GameTypeToRect(lobbyItem.Id);
                if (!string.IsNullOrEmpty(rect))
                {
                    lobbyItemXmlElement.AddOrUpdateAttributeValue(XmlNames.rect, rect);
                }
                newLobbyArenaXmlElement.Add(lobbyItemXmlElement);

                placeHolder++;
            }

            return(newLobbyArenaXmlElement);
        }