diff --git a/Assets/Prefabs/Anchor.prefab b/Assets/Prefabs/Anchor.prefab index 5463da2..8db5f78 100755 --- a/Assets/Prefabs/Anchor.prefab +++ b/Assets/Prefabs/Anchor.prefab @@ -99,6 +99,7 @@ MonoBehaviour: Name: IsInput: 0 ScaleIncrease: 1.5 + Orientation: {x: 0, y: 0} --- !u!58 &8643366489253547345 CircleCollider2D: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Cable.prefab b/Assets/Prefabs/Cable.prefab index 7d2f15d..a3d08b1 100755 --- a/Assets/Prefabs/Cable.prefab +++ b/Assets/Prefabs/Cable.prefab @@ -122,8 +122,8 @@ LineRenderer: m_Mode: 0 m_NumColorKeys: 2 m_NumAlphaKeys: 2 - numCornerVertices: 0 - numCapVertices: 0 + numCornerVertices: 90 + numCapVertices: 90 alignment: 0 textureMode: 0 shadowBias: 0.5 diff --git a/Assets/Prefabs/Gates/NAND gate.prefab b/Assets/Prefabs/Gates/NAND gate.prefab index c240d26..3036c53 100755 --- a/Assets/Prefabs/Gates/NAND gate.prefab +++ b/Assets/Prefabs/Gates/NAND gate.prefab @@ -229,6 +229,10 @@ PrefabInstance: propertyPath: IsInput value: 1 objectReference: {fileID: 0} + - target: {fileID: -7307756874029176930, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3} + propertyPath: Orientation.x + value: -1 + objectReference: {fileID: 0} - target: {fileID: 1824742176375353076, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3} propertyPath: m_Name value: A @@ -295,6 +299,10 @@ PrefabInstance: propertyPath: Name value: Q objectReference: {fileID: 0} + - target: {fileID: -7307756874029176930, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3} + propertyPath: Orientation.x + value: 1 + objectReference: {fileID: 0} - target: {fileID: 1824742176375353076, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3} propertyPath: m_Name value: Q @@ -365,6 +373,10 @@ PrefabInstance: propertyPath: IsInput value: 1 objectReference: {fileID: 0} + - target: {fileID: -7307756874029176930, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3} + propertyPath: Orientation.x + value: -1 + objectReference: {fileID: 0} - target: {fileID: 1824742176375353076, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3} propertyPath: m_Name value: B diff --git a/Assets/Scenes/Workspace.unity b/Assets/Scenes/Workspace.unity index df618b8..9625d46 100755 --- a/Assets/Scenes/Workspace.unity +++ b/Assets/Scenes/Workspace.unity @@ -490,11 +490,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} propertyPath: m_LocalPosition.x - value: -10.11 + value: -10 objectReference: {fileID: 0} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} propertyPath: m_LocalPosition.y - value: 2.82 + value: 3 objectReference: {fileID: 0} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} propertyPath: m_LocalPosition.z @@ -557,11 +557,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} propertyPath: m_LocalPosition.x - value: -10.26 + value: -10 objectReference: {fileID: 0} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} propertyPath: m_LocalPosition.y - value: -4.53 + value: -4 objectReference: {fileID: 0} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} propertyPath: m_LocalPosition.z diff --git a/Assets/Scripts/Anchor.cs b/Assets/Scripts/Anchor.cs index 3315b12..2f98738 100755 --- a/Assets/Scripts/Anchor.cs +++ b/Assets/Scripts/Anchor.cs @@ -11,7 +11,8 @@ namespace UntitledLogicGame public string Name; public bool IsInput; - public float ScaleIncrease; + public float ScaleIncrease; + public Vector2 Orientation; #endregion @@ -56,6 +57,7 @@ namespace UntitledLogicGame _scale = transform.localScale; _sprite = GetComponent(); Cables = new List(); + Orientation = Orientation.normalized; } // Update is called once per frame diff --git a/Assets/Scripts/Cable.cs b/Assets/Scripts/Cable.cs index 40aca4a..55dbaea 100755 --- a/Assets/Scripts/Cable.cs +++ b/Assets/Scripts/Cable.cs @@ -87,12 +87,61 @@ namespace UntitledLogicGame _line.endColor = Activated ? GameManager.Instance.ActivatedColor : GameManager.Instance.DeadColor; _lastActivated = Activated; } + + if(StartAnchor != null) + { + if (EndAnchor == null) + { + _line.positionCount = 2; + _line.SetPosition(0, StartAnchor.transform.position); + _line.SetPosition(1, MouseManager.MousePos); + } + else + { + var startPos = StartAnchor.transform.position; + var startOr = StartAnchor.Orientation; + var endPos = EndAnchor.transform.position; + var endOr = StartAnchor.Orientation; - var startPos = StartAnchor == null ? MouseManager.MousePos : StartAnchor.transform.position; - var endPos = EndAnchor == null ? MouseManager.MousePos : EndAnchor.transform.position; - _line.positionCount = 2; - _line.SetPosition(0, startPos); - _line.SetPosition(1, endPos); + _line.positionCount = 4; + _line.SetPosition(0, startPos); + + if (Mathf.Abs(startOr.x) > 0) + { + if (Mathf.Abs(endOr.x) > 0) + { + var middle = (startPos.x + endPos.x) / 2; + _line.SetPosition(1, new Vector3(middle, startPos.y, 0)); + _line.SetPosition(2, new Vector3(middle, endPos.y, 0)); + } + else + { + _line.SetPosition(1, new Vector3(startPos.x, endPos.y, 0)); + _line.SetPosition(2, new Vector3(startPos.x, endPos.y, 0)); + } + } + else + { + if (Mathf.Abs(endOr.x) > 0) + { + var middle = (startPos.y + endPos.y) / 2; + _line.SetPosition(1, new Vector3(startPos.x, middle, 0)); + _line.SetPosition(2, new Vector3(endPos.x, middle, 0)); + } + else + { + _line.SetPosition(1, new Vector3(endPos.x, startPos.y, 0)); + _line.SetPosition(2, new Vector3(endPos.x, startPos.y, 0)); + } + } + + _line.SetPosition(3, endPos); + } + } + else + { + _line.positionCount = 0; + } } private void OnDestroy()