| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using UnityEngine;
- public class SkeletonCharacter : Character
- {
- public Weapon weaponPrefab; // Assign the weapon prefab in the inspector
- public GameObject arrowPrefab; // Assign the arrow prefab in the inspector
- protected override void InitializeStats()
- {
- MaxHealth = 10;
- CurrentHealth = MaxHealth;
- Attack = 8;
- Constitution = 5;
- Dexterity = 3;
- Wisdom = 2;
- InitModifier = -2;
- DamageModifier = 0;
- SpellModifier = 0;
- MovementSpeed = 10;
- ArmorClass = 6;
- }
- public override Character Spawn(int count)
- {
- name = "Skeleton";
- CharacterName = "Skeleton";
- if (count > 1)
- {
- name += " " + count;
- CharacterName += " " + count;
- }
- return this;
- }
- public override Weapon GetWeapon()
- {
- // Return null to trigger direct weapon creation in SpawnAndEquipWeapon
- return weaponPrefab == null ? CreateDirectWeapon() : weaponPrefab;
- }
- protected override Weapon CreateDirectWeapon()
- {
- // Create weapon directly without prefab system
- GameObject bowObject = new GameObject("Simple Bow");
- bowObject.transform.SetParent(this.transform, false);
- SimpleBow bowComponent = bowObject.AddComponent<SimpleBow>();
- bowComponent.arrowPrefab = this.arrowPrefab;
- spawnedWeapon = bowComponent;
- spawnedWeapon.SetWielder(this);
- return spawnedWeapon;
- }
- }
|