CreateSampleItems.cs 6.5 KB

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