Procházet zdrojové kódy

Small tweaks to the event system

Axel Nordh před 8 měsíci
rodič
revize
5aa6961630

+ 3 - 3
Assets/Resources/TravelEvents/SkeletonAmbush.asset

@@ -14,8 +14,8 @@ MonoBehaviour:
   eventName: Skeleton Ambush
   eventDescription: Ancient skeletal warriors rise from the ground to attack your party!
   eventType: 0
-  rarity: 0
-  plainsChance: 0.3
+  rarity: 1
+  plainsChance: 0.1
   forestChance: 0.8
   mountainChance: 0.6
   roadChance: 0.2
@@ -28,7 +28,7 @@ MonoBehaviour:
   tunnelChance: 0.7
   ferryChance: 0.2
   canOccurMultipleTimes: 1
-  cooldownDays: 0.5
+  cooldownDays: 1
   minEnemies: 1
   maxEnemies: 3
   possibleEnemyTypes:

+ 6 - 6
Assets/Scripts/Events/SkeletonAmbushEvent.cs

@@ -12,12 +12,12 @@ public class SkeletonAmbushEvent : CombatTravelEvent
         eventName = "Skeleton Ambush";
         eventDescription = "Ancient skeletal warriors rise from the ground to attack your party!";
         eventType = EventType.Combat;
-        rarity = EventRarity.Common;
+        rarity = EventRarity.Uncommon; // Changed from Common to Uncommon
 
-        // Terrain preferences - high in dangerous/abandoned areas
+        // Terrain preferences - reduced plains frequency
         forestChance = 0.8f;        // Common in dark forests
         mountainChance = 0.6f;      // Moderate in mountains
-        plainsChance = 0.3f;        // Less common in open plains
+        plainsChance = 0.1f;        // Much less common in open plains (reduced from 0.3f)
         roadChance = 0.2f;          // Much safer on roads
         townChance = 0.05f;         // Very rare near civilization
         villageChance = 0.15f;      // Uncommon near villages
@@ -27,12 +27,12 @@ public class SkeletonAmbushEvent : CombatTravelEvent
         // Combat settings
         minEnemies = 1;
         maxEnemies = 3;
-        
+
         // NOTE: In the Inspector, drag your EnemyCharacterData assets here:
         // - SkeletonWarrior.asset
         // - Any other skeleton variants you create
         // This replaces the old string-based possibleEnemyTypes
-        
+
         encounterDescriptions = new string[]
         {
             "Bones clatter as skeletal warriors emerge from the earth!",
@@ -43,6 +43,6 @@ public class SkeletonAmbushEvent : CombatTravelEvent
         };
 
         canOccurMultipleTimes = true;
-        cooldownDays = 0.5f; // Can happen again after half a day
+        cooldownDays = 1.0f; // Increased cooldown (was 0.5f)
     }
 }

+ 56 - 8
Assets/Scripts/Events/TravelEventSystem.cs

@@ -11,9 +11,9 @@ public class TravelEventSystem : MonoBehaviour
     [Header("Event System Settings")]
     public bool enableEvents = true;
     [Range(0f, 1f)]
-    public float baseEventChance = 0.15f; // 15% chance per tile by default
+    public float baseEventChance = 0.1f; // 10% chance per tile check (reduced from 15%)
     [Range(1, 10)]
-    public int tilesPerEventCheck = 3; // Check for events every N tiles
+    public int tilesPerEventCheck = 4; // Check for events every 4 tiles (increased from 3)
 
     [Header("Event Collections")]
     public List<TravelEvent> availableEvents = new List<TravelEvent>();
@@ -26,6 +26,8 @@ public class TravelEventSystem : MonoBehaviour
     private TravelEventHistory globalEventHistory;
     private int tilesTraveledSinceLastCheck = 0;
     private TravelEventContext currentContext;
+    private Vector2Int lastTeamPosition = Vector2Int.zero;
+    private bool hasInitializedPosition = false;
 
     // Component references
     private TeamTravelSystem travelSystem;
