-
Notifications
You must be signed in to change notification settings - Fork 2
/
GameManager.cs
72 lines (67 loc) · 1.89 KB
/
GameManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using Godot;
public class GameManager : Node
{
/* THIS IS A SINGLETON / AUTOLOADER - burcarz */
// public static GameManager Instance;
public Vector2 selectedTile;
public Vector2 playerPosition;
public TileDictionary<Tile.TileData> tileDict = new TileDictionary<Tile.TileData>();
public Vector2 refPosition;
public int visionRange;
public bool green;
public bool orange;
public bool blue;
public bool violet;
public int time;
[Export] public int dayLength;
[Export] public float rate;
[Export] public float light;
[Export] public float maxLight = 1.5f;
[Export] public float maxDark = 0.3f;
TileMap map;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
map = (GridMap)GetNode("/root/Main/WorldSpace/Node2D/ParentMap");
map.Modulate = new Color(light, light, light, 1);
time = dayLength / 2;
}
public override void _Process(float delta)
{
DayNightCycle();
}
public void DayNightCycle()
{
if (time < dayLength)
{
time++;
if (time <= dayLength / 2)
{
if (light <= maxLight)
{
map.Modulate = new Color(light + rate, light + rate, light + rate, 1);
light = light += rate;
}
}
else if (time >= dayLength / 2)
{
if (light >= maxDark)
{
map.Modulate = new Color(light - rate, light - rate, light - rate, 1);
light = light -= rate;
}
}
}
else
{
time = 0;
}
}
public override void _Input(InputEvent inputEvent)
{
if (Input.IsActionPressed("ui_accept"))
{
// DayNightCycle();
}
}
}