HumanCharacter.cs 1.5 KB

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