diff --git a/Assets/Scripts/Buttons/LoadButton.cs b/Assets/Scripts/Buttons/LoadButton.cs index 11c32e8..1ebd330 100644 --- a/Assets/Scripts/Buttons/LoadButton.cs +++ b/Assets/Scripts/Buttons/LoadButton.cs @@ -42,6 +42,12 @@ nodeData.targets.Add(nodes[target].nodeData as ExitNodeData); } } - // todo: generate roads + foreach (SaveRoad saveRoad in saveData.roads) { + Road road = new Road(nodes[saveRoad.start], nodes[saveRoad.end], config); + foreach (Node node in road.nodes) { + node.roads.Add(road); + } + road.initialize(roads); + } } } diff --git a/Assets/Scripts/Buttons/LoadButton.cs b/Assets/Scripts/Buttons/LoadButton.cs index 11c32e8..1ebd330 100644 --- a/Assets/Scripts/Buttons/LoadButton.cs +++ b/Assets/Scripts/Buttons/LoadButton.cs @@ -42,6 +42,12 @@ nodeData.targets.Add(nodes[target].nodeData as ExitNodeData); } } - // todo: generate roads + foreach (SaveRoad saveRoad in saveData.roads) { + Road road = new Road(nodes[saveRoad.start], nodes[saveRoad.end], config); + foreach (Node node in road.nodes) { + node.roads.Add(road); + } + road.initialize(roads); + } } } diff --git a/Assets/Scripts/Buttons/SaveButton.cs b/Assets/Scripts/Buttons/SaveButton.cs index 1cc6a12..a8865b5 100644 --- a/Assets/Scripts/Buttons/SaveButton.cs +++ b/Assets/Scripts/Buttons/SaveButton.cs @@ -18,10 +18,17 @@ saveNode.position = node.position; if (node is SpawnNode) { saveNode.type = "spawn"; + List targets = new List(); + foreach (ExitNodeData exit in (node.nodeData as SpawnNodeData).targets) { + targets.Add(config.roadNetwork.nodes.IndexOf(exit.node)); + } + saveNode.targets = targets; } else if (node is ExitNode) { saveNode.type = "exit"; + saveNode.targets = new List(); } else { saveNode.type = ""; + saveNode.targets = new List(); } nodes.Add(saveNode); } diff --git a/Assets/Scripts/Buttons/LoadButton.cs b/Assets/Scripts/Buttons/LoadButton.cs index 11c32e8..1ebd330 100644 --- a/Assets/Scripts/Buttons/LoadButton.cs +++ b/Assets/Scripts/Buttons/LoadButton.cs @@ -42,6 +42,12 @@ nodeData.targets.Add(nodes[target].nodeData as ExitNodeData); } } - // todo: generate roads + foreach (SaveRoad saveRoad in saveData.roads) { + Road road = new Road(nodes[saveRoad.start], nodes[saveRoad.end], config); + foreach (Node node in road.nodes) { + node.roads.Add(road); + } + road.initialize(roads); + } } } diff --git a/Assets/Scripts/Buttons/SaveButton.cs b/Assets/Scripts/Buttons/SaveButton.cs index 1cc6a12..a8865b5 100644 --- a/Assets/Scripts/Buttons/SaveButton.cs +++ b/Assets/Scripts/Buttons/SaveButton.cs @@ -18,10 +18,17 @@ saveNode.position = node.position; if (node is SpawnNode) { saveNode.type = "spawn"; + List targets = new List(); + foreach (ExitNodeData exit in (node.nodeData as SpawnNodeData).targets) { + targets.Add(config.roadNetwork.nodes.IndexOf(exit.node)); + } + saveNode.targets = targets; } else if (node is ExitNode) { saveNode.type = "exit"; + saveNode.targets = new List(); } else { saveNode.type = ""; + saveNode.targets = new List(); } nodes.Add(saveNode); } diff --git a/Assets/Scripts/Roads/Node/SpawnNodeData.cs b/Assets/Scripts/Roads/Node/SpawnNodeData.cs index 6089504..1e23c32 100644 --- a/Assets/Scripts/Roads/Node/SpawnNodeData.cs +++ b/Assets/Scripts/Roads/Node/SpawnNodeData.cs @@ -6,10 +6,6 @@ public List targets = new List(); public float timeLeft = 0f, interval = 5f; - override public void Start() { - base.Start(); - } - void Update() { timeLeft -= Time.deltaTime; if (timeLeft <= 0f && targets.Count > 0) {