Procházet zdrojové kódy

BattleScene updated working

Axel Nordh před 8 měsíci
rodič
revize
27d952a131

+ 316 - 0
Assets/Scenes/TownSceen.unity

@@ -0,0 +1,316 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!29 &1
+OcclusionCullingSettings:
+  m_ObjectHideFlags: 0
+  serializedVersion: 2
+  m_OcclusionBakeSettings:
+    smallestOccluder: 5
+    smallestHole: 0.25
+    backfaceThreshold: 100
+  m_SceneGUID: 00000000000000000000000000000000
+  m_OcclusionCullingData: {fileID: 0}
+--- !u!104 &2
+RenderSettings:
+  m_ObjectHideFlags: 0
+  serializedVersion: 10
+  m_Fog: 0
+  m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
+  m_FogMode: 3
+  m_FogDensity: 0.01
+  m_LinearFogStart: 0
+  m_LinearFogEnd: 300
+  m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
+  m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
+  m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
+  m_AmbientIntensity: 1
+  m_AmbientMode: 0
+  m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
+  m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
+  m_HaloStrength: 0.5
+  m_FlareStrength: 1
+  m_FlareFadeSpeed: 3
+  m_HaloTexture: {fileID: 0}
+  m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
+  m_DefaultReflectionMode: 0
+  m_DefaultReflectionResolution: 128
+  m_ReflectionBounces: 1
+  m_ReflectionIntensity: 1
+  m_CustomReflection: {fileID: 0}
+  m_Sun: {fileID: 0}
+  m_UseRadianceAmbientProbe: 0
+--- !u!157 &3
+LightmapSettings:
+  m_ObjectHideFlags: 0
+  serializedVersion: 13
+  m_BakeOnSceneLoad: 0
+  m_GISettings:
+    serializedVersion: 2
+    m_BounceScale: 1
+    m_IndirectOutputScale: 1
+    m_AlbedoBoost: 1
+    m_EnvironmentLightingMode: 0
+    m_EnableBakedLightmaps: 1
+    m_EnableRealtimeLightmaps: 0
+  m_LightmapEditorSettings:
+    serializedVersion: 12
+    m_Resolution: 2
+    m_BakeResolution: 40
+    m_AtlasSize: 1024
+    m_AO: 0
+    m_AOMaxDistance: 1
+    m_CompAOExponent: 1
+    m_CompAOExponentDirect: 0
+    m_ExtractAmbientOcclusion: 0
+    m_Padding: 2
+    m_LightmapParameters: {fileID: 0}
+    m_LightmapsBakeMode: 1
+    m_TextureCompression: 1
+    m_ReflectionCompression: 2
+    m_MixedBakeMode: 2
+    m_BakeBackend: 1
+    m_PVRSampling: 1
+    m_PVRDirectSampleCount: 32
+    m_PVRSampleCount: 512
+    m_PVRBounces: 2
+    m_PVREnvironmentSampleCount: 256
+    m_PVREnvironmentReferencePointCount: 2048
+    m_PVRFilteringMode: 1
+    m_PVRDenoiserTypeDirect: 1
+    m_PVRDenoiserTypeIndirect: 1
+    m_PVRDenoiserTypeAO: 1
+    m_PVRFilterTypeDirect: 0
+    m_PVRFilterTypeIndirect: 0
+    m_PVRFilterTypeAO: 0
+    m_PVREnvironmentMIS: 1
+    m_PVRCulling: 1
+    m_PVRFilteringGaussRadiusDirect: 1
+    m_PVRFilteringGaussRadiusIndirect: 1
+    m_PVRFilteringGaussRadiusAO: 1
+    m_PVRFilteringAtrousPositionSigmaDirect: 0.5
+    m_PVRFilteringAtrousPositionSigmaIndirect: 2
+    m_PVRFilteringAtrousPositionSigmaAO: 1
+    m_ExportTrainingData: 0
+    m_TrainingDataDestination: TrainingData
+    m_LightProbeSampleCountMultiplier: 4
+  m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0}
+  m_LightingSettings: {fileID: 0}
+--- !u!196 &4
+NavMeshSettings:
+  serializedVersion: 2
+  m_ObjectHideFlags: 0
+  m_BuildSettings:
+    serializedVersion: 3
+    agentTypeID: 0
+    agentRadius: 0.5
+    agentHeight: 2
+    agentSlope: 45
+    agentClimb: 0.4
+    ledgeDropHeight: 0
+    maxJumpAcrossDistance: 0
+    minRegionArea: 2
+    manualCellSize: 0
+    cellSize: 0.16666667
+    manualTileSize: 0
+    tileSize: 256
+    buildHeightMesh: 0
+    maxJobWorkers: 0
+    preserveTilesOutsideBounds: 0
+    debug:
+      m_Flags: 0
+  m_NavMeshData: {fileID: 0}
+--- !u!1 &276547329
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 276547331}
+  - component: {fileID: 276547330}
+  m_Layer: 0
+  m_Name: Directional Light
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!108 &276547330
+Light:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 276547329}
+  m_Enabled: 1
+  serializedVersion: 11
+  m_Type: 1
+  m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
+  m_Intensity: 1
+  m_Range: 10
+  m_SpotAngle: 30
+  m_InnerSpotAngle: 21.80208
+  m_CookieSize: 10
+  m_Shadows:
+    m_Type: 2
+    m_Resolution: -1
+    m_CustomResolution: -1
+    m_Strength: 1
+    m_Bias: 0.05
+    m_NormalBias: 0.4
+    m_NearPlane: 0.2
+    m_CullingMatrixOverride:
+      e00: 1
+      e01: 0
+      e02: 0
+      e03: 0
+      e10: 0
+      e11: 1
+      e12: 0
+      e13: 0
+      e20: 0
+      e21: 0
+      e22: 1
+      e23: 0
+      e30: 0
+      e31: 0
+      e32: 0
+      e33: 1
+    m_UseCullingMatrixOverride: 0
+  m_Cookie: {fileID: 0}
+  m_DrawHalo: 0
+  m_Flare: {fileID: 0}
+  m_RenderMode: 0
+  m_CullingMask:
+    serializedVersion: 2
+    m_Bits: 4294967295
+  m_RenderingLayerMask: 1
+  m_Lightmapping: 4
+  m_LightShadowCasterMode: 0
+  m_AreaSize: {x: 1, y: 1}
+  m_BounceIntensity: 1
+  m_ColorTemperature: 6570
+  m_UseColorTemperature: 0
+  m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
+  m_UseBoundingSphereOverride: 0
+  m_UseViewFrustumForShadowCasterCull: 1
+  m_ForceVisible: 0
+  m_ShadowRadius: 0
+  m_ShadowAngle: 0
+  m_LightUnit: 1
+  m_LuxAtDistance: 1
+  m_EnableSpotReflector: 1
+--- !u!4 &276547331
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 276547329}
+  serializedVersion: 2
+  m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
+  m_LocalPosition: {x: 0, y: 3, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
+--- !u!1 &712987406
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 712987409}
+  - component: {fileID: 712987408}
+  - component: {fileID: 712987407}
+  m_Layer: 0
+  m_Name: Main Camera
+  m_TagString: MainCamera
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!81 &712987407
+AudioListener:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 712987406}
+  m_Enabled: 1
+--- !u!20 &712987408
+Camera:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 712987406}
+  m_Enabled: 1
+  serializedVersion: 2
+  m_ClearFlags: 1
+  m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
+  m_projectionMatrixMode: 1
+  m_GateFitMode: 2
+  m_FOVAxisMode: 0
+  m_Iso: 200
+  m_ShutterSpeed: 0.005
+  m_Aperture: 16
+  m_FocusDistance: 10
+  m_FocalLength: 50
+  m_BladeCount: 5
+  m_Curvature: {x: 2, y: 11}
+  m_BarrelClipping: 0.25
+  m_Anamorphism: 0
+  m_SensorSize: {x: 36, y: 24}
+  m_LensShift: {x: 0, y: 0}
+  m_NormalizedViewPortRect:
+    serializedVersion: 2
+    x: 0
+    y: 0
+    width: 1
+    height: 1
+  near clip plane: 0.3
+  far clip plane: 1000
+  field of view: 60
+  orthographic: 0
+  orthographic size: 5
+  m_Depth: -1
+  m_CullingMask:
+    serializedVersion: 2
+    m_Bits: 4294967295
+  m_RenderingPath: -1
+  m_TargetTexture: {fileID: 0}
+  m_TargetDisplay: 0
+  m_TargetEye: 3
+  m_HDR: 1
+  m_AllowMSAA: 1
+  m_AllowDynamicResolution: 0
+  m_ForceIntoRT: 0
+  m_OcclusionCulling: 1
+  m_StereoConvergence: 10
+  m_StereoSeparation: 0.022
+--- !u!4 &712987409
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 712987406}
+  serializedVersion: 2
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 1, z: -10}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1660057539 &9223372036854775807
+SceneRoots:
+  m_ObjectHideFlags: 0
+  m_Roots:
+  - {fileID: 712987409}
+  - {fileID: 276547331}

+ 285 - 42
Assets/Scripts/BattleScene/BattleActionIntegration.cs

@@ -17,7 +17,6 @@ public class BattleActionIntegration : MonoBehaviour
     [Header("Settings")]
     [Tooltip("Enable new action wheel system (false = use old click-drag system)")]
     public bool useNewActionSystem = false; // Changed to false by default for simpler testing
-    public KeyCode actionWheelKey = KeyCode.Q; // Use Q consistently
     [Space]
     [Tooltip("Press this key to toggle between action systems")]
     public KeyCode toggleSystemKey = KeyCode.T;
@@ -32,6 +31,9 @@ public class BattleActionIntegration : MonoBehaviour
     {
         Debug.Log("🚀 BattleActionIntegration starting...");
 
+        // FORCE useNewActionSystem to false to preserve drag functionality
+        useNewActionSystem = false;
+
         // Find components if not assigned
         if (playerDecisionController == null)
             playerDecisionController = FindFirstObjectByType<PlayerDecisionController>();
@@ -48,11 +50,12 @@ public class BattleActionIntegration : MonoBehaviour
         if (itemSelectionUI == null)
             itemSelectionUI = FindFirstObjectByType<BattleItemSelector>();
 
-        // Disable old drag system if using new action system (but allow re-enabling for targeting)
-        if (useNewActionSystem && playerDecisionController != null)
+        // Ensure PlayerDecisionController is always enabled for drag functionality
+        if (playerDecisionController != null)
         {
-            // Don't completely disable - we'll use it for targeting after action selection
-            Debug.Log("🎮 PlayerDecisionController will be used for targeting after action selection");
+            playerDecisionController.enabled = true;
+            playerDecisionController.SetEnabled(true);
+            Debug.Log("🎮 PlayerDecisionController enabled for drag functionality");
         }
 
         // Try to find or create a simple wheel component
@@ -96,7 +99,7 @@ public class BattleActionIntegration : MonoBehaviour
             ConnectSimpleWheelEvents();
         }
 
