public static LevelList LoadLevelList(string levlist) { string[] files = Directory.GetFiles(GunMain.SPath, "*.json"); LevelList levels = new LevelList(); foreach (string file in files) { if (file.Split('.')[0].EndsWith(levlist)) { StreamReader read = new StreamReader(GunMain.SPath + levlist + ".json"); levels = Newtonsoft.Json.JsonConvert.DeserializeObject<LevelList>(read.ReadToEnd()); read.Dispose(); break; } } return levels; }
public static void GiveNewItems(GunPlayer ply, int level, LevelList list) { int x = ply.TSPlayer.TileX; int y = ply.TSPlayer.TileY; ply.TSPlayer.DamagePlayer(500); ply.TSPlayer.Teleport(x, y); string[] items = list.Levels[level]; foreach (string item in items) { if (item != "null") { Item give = TShock.Utils.GetItemByName(item)[0]; ply.GiveItem(give.type, give.name, give.width, give.height, give.maxStack); } } if (list.Knife != "null") { Item knife = TShock.Utils.GetItemByName(list.Knife)[0]; ply.GiveItem(knife.type, knife.name, knife.width, knife.height, knife.maxStack); } ply.TSPlayer.Teleport(x, y); }