HumanCharacter.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // Only set default stats if they haven't been set by combat data
  9. if (Strength == 0) // Assume if Strength is 0, no combat data has been applied
  10. {
  11. MaxHealth = 20;
  12. CurrentHealth = MaxHealth;
  13. Attack = 8;
  14. Strength = 10; // Default strength
  15. Constitution = 5;
  16. Dexterity = 3;
  17. Wisdom = 2;
  18. Perception = 10; // Default perception
  19. InitModifier = -2;
  20. DamageModifier = 0;
  21. SpellModifier = 0;
  22. MovementSpeed = 10;
  23. ArmorClass = 10;
  24. }
  25. }
  26. public override Weapon GetWeapon()
  27. {
  28. // Return null to trigger direct weapon creation in SpawnAndEquipWeapon
  29. return weaponPrefab == null ? CreateDirectWeapon() : weaponPrefab;
  30. }
  31. protected override Weapon CreateDirectWeapon()
  32. {
  33. // Create weapon directly without prefab system
  34. GameObject swordObject = new GameObject("Simple Sword");
  35. swordObject.transform.SetParent(this.transform, false);
  36. spawnedWeapon = swordObject.AddComponent<SimpleSword>();
  37. spawnedWeapon.SetWielder(this);
  38. return spawnedWeapon;
  39. }
  40. public override Character Spawn(int count)
  41. {
  42. name = "Human";
  43. CharacterName = "Human";
  44. if (count > 1)
  45. {
  46. name += " " + count;
  47. CharacterName += " " + count;
  48. }
  49. return this;
  50. }
  51. }