-        Debug.Log($"✅ BattleActionIntegration initialized - useNewActionSystem: {useNewActionSystem}, actionWheelKey: {actionWheelKey}");
+        Debug.Log($"✅ BattleActionIntegration initialized - useNewActionSystem: {useNewActionSystem}");
     }
 
     void Update()
@@ -107,10 +110,70 @@ public class BattleActionIntegration : MonoBehaviour
             ToggleActionSystem();
         }
 
+        // Handle action wheel key from SimpleActionWheel
+        // Get the key from SimpleActionWheel component if available
+        KeyCode wheelKey = KeyCode.Q; // Default fallback
+        if (simpleWheelComponent != null)
+        {
+            var toggleKeyField = simpleWheelComponent.GetType().GetField("toggleKey");
+            if (toggleKeyField != null)
+            {
+                wheelKey = (KeyCode)toggleKeyField.GetValue(simpleWheelComponent);
+            }
+        }
+
+        if (Input.GetKeyDown(wheelKey))
+        {
+            // Clear any existing instruction when opening wheel
+            currentInstruction = "";
+            instructionTimer = 0f;
+
+            // When using old system, get the selected character from PlayerDecisionController
+            Character characterForWheel = lastSelectedCharacter;
+            if (!useNewActionSystem && playerDecisionController != null)
+            {
+                Character currentlySelected = playerDecisionController.GetSelectedCharacter();
+                if (currentlySelected != null)
+                {
+                    characterForWheel = currentlySelected;
+                    lastSelectedCharacter = currentlySelected; // Update for consistency
+                }
+            }
+
+            if (characterForWheel != null)
+            {
+                // Allow reopening the action wheel even if an action is already selected
+                // This enables canceling/changing the selected action
+                Debug.Log($"⌨️ {wheelKey} pressed, showing wheel for {characterForWheel.CharacterName}");
+                ShowActionWheelForCharacter(characterForWheel);
+            }
+            else
+            {
+                Debug.Log($"⌨️ {wheelKey} pressed but no character selected");
+            }
+        }
+
         if (useNewActionSystem)
         {
             HandleNewActionSystemInput();
         }
+        else
+        {
+            // When using old system, track character selection for action wheel
+            // Monitor PlayerDecisionController's targeting state to update lastSelectedCharacter
+            if (playerDecisionController != null && playerDecisionController.IsInTargetingMode)
+            {
+                Character currentlySelected = playerDecisionController.GetSelectedCharacter();
+                if (currentlySelected != null && currentlySelected != lastSelectedCharacter)
+                {
+                    lastSelectedCharacter = currentlySelected;
+                    Debug.Log($"🖱️ Character selected for action wheel: {currentlySelected.CharacterName}");
+                    
+                    // Clear any old instructions and show current action status
+                    ShowCharacterActionStatus(currentlySelected);
+                }
+            }
+        }
         // Note: When useNewActionSystem is false, the old PlayerDecisionController.Update() 
         // will handle input automatically - no need to interfere
 
@@ -125,6 +188,22 @@ public class BattleActionIntegration : MonoBehaviour
         }
     }
 
+    /// <summary>
+    /// Get the action wheel key from SimpleActionWheel component
+    /// </summary>
+    private KeyCode GetActionWheelKey()
+    {
+        if (simpleWheelComponent != null)
+        {
+            var toggleKeyField = simpleWheelComponent.GetType().GetField("toggleKey");
+            if (toggleKeyField != null)
+            {
+                return (KeyCode)toggleKeyField.GetValue(simpleWheelComponent);
+            }
+        }
+        return KeyCode.Q; // Default fallback
+    }
+
     void OnGUI()
     {
         // Show instruction message if active
@@ -147,12 +226,10 @@ public class BattleActionIntegration : MonoBehaviour
             GUI.Label(instructionRect, currentInstruction, instructionStyle);
         }
 
-        if (!useNewActionSystem) return;
-
-        // Simple UI for testing
+        // Simple UI for testing - show regardless of system mode
         GUILayout.BeginArea(new Rect(10, 10, 300, 250));
-        GUILayout.Label("Battle Action System");
-        GUILayout.Label($"Action Key: {actionWheelKey}");
+        GUILayout.Label($"Battle Action System (Mode: {(useNewActionSystem ? "New" : "Old")})");
+        GUILayout.Label($"Action Key: {GetActionWheelKey()}");
         GUILayout.Label($"Simple Wheel: {(simpleWheelComponent != null ? "✅" : "❌")}");
 
         if (lastSelectedCharacter != null)
@@ -163,6 +240,11 @@ public class BattleActionIntegration : MonoBehaviour
             if (actionData != null && actionData.hasValidAction)
             {
                 GUILayout.Label($"Action: {actionData.GetActionDescription()}");
+                GUILayout.Label($"Press {GetActionWheelKey()} again to change action", GUI.skin.box);
+            }
+            else
+            {
+                GUILayout.Label($"Press {GetActionWheelKey()} to choose action");
             }
         }
         else
@@ -171,7 +253,7 @@ public class BattleActionIntegration : MonoBehaviour
             GUILayout.Label("Click a player character to select");
         }
 
-        GUILayout.Label($"Press {actionWheelKey} to show action wheel");
+        GUILayout.Label($"Press {GetActionWheelKey()} to show action wheel");
 
         if (GUILayout.Button("Test Action Wheel"))
         {
@@ -182,11 +264,26 @@ public class BattleActionIntegration : MonoBehaviour
             }
         }
 
+        if (GUILayout.Button("Reset PlayerDecisionController"))
+        {
+            if (playerDecisionController != null)
+            {
+                playerDecisionController.ResetState();
+            }
+        }
+
         GUILayout.EndArea();
     }
 
     private void HandleNewActionSystemInput()
     {
+        // Don't interfere with mouse input if PlayerDecisionController is in targeting mode
+        if (playerDecisionController != null && playerDecisionController.IsInTargetingMode)
+        {
+            // Let PlayerDecisionController handle the input for targeting
+            return;
+        }
+
         // Check for character selection
         if (Input.GetMouseButtonDown(0))
         {
@@ -213,20 +310,6 @@ public class BattleActionIntegration : MonoBehaviour
                 Debug.Log("🖱️ Clicked but no character found");
             }
         }
-
-        // Show action wheel with Q key
-        if (Input.GetKeyDown(actionWheelKey))
-        {
-            if (lastSelectedCharacter != null)
-            {
-                Debug.Log($"⌨️ {actionWheelKey} pressed, showing wheel for {lastSelectedCharacter.CharacterName}");
-                ShowActionWheelForCharacter(lastSelectedCharacter);
-            }
-            else
-            {
-                Debug.Log($"⌨️ {actionWheelKey} pressed but no character selected");
-            }
-        }
     }
 
     private Character GetCharacterAtMousePosition()
@@ -244,10 +327,20 @@ public class BattleActionIntegration : MonoBehaviour
 
     private void SelectCharacterForAction(Character character)
     {
-        // Clear previous selection
+        // Only clear visual state of previous selection if they don't have an action
         if (lastSelectedCharacter != null)
         {
-            lastSelectedCharacter.SetVisualState(ActionDecisionState.NoAction);
+            var prevActionData = lastSelectedCharacter.GetEnhancedActionData<EnhancedCharacterActionData>();
+            if (prevActionData == null || !prevActionData.hasValidAction)
+            {
+                // Only reset to NoAction if they don't have a valid action
+                lastSelectedCharacter.SetVisualState(ActionDecisionState.NoAction);
+            }
+            else
+            {
+                // Preserve their action state
+                lastSelectedCharacter.SetVisualState(ActionDecisionState.ActionSelected);
+            }
         }
 
         lastSelectedCharacter = character;
@@ -261,9 +354,12 @@ public class BattleActionIntegration : MonoBehaviour
             character.SetEnhancedActionData(actionData);
         }
 
-        // Highlight selected character
+        // Highlight selected character (use a different state for "currently selected")
         character.SetVisualState(ActionDecisionState.NoAction);
 
+        // Update all character visual states to maintain proper color coding
+        UpdateAllCharacterVisualStates();
+
         Debug.Log($"🎯 Selected character for action: {character.CharacterName}");
 
         // Don't auto-show wheel - let user press Q manually
@@ -273,10 +369,61 @@ public class BattleActionIntegration : MonoBehaviour
         // }
     }
 
+    /// <summary>
+    /// Update visual states for all characters to properly show action status
+    /// </summary>
+    private void UpdateAllCharacterVisualStates()
+    {
+        Character[] allCharacters = FindObjectsByType<Character>(FindObjectsSortMode.None);
+
+        foreach (Character character in allCharacters)
+        {
+            if (character.CompareTag("Player"))
+            {
+                var actionData = character.GetEnhancedActionData<EnhancedCharacterActionData>();
+
+                if (character == lastSelectedCharacter)
+                {
+                    // Currently selected character - show selection highlight
+                    character.SetVisualState(ActionDecisionState.NoAction); // Pink for selection
+                }
+                else if (actionData != null && actionData.hasValidAction)
+                {
+                    // Has valid action selected - show action confirmed state
+                    character.SetVisualState(ActionDecisionState.ActionSelected); // Green for confirmed action
+                }
+                else
+                {
+                    // No action selected
+                    character.SetVisualState(ActionDecisionState.NoAction); // Pink for no action
+                }
+            }
+        }
+    }
+
     private void ShowActionWheelForCharacter(Character character)
     {
         Debug.Log($"🎯 ShowActionWheelForCharacter called for: {character.CharacterName}");
 
+        // Clear any existing instruction when showing the wheel
+        currentInstruction = "";
+        instructionTimer = 0f;
+
+        // Reset PlayerDecisionController state to ensure clean state
+        if (playerDecisionController != null)
+        {
+            playerDecisionController.ResetState();
+        }
+
+        // Reset any existing action for this character to allow changing selection
+        var existingActionData = character.GetEnhancedActionData<EnhancedCharacterActionData>();
+        if (existingActionData != null && existingActionData.hasValidAction)
+        {
+            Debug.Log($"🔄 Resetting existing action for {character.CharacterName}: {existingActionData.GetActionDescription()}");
+            existingActionData.Reset();
+            character.SetVisualState(ActionDecisionState.NoAction);
+        }
+
         // Try simple wheel first
         if (simpleWheelComponent != null)
         {
@@ -418,6 +565,9 @@ public class BattleActionIntegration : MonoBehaviour
         }
 
         Debug.Log($"✅ Action {actionType} configured for {lastSelectedCharacter.CharacterName}");
+
+        // Update all character visual states to show proper action status
+        UpdateAllCharacterVisualStates();
     }
 
     private void StartTargetingMode(Character character, BattleActionType actionType)
