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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cw1toc1hcl5p5
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://cgfk2vhdo4nbi"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cw1toc1hcl5p5" path="res://Renderer/Level.cs" id="1_u072b"]
|
||||
|
||||
[node name="Level" type="Node2D" unique_id=1624383015]
|
||||
script = ExtResource("1_u072b")
|
||||
Reference in new issue
Block a user