Initial commit

This commit is contained in:
2026-09-02 21:14:02 +01:00
parent 10d6c0fa34
commit 41d8d1804d
17 changed files with 9427 additions and 85 deletions

53
Assets/Scripts/Skills.cs Normal file
View File

@@ -0,0 +1,53 @@
using UnityEngine;
// System.Serializable makes these show up in the Unity Inspector so you can debug NPC levels!
[System.Serializable]
public class Skills
{
public enum SkillType
{
Woodcutting,
Stonecutting,
Mining,
Building,
Farming // Added to match your Farmer job
}
public SkillType skillType;
public int skillExp;
public int skillLevel;
// 1. The Constructor: This runs automatically when the NPC learns the skill for the first time
public Skills(SkillType type)
{
skillType = type;
skillLevel = 1;
skillExp = 0;
}
// 2. The Math: Handles gaining XP and checking for level ups
public void AddExperience(int amount)
{
skillExp += amount;
// Example leveling formula: Level 1 requires 100xp, Level 2 requires 200xp, etc.
int xpRequiredForNextLevel = skillLevel * 100;
if (skillExp >= xpRequiredForNextLevel)
{
// Subtract the requirement but keep the rollover XP
skillExp -= xpRequiredForNextLevel;
skillLevel++;
Debug.Log($"Leveled up! {skillType} is now Level {skillLevel}");
}
}
public int GetLevel(SkillType type)
{
if (type == skillType)
return skillLevel;
Debug.LogWarning($"Requested level for {type} but this skill is {skillType}");
return 0;
}
}