@@ -473,16 +623,49 @@ public class BattleActionIntegration : MonoBehaviour
             var actionData = lastSelectedCharacter.GetEnhancedActionData<EnhancedCharacterActionData>();
             if (actionData != null)
             {
-                actionData.selectedItemName = itemName;
-                actionData.selectedItemIndex = itemIndex;
-                actionData.state = ActionDecisionState.ActionSelected;
-                lastSelectedCharacter.SetVisualState(ActionDecisionState.ActionSelected);
-
-                Debug.Log($"✅ {lastSelectedCharacter.CharacterName} will use {itemName}");
+                // Check if item requires targeting (healing potions, etc. might target allies)
+                bool requiresTargeting = IsItemRequiringTargeting(itemName);
+                
+                // Properly set the item action using the SetItemAction method
+                actionData.SetItemAction(itemName, itemIndex, requiresTargeting);
+                
+                if (!requiresTargeting)
+                {
+                    lastSelectedCharacter.SetVisualState(ActionDecisionState.ActionSelected);
+                    Debug.Log($"✅ {lastSelectedCharacter.CharacterName} will use {itemName}");
+                    
+                    // Show the updated action status
+                    ShowCharacterActionStatus(lastSelectedCharacter);
+                }
+                else
+                {
+                    Debug.Log($"🎯 {itemName} requires targeting - start targeting mode");
+                    ShowInstructionMessage($"TARGET: Select target for {itemName}");
+                    StartTargetingMode(lastSelectedCharacter, BattleActionType.UseItem);
+                }
             }
         }
     }
 
+    /// <summary>
+    /// Check if an item requires targeting (healing items, targeted attacks, etc.)
+    /// </summary>
+    private bool IsItemRequiringTargeting(string itemName)
+    {
+        // Add logic here to determine if item needs targeting
+        // For now, assume most items are self-use (like health potions)
+        // Healing items that can target others would return true
+        
+        if (itemName.ToLower().Contains("heal") && itemName.ToLower().Contains("other"))
+            return true;
+        if (itemName.ToLower().Contains("revive"))
+            return true;
+        if (itemName.ToLower().Contains("bomb") || itemName.ToLower().Contains("throw"))
+            return true;
+            
+        return false; // Most items are self-use
+    }
+
     private void OnItemSelectionCancelled()
     {
         Debug.Log("❌ Item selection cancelled");
@@ -547,13 +730,10 @@ public class BattleActionIntegration : MonoBehaviour
         // Enable/disable appropriate systems
         if (playerDecisionController != null)
         {
-            playerDecisionController.enabled = !useNewActionSystem;
-
-            // If switching to old system, make sure it's properly enabled
-            if (!useNewActionSystem)
-            {
-                playerDecisionController.SetEnabled(true);
-            }
+            // Keep PlayerDecisionController enabled for targeting support
+            // Just control its input handling behavior
+            playerDecisionController.enabled = true;
+            playerDecisionController.SetEnabled(true);
         }
 
         // Clear any instruction messages when switching
@@ -608,10 +788,73 @@ public class BattleActionIntegration : MonoBehaviour
         Debug.Log("🔄 All player actions reset");
     }
 
+    /// <summary>
+    /// Cancel action for a specific character (useful for undoing individual selections)
+    /// </summary>
+    public void CancelCharacterAction(Character character)
+    {
+        if (character == null) return;
+
+        var actionData = character.GetEnhancedActionData<EnhancedCharacterActionData>();
+        if (actionData != null && actionData.hasValidAction)
+        {
+            Debug.Log($"❌ Canceling action for {character.CharacterName}: {actionData.GetActionDescription()}");
+            actionData.Reset();
+            character.SetVisualState(ActionDecisionState.NoAction);
+
+            ShowInstructionMessage($"Action canceled for {character.CharacterName}");
+        }
+        else
+        {
+            Debug.Log($"No action to cancel for {character.CharacterName}");
+        }
+    }
+
     private void ShowInstructionMessage(string message)
     {
         currentInstruction = message;
         instructionTimer = instructionDuration;
         Debug.Log($"📢 Instruction: {message}");
     }
+
+    /// <summary>
+    /// Show the current action status for a character or clear instructions if no action
+    /// </summary>
+    private void ShowCharacterActionStatus(Character character)
+    {
+        var actionData = character.GetEnhancedActionData<EnhancedCharacterActionData>();
+        if (actionData != null && actionData.hasValidAction)
+        {
+            // Show current action
+            ShowInstructionMessage($"Current action: {actionData.GetActionDescription()}");
+        }
+        else
+        {
+            // Clear instructions if no action set
+            currentInstruction = "";
+            instructionTimer = 0f;
+            Debug.Log($"📢 No action set for {character.CharacterName} - instructions cleared");
+        }
+    }
+
+    /// <summary>
+    /// Called by PlayerDecisionController when targeting is complete
+    /// </summary>
+    public void OnTargetingComplete(Character character)
+    {
+        Debug.Log($"✅ Targeting complete for {character.CharacterName}");
+
+        // Update lastSelectedCharacter so action wheel knows which character was last used
+        lastSelectedCharacter = character;
+
+        // Update all character visual states to reflect the completed action
+        UpdateAllCharacterVisualStates();
+
+        // Show instruction that action is set
+        var actionData = character.GetEnhancedActionData<EnhancedCharacterActionData>();
+        if (actionData != null && actionData.hasValidAction)
+        {
+            ShowInstructionMessage($"Action set: {actionData.GetActionDescription()}");
+        }
+    }
 }

+ 94 - 5
Assets/Scripts/BattleScene/BattleActionSystem.cs

@@ -558,17 +558,106 @@ public class BattleActionSystem : MonoBehaviour
     {
         Debug.Log($"📦 Using item {itemName} on {(target ? target.CharacterName : "self")}");
 
-        // Placeholder item effects
-        if (itemName.ToLower().Contains("heal"))
+        // Try to find and use the actual item from inventory
+        bool itemConsumed = false;
+        var inventory = user.GetComponent<Inventory>();
+
+        if (inventory != null)
+        {
+            // Try to find the item in the inventory
+            var miscItems = inventory.Miscellaneous;
+            foreach (var slot in miscItems)
+            {
+                if (slot.item != null && slot.item.itemName == itemName && slot.quantity > 0)
+                {
+                    if (slot.item is MiscellaneousItem miscItem && miscItem.isConsumable)
+                    {
+                        // Use the item effect
+                        Character effectTarget = target ?? user;
+                        miscItem.UseItem(effectTarget);
+
+                        // Remove one from inventory
+                        inventory.RemoveItem(slot.item, 1);
+                        itemConsumed = true;
+
+                        Debug.Log($"💚 {user.CharacterName} used {itemName} on {effectTarget.CharacterName}");
+                        break;
+                    }
+                }
+            }
+        }
+
+        // If no ScriptableObject item found, try CombatDataTransfer session data
+        if (!itemConsumed && CombatDataTransfer.HasValidSession())
+        {
+            var session = CombatDataTransfer.GetCurrentSession();
+            var playerData = session.playerTeam.Find(p =>
+                p.characterName == user.CharacterName ||
+                user.CharacterName.StartsWith(p.characterName));
+
+            if (playerData != null && playerData.miscItems != null)
+            {
+                // Remove item from session data
+                for (int i = 0; i < playerData.miscItems.Count; i++)
+                {
+                    if (playerData.miscItems[i] == itemName)
+                    {
+                        playerData.miscItems.RemoveAt(i);
+                        itemConsumed = true;
+
+                        // Apply basic effects based on item name
+                        Character effectTarget = target ?? user;
+                        ApplyItemEffectByName(itemName, effectTarget);
+
+                        Debug.Log($"💚 {user.CharacterName} used {itemName} on {effectTarget.CharacterName} (from session data)");
+                        break;
+                    }
+                }
+            }
+        }
+
+        // Fallback - basic effects without consumption
+        if (!itemConsumed)
         {
-            Character healTarget = target ?? user;
-            healTarget.Heal(20); // Heal for 20 HP
-            Debug.Log($"💚 {healTarget.CharacterName} healed for 20 HP");
+            Debug.LogWarning($"📦 Could not find consumable item {itemName} in {user.CharacterName}'s inventory - applying basic effect");
+            Character effectTarget = target ?? user;
+            ApplyItemEffectByName(itemName, effectTarget);
         }
 
         yield return null;
     }
 
