Added basic light controls to the game and added more content spawnpoints. Adjusted values a bit.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class LightHandler
|
||||
{
|
||||
public static List<OmniLight3D> lights = new ();
|
||||
|
||||
public static void RedrawLights(Color color)
|
||||
{
|
||||
foreach(OmniLight3D light in lights)
|
||||
{
|
||||
light.LightColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b150nxl3cc3ck
|
||||
@@ -4,7 +4,7 @@ public partial class UIHandler : Control
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
GetNode<ColorPickerButton>("./MainUI/HeaderContainer/Header/LightColor").Color = GameData.lightColor;
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
@@ -13,4 +13,10 @@ public partial class UIHandler : Control
|
||||
|
||||
}
|
||||
|
||||
public void ChangeColor(Color color)
|
||||
{
|
||||
GameData.lightColor = color;
|
||||
LightHandler.RedrawLights(color);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-2
@@ -104,6 +104,7 @@ public partial class Tile
|
||||
Position = placeholder.transform.Origin
|
||||
};
|
||||
lightSource.Position.MoveToward(transform.Origin, 0.1f);
|
||||
LightHandler.lights.Add(lightSource);
|
||||
light.AddChild(lightSource);
|
||||
ContentNode.AddChild(light);
|
||||
light.LookAt(transform.Origin, Vector3.Up);
|
||||
@@ -111,14 +112,13 @@ public partial class Tile
|
||||
|
||||
private void SpawnResource(MeshInstance3D resourceMesh, Placeholder placeholder, Transform3D transform)
|
||||
{
|
||||
Vector3 forward = (transform.Origin - placeholder.transform.Origin).Normalized();
|
||||
MeshInstance3D resource = new MeshInstance3D
|
||||
{
|
||||
Mesh = resourceMesh.Mesh,
|
||||
Position = placeholder.transform.Origin
|
||||
};
|
||||
ContentNode.AddChild(resource);
|
||||
resource.LookAt(resource.Position + forward, Vector3.Up);
|
||||
resource.LookAt(transform.Origin, Vector3.Up);
|
||||
}
|
||||
|
||||
private void SpawnDecorations(Dictionary<string, MeshInstance3D> contentMeshes, Placeholder placeholder, Transform3D transform)
|
||||
@@ -132,6 +132,7 @@ public partial class Tile
|
||||
Position = placeholder.transform.Origin
|
||||
};
|
||||
ContentNode.AddChild(decoration);
|
||||
decoration.LookAt(transform.Origin, Vector3.Up);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ public partial class World : Node3D
|
||||
|
||||
int posX, posY;
|
||||
|
||||
while(currentLight < layerSize * layerSize / 2)
|
||||
while(currentLight < layerSize * layerSize / 4)
|
||||
{
|
||||
posX = rand.Next(layerSize);
|
||||
posY = rand.Next(layerSize);
|
||||
|
||||
Reference in New Issue
Block a user