|
|
@@ -20,7 +20,7 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
private TextField characterNameField;
|
|
|
private Button randomizeNameButton;
|
|
|
private DropdownField genderDropdown;
|
|
|
- private IntegerField strengthField, dexterityField, constitutionField, wisdomField;
|
|
|
+ private IntegerField strengthField, dexterityField, constitutionField, wisdomField, perceptionField;
|
|
|
private IntegerField initField, damageField, spellCastingField, movementSpeedField, hpField, acField;
|
|
|
|
|
|
// Attribute management UI
|
|
|
@@ -151,6 +151,7 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
dexterityField = root.Q<IntegerField>("DexterityValue");
|
|
|
constitutionField = root.Q<IntegerField>("ConstitutionValue");
|
|
|
wisdomField = root.Q<IntegerField>("WisdomValue");
|
|
|
+ perceptionField = root.Q<IntegerField>("PerceptionValue");
|
|
|
|
|
|
// Derived stat fields
|
|
|
initField = root.Q<IntegerField>("InitValue");
|
|
|
@@ -275,6 +276,8 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
constitutionField.RegisterValueChangedCallback(evt => OnStatChanged());
|
|
|
if (wisdomField != null)
|
|
|
wisdomField.RegisterValueChangedCallback(evt => OnStatChanged());
|
|
|
+ if (perceptionField != null)
|
|
|
+ perceptionField.RegisterValueChangedCallback(evt => OnStatChanged());
|
|
|
|
|
|
// Attribute management
|
|
|
if (randomizeAttributesButton != null)
|
|
|
@@ -366,24 +369,27 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
int newDex = dexterityField?.value ?? currentCharacter.dexterity;
|
|
|
int newCon = constitutionField?.value ?? currentCharacter.constitution;
|
|
|
int newWis = wisdomField?.value ?? currentCharacter.wisdom;
|
|
|
+ int newPer = perceptionField?.value ?? currentCharacter.perception;
|
|
|
|
|
|
// Clamp values to valid range (4-18)
|
|
|
newStr = Mathf.Clamp(newStr, 4, 18);
|
|
|
newDex = Mathf.Clamp(newDex, 4, 18);
|
|
|
newCon = Mathf.Clamp(newCon, 4, 18);
|
|
|
newWis = Mathf.Clamp(newWis, 4, 18);
|
|
|
+ newPer = Mathf.Clamp(newPer, 4, 18);
|
|
|
|
|
|
// Check if the new combination is affordable
|
|
|
int totalCost = TeamCharacter.GetStatCost(newStr) + TeamCharacter.GetStatCost(newDex) +
|
|
|
- TeamCharacter.GetStatCost(newCon) + TeamCharacter.GetStatCost(newWis);
|
|
|
+ TeamCharacter.GetStatCost(newCon) + TeamCharacter.GetStatCost(newWis) + TeamCharacter.GetStatCost(newPer);
|
|
|
|
|
|
- if (totalCost <= 18) // Changed from 27 to 18 for 4-stat system
|
|
|
+ if (totalCost <= 22) // Changed from 18 to 22 for 5-stat system
|
|
|
{
|
|
|
// Update character stats from UI
|
|
|
currentCharacter.strength = newStr;
|
|
|
currentCharacter.dexterity = newDex;
|
|
|
currentCharacter.constitution = newCon;
|
|
|
currentCharacter.wisdom = newWis;
|
|
|
+ currentCharacter.perception = newPer;
|
|
|
currentCharacter.UpdateAvailablePoints();
|
|
|
}
|
|
|
else
|
|
|
@@ -393,6 +399,7 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
if (dexterityField != null) dexterityField.value = currentCharacter.dexterity;
|
|
|
if (constitutionField != null) constitutionField.value = currentCharacter.constitution;
|
|
|
if (wisdomField != null) wisdomField.value = currentCharacter.wisdom;
|
|
|
+ if (perceptionField != null) perceptionField.value = currentCharacter.perception;
|
|
|
}
|
|
|
|
|
|
// Update derived stats and point display
|
|
|
@@ -774,6 +781,7 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
if (dexterityField != null) dexterityField.value = currentCharacter.dexterity;
|
|
|
if (constitutionField != null) constitutionField.value = currentCharacter.constitution;
|
|
|
if (wisdomField != null) wisdomField.value = currentCharacter.wisdom;
|
|
|
+ if (perceptionField != null) perceptionField.value = currentCharacter.perception;
|
|
|
|
|
|
// Recalculate equipment bonuses from inventory
|
|
|
currentCharacter.RecalculateEquipmentBonuses();
|
|
|
@@ -804,6 +812,7 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
if (dexterityField != null) dexterityField.SetEnabled(true);
|
|
|
if (constitutionField != null) constitutionField.SetEnabled(true);
|
|
|
if (wisdomField != null) wisdomField.SetEnabled(true);
|
|
|
+ if (perceptionField != null) perceptionField.SetEnabled(true);
|
|
|
}
|
|
|
|
|
|
private void UpdateDerivedStats()
|
|
|
@@ -865,6 +874,9 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
var wisdomLabel = characterCard.Q<Label>("WisdomLabel");
|
|
|
if (wisdomLabel != null) wisdomLabel.text = character.wisdom.ToString();
|
|
|
|
|
|
+ var perceptionLabel = characterCard.Q<Label>("PerceptionLabel");
|
|
|
+ if (perceptionLabel != null) perceptionLabel.text = character.perception.ToString();
|
|
|
+
|
|
|
// Update HP and AC
|
|
|
var hpLabel = characterCard.Q<Label>("HPLabel");
|
|
|
if (hpLabel != null) hpLabel.text = $"HP: {character.HitPoints}";
|
|
|
@@ -1476,6 +1488,7 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
character.dexterity = PlayerPrefs.GetInt(prefix + "Dexterity", 10);
|
|
|
character.constitution = PlayerPrefs.GetInt(prefix + "Constitution", 10);
|
|
|
character.wisdom = PlayerPrefs.GetInt(prefix + "Wisdom", 10);
|
|
|
+ character.perception = PlayerPrefs.GetInt(prefix + "Perception", 10);
|
|
|
character.gold = PlayerPrefs.GetInt(prefix + "Gold", 25);
|
|
|
character.silver = PlayerPrefs.GetInt(prefix + "Silver", 0);
|
|
|
character.copper = PlayerPrefs.GetInt(prefix + "Copper", 0);
|
|
|
@@ -1498,6 +1511,7 @@ public class MainTeamSelectScript : MonoBehaviour
|
|
|
PlayerPrefs.SetInt(prefix + "Dexterity", character.dexterity);
|
|
|
PlayerPrefs.SetInt(prefix + "Constitution", character.constitution);
|
|
|
PlayerPrefs.SetInt(prefix + "Wisdom", character.wisdom);
|
|
|
+ PlayerPrefs.SetInt(prefix + "Perception", character.perception);
|
|
|
PlayerPrefs.SetInt(prefix + "Gold", character.gold);
|
|
|
PlayerPrefs.SetInt(prefix + "Silver", character.silver);
|
|
|
PlayerPrefs.SetInt(prefix + "Copper", character.copper);
|
|
|
@@ -1728,16 +1742,18 @@ public class TeamCharacter
|
|
|
public int dexterity = 10;
|
|
|
public int constitution = 10;
|
|
|
public int wisdom = 10;
|
|
|
+ public int perception = 10;
|
|
|
|
|
|
// Character creation mode
|
|
|
public bool isRandomized = false; // Track if stats were randomized
|
|
|
- public int availablePoints = 18; // Point-buy system (adjusted for 4 stats instead of 6)
|
|
|
+ public int availablePoints = 22; // Point-buy system (adjusted for 5 stats instead of 4)
|
|
|
|
|
|
// Equipment modifiers (for future use)
|
|
|
public int strengthModifier = 0;
|
|
|
public int dexterityModifier = 0;
|
|
|
public int constitutionModifier = 0;
|
|
|
public int wisdomModifier = 0;
|
|
|
+ public int perceptionModifier = 0;
|
|
|
public int acModifier = 0; // Direct AC bonuses from equipment
|
|
|
|
|
|
// Currency
|
|
|
@@ -1757,6 +1773,7 @@ public class TeamCharacter
|
|
|
public int FinalDexterity => dexterity + dexterityModifier;
|
|
|
public int FinalConstitution => constitution + constitutionModifier;
|
|
|
public int FinalWisdom => wisdom + wisdomModifier;
|
|
|
+ public int FinalPerception => perception + perceptionModifier;
|
|
|
|
|
|
// Derived stats (calculated from final stats)
|
|
|
public int Initiative => FinalDexterity - 10;
|
|
|
@@ -1797,31 +1814,31 @@ public class TeamCharacter
|
|
|
isMale = male;
|
|
|
}
|
|
|
|
|
|
- // Randomize all attributes using point-buy system (18 points)
|
|
|
+ // Randomize all attributes using point-buy system (22 points)
|
|
|
public void RandomizeAttributes()
|
|
|
{
|
|
|
if (Application.isPlaying)
|
|
|
{
|
|
|
// Start with random base values (4-12 range for variety)
|
|
|
- int[] stats = new int[4];
|
|
|
- for (int i = 0; i < 4; i++)
|
|
|
+ int[] stats = new int[5];
|
|
|
+ for (int i = 0; i < 5; i++)
|
|
|
{
|
|
|
stats[i] = UnityEngine.Random.Range(4, 13); // Random start between 4-12
|
|
|
}
|
|
|
|
|
|
// Calculate how many points we've spent so far
|
|
|
int pointsSpent = 0;
|
|
|
- for (int i = 0; i < 4; i++)
|
|
|
+ for (int i = 0; i < 5; i++)
|
|
|
{
|
|
|
pointsSpent += GetStatCost(stats[i]);
|
|
|
}
|
|
|
|
|
|
- int pointsRemaining = 18 - pointsSpent; // Changed from 27 to 18
|
|
|
+ int pointsRemaining = 22 - pointsSpent; // Changed from 18 to 22 for 5 stats
|
|
|
|
|
|
// If we're over budget, reduce some stats
|
|
|
while (pointsRemaining < 0)
|
|
|
{
|
|
|
- int randomStat = UnityEngine.Random.Range(0, 4);
|
|
|
+ int randomStat = UnityEngine.Random.Range(0, 5);
|
|
|
if (stats[randomStat] > 4) // Don't go below 4
|
|
|
{
|
|
|
int oldCost = GetStatCost(stats[randomStat]);
|
|
|
@@ -1835,7 +1852,7 @@ public class TeamCharacter
|
|
|
while (pointsRemaining > 0)
|
|
|
{
|
|
|
// Pick a random stat to increase
|
|
|
- int randomStat = UnityEngine.Random.Range(0, 4);
|
|
|
+ int randomStat = UnityEngine.Random.Range(0, 5);
|
|
|
|
|
|
// Check if we can afford to increase this stat
|
|
|
int currentValue = stats[randomStat];
|
|
|
@@ -1854,7 +1871,7 @@ public class TeamCharacter
|
|
|
{
|
|
|
// If we can't afford any increases, try to find a stat we can afford
|
|
|
bool foundAffordable = false;
|
|
|
- for (int i = 0; i < 4; i++)
|
|
|
+ for (int i = 0; i < 5; i++)
|
|
|
{
|
|
|
if (stats[i] < 18)
|
|
|
{
|
|
|
@@ -1880,6 +1897,7 @@ public class TeamCharacter
|
|
|
dexterity = stats[1];
|
|
|
constitution = stats[2];
|
|
|
wisdom = stats[3];
|
|
|
+ perception = stats[4];
|
|
|
|
|
|
// Set as point-buy mode (not locked like true random)
|
|
|
isRandomized = false;
|
|
|
@@ -1894,6 +1912,7 @@ public class TeamCharacter
|
|
|
dexterity = UnityEngine.Random.Range(2, 19);
|
|
|
constitution = UnityEngine.Random.Range(2, 19);
|
|
|
wisdom = UnityEngine.Random.Range(2, 19);
|
|
|
+ perception = UnityEngine.Random.Range(2, 19);
|
|
|
isRandomized = true;
|
|
|
availablePoints = 0; // No points available when randomized
|
|
|
}
|
|
|
@@ -1906,8 +1925,9 @@ public class TeamCharacter
|
|
|
dexterity = 10;
|
|
|
constitution = 10;
|
|
|
wisdom = 10;
|
|
|
+ perception = 10;
|
|
|
isRandomized = false;
|
|
|
- availablePoints = 18; // Reset to full point pool (adjusted for 4 stats)
|
|
|
+ availablePoints = 22; // Reset to full point pool (adjusted for 5 stats)
|
|
|
}
|
|
|
|
|
|
// Calculate point cost for a stat value (point-buy system)
|
|
|
@@ -1938,7 +1958,7 @@ public class TeamCharacter
|
|
|
// Calculate total points spent
|
|
|
public int GetTotalPointsSpent()
|
|
|
{
|
|
|
- return GetStatCost(strength) + GetStatCost(dexterity) + GetStatCost(constitution) + GetStatCost(wisdom);
|
|
|
+ return GetStatCost(strength) + GetStatCost(dexterity) + GetStatCost(constitution) + GetStatCost(wisdom) + GetStatCost(perception);
|
|
|
}
|
|
|
|
|
|
// Update available points based on current stats
|
|
|
@@ -1946,7 +1966,7 @@ public class TeamCharacter
|
|
|
{
|
|
|
if (!isRandomized)
|
|
|
{
|
|
|
- availablePoints = 18 - GetTotalPointsSpent(); // Changed from 27 to 18
|
|
|
+ availablePoints = 22 - GetTotalPointsSpent(); // Changed from 18 to 22 for 5 stats
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1972,6 +1992,7 @@ public class TeamCharacter
|
|
|
dexterity = this.dexterity,
|
|
|
constitution = this.constitution,
|
|
|
wisdom = this.wisdom,
|
|
|
+ perception = this.perception,
|
|
|
isRandomized = this.isRandomized,
|
|
|
availablePoints = this.availablePoints,
|
|
|
gold = this.gold,
|
|
|
@@ -1997,6 +2018,7 @@ public class TeamCharacter
|
|
|
dexterityModifier = 0;
|
|
|
constitutionModifier = 0;
|
|
|
wisdomModifier = 0;
|
|
|
+ perceptionModifier = 0;
|
|
|
acModifier = 0;
|
|
|
|
|
|
// Get reference to the shop manager to access item definitions
|