SkeletonCharacter.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. Constitution = 5;
  12. Dexterity = 3;
  13. Wisdom = 2;
  14. InitModifier = -2;
  15. DamageModifier = 0;
  16. SpellModifier = 0;
  17. MovementSpeed = 10;
  18. ArmorClass = 6;
  19. }
  20. public override Character Spawn(int count)
  21. {
  22. name = "Skeleton";
  23. CharacterName = "Skeleton";
  24. if (count > 1)
  25. {
  26. name += " " + count;
  27. CharacterName += " " + count;
  28. }
  29. return this;
  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 bowObject = new GameObject("Simple Bow");
  40. bowObject.transform.SetParent(this.transform, false);
  41. SimpleBow bowComponent = bowObject.AddComponent<SimpleBow>();
  42. bowComponent.arrowPrefab = this.arrowPrefab;
  43. spawnedWeapon = bowComponent;
  44. spawnedWeapon.SetWielder(this);
  45. return spawnedWeapon;
  46. }
  47. }