Finalised json save, added newtonsoft to project, v1.3.0
This commit is contained in:
parent
14f62410f5
commit
a026b9b1f5
8
Assets/Plugins.meta
Normal file
8
Assets/Plugins.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3f551e260fd255942ae7feb52fe1b4f1
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Plugins/Newtonsoft.Json.dll
Normal file
BIN
Assets/Plugins/Newtonsoft.Json.dll
Normal file
Binary file not shown.
33
Assets/Plugins/Newtonsoft.Json.dll.meta
Normal file
33
Assets/Plugins/Newtonsoft.Json.dll.meta
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0a26f55bc3f508441bb3d6ea70973bc5
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
Windows Store Apps: WindowsStoreApps
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,6 +1,8 @@
|
|||||||
|
using Assets.Scripts;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
public class NoiseGenerator
|
public class NoiseGenerator
|
||||||
{
|
{
|
||||||
@ -227,4 +229,31 @@ public class NoiseGenerator
|
|||||||
mesh.colors32 = colors;
|
mesh.colors32 = colors;
|
||||||
tile.GetComponent<MeshCollider>().sharedMesh = mesh;
|
tile.GetComponent<MeshCollider>().sharedMesh = mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string saveTile(GameObject tile)
|
||||||
|
{
|
||||||
|
string result = "";
|
||||||
|
Vector3[] vertices = tile.GetComponent<MeshFilter>().mesh.vertices;
|
||||||
|
Color32[] colors = tile.GetComponent<MeshFilter>().mesh.colors32;
|
||||||
|
result = result + "\"vertices\": {\r\n";
|
||||||
|
for (int i = 0; i < vertices.Length; i++)
|
||||||
|
{
|
||||||
|
result = result + FileHandler.generateJSON("vertice"+i, "\"" + vertices[i].x + "/" + vertices[i].y + "/" + vertices[i].z + "\"");
|
||||||
|
if (i < vertices.Length - 1)
|
||||||
|
{
|
||||||
|
result = result + ",\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = result + "\r\n},\"colors\": {\r\n";
|
||||||
|
for (int i = 0; i < colors.Length; i++)
|
||||||
|
{
|
||||||
|
result = result + FileHandler.generateJSON("color" + i, "\"" + colors[i].r + "/" + colors[i].g + "/" + colors[i].b + "\"");
|
||||||
|
if (i < colors.Length - 1)
|
||||||
|
{
|
||||||
|
result = result + ",\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = result + "\r\n}";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -220,17 +220,13 @@ public class Tile : MonoBehaviour
|
|||||||
string result = "";
|
string result = "";
|
||||||
GameObject obj;
|
GameObject obj;
|
||||||
result = result + FileHandler.generateJSON("tiletype", "\"" + tiletype + "\"") + ",\r\n";
|
result = result + FileHandler.generateJSON("tiletype", "\"" + tiletype + "\"") + ",\r\n";
|
||||||
result = result + FileHandler.generateJSON("positionX", position.x) + ",\r\n";
|
result = result + FileHandler.generateJSON("position", "\"" + position.x + "/" + position.y + "/" + position.z + "\"") + ",\r\n";
|
||||||
result = result + FileHandler.generateJSON("positionY", position.y) + ",\r\n";
|
result = result + "\"objects\": {\r\n";
|
||||||
result = result + FileHandler.generateJSON("positionZ", position.z) + ",\r\n";
|
|
||||||
result = result + "\"Objects\": {\r\n";
|
|
||||||
for (int i = 0; i < gameObject.transform.childCount; i++)
|
for (int i = 0; i < gameObject.transform.childCount; i++)
|
||||||
{
|
{
|
||||||
obj = gameObject.transform.GetChild(i).gameObject;
|
obj = gameObject.transform.GetChild(i).gameObject;
|
||||||
result = result + "\"Object" + i + "\": {\r\n";
|
result = result + "\"object" + i + "\": {\r\n";
|
||||||
result = result + FileHandler.generateJSON("positionX", obj.transform.position.x) + ",\r\n";
|
result = result + FileHandler.generateJSON("position", "\"" + obj.transform.position.x + "/" + obj.transform.position.y + "/" + obj.transform.position.z + "\"") + ",\r\n";
|
||||||
result = result + FileHandler.generateJSON("positionY", obj.transform.position.y) + ",\r\n";
|
|
||||||
result = result + FileHandler.generateJSON("positionZ", obj.transform.position.z) + ",\r\n";
|
|
||||||
if (obj.tag.Contains("Enemy"))
|
if (obj.tag.Contains("Enemy"))
|
||||||
{
|
{
|
||||||
result = result + obj.GetComponent<Enemy>().saveEnemy() + "\r\n}";
|
result = result + obj.GetComponent<Enemy>().saveEnemy() + "\r\n}";
|
||||||
@ -247,4 +243,11 @@ public class Tile : MonoBehaviour
|
|||||||
result = result + "\r\n}";
|
result = result + "\r\n}";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string saveCurrent()
|
||||||
|
{
|
||||||
|
string result = "";
|
||||||
|
result = result + "\"" + position.x + "/" + position.y + "/" + position.z + "\"";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -186,18 +186,21 @@ public class WorldGenerator : MonoBehaviour
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
result = result + FileHandler.generateJSON("cityAmount", cityAmount) + ",\r\n";
|
result = result + FileHandler.generateJSON("cityAmount", cityAmount) + ",\r\n";
|
||||||
result = result + FileHandler.generateJSON("maxCityAmount", maxCityAmount) + ",\r\n";
|
result = result + FileHandler.generateJSON("maxCityAmount", maxCityAmount) + ",\r\n";
|
||||||
result = result + "\"currentTile\": {\r\n";
|
result = result + "\"currentTile\": " + currentTile.GetComponent<Tile>().saveCurrent() + ",\r\n";
|
||||||
result = result + currentTile.GetComponent<Tile>().saveTile() + "\r\n},\r\n";
|
result = result + "\"map\": {\r\n";
|
||||||
result = result + "\"Map\": {\r\n";
|
|
||||||
foreach (GameObject tile in tiles.Values)
|
foreach (GameObject tile in tiles.Values)
|
||||||
{
|
{
|
||||||
result = result + "\"Tile"+counter+"\": {\r\n";
|
if (tile.name != "Spawn")
|
||||||
result = result + tile.GetComponent<Tile>().saveTile() + "\r\n}";
|
|
||||||
if (counter < tiles.Count - 1)
|
|
||||||
{
|
{
|
||||||
result = result + ",\r\n";
|
result = result + "\"tile" + counter + "\": {\r\n";
|
||||||
|
result = result + tile.GetComponent<Tile>().saveTile() + ",\r\n";
|
||||||
|
result = result + noise.saveTile(tile) + "\r\n}";
|
||||||
|
if (counter < tiles.Count - 1)
|
||||||
|
{
|
||||||
|
result = result + ",\r\n";
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
}
|
}
|
||||||
counter++;
|
|
||||||
}
|
}
|
||||||
result = result + "\r\n}";
|
result = result + "\r\n}";
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
BIN
Packages/Newtonsoft.Json.13.0.1/.signature.p7s
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/.signature.p7s
vendored
Normal file
Binary file not shown.
20
Packages/Newtonsoft.Json.13.0.1/LICENSE.md
vendored
Normal file
20
Packages/Newtonsoft.Json.13.0.1/LICENSE.md
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2007 James Newton-King
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
BIN
Packages/Newtonsoft.Json.13.0.1/Newtonsoft.Json.13.0.1.nupkg
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/Newtonsoft.Json.13.0.1.nupkg
vendored
Normal file
Binary file not shown.
BIN
Packages/Newtonsoft.Json.13.0.1/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
10335
Packages/Newtonsoft.Json.13.0.1/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
10335
Packages/Newtonsoft.Json.13.0.1/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Packages/Newtonsoft.Json.13.0.1/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
9483
Packages/Newtonsoft.Json.13.0.1/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
9483
Packages/Newtonsoft.Json.13.0.1/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Packages/Newtonsoft.Json.13.0.1/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
9683
Packages/Newtonsoft.Json.13.0.1/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
9683
Packages/Newtonsoft.Json.13.0.1/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Packages/Newtonsoft.Json.13.0.1/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11305
Packages/Newtonsoft.Json.13.0.1/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
11305
Packages/Newtonsoft.Json.13.0.1/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Packages/Newtonsoft.Json.13.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
10993
Packages/Newtonsoft.Json.13.0.1/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
10993
Packages/Newtonsoft.Json.13.0.1/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Packages/Newtonsoft.Json.13.0.1/lib/netstandard1.3/Newtonsoft.Json.dll
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/lib/netstandard1.3/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11115
Packages/Newtonsoft.Json.13.0.1/lib/netstandard1.3/Newtonsoft.Json.xml
vendored
Normal file
11115
Packages/Newtonsoft.Json.13.0.1/lib/netstandard1.3/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Packages/Newtonsoft.Json.13.0.1/lib/netstandard2.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/lib/netstandard2.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
11280
Packages/Newtonsoft.Json.13.0.1/lib/netstandard2.0/Newtonsoft.Json.xml
vendored
Normal file
11280
Packages/Newtonsoft.Json.13.0.1/lib/netstandard2.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Packages/Newtonsoft.Json.13.0.1/packageIcon.png
vendored
Normal file
BIN
Packages/Newtonsoft.Json.13.0.1/packageIcon.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.7 KiB |
4
packages.config
Normal file
4
packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net471" />
|
||||||
|
</packages>
|
||||||
Loading…
x
Reference in New Issue
Block a user