ItemCreatorHelper.cs 9.7 KB

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