using UnityEngine; using System.Collections.Generic; using System.Linq; [System.Serializable] public class Skill // class, not struct { public enum SkillType { Swordsmanship, Archer, Magic, Unarmed, Stealth, Alchemy, Blacksmithing, Cooking, Speech, Perception, Lockpicking, Pickpocketing, Persuasion, Bartering, Leadership, Tactics, Strategy, Healing, Enchanting, Summoning, Necromancy, ElementalMagic, IllusionMagic, RestorationMagic, ConjurationMagic, DestructionMagic } public SkillType skillType; public enum SkillTier { Novice, Apprentice, Journeyman, Expert, Master } public SkillTier skillTier; public int level; private static readonly Dictionary Descriptions = new Dictionary { { SkillType.Swordsmanship, "Mastery of the sword." }, { SkillType.Archer, "Mastery of the bow." }, { SkillType.Magic, "Mastery of arcane arts." }, { SkillType.Unarmed, "Mastery of hand-to-hand combat." }, { SkillType.Stealth, "Mastery of moving unseen." }, { SkillType.Alchemy, "Mastery of potion making and chemical reactions." }, { SkillType.Blacksmithing, "Mastery of forging weapons and armor." }, { SkillType.Cooking, "Mastery of preparing food and potions." }, { SkillType.Speech, "Mastery of persuasion and communication." }, { SkillType.Perception, "Mastery of noticing details and hidden objects." }, { SkillType.Lockpicking, "Mastery of opening locks without a key." }, { SkillType.Pickpocketing, "Mastery of stealing undetected." }, { SkillType.Persuasion, "Mastery of convincing others." }, { SkillType.Bartering, "Mastery of trading and negotiation." }, { SkillType.Leadership, "Mastery of commanding others." }, { SkillType.Tactics, "Mastery of battlefield planning." }, { SkillType.Strategy, "Mastery of long-term planning and warfare." }, { SkillType.Healing, "Mastery of mending wounds and ailments." }, { SkillType.Enchanting, "Mastery of imbuing items with magic." }, { SkillType.Summoning, "Mastery of calling forth creatures." }, { SkillType.Necromancy, "Mastery of death and undead magic." }, { SkillType.ElementalMagic, "Mastery of fire, ice, and lightning." }, { SkillType.IllusionMagic, "Mastery of deceiving the senses." }, { SkillType.RestorationMagic, "Mastery of healing and ward magic." }, { SkillType.ConjurationMagic, "Mastery of summoning and binding." }, { SkillType.DestructionMagic, "Mastery of destructive spells." }, }; public string Description => Descriptions.TryGetValue(skillType, out var desc) ? desc : string.Empty; } public class Player : MonoBehaviour { [Header("Player Stats")] [SerializeField] private int maxHealth, maxStamina, maxMana; private int curHealth, curStamina, curMana; [Header("Player Skills")] [SerializeField] private List skillList = new List(); // serializable public Dictionary skills; // runtime lookup void Start() { skills = skillList.ToDictionary(s => s.skillType.ToString(), s => s); // convert list to dictionary for runtime lookup // Initialize player stats curHealth = maxHealth; curStamina = maxStamina; curMana = maxMana; } public void GetStats(out int health, out int stamina, out int mana) { health = curHealth; stamina = curStamina; mana = curMana; } public void GetSkills(out Dictionary playerSkills) { playerSkills = new Dictionary(skills); } public int GetSkillLevel(string skillName) { if (skills.TryGetValue(skillName, out Skill skill)) { return skill.level; } else { Debug.LogWarning($"Skill '{skillName}' not found for player."); return -1; // or throw an exception, or return a default value } } public void TakeDamage(int damage) { curHealth -= damage; if (curHealth <= 0) { Die(); } } private void Die() { Debug.Log("Player has died."); // Handle player death (e.g., respawn, game over, etc.) } }