+    /// <summary>
+    /// Apply item effects based on item name (fallback method)
+    /// </summary>
+    private void ApplyItemEffectByName(string itemName, Character target)
+    {
+        string lowerName = itemName.ToLower();
+
+        if (lowerName.Contains("heal") || lowerName.Contains("potion"))
+        {
+            target.Heal(20); // Standard healing amount
+            Debug.Log($"💚 {target.CharacterName} healed for 20 HP from {itemName}");
+        }
+        else if (lowerName.Contains("antidote"))
+        {
+            // Could add poison removal here if implemented
+            target.Heal(5); // Minor healing from antidote
+            Debug.Log($"💚 {target.CharacterName} recovered from {itemName}");
+        }
+        else if (lowerName.Contains("bread") || lowerName.Contains("food"))
+        {
+            target.Heal(10); // Minor healing from food
+            Debug.Log($"💚 {target.CharacterName} recovered 10 HP from {itemName}");
+        }
+        else
+        {
+            // Generic beneficial effect
+            target.Heal(15);
+            Debug.Log($"💚 {target.CharacterName} gained 15 HP from {itemName}");
+        }
+    }
+
     private IEnumerator CastSpell(Character caster, string spellName, Character target, Vector3 targetPosition)
     {
         Debug.Log($"🔮 Casting {spellName} from {caster.CharacterName}");

+ 1 - 1
Assets/Scripts/BattleScene/EnhancedBattleSetup.cs

@@ -121,7 +121,7 @@ public class EnhancedBattleSetup : MonoBehaviour
             string timeDesc = GetTimeDescription(session.timeOfDay);
             string weatherDesc = session.weather.ToString().ToLower();
 
-            string contextDescription = $"Battle {terrainDesc}\\n{timeDesc.ToUpper()} - {weatherDesc} weather";
+            string contextDescription = $"Battle {terrainDesc}\n{timeDesc.ToUpper()} - {weatherDesc} weather";
             battleContextText.text = contextDescription;
 
             if (showDebugLogs)

+ 158 - 10
Assets/Scripts/BattleScene/GameManager.cs

@@ -6,6 +6,7 @@ using Unity.VisualScripting;
 using UnityEngine;
 using UnityEngine.AI;
 using UnityEngine.Rendering.UI;
+using UnityEngine.UIElements;
 
 public class GameManager : MonoBehaviour
 {
@@ -235,19 +236,46 @@ public class GameManager : MonoBehaviour
     {
         Debug.Log("🏆 Players have won the battle!");
 
-        // Find or create the post-battle loot system
-        var lootSystem = FindFirstObjectByType<PostBattleLootSystem>();
-        if (lootSystem == null)
+        // Check if there are actually any enemies to loot
+        bool hasLootableEnemies = false;
+        if (defeatedEnemies != null && defeatedEnemies.Count > 0)
         {
-            // Create loot system if it doesn't exist
-            GameObject lootSystemGO = new GameObject("PostBattleLootSystem");
-            lootSystem = lootSystemGO.AddComponent<PostBattleLootSystem>();
+            foreach (var enemy in defeatedEnemies)
+            {
+                if (enemy != null)
+                {
+                    var character = enemy.GetComponent<Character>();
+                    if (character != null && character.IsDead)
+                    {
+                        hasLootableEnemies = true;
+                        break;
+                    }
+                }
+            }
         }
 
-        // Initialize and start looting
-        lootSystem.InitializeLootSystem(defeatedEnemies);
-        lootSystem.OnLootingComplete += OnLootingComplete;
-        lootSystem.StartLooting();
+        if (hasLootableEnemies)
+        {
+            // Find or create the post-battle loot system
+            var lootSystem = FindFirstObjectByType<PostBattleLootSystem>();
+            if (lootSystem == null)
+            {
+                // Create loot system if it doesn't exist
+                GameObject lootSystemGO = new GameObject("PostBattleLootSystem");
+                lootSystem = lootSystemGO.AddComponent<PostBattleLootSystem>();
+            }
+
+            // Initialize and start looting
+            lootSystem.InitializeLootSystem(defeatedEnemies);
+            lootSystem.OnLootingComplete += OnLootingComplete;
+            lootSystem.StartLooting();
+        }
+        else
+        {
+            // No loot to collect, show victory screen with return button
+            Debug.Log("🏆 No loot to collect, showing victory screen");
+            StartCoroutine(ShowVictoryScreenAndReturn());
+        }
     }
 
     /// <summary>
@@ -270,6 +298,126 @@ public class GameManager : MonoBehaviour
         gameOverScreen.ShowGameOver(defeatedPlayers);
     }
 
+    /// <summary>
+    /// Show a simple victory screen when there's no loot and allow return to map
+    /// </summary>
+    private System.Collections.IEnumerator ShowVictoryScreenAndReturn()
+    {
+        // Create a simple victory overlay using UI Toolkit or IMGUI
+        GameObject victoryUIGO = new GameObject("VictoryUI");
+        var uiDocument = victoryUIGO.AddComponent<UIDocument>();
+
+        // Create basic victory UI
+        var rootElement = uiDocument.rootVisualElement;
+
+        // Create overlay
+        var overlay = new VisualElement();
+        overlay.style.position = Position.Absolute;
+        overlay.style.top = 0;
+        overlay.style.left = 0;
+        overlay.style.right = 0;
+        overlay.style.bottom = 0;
+        overlay.style.backgroundColor = new Color(0, 0, 0, 0.8f);
+        overlay.style.justifyContent = Justify.Center;
+        overlay.style.alignItems = Align.Center;
+
+        // Create victory panel
+        var panel = new VisualElement();
+        panel.style.backgroundColor = new Color(0.1f, 0.3f, 0.1f, 0.95f);
+        panel.style.borderTopWidth = 3;
+        panel.style.borderBottomWidth = 3;
+        panel.style.borderLeftWidth = 3;
+        panel.style.borderRightWidth = 3;
+        panel.style.borderTopColor = Color.yellow;
+        panel.style.borderBottomColor = Color.yellow;
+        panel.style.borderLeftColor = Color.yellow;
+        panel.style.borderRightColor = Color.yellow;
+        panel.style.borderTopLeftRadius = 15;
+        panel.style.borderTopRightRadius = 15;
+        panel.style.borderBottomLeftRadius = 15;
+        panel.style.borderBottomRightRadius = 15;
+        panel.style.paddingTop = 40;
+        panel.style.paddingBottom = 40;
+        panel.style.paddingLeft = 60;
+        panel.style.paddingRight = 60;
+        panel.style.width = 500;
+
+        // Victory title
+        var title = new Label("🏆 VICTORY! 🏆");
+        title.style.fontSize = 36;
+        title.style.color = Color.yellow;
+        title.style.unityTextAlign = TextAnchor.MiddleCenter;
+        title.style.marginBottom = 20;
+        title.style.unityFontStyleAndWeight = FontStyle.Bold;
+
+        // Victory message
+        var message = new Label("The enemies have been defeated!\nThe battle is won!");
+        message.style.fontSize = 18;
+        message.style.color = Color.white;
+        message.style.unityTextAlign = TextAnchor.MiddleCenter;
+        message.style.marginBottom = 30;
+        message.style.whiteSpace = WhiteSpace.Normal;
+
+        // Return button
+        var returnButton = new Button(() =>
+        {
+            // Destroy the victory UI
+            if (victoryUIGO != null) Destroy(victoryUIGO);
+
+            // Proceed to return to exploration
+            OnLootingComplete();
+        });
+        returnButton.text = "Return to Map";
+        returnButton.style.fontSize = 18;
+        returnButton.style.paddingTop = 15;
+        returnButton.style.paddingBottom = 15;
+        returnButton.style.paddingLeft = 30;
+        returnButton.style.paddingRight = 30;
+        returnButton.style.backgroundColor = new Color(0.2f, 0.7f, 0.2f, 0.9f);
+        returnButton.style.color = Color.white;
+        returnButton.style.borderTopLeftRadius = 8;
+        returnButton.style.borderTopRightRadius = 8;
+        returnButton.style.borderBottomLeftRadius = 8;
+        returnButton.style.borderBottomRightRadius = 8;
+
+        // Space key hint
+        var hint = new Label("Press SPACE or click the button to continue");
+        hint.style.fontSize = 14;
+        hint.style.color = Color.gray;
+        hint.style.unityTextAlign = TextAnchor.MiddleCenter;
+        hint.style.marginTop = 15;
+
+        // Assemble UI
+        panel.Add(title);
+        panel.Add(message);
+        panel.Add(returnButton);
+        panel.Add(hint);
+        overlay.Add(panel);
+        rootElement.Add(overlay);
+
+        // Make the UI focusable for keyboard input
+        rootElement.focusable = true;
+        rootElement.Focus();
+
+        // Handle keyboard input
+        bool waitingForInput = true;
+        rootElement.RegisterCallback<KeyDownEvent>((evt) =>
+        {
+            if (evt.keyCode == KeyCode.Space && waitingForInput)
+            {
+                waitingForInput = false;
+                if (victoryUIGO != null) Destroy(victoryUIGO);
+                OnLootingComplete();
+            }
+        });
+
+        // Wait for user input (this coroutine will be stopped when the button is clicked or space is pressed)
+        while (waitingForInput && victoryUIGO != null)
+        {
+            yield return null;
+        }
+    }
+
     /// <summary>
     /// Called when looting is complete, proceed to end battle
     /// </summary>

+ 149 - 27
Assets/Scripts/BattleScene/PlayerDecisionController .cs

@@ -5,18 +5,20 @@ using UnityEngine;
 public class PlayerDecisionController : MonoBehaviour
 {
     [Header("References")]
-    public LayerMask enemyLayerMask = 1 << 10; // Enemies are on layer 10
-    public LayerMask playerLayerMask = 1 << 9; // Players are on layer 9
+    public LayerMask enemyLayerMask = 1 << 10; // Enemy layer
+    public LayerMask playerLayerMask = 1 << 9; // Player layer
+
+    [Header("State")]
+    private Character selectedCharacter;
+    private bool isDragging = false;
+    private Vector3 dragStartPosition;
 
     [Header("Settings")]
     public float enemySnapDistance = 1f;
 
     private List<Character> playerCharacters = new List<Character>();
-    private Character selectedCharacter;
     private TargetingLine targetingLine;
     private Camera mainCamera;
-    private bool isDragging = false;
-    private Vector3 dragStartPosition;
     private bool isEnabled = true;
     private List<TargetingLine> activeActionLines = new List<TargetingLine>();
 
@@ -94,28 +96,53 @@ public class PlayerDecisionController : MonoBehaviour
         }
     }
 
+    /// <summary>
+    /// Check if we're currently in move targeting mode (move action selected but not yet targeted)
+    /// </summary>
+    private bool IsInMoveTargetingMode()
+    {
+        if (selectedCharacter == null) return false;
+        
+        var actionData = selectedCharacter.GetEnhancedActionData<EnhancedCharacterActionData>();
+        return actionData != null && 
+               actionData.actionType == BattleActionType.Move && 
+               actionData.state == ActionDecisionState.NoAction;
+    }
+
     private void HandleLeftClickDown()
     {
         Vector3 mouseWorldPosition = GetMouseWorldPosition();
         Character clickedCharacter = GetPlayerCharacterAtPosition(mouseWorldPosition);
 
-
-
         if (clickedCharacter != null)
         {
+            // Start drag mode from character - this allows both move and attack by dragging
             selectedCharacter = clickedCharacter;
             isDragging = true;
             dragStartPosition = clickedCharacter.transform.position;
+            
+            Debug.Log($"🖱️ Starting drag from character {clickedCharacter.CharacterName}");
 
             // Clear any existing action lines before starting new targeting
             ClearActionLineForCharacter(clickedCharacter);
 
+            // Start targeting line for drag operations
             targetingLine.StartTargeting(dragStartPosition);
 
-
             // CinemachineCameraController.Instance.FocusOnCharacter(clickedCharacter.transform);
         }
+        else
+        {
+            // Clicked empty space - start drag if we have a selected character and are in move mode
+            if (selectedCharacter != null && IsInMoveTargetingMode())
+            {
+                isDragging = true;
+                targetingLine.StartTargeting(selectedCharacter.transform.position);
+                Debug.Log($"🎯 Started move targeting for {selectedCharacter.CharacterName}");
+            }
+        }
     }