@@ -64,14 +66,40 @@ public class TravelEventSystem : MonoBehaviour
 
     void Update()
     {
-        if (!enableEvents || travelSystem == null || !travelSystem.IsTraveling()) return;
+        if (!enableEvents || travelSystem == null) return;
 
-        // Check if we should evaluate for events
-        tilesTraveledSinceLastCheck++;
-        if (tilesTraveledSinceLastCheck >= tilesPerEventCheck)
+        // Track actual tile movement instead of frame-based checks
+        Vector2Int currentTeamPosition = GetCurrentTeamPosition();
+
+        if (!hasInitializedPosition)
         {
-            CheckForTravelEvent();
-            tilesTraveledSinceLastCheck = 0;
+            lastTeamPosition = currentTeamPosition;
+            hasInitializedPosition = true;
+            return;
+        }
+
+        // Only check for events when the team actually moves to a new tile
+        if (currentTeamPosition != lastTeamPosition)
+        {
+            tilesTraveledSinceLastCheck++;
+
+            if (showDebugLogs)
+            {
+                Debug.Log($"🚶 Team moved from {lastTeamPosition} to {currentTeamPosition} (tiles since last check: {tilesTraveledSinceLastCheck})");
+            }
+
+            lastTeamPosition = currentTeamPosition;
+
+            // Check for events every N tiles traveled
+            if (tilesTraveledSinceLastCheck >= tilesPerEventCheck)
+            {
+                if (showDebugLogs)
+                {
+                    Debug.Log($"🎲 Checking for travel event after {tilesTraveledSinceLastCheck} tiles traveled");
+                }
+                CheckForTravelEvent();
+                tilesTraveledSinceLastCheck = 0;
+            }
         }
     }
 
@@ -485,4 +513,24 @@ public class TravelEventSystem : MonoBehaviour
         tilesTraveledSinceLastCheck = 0;
         Debug.Log("🔄 Event history reset");
     }
+
+    /// <summary>
+    /// Get the current team position in tile coordinates
+    /// </summary>
+    private Vector2Int GetCurrentTeamPosition()
+    {
+        if (teamPlacement == null)
+            return Vector2Int.zero;
+
+        var teamMarker = teamPlacement.GetTeamMarker();
+        if (teamMarker == null)
+            return Vector2Int.zero;
+
+        // Convert world position to tile position
+        Vector3 worldPos = teamMarker.transform.position;
+        return new Vector2Int(
+            Mathf.RoundToInt(worldPos.x),
+            Mathf.RoundToInt(worldPos.z)
+        );
+    }
 }

+ 2 - 2
Assets/Scripts/Objects/Items/MiscellaneousItem.cs

@@ -73,7 +73,7 @@ public class MiscellaneousItem : Item
         {
             int healthRestored = CalculateHealthRestore();
             character.CurrentHealth = Mathf.Min(character.MaxHealth, character.CurrentHealth + healthRestored);
-            
+
             string rollInfo = GetHealthRollDescription();
             Debug.Log($"{character.CharacterName} restored {healthRestored} health from {itemName} {rollInfo}");
         }
