Browse Source

Perception added to the character

Axel Nordh 8 tháng trước cách đây
mục cha
commit
4c4812a453

+ 11 - 12
Assets/Scripts/Events/HiddenTreasure.asset → Assets/Resources/TravelEvents/HiddenTreasure.asset

@@ -12,20 +12,19 @@ MonoBehaviour:
   m_Script: {fileID: 0}
   m_Name: HiddenTreasure
   m_EditorClassIdentifier: Assembly-CSharp::DiscoveryTravelEvent
-  eventName: Hidden treasure
-  eventDescription: A chest is hidden at this location, spend {time} hours to dig
-    it out
+  eventName: 
+  eventDescription: 
   eventType: 2
   rarity: 2
-  plainsChance: 0.4
-  forestChance: 0.7
-  mountainChance: 0.8
-  roadChance: 0.3
-  riverChance: 0.033
-  lakeChance: 0.059
-  oceanChance: 0.197
-  townChance: 0.1
-  villageChance: 0.01
+  plainsChance: 0.125
+  forestChance: 0.236
+  mountainChance: 0.37
+  roadChance: 0.033
+  riverChance: 0.21
+  lakeChance: 0.246
+  oceanChance: 0.387
+  townChance: 0
+  villageChance: 0
   bridgeChance: 0
   tunnelChance: 0
   ferryChance: 0

+ 2 - 2
Assets/Scenes/MapScene2.unity

@@ -620,8 +620,8 @@ MonoBehaviour:
   baseEventChance: 0.15
   tilesPerEventCheck: 3
   availableEvents:
-  - {fileID: 11400000, guid: de1e17a43d8889f4581856faed745ea2, type: 2}
-  - {fileID: 11400000, guid: 644048a8c9939c2408e9c8df1d68a170, type: 2}
+  - {fileID: 11400000, guid: 3756641546a12504cbd1273f2dd7bbf3, type: 2}
+  - {fileID: 11400000, guid: 7f47d27e7a16f0d4ca61a2db845dd20e, type: 2}
   showDebugLogs: 1
   forceNextEvent: 0
 --- !u!114 &1581552017

+ 0 - 40
Assets/Scripts/Events/SkeletonAmbush.asset

@@ -1,40 +0,0 @@
-%YAML 1.1
-%TAG !u! tag:unity3d.com,2011:
---- !u!114 &11400000
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 0}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: f460ab3f7cb3e5342a0c4d4cd2acb8a5, type: 3}
-  m_Name: SkeletonAmbush
-  m_EditorClassIdentifier: 
-  eventName: Skeletons attack!
-  eventDescription: A group of skeletons are attacking
-  eventType: 0
-  rarity: 1
-  plainsChance: 0.4
-  forestChance: 0.8
-  mountainChance: 0.9
-  roadChance: 0.2
-  riverChance: 0.5
-  lakeChance: 0.5
-  oceanChance: 0.5
-  townChance: 0.1
-  villageChance: 0.3
-  bridgeChance: 0.5
-  tunnelChance: 0.5
-  ferryChance: 0.5
-  canOccurMultipleTimes: 1
-  cooldownDays: 0
-  minEnemies: 1
-  maxEnemies: 3
-  possibleEnemies:
-  - {fileID: 11400000, guid: a0c1cb52b0bf42c4299acc5827d0d6e2, type: 2}
-  encounterDescriptions:
-  - Your party is ambushed by {enemyType}s!
-  - A group of {enemyType}s blocks your path!
-  - You stumble upon a {enemyType} camp!

+ 37 - 15
Assets/Scripts/MainTeamSelect/MainTeamSelectScript.cs

@@ -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

+ 3 - 0
Assets/Scripts/UI/SimpleShopManager.cs

@@ -442,6 +442,7 @@ public class SimpleShopManager : MonoBehaviour
         character.dexterityModifier += stats.dexterityBonus;
         character.constitutionModifier += stats.constitutionBonus;
         character.wisdomModifier += stats.wisdomBonus;
+        character.perceptionModifier += stats.perceptionBonus;
         character.acModifier += stats.acBonus; // Apply direct AC bonuses
 
         // Note: AC and HP are calculated properties using Final stats (base + modifiers), 
@@ -564,6 +565,7 @@ public class SimpleShopItem
         if (stats.dexterityBonus != 0) statStrings.Add($"DEX: +{stats.dexterityBonus}");
         if (stats.constitutionBonus != 0) statStrings.Add($"CON: +{stats.constitutionBonus}");
         if (stats.wisdomBonus != 0) statStrings.Add($"WIS: +{stats.wisdomBonus}");
+        if (stats.perceptionBonus != 0) statStrings.Add($"PER: +{stats.perceptionBonus}");
         if (stats.movementBonus != 0) statStrings.Add($"Move: +{stats.movementBonus}");
         if (stats.healthBonus != 0) statStrings.Add($"HP: +{stats.healthBonus}");
 
@@ -583,6 +585,7 @@ public class ItemStats
     public int dexterityBonus = 0;
     public int constitutionBonus = 0;
     public int wisdomBonus = 0;
+    public int perceptionBonus = 0;
 
     [Header("Other Bonuses")]
     public int movementBonus = 0;

+ 1 - 0
Assets/Scripts/UI/TitleScreenManager.cs

@@ -375,6 +375,7 @@ public class TitleScreenManager : MonoBehaviour
             PlayerPrefs.DeleteKey(prefix + "Dexterity");
             PlayerPrefs.DeleteKey(prefix + "Constitution");
             PlayerPrefs.DeleteKey(prefix + "Wisdom");
