initial commit
This commit is contained in:
commit
41f6494eea
22 files changed
+344
No files matched your search
@@ -0,0 +1,70 @@
|
||||
using GeometryJump;
|
||||
using GeometryJump.Level;
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
||||
public partial class Level : Node2D
|
||||
{
|
||||
public LevelData level = new LevelData
|
||||
{
|
||||
LevelName = "Test",
|
||||
LevelAuthor = "Xtimhedi",
|
||||
LevelRenderPaths = new List<RenderPath>
|
||||
{
|
||||
new RenderPath{
|
||||
Points = new System.Collections.Generic.List<PathNode>
|
||||
{
|
||||
new PathNode { NodeColor = Colors.Red, PosX = 0, PosY = 0 },
|
||||
new PathNode { NodeColor = Colors.Red, PosX = 10, PosY = 0 },
|
||||
new PathNode { NodeColor = Colors.Red, PosX = 10, PosY = 10 },
|
||||
},
|
||||
Vertcies = new System.Collections.Generic.List<int> { 0, 1, 2 }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
SerializeLevel();
|
||||
GD.Print(Globals.BasePath);
|
||||
}
|
||||
|
||||
public void SerializeLevel()
|
||||
{
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
string jsonString = JsonSerializer.Serialize(level, options);
|
||||
|
||||
string savePath = Globals.BasePath.PathJoin("level.json");
|
||||
using var file = FileAccess.Open(savePath, FileAccess.ModeFlags.Write);
|
||||
|
||||
if (file != null)
|
||||
{
|
||||
file.StoreString(jsonString);
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.PrintErr($"Failed to open path: {savePath}. Error: {FileAccess.GetOpenError()}");
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderLevel()
|
||||
{
|
||||
foreach (RenderPath rp in level.LevelRenderPaths)
|
||||
{
|
||||
// setup pathing
|
||||
List<PathNode> nodes = rp.Points;
|
||||
List<int> verts = rp.Vertcies;
|
||||
|
||||
foreach (int vert in verts)
|
||||
{
|
||||
PathNode curNode = nodes[vert];
|
||||
if (curNode != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user