[Player][Interactions] Items can be switched when picked up now
This commit is contained in:
17
Assets/Data/Items/Ass2PickupItem.asset
Normal file
17
Assets/Data/Items/Ass2PickupItem.asset
Normal file
@@ -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}
|
||||
8
Assets/Data/Items/Ass2PickupItem.asset.meta
Normal file
8
Assets/Data/Items/Ass2PickupItem.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 967d5b182189c14489ad851b665de84c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Data/Items/Ass3PickupItem 1.asset
Normal file
17
Assets/Data/Items/Ass3PickupItem 1.asset
Normal file
@@ -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}
|
||||
8
Assets/Data/Items/Ass3PickupItem 1.asset.meta
Normal file
8
Assets/Data/Items/Ass3PickupItem 1.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ff44a6951f74494daf1c8b2cb7f84be
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -25,3 +25,4 @@ MonoBehaviour:
|
||||
followUpdateInterval: 0.1
|
||||
followerSpeedMultiplier: 1.2
|
||||
heldIconDisplayHeight: 2
|
||||
basePickupPrefab: {fileID: 7447346505753002421, guid: bf4b9d7045397f946b2125b1ad4a3fbd, type: 3}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Pickup>();
|
||||
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<Pickup>();
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user