feat: first level configured

This commit is contained in:
LordDemonix 2025-09-17 17:05:48 +02:00
parent 9a5b06387d
commit 2f297461e3
5 changed files with 123698 additions and 111654 deletions

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@ Material:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: EarthMaterial m_Name: EarthMaterial
m_Shader: {fileID: 4800000, guid: 32a0ef2a7ef59ad47846655a3c02fa8d, type: 3} m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
m_Parent: {fileID: 0} m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0 m_ModifiedSerializedProperties: 0
m_ValidKeywords: [] m_ValidKeywords: []
@ -27,6 +27,10 @@ Material:
m_SavedProperties: m_SavedProperties:
serializedVersion: 3 serializedVersion: 3
m_TexEnvs: m_TexEnvs:
- _AlphaTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap: - _BumpMap:
m_Texture: {fileID: 2800000, guid: c2fa05cb71836f246b5eabf3f3c6151c, type: 3} m_Texture: {fileID: 2800000, guid: c2fa05cb71836f246b5eabf3f3c6151c, type: 3}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
@ -36,7 +40,7 @@ Material:
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _CloudsTex: - _CloudsTex:
m_Texture: {fileID: 2800000, guid: 961fa74443856d247867fce623b3d325, type: 3} m_Texture: {fileID: 2800000, guid: 7dfcb90673cf9a44281e7da0b32902b2, type: 3}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _Cube: - _Cube:
@ -113,6 +117,7 @@ Material:
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
m_Ints: [] m_Ints: []
m_Floats: m_Floats:
- PixelSnap: 0
- _AtmosFalloff: 14 - _AtmosFalloff: 14
- _BumpScale: 1 - _BumpScale: 1
- _CloudIntensityMin: 0.1 - _CloudIntensityMin: 0.1
@ -121,6 +126,7 @@ Material:
- _DetailIntensityMin: 0.01 - _DetailIntensityMin: 0.01
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _DstBlend: 0 - _DstBlend: 0
- _EnableExternalAlpha: 0
- _Glossiness: 0.5 - _Glossiness: 0.5
- _InvFade: 1 - _InvFade: 1
- _LightScale: 1 - _LightScale: 1
@ -146,7 +152,9 @@ Material:
- _Color: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1}
- _DayTintColor: {r: 1, g: 1, b: 1, a: 1} - _DayTintColor: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0.04, g: 0.04, b: 0.04, a: 1} - _EmissionColor: {r: 0.04, g: 0.04, b: 0.04, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _ReflectColor: {r: 1, g: 1, b: 1, a: 0.5} - _ReflectColor: {r: 1, g: 1, b: 1, a: 0.5}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
- _RimColor: {r: 0, g: 0.27520287, b: 0.5955882, a: 0} - _RimColor: {r: 0, g: 0.27520287, b: 0.5955882, a: 0}
- _SpecColor: {r: 0.08823532, g: 0.08823532, b: 0.08823532, a: 1} - _SpecColor: {r: 0.08823532, g: 0.08823532, b: 0.08823532, a: 1}
- _SunColor: {r: 1, g: 1, b: 1, a: 1} - _SunColor: {r: 1, g: 1, b: 1, a: 1}

View file

@ -1,6 +1,7 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Linq; using System.Linq;
using NUnit.Framework.Internal.Commands;
[InitializeOnLoad] [InitializeOnLoad]
public static class EditorCustom public static class EditorCustom
@ -71,7 +72,8 @@ public static class EditorCustom
} }
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
gm.maxConnectionLength = EditorGUILayout.Slider("Max Connection Length", gm.maxConnectionLength, 0, 100); gm.minConnectionLength = EditorGUILayout.Slider("Min Connection Length", gm.minConnectionLength, 0, gm.maxConnectionLength);
gm.maxConnectionLength = EditorGUILayout.Slider("Max Connection Length", gm.maxConnectionLength, gm.minConnectionLength, 30);
if (EditorGUI.EndChangeCheck() && gm.regenerateOnChange) if (EditorGUI.EndChangeCheck() && gm.regenerateOnChange)
{ {
gm.GenerateConnections(); gm.GenerateConnections();
@ -114,14 +116,8 @@ public static class EditorCustom
if (GUILayout.Button("Fetch all Nodes")) if (GUILayout.Button("Fetch all Nodes"))
{ gm.FetchAllNodes();
Node[] allNodes = gm.NodeParent.GetComponentsInChildren<Node>();
Debug.Log("Added " + (allNodes.Length - gm.nodeCount) + " new nodes");
gm.nodes = allNodes.ToList();
gm.nodeCount = allNodes.Length;
}
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();

View file

@ -20,6 +20,7 @@ public class GameManager : MonoBehaviour
public bool regenerateOnChange = false; public bool regenerateOnChange = false;
[HideInInspector] public float minConnectionLength = 6;
[HideInInspector] public float maxConnectionLength = 6; [HideInInspector] public float maxConnectionLength = 6;
[HideInInspector] public int nodeCount = 100; [HideInInspector] public int nodeCount = 100;
[HideInInspector] public int hoverRadiusCon = 50; [HideInInspector] public int hoverRadiusCon = 50;
@ -57,6 +58,7 @@ public class GameManager : MonoBehaviour
public bool allowed = true; public bool allowed = true;
} }
public float minConnectionLength = 0;
public float maxConnectionLength = 0; public float maxConnectionLength = 0;
public List<NodeData> nodes = new List<NodeData>(); public List<NodeData> nodes = new List<NodeData>();
public List<ConnectionData> connections = new List<ConnectionData>(); public List<ConnectionData> connections = new List<ConnectionData>();
@ -121,7 +123,8 @@ public class GameManager : MonoBehaviour
{ {
if (nodeB == null) continue; if (nodeB == null) continue;
bool conExists = false; bool conExists = false;
if (nodeA == nodeB || Math.Abs(Vector3.Distance(nodeA.transform.position, nodeB.transform.position)) > maxConnectionLength) float dist = Vector3.Distance(nodeA.transform.position, nodeB.transform.position);
if (nodeA == nodeB || dist > maxConnectionLength)
continue; continue;
foreach (Connection con in connections) foreach (Connection con in connections)
@ -134,13 +137,21 @@ public class GameManager : MonoBehaviour
} }
if (!conExists) if (!conExists)
{ {
AddConnection(nodeA, nodeB); AddConnection(nodeA, nodeB, dist < minConnectionLength);
} }
} }
} }
} }
public void FetchAllNodes()
{
Node[] allNodes = NodeParent.GetComponentsInChildren<Node>();
nodes = allNodes.ToList();
nodeCount = allNodes.Length;
}
private void Update() private void Update()
{ {
foreach (var con in connections) foreach (var con in connections)
@ -210,19 +221,19 @@ public class GameManager : MonoBehaviour
foreach (LevelData.ConnectionData conData in levels[index].connections) foreach (LevelData.ConnectionData conData in levels[index].connections)
{ {
AddConnection(nodes[conData.nodeAIndex], nodes[conData.nodeBIndex]); AddConnection(nodes[conData.nodeAIndex], nodes[conData.nodeBIndex], conData.allowed);
} }
selectedLevel = index; selectedLevel = index;
minConnectionLength = levels[index].minConnectionLength;
maxConnectionLength = levels[index].maxConnectionLength; maxConnectionLength = levels[index].maxConnectionLength;
nodeCount = nodes.Count; nodeCount = nodes.Count;
Debug.Log("Loaded Level " + index);
} }
public void SaveLevelData(int index = -1) public void SaveLevelData(int index = -1)
{ {
LevelData data = new LevelData(); LevelData data = new LevelData();
data.minConnectionLength = minConnectionLength;
data.maxConnectionLength = maxConnectionLength; data.maxConnectionLength = maxConnectionLength;
// Nodes speichern // Nodes speichern
@ -258,7 +269,5 @@ public class GameManager : MonoBehaviour
int newIndex = index < 0 ? levels.Count - 1 : index; int newIndex = index < 0 ? levels.Count - 1 : index;
selectedLevel = newIndex; selectedLevel = newIndex;
Debug.Log("Saved Level " + newIndex);
} }
} }

View file

@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using System.Collections.Generic;
[ExecuteAlways] [ExecuteAlways]
public class Node : MonoBehaviour public class Node : MonoBehaviour
@ -32,10 +33,26 @@ public class Node : MonoBehaviour
UpdateTransform(); UpdateTransform();
} }
private void OnDestroy()
{
GameManager gm = FindFirstObjectByType<GameManager>();
List<GameManager.Connection> looseConnections = gm.connections.FindAll(c => c.nodeA == this || c.nodeB == this);
foreach(GameManager.Connection c in looseConnections)
{
DestroyImmediate(c.lineRenderer.gameObject);
gm.connections.Remove(c);
}
gm.FetchAllNodes();
}
public void UpdateTransform() public void UpdateTransform()
{ {
transform.localPosition = transform.localPosition.normalized * 20f; transform.localPosition = transform.localPosition.normalized * 20f;
transform.forward = transform.position; if(transform.position != Vector3.zero)
transform.forward = transform.position;
} }
public void UpdateColor() public void UpdateColor()