+
     private void HandleLeftDrag()
     {
         if (selectedCharacter == null) return;
@@ -139,30 +166,77 @@ public class PlayerDecisionController : MonoBehaviour
 
     private void HandleLeftClickUp()
     {
-        if (!isDragging || selectedCharacter == null) return;
-
         Vector3 mouseWorldPos = GetMouseWorldPosition();
         GameObject enemyAtMouse = GetEnemyAtPosition(mouseWorldPos);
-
-        if (enemyAtMouse != null)
+        
+        // Handle different cases based on current state
+        if (isDragging && selectedCharacter != null)
         {
-            // Set attack target
-            selectedCharacter.actionData.SetAttackTarget(enemyAtMouse);
+            // We're in active targeting mode
+            if (enemyAtMouse != null)
+            {
+                // Attack target selected
+                selectedCharacter.actionData.SetAttackTarget(enemyAtMouse);
+                UpdateEnhancedActionData(selectedCharacter, BattleActionType.Attack, enemyAtMouse, mouseWorldPos);
+                selectedCharacter.SetVisualState(selectedCharacter.actionData.state);
+                Debug.Log($"⚔️ Attack target set for {selectedCharacter.CharacterName}");
+            }
+ else
+            {
+                // Check if user actually dragged (minimum distance threshold) OR if we're in action wheel move mode
+                float dragDistance = Vector3.Distance(dragStartPosition, mouseWorldPos);
+                const float minDragDistance = 0.5f; // Minimum distance to consider it a drag vs click
+                
+                bool isActionWheelMove = IsInMoveTargetingMode();
+                bool isDragMove = dragDistance > minDragDistance;
+                
+                if (isActionWheelMove || isDragMove)
+                {
+                    // Move target selected
+                    selectedCharacter.actionData.SetMoveTarget(mouseWorldPos);
+                    UpdateEnhancedActionData(selectedCharacter, BattleActionType.Move, null, mouseWorldPos);
+                    selectedCharacter.SetVisualState(selectedCharacter.actionData.state);
+                    
+                    if (isActionWheelMove)
+                    {
+                        Debug.Log($"👟 Move target set for {selectedCharacter.CharacterName} (action wheel mode)");
+                    }
+                    else
+                    {
+                        Debug.Log($"👟 Move target set for {selectedCharacter.CharacterName} (dragged {dragDistance:F1} units)");
+                    }
+                }
+                else
+                {
+                    // User just clicked on character without dragging - don't set any action
+                    Debug.Log($"🖱️ Character {selectedCharacter.CharacterName} selected (clicked without dragging)");
+                }
+            }
+
+            // Notify BattleActionIntegration that targeting is complete
+            var integration = FindFirstObjectByType<BattleActionIntegration>();
+            if (integration != null)
+            {
+                integration.OnTargetingComplete(selectedCharacter);
+            }
 
-            // Also update enhanced action data if it exists
-            UpdateEnhancedActionData(selectedCharacter, BattleActionType.Attack, enemyAtMouse, mouseWorldPos);
+            // Cleanup targeting
+            targetingLine.StopTargeting();
+            isDragging = false;
+            selectedCharacter = null; // Clear selection after action is set
         }
-        else
+        else if (selectedCharacter != null)
         {
-            // Set move target
-            selectedCharacter.actionData.SetMoveTarget(mouseWorldPos);
-
-            // Also update enhanced action data if it exists
-            UpdateEnhancedActionData(selectedCharacter, BattleActionType.Move, null, mouseWorldPos);
+            // Just a character selection click - notify integration but don't set actions
+            var integration = FindFirstObjectByType<BattleActionIntegration>();
+            if (integration != null)
+            {
+                integration.OnTargetingComplete(selectedCharacter);
+            }
+            Debug.Log($"👆 Character {selectedCharacter.CharacterName} selected (no action set)");
+            // Don't clear selectedCharacter here - let integration handle it
         }
 
-        selectedCharacter.SetVisualState(selectedCharacter.actionData.state);
-
         // Cleanup
         targetingLine.StopTargeting();
         selectedCharacter = null;
@@ -203,6 +277,7 @@ public class PlayerDecisionController : MonoBehaviour
         // Raycast against a ground plane or existing colliders
         if (Physics.Raycast(ray, out hit, 200f))
         {
+            Debug.Log($"🌍 Mouse world position: {hit.point} (hit: {hit.collider.gameObject.name})");
             return hit.point;
         }
 
@@ -210,9 +285,12 @@ public class PlayerDecisionController : MonoBehaviour
         Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
         if (groundPlane.Raycast(ray, out float distance))
         {
-            return ray.GetPoint(distance);
+            Vector3 position = ray.GetPoint(distance);
+            Debug.Log($"🌍 Mouse world position (fallback plane): {position}");
+            return position;
         }
 
+        Debug.Log($"❌ Could not determine mouse world position");
         return Vector3.zero;
     }
 
@@ -249,8 +327,20 @@ public class PlayerDecisionController : MonoBehaviour
 
         if (Physics.Raycast(ray, out hit, 200f, enemyLayerMask))
         {
+            Debug.Log($"🎯 Enemy detected: {hit.collider.gameObject.name} on layer {hit.collider.gameObject.layer}");
             return hit.collider.gameObject;
         }
+        
+        // Debug: Check what we're hitting without layer mask
+        if (Physics.Raycast(ray, out hit, 200f))
+        {
+            Debug.Log($"🔍 Hit object: {hit.collider.gameObject.name} on layer {hit.collider.gameObject.layer} (not enemy layer)");
+        }
+        else
+        {
+            Debug.Log($"❌ No raycast hit detected at mouse position");
+        }
+        
         return null;
     }
 
@@ -314,6 +404,35 @@ public class PlayerDecisionController : MonoBehaviour
 
     }
 
+    /// <summary>
+    /// Check if PlayerDecisionController is currently in targeting/dragging mode
+    /// </summary>
+    public bool IsInTargetingMode => isDragging && selectedCharacter != null;
+
+    /// <summary>
+    /// Get the currently selected character (for action wheel integration)
+    /// </summary>
+    public Character GetSelectedCharacter() => selectedCharacter;
+
+    /// <summary>
+    /// Reset the controller state (for debugging/recovery)
+    /// </summary>
+    public void ResetState()
+    {
+        Debug.Log("🔄 PlayerDecisionController: Resetting state");
+
+        if (isDragging && targetingLine != null)
+        {
+            targetingLine.StopTargeting();
+        }
+
+        selectedCharacter = null;
+        isDragging = false;
+        isEnabled = true;
+
+        Debug.Log("✅ PlayerDecisionController: State reset complete");
+    }
+
     public void ShowActiveActionLines()
     {
         HideActiveActionLines(); // Clear any existing lines first
@@ -415,7 +534,6 @@ public class PlayerDecisionController : MonoBehaviour
         Debug.Log($"🎯 StartTargetingForCharacter called: {character.CharacterName} -> {actionType}");
 
         selectedCharacter = character;
-        isDragging = true;
         dragStartPosition = character.transform.position;
 
         // Store the action type for later reference
@@ -426,14 +544,18 @@ public class PlayerDecisionController : MonoBehaviour
             character.SetEnhancedActionData(enhancedData);
         }
         enhancedData.actionType = actionType;
+        enhancedData.state = ActionDecisionState.NoAction; // Waiting for target
 
+        // Start targeting mode - user needs to click to set target
+        isDragging = true;
+        
         // Clear any existing action lines before starting new targeting
         ClearActionLineForCharacter(character);
 
         // Start the targeting line
         targetingLine.StartTargeting(dragStartPosition);
 
-        Debug.Log($"✅ Targeting mode activated for {character.CharacterName}");
+        Debug.Log($"✅ Targeting mode active for {character.CharacterName} - {actionType}");
     }
 
     /// <summary>

+ 587 - 15
Assets/Scripts/BattleScene/PostBattleLootSystem.cs

@@ -25,6 +25,10 @@ public class PostBattleLootSystem : MonoBehaviour
     [Header("Debug Settings")]
     public bool showDebugLogs = true;
 
+    [Header("Item Distribution Settings")]
+    public bool enablePlayerItemSelection = true; // Allow manual item distribution
+    public bool autoDistributeItems = false; // If true, items are distributed automatically
+
     // Events
     public event System.Action OnLootingComplete;
 
@@ -32,6 +36,7 @@ public class PostBattleLootSystem : MonoBehaviour
     private bool isLootingActive = false;
     private VisualElement rootElement;
     private bool takeAllPressed = false;
+    private Dictionary<string, int> selectedPlayerForItem = new Dictionary<string, int>(); // itemName -> playerIndex
 
     /// <summary>
     /// Gets whether the looting process is currently active
@@ -320,22 +325,30 @@ public class PostBattleLootSystem : MonoBehaviour
             takeAllButton.clicked += () =>
             {
                 takeAllPressed = true;
+
+                // Force auto-distribution and skip player selection
+                bool originalAutoDistribute = autoDistributeItems;
+                autoDistributeItems = true; // Temporarily force auto-distribution
+
                 AutoLootAll();
-                CompleteLootingProcess();
+
+                // Restore original setting
+                autoDistributeItems = originalAutoDistribute;
             };
         }
 
-        // Set up Continue button
+        // Set up Continue button - this should return to map
         var continueButton = rootElement.Q<Button>("ContinueButton");
         if (continueButton != null)
         {
+            continueButton.text = "Return to Map"; // Make it clear what this button does
             continueButton.clicked += () =>
             {
                 if (!takeAllPressed)
                 {
                     AutoLootAll(); // Auto-loot if not already done
                 }
-                CompleteLootingProcess();
+                // CompleteLootingProcess is called by AutoLootAll, so scene transition will happen
             };
         }
 
@@ -356,9 +369,17 @@ public class PostBattleLootSystem : MonoBehaviour
         {
             if (!takeAllPressed)
             {
+                takeAllPressed = true;
+
+                // Force auto-distribution and skip player selection
+                bool originalAutoDistribute = autoDistributeItems;
+                autoDistributeItems = true; // Temporarily force auto-distribution
+
                 AutoLootAll();
+
+                // Restore original setting
+                autoDistributeItems = originalAutoDistribute;
             }
-            CompleteLootingProcess();
         }
     }
 
@@ -481,6 +502,10 @@ public class PostBattleLootSystem : MonoBehaviour
     {
         isLootingActive = false;
 
+        // Hide the loot UI
+        if (rootElement != null)
+            rootElement.style.display = DisplayStyle.None;
+
         if (showDebugLogs)
             Debug.Log("💰 Looting completed, triggering OnLootingComplete");
 
@@ -612,14 +637,68 @@ public class PostBattleLootSystem : MonoBehaviour
             allItems.AddRange(enemy.dropItems);
         }
 
-        // Update currency displays
+        // Update currency displays with better formatting and tighter spacing
         var goldLabel = rootElement.Q<Label>("GoldAmount");
         var silverLabel = rootElement.Q<Label>("SilverAmount");
         var copperLabel = rootElement.Q<Label>("CopperAmount");
 
