From 1980455d86416b82f0bf7b80569bb71776a59ec7 Mon Sep 17 00:00:00 2001 From: "SWIN\\jreason" Date: Wed, 22 May 2019 17:03:03 +1000 Subject: [PATCH] Semi working editable for loop --- Assets/Data/Inventory/BaseInventory.asset | 4 +- Assets/Data/Logic Blocks/ForLoop.asset | 4 +- Assets/Plugins.meta | 8 - Assets/Prefabs/UI/Bag Item.prefab | 3 +- Assets/Prefabs/UI/Player Canvas.prefab | 293 ++++++++++++++++++ Assets/Scenes/Client Scenes/ClientScene.unity | 67 +++- Assets/Scripts/Logic/Blocks/CombinedBlock.cs | 37 ++- Assets/Scripts/Logic/Blocks/LogicBlock.cs | 11 +- Assets/Scripts/UI/BagItem.cs | 4 +- Assets/Scripts/UI/ILogicElementHolder.cs | 2 +- Assets/Scripts/UI/InventoryCatch.cs | 12 +- Assets/Scripts/UI/LogicElementUI.cs | 6 +- Assets/Scripts/UI/LogicTrayUI.cs | 67 +++- 13 files changed, 478 insertions(+), 40 deletions(-) delete mode 100644 Assets/Plugins.meta diff --git a/Assets/Data/Inventory/BaseInventory.asset b/Assets/Data/Inventory/BaseInventory.asset index dd184bf..a0cb135 100644 --- a/Assets/Data/Inventory/BaseInventory.asset +++ b/Assets/Data/Inventory/BaseInventory.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:479be56d3de9e28201b00e89d275b36c21fb25244411ae9838f567db460ee1b1 -size 979 +oid sha256:6e4c66a6bd49ce2a4272d7a654c5f672cace8afca5f31e4902f701fd892b2651 +size 1090 diff --git a/Assets/Data/Logic Blocks/ForLoop.asset b/Assets/Data/Logic Blocks/ForLoop.asset index 1786a14..598bf3b 100644 --- a/Assets/Data/Logic Blocks/ForLoop.asset +++ b/Assets/Data/Logic Blocks/ForLoop.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6e6e8e46d29e12c7793ce76da141fbb3dc619368660efd6d4338052edcafd802 -size 787 +oid sha256:bedf21a36efd57e309566f8720c0ef1f348713ed8aca032e51b42634e368fb4a +size 712 diff --git a/Assets/Plugins.meta b/Assets/Plugins.meta deleted file mode 100644 index aa3b71c..0000000 --- a/Assets/Plugins.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: eb6762a6d45772b43a77849ba46f89db -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Prefabs/UI/Bag Item.prefab b/Assets/Prefabs/UI/Bag Item.prefab index 3a53f0d..fb539b3 100644 --- a/Assets/Prefabs/UI/Bag Item.prefab +++ b/Assets/Prefabs/UI/Bag Item.prefab @@ -111,6 +111,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d900b6d035606e046acdf763c041a7c9, type: 3} m_Name: m_EditorClassIdentifier: + Priority: -2 LogicElementLocation: {fileID: 5884576982143469529} LogicElementPrefab: {fileID: 6973439230367005604, guid: f1daf3f500b22a048bbbad4287c2fcb2, type: 3} @@ -256,7 +257,7 @@ MonoBehaviour: lineCount: 0 pageCount: 0 materialCount: 1 - m_havePropertiesChanged: 0 + m_havePropertiesChanged: 1 m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 m_spriteAnimator: {fileID: 0} diff --git a/Assets/Prefabs/UI/Player Canvas.prefab b/Assets/Prefabs/UI/Player Canvas.prefab index dbecfdf..425e539 100644 --- a/Assets/Prefabs/UI/Player Canvas.prefab +++ b/Assets/Prefabs/UI/Player Canvas.prefab @@ -360,6 +360,295 @@ MonoBehaviour: m_FillClockwise: 1 m_FillOrigin: 0 m_UseSpriteMesh: 0 +--- !u!1 &3854733345615527911 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 463365253886133364} + - component: {fileID: 902273219000936902} + - component: {fileID: 2584547907285081931} + m_Layer: 5 + m_Name: TextMeshPro Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &463365253886133364 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3854733345615527911} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 2052082028810034629} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &902273219000936902 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3854733345615527911} + m_CullTransparentMesh: 0 +--- !u!114 &2584547907285081931 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3854733345615527911} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_text: '>' + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4278190080 + m_fontColor: {r: 0, g: 0, b: 0, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_outlineColor: + serializedVersion: 2 + rgba: 4278190080 + m_fontSize: 72 + m_fontSizeBase: 24.98 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_textAlignment: 514 + m_isAlignmentEnumConverted: 1 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_firstOverflowCharacterIndex: -1 + m_linkedTextComponent: {fileID: 0} + m_isLinkedTextComponent: 0 + m_isTextTruncated: 0 + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_ignoreRectMaskCulling: 0 + m_ignoreCulling: 1 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_firstVisibleCharacter: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_textInfo: + textComponent: {fileID: 2584547907285081931} + characterCount: 1 + spriteCount: 0 + spaceCount: 0 + wordCount: 1 + linkCount: 0 + lineCount: 1 + pageCount: 1 + materialCount: 1 + m_havePropertiesChanged: 1 + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_spriteAnimator: {fileID: 0} + m_isInputParsingRequired: 0 + m_inputSource: 0 + m_hasFontAssetChanged: 0 + m_subTextObjects: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!1 &4080157917815310858 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2052082028810034629} + - component: {fileID: 6693883212389319580} + - component: {fileID: 3310961320254260425} + - component: {fileID: 4132265620032504676} + m_Layer: 5 + m_Name: Return Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2052082028810034629 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4080157917815310858} + m_LocalRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 463365253886133364} + m_Father: {fileID: 5195354183101525347} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -70, y: 0} + m_SizeDelta: {x: 100, y: -40} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &6693883212389319580 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4080157917815310858} + m_CullTransparentMesh: 0 +--- !u!114 &3310961320254260425 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4080157917815310858} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.972549, g: 0, b: 0.63497144, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!114 &4132265620032504676 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4080157917815310858} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 3310961320254260425} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 0} + m_MethodName: OnClick_Play + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null --- !u!1 &5195354181250555041 GameObject: m_ObjectHideFlags: 0 @@ -1204,6 +1493,7 @@ RectTransform: m_Children: - {fileID: 5195354181250555040} - {fileID: 5195354183157824117} + - {fileID: 2052082028810034629} m_Father: {fileID: 5195354182462625304} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1472,6 +1762,9 @@ MonoBehaviour: Prefab: {fileID: 6973439230367005604, guid: f1daf3f500b22a048bbbad4287c2fcb2, type: 3} insertIndex: -1 content: {fileID: 5195354181806561359} + playButton: {fileID: 0} + returnButton: {fileID: 0} + border: {fileID: 0} maxLength: 6 reader: LogicChain: [] diff --git a/Assets/Scenes/Client Scenes/ClientScene.unity b/Assets/Scenes/Client Scenes/ClientScene.unity index 815c8b9..85317c8 100644 --- a/Assets/Scenes/Client Scenes/ClientScene.unity +++ b/Assets/Scenes/Client Scenes/ClientScene.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.44657898, g: 0.4964133, b: 0.5748178, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -112,6 +112,18 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &70099146 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 5195354181250555041, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + m_PrefabInstance: {fileID: 5195354181466942481} + m_PrefabAsset: {fileID: 0} +--- !u!1 &136803099 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 4080157917815310858, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + m_PrefabInstance: {fileID: 5195354181466942481} + m_PrefabAsset: {fileID: 0} --- !u!1 &1254212986 GameObject: m_ObjectHideFlags: 0 @@ -203,9 +215,24 @@ MonoBehaviour: Prefab: {fileID: 6973439230367005604, guid: f1daf3f500b22a048bbbad4287c2fcb2, type: 3} insertIndex: -1 content: {fileID: 1704581577} + playButton: {fileID: 70099146} + returnButton: {fileID: 136803099} + border: {fileID: 1324620582} maxLength: 6 reader: LogicChain: [] +--- !u!114 &1324620582 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + m_PrefabInstance: {fileID: 5195354181466942481} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1324620580} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1352513146 GameObject: m_ObjectHideFlags: 0 @@ -656,6 +683,26 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 2584547907285081931, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_isInputParsingRequired + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4132265620032504676, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 1324620581} + - target: {fileID: 4132265620032504676, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: OnClick_Return + objectReference: {fileID: 0} + - target: {fileID: 4080157917815310858, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 5195354182462625300, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_Name @@ -674,7 +721,7 @@ PrefabInstance: - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_AnchoredPosition.y - value: 0.000008220466 + value: 0.0000076293945 objectReference: {fileID: 0} - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} @@ -935,17 +982,17 @@ PrefabInstance: - target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_Color.r - value: 0.882353 + value: 0.8862745 objectReference: {fileID: 0} - target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_Color.g - value: 0.8862746 + value: 0.884576 objectReference: {fileID: 0} - target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_Color.b - value: 0.882353 + value: 0.88235295 objectReference: {fileID: 0} - target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} @@ -960,7 +1007,7 @@ PrefabInstance: - target: {fileID: 5195354183101525346, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_AspectRatio - value: 41.85203 + value: 12.0465555 objectReference: {fileID: 0} - target: {fileID: 5195354183134146559, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} @@ -1005,12 +1052,12 @@ PrefabInstance: - target: {fileID: 2665231841929910945, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_havePropertiesChanged - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 2665231841929910945, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_isInputParsingRequired - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 2665231841929910945, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} @@ -1040,12 +1087,12 @@ PrefabInstance: - target: {fileID: 5195354181796512270, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_havePropertiesChanged - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 5195354181796512270, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} propertyPath: m_isInputParsingRequired - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 5195354182925078847, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} diff --git a/Assets/Scripts/Logic/Blocks/CombinedBlock.cs b/Assets/Scripts/Logic/Blocks/CombinedBlock.cs index 6ceb1c3..dc4bc26 100644 --- a/Assets/Scripts/Logic/Blocks/CombinedBlock.cs +++ b/Assets/Scripts/Logic/Blocks/CombinedBlock.cs @@ -9,15 +9,25 @@ public class CombinedBlock : LogicBlock #region Inspector Variables [SerializeField] [Tooltip("Is this block editable")] - protected bool isEditable = false; + public bool isEditable = false; [SerializeField] [Tooltip("Blocks this will run through")] - protected BlockReader blockReader; + public BlockReader blockReader = new BlockReader(); #endregion Inspector Variables #region Private Variables + public override int Size() + { + if (!isEditable) + return 1; + + int retVal = 1; + foreach(LogicBlock block in blockReader.LogicChain) + retVal += block.Size(); + return retVal; + } #endregion Private Variables @@ -60,10 +70,29 @@ public class CombinedBlock : LogicBlock blockReader.Reset(); } + public override LogicBlock[] GetAllBlocks() + { + if (!isEditable) + return new LogicBlock[] { this }; + + List retVal = new List(); + retVal.Add(this); + + foreach (LogicBlock block in blockReader.LogicChain) + retVal.AddRange(block.GetAllBlocks()); - public override void OnDoubleClick() + return retVal.ToArray(); + } + + public override LogicBlock Clone() { - base.OnDoubleClick(); + CombinedBlock retVal = base.Clone() as CombinedBlock; + retVal.blockReader = new BlockReader(); + + foreach (LogicBlock block in blockReader.LogicChain) + retVal.blockReader.Add(block.Clone()); + + return retVal; } #region Serialisation Functions diff --git a/Assets/Scripts/Logic/Blocks/LogicBlock.cs b/Assets/Scripts/Logic/Blocks/LogicBlock.cs index 232c323..8b78e6f 100644 --- a/Assets/Scripts/Logic/Blocks/LogicBlock.cs +++ b/Assets/Scripts/Logic/Blocks/LogicBlock.cs @@ -154,11 +154,20 @@ public abstract class LogicBlock : ScriptableObject && string.Equals(name, otherLogic.name); } - public virtual void OnDoubleClick() + public virtual LogicBlock Clone() { + LogicBlock retVal = Instantiate(this); + retVal.name = this.name; + return retVal; } + public virtual LogicBlock[] GetAllBlocks() + { + return new LogicBlock[] { this }; + } + + #endregion Class Functions } diff --git a/Assets/Scripts/UI/BagItem.cs b/Assets/Scripts/UI/BagItem.cs index c615914..f5607f1 100644 --- a/Assets/Scripts/UI/BagItem.cs +++ b/Assets/Scripts/UI/BagItem.cs @@ -93,9 +93,9 @@ public class BagItem : LogicElementHolder /// /// element to check if it can hold /// returns true if this can hold the element - public override bool canHold(LogicElementUI element) + public override bool canHold(LogicBlock element) { - return element.logicElement.isSameType(InventoryData.element); + return element.isSameType(InventoryData.element); } /// diff --git a/Assets/Scripts/UI/ILogicElementHolder.cs b/Assets/Scripts/UI/ILogicElementHolder.cs index dfefe7e..7b2aa74 100644 --- a/Assets/Scripts/UI/ILogicElementHolder.cs +++ b/Assets/Scripts/UI/ILogicElementHolder.cs @@ -73,7 +73,7 @@ public abstract class LogicElementHolder : MonoBehaviour /// /// element to check if it can hold /// returns true if this can hold the element - public virtual bool canHold(LogicElementUI element) { return true; } + public virtual bool canHold(LogicBlock element) { return true; } #endregion Class Funtions diff --git a/Assets/Scripts/UI/InventoryCatch.cs b/Assets/Scripts/UI/InventoryCatch.cs index 28be0eb..23eaa73 100644 --- a/Assets/Scripts/UI/InventoryCatch.cs +++ b/Assets/Scripts/UI/InventoryCatch.cs @@ -10,12 +10,16 @@ public class InventoryCatch : LogicElementHolder public override void OnAdd(LogicElementUI element) { - BagItem item = InventoryUI.content.FirstOrDefault(p => p.canHold(element)); + foreach (LogicBlock block in element.logicElement.GetAllBlocks()) + { - if (item != default) - item.OnAdd(element); + BagItem item = InventoryUI.content.FirstOrDefault(p => p.canHold(block)); - Destroy(element.gameObject); + if (item != default) + item.OnAdd(element); + + Destroy(element.gameObject); + } } public override void OnDoubleClick(LogicElementUI element) diff --git a/Assets/Scripts/UI/LogicElementUI.cs b/Assets/Scripts/UI/LogicElementUI.cs index e478116..8d184f5 100644 --- a/Assets/Scripts/UI/LogicElementUI.cs +++ b/Assets/Scripts/UI/LogicElementUI.cs @@ -69,7 +69,7 @@ public class LogicElementUI : Dragable public virtual void Initialise(LogicBlock LogicElement, LogicElementHolder Holder) { - this.LogicElement = LogicElement; + this.LogicElement = LogicElement.Clone(); currentHolder = Holder; } #endregion Class Implementation @@ -120,9 +120,9 @@ public class LogicElementUI : Dragable //order the UIHolders by priority and get the first which will accept this lastHover = lastHover.OrderByDescending(p => p.Priority).ToList(); - + lastHover.ForEach(p => Debug.Log(p.gameObject.name)); - LogicElementHolder holderToAdd = lastHover.FirstOrDefault(p => p.canHold(this)); + LogicElementHolder holderToAdd = lastHover.FirstOrDefault(p => p.canHold(LogicElement)); //If we are still hovering over anything add this to it //Else add it back to where it came from diff --git a/Assets/Scripts/UI/LogicTrayUI.cs b/Assets/Scripts/UI/LogicTrayUI.cs index dd7a39a..ef93f4a 100644 --- a/Assets/Scripts/UI/LogicTrayUI.cs +++ b/Assets/Scripts/UI/LogicTrayUI.cs @@ -15,21 +15,38 @@ public class LogicTrayUI : LogicElementHolder protected int insertIndex = -1; [SerializeField] private Transform content; + + [SerializeField] + private GameObject playButton; + [SerializeField] + private GameObject returnButton; + [SerializeField] + private Image border; + [SerializeField] private int maxLength = 6; [SerializeField] public BlockReader reader; + [SerializeField] + private List readerQueue = new List(); + #region Unity Functions public void Start() { + + readerQueue.Add(new QueueData(null, reader, border.color)); + UpdateDisplay(); + + } protected override void OnEnable() { base.OnEnable(); + if (reader != null) reader.OnUpdate += UpdateDisplay; } @@ -52,6 +69,27 @@ public class LogicTrayUI : LogicElementHolder UpdateDisplay(); } + public void OnClick_Return() + { + if (readerQueue.Count <= 1) + return; + + QueueData lastData = readerQueue[readerQueue.Count - 1]; + readerQueue.RemoveAt(readerQueue.Count - 1); + + lastData.block.blockReader.LogicChain = new List(lastData.reader.LogicChain); + + + + border.color = readerQueue[readerQueue.Count - 1].color; + readerQueue[readerQueue.Count - 1].reader.LogicChain = new List(reader.LogicChain); + SetBlockReader(readerQueue[readerQueue.Count - 1].reader); + + + UpdateDisplay(); + + } + [ContextMenu("Update Display")] public void UpdateDisplay() { @@ -90,6 +128,9 @@ public class LogicTrayUI : LogicElementHolder elementObject.transform.SetSiblingIndex(destroyedCount + insertIndex); } + playButton.SetActive(readerQueue.Count <= 1); + returnButton.SetActive(readerQueue.Count > 1); + } @@ -165,7 +206,14 @@ public class LogicTrayUI : LogicElementHolder /// element which was double clicked public override void OnDoubleClick(LogicElementUI element) { - throw new System.NotImplementedException(); + CombinedBlock block = element.logicElement as CombinedBlock; + if (block == null || !block.isEditable) + return; + + readerQueue.Add(new QueueData(block,reader,block.Color)); + + border.color = block.Color; + SetBlockReader(block.blockReader); } /// @@ -173,7 +221,7 @@ public class LogicTrayUI : LogicElementHolder /// /// element to check if it can hold /// returns true if this can hold the element - public override bool canHold(LogicElementUI element) + public override bool canHold(LogicBlock element) { return reader.Length < maxLength; } @@ -212,4 +260,19 @@ public class LogicTrayUI : LogicElementHolder #endregion Helper Functions + [System.Serializable] + public class QueueData + { + public Color color; + public BlockReader reader; + public CombinedBlock block; + + public QueueData(CombinedBlock block, BlockReader reader, Color color) + { + this.color = color; + this.reader = reader; + this.block = block; + } + } + }