diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node/NodeData.cs.meta b/Assets/Scripts/Roads/Node/NodeData.cs.meta new file mode 100644 index 0000000..73dcf56 --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf9bcd8c4889de4985e5d6a776acc5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node/NodeData.cs.meta b/Assets/Scripts/Roads/Node/NodeData.cs.meta new file mode 100644 index 0000000..73dcf56 --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf9bcd8c4889de4985e5d6a776acc5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs b/Assets/Scripts/Roads/Node/PermanentNode.cs new file mode 100644 index 0000000..968ec97 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PermanentNode : Node { + public PermanentNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + } +} diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node/NodeData.cs.meta b/Assets/Scripts/Roads/Node/NodeData.cs.meta new file mode 100644 index 0000000..73dcf56 --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf9bcd8c4889de4985e5d6a776acc5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs b/Assets/Scripts/Roads/Node/PermanentNode.cs new file mode 100644 index 0000000..968ec97 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PermanentNode : Node { + public PermanentNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + } +} diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs.meta b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta new file mode 100644 index 0000000..a5adc18 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41fd1df1cdde8fb4cb89e5b8fc36d423 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node/NodeData.cs.meta b/Assets/Scripts/Roads/Node/NodeData.cs.meta new file mode 100644 index 0000000..73dcf56 --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf9bcd8c4889de4985e5d6a776acc5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs b/Assets/Scripts/Roads/Node/PermanentNode.cs new file mode 100644 index 0000000..968ec97 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PermanentNode : Node { + public PermanentNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + } +} diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs.meta b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta new file mode 100644 index 0000000..a5adc18 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41fd1df1cdde8fb4cb89e5b8fc36d423 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs b/Assets/Scripts/Roads/Node/SpawnNode.cs new file mode 100644 index 0000000..8fd4a14 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SpawnNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node/NodeData.cs.meta b/Assets/Scripts/Roads/Node/NodeData.cs.meta new file mode 100644 index 0000000..73dcf56 --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf9bcd8c4889de4985e5d6a776acc5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs b/Assets/Scripts/Roads/Node/PermanentNode.cs new file mode 100644 index 0000000..968ec97 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PermanentNode : Node { + public PermanentNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + } +} diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs.meta b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta new file mode 100644 index 0000000..a5adc18 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41fd1df1cdde8fb4cb89e5b8fc36d423 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs b/Assets/Scripts/Roads/Node/SpawnNode.cs new file mode 100644 index 0000000..8fd4a14 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SpawnNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs.meta b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta new file mode 100644 index 0000000..751f503 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 71fd0b84cdaf65f48998acd1412e970e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node/NodeData.cs.meta b/Assets/Scripts/Roads/Node/NodeData.cs.meta new file mode 100644 index 0000000..73dcf56 --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf9bcd8c4889de4985e5d6a776acc5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs b/Assets/Scripts/Roads/Node/PermanentNode.cs new file mode 100644 index 0000000..968ec97 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PermanentNode : Node { + public PermanentNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + } +} diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs.meta b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta new file mode 100644 index 0000000..a5adc18 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41fd1df1cdde8fb4cb89e5b8fc36d423 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs b/Assets/Scripts/Roads/Node/SpawnNode.cs new file mode 100644 index 0000000..8fd4a14 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SpawnNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs.meta b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta new file mode 100644 index 0000000..751f503 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 71fd0b84cdaf65f48998acd1412e970e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/NodeData.cs b/Assets/Scripts/Roads/NodeData.cs deleted file mode 100644 index 9ee8ace..0000000 --- a/Assets/Scripts/Roads/NodeData.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class NodeData : MonoBehaviour { - public Node node = null; -} diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node/NodeData.cs.meta b/Assets/Scripts/Roads/Node/NodeData.cs.meta new file mode 100644 index 0000000..73dcf56 --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf9bcd8c4889de4985e5d6a776acc5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs b/Assets/Scripts/Roads/Node/PermanentNode.cs new file mode 100644 index 0000000..968ec97 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PermanentNode : Node { + public PermanentNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + } +} diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs.meta b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta new file mode 100644 index 0000000..a5adc18 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41fd1df1cdde8fb4cb89e5b8fc36d423 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs b/Assets/Scripts/Roads/Node/SpawnNode.cs new file mode 100644 index 0000000..8fd4a14 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SpawnNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs.meta b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta new file mode 100644 index 0000000..751f503 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 71fd0b84cdaf65f48998acd1412e970e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/NodeData.cs b/Assets/Scripts/Roads/NodeData.cs deleted file mode 100644 index 9ee8ace..0000000 --- a/Assets/Scripts/Roads/NodeData.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class NodeData : MonoBehaviour { - public Node node = null; -} diff --git a/Assets/Scripts/Roads/NodeData.cs.meta b/Assets/Scripts/Roads/NodeData.cs.meta deleted file mode 100644 index 73dcf56..0000000 --- a/Assets/Scripts/Roads/NodeData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4cf9bcd8c4889de4985e5d6a776acc5b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node/NodeData.cs.meta b/Assets/Scripts/Roads/Node/NodeData.cs.meta new file mode 100644 index 0000000..73dcf56 --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf9bcd8c4889de4985e5d6a776acc5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs b/Assets/Scripts/Roads/Node/PermanentNode.cs new file mode 100644 index 0000000..968ec97 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PermanentNode : Node { + public PermanentNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + } +} diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs.meta b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta new file mode 100644 index 0000000..a5adc18 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41fd1df1cdde8fb4cb89e5b8fc36d423 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs b/Assets/Scripts/Roads/Node/SpawnNode.cs new file mode 100644 index 0000000..8fd4a14 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SpawnNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs.meta b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta new file mode 100644 index 0000000..751f503 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 71fd0b84cdaf65f48998acd1412e970e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/NodeData.cs b/Assets/Scripts/Roads/NodeData.cs deleted file mode 100644 index 9ee8ace..0000000 --- a/Assets/Scripts/Roads/NodeData.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class NodeData : MonoBehaviour { - public Node node = null; -} diff --git a/Assets/Scripts/Roads/NodeData.cs.meta b/Assets/Scripts/Roads/NodeData.cs.meta deleted file mode 100644 index 73dcf56..0000000 --- a/Assets/Scripts/Roads/NodeData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4cf9bcd8c4889de4985e5d6a776acc5b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Road.cs b/Assets/Scripts/Roads/Road.cs index 1ad1a74..57cd7cf 100644 --- a/Assets/Scripts/Roads/Road.cs +++ b/Assets/Scripts/Roads/Road.cs @@ -85,4 +85,16 @@ public override int GetHashCode() { return nodes[0].GetHashCode() << 16 | nodes[1].GetHashCode(); } + + public void delete() { + foreach (Node node in nodes) { + node.roads.Remove(this); + if (node.roads.Count == 0) { + node.delete(); + } else { + node.update(); + } + } + GameObject.Destroy(gameObject); + } } diff --git a/Assets/Scripts/Roads/Node.cs b/Assets/Scripts/Roads/Node.cs deleted file mode 100644 index 3b2f31a..0000000 --- a/Assets/Scripts/Roads/Node.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Node { - private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); - private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); - - public Vector3 position; - public List roads = new List(); - public GameObject gameObject; - - public Node(Vector3 position, Transform parent, Config config) { - gameObject = new GameObject(); - gameObject.transform.position = position; - gameObject.transform.parent = parent; - gameObject.AddComponent().radius = 2f; - gameObject.layer = 7; - gameObject.AddComponent().node = this; - - GameObject nodeCircle = new GameObject(); - nodeCircle.AddComponent().material = config.roadEditMaterial; - nodeCircle.AddComponent().mesh = circle.mesh; - nodeCircle.transform.parent = gameObject.transform; - nodeCircle.transform.localPosition = Vector3.zero; - - GameObject nodeRoad = new GameObject(); - nodeRoad.AddComponent().material = config.roadMaterial; - nodeRoad.AddComponent().mesh = fullCircle.mesh; - nodeRoad.transform.parent = gameObject.transform; - nodeRoad.transform.localPosition = Vector3.zero; - this.position = position; - } - - public Node getOther(Node caller) { - if (roads.Count != 2) { - return null; - } - foreach (Road road in roads) { - if (! road.nodes.Contains(caller)) { - return road.nodes.Find(test => test != this); - } - } - return null; - } - - override public int GetHashCode() { - return position.GetHashCode(); - } - - override public bool Equals(object other) { - if ((other == null) || ! this.GetType().Equals(other.GetType())) { - return false; - } - if (other == this) { - return true; - } - return ((Node)other).position.Equals(position); - } - - public void pull(Vector3 position) { - this.position = position; - gameObject.transform.position = position; - foreach (Road road in roads) { - road.update(true); - } - } - - public void lateUpdate(Road caller) { - foreach (Road road in roads) { - if (!road.Equals(caller)) { - road.update(false); - } - } - } - - public void update() { - foreach (Road road in roads) { - road.update(true); - } - } -} diff --git a/Assets/Scripts/Roads/Node.cs.meta b/Assets/Scripts/Roads/Node.cs.meta deleted file mode 100644 index 8bbedf1..0000000 --- a/Assets/Scripts/Roads/Node.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3cbed1dad7ec67d4dbe8602aea1e2979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node.meta b/Assets/Scripts/Roads/Node.meta new file mode 100644 index 0000000..32bbe9b --- /dev/null +++ b/Assets/Scripts/Roads/Node.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ac38b1c1d8b9c6448864218dbacf642 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs b/Assets/Scripts/Roads/Node/CustomNode.cs new file mode 100644 index 0000000..8abdf35 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CustomNode : Node { + public CustomNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + foreach (Road road in roads) { + road.nodes.Remove(this); + road.delete(); + } + GameObject.Destroy(gameObject); + } +} diff --git a/Assets/Scripts/Roads/Node/CustomNode.cs.meta b/Assets/Scripts/Roads/Node/CustomNode.cs.meta new file mode 100644 index 0000000..bdd6591 --- /dev/null +++ b/Assets/Scripts/Roads/Node/CustomNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ffe37851a1b2e6479ab34b6b2cc0829 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs b/Assets/Scripts/Roads/Node/ExitNode.cs new file mode 100644 index 0000000..033d3a1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ExitNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/ExitNode.cs.meta b/Assets/Scripts/Roads/Node/ExitNode.cs.meta new file mode 100644 index 0000000..5632cc4 --- /dev/null +++ b/Assets/Scripts/Roads/Node/ExitNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 42b9d9ab3d3a7f54390b6f12f991b39d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/Node.cs b/Assets/Scripts/Roads/Node/Node.cs new file mode 100644 index 0000000..0f254ec --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public abstract class Node { + private FlatCircleRenderer circle = new FlatCircleRenderer(0.2f, 0.05f, 32); + private FlatCircleRenderer fullCircle = new FlatCircleRenderer(0f, 1f, 32); + + public Vector3 position; + public List roads = new List(); + public GameObject gameObject; + + public Node(Vector3 position, Transform parent, Config config) { + gameObject = new GameObject(); + gameObject.transform.position = position; + gameObject.transform.parent = parent; + gameObject.AddComponent().radius = 2f; + gameObject.layer = 7; + gameObject.AddComponent().node = this; + + GameObject nodeCircle = new GameObject(); + nodeCircle.AddComponent().material = config.roadEditMaterial; + nodeCircle.AddComponent().mesh = circle.mesh; + nodeCircle.transform.parent = gameObject.transform; + nodeCircle.transform.localPosition = Vector3.zero; + + GameObject nodeRoad = new GameObject(); + nodeRoad.AddComponent().material = config.roadMaterial; + nodeRoad.AddComponent().mesh = fullCircle.mesh; + nodeRoad.transform.parent = gameObject.transform; + nodeRoad.transform.localPosition = Vector3.zero; + this.position = position; + } + + public Node getOther(Node caller) { + if (roads.Count != 2) { + return null; + } + foreach (Road road in roads) { + if (! road.nodes.Contains(caller)) { + return road.nodes.Find(test => test != this); + } + } + return null; + } + + override public int GetHashCode() { + return position.GetHashCode(); + } + + override public bool Equals(object other) { + if ((other == null) || ! this.GetType().Equals(other.GetType())) { + return false; + } + if (other == this) { + return true; + } + return ((Node)other).position.Equals(position); + } + + public void pull(Vector3 position) { + this.position = position; + gameObject.transform.position = position; + foreach (Road road in roads) { + road.update(true); + } + } + + public void lateUpdate(Road caller) { + foreach (Road road in roads) { + if (!road.Equals(caller)) { + road.update(false); + } + } + } + + public void update() { + foreach (Road road in roads) { + road.update(true); + } + } + + public abstract void delete(); +} diff --git a/Assets/Scripts/Roads/Node/Node.cs.meta b/Assets/Scripts/Roads/Node/Node.cs.meta new file mode 100644 index 0000000..8bbedf1 --- /dev/null +++ b/Assets/Scripts/Roads/Node/Node.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3cbed1dad7ec67d4dbe8602aea1e2979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/NodeData.cs b/Assets/Scripts/Roads/Node/NodeData.cs new file mode 100644 index 0000000..9ee8ace --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class NodeData : MonoBehaviour { + public Node node = null; +} diff --git a/Assets/Scripts/Roads/Node/NodeData.cs.meta b/Assets/Scripts/Roads/Node/NodeData.cs.meta new file mode 100644 index 0000000..73dcf56 --- /dev/null +++ b/Assets/Scripts/Roads/Node/NodeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf9bcd8c4889de4985e5d6a776acc5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs b/Assets/Scripts/Roads/Node/PermanentNode.cs new file mode 100644 index 0000000..968ec97 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PermanentNode : Node { + public PermanentNode(Vector3 position, Transform parent, Config config): base(position, parent, config) { + } + + override public void delete() { + } +} diff --git a/Assets/Scripts/Roads/Node/PermanentNode.cs.meta b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta new file mode 100644 index 0000000..a5adc18 --- /dev/null +++ b/Assets/Scripts/Roads/Node/PermanentNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41fd1df1cdde8fb4cb89e5b8fc36d423 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs b/Assets/Scripts/Roads/Node/SpawnNode.cs new file mode 100644 index 0000000..8fd4a14 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SpawnNode : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/Roads/Node/SpawnNode.cs.meta b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta new file mode 100644 index 0000000..751f503 --- /dev/null +++ b/Assets/Scripts/Roads/Node/SpawnNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 71fd0b84cdaf65f48998acd1412e970e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Roads/NodeData.cs b/Assets/Scripts/Roads/NodeData.cs deleted file mode 100644 index 9ee8ace..0000000 --- a/Assets/Scripts/Roads/NodeData.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class NodeData : MonoBehaviour { - public Node node = null; -} diff --git a/Assets/Scripts/Roads/NodeData.cs.meta b/Assets/Scripts/Roads/NodeData.cs.meta deleted file mode 100644 index 73dcf56..0000000 --- a/Assets/Scripts/Roads/NodeData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4cf9bcd8c4889de4985e5d6a776acc5b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Roads/Road.cs b/Assets/Scripts/Roads/Road.cs index 1ad1a74..57cd7cf 100644 --- a/Assets/Scripts/Roads/Road.cs +++ b/Assets/Scripts/Roads/Road.cs @@ -85,4 +85,16 @@ public override int GetHashCode() { return nodes[0].GetHashCode() << 16 | nodes[1].GetHashCode(); } + + public void delete() { + foreach (Node node in nodes) { + node.roads.Remove(this); + if (node.roads.Count == 0) { + node.delete(); + } else { + node.update(); + } + } + GameObject.Destroy(gameObject); + } } diff --git a/Assets/Scripts/Roads/Roads.cs b/Assets/Scripts/Roads/Roads.cs index 02923e2..d9d4f28 100644 --- a/Assets/Scripts/Roads/Roads.cs +++ b/Assets/Scripts/Roads/Roads.cs @@ -26,7 +26,7 @@ pullingNode = hit.transform.gameObject.GetComponent().node; return; } - pullingNode = new Node(groundPosition, transform, config); + pullingNode = new CustomNode(groundPosition, transform, config); } private void endRoad(Ray ray, Vector3 groundPosition) { @@ -35,7 +35,7 @@ if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, 1 << 7)) { endNode = hit.transform.gameObject.GetComponent().node; } else { - endNode = new Node(groundPosition, transform, config); + endNode = new CustomNode(groundPosition, transform, config); } Road road = new Road(pullingNode, endNode, config); if (! pullingNode.roads.Contains(road) && pullingNode != endNode) { @@ -56,37 +56,14 @@ } } - private void removeRoad(Road road) { - foreach (Node node in road.nodes) { - node.roads.Remove(road); - if (node.roads.Count == 0) { - removeNode(node); - } else { - node.update(); - } - } - Destroy(road.gameObject); - } - - private void removeNode(Node node) { - foreach (Road road in node.roads) { - road.nodes.Remove(node); - removeRoad(road); - } - Destroy(node.gameObject); - } - private void handleRoadRemoving(Ray ray) { if (drawMode == DrawMode.None && Input.GetAxis("Fire1") != 0.0f) { RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << 7)) { - Node node = hit.transform.gameObject.GetComponent().node; - removeNode(node); + hit.transform.gameObject.GetComponent().node.delete(); drawMode = DrawMode.DeleteRoad; } else if (Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << 8)) { - Road road = hit.transform.gameObject.GetComponent().road; - print("road"); - removeRoad(road); + hit.transform.gameObject.GetComponent().road.delete(); drawMode = DrawMode.DeleteRoad; } } else if (drawMode == DrawMode.DeleteRoad && Input.GetAxis("Fire1") == 0.0f) {