-        if (goldLabel != null) goldLabel.text = totalGold.ToString();
-        if (silverLabel != null) silverLabel.text = totalSilver.ToString();
-        if (copperLabel != null) copperLabel.text = totalCopper.ToString();
+        if (goldLabel != null)
+        {
+            goldLabel.text = totalGold.ToString();
+            goldLabel.style.fontSize = 18; // Slightly larger than before but not huge
+            goldLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
+            goldLabel.style.marginBottom = 2; // Reduce spacing
+            goldLabel.style.marginTop = 2;
+        }
+        if (silverLabel != null)
+        {
+            silverLabel.text = totalSilver.ToString();
+            silverLabel.style.fontSize = 18;
+            silverLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
+            silverLabel.style.marginBottom = 2;
+            silverLabel.style.marginTop = 2;
+        }
+        if (copperLabel != null)
+        {
+            copperLabel.text = totalCopper.ToString();
+            copperLabel.style.fontSize = 18;
+            copperLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
+            copperLabel.style.marginBottom = 2;
+            copperLabel.style.marginTop = 2;
+        }
+
+        // Style the currency text labels to be closer to the numbers
+        var goldText = rootElement.Q<Label>("GoldText");
+        var silverText = rootElement.Q<Label>("SilverText");
+        var copperText = rootElement.Q<Label>("CopperText");
+
+        if (goldText != null)
+        {
+            goldText.style.fontSize = 12;
+            goldText.style.marginTop = -2; // Move closer to number
+            goldText.style.marginBottom = 8; // Add space after currency section
+        }
+        if (silverText != null)
+        {
+            silverText.style.fontSize = 12;
+            silverText.style.marginTop = -2;
+            silverText.style.marginBottom = 8;
+        }
+        if (copperText != null)
+        {
+            copperText.style.fontSize = 12;
+            copperText.style.marginTop = -2;
+            copperText.style.marginBottom = 8;
+        }
+
+        // Also style the currency icons to be smaller
+        var goldIcon = rootElement.Q<Label>("GoldIcon");
+        var silverIcon = rootElement.Q<Label>("SilverIcon");
+        var copperIcon = rootElement.Q<Label>("CopperIcon");
+
+        if (goldIcon != null) goldIcon.style.fontSize = 14;
+        if (silverIcon != null) silverIcon.style.fontSize = 14;
+        if (copperIcon != null) copperIcon.style.fontSize = 14;
 
         // Update item count
         var itemCountLabel = rootElement.Q<Label>("ItemCount");
@@ -691,10 +770,121 @@ public class PostBattleLootSystem : MonoBehaviour
                 enemyLootContainer.Add(enemySection);
             }
         }
+
+        // Populate the total items list scrollview with better visibility
+        var itemsListContainer = rootElement.Q<ScrollView>("ItemsList");
+        if (itemsListContainer != null)
+        {
+            itemsListContainer.Clear();
+
+            // Set scrollview properties for better visibility and containment
+            itemsListContainer.style.minHeight = 80;
+            itemsListContainer.style.maxHeight = 150;
+            itemsListContainer.style.backgroundColor = new Color(0.15f, 0.15f, 0.25f, 0.9f);
+            itemsListContainer.style.borderTopWidth = 2;
+            itemsListContainer.style.borderBottomWidth = 2;
+            itemsListContainer.style.borderLeftWidth = 2;
+            itemsListContainer.style.borderRightWidth = 2;
+            itemsListContainer.style.borderTopColor = new Color(0.6f, 0.6f, 0.8f, 0.8f);
+            itemsListContainer.style.borderBottomColor = new Color(0.6f, 0.6f, 0.8f, 0.8f);
+            itemsListContainer.style.borderLeftColor = new Color(0.6f, 0.6f, 0.8f, 0.8f);
+            itemsListContainer.style.borderRightColor = new Color(0.6f, 0.6f, 0.8f, 0.8f);
+            itemsListContainer.style.borderTopLeftRadius = 8;
+            itemsListContainer.style.borderTopRightRadius = 8;
+            itemsListContainer.style.borderBottomLeftRadius = 8;
+            itemsListContainer.style.borderBottomRightRadius = 8;
+            itemsListContainer.style.paddingTop = 8;
+            itemsListContainer.style.paddingBottom = 8;
+            itemsListContainer.style.paddingLeft = 8;
+            itemsListContainer.style.paddingRight = 8;
+            itemsListContainer.style.marginTop = 5;
+            itemsListContainer.style.marginBottom = 10;
+            itemsListContainer.style.marginLeft = 5;
+            itemsListContainer.style.marginRight = 5;
+
+            if (allItems.Count > 0)
+            {
+                foreach (var item in allItems)
+                {
+                    var itemEntry = new Label($"📦 {item}");
+                    itemEntry.AddToClassList("total-item-entry");
+                    itemEntry.style.fontSize = 14;
+                    itemEntry.style.color = Color.white;
+                    itemEntry.style.marginBottom = 2;
+                    itemEntry.style.paddingLeft = 6;
+                    itemEntry.style.paddingRight = 6;
+                    itemEntry.style.paddingTop = 3;
+                    itemEntry.style.paddingBottom = 3;
+                    itemEntry.style.backgroundColor = new Color(0.25f, 0.35f, 0.45f, 0.8f);
+                    itemEntry.style.borderTopLeftRadius = 4;
+                    itemEntry.style.borderTopRightRadius = 4;
+                    itemEntry.style.borderBottomLeftRadius = 4;
+                    itemEntry.style.borderBottomRightRadius = 4;
+                    itemEntry.style.borderTopWidth = 1;
+                    itemEntry.style.borderBottomWidth = 1;
+                    itemEntry.style.borderLeftWidth = 1;
+                    itemEntry.style.borderRightWidth = 1;
+                    itemEntry.style.borderTopColor = new Color(0.7f, 0.7f, 0.9f, 0.6f);
+                    itemEntry.style.borderBottomColor = new Color(0.7f, 0.7f, 0.9f, 0.6f);
+                    itemEntry.style.borderLeftColor = new Color(0.7f, 0.7f, 0.9f, 0.6f);
+                    itemEntry.style.borderRightColor = new Color(0.7f, 0.7f, 0.9f, 0.6f);
+
+                    itemsListContainer.Add(itemEntry);
+                }
+            }
+            else
+            {
+                var noItemsLabel = new Label("No items collected");
+                noItemsLabel.style.fontSize = 14;
+                noItemsLabel.style.color = new Color(0.7f, 0.7f, 0.7f, 1f);
+                noItemsLabel.style.unityTextAlign = TextAnchor.MiddleCenter;
+                noItemsLabel.style.paddingTop = 20;
+                itemsListContainer.Add(noItemsLabel);
+            }
+        }
+
+        // Add informational message about item distribution
+        if (allItems.Count > 0)
+        {
+            var distributionHint = rootElement.Q<Label>("DistributionHint");
+            if (distributionHint == null)
+            {
+                distributionHint = new Label();
+                distributionHint.name = "DistributionHint";
+                // Find a good place to add it (after the items section)
+                var itemsSection = rootElement.Q<VisualElement>("ItemsSection");
+                if (itemsSection != null)
+                {
+                    itemsSection.Add(distributionHint);
+                }
+                else
+                {
+                    rootElement.Add(distributionHint);
+                }
+            }
+
+            if (enablePlayerItemSelection && !takeAllPressed)
+            {
+                distributionHint.text = "💡 Click individual items above to choose which character gets them, or use 'Take All' for automatic distribution.";
+            }
+            else
+            {
+                distributionHint.text = "📋 Items will be distributed automatically among surviving party members.";
+            }
+
+            distributionHint.style.fontSize = 12;
+            distributionHint.style.color = new Color(0.8f, 0.8f, 0.9f, 0.9f);
+            distributionHint.style.unityTextAlign = TextAnchor.MiddleCenter;
+            distributionHint.style.marginTop = 10;
+            distributionHint.style.marginBottom = 5;
+            distributionHint.style.paddingLeft = 10;
+            distributionHint.style.paddingRight = 10;
+            distributionHint.style.whiteSpace = WhiteSpace.Normal;
+        }
     }
 
     /// <summary>
-    /// Auto-loot all items and currency (temporary solution)
+    /// Auto-loot all items and currency with optional player selection
     /// </summary>
     private void AutoLootAll()
     {
@@ -713,16 +903,31 @@ public class PostBattleLootSystem : MonoBehaviour
             }
         }
 
-        // Distribute rewards to players
-        DistributeRewards(totalGold, totalSilver, totalCopper, allItems);
+        // Always distribute currency automatically
+        DistributeCurrency(totalGold, totalSilver, totalCopper);
 
-        if (showDebugLogs)
+        // Handle item distribution based on settings
+        // Show item distribution UI if:
+        // 1. Player item selection is enabled
+        // 2. There are items to distribute
+        // 3. We're NOT in "Take All" mode (which forces auto-distribution)
+        if (enablePlayerItemSelection && allItems.Count > 0 && !takeAllPressed)
         {
-            Debug.Log($"💰 Auto-looted: {totalGold}g {totalSilver}s {totalCopper}c and {allItems.Count} items");
+            ShowItemDistributionUI(allItems);
         }
+        else
+        {
+            // Auto-distribute items
+            DistributeItemsAutomatically(allItems);
 
-        // End looting phase
-        FinishLooting();
+            if (showDebugLogs)
+            {
+                Debug.Log($"💰 Auto-looted: {totalGold}g {totalSilver}s {totalCopper}c and {allItems.Count} items");
+            }
+
+            // End looting phase
+            FinishLooting();
+        }
     }
 
     /// <summary>
@@ -786,6 +991,373 @@ public class PostBattleLootSystem : MonoBehaviour
         }
     }
 
