/// <summary>
    /// Sets up the UI inputs based on the player stat record selected
    /// </summary>
    /// <param name="playerId"></param>
    public void Edit(int playerId)
    {
        ResetGUI();

        _playerId = playerId;

        // determine if the record exists
        bool recordExists;
        var  firstRecord = dbManager.QueryFirstRecord <PlayerStats>(out recordExists, "SELECT * FROM PlayerStats WHERE PlayerID = ?", _playerId);

        if (recordExists)
        {
            // show the edit panel;
            editPanel.SetActive(true);

            // set the player id label
            playerIdLabel.text = "PlayerId: " + _playerId.ToString();

            // populate the edit fields with the record if it exists
            playerNameInput.text = firstRecord.PlayerName;
            totalKillsInput.text = firstRecord.TotalKills.ToString();
            pointsInput.text     = firstRecord.Points.ToString();
        }
        else
        {
            // hide the edit panel
            editPanel.SetActive(false);
        }
    }
Example #2
0
    void Start()
    {
        // Gather a list of weapons and their type names pulled from the weapontype table
        List <Weapon> weaponList = dbManager.Query <Weapon>(
            "SELECT " +
            "W.WeaponID, " +
            "W.WeaponName, " +
            "W.Damage, " +
            "W.Cost, " +
            "W.Weight, " +
            "W.WeaponTypeID, " +
            "T.Description AS WeaponTypeDescription " +
            "FROM " +
            "Weapon W " +
            "JOIN WeaponType T " +
            "ON W.WeaponTypeID = T.WeaponTypeID " +
            "ORDER BY " +
            "W.WeaponID "
            );

        // output the list of weapons
        outputText.text = "Weapons\n\n";
        foreach (Weapon weaponRecord in weaponList)
        {
            outputText.text += "<color=#1abc9c>Name</color>: '" + weaponRecord.WeaponName + "' " +
                               "<color=#1abc9c>Damage</color>:" + weaponRecord.Damage.ToString() + " " +
                               "<color=#1abc9c>Cost</color>:" + weaponRecord.Cost.ToString() + " " +
                               "<color=#1abc9c>Weight</color>:" + weaponRecord.Weight.ToString() + " " +
                               "<color=#1abc9c>Type</color>:" + weaponRecord.WeaponTypeDescription + "\n";
        }


        // get the first weapon record that has a WeaponID > 4
        outputText.text += "\nFirst weapon record where the WeaponID > 4: ";
        bool   recordExists;
        Weapon firstWeaponRecord = dbManager.QueryFirstRecord <Weapon>(out recordExists, "SELECT WeaponName FROM Weapon WHERE WeaponID > 4");

        if (recordExists)
        {
            outputText.text += firstWeaponRecord.WeaponName + "\n";
        }
        else
        {
            outputText.text += "No record found\n";
        }
    }