@@ -147,7 +147,7 @@ public class MiscellaneousItem : Item
     public string GetEffectDescription()
     {
         string description = "";
-        
+
         if (healthDiceCount > 0 && healthDiceType > 0)
         {
             description += $"Restores {healthDiceCount}d{healthDiceType}";

+ 86 - 86
UserSettings/Layouts/default-6000.dwlt

@@ -14,16 +14,16 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   m_PixelRect:
     serializedVersion: 2
-    x: 242
-    y: 51
-    width: 2781
-    height: 1333
+    x: 0
+    y: 43
+    width: 3440
+    height: 1349
   m_ShowMode: 4
-  m_Title: Game
+  m_Title: Inspector
   m_RootView: {fileID: 5}
   m_MinSize: {x: 875, y: 332}
   m_MaxSize: {x: 10000, y: 10000}
-  m_Maximized: 0
+  m_Maximized: 1
 --- !u!114 &2
 MonoBehaviour:
   m_ObjectHideFlags: 52
@@ -39,10 +39,10 @@ MonoBehaviour:
   m_Children: []
   m_Position:
     serializedVersion: 2
-    x: 1363
+    x: 1686
     y: 0
-    width: 897
-    height: 434
+    width: 1110
+    height: 439
   m_MinSize: {x: 102, y: 126}
   m_MaxSize: {x: 4002, y: 4026}
   m_ActualView: {fileID: 22}
@@ -68,13 +68,13 @@ MonoBehaviour:
   m_Position:
     serializedVersion: 2
     x: 0
-    y: 843
-    width: 2260
-    height: 434
+    y: 854
+    width: 2796
+    height: 439
   m_MinSize: {x: 200, y: 50}
   m_MaxSize: {x: 16192, y: 8096}
   vertical: 0
-  controlID: 129
+  controlID: 74
   draggingID: 0
 --- !u!114 &4
 MonoBehaviour:
@@ -91,10 +91,10 @@ MonoBehaviour:
   m_Children: []
   m_Position:
     serializedVersion: 2
-    x: 1136
+    x: 1405
     y: 0
-    width: 1124
-    height: 843
+    width: 1391
+    height: 854
   m_MinSize: {x: 52, y: 76}
   m_MaxSize: {x: 4002, y: 4026}
   m_ActualView: {fileID: 16}
@@ -123,8 +123,8 @@ MonoBehaviour:
     serializedVersion: 2
     x: 0
     y: 0
-    width: 2781
-    height: 1333
+    width: 3440
+    height: 1349
   m_MinSize: {x: 875, y: 300}
   m_MaxSize: {x: 10000, y: 10000}
   m_UseTopView: 1
@@ -148,7 +148,7 @@ MonoBehaviour:
     serializedVersion: 2
     x: 0
     y: 0
-    width: 2781
+    width: 3440
     height: 36
   m_MinSize: {x: 0, y: 0}
   m_MaxSize: {x: 0, y: 0}
@@ -169,8 +169,8 @@ MonoBehaviour:
   m_Position:
     serializedVersion: 2
     x: 0
-    y: 1313
-    width: 2781
+    y: 1329
+    width: 3440
     height: 20
   m_MinSize: {x: 0, y: 0}
   m_MaxSize: {x: 0, y: 0}
@@ -193,12 +193,12 @@ MonoBehaviour:
     serializedVersion: 2
     x: 0
     y: 36
-    width: 2781
-    height: 1277
+    width: 3440
+    height: 1293
   m_MinSize: {x: 400, y: 100}
   m_MaxSize: {x: 32384, y: 16192}
   vertical: 0
-  controlID: 165
+  controlID: 47
   draggingID: 0
 --- !u!114 &9
 MonoBehaviour:
@@ -219,8 +219,8 @@ MonoBehaviour:
     serializedVersion: 2
     x: 0
     y: 0
-    width: 2260
-    height: 1277
+    width: 2796
+    height: 1293
   m_MinSize: {x: 300, y: 100}
   m_MaxSize: {x: 24288, y: 16192}
   vertical: 1
@@ -246,8 +246,8 @@ MonoBehaviour:
     serializedVersion: 2
     x: 0
     y: 0
-    width: 2260
-    height: 843
+    width: 2796
+    height: 854
   m_MinSize: {x: 300, y: 50}
   m_MaxSize: {x: 24288, y: 8096}
   vertical: 0
@@ -270,8 +270,8 @@ MonoBehaviour:
     serializedVersion: 2
     x: 0
     y: 0
-    width: 516
-    height: 843
+    width: 638
+    height: 854
   m_MinSize: {x: 201, y: 226}
   m_MaxSize: {x: 4001, y: 4026}
   m_ActualView: {fileID: 18}
@@ -294,10 +294,10 @@ MonoBehaviour:
   m_Children: []
   m_Position:
     serializedVersion: 2
-    x: 516
+    x: 638
     y: 0
-    width: 620
-    height: 843
+    width: 767
+    height: 854
   m_MinSize: {x: 202, y: 226}
   m_MaxSize: {x: 4002, y: 4026}
   m_ActualView: {fileID: 19}
@@ -324,8 +324,8 @@ MonoBehaviour:
     serializedVersion: 2
     x: 0
     y: 0
-    width: 1363
-    height: 434
+    width: 1686
+    height: 439
   m_MinSize: {x: 231, y: 276}
   m_MaxSize: {x: 10001, y: 10026}
   m_ActualView: {fileID: 21}
@@ -348,10 +348,10 @@ MonoBehaviour:
   m_Children: []
   m_Position:
     serializedVersion: 2
-    x: 2260
+    x: 2796
     y: 0
-    width: 521
-    height: 1277
+    width: 644
+    height: 1293
   m_MinSize: {x: 276, y: 76}
   m_MaxSize: {x: 4001, y: 4026}
   m_ActualView: {fileID: 23}
@@ -380,10 +380,10 @@ MonoBehaviour:
     m_TextWithWhitespace: "UI Builder\u200B"
   m_Pos:
     serializedVersion: 2
-    x: 1378
-    y: 87
-    width: 1122
-    height: 822
+    x: 1405
+    y: 79
+    width: 1389
+    height: 828
   m_SerializedDataModeController:
     m_DataMode: 0
     m_PreferredDataMode: 0
@@ -416,10 +416,10 @@ MonoBehaviour:
     m_TextWithWhitespace: "Game\u200B"
   m_Pos:
     serializedVersion: 2
-    x: 1137
+    x: 1406
     y: 24
-    width: 1122
-    height: 817
+    width: 1389
+    height: 828
   m_SerializedDataModeController:
     m_DataMode: 0
     m_PreferredDataMode: 0
@@ -437,7 +437,7 @@ MonoBehaviour:
   m_ShowGizmos: 0
   m_TargetDisplay: 0
   m_ClearColor: {r: 0, g: 0, b: 0, a: 0}
-  m_TargetSize: {x: 1122, y: 796}
+  m_TargetSize: {x: 1389, y: 807}
   m_TextureFilterMode: 0
   m_TextureHideFlags: 61
   m_RenderIMGUI: 1
@@ -452,10 +452,10 @@ MonoBehaviour:
     m_VRangeLocked: 0
     hZoomLockedByDefault: 0
     vZoomLockedByDefault: 0
-    m_HBaseRangeMin: -561
-    m_HBaseRangeMax: 561
-    m_VBaseRangeMin: -398
-    m_VBaseRangeMax: 398
+    m_HBaseRangeMin: -694.5
+    m_HBaseRangeMax: 694.5
+    m_VBaseRangeMin: -403.5
+    m_VBaseRangeMax: 403.5
     m_HAllowExceedBaseRangeMin: 1
     m_HAllowExceedBaseRangeMax: 1
     m_VAllowExceedBaseRangeMin: 1
@@ -473,23 +473,23 @@ MonoBehaviour:
       serializedVersion: 2
       x: 0
       y: 21
-      width: 1122
-      height: 796
+      width: 1389
+      height: 807
     m_Scale: {x: 1, y: 1}
-    m_Translation: {x: 561, y: 398}
+    m_Translation: {x: 694.5, y: 403.5}
     m_MarginLeft: 0
     m_MarginRight: 0
     m_MarginTop: 0
     m_MarginBottom: 0
     m_LastShownAreaInsideMargins:
       serializedVersion: 2
-      x: -561
-      y: -398
-      width: 1122
-      height: 796
+      x: -694.5
+      y: -403.5
+      width: 1389
+      height: 807
     m_MinimalGUI: 1
   m_defaultScale: 1
-  m_LastWindowPixelSize: {x: 1122, y: 817}
+  m_LastWindowPixelSize: {x: 1389, y: 828}
   m_ClearInEditMode: 1
   m_NoCameraWarning: 1
   m_LowResolutionForAspectRatios: 01000000000000000000
@@ -534,7 +534,7 @@ MonoBehaviour:
     m_OverlaysVisible: 1
   m_LockTracker:
     m_IsLocked: 0
-  m_LastSelectedObjectID: 48954
+  m_LastSelectedObjectID: 45276
 --- !u!114 &18
 MonoBehaviour:
   m_ObjectHideFlags: 52
@@ -558,8 +558,8 @@ MonoBehaviour:
     serializedVersion: 2
     x: 0
     y: 24
-    width: 515
-    height: 817
+    width: 637
+    height: 828
   m_SerializedDataModeController:
     m_DataMode: 0
     m_PreferredDataMode: 0
@@ -576,7 +576,7 @@ MonoBehaviour:
       scrollPos: {x: 0, y: 0}
       m_SelectedIDs: 
       m_LastClickedID: 0
-      m_ExpandedIDs: be1de4ff9c9eecffe89efbff1afbffff
+      m_ExpandedIDs: b80aacff6e71b4ff009dcdffbc02d6ff1afbffff
       m_RenameOverlay:
         m_UserAcceptedRename: 0
         m_Name: 
@@ -622,10 +622,10 @@ MonoBehaviour:
     m_TextWithWhitespace: "Scene\u200B"
   m_Pos:
     serializedVersion: 2
-    x: 517
+    x: 639
     y: 24
-    width: 618
-    height: 817
+    width: 765
+    height: 828
   m_SerializedDataModeController:
     m_DataMode: 0
     m_PreferredDataMode: 0
@@ -1208,9 +1208,9 @@ MonoBehaviour:
   m_AudioPlay: 0
   m_DebugDrawModesUseInteractiveLightBakingData: 0
   m_Position:
-    m_Target: {x: 146.89474, y: 135.49393, z: -2}
+    m_Target: {x: 12.970818, y: 433.2704, z: 802.6817}
     speed: 2
-    m_Value: {x: 146.89474, y: 135.49393, z: -2}
+    m_Value: {x: 12.970818, y: 433.2704, z: 802.6817}
   m_RenderMode: 0
   m_CameraMode:
     drawMode: 0
@@ -1256,13 +1256,13 @@ MonoBehaviour:
     m_GridAxis: 1
     m_gridOpacity: 0.5
   m_Rotation:
-    m_Target: {x: 0, y: 0, z: 0, w: 1}
+    m_Target: {x: 0.23769794, y: 0.0058279876, z: -0.0014266352, w: 0.9713199}
     speed: 2
-    m_Value: {x: -0, y: 0, z: -0, w: -1}
+    m_Value: {x: -0.23769796, y: -0.0058279876, z: 0.0014266352, w: -0.9713199}
   m_Size:
-    m_Target: 106.721756
+    m_Target: 10
     speed: 2
-    m_Value: 106.721756
+    m_Value: 10
   m_Ortho:
     m_Target: 0
     speed: 2
@@ -1388,8 +1388,8 @@ MonoBehaviour:
     serializedVersion: 2
     x: 0
     y: 24
-    width: 1362
-    height: 408
+    width: 1685
+    height: 413
   m_SerializedDataModeController:
     m_DataMode: 0
     m_PreferredDataMode: 0
@@ -1412,7 +1412,7 @@ MonoBehaviour:
     m_SkipHidden: 0
     m_SearchArea: 1
     m_Folders:
-    - Assets/Scripts/UI
+    - Assets/Scripts/Objects/Weapons
     m_Globs: []
     m_ProductIds: 
     m_AnyWithAssetOrigin: 0
@@ -1422,16 +1422,16 @@ MonoBehaviour:
   m_ViewMode: 1
   m_StartGridSize: 67
   m_LastFolders:
-  - Assets/Scripts/UI
+  - Assets/Scripts/Objects/Weapons
   m_LastFoldersGridSize: 67
   m_LastProjectPath: C:\Users\Axel-PC\RPG-RougeLiteBatteler
   m_LockTracker:
     m_IsLocked: 0
   m_FolderTreeState:
-    scrollPos: {x: 0, y: 79}
-    m_SelectedIDs: e8b40000
-    m_LastClickedID: 46312
-    m_ExpandedIDs: 000000004eb2000050b2000052b2000054b2000056b20000
+    scrollPos: {x: 0, y: 371}
+    m_SelectedIDs: 40be0000
+    m_LastClickedID: 48704
+    m_ExpandedIDs: 0000000036b3000038b300003ab300003cb300003eb3000040b3000042b3000044b3000046b30000
     m_RenameOverlay:
       m_UserAcceptedRename: 0
       m_Name: 
@@ -1460,7 +1460,7 @@ MonoBehaviour:
     scrollPos: {x: 0, y: 0}
     m_SelectedIDs: 
     m_LastClickedID: 0
-    m_ExpandedIDs: 000000004eb2000050b2000052b2000054b2000056b20000
+    m_ExpandedIDs: 0000000036b3000038b300003ab300003cb300003eb3000040b3000042b3000044b3000046b30000
     m_RenameOverlay:
       m_UserAcceptedRename: 0
       m_Name: 
@@ -1539,10 +1539,10 @@ MonoBehaviour:
     m_TextWithWhitespace: "Console\u200B"
   m_Pos:
     serializedVersion: 2
-    x: 1364
+    x: 1687
     y: 24
-    width: 895
-    height: 408
+    width: 1108
+    height: 413
   m_SerializedDataModeController:
     m_DataMode: 0
     m_PreferredDataMode: 0
@@ -1575,10 +1575,10 @@ MonoBehaviour:
     m_TextWithWhitespace: "Inspector\u200B"
   m_Pos:
     serializedVersion: 2
-    x: 2261
+    x: 2797
     y: 24
-    width: 520
-    height: 1251
+    width: 643
+    height: 1267
   m_SerializedDataModeController:
     m_DataMode: 0
     m_PreferredDataMode: 0