ItemCreatorHelper.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using UnityEngine;
  2. #if UNITY_EDITOR
  3. using UnityEditor;
  4. public class ItemCreatorHelper
  5. {
  6. [MenuItem("RPG Tools/Create Sample Items")]
  7. public static void CreateSampleItems()
  8. {
  9. CreateSampleWeapons();
  10. CreateSampleArmor();
  11. CreateSampleConsumables();
  12. CreateSampleMiscItems();
  13. AssetDatabase.SaveAssets();
  14. AssetDatabase.Refresh();
  15. Debug.Log("Sample items created successfully!");
  16. }
  17. private static void CreateSampleWeapons()
  18. {
  19. EnsureFolderExists("Assets/Resources/Items/Weapons");
  20. // Simple Sword
  21. var simpleSword = ScriptableObject.CreateInstance<WeaponItem>();
  22. simpleSword.itemName = "Simple Sword";
  23. simpleSword.description = "A basic iron blade, reliable and sturdy";
  24. simpleSword.goldCost = 15;
  25. simpleSword.silverCost = 0;
  26. simpleSword.copperCost = 0;
  27. simpleSword.itemType = ItemType.Weapon;
  28. simpleSword.rarity = ItemRarity.Common;
  29. simpleSword.weaponType = WeaponType.Sword;
  30. simpleSword.weaponClassName = "SimpleSword";
  31. simpleSword.minDamage = 4;
  32. simpleSword.maxDamage = 8;
  33. simpleSword.searchTags = new string[] { "melee", "blade", "sword", "iron" };
  34. AssetDatabase.CreateAsset(simpleSword, "Assets/Resources/Items/Weapons/SimpleSword.asset");
  35. // War Axe
  36. var warAxe = ScriptableObject.CreateInstance<WeaponItem>();
  37. warAxe.itemName = "War Axe";
  38. warAxe.description = "A heavy two-handed axe that cleaves through armor";
  39. warAxe.goldCost = 22;
  40. warAxe.itemType = ItemType.Weapon;
  41. warAxe.rarity = ItemRarity.Common;
  42. warAxe.weaponType = WeaponType.Axe;
  43. warAxe.weaponClassName = "SimpleSword"; // Reuse for now
  44. warAxe.minDamage = 6;
  45. warAxe.maxDamage = 12;
  46. warAxe.searchTags = new string[] { "melee", "axe", "two-handed", "heavy" };
  47. AssetDatabase.CreateAsset(warAxe, "Assets/Resources/Items/Weapons/WarAxe.asset");
  48. // Hunting Bow
  49. var huntingBow = ScriptableObject.CreateInstance<WeaponItem>();
  50. huntingBow.itemName = "Hunting Bow";
  51. huntingBow.description = "A reliable ranged weapon favored by hunters";
  52. huntingBow.goldCost = 18;
  53. huntingBow.itemType = ItemType.Weapon;
  54. huntingBow.rarity = ItemRarity.Common;
  55. huntingBow.weaponType = WeaponType.Bow;
  56. huntingBow.weaponClassName = "SimpleBow";
  57. huntingBow.minDamage = 3;
  58. huntingBow.maxDamage = 6;
  59. huntingBow.range = 30;
  60. huntingBow.searchTags = new string[] { "ranged", "bow", "hunting", "arrows" };
  61. AssetDatabase.CreateAsset(huntingBow, "Assets/Resources/Items/Weapons/HuntingBow.asset");
  62. // Iron Dagger
  63. var ironDagger = ScriptableObject.CreateInstance<WeaponItem>();
  64. ironDagger.itemName = "Iron Dagger";
  65. ironDagger.description = "Quick and light, perfect for swift strikes";
  66. ironDagger.goldCost = 8;
  67. ironDagger.itemType = ItemType.Weapon;
  68. ironDagger.rarity = ItemRarity.Common;
  69. ironDagger.weaponType = WeaponType.Dagger;
  70. ironDagger.weaponClassName = "SimpleSword"; // Reuse for now
  71. ironDagger.minDamage = 2;
  72. ironDagger.maxDamage = 5;
  73. ironDagger.searchTags = new string[] { "melee", "dagger", "quick", "light", "iron" };
  74. AssetDatabase.CreateAsset(ironDagger, "Assets/Resources/Items/Weapons/IronDagger.asset");
  75. }
  76. private static void CreateSampleArmor()
  77. {
  78. EnsureFolderExists("Assets/Resources/Items/Armor");
  79. // Leather Vest
  80. var leatherVest = ScriptableObject.CreateInstance<ArmorItem>();
  81. leatherVest.itemName = "Leather Vest";
  82. leatherVest.description = "Light chest protection made from quality leather";
  83. leatherVest.goldCost = 10;
  84. leatherVest.itemType = ItemType.Armor;
  85. leatherVest.rarity = ItemRarity.Common;
  86. leatherVest.armorType = ArmorType.Light;
  87. leatherVest.armorSlot = ArmorSlot.Chest;
  88. leatherVest.armorClass = 2;
  89. leatherVest.searchTags = new string[] { "light", "leather", "chest", "vest" };
  90. AssetDatabase.CreateAsset(leatherVest, "Assets/Resources/Items/Armor/LeatherVest.asset");
  91. // Iron Helmet
  92. var ironHelmet = ScriptableObject.CreateInstance<ArmorItem>();
  93. ironHelmet.itemName = "Iron Helmet";
  94. ironHelmet.description = "Sturdy head protection forged from iron";
  95. ironHelmet.goldCost = 15;
  96. ironHelmet.itemType = ItemType.Armor;
  97. ironHelmet.rarity = ItemRarity.Common;
  98. ironHelmet.armorType = ArmorType.Medium;
  99. ironHelmet.armorSlot = ArmorSlot.Head;
  100. ironHelmet.armorClass = 3;
  101. ironHelmet.searchTags = new string[] { "medium", "iron", "head", "helmet" };
  102. AssetDatabase.CreateAsset(ironHelmet, "Assets/Resources/Items/Armor/IronHelmet.asset");
  103. // Chainmail Shirt
  104. var chainmail = ScriptableObject.CreateInstance<ArmorItem>();
  105. chainmail.itemName = "Chainmail Shirt";
  106. chainmail.description = "Interlocked metal rings provide excellent protection";
  107. chainmail.goldCost = 35;
  108. chainmail.itemType = ItemType.Armor;
  109. chainmail.rarity = ItemRarity.Uncommon;
  110. chainmail.armorType = ArmorType.Medium;
  111. chainmail.armorSlot = ArmorSlot.Chest;
  112. chainmail.armorClass = 5;
  113. chainmail.searchTags = new string[] { "medium", "chainmail", "chest", "metal" };
  114. AssetDatabase.CreateAsset(chainmail, "Assets/Resources/Items/Armor/ChainmailShirt.asset");
  115. }
  116. private static void CreateSampleConsumables()
  117. {
  118. EnsureFolderExists("Assets/Resources/Items/Miscellaneous");
  119. // Health Potion
  120. var healthPotion = ScriptableObject.CreateInstance<MiscellaneousItem>();
  121. healthPotion.itemName = "Health Potion";
  122. healthPotion.description = "A red liquid that restores 25 health points";
  123. healthPotion.goldCost = 5;
  124. healthPotion.itemType = ItemType.Consumable;
  125. healthPotion.rarity = ItemRarity.Common;
  126. healthPotion.isConsumable = true;
  127. healthPotion.searchTags = new string[] { "potion", "healing", "health", "red" };
  128. AssetDatabase.CreateAsset(healthPotion, "Assets/Resources/Items/Miscellaneous/HealthPotion.asset");
  129. // Mana Potion
  130. var manaPotion = ScriptableObject.CreateInstance<MiscellaneousItem>();
  131. manaPotion.itemName = "Mana Potion";
  132. manaPotion.description = "A blue elixir that restores 15 mana points";
  133. manaPotion.goldCost = 7;
  134. manaPotion.itemType = ItemType.Consumable;
  135. manaPotion.rarity = ItemRarity.Common;
  136. manaPotion.isConsumable = true;
  137. manaPotion.searchTags = new string[] { "potion", "mana", "magic", "blue" };
  138. AssetDatabase.CreateAsset(manaPotion, "Assets/Resources/Items/Miscellaneous/ManaPotion.asset");
  139. // Antidote
  140. var antidote = ScriptableObject.CreateInstance<MiscellaneousItem>();
  141. antidote.itemName = "Antidote";
  142. antidote.description = "Neutralizes most common poisons";
  143. antidote.goldCost = 3;
  144. antidote.itemType = ItemType.Consumable;
  145. antidote.rarity = ItemRarity.Common;
  146. antidote.isConsumable = true;
  147. antidote.searchTags = new string[] { "antidote", "poison", "cure", "healing" };
  148. AssetDatabase.CreateAsset(antidote, "Assets/Resources/Items/Miscellaneous/Antidote.asset");
  149. }
  150. private static void CreateSampleMiscItems()
  151. {
  152. EnsureFolderExists("Assets/Resources/Items/Miscellaneous");
  153. // Hemp Rope
  154. var rope = ScriptableObject.CreateInstance<MiscellaneousItem>();
  155. rope.itemName = "Hemp Rope";
  156. rope.description = "50 feet of sturdy rope, useful for climbing";
  157. rope.goldCost = 2;
  158. rope.itemType = ItemType.Tool;
  159. rope.rarity = ItemRarity.Common;
  160. rope.isConsumable = false;
  161. rope.searchTags = new string[] { "rope", "climbing", "tool", "hemp" };
  162. AssetDatabase.CreateAsset(rope, "Assets/Resources/Items/Miscellaneous/HempRope.asset");
  163. // Torch
  164. var torch = ScriptableObject.CreateInstance<MiscellaneousItem>();
  165. torch.itemName = "Torch";
  166. torch.description = "Provides light in dark places";
  167. torch.goldCost = 0;
  168. torch.silverCost = 5;
  169. torch.itemType = ItemType.Tool;
  170. torch.rarity = ItemRarity.Common;
  171. torch.isConsumable = true;
  172. torch.searchTags = new string[] { "torch", "light", "fire", "tool" };
  173. AssetDatabase.CreateAsset(torch, "Assets/Resources/Items/Miscellaneous/Torch.asset");
  174. // Lockpicks
  175. var lockpicks = ScriptableObject.CreateInstance<MiscellaneousItem>();
  176. lockpicks.itemName = "Lockpicks";
  177. lockpicks.description = "Fine tools for opening locks";
  178. lockpicks.goldCost = 8;
  179. lockpicks.itemType = ItemType.Tool;
  180. lockpicks.rarity = ItemRarity.Common;
  181. lockpicks.isConsumable = false;
  182. lockpicks.searchTags = new string[] { "lockpicks", "tools", "thief", "locks" };
  183. AssetDatabase.CreateAsset(lockpicks, "Assets/Resources/Items/Miscellaneous/Lockpicks.asset");
  184. // Camping Kit
  185. var campingKit = ScriptableObject.CreateInstance<MiscellaneousItem>();
  186. campingKit.itemName = "Camping Kit";
  187. campingKit.description = "Everything needed for a comfortable night outdoors";
  188. campingKit.goldCost = 15;
  189. campingKit.itemType = ItemType.Tool;
  190. campingKit.rarity = ItemRarity.Common;
  191. campingKit.isConsumable = false;
  192. campingKit.searchTags = new string[] { "camping", "rest", "outdoor", "kit" };
  193. AssetDatabase.CreateAsset(campingKit, "Assets/Resources/Items/Miscellaneous/CampingKit.asset");
  194. }
  195. private static void EnsureFolderExists(string path)
  196. {
  197. if (!AssetDatabase.IsValidFolder(path))
  198. {
  199. var parentPath = System.IO.Path.GetDirectoryName(path);
  200. var folderName = System.IO.Path.GetFileName(path);
  201. AssetDatabase.CreateFolder(parentPath, folderName);
  202. }
  203. }
  204. }
  205. #endif