Ejemplo n.º 1
0
        public GameMap LoadGameMap(int mapID)
        {
            SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RPGMasterDb"].ConnectionString);
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandText = "LoadGameMap";
            command.CommandType = CommandType.StoredProcedure;

            SqlParameter MapID = new SqlParameter("@MapID", SqlDbType.Int);

            MapID.Value = mapID;
            command.Parameters.Add(MapID);

            connection.Open();
            SqlDataReader dr;
            dr = command.ExecuteReader();

            var gameMap = new GameMap();

            if (dr.HasRows)
            {
                dr.Read();
                gameMap.Name = dr.GetString(0);
                gameMap.TilesData = dr.GetString(1);
            }
            connection.Close();
            dr.Close();

            return gameMap;
        }
Ejemplo n.º 2
0
        public void SaveGameMap(GameMap gameMap)
        {
            SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RPGMasterDb"].ConnectionString);
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandText = "SaveGameMap";
            command.CommandType = CommandType.StoredProcedure;

            SqlParameter Name = new SqlParameter("@Name", SqlDbType.NVarChar);
            SqlParameter UserName = new SqlParameter("@UserName", SqlDbType.NVarChar);
            SqlParameter TilesData = new SqlParameter("@TilesData", SqlDbType.NVarChar);
            SqlParameter isActive = new SqlParameter("@isActive", SqlDbType.NVarChar);

            Name.Value = gameMap.Name;
            UserName.Value = gameMap.UserName;
            TilesData.Value = gameMap.TilesData;
            isActive.Value = 1;

            command.Parameters.Add(Name);
            command.Parameters.Add(UserName);
            command.Parameters.Add(TilesData);
            command.Parameters.Add(isActive);

            connection.Open();
            command.ExecuteNonQuery();

            connection.Close();
        }
Ejemplo n.º 3
0
 public string SaveMap(GameMap gameMap)
 {
     var MapRepo = new MapRepository();
     MapRepo.SaveStoredGameMap(gameMap);
     return "{'Result': '" + gameMap.Name + " Map Saved.'}";
 }
Ejemplo n.º 4
0
 public void SaveStoredGameMap(GameMap gameMap)
 {
     var sm = new StoredGameMap();
     sm.SaveGameMap(gameMap);
 }