+    /// <summary>
+    /// Distribute currency to players (separated from items for flexibility)
+    /// </summary>
+    private void DistributeCurrency(int gold, int silver, int copper)
+    {
+        var survivingPlayers = GetSurvivingPlayers();
+        if (survivingPlayers.Count == 0)
+        {
+            Debug.LogWarning("💰 No surviving players to distribute currency to!");
+            return;
+        }
+
+        // Distribute currency evenly
+        int goldPerPlayer = gold / survivingPlayers.Count;
+        int silverPerPlayer = silver / survivingPlayers.Count;
+        int copperPerPlayer = copper / survivingPlayers.Count;
+
+        // Handle remainder
+        int goldRemainder = gold % survivingPlayers.Count;
+        int silverRemainder = silver % survivingPlayers.Count;
+        int copperRemainder = copper % survivingPlayers.Count;
+
+        for (int i = 0; i < survivingPlayers.Count; i++)
+        {
+            var player = survivingPlayers[i];
+            Character playerCharacter = player.GetComponent<Character>();
+
+            if (playerCharacter == null) continue;
+
+            // Get player's bank
+            var bank = playerCharacter.GetComponent<Bank>();
+            if (bank != null)
+            {
+                bank.gold += goldPerPlayer + (i < goldRemainder ? 1 : 0);
+                bank.silver += silverPerPlayer + (i < silverRemainder ? 1 : 0);
+                bank.copper += copperPerPlayer + (i < copperRemainder ? 1 : 0);
+
+                if (showDebugLogs)
+                {
+                    int finalGold = goldPerPlayer + (i < goldRemainder ? 1 : 0);
+                    int finalSilver = silverPerPlayer + (i < silverRemainder ? 1 : 0);
+                    int finalCopper = copperPerPlayer + (i < copperRemainder ? 1 : 0);
+                    Debug.Log($"💰 {playerCharacter.CharacterName} received: {finalGold}g {finalSilver}s {finalCopper}c");
+                }
+            }
+        }
+    }
+
+    /// <summary>
+    /// Show UI for manually assigning items to players
+    /// </summary>
+    private void ShowItemDistributionUI(List<string> items)
+    {
+        var survivingPlayers = GetSurvivingPlayers();
+        if (survivingPlayers.Count == 0)
+        {
+            Debug.LogWarning("💰 No surviving players for item distribution!");
+            FinishLooting();
+            return;
+        }
+
+        // For now, create a simple distribution UI overlay
+        var distributionOverlay = new VisualElement();
+        distributionOverlay.name = "ItemDistributionOverlay";
+        distributionOverlay.style.position = Position.Absolute;
+        distributionOverlay.style.top = 0;
+        distributionOverlay.style.left = 0;
+        distributionOverlay.style.right = 0;
+        distributionOverlay.style.bottom = 0;
+        distributionOverlay.style.backgroundColor = new Color(0, 0, 0, 0.8f);
+        distributionOverlay.style.justifyContent = Justify.Center;
+        distributionOverlay.style.alignItems = Align.Center;
+
+        // Create distribution panel
+        var panel = new VisualElement();
+        panel.style.backgroundColor = new Color(0.15f, 0.15f, 0.25f, 0.95f);
+        panel.style.borderTopWidth = 2;
+        panel.style.borderBottomWidth = 2;
+        panel.style.borderLeftWidth = 2;
+        panel.style.borderRightWidth = 2;
+        panel.style.borderTopColor = Color.yellow;
+        panel.style.borderBottomColor = Color.yellow;
+        panel.style.borderLeftColor = Color.yellow;
+        panel.style.borderRightColor = Color.yellow;
+        panel.style.borderTopLeftRadius = 10;
+        panel.style.borderTopRightRadius = 10;
+        panel.style.borderBottomLeftRadius = 10;
+        panel.style.borderBottomRightRadius = 10;
+        panel.style.paddingTop = 20;
+        panel.style.paddingBottom = 20;
+        panel.style.paddingLeft = 20;
+        panel.style.paddingRight = 20;
+        panel.style.width = new Length(90, LengthUnit.Percent);
+        panel.style.maxWidth = 600;
+        panel.style.maxHeight = new Length(80, LengthUnit.Percent);
+
+        // Title
+        var title = new Label("Distribute Items to Players");
+        title.style.fontSize = 24;
+        title.style.color = Color.yellow;
+        title.style.unityTextAlign = TextAnchor.MiddleCenter;
+        title.style.marginBottom = 20;
+        panel.Add(title);
+
+        // Scroll view for items
+        var scrollView = new ScrollView();
+        scrollView.style.flexGrow = 1;
+        scrollView.style.marginBottom = 15;
+
+        // Create item distribution entries
+        foreach (var item in items)
+        {
+            var itemRow = CreateItemDistributionRow(item, survivingPlayers);
+            scrollView.Add(itemRow);
+        }
+
+        panel.Add(scrollView);
+
+        // Buttons
+        var buttonContainer = new VisualElement();
+        buttonContainer.style.flexDirection = FlexDirection.Row;
+        buttonContainer.style.justifyContent = Justify.SpaceAround;
+
+        var autoDistributeBtn = new Button(() =>
+        {
+            DistributeItemsAutomatically(items);
+            rootElement.Remove(distributionOverlay);
+            FinishLooting();
+        });
+        autoDistributeBtn.text = "Auto Distribute";
+        autoDistributeBtn.style.fontSize = 14;
+
+        var confirmBtn = new Button(() =>
+        {
+            DistributeItemsManually(items, survivingPlayers);
+            rootElement.Remove(distributionOverlay);
+            FinishLooting();
+        });
+        confirmBtn.text = "Confirm Distribution";
+        confirmBtn.style.fontSize = 14;
+
+        buttonContainer.Add(autoDistributeBtn);
+        buttonContainer.Add(confirmBtn);
+        panel.Add(buttonContainer);
+
+        distributionOverlay.Add(panel);
+        rootElement.Add(distributionOverlay);
+    }
+
+    /// <summary>
+    /// Create a row for item distribution with player selection buttons
+    /// </summary>
+    private VisualElement CreateItemDistributionRow(string itemName, List<GameObject> players)
+    {
+        var row = new VisualElement();
+        row.style.flexDirection = FlexDirection.Row;
+        row.style.alignItems = Align.Center;
+        row.style.marginBottom = 10;
+        row.style.paddingTop = 8;
+        row.style.paddingBottom = 8;
+        row.style.paddingLeft = 12;
+        row.style.paddingRight = 12;
+        row.style.backgroundColor = new Color(0.2f, 0.2f, 0.3f, 0.9f);
+        row.style.borderTopLeftRadius = 8;
+        row.style.borderTopRightRadius = 8;
+        row.style.borderBottomLeftRadius = 8;
+        row.style.borderBottomRightRadius = 8;
+        row.style.borderTopWidth = 1;
+        row.style.borderBottomWidth = 1;
+        row.style.borderLeftWidth = 1;
+        row.style.borderRightWidth = 1;
+        row.style.borderTopColor = new Color(0.5f, 0.5f, 0.6f, 0.8f);
+        row.style.borderBottomColor = new Color(0.5f, 0.5f, 0.6f, 0.8f);
+        row.style.borderLeftColor = new Color(0.5f, 0.5f, 0.6f, 0.8f);
+        row.style.borderRightColor = new Color(0.5f, 0.5f, 0.6f, 0.8f);
+
+        // Item name with better styling
+        var itemLabel = new Label($"📦 {itemName}");
+        itemLabel.style.fontSize = 15;
+        itemLabel.style.color = Color.white;
+        itemLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
+        itemLabel.style.width = new Length(35, LengthUnit.Percent);
+        itemLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
+        row.Add(itemLabel);
+
+        // "Assign to:" label
+        var assignLabel = new Label("→");
+        assignLabel.style.fontSize = 14;
+        assignLabel.style.color = Color.yellow;
+        assignLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
+        assignLabel.style.width = 20;
+        assignLabel.style.unityTextAlign = TextAnchor.MiddleCenter;
+        row.Add(assignLabel);
+
+        // Player selection buttons
+        var buttonContainer = new VisualElement();
+        buttonContainer.style.flexDirection = FlexDirection.Row;
+        buttonContainer.style.flexGrow = 1;
+        buttonContainer.style.justifyContent = Justify.SpaceAround;
+
+        int selectedPlayerIndex = selectedPlayerForItem.ContainsKey(itemName) ? selectedPlayerForItem[itemName] : -1;
+
+        // Store button references for updating
+        var playerButtons = new List<Button>();
+
+        for (int i = 0; i < players.Count; i++)
+        {
+            var player = players[i];
+            var character = player.GetComponent<Character>();
+            if (character == null) continue;
+
+            int playerIndex = i; // Capture for closure
+            var playerBtn = new Button(() =>
+            {
+                selectedPlayerForItem[itemName] = playerIndex;
+
+                // Update all buttons in this row to show selection
+                UpdatePlayerButtonVisuals(playerButtons, playerIndex);
+
+                Debug.Log($"💰 Assigned {itemName} to {character.CharacterName}");
+            });
+
+            playerBtn.text = character.CharacterName;
+            playerBtn.style.fontSize = 13;
+            playerBtn.style.flexGrow = 1;
+            playerBtn.style.marginLeft = 3;
+            playerBtn.style.marginRight = 3;
+            playerBtn.style.paddingTop = 8;
+            playerBtn.style.paddingBottom = 8;
+            playerBtn.style.paddingLeft = 6;
+            playerBtn.style.paddingRight = 6;
+            playerBtn.style.borderTopLeftRadius = 5;
+            playerBtn.style.borderTopRightRadius = 5;
+            playerBtn.style.borderBottomLeftRadius = 5;
+            playerBtn.style.borderBottomRightRadius = 5;
+            playerBtn.style.borderTopWidth = 2;
+            playerBtn.style.borderBottomWidth = 2;
+            playerBtn.style.borderLeftWidth = 2;
+            playerBtn.style.borderRightWidth = 2;
+
+            // Set initial visual state
+            if (i == selectedPlayerIndex)
+            {
+                // Selected state
+                playerBtn.style.backgroundColor = new Color(0.2f, 0.8f, 0.2f, 0.9f);
+                playerBtn.style.borderTopColor = Color.green;
+                playerBtn.style.borderBottomColor = Color.green;
+                playerBtn.style.borderLeftColor = Color.green;
+                playerBtn.style.borderRightColor = Color.green;
+                playerBtn.style.color = Color.white;
+            }
+            else
+            {
+                // Unselected state
+                playerBtn.style.backgroundColor = new Color(0.3f, 0.3f, 0.4f, 0.8f);
+                playerBtn.style.borderTopColor = new Color(0.6f, 0.6f, 0.7f, 0.8f);
+                playerBtn.style.borderBottomColor = new Color(0.6f, 0.6f, 0.7f, 0.8f);
+                playerBtn.style.borderLeftColor = new Color(0.6f, 0.6f, 0.7f, 0.8f);
+                playerBtn.style.borderRightColor = new Color(0.6f, 0.6f, 0.7f, 0.8f);
+                playerBtn.style.color = new Color(0.9f, 0.9f, 0.9f, 0.9f);
+            }
+
+            playerButtons.Add(playerBtn);
+            buttonContainer.Add(playerBtn);
+        }
+
+        row.Add(buttonContainer);
+        return row;
+    }
+
+    /// <summary>
+    /// Update visual state of player selection buttons
+    /// </summary>
+    private void UpdatePlayerButtonVisuals(List<Button> buttons, int selectedIndex)
+    {
+        for (int i = 0; i < buttons.Count; i++)
+        {
+            var button = buttons[i];
+            if (i == selectedIndex)
+            {
+                // Selected state - green highlight
+                button.style.backgroundColor = new Color(0.2f, 0.8f, 0.2f, 0.9f);
+                button.style.borderTopColor = Color.green;
+                button.style.borderBottomColor = Color.green;
+                button.style.borderLeftColor = Color.green;
+                button.style.borderRightColor = Color.green;
+                button.style.color = Color.white;
+            }
+            else
+            {
+                // Unselected state - neutral gray
+                button.style.backgroundColor = new Color(0.3f, 0.3f, 0.4f, 0.8f);
+                button.style.borderTopColor = new Color(0.6f, 0.6f, 0.7f, 0.8f);
+                button.style.borderBottomColor = new Color(0.6f, 0.6f, 0.7f, 0.8f);
+                button.style.borderLeftColor = new Color(0.6f, 0.6f, 0.7f, 0.8f);
+                button.style.borderRightColor = new Color(0.6f, 0.6f, 0.7f, 0.8f);
+                button.style.color = new Color(0.9f, 0.9f, 0.9f, 0.9f);
+            }
+        }
+    }
+
+    /// <summary>
+    /// Distribute items automatically using round-robin
+    /// </summary>
+    private void DistributeItemsAutomatically(List<string> items)
+    {
+        var survivingPlayers = GetSurvivingPlayers();
+        if (survivingPlayers.Count == 0) return;
+
+        for (int i = 0; i < items.Count; i++)
+        {
+            var player = survivingPlayers[i % survivingPlayers.Count];
+            var character = player.GetComponent<Character>();
+            if (character != null)
+            {
+                AddItemToPlayer(character, items[i]);
+            }
+        }
+
+        if (showDebugLogs)
+        {
+            Debug.Log($"💰 Auto-distributed {items.Count} items among {survivingPlayers.Count} players");
+        }
+    }
+
+    /// <summary>
+    /// Distribute items based on manual player selection
+    /// </summary>
+    private void DistributeItemsManually(List<string> items, List<GameObject> players)
+    {
+        foreach (var item in items)
+        {
+            if (selectedPlayerForItem.ContainsKey(item))
+            {
+                int playerIndex = selectedPlayerForItem[item];
+                if (playerIndex >= 0 && playerIndex < players.Count)
+                {
+                    var character = players[playerIndex].GetComponent<Character>();
+                    if (character != null)
+                    {
+                        AddItemToPlayer(character, item);
+                        if (showDebugLogs)
+                        {
+                            Debug.Log($"💰 Manually distributed {item} to {character.CharacterName}");
+                        }
+                    }
+                }
+            }
+            else
+            {
+                // If no selection was made, give to first player
+                var character = players[0].GetComponent<Character>();
+                if (character != null)
+                {
+                    AddItemToPlayer(character, item);
+                    if (showDebugLogs)
+                    {
+                        Debug.Log($"💰 {item} given to {character.CharacterName} (no selection made)");
+                    }
+                }
+            }
+        }
+
+        // Clear selections for next battle
+        selectedPlayerForItem.Clear();
+    }
+
     /// <summary>
     /// Add an item to a player's inventory
     /// </summary>

