SkeletonCharacter.cs 1.6 KB

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