diff --git a/Assets/Data/Inventory/PlayerInventory.asset b/Assets/Data/Inventory/PlayerInventory.asset index 2dcc399..a536457 100644 --- a/Assets/Data/Inventory/PlayerInventory.asset +++ b/Assets/Data/Inventory/PlayerInventory.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:362b0120802255e93f8c0b15edc15dd357571757d07e6a9f75a9666050a1469a -size 962 +oid sha256:6c75d69c62bbc00bb4af4493737a2bb52d5212a295007ff7211aced4daac792f +size 750 diff --git a/Assets/Data/Inventory/Tutorial5.asset b/Assets/Data/Inventory/Tutorial5.asset new file mode 100644 index 0000000..5a0e4a0 --- /dev/null +++ b/Assets/Data/Inventory/Tutorial5.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c81d2820a9790c0163625e9c05c69cb3f8d3d7492404c40895fd21f9848db8f6 +size 744 diff --git a/Assets/Data/Inventory/Tutorial5.asset.meta b/Assets/Data/Inventory/Tutorial5.asset.meta new file mode 100644 index 0000000..a2af943 --- /dev/null +++ b/Assets/Data/Inventory/Tutorial5.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 57948efb1cd9603419511d2dd2eabc3d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Models.meta b/Assets/Models.meta new file mode 100644 index 0000000..5346456 --- /dev/null +++ b/Assets/Models.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 296bd90e667df1f4697823a0aa45acf0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/TuteLevelFive.unity b/Assets/Scenes/TuteLevelFive.unity index 215aafd..2664e1c 100644 --- a/Assets/Scenes/TuteLevelFive.unity +++ b/Assets/Scenes/TuteLevelFive.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1} + m_IndirectSpecularColor: {r: 0.44657868, g: 0.49641263, b: 0.57481706, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -130,6 +130,18 @@ Transform: type: 3} m_PrefabInstance: {fileID: 1337844285} m_PrefabAsset: {fileID: 0} +--- !u!114 &20179508 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 6815585465521158857, guid: c176f4ae8f7b4074db99b27b2e015a2a, + type: 3} + m_PrefabInstance: {fileID: 421711684} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c0bbbf19cb68b2742bd80855243b64e3, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &43307494 PrefabInstance: m_ObjectHideFlags: 0 @@ -493,6 +505,195 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: bf82e6870e62966448210c1718aa3fb3, type: 3} +--- !u!1001 &192739617 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 5195354182462625300, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_Name + value: Player Canvas + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_Pivot.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_Pivot.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625305, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_RenderMode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5195354182462625305, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_Camera + value: + objectReference: {fileID: 222433593} + - target: {fileID: 5195354182462625307, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: characterInput + value: + objectReference: {fileID: 20179508} + - target: {fileID: 5195354182462625307, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: Inventory + value: + objectReference: {fileID: 994635199} + - target: {fileID: 5195354183101525347, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 149.60864 + objectReference: {fileID: 0} + - target: {fileID: 5195354183101525347, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354183101525347, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354183157824117, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchoredPosition.x + value: -64.200195 + objectReference: {fileID: 0} + - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchoredPosition.y + value: -0.0000061496803 + objectReference: {fileID: 0} + - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AnchoredPosition.x + value: -0.000035584977 + objectReference: {fileID: 0} + - target: {fileID: 5195354183101525346, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_AspectRatio + value: 30.407776 + objectReference: {fileID: 0} + - target: {fileID: 5195354181796512270, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_havePropertiesChanged + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5195354181796512270, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_isInputParsingRequired + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} --- !u!1 &204689275 GameObject: m_ObjectHideFlags: 0 @@ -572,7 +773,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &211889378 PrefabInstance: @@ -723,7 +924,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 49.321003, y: 0, z: 0} --- !u!1001 &226508591 PrefabInstance: @@ -1613,11 +1814,28 @@ PrefabInstance: propertyPath: popUpText value: objectReference: {fileID: 1792455937} + - target: {fileID: 2862111851184665482, guid: c176f4ae8f7b4074db99b27b2e015a2a, + type: 3} + propertyPath: Inventory + value: + objectReference: {fileID: 11400000, guid: b6fa892e4c159bf46a2c4cda19627e97, + type: 2} + - target: {fileID: 2862111851184665482, guid: c176f4ae8f7b4074db99b27b2e015a2a, + type: 3} + propertyPath: startingInventory + value: + objectReference: {fileID: 11400000, guid: 57948efb1cd9603419511d2dd2eabc3d, + type: 2} - target: {fileID: 2631002120179805110, guid: c176f4ae8f7b4074db99b27b2e015a2a, type: 3} propertyPath: m_Enabled value: 1 objectReference: {fileID: 0} + - target: {fileID: 6815585465521158857, guid: c176f4ae8f7b4074db99b27b2e015a2a, + type: 3} + propertyPath: blockReader.LogicChain.Array.size + value: 0 + objectReference: {fileID: 0} - target: {fileID: 6815585465521158857, guid: c176f4ae8f7b4074db99b27b2e015a2a, type: 3} propertyPath: m_Enabled @@ -2888,6 +3106,18 @@ Transform: type: 3} m_PrefabInstance: {fileID: 326265431} m_PrefabAsset: {fileID: 0} +--- !u!114 &994635199 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 5195354183134146528, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + m_PrefabInstance: {fileID: 192739617} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 36cc4df775c8e8b46a89972d8008d56d, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!4 &1045336388 stripped Transform: m_CorrespondingSourceObject: {fileID: 850440798328794615, guid: bf82e6870e62966448210c1718aa3fb3, @@ -2961,7 +3191,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1001 &1061954515 PrefabInstance: @@ -3088,7 +3318,7 @@ PrefabInstance: - target: {fileID: 7103365430685043225, guid: 80a26ed87f729434abe07a722ef15e7c, type: 3} propertyPath: m_RootOrder - value: 7 + value: 8 objectReference: {fileID: 0} - target: {fileID: 7103365430685043225, guid: 80a26ed87f729434abe07a722ef15e7c, type: 3} @@ -4322,6 +4552,7 @@ GameObject: - component: {fileID: 1691679949} - component: {fileID: 1691679948} - component: {fileID: 1691679947} + - component: {fileID: 1691679951} m_Layer: 0 m_Name: Jump m_TagString: New Block @@ -4399,8 +4630,26 @@ Transform: m_LocalScale: {x: 0.3, y: 0.3, z: 0.3} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1691679951 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1691679946} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3de8ea85fe104ee46819ac1ff5e87159, type: 3} + m_Name: + m_EditorClassIdentifier: + Collectable: + element: {fileID: 11400000, guid: dcf80d6bc49692f4d849f5afb0d05911, type: 2} + Count: 2 + isInfinit: 0 + BlockMenu: {fileID: 1792455936} + popUpText: {fileID: 1792455937} --- !u!1001 &1718022930 PrefabInstance: m_ObjectHideFlags: 0 @@ -4802,7 +5051,7 @@ PrefabInstance: - target: {fileID: 6379596649083080716, guid: 12c252cb33f8c9d41be9fc3a9adb9bb9, type: 3} propertyPath: m_RootOrder - value: 6 + value: 7 objectReference: {fileID: 0} - target: {fileID: 6379596649083080716, guid: 12c252cb33f8c9d41be9fc3a9adb9bb9, type: 3} diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index 4ea11ef..fa32887 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -7,10 +7,11 @@ using UnityEngine.SceneManagement; public class Character : MonoBehaviour { public string nextScene; - public GameObject BlockMenu; - public Text popUpText; - #region Inspector Fields + #region Inspector Fields + + [SerializeField] + private Inventory startingInventory; [SerializeField] [Tooltip ("Will move to this block at start, else will try and find a block below")] @@ -20,7 +21,8 @@ public class Character : MonoBehaviour [Tooltip ("Layers to ignore when checking for blocks")] private LayerMask Ignore; - public string PickUpTag = "NewBlock"; + [Tooltip("Current Inventory of the player")] + public Inventory Inventory; #endregion Inspector Fields @@ -28,6 +30,8 @@ public class Character : MonoBehaviour private void Awake () { + Inventory.Clone(startingInventory); + //If no starting block find one below it if (CurrentBlock == null) Block.isBlockAtPosition (transform.position + Vector3.down / 2, 1, ~Ignore, out CurrentBlock); @@ -76,11 +80,10 @@ public class Character : MonoBehaviour /// name of collided object void OnTriggerEnter (Collider other) { - if (other.gameObject.tag == PickUpTag) { - BlockMenu.SetActive (true); - other.gameObject.SetActive (false); - Debug.Log ("You picked up the new coding block " + other.gameObject.name + "!"); - popUpText.text = other.gameObject.name.ToUpper (); + Collectable collectable = other.GetComponentInChildren(); + + if (other != null) { + collectable.OnCollect(this); } if (other.gameObject.name == "End Portal") { other.GetComponent ().enabled = false; diff --git a/Assets/Scripts/Collectables.meta b/Assets/Scripts/Collectables.meta new file mode 100644 index 0000000..ceff81a --- /dev/null +++ b/Assets/Scripts/Collectables.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5883cd0dff73b794ca76695db9281213 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Collectables/Collectable.cs b/Assets/Scripts/Collectables/Collectable.cs new file mode 100644 index 0000000..249e236 --- /dev/null +++ b/Assets/Scripts/Collectables/Collectable.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Collectable : MonoBehaviour +{ + + public abstract void OnCollect(Character character); + +} diff --git a/Assets/Scripts/Collectables/Collectable.cs.meta b/Assets/Scripts/Collectables/Collectable.cs.meta new file mode 100644 index 0000000..8735ee4 --- /dev/null +++ b/Assets/Scripts/Collectables/Collectable.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2af2f61d23b983742b02bb522d600055 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Collectables/LogicCollectable.cs b/Assets/Scripts/Collectables/LogicCollectable.cs new file mode 100644 index 0000000..e332b30 --- /dev/null +++ b/Assets/Scripts/Collectables/LogicCollectable.cs @@ -0,0 +1,34 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class LogicCollectable : Collectable +{ + + [SerializeField] + protected Inventory.Data Collectable; + + [SerializeField] + protected GameObject BlockMenu; + + [SerializeField] + protected Text popUpText; + + public override void OnCollect(Character character) + { + character.Inventory.Add(Collectable); + + if (BlockMenu != null) + { + BlockMenu.SetActive(true); + + Debug.Log("You picked up the new coding block " + Collectable.element.DisplayName + "!"); + popUpText.text = Collectable.element.DisplayName.ToUpper(); + } + Destroy(gameObject); + } + + + +} diff --git a/Assets/Scripts/Collectables/LogicCollectable.cs.meta b/Assets/Scripts/Collectables/LogicCollectable.cs.meta new file mode 100644 index 0000000..11c1423 --- /dev/null +++ b/Assets/Scripts/Collectables/LogicCollectable.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3de8ea85fe104ee46819ac1ff5e87159 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Inventory.cs b/Assets/Scripts/Inventory.cs index 6b73c87..cf388c6 100644 --- a/Assets/Scripts/Inventory.cs +++ b/Assets/Scripts/Inventory.cs @@ -12,22 +12,29 @@ public class Inventory : ScriptableObject [SerializeField] protected List _bagItems = new List(); - public void Add(LogicBlock element) + public void Add(LogicBlock element,int count = 1, bool isInfinit = false) { - Data data; + Data data = new Data { + element = element, + Count = count, + isInfinit = isInfinit }; - try + Add(data); + } + + public void Add(Data data) + { + + if (_bagItems.Contains(data)) { - data = _bagItems.First(p => p.element == element); + Data bagData = BagItems.Find(p => p.Equals(data)); + + bagData.Count += data.Count; + bagData.isInfinit = (data.isInfinit || bagData.isInfinit); } - catch - { - data = new Data() { element = element }; + else _bagItems.Add(data); - } - - data.Count++; } public void Remove(LogicBlock element) { @@ -37,10 +44,17 @@ public class Inventory : ScriptableObject Data data = _bagItems.First(p => p.element == element); - if (!data.infinit) + if (!data.isInfinit) data.Count--; } + public void Clone(Inventory inventory) + { + + _bagItems = new List(inventory._bagItems); + + } + [System.Serializable] @@ -48,6 +62,6 @@ public class Inventory : ScriptableObject { public LogicBlock element; public int Count; - public bool infinit = false; + public bool isInfinit = false; } } diff --git a/Assets/Scripts/Logic/Blocks/LogicBlock.cs b/Assets/Scripts/Logic/Blocks/LogicBlock.cs index 765339a..d15a5cb 100644 --- a/Assets/Scripts/Logic/Blocks/LogicBlock.cs +++ b/Assets/Scripts/Logic/Blocks/LogicBlock.cs @@ -17,7 +17,7 @@ public abstract class LogicBlock : ScriptableObject [SerializeField] [Tooltip("Name which will appear in the UI")] - public string DisplayName; + protected string _DisplayName; [SerializeField] [Header("Base Settings")] @@ -29,6 +29,10 @@ public abstract class LogicBlock : ScriptableObject protected int RepeatAmount = 1; #endregion Inspector Fields + #region ReadOnly Variables + public string DisplayName { get {return (string.IsNullOrEmpty(_DisplayName)) ? name : _DisplayName; } } + #endregion + #region private variables /// diff --git a/Assets/Scripts/LogicBlocks.meta b/Assets/Scripts/LogicBlocks.meta new file mode 100644 index 0000000..98af9d1 --- /dev/null +++ b/Assets/Scripts/LogicBlocks.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8936b441d7647f74884c94f97bfb8931 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/BagItem.cs b/Assets/Scripts/UI/BagItem.cs index 4dfd001..ff6a6d4 100644 --- a/Assets/Scripts/UI/BagItem.cs +++ b/Assets/Scripts/UI/BagItem.cs @@ -39,7 +39,7 @@ public class BagItem : LogicElementHolder public void UpdateUI() { - if (!InventoryData.infinit) + if (!InventoryData.isInfinit) CountText.text = Count.ToString(); else CountText.text = "∞"; @@ -57,7 +57,7 @@ public class BagItem : LogicElementHolder { Destroy(element.gameObject); - if (!InventoryData.infinit) + if (!InventoryData.isInfinit) Count++; UpdateUI(); @@ -69,9 +69,9 @@ public class BagItem : LogicElementHolder /// Element which is being dragged public override void OnRemove(LogicElementUI element) { - if (!InventoryData.infinit && Count > 0) + if (!InventoryData.isInfinit && Count > 0) Count--; - else if (!InventoryData.infinit) + else if (!InventoryData.isInfinit) Destroy(element.gameObject); LogicElementUI logicElement = Instantiate(LogicElementPrefab.gameObject, LogicElementLocation).GetComponent(); diff --git a/Assets/Scripts/UI/LogicElementUI.cs b/Assets/Scripts/UI/LogicElementUI.cs index c489854..3a45dd0 100644 --- a/Assets/Scripts/UI/LogicElementUI.cs +++ b/Assets/Scripts/UI/LogicElementUI.cs @@ -62,7 +62,7 @@ public class LogicElementUI : Dragable if (LogicElement != null) { //If name null use file name - nameText.text = (string.IsNullOrEmpty(LogicElement.DisplayName)) ? LogicElement.name : LogicElement.DisplayName; + nameText.text = LogicElement.DisplayName; background.color = LogicElement.Color; } } diff --git a/Assets/Scripts/UI/PlayerUIManager.cs b/Assets/Scripts/UI/PlayerUIManager.cs index d5f79f7..2dd8527 100644 --- a/Assets/Scripts/UI/PlayerUIManager.cs +++ b/Assets/Scripts/UI/PlayerUIManager.cs @@ -6,7 +6,7 @@ public class PlayerUIManager : MonoBehaviour { [SerializeField] - private RectTransform Inventory; + private InventoryUI Inventory; [SerializeField] private float AnimationSpeed = 0.5f; @@ -19,14 +19,17 @@ public class PlayerUIManager : MonoBehaviour private Vector3 ShowPosition; private Vector3 HidePosition; + private RectTransform inventoryRect { get { return Inventory.transform as RectTransform; } } private void Awake() { - ShowPosition = new Vector3(0, -Inventory.rect.height / 2, 0); - HidePosition = new Vector3(0, Inventory.rect.height/2, 0); - Debug.Log(Inventory.rect.height); - Inventory.anchoredPosition = HidePosition; + + ShowPosition = new Vector3(0, -inventoryRect.rect.height / 2, 0); + HidePosition = new Vector3(0, inventoryRect.rect.height/2, 0); + + + inventoryRect.anchoredPosition = HidePosition; TrayUI.SetBlockReader(characterInput.blockReader); } @@ -34,7 +37,8 @@ public class PlayerUIManager : MonoBehaviour public void OnClick_Show() { StopAllCoroutines(); - StartCoroutine( LerpPosition(Inventory, ShowPosition, AnimationSpeed)); + Inventory.UpdateUI(); + StartCoroutine( LerpPosition(inventoryRect, ShowPosition, AnimationSpeed)); } [ContextMenu("Hide")] @@ -42,12 +46,12 @@ public class PlayerUIManager : MonoBehaviour { StopAllCoroutines(); - StartCoroutine( LerpPosition(Inventory, HidePosition, AnimationSpeed)); + StartCoroutine( LerpPosition(inventoryRect, HidePosition, AnimationSpeed)); } public void OnClick_Toggle() { - if (Vector3.Distance(Inventory.anchoredPosition,ShowPosition) < Vector3.Distance(Inventory.anchoredPosition, HidePosition)) + if (Vector3.Distance(inventoryRect.anchoredPosition,ShowPosition) < Vector3.Distance(inventoryRect.anchoredPosition, HidePosition)) { Debug.Log("Hiding Menu"); OnClick_Hide();