+ 16 - 6
Assets/Scripts/BattleScene/SimpleActionWheel.cs

@@ -74,22 +74,32 @@ public class SimpleActionWheel : MonoBehaviour
         DrawCircle(center, wheelRadius + 25, Color.white);
         DrawCircle(center, wheelRadius + 20, new Color(0.2f, 0.2f, 0.2f, 0.9f)); // Inner background
 
-        // Draw title with better contrast
+        // Draw title with better contrast and auto-sizing
         GUI.color = Color.white;
         GUIStyle titleStyle = new GUIStyle(GUI.skin.label);
-        titleStyle.fontSize = 24; // Larger font
+        titleStyle.fontSize = 24; // Starting font size
         titleStyle.alignment = TextAnchor.MiddleCenter;
         titleStyle.normal.textColor = Color.white;
         titleStyle.fontStyle = FontStyle.Bold;
 
-        Rect titleRect = new Rect(center.x - 150, center.y - wheelRadius - 60, 300, 40);
+        string titleText = $"{currentCharacter.CharacterName} - Choose Action";
+        Rect titleRect = new Rect(center.x - 200, center.y - wheelRadius - 60, 400, 40);
+
+        // Auto-size text to fit the available width
+        Vector2 textSize = titleStyle.CalcSize(new GUIContent(titleText));
+        if (textSize.x > titleRect.width)
+        {
+            // Calculate scale factor to fit text
+            float scaleFactor = titleRect.width / textSize.x;
+            titleStyle.fontSize = Mathf.Max(14, Mathf.RoundToInt(titleStyle.fontSize * scaleFactor));
+        }
 
         // Draw background for title text
         GUI.color = new Color(0, 0, 0, 0.8f);
         GUI.Box(titleRect, "");
 
         GUI.color = Color.white;
-        GUI.Label(titleRect, $"{currentCharacter.CharacterName} - Choose Action", titleStyle);
+        GUI.Label(titleRect, titleText, titleStyle);
 
         // Draw action buttons with better spacing
         int actionCount = actionTypes.Length;
@@ -110,14 +120,14 @@ public class SimpleActionWheel : MonoBehaviour
         instructionStyle.normal.textColor = Color.white;
         instructionStyle.fontStyle = FontStyle.Bold;
 
-        Rect instructionRect = new Rect(center.x - 200, center.y + wheelRadius + 40, 400, 25);
+        Rect instructionRect = new Rect(center.x - 250, center.y + wheelRadius + 40, 500, 25);
 
         // Background for instructions
         GUI.color = new Color(0, 0, 0, 0.8f);
         GUI.Box(instructionRect, "");
 
         GUI.color = Color.white;
-        GUI.Label(instructionRect, "Click action or press ESC to cancel", instructionStyle);
+        GUI.Label(instructionRect, "Click action, ESC to cancel, or Q to change action later", instructionStyle);
 
         GUI.color = Color.white;
     }

+ 16 - 0
Assets/Scripts/Town/TownManager.cs

@@ -0,0 +1,16 @@
+using UnityEngine;
+
+public class TownManager : MonoBehaviour
+{
+    // Start is called once before the first execution of Update after the MonoBehaviour is created
+    void Start()
+    {
+        
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+        
+    }
+}

+ 7 - 4
UserSettings/EditorUserSettings.asset

@@ -15,19 +15,22 @@ EditorUserSettings:
       value: 5655020755505a0d5e0a5577457b0a44154f1a7f2a7e70697e284b30e4b2623b
       flags: 0
     RecentlyUsedSceneGuid-2:
-      value: 51020c5550545a0354575e7b47270744174e4b787e2b77687b7e1b37e7e4366d
+      value: 5309060006570d5f0c580e2715270c44144e1c722a7d20612c2d4b37b1b4643a
       flags: 0
     RecentlyUsedSceneGuid-3:
-      value: 5309060006570d5f0c580e2715270c44144e1c722a7d20612c2d4b37b1b4643a
+      value: 5a08575f5207595a0f5d59741173094444164f7d7d2a23317c7a4465bbe1646d
       flags: 0
     RecentlyUsedSceneGuid-4:
-      value: 510500025d560a0c095d092111730d44464f4b78757b72357a701c31b7b16368
+      value: 51020c5550545a0354575e7b47270744174e4b787e2b77687b7e1b37e7e4366d
       flags: 0
     RecentlyUsedSceneGuid-5:
       value: 5a090503000558580f0d557342700844144f4d7c7b7d74692c281e63b0e2623c
       flags: 0
     RecentlyUsedSceneGuid-6:
-      value: 5a08575f5207595a0f5d59741173094444164f7d7d2a23317c7a4465bbe1646d
+      value: 510500025d560a0c095d092111730d44464f4b78757b72357a701c31b7b16368
+      flags: 0
+    RecentlyUsedSceneGuid-7:
+      value: 54030700010708095d0d5b7643260c44464f1e29797022342c2a1b67b1b03760
       flags: 0
     vcSharedLogLevel:
       value: 0d5e400f0650

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

@@ -74,7 +74,7 @@ MonoBehaviour:
   m_MinSize: {x: 200, y: 50}
   m_MaxSize: {x: 16192, y: 8096}
   vertical: 0
-  controlID: 126
+  controlID: 130
   draggingID: 0
 --- !u!114 &4
 MonoBehaviour:
@@ -198,7 +198,7 @@ MonoBehaviour:
   m_MinSize: {x: 400, y: 100}
   m_MaxSize: {x: 32384, y: 16192}
   vertical: 0
-  controlID: 162
+  controlID: 166
   draggingID: 0
 --- !u!114 &9
 MonoBehaviour:
@@ -224,7 +224,7 @@ MonoBehaviour:
   m_MinSize: {x: 300, y: 100}
   m_MaxSize: {x: 24288, y: 16192}
   vertical: 1
-  controlID: 48
+  controlID: 50
   draggingID: 0
 --- !u!114 &10
 MonoBehaviour:
@@ -251,7 +251,7 @@ MonoBehaviour:
   m_MinSize: {x: 300, y: 50}
   m_MaxSize: {x: 24288, y: 8096}
   vertical: 0
-  controlID: 49
+  controlID: 51
   draggingID: 0
 --- !u!114 &11
 MonoBehaviour:
@@ -534,7 +534,7 @@ MonoBehaviour:
     m_OverlaysVisible: 1
   m_LockTracker:
     m_IsLocked: 0
-  m_LastSelectedObjectID: 52458
+  m_LastSelectedObjectID: 50526
 --- !u!114 &18
 MonoBehaviour:
   m_ObjectHideFlags: 52
@@ -576,7 +576,7 @@ MonoBehaviour:
       scrollPos: {x: 0, y: 0}
       m_SelectedIDs: 
       m_LastClickedID: 0
-      m_ExpandedIDs: 5062e6ff0a72e6ffb87ae6ff64eaeeff5af3eeff32c5ffff04c6ffff5ef6ffff1afbfffff4ffffff8ebf0000
+      m_ExpandedIDs: 9e09efff9612effffa13efff1cf6ffff1afbfffff4ffffff
       m_RenameOverlay:
         m_UserAcceptedRename: 0
         m_Name: 
@@ -1208,9 +1208,9 @@ MonoBehaviour:
   m_AudioPlay: 0
   m_DebugDrawModesUseInteractiveLightBakingData: 0
   m_Position:
-    m_Target: {x: 12.970818, y: 433.2704, z: 802.6817}
+    m_Target: {x: 8.00217, y: 0.8804817, z: 1.8643875}
     speed: 2
-    m_Value: {x: 12.970818, y: 433.2704, z: 802.6817}
+    m_Value: {x: 8.00217, y: 0.8804817, z: 1.8643875}
   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.23769794, y: 0.0058279876, z: -0.0014266352, w: 0.9713199}
+    m_Target: {x: 0.15735282, y: 0.6030923, z: -0.122881055, w: 0.7722813}
     speed: 2
-    m_Value: {x: -0.23769796, y: -0.0058279876, z: 0.0014266352, w: -0.9713199}
+    m_Value: {x: 0.15735283, y: 0.6030923, z: -0.12288106, w: 0.7722813}
   m_Size:
-    m_Target: 30.05434
+    m_Target: 1.9450212
     speed: 2
-    m_Value: 30.05434
+    m_Value: 1.9450212
   m_Ortho:
     m_Target: 0
     speed: 2
@@ -1412,7 +1412,7 @@ MonoBehaviour:
     m_SkipHidden: 0
     m_SearchArea: 1
     m_Folders:
-    - Assets/Resources/UI/BattleSceneUI
+    - Assets/Scenes
     m_Globs: []
     m_ProductIds: 
     m_AnyWithAssetOrigin: 0
@@ -1422,15 +1422,15 @@ MonoBehaviour:
   m_ViewMode: 1
   m_StartGridSize: 67
   m_LastFolders:
-  - Assets/Resources/UI/BattleSceneUI
+  - Assets/Scenes
   m_LastFoldersGridSize: 67
   m_LastProjectPath: C:\Users\Axel-PC\RPG-RougeLiteBatteler
   m_LockTracker:
     m_IsLocked: 0
   m_FolderTreeState:
-    scrollPos: {x: 0, y: 271}
-    m_SelectedIDs: 80d10000
-    m_LastClickedID: 53632
+    scrollPos: {x: 0, y: 0}
+    m_SelectedIDs: 2ab70000
+    m_LastClickedID: 46890
     m_ExpandedIDs: 00000000d2b40000d4b40000
     m_RenameOverlay:
       m_UserAcceptedRename: 0