From 6fe7a0ad17b002809c05a0c3b5812146978d277e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=B6sl?= <benjamin.boesl@fau.de> Date: Thu, 12 Dec 2019 16:32:02 +0100 Subject: [PATCH] added Relation between Items and ItemsGUI, Magic button can now potentially do Magic --- Assets/InventoryStuff/DropHandling.cs | 4 + Assets/InventoryStuff/FactWrapper.cs | 8 ++ Assets/InventoryStuff/FactWrapper.cs.meta | 11 +++ .../Items/scripts/AngleObject.cs | 1 + .../Items/scripts/LengthObject.cs | 1 + .../Items/scripts/PointObject.cs | 1 + Assets/InventoryStuff/PointWrapper.cs | 8 ++ Assets/InventoryStuff/PointWrapper.cs.meta | 11 +++ Assets/Prefabs/AngleDisplay.prefab | 14 +++ Assets/Prefabs/DisplayPoint.prefab | 14 +++ Assets/Prefabs/DistanceDisplay.prefab | 17 +++- Assets/PythagorasScript.cs | 22 +++++ Assets/PythagorasScript.cs.meta | 11 +++ Assets/inventoryStuff.unity | 88 +++++++++++++++++++ 14 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 Assets/InventoryStuff/FactWrapper.cs create mode 100644 Assets/InventoryStuff/FactWrapper.cs.meta create mode 100644 Assets/InventoryStuff/PointWrapper.cs create mode 100644 Assets/InventoryStuff/PointWrapper.cs.meta create mode 100644 Assets/PythagorasScript.cs create mode 100644 Assets/PythagorasScript.cs.meta diff --git a/Assets/InventoryStuff/DropHandling.cs b/Assets/InventoryStuff/DropHandling.cs index 6c56a80f..b0d7a1e5 100644 --- a/Assets/InventoryStuff/DropHandling.cs +++ b/Assets/InventoryStuff/DropHandling.cs @@ -11,6 +11,10 @@ public void OnDrop(PointerEventData eventData){ Destroy(current); current = Instantiate(eventData.pointerDrag,Vector3.zero, Quaternion.identity); current.transform.SetParent(gameObject.transform, false); + GameObject scrollShow = gameObject.transform.parent.gameObject; + PythagorasScript pythagorasScript = scrollShow.GetComponent<PythagorasScript>(); + var fact = ((FactWrapper)current.GetComponent<FactWrapper>()).fact; + pythagorasScript.putItem(gameObject.name, fact); } } diff --git a/Assets/InventoryStuff/FactWrapper.cs b/Assets/InventoryStuff/FactWrapper.cs new file mode 100644 index 00000000..bf333315 --- /dev/null +++ b/Assets/InventoryStuff/FactWrapper.cs @@ -0,0 +1,8 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FactWrapper : MonoBehaviour +{ + public ItemObject fact; +} diff --git a/Assets/InventoryStuff/FactWrapper.cs.meta b/Assets/InventoryStuff/FactWrapper.cs.meta new file mode 100644 index 00000000..3cf5d6e7 --- /dev/null +++ b/Assets/InventoryStuff/FactWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ed0bcd3d8d9996d4f86c0a2b8b71c6bf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/InventoryStuff/Items/scripts/AngleObject.cs b/Assets/InventoryStuff/Items/scripts/AngleObject.cs index 2e3fd1f7..1231871c 100644 --- a/Assets/InventoryStuff/Items/scripts/AngleObject.cs +++ b/Assets/InventoryStuff/Items/scripts/AngleObject.cs @@ -20,6 +20,7 @@ public override GameObject CreateDisplay(Transform transform, GameObject prefab obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = pointA; obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = pointB; obj.transform.GetChild(2).gameObject.GetComponent<TextMeshProUGUI>().text = pointC; + obj.GetComponent<FactWrapper>().fact = this; return obj; } } diff --git a/Assets/InventoryStuff/Items/scripts/LengthObject.cs b/Assets/InventoryStuff/Items/scripts/LengthObject.cs index 7a265ee1..2fc722b3 100644 --- a/Assets/InventoryStuff/Items/scripts/LengthObject.cs +++ b/Assets/InventoryStuff/Items/scripts/LengthObject.cs @@ -20,6 +20,7 @@ public override GameObject CreateDisplay(Transform transform, GameObject prefab var obj = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = pointA; obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = pointB; + obj.GetComponent<FactWrapper>().fact = this; return obj; } } diff --git a/Assets/InventoryStuff/Items/scripts/PointObject.cs b/Assets/InventoryStuff/Items/scripts/PointObject.cs index cc6b14be..acf63e37 100644 --- a/Assets/InventoryStuff/Items/scripts/PointObject.cs +++ b/Assets/InventoryStuff/Items/scripts/PointObject.cs @@ -17,6 +17,7 @@ public void Awake() public override GameObject CreateDisplay(Transform transform, GameObject prefab){ var obj = Instantiate(prefab, Vector3.zero, Quaternion.identity, transform); obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = point; + obj.GetComponent<FactWrapper>(). fact = this; return obj; } } \ No newline at end of file diff --git a/Assets/InventoryStuff/PointWrapper.cs b/Assets/InventoryStuff/PointWrapper.cs new file mode 100644 index 00000000..9e7a54c9 --- /dev/null +++ b/Assets/InventoryStuff/PointWrapper.cs @@ -0,0 +1,8 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PointWrapper : MonoBehaviour +{ + public PointObject point; +} diff --git a/Assets/InventoryStuff/PointWrapper.cs.meta b/Assets/InventoryStuff/PointWrapper.cs.meta new file mode 100644 index 00000000..3af2b1ec --- /dev/null +++ b/Assets/InventoryStuff/PointWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d5e5e87a22cc1714dbacaa2632c40e98 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/AngleDisplay.prefab b/Assets/Prefabs/AngleDisplay.prefab index 40b6da3e..d98dc8b7 100644 --- a/Assets/Prefabs/AngleDisplay.prefab +++ b/Assets/Prefabs/AngleDisplay.prefab @@ -478,6 +478,7 @@ GameObject: - component: {fileID: 6643637775379894486} - component: {fileID: 225831940989964384} - component: {fileID: 114522817932931646} + - component: {fileID: 3011926265969909947} m_Layer: 5 m_Name: AngleDisplay m_TagString: Untagged @@ -566,3 +567,16 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a091cb23127eb7347955cb7f747af431, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &3011926265969909947 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6643637775379894484} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ed0bcd3d8d9996d4f86c0a2b8b71c6bf, type: 3} + m_Name: + m_EditorClassIdentifier: + fact: {fileID: 0} diff --git a/Assets/Prefabs/DisplayPoint.prefab b/Assets/Prefabs/DisplayPoint.prefab index 7825702a..264aa3b2 100644 --- a/Assets/Prefabs/DisplayPoint.prefab +++ b/Assets/Prefabs/DisplayPoint.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 858001163752551617} - component: {fileID: 114132791164475416} - component: {fileID: 225408562469983378} + - component: {fileID: 114984628052382182} m_Layer: 5 m_Name: DisplayPoint m_TagString: Untagged @@ -99,6 +100,19 @@ CanvasGroup: m_Interactable: 1 m_BlocksRaycasts: 1 m_IgnoreParentGroups: 0 +--- !u!114 &114984628052382182 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 858001163752551619} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ed0bcd3d8d9996d4f86c0a2b8b71c6bf, type: 3} + m_Name: + m_EditorClassIdentifier: + fact: {fileID: 0} --- !u!1 &858001164857725565 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/DistanceDisplay.prefab b/Assets/Prefabs/DistanceDisplay.prefab index 6300a874..9062cc08 100644 --- a/Assets/Prefabs/DistanceDisplay.prefab +++ b/Assets/Prefabs/DistanceDisplay.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 1241458608524046696} - component: {fileID: 2785940634305866798} - component: {fileID: 9035428711241438515} + - component: {fileID: 114476148939060428} m_Layer: 5 m_Name: DistanceDisplay m_TagString: Untagged @@ -100,6 +101,18 @@ CanvasGroup: m_Interactable: 1 m_BlocksRaycasts: 1 m_IgnoreParentGroups: 0 +--- !u!114 &114476148939060428 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4221381813544557775} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ed0bcd3d8d9996d4f86c0a2b8b71c6bf, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &6379254425133528592 GameObject: m_ObjectHideFlags: 0 @@ -165,7 +178,7 @@ MonoBehaviour: m_Calls: [] m_text: A m_isRightToLeft: 0 - m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontAsset: {fileID: 0} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} @@ -320,7 +333,7 @@ MonoBehaviour: m_Calls: [] m_text: A m_isRightToLeft: 0 - m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontAsset: {fileID: 0} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} diff --git a/Assets/PythagorasScript.cs b/Assets/PythagorasScript.cs new file mode 100644 index 00000000..3911edcc --- /dev/null +++ b/Assets/PythagorasScript.cs @@ -0,0 +1,22 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PythagorasScript : MonoBehaviour +{ + private Dictionary<string, ItemObject> items = new Dictionary<string, ItemObject>(); + + public void putItem(string name, ItemObject obj) { + if (this.items.ContainsKey(name)) { + this.items.Remove(name); + } + this.items.Add(name, obj); + } + + public void doMagic() { + Dictionary<string, ItemObject>.Enumerator enumerator = this.items.GetEnumerator(); + while (enumerator.MoveNext()){ + Debug.Log(enumerator.Current.Key + " is mapped to " + enumerator.Current.Value); + } + } +} diff --git a/Assets/PythagorasScript.cs.meta b/Assets/PythagorasScript.cs.meta new file mode 100644 index 00000000..d103391a --- /dev/null +++ b/Assets/PythagorasScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 413dcae9856bd794ab03d29210561c57 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/inventoryStuff.unity b/Assets/inventoryStuff.unity index 8a69f69f..f9966049 100644 --- a/Assets/inventoryStuff.unity +++ b/Assets/inventoryStuff.unity @@ -112,6 +112,24 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &84407291 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 4362180880950796636, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + m_PrefabInstance: {fileID: 1784564330} + m_PrefabAsset: {fileID: 0} +--- !u!114 &84407294 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 84407291} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 413dcae9856bd794ab03d29210561c57, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &189930219 GameObject: m_ObjectHideFlags: 0 @@ -1802,6 +1820,76 @@ PrefabInstance: propertyPath: m_textInfo.pageCount value: 0 objectReference: {fileID: 0} + - target: {fileID: 4362180880026436509, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_Name + value: EckeC + objectReference: {fileID: 0} + - target: {fileID: 4362180880123462339, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_Name + value: EckeB + objectReference: {fileID: 0} + - target: {fileID: 4362180880440508805, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_Name + value: DistBc + objectReference: {fileID: 0} + - target: {fileID: 4362180880452624253, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_Name + value: Angle + objectReference: {fileID: 0} + - target: {fileID: 4362180880945641279, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_SizeDelta.x + value: 200 + objectReference: {fileID: 0} + - target: {fileID: 4362180880945641279, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_SizeDelta.y + value: 50 + objectReference: {fileID: 0} + - target: {fileID: 4362180881465634439, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_Name + value: EckeA + objectReference: {fileID: 0} + - target: {fileID: 4362180881807297815, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_Name + value: DistAc + objectReference: {fileID: 0} + - target: {fileID: 4362180881535347500, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4362180881535347500, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4362180881535347500, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 4362180881535347500, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 84407294} + - target: {fileID: 4362180881535347500, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: doMagic + objectReference: {fileID: 0} + - target: {fileID: 4362180881535347500, guid: 170ab14de1eba214fb78abe18aaf388c, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 170ab14de1eba214fb78abe18aaf388c, type: 3} --- !u!1 &2070523361 -- GitLab