HumanCharacter.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. Debug.Log($"🔧 Applied default stats to {CharacterName}");
  25. }
  26. else
  27. {
  28. Debug.Log($"🔧 Skipping default stats for {CharacterName} - combat data already applied (STR:{Strength})");
  29. }
  30. }
  31. public override Weapon GetWeapon()
  32. {
  33. // Return null to trigger direct weapon creation in SpawnAndEquipWeapon
  34. return weaponPrefab == null ? CreateDirectWeapon() : weaponPrefab;
  35. }
  36. protected override Weapon CreateDirectWeapon()
  37. {
  38. // Create weapon directly without prefab system
  39. GameObject swordObject = new GameObject("Simple Sword");
  40. swordObject.transform.SetParent(this.transform, false);
  41. spawnedWeapon = swordObject.AddComponent<SimpleSword>();
  42. spawnedWeapon.SetWielder(this);
  43. return spawnedWeapon;
  44. }
  45. public override Character Spawn(int count)
  46. {
  47. name = "Human";
  48. CharacterName = "Human";
  49. if (count > 1)
  50. {
  51. name += " " + count;
  52. CharacterName += " " + count;
  53. }
  54. return this;
  55. }
  56. }