Example #1
0
        public static GameResponseEntry[] GetGameList(
            AsyncRPGDataContext context)
        {
            List <GameResponseEntry> gameList = new List <GameResponseEntry>();
            var query = from g in context.Games
                        join a in context.Accounts on g.OwnerAccountID equals a.AccountID into sr
                        from x in sr.DefaultIfEmpty()
                        select new
            {
                g.GameID,
                g.Name,
                g.OwnerAccountID,
                OwnerAccountName = x.UserName ?? ""             // Can be null if the game isn't owned by anyone
            };

            foreach (var dbEntry in query)
            {
                GameResponseEntry entry = new GameResponseEntry();

                entry.game_id            = dbEntry.GameID;
                entry.game_name          = dbEntry.Name;
                entry.owner_account_id   = dbEntry.OwnerAccountID;
                entry.owner_account_name = dbEntry.OwnerAccountName;
                entry.character_names    = null;

                gameList.Add(entry);
            }

            //join g in context.games on c.gameid equals g.gameid
            return(gameList.ToArray());
        }
Example #2
0
    public void OnSelectedGameChanged(int scrollIndex)
    {
        GameResponseEntry gameEntry = SelectGameController.Model.GetGameEntry(scrollIndex);

        // Update the data in the game info panel
        m_gamePanel.ShowGameData(gameEntry);

        // Notify the controller
        SelectGameController.OnSelectedGameChanged(scrollIndex);
    }
    public void RequestGameList()
    {
        if (!IsGameListRequestPending)
        {
            AsyncJSONRequest gameListRequest = AsyncJSONRequest.Create(m_selectGameController.gameObject);

            IsGameListRequestPending = true;

            gameListRequest.GET(
                ServerConstants.gameListRequestURL,
                (AsyncJSONRequest asyncRequest) =>
            {
                if (asyncRequest.GetRequestState() == AsyncJSONRequest.eRequestState.succeded)
                {
                    JsonData response     = asyncRequest.GetResult();
                    string responseResult = (string)response["result"];

                    if (responseResult == "Success")
                    {
                        SessionData sessionData = SessionData.GetInstance();
                        JsonData gamesList      = response["game_list"];

                        sessionData.GameList = new List <GameResponseEntry>();
                        for (int listIndex = 0; listIndex < gamesList.Count; listIndex++)
                        {
                            sessionData.GameList.Add(GameResponseEntry.FromObject(gamesList[listIndex]));
                        }

                        if (sessionData.GameList.Count > 0)
                        {
                            SelectedListIndex = 0;
                        }

                        m_selectGameController.OnGameListUpdated();
                    }
                    else
                    {
                        m_selectGameController.OnRequestFailed(responseResult);
                        Debug.LogError("Get Game List Failed: " + asyncRequest.GetFailureReason());
                    }
                }
                else
                {
                    m_selectGameController.OnRequestFailed("Connection Failure!");
                    Debug.LogError("Get Game List Failed: " + asyncRequest.GetFailureReason());
                }

                IsGameListRequestPending = false;
            });
        }
    }
    public static GameResponseEntry FromObject(JsonData jsonData)
    {
        GameResponseEntry result = new GameResponseEntry();

        result.game_id = (int)jsonData["game_id"];
        result.game_name = (string)jsonData["game_name"];
        result.owner_account_id = (int)jsonData["owner_account_id"];
        result.owner_account_name = (string)jsonData["owner_account_name"];

        JsonData character_names = jsonData["character_names"];
        for (int namesListIndex= 0; namesListIndex < character_names.Count; namesListIndex++)
        {
            result.character_names.Add((string)character_names[namesListIndex]);
        }

        return result;
    }
    public GameThumbnailWidget(WidgetGroup parentGroup, GameThumbnailStyle style, GameResponseEntry gameInfo, float x, float y)
        : base(parentGroup, style.Width, style.Height, x, y)
    {
        new ImageWidget(this, style.Width, style.Height, style.Background, 0.0f, 0.0f);

        LabelWidget gameNameLabel =
            new LabelWidget(
                this,
                40, style.LabelHeight,
                BORDER_WIDTH, BORDER_WIDTH,
                "Game:");

        gameNameLabel.Alignment = TextAnchor.UpperRight;

        LabelWidget gameOwnerLabel =
            new LabelWidget(
                this,
                40, style.LabelHeight,
                BORDER_WIDTH, gameNameLabel.LocalY + gameNameLabel.Height,
                "Owner:");

        gameOwnerLabel.Alignment = TextAnchor.UpperRight;

        {
            float textWidth = style.Width - gameNameLabel.Width - 2 * BORDER_WIDTH;
            float textX     = BORDER_WIDTH + gameNameLabel.Width;

            LabelWidget gameNameText =
                new LabelWidget(
                    this,
                    textWidth, style.LabelHeight,
                    textX, BORDER_WIDTH,
                    gameInfo.game_name);
            gameNameText.Alignment = TextAnchor.UpperLeft;

            LabelWidget gameOwnerText =
                new LabelWidget(
                    this,
                    textWidth, style.LabelHeight,
                    textX, gameNameText.LocalY + gameNameText.Height,
                    gameInfo.owner_account_name);
            gameOwnerText.Alignment = TextAnchor.UpperLeft;
        }

        this.Visible = false;
    }