+            PlayerPrefs.DeleteKey(prefix + "Perception");
             PlayerPrefs.DeleteKey(prefix + "Gold");
             PlayerPrefs.DeleteKey(prefix + "Silver");
             PlayerPrefs.DeleteKey(prefix + "Copper");

+ 4 - 0
Assets/UI/TeamSelectOverview/CaracterOverviewPanel.uxml

@@ -41,6 +41,10 @@
                             <engine:Label text="WIS" class="stat-label" />
                             <engine:Label text="10" name="WisdomLabel" class="stat-value" />
                         </engine:VisualElement>
+                        <engine:VisualElement class="stat-row">
+                            <engine:Label text="PER" class="stat-label" />
+                            <engine:Label text="10" name="PerceptionLabel" class="stat-value" />
+                        </engine:VisualElement>
                     </engine:VisualElement>
                     
                     <!-- Character Level/HP -->

+ 7 - 3
Assets/UI/TeamSelectOverview/CharacterSheet.uxml

@@ -17,11 +17,11 @@
             <ui:Label text="Attribute Management" display-tooltip-when-elided="true" name="AttributeManagementTitle" style="font-size: 14px; -unity-font-style: bold; margin-bottom: 5px; color: rgb(220, 220, 220);" />
             <ui:VisualElement name="StatusRow" style="flex-direction: row; justify-content: space-between; margin-bottom: 8px;">
                 <ui:Label text="Mode: Point Buy" display-tooltip-when-elided="true" name="CreationModeLabel" style="font-size: 12px; color: rgb(255, 200, 100);" />
-                <ui:Label text="Available Points: 18" display-tooltip-when-elided="true" name="AvailablePointsLabel" style="font-size: 12px; color: rgb(100, 255, 100);" />
+                <ui:Label text="Available Points: 22" display-tooltip-when-elided="true" name="AvailablePointsLabel" style="font-size: 12px; color: rgb(100, 255, 100);" />
             </ui:VisualElement>
             <ui:VisualElement name="ButtonsRow" style="flex-direction: row; justify-content: space-between; margin-bottom: 5px;">
-                <ui:Button text="Random Point Buy" display-tooltip-when-elided="true" name="RandomizeAttributesButton" tooltip="Randomly distribute 18 points using point-buy rules (stats can range 4-18). Can be edited afterwards!" style="flex-grow: 1; margin-right: 5px; background-color: rgb(200, 100, 100); height: 25px;" />
-                <ui:Button text="Reset to Point Buy" display-tooltip-when-elided="true" name="ResetToPointBuyButton" tooltip="Reset all stats to 10 and use 18-point buy system" style="flex-grow: 1; margin-left: 5px; background-color: rgb(100, 150, 200); height: 25px;" />
+                <ui:Button text="Random Point Buy" display-tooltip-when-elided="true" name="RandomizeAttributesButton" tooltip="Randomly distribute 22 points using point-buy rules (stats can range 4-18). Can be edited afterwards!" style="flex-grow: 1; margin-right: 5px; background-color: rgb(200, 100, 100); height: 25px;" />
+                <ui:Button text="Reset to Point Buy" display-tooltip-when-elided="true" name="ResetToPointBuyButton" tooltip="Reset all stats to 10 and use 22-point buy system" style="flex-grow: 1; margin-left: 5px; background-color: rgb(100, 150, 200); height: 25px;" />
             </ui:VisualElement>
             <ui:Label text="Point Costs: 4=-4pts, 5=-2pts, 6=-1pts, 7=-1pts, 8=0pts, 9=1pt, 10=2pts, 11=3pts, 12=4pts, 13=5pts, 14=7pts, 15=9pts, 16=12pts, 17=16pts, 18=21pts" display-tooltip-when-elided="true" name="PointCostReference" style="font-size: 9px; color: rgb(200, 200, 200); margin-top: 3px; white-space: normal;" />
         </ui:VisualElement>
@@ -44,6 +44,10 @@
                 <ui:Label text="Wisdom" class="stat-label" />
                 <ui:IntegerField name="WisdomValue" value="10" class="stat-input editable" />
             </ui:VisualElement>
+            <ui:VisualElement name="PerceptionRow" class="stat-row">
+                <ui:Label text="Perception" class="stat-label" />
+                <ui:IntegerField name="PerceptionValue" value="10" class="stat-input editable" />
+            </ui:VisualElement>
         </ui:VisualElement>
         <ui:VisualElement name="DerivedStats" class="stats-section" style="border-bottom-right-radius: 0;">
             <ui:Label text="Combat Stats" name="Label" class="section-header CharacterSheetHeading" />

+ 2 - 2
UserSettings/EditorUserSettings.asset

@@ -18,10 +18,10 @@ EditorUserSettings:
       value: 5309060006570d5f0c580e2715270c44144e1c722a7d20612c2d4b37b1b4643a
       flags: 0
     RecentlyUsedSceneGuid-3:
-      value: 510500025d560a0c095d092111730d44464f4b78757b72357a701c31b7b16368
+      value: 5655020755505a0d5e0a5577457b0a44154f1a7f2a7e70697e284b30e4b2623b
       flags: 0
     RecentlyUsedSceneGuid-4:
-      value: 5655020755505a0d5e0a5577457b0a44154f1a7f2a7e70697e284b30e4b2623b
+      value: 510500025d560a0c095d092111730d44464f4b78757b72357a701c31b7b16368
       flags: 0
     RecentlyUsedSceneGuid-5:
       value: 51020c5550545a0354575e7b47270744174e4b787e2b77687b7e1b37e7e4366d