Example #1
0
    private void ResetGUI()
    {
        // Reset the temporary GUI variables
        _newPlayerName       = "";
        _newPlayerTotalKills = "";
        _newPlayerPoints     = "";

        // Loads the player stats from the database using Linq
        _playerStatsList = new List <PlayerStats> (from ps in dbManager.Table <PlayerStats> () select ps);
    }
    public void ResetGUI()
    {
        // clear out the previous list of record objects
        foreach (var recordObject in recordObjectList)
        {
            GameObject.DestroyImmediate(recordObject);
        }

        // hide the edit panel
        editPanel.SetActive(false);

        _playerId = -1;

        // Reset the temporary GUI variables
        playerIdLabel.text   = "";
        playerNameInput.text = "";
        totalKillsInput.text = "";
        pointsInput.text     = "";

        // Loads the player stats from the database using Linq
        _playerStatsList = new List <PlayerStats> (from ps in dbManager.Table <PlayerStats> () select ps);

        var y = -recordObjectHeight;

        // loop through each stat record
        foreach (var playerStatRecord in _playerStatsList)
        {
            // instantiate the record and add it to our list of objects
            var recordObject = GameObject.Instantiate(updateRecordPrefab);
            recordObjectList.Add(recordObject);

            // set the record inside the scroll view container
            recordObject.transform.SetParent(container);
            var rectTransform = recordObject.GetComponent <RectTransform>();
            rectTransform.anchoredPosition = new Vector2(10, y);

            // populate the record
            var record = recordObject.GetComponent <UpdateRecord>();
            record.SetRecord(playerStatRecord.PlayerID,
                             "<color=#1abc9c>Id:</color> " + playerStatRecord.PlayerID.ToString() + " " +
                             "<color=#1abc9c>Name:</color> " + playerStatRecord.PlayerName + " " +
                             "<color=#1abc9c>Total Kills:</color> " + playerStatRecord.TotalKills.ToString() + " " +
                             "<color=#1abc9c>Points:</color> " + playerStatRecord.Points.ToString() + "\n");

            // set the record's edit button callback to the method here
            record.editButtonClicked = Edit;

            // increment the y position for the next record
            y -= recordObjectHeight;
        }
    }
    private void ResetGUI()
    {
        // Loads the player stats from the database using Linq
        _playerStatsList = new List <PlayerStats> (from ps in dbManager.Table <PlayerStats> () select ps);

        _playerID = -1;
        if (_playerStatsList != null)
        {
            if (_playerStatsList.Count > 0)
            {
                _playerID = _playerStatsList[0].PlayerID;
            }
        }
    }
Example #4
0
    void Start()
    {
        // alternate way of populating an entire table without using a SQL statement. This uses Linq.
        // You could also use "SELECT * FROM Location" with a Query function without Linq.
        List <Location> startingLocationList = new List <Location> (from loc in dbManager.Table <Location> () select loc);

        // set up a sql query that we will reuse,
        // binding the parameter denoted by ? with the location id
        string sql = "SELECT " +
                     "CASE " +
                     "WHEN L.LocationID = M.LocationID1 THEN ML2.LocationName " +
                     "WHEN L.LocationID = M.LocationID2 THEN ML1.LocationName " +
                     "END AS LocationName " +
                     "FROM " +
                     "Location L " +
                     "JOIN LocationMapping M " +
                     "ON L.LocationID = M.LocationID1 " +
                     "OR L.LocationID = M.LocationID2 " +
                     "LEFT JOIN Location ML1 " +
                     "ON M.LocationID1 = ML1.LocationID " +
                     "LEFT JOIN Location ML2 " +
                     "ON M.LocationID2 = ML2.LocationID " +
                     "WHERE " +
                     "L.LocationID = ?";

        // loop through each starting location and gather the list of adjacent location based on our mapping table
        // using the premade query above.
        foreach (Location startingLocation in startingLocationList)
        {
            startingLocation.AdjacentLocations = dbManager.Query <Location>(sql, startingLocation.LocationID);
        }

        // output our list of starting locations along with their corresponding adjacent locations
        outputText.text = "Map adjacent locations:\n\n";
        foreach (Location startingLocationRecord in startingLocationList)
        {
            outputText.text += "<color=#1abc9c>" + startingLocationRecord.LocationName + "</color> is next to:  <color=#34495e>";
            foreach (Location adjacentLocation in startingLocationRecord.AdjacentLocations)
            {
                outputText.text += adjacentLocation.LocationName + ", ";
            }
            // trim off last comma
            outputText.text  = outputText.text.Substring(0, outputText.text.Length - 2);
            outputText.text += "</color>\n";
        }
    }
Example #5
0
    private void ResetGUI()
    {
        // Reset the temporary GUI variables
        _newPlayerName       = "";
        _newPlayerTotalKills = "";
        _newPlayerPoints     = "";

        // Loads the player stats from the database using Linq
        _playerStatsList = new List <PlayerStats> (from ps in dbManager.Table <PlayerStats> () select ps);

        _playerID = -1;
        if (_playerStatsList != null)
        {
            if (_playerStatsList.Count > 0)
            {
                _playerID = _playerStatsList[0].PlayerID;
            }
        }
    }
        private void ResetGUI()
        {
            // Reset the temporary GUI variables
            playerNameInput.text = "";
            totalKillsInput.text = "";
            pointsInput.text     = "";

            // Loads the player stats from the database using Linq (not required to use Linq, but this is a simple example)
            _playerStatsList = new List <PlayerStats>(from ps in dbManager.Table <PlayerStats>() select ps);

            outputText.text = "";

            foreach (var playerStatRecord in _playerStatsList)
            {
                outputText.text += "<color=#1abc9c>Name:</color> " + playerStatRecord.PlayerName + " " +
                                   "<color=#1abc9c>Total Kills:</color> " + playerStatRecord.TotalKills.ToString() + " " +
                                   "<color=#1abc9c>Points:</color> " + playerStatRecord.Points.ToString() + "\n";
            }
        }