Example #6
0
    public static GameResponseEntry FromObject(JsonData jsonData)
    {
        GameResponseEntry result = new GameResponseEntry();

        result.game_id            = (int)jsonData["game_id"];
        result.game_name          = (string)jsonData["game_name"];
        result.owner_account_id   = (int)jsonData["owner_account_id"];
        result.owner_account_name = (string)jsonData["owner_account_name"];

        JsonData character_names = jsonData["character_names"];

        for (int namesListIndex = 0; namesListIndex < character_names.Count; namesListIndex++)
        {
            result.character_names.Add((string)character_names[namesListIndex]);
        }

        return(result);
    }
    public GameThumbnailWidget(WidgetGroup parentGroup, GameThumbnailStyle style, GameResponseEntry gameInfo, float x, float y)
        : base(parentGroup, style.Width, style.Height, x, y)
    {
        new ImageWidget(this, style.Width, style.Height, style.Background, 0.0f, 0.0f);

        LabelWidget gameNameLabel =
            new LabelWidget(
                this,
                40, style.LabelHeight,
                BORDER_WIDTH, BORDER_WIDTH,
                "Game:");
        gameNameLabel.Alignment = TextAnchor.UpperRight;

        LabelWidget gameOwnerLabel =
            new LabelWidget(
                this,
                40, style.LabelHeight,
                BORDER_WIDTH, gameNameLabel.LocalY + gameNameLabel.Height,
                "Owner:");
        gameOwnerLabel.Alignment = TextAnchor.UpperRight;

        {
            float textWidth = style.Width - gameNameLabel.Width - 2 * BORDER_WIDTH;
            float textX = BORDER_WIDTH + gameNameLabel.Width;

            LabelWidget gameNameText =
                new LabelWidget(
                    this,
                    textWidth, style.LabelHeight,
                    textX, BORDER_WIDTH,
                    gameInfo.game_name);
            gameNameText.Alignment = TextAnchor.UpperLeft;

            LabelWidget gameOwnerText =
                new LabelWidget(
                    this,
                    textWidth, style.LabelHeight,
                    textX, gameNameText.LocalY + gameNameText.Height,
                    gameInfo.owner_account_name);
            gameOwnerText.Alignment = TextAnchor.UpperLeft;
        }

        this.Visible = false;
    }
    public void ShowGameData(GameResponseEntry gameEntry)
    {
        m_nameLabel.Visible = true;
        m_nameText.Visible  = true;
        m_nameText.Text     = gameEntry.game_name;

        m_ownerLabel.Visible = true;
        m_ownerText.Visible  = true;
        m_ownerText.Text     = gameEntry.owner_account_name;

        m_charactersLabel.Visible = true;
        m_charactersText.Visible  = true;

        string characterNames = "";

        foreach (string characterName in gameEntry.character_names)
        {
            characterNames += ("  " + characterName + "\n");
        }

        m_charactersText.Text = characterNames;
    }
Example #9
0
    public void ShowGameData(GameResponseEntry gameEntry)
    {
        m_nameLabel.Visible= true;
        m_nameText.Visible = true;
        m_nameText.Text = gameEntry.game_name;

        m_ownerLabel.Visible= true;
        m_ownerText.Visible= true;
        m_ownerText.Text= gameEntry.owner_account_name;

        m_charactersLabel.Visible = true;
        m_charactersText.Visible = true;

        string characterNames = "";
        foreach (string characterName in gameEntry.character_names)
        {
            characterNames += ("  "+characterName + "\n");
        }

        m_charactersText.Text = characterNames;
    }