Ejemplo n.º 1
0
        public static Dictionary <string, string> GetRaceInfo(int id)
        {
            // id, name, creator, type, number of checkpoints
            Dictionary <string, string> results = new Dictionary <string, string>();
            Dictionary <string, string> row;

            MySQLConnector mySQLConnector = MySQLConnector.Instance();

            mySQLConnector = MySQLConnector.Instance();
            Dictionary <string, object> param = new Dictionary <string, object>
            {
                { "@id", id }
            };

            // On récupère l'id, le nom et le nom du créateur
            mySQLConnector.OpenReader("SELECT race_id, race_name, race_creator FROM races WHERE race_id = @id", param);

            row = mySQLConnector.GetNextRow();
            foreach (KeyValuePair <string, string> kvp in row)
            {
                results.Add(MySQLConnector.Field.GetFieldName(kvp.Key), kvp.Value);
            }

            mySQLConnector.CloseReader();

            // On récupère tous les checkpoints de la course
            mySQLConnector.OpenReader("SELECT checkpoint_id, checkpoint_number, checkpoint_pos_x, checkpoint_pos_y, checkpoint_pos_z " +
                                      "FROM race_checkpoints WHERE race_id = @id", param);
            int nbrOfCheckpoints = 0;

            row = mySQLConnector.GetNextRow();
            Vector3 firstCheckpointPos = new Vector3();

            while (row.Count > 0)
            {
                nbrOfCheckpoints++;
                if (row["checkpoint_number"] == "0")
                {
                    firstCheckpointPos = new Vector3(
                        (float)Convert.ToDouble(row["checkpoint_pos_x"]),
                        (float)Convert.ToDouble(row["checkpoint_pos_y"]),
                        (float)Convert.ToDouble(row["checkpoint_pos_z"])
                        );
                }
                row = mySQLConnector.GetNextRow();
            }
            results.Add("Nombre de checkpoints", nbrOfCheckpoints.ToString());
            mySQLConnector.CloseReader();

            // On récupère la zone du premier checkpoint
            string zoneStr = "";
            Zone   zone    = new Zone();

            zoneStr = zone.GetZoneName(firstCheckpointPos);
            results.Add("Zone", zoneStr);

            return(results);
        }
Ejemplo n.º 2
0
        public static Dictionary <string, string> FindRace(string str)
        {
            MySQLConnector mySQLConnector = MySQLConnector.Instance();

            mySQLConnector = MySQLConnector.Instance();
            Dictionary <string, object> param = new Dictionary <string, object>
            {
                { "@name", str }
            };

            mySQLConnector.OpenReader("SELECT race_id, race_name FROM races WHERE race_name LIKE @name", param);
            Dictionary <string, string> results = mySQLConnector.GetNextRow();

            mySQLConnector.CloseReader();
            return(results);
        }