CreateSampleItems.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using UnityEngine;
  2. using UnityEditor;
  3. public class CreateSampleItems
  4. {
  5. [MenuItem("RPG/Create Sample Items")]
  6. public static void CreateItems()
  7. {
  8. // Create weapon items
  9. CreateSimpleSword();
  10. CreateSimpleBow();
  11. CreateIronSword();
  12. // Create armor items
  13. CreateLeatherArmor();
  14. CreateIronChainmail();
  15. // Create miscellaneous items
  16. CreateHealthPotion();
  17. CreateManaPotion();
  18. CreateHempRope();
  19. AssetDatabase.SaveAssets();
  20. AssetDatabase.Refresh();
  21. Debug.Log("Sample items created in Resources/Items folder!");
  22. }
  23. private static void CreateSimpleSword()
  24. {
  25. var sword = ScriptableObject.CreateInstance<WeaponItem>();
  26. sword.itemName = "Simple Sword";
  27. sword.description = "A basic sword perfect for beginners. Light and easy to handle.";
  28. sword.itemType = ItemType.Weapon;
  29. sword.rarity = ItemRarity.Common;
  30. sword.goldCost = 10;
  31. sword.minDamage = 1;
  32. sword.maxDamage = 6;
  33. sword.range = 5; // Melee range
  34. sword.weaponModifier = 0;
  35. sword.attackSpeed = 1.0f;
  36. sword.weaponType = WeaponType.Sword;
  37. sword.weaponClassName = "SimpleSword";
  38. sword.searchTags = new string[] { "sword", "melee", "blade", "basic", "one-handed" };
  39. AssetDatabase.CreateAsset(sword, "Assets/Resources/Items/Weapons/SimpleSword.asset");
  40. }
  41. private static void CreateSimpleBow()
  42. {
  43. var bow = ScriptableObject.CreateInstance<WeaponItem>();
  44. bow.itemName = "Simple Bow";
  45. bow.description = "A basic wooden bow with decent range. Perfect for hunting small game.";
  46. bow.itemType = ItemType.Weapon;
  47. bow.rarity = ItemRarity.Common;
  48. bow.goldCost = 15;
  49. bow.minDamage = 1;
  50. bow.maxDamage = 4;
  51. bow.range = 150;
  52. bow.weaponModifier = 0;
  53. bow.attackSpeed = 0.8f;
  54. bow.weaponType = WeaponType.Bow;
  55. bow.weaponClassName = "SimpleBow";
  56. bow.searchTags = new string[] { "bow", "ranged", "arrow", "hunting", "wood" };
  57. AssetDatabase.CreateAsset(bow, "Assets/Resources/Items/Weapons/SimpleBow.asset");
  58. }
  59. private static void CreateIronSword()
  60. {
  61. var sword = ScriptableObject.CreateInstance<WeaponItem>();
  62. sword.itemName = "Iron Sword";
  63. sword.description = "A well-crafted iron sword. Durable and sharp, favored by town guards.";
  64. sword.itemType = ItemType.Weapon;
  65. sword.rarity = ItemRarity.Uncommon;
  66. sword.goldCost = 25;
  67. sword.minDamage = 2;
  68. sword.maxDamage = 8;
  69. sword.range = 5;
  70. sword.weaponModifier = 1;
  71. sword.attackSpeed = 1.0f;
  72. sword.weaponType = WeaponType.Sword;
  73. sword.weaponClassName = "SimpleSword";
  74. sword.searchTags = new string[] { "sword", "melee", "blade", "iron", "guard", "military" };
  75. AssetDatabase.CreateAsset(sword, "Assets/Resources/Items/Weapons/IronSword.asset");
  76. }
  77. private static void CreateLeatherArmor()
  78. {
  79. var armor = ScriptableObject.CreateInstance<ArmorItem>();
  80. armor.itemName = "Leather Armor";
  81. armor.description = "Simple leather protection that doesn't restrict movement.";
  82. armor.itemType = ItemType.Armor;
  83. armor.rarity = ItemRarity.Common;
  84. armor.goldCost = 12;
  85. armor.armorClass = 1;
  86. armor.armorType = ArmorType.Light;
  87. armor.armorSlot = ArmorSlot.Chest;
  88. armor.dexterityModifier = 0; // No penalty for light armor
  89. armor.searchTags = new string[] { "leather", "armor", "chest", "light", "flexible" };
  90. AssetDatabase.CreateAsset(armor, "Assets/Resources/Items/Armor/LeatherArmor.asset");
  91. }
  92. private static void CreateIronChainmail()
  93. {
  94. var armor = ScriptableObject.CreateInstance<ArmorItem>();
  95. armor.itemName = "Iron Chainmail";
  96. armor.description = "Interlocking iron rings provide solid protection.";
  97. armor.itemType = ItemType.Armor;
  98. armor.rarity = ItemRarity.Uncommon;
  99. armor.goldCost = 30;
  100. armor.armorClass = 2;
  101. armor.armorType = ArmorType.Medium;
  102. armor.armorSlot = ArmorSlot.Chest;
  103. armor.dexterityModifier = -1; // Medium armor restricts movement slightly
  104. armor.searchTags = new string[] { "chainmail", "armor", "chest", "medium", "iron", "metal" };
  105. AssetDatabase.CreateAsset(armor, "Assets/Resources/Items/Armor/IronChainmail.asset");
  106. }
  107. private static void CreateHealthPotion()
  108. {
  109. var potion = ScriptableObject.CreateInstance<MiscellaneousItem>();
  110. potion.itemName = "Health Potion";
  111. potion.description = "A red liquid that restores vitality when consumed.";
  112. potion.itemType = ItemType.Consumable;
  113. potion.rarity = ItemRarity.Common;
  114. potion.goldCost = 3;
  115. potion.isConsumable = true;
  116. potion.isStackable = true;
  117. potion.maxStackSize = 10;
  118. // Heals 1d6+1 (2-7 health)
  119. potion.healthDiceCount = 1;
  120. potion.healthDiceType = 6;
  121. potion.healthBonus = 1;
  122. potion.searchTags = new string[] { "potion", "health", "healing", "consumable", "red" };
  123. AssetDatabase.CreateAsset(potion, "Assets/Resources/Items/Miscellaneous/HealthPotion.asset");
  124. }
  125. private static void CreateManaPotion()
  126. {
  127. var potion = ScriptableObject.CreateInstance<MiscellaneousItem>();
  128. potion.itemName = "Mana Potion";
  129. potion.description = "A blue liquid that restores magical energy.";
  130. potion.itemType = ItemType.Consumable;
  131. potion.rarity = ItemRarity.Common;
  132. potion.goldCost = 4;
  133. potion.isConsumable = true;
  134. potion.isStackable = true;
  135. potion.maxStackSize = 10;
  136. // Restores 1d4 (1-4 mana)
  137. potion.manaDiceCount = 1;
  138. potion.manaDiceType = 4;
  139. potion.manaBonus = 0;
  140. potion.searchTags = new string[] { "potion", "mana", "magic", "consumable", "blue" };
  141. AssetDatabase.CreateAsset(potion, "Assets/Resources/Items/Miscellaneous/ManaPotion.asset");
  142. }
  143. private static void CreateHempRope()
  144. {
  145. var rope = ScriptableObject.CreateInstance<MiscellaneousItem>();
  146. rope.itemName = "Hemp Rope";
  147. rope.description = "50 feet of sturdy rope. Essential for any adventurer.";
  148. rope.itemType = ItemType.Tool;
  149. rope.rarity = ItemRarity.Common;
  150. rope.silverCost = 8;
  151. rope.isConsumable = false;
  152. rope.isStackable = false;
  153. rope.searchTags = new string[] { "rope", "hemp", "utility", "tool", "climbing" };
  154. AssetDatabase.CreateAsset(rope, "Assets/Resources/Items/Miscellaneous/HempRope.asset");
  155. }
  156. }