From 78fe02101448c12e79f4d1d531f1790221453829 Mon Sep 17 00:00:00 2001 From: klemek Date: Tue, 15 Dec 2020 14:28:00 +0100 Subject: [PATCH] working toolbar --- Assets/Prefabs/UI Gate.prefab | 126 +++++++ Assets/Prefabs/UI Gate.prefab.meta | 7 + Assets/Scenes/Workspace.unity | 540 ++-------------------------- Assets/Scripts/GameManager.cs | 13 + Assets/Scripts/Gate.cs | 14 +- Assets/Scripts/MouseManager.cs | 50 ++- Assets/Scripts/UI.meta | 8 + Assets/Scripts/UI/UIGate.cs | 67 ++++ Assets/Scripts/UI/UIGate.cs.meta | 11 + Assets/Scripts/UI/UIManager.cs | 67 ++++ Assets/Scripts/UI/UIManager.cs.meta | 11 + 11 files changed, 386 insertions(+), 528 deletions(-) create mode 100755 Assets/Prefabs/UI Gate.prefab create mode 100755 Assets/Prefabs/UI Gate.prefab.meta create mode 100755 Assets/Scripts/UI.meta create mode 100755 Assets/Scripts/UI/UIGate.cs create mode 100755 Assets/Scripts/UI/UIGate.cs.meta create mode 100755 Assets/Scripts/UI/UIManager.cs create mode 100755 Assets/Scripts/UI/UIManager.cs.meta diff --git a/Assets/Prefabs/UI Gate.prefab b/Assets/Prefabs/UI Gate.prefab new file mode 100755 index 0000000..4111ff8 --- /dev/null +++ b/Assets/Prefabs/UI Gate.prefab @@ -0,0 +1,126 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &7325205278540948172 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5918716415944322838} + - component: {fileID: 7428085258827749561} + - component: {fileID: 6261246541132972746} + - component: {fileID: 7325205278540948175} + - component: {fileID: 5409402217447883743} + m_Layer: 5 + m_Name: UI Gate + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5918716415944322838 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7325205278540948172} + 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: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0, y: 0.5} +--- !u!222 &7428085258827749561 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7325205278540948172} + m_CullTransparentMesh: 0 +--- !u!114 &6261246541132972746 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7325205278540948172} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ef8b96895a0ec4ba685178a052544251, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: 8d66e65c66e29504199ed664979682cd, type: 2} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_PreserveAspect: 1 +--- !u!114 &7325205278540948175 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7325205278540948172} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6a451c18bcd06994d8ac3b549cff313d, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &5409402217447883743 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7325205278540948172} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, 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: 0 + 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_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, 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_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 6261246541132972746} + m_OnClick: + m_PersistentCalls: + m_Calls: [] diff --git a/Assets/Prefabs/UI Gate.prefab.meta b/Assets/Prefabs/UI Gate.prefab.meta new file mode 100755 index 0000000..d059c6f --- /dev/null +++ b/Assets/Prefabs/UI Gate.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: eccdec2d2494caa4ba1b906d71a760f8 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Workspace.unity b/Assets/Scenes/Workspace.unity index e144b30..872d485 100755 --- a/Assets/Scenes/Workspace.unity +++ b/Assets/Scenes/Workspace.unity @@ -123,73 +123,6 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!4 &10086102 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - m_PrefabInstance: {fileID: 1005212156} - m_PrefabAsset: {fileID: 0} ---- !u!1001 &51242685 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 297330684} - m_Modifications: - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_RootOrder - value: 4 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalPosition.x - value: -10 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalPosition.y - value: -10 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4202092108985620497, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - propertyPath: m_Name - value: OR gate - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} ---- !u!4 &107099241 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - m_PrefabInstance: {fileID: 975258578} - m_PrefabAsset: {fileID: 0} --- !u!1 &155822103 GameObject: m_ObjectHideFlags: 0 @@ -272,63 +205,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &225124962 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 297330684} - m_Modifications: - - target: {fileID: 7740356803889805974, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_Name - value: AND gate - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_RootOrder - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalPosition.x - value: -10 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalPosition.y - value: 10 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} --- !u!1 &297330683 GameObject: m_ObjectHideFlags: 0 @@ -355,14 +231,7 @@ Transform: 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: - - {fileID: 805769444} - - {fileID: 1479023136} - - {fileID: 1512123881} - - {fileID: 10086102} - - {fileID: 2004906720} - - {fileID: 1853814771} - - {fileID: 107099241} + m_Children: [] m_Father: {fileID: 1741727034} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -378,13 +247,14 @@ GameObject: - component: {fileID: 431027839} - component: {fileID: 431027838} - component: {fileID: 431027837} + - component: {fileID: 431027841} m_Layer: 5 m_Name: Canvas m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!114 &431027837 MonoBehaviour: m_ObjectHideFlags: 0 @@ -465,6 +335,20 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!114 &431027841 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 431027836} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3124eabb2ea5e3547bf503bdcc463cb6, type: 3} + m_Name: + m_EditorClassIdentifier: + GateBar: {fileID: 881209084} + UIGatePrefab: {fileID: 7325205278540948175, guid: eccdec2d2494caa4ba1b906d71a760f8, type: 3} --- !u!1 &519420028 GameObject: m_ObjectHideFlags: 0 @@ -600,6 +484,14 @@ MonoBehaviour: CablesGroup: {fileID: 1929026276} DeadColor: {r: 0, g: 0.20240787, b: 0.262, a: 1} ActivatedColor: {r: 0, g: 0.7725491, b: 1, a: 1} + GatePrefabs: + - {fileID: 395496744302543944, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} + - {fileID: 5414015581782372340, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} + - {fileID: 1880784449839238515, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} + - {fileID: 1598869823234492652, guid: e5170b18be775644e8f56c93d402a270, type: 3} + - {fileID: 6236349114868766289, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} + - {fileID: 6979581962575144672, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} + - {fileID: 3834481072508960832, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} --- !u!4 &535412053 Transform: m_ObjectHideFlags: 0 @@ -692,11 +584,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &805769444 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 8287754163135265989, guid: f9d4ead6b60b0ac4ca6d566c674c515d, type: 3} - m_PrefabInstance: {fileID: 225124962} - m_PrefabAsset: {fileID: 0} --- !u!1 &816332482 GameObject: m_ObjectHideFlags: 0 @@ -783,7 +670,7 @@ GameObject: - component: {fileID: 881209087} - component: {fileID: 881209086} m_Layer: 5 - m_Name: Panel + m_Name: GateBar m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -799,8 +686,7 @@ RectTransform: 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: - - {fileID: 1217241478779729083} + m_Children: [] m_Father: {fileID: 431027840} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -847,244 +733,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 881209084} m_CullTransparentMesh: 0 ---- !u!1001 &975258578 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 297330684} - m_Modifications: - - target: {fileID: 4653699648936194946, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_Name - value: XOR gate - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_RootOrder - value: 6 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalPosition.x - value: 10 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalPosition.y - value: -10 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6411439409125897681, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 9993fd3a92f426c40a9eb291a8224b89, type: 3} ---- !u!1001 &1005212156 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 297330684} - m_Modifications: - - target: {fileID: 2680804846365987114, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_Name - value: NOT gate - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_RootOrder - value: 3 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalPosition.x - value: 10 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalPosition.y - value: 10 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4421233893283878777, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 7f0ed90de4f8dcf4cb3b8bd1f47a6c55, type: 3} ---- !u!1001 &1079988228 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 297330684} - m_Modifications: - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_RootOrder - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalPosition.x - value: -10 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3925278906827644302, guid: e5170b18be775644e8f56c93d402a270, type: 3} - propertyPath: m_Name - value: NAND gate - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: e5170b18be775644e8f56c93d402a270, type: 3} ---- !u!1001 &1270478718 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 297330684} - m_Modifications: - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_RootOrder - value: 5 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalPosition.y - value: -10 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1549211627363718434, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - propertyPath: m_Name - value: XNOR gate - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} ---- !u!4 &1479023136 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 3320882863441419229, guid: e5170b18be775644e8f56c93d402a270, type: 3} - m_PrefabInstance: {fileID: 1079988228} - m_PrefabAsset: {fileID: 0} ---- !u!4 &1512123881 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - m_PrefabInstance: {fileID: 1954114439} - m_PrefabAsset: {fileID: 0} --- !u!1 &1741727033 GameObject: m_ObjectHideFlags: 0 @@ -1149,11 +797,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &1853814771 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 941435685669917553, guid: 04e2cfd7b9447984d870b9a310e41070, type: 3} - m_PrefabInstance: {fileID: 1270478718} - m_PrefabAsset: {fileID: 0} --- !u!1 &1929026275 GameObject: m_ObjectHideFlags: 0 @@ -1184,132 +827,3 @@ Transform: m_Father: {fileID: 1741727034} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &1954114439 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 297330684} - m_Modifications: - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_RootOrder - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalPosition.y - value: 10 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 7975171831931028832, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8557615023715992371, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} - propertyPath: m_Name - value: NOR gate - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: b96d09631ef08604ea83f8843ce8563e, type: 3} ---- !u!4 &2004906720 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 2467855508822777410, guid: 426ccfa3b75c9644c80250677d1089f6, type: 3} - m_PrefabInstance: {fileID: 51242685} - m_PrefabAsset: {fileID: 0} ---- !u!224 &1217241478779729083 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2841587710459967841} - 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: 881209085} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0.5} - m_AnchorMax: {x: 0, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0, y: 0.5} ---- !u!114 &1451119067371198823 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2841587710459967841} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ef8b96895a0ec4ba685178a052544251, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 2100000, guid: 8d66e65c66e29504199ed664979682cd, type: 2} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 3286163911610860551, guid: dd1159e4e096fd24695274a28f36162e, type: 3} - m_PreserveAspect: 1 ---- !u!222 &2725486721643135764 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2841587710459967841} - m_CullTransparentMesh: 0 ---- !u!1 &2841587710459967841 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1217241478779729083} - - component: {fileID: 2725486721643135764} - - component: {fileID: 1451119067371198823} - m_Layer: 0 - m_Name: ui_nand - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index bd39b82..fef4b77 100755 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -27,6 +27,9 @@ namespace UntitledLogicGame public Color DeadColor; public Color ActivatedColor; + [Header("Gates")] + public List GatePrefabs; + #endregion #region Public Properties @@ -35,6 +38,8 @@ namespace UntitledLogicGame public Gate CurrentGate { get; set; } + public MouseManager MouseManager { get; private set; } + #endregion #region Private Properties @@ -49,6 +54,7 @@ namespace UntitledLogicGame if (Instance != null) throw new InvalidOperationException("More than one GameManager in scene"); Instance = this; + MouseManager = GetComponent(); } // Update is called once per frame @@ -61,6 +67,13 @@ namespace UntitledLogicGame #region Public Methods + public void CreateGate(Gate gatePrefab, Vector3 position) + { + var gate = Instantiate(gatePrefab, GatesGroup); + gate.transform.position = MouseManager.MousePos - gate.Box.transform.position; + MouseManager.DragGate(gate, true); + } + #endregion #region Private Methods diff --git a/Assets/Scripts/Gate.cs b/Assets/Scripts/Gate.cs index 0234848..5858a78 100755 --- a/Assets/Scripts/Gate.cs +++ b/Assets/Scripts/Gate.cs @@ -17,9 +17,17 @@ namespace UntitledLogicGame #region Public Properties - public List Anchors { get; set; } + public List Anchors { get; private set; } public IEnumerable InputAnchors => Anchors.Where(a => a.IsInput); public IEnumerable OutputAnchors => Anchors.Where(a => !a.IsInput); + public BoxCollider2D Box { + get + { + if (_box == null) + _box = GetComponentInChildren(); + return _box; + } + } #endregion @@ -27,6 +35,7 @@ namespace UntitledLogicGame private GateDefinition _definition; private int _lastState = -1; + private BoxCollider2D _box; #endregion @@ -36,7 +45,7 @@ namespace UntitledLogicGame { Utils.RandomName(GateType.ToString(), gameObject); Anchors = GetComponentsInChildren().ToList(); - _definition = GateDefinition.Get(GateType, this); + _definition = GateDefinition.Get(GateType, this); } // Update is called once per frame @@ -48,7 +57,6 @@ namespace UntitledLogicGame _definition.Compute(this); _lastState = state; } - } #endregion diff --git a/Assets/Scripts/MouseManager.cs b/Assets/Scripts/MouseManager.cs index 167f072..27f50d3 100755 --- a/Assets/Scripts/MouseManager.cs +++ b/Assets/Scripts/MouseManager.cs @@ -7,6 +7,12 @@ namespace UntitledLogicGame { public class MouseManager : MonoBehaviour { + #region Static Properties + + public static MouseManager Instance => GameManager.Instance.MouseManager; + + #endregion + #region Unity Properties #endregion @@ -15,6 +21,10 @@ namespace UntitledLogicGame public static Vector3 MousePos { get; set; } + public bool Interacting => _currentCable != null || _currentGate != null; + + public static bool Clicking => Input.GetButton("Fire1"); + #endregion #region Private Properties @@ -39,7 +49,7 @@ namespace UntitledLogicGame mousePos.z = 0f; MousePos = mousePos; - if (Input.GetMouseButton(0)) + if (Clicking) { if(_currentCable == null) { @@ -54,13 +64,7 @@ namespace UntitledLogicGame } else if (GameManager.Instance.CurrentGate != null) { - _currentGate = GameManager.Instance.CurrentGate; - _currentGateDelta = MousePos - _currentGate.transform.position; - _currentGateInitialPos = _currentGate.transform.position; - foreach (var renderer in _currentGate.GetComponentsInChildren()) - { - renderer.sortingLayerName = "moving"; - } + DragGate(GameManager.Instance.CurrentGate, false); } } } @@ -83,12 +87,22 @@ namespace UntitledLogicGame renderer.sortingLayerName = "default"; } _currentGate.transform.position = _currentGate.transform.position.Round(); - var currentBox = _currentGate.GetComponentInChildren(); + var currentBox = _currentGate.Box; if (FindObjectsOfType() .Where(g => !g.Equals(_currentGate)) - .Select(g => g.GetComponentInChildren()) - .Any(b => currentBox.IsTouching(b))) // Collision with another gate - _currentGate.transform.position = _currentGateInitialPos; // Reset pos + .Select(g => g.Box) + .Any(b => currentBox.IsTouching(b))) + { + // Collision with another gate + if(_currentGateInitialPos == null) + { + Destroy(_currentGate.gameObject); + } + else + { + _currentGate.transform.position = _currentGateInitialPos; // Reset pos + } + } _currentGate = null; } } @@ -97,6 +111,18 @@ namespace UntitledLogicGame #region Public Methods + public void DragGate(Gate gate, bool created) + { + _currentGate = gate; + _currentGateDelta = MousePos - _currentGate.transform.position; + if(!created) + _currentGateInitialPos = _currentGate.transform.position; + foreach (var renderer in _currentGate.GetComponentsInChildren()) + { + renderer.sortingLayerName = "moving"; + } + } + #endregion #region Private Methods diff --git a/Assets/Scripts/UI.meta b/Assets/Scripts/UI.meta new file mode 100755 index 0000000..c061c53 --- /dev/null +++ b/Assets/Scripts/UI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac8985c980f48e84594b68ae9051ce1d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/UIGate.cs b/Assets/Scripts/UI/UIGate.cs new file mode 100755 index 0000000..3073ef5 --- /dev/null +++ b/Assets/Scripts/UI/UIGate.cs @@ -0,0 +1,67 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.VectorGraphics; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace UntitledLogicGame.UI +{ + public class UIGate : MonoBehaviour, IPointerDownHandler + { + #region Unity Properties + + #endregion + + #region Public Properties + + public Gate GatePrefab { + set + { + _gatePrefab = value; + var sprite = _gatePrefab.GetComponentInChildren().sprite; + GetComponent().sprite = sprite; + RectTransform.sizeDelta = new Vector2(100 * sprite.rect.width / 700f, 100); // TODO get max width from UIManager + gameObject.name = "UI_" + _gatePrefab.GateType.ToString(); + } + } + + public RectTransform RectTransform + { + get + { + if (_rectTransform == null) + _rectTransform = GetComponent(); + return _rectTransform; + } + } + + #endregion + + #region Private Properties + + private Gate _gatePrefab; + private RectTransform _rectTransform; + + #endregion + + #region Unity Methods + + public void OnPointerDown(PointerEventData eventData) + { + var position = Camera.main.ScreenToWorldPoint(transform.position); + position.z = 0f; + GameManager.Instance.CreateGate(_gatePrefab, position); + } + + #endregion + + #region Public Methods + + #endregion + + #region Private Methods + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/UIGate.cs.meta b/Assets/Scripts/UI/UIGate.cs.meta new file mode 100755 index 0000000..672e0a9 --- /dev/null +++ b/Assets/Scripts/UI/UIGate.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6a451c18bcd06994d8ac3b549cff313d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/UIManager.cs b/Assets/Scripts/UI/UIManager.cs new file mode 100755 index 0000000..94ad5d5 --- /dev/null +++ b/Assets/Scripts/UI/UIManager.cs @@ -0,0 +1,67 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +namespace UntitledLogicGame.UI +{ + public class UIManager : MonoBehaviour + { + #region Unity Properties + + [Header("Components")] + public GameObject GateBar; + + [Header("Prefabs")] + public UIGate UIGatePrefab; + + #endregion + + #region Public Properties + + #endregion + + #region Private Properties + + private bool _lastMouseInteracting; + + #endregion + + #region Unity Methods + + private IEnumerator Start() + { + yield return new WaitUntil(() => GameManager.Instance != null); + // TODO calculate max width + var currentPos = 0f; + foreach(var gatePrefab in GameManager.Instance.GatePrefabs) + { + var uiGate = Instantiate(UIGatePrefab, GateBar.transform); + uiGate.GatePrefab = gatePrefab; + uiGate.RectTransform.anchoredPosition = new Vector2(currentPos, 0); + currentPos += uiGate.RectTransform.sizeDelta.x; + } + + } + + private void FixedUpdate() + { + if(MouseManager.Instance.Interacting != _lastMouseInteracting) + { + //TODO animate go down + GateBar.SetActive(!MouseManager.Instance.Interacting); + _lastMouseInteracting = MouseManager.Instance.Interacting; + } + } + + #endregion + + #region Public Methods + + #endregion + + #region Private Methods + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/UIManager.cs.meta b/Assets/Scripts/UI/UIManager.cs.meta new file mode 100755 index 0000000..5bd32f4 --- /dev/null +++ b/Assets/Scripts/UI/UIManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3124eabb2ea5e3547bf503bdcc463cb6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: