-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cs
107 lines (84 loc) · 2.25 KB
/
Game.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections.Generic;
using Godot;
/**
* Autoloaded, singleton
*/
public class Game : Node
{
private static Game _instance;
[Export] private PackedScene Yard { get; set; }
[Export] private Beelancer Bee { get; set; }
public static Random Random = new Random();
public static Yard CurrentYard { get; private set; }
public static Dictionary<UpgradeTypeEnum, int> CurrentLevels;
public static Dictionary<ResourceTypeEnum, float> CollectedResources;
private static MainMenu _mainMenu;
private GameStateEnum _stateEnum = GameStateEnum.MainMenu;
public override void _Ready()
{
CurrentYard = GetParent().GetNodeOrNull<Yard>("Yard");
_mainMenu = GetNode<MainMenu>("MainMenu");
if (!IsInstanceValid(CurrentYard))
{
_mainMenu.Visible = true;
}
_instance = this;
}
public static void SetLandedFlower(Flower flower)
{
if (!IsInstanceValid(GameCamera.Current)) return;
if (flower != null)
{
GameCamera.Current.LastLandingFocusLocation = flower.GlobalPosition;
GameCamera.Current.IsLanded = true;
GameCamera.StartLerp();
ActionText.SetText(ActionTextEnum.Takeoff);
}
else
{
GameCamera.Current.IsLanded = false;
GameCamera.ReverseLerp();
ActionText.DismissText();
}
}
public static void NewGame()
{
SetLandedFlower(null);
GUIManager.SetGameState(GameStateEnum.Gameplay);
_mainMenu.Visible = false;
CurrentLevels = new Dictionary<UpgradeTypeEnum, int>();
foreach (UpgradeTypeEnum upgrade in Enum.GetValues(typeof(UpgradeTypeEnum)))
{
CurrentLevels.Add(upgrade, 1);
}
NewYard();
InitializeResources();
AudioManager.PlayTrack(MusicTrackEnum.Exploration);
}
public static void NewYard()
{
if (IsInstanceValid(CurrentYard))
{
CurrentYard.QueueFree();
}
CurrentYard = _instance.Yard.Instance<Yard>();
_instance.AddChild(CurrentYard);
}
public static void InitializeResources()
{
CollectedResources = new Dictionary<ResourceTypeEnum, float>
{
{ResourceTypeEnum.RedPollen, 0f},
{ResourceTypeEnum.BluePollen, 0f},
{ResourceTypeEnum.GreenPollen, 0f},
{ResourceTypeEnum.Honey, 0f}
};
}
public static void ShowMainMenu()
{
GUIManager.SetGameState(GameStateEnum.MainMenu);
CurrentYard.QueueFree();
_mainMenu.Visible = true;
}
}