HumanCharacter.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using UnityEngine;
  2. public class HumanCharacter : Character
  3. {
  4. public Weapon weaponPrefab; // Assign the weapon prefab in the inspector
  5. public GameObject arrowPrefab; // Assign the arrow prefab in the inspector
  6. protected override void InitializeStats()
  7. {
  8. MaxHealth = 20;
  9. CurrentHealth = MaxHealth;
  10. Attack = 8;
  11. Constitution = 5;
  12. Dexterity = 3;
  13. Wisdom = 2;
  14. InitModifier = -2;
  15. DamageModifier = 0;
  16. SpellModifier = 0;
  17. MovementSpeed = 10;
  18. ArmorClass = 10;
  19. }
  20. public override Weapon GetWeapon()
  21. {
  22. // Return null to trigger direct weapon creation in SpawnAndEquipWeapon
  23. return weaponPrefab == null ? CreateDirectWeapon() : weaponPrefab;
  24. }
  25. protected override Weapon CreateDirectWeapon()
  26. {
  27. // Create weapon directly without prefab system
  28. GameObject swordObject = new GameObject("Simple Sword");
  29. swordObject.transform.SetParent(this.transform, false);
  30. spawnedWeapon = swordObject.AddComponent<SimpleSword>();
  31. spawnedWeapon.SetWielder(this);
  32. return spawnedWeapon;
  33. }
  34. public override Character Spawn(int count)
  35. {
  36. name = "Human";
  37. CharacterName = "Human";
  38. if (count > 1)
  39. {
  40. name += " " + count;
  41. CharacterName += " " + count;
  42. }
  43. return this;
  44. }
  45. }