diff --git a/Assets/Data/Items/Ass2PickupItem.asset b/Assets/Data/Items/Ass2PickupItem.asset new file mode 100644 index 00000000..860137fc --- /dev/null +++ b/Assets/Data/Items/Ass2PickupItem.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 951b5c8af5114086a865d4bb7eae4548, type: 3} + m_Name: Ass2PickupItem + m_EditorClassIdentifier: + itemName: TestAss + description: Well... how do you like 'em? + mapSprite: {fileID: 4013237533433454447, guid: 77ab3d770c92d5344b36eee3293a0f94, type: 3} diff --git a/Assets/Data/Items/Ass2PickupItem.asset.meta b/Assets/Data/Items/Ass2PickupItem.asset.meta new file mode 100644 index 00000000..e3e9daca --- /dev/null +++ b/Assets/Data/Items/Ass2PickupItem.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 967d5b182189c14489ad851b665de84c +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Data/Items/Ass3PickupItem 1.asset b/Assets/Data/Items/Ass3PickupItem 1.asset new file mode 100644 index 00000000..f1981f77 --- /dev/null +++ b/Assets/Data/Items/Ass3PickupItem 1.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 951b5c8af5114086a865d4bb7eae4548, type: 3} + m_Name: Ass3PickupItem 1 + m_EditorClassIdentifier: + itemName: TestAss + description: Well... how do you like 'em? + mapSprite: {fileID: -8109988653212156562, guid: 77ab3d770c92d5344b36eee3293a0f94, type: 3} diff --git a/Assets/Data/Items/Ass3PickupItem 1.asset.meta b/Assets/Data/Items/Ass3PickupItem 1.asset.meta new file mode 100644 index 00000000..4eb63d9e --- /dev/null +++ b/Assets/Data/Items/Ass3PickupItem 1.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7ff44a6951f74494daf1c8b2cb7f84be +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Data/Settings/DefaultSettings.asset b/Assets/Data/Settings/DefaultSettings.asset index 6f0dd9ce..463ab1cf 100644 --- a/Assets/Data/Settings/DefaultSettings.asset +++ b/Assets/Data/Settings/DefaultSettings.asset @@ -25,3 +25,4 @@ MonoBehaviour: followUpdateInterval: 0.1 followerSpeedMultiplier: 1.2 heldIconDisplayHeight: 2 + basePickupPrefab: {fileID: 7447346505753002421, guid: bf4b9d7045397f946b2125b1ad4a3fbd, type: 3} diff --git a/Assets/Prefabs/Items/BasePickup.prefab b/Assets/Prefabs/Items/BasePickup.prefab index 758e5a3f..d43bd06f 100644 --- a/Assets/Prefabs/Items/BasePickup.prefab +++ b/Assets/Prefabs/Items/BasePickup.prefab @@ -30,7 +30,7 @@ Transform: serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 3.405, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalScale: {x: 4, y: 4, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/Scenes/AppleHillsOverworld.unity b/Assets/Scenes/AppleHillsOverworld.unity index 58521d89..78a31891 100644 --- a/Assets/Scenes/AppleHillsOverworld.unity +++ b/Assets/Scenes/AppleHillsOverworld.unity @@ -262,10 +262,18 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 3985075764085675244, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} + propertyPath: itemData + value: + objectReference: {fileID: 11400000, guid: 7ff44a6951f74494daf1c8b2cb7f84be, type: 2} - target: {fileID: 4778083634590203921, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: stepData value: objectReference: {fileID: 11400000, guid: 13b0c411066f85a41ba40c3bbbc281ed, type: 2} + - target: {fileID: 6303063351359542479, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: -8109988653212156562, guid: 77ab3d770c92d5344b36eee3293a0f94, type: 3} - target: {fileID: 6350287859698694726, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: m_Name value: TestAss @@ -764,10 +772,18 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 3985075764085675244, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} + propertyPath: itemData + value: + objectReference: {fileID: 11400000, guid: 967d5b182189c14489ad851b665de84c, type: 2} - target: {fileID: 4778083634590203921, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: stepData value: objectReference: {fileID: 11400000, guid: a84cbe9804e13f74e857c55d90cc10d1, type: 2} + - target: {fileID: 6303063351359542479, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: 4013237533433454447, guid: 77ab3d770c92d5344b36eee3293a0f94, type: 3} - target: {fileID: 6350287859698694726, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} propertyPath: m_Name value: TestAss diff --git a/Assets/Scripts/FollowerController.cs b/Assets/Scripts/FollowerController.cs index d91ed8c1..658cd1cb 100644 --- a/Assets/Scripts/FollowerController.cs +++ b/Assets/Scripts/FollowerController.cs @@ -258,7 +258,7 @@ public class FollowerController : MonoBehaviour yield return null; } OnPickupArrived?.Invoke(); - // Set held item and destroy pickup + // Swap held item if necessary, then set held item and destroy pickup if (heldObjectRenderer != null) { Collider2D[] hits = Physics2D.OverlapCircleAll(itemPosition, 0.2f); @@ -267,6 +267,25 @@ public class FollowerController : MonoBehaviour var pickup = hit.GetComponent(); if (pickup != null) { + // Swap logic: if holding an item, drop it here + if (currentlyHeldItem != null) + { + var basePickupPrefab = GameManager.Instance.BasePickupPrefab; + if (basePickupPrefab != null) + { + var droppedPickupObj = GameObject.Instantiate(basePickupPrefab, pickup.transform.position, Quaternion.identity); + var droppedPickup = droppedPickupObj.GetComponent(); + if (droppedPickup != null) + { + droppedPickup.itemData = currentlyHeldItem; + droppedPickup.ApplyItemData(); + } + } + else + { + Debug.LogWarning("BasePickup prefab not assigned in GameSettings"); + } + } SetHeldItem(pickup.itemData); GameObject.Destroy(pickup.gameObject); break; diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index ac198d3a..4e4e380d 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -43,5 +43,6 @@ public class GameManager : MonoBehaviour public float FollowUpdateInterval => gameSettings != null ? gameSettings.followUpdateInterval : 0.1f; public float FollowerSpeedMultiplier => gameSettings != null ? gameSettings.followerSpeedMultiplier : 1.2f; public float HeldIconDisplayHeight => gameSettings != null ? gameSettings.heldIconDisplayHeight : 2.0f; + public GameObject BasePickupPrefab => gameSettings != null ? gameSettings.basePickupPrefab : null; // Add more accessors as needed } diff --git a/Assets/Scripts/GameSettings.cs b/Assets/Scripts/GameSettings.cs index 08ae6465..d9496b50 100644 --- a/Assets/Scripts/GameSettings.cs +++ b/Assets/Scripts/GameSettings.cs @@ -25,6 +25,9 @@ public class GameSettings : ScriptableObject public float followerSpeedMultiplier = 1.2f; public float heldIconDisplayHeight = 2.0f; + [Header("Default Prefabs")] + public GameObject basePickupPrefab; + // Singleton pattern private static GameSettings _instance; public static GameSettings Instance { @@ -53,4 +56,5 @@ public class GameSettings : ScriptableObject public static float FollowUpdateInterval => Instance.followUpdateInterval; public static float FollowerSpeedMultiplier => Instance.followerSpeedMultiplier; public static float HeldIconDisplayHeight => Instance.heldIconDisplayHeight; + public static GameObject BasePickupPrefab => Instance.basePickupPrefab; }