-
Notifications
You must be signed in to change notification settings - Fork 7
/
GameStates.cs
110 lines (85 loc) · 2.2 KB
/
GameStates.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
108
109
110
using Godot;
using System;
using System.Collections.Generic;
public class GameStates : Node
{
public enum GameType {
SINGLE_PLAYER, MULTI_PLAYER, SIMULATION
}
private GameType _gameType = GameType.SIMULATION;
public int current_level = 0;
// How many game updates per second
public float updateRate = 60;
public float updateDelta = 0;
public String[] levels = { "res://ui/TitleScreen.tscn", "res://network/Lobby.tscn", "res://map/GameWorld.tscn" };
public String endResultScreen = "res://ui/EndGameScreen.tscn";
public float currentTime = 0;
public List<TeamMapAISetting> _teamMapAISettings = null;
private String messages;
public override void _Ready()
{
set_update_rate(updateRate);
}
public List<TeamMapAISetting> GetTeamMapAISettings()
{
return _teamMapAISettings;
}
public void SetTeamMapAISettings(List<TeamMapAISetting> teamMapAISettings)
{
_teamMapAISettings = teamMapAISettings;
}
public void setMessagesForNextScene(String inputMessages)
{
messages = inputMessages;
}
public String getMessgesForNextScene()
{
return messages;
}
public GameType GetGameType()
{
return _gameType;
}
private void set_update_rate(float rate)
{
this.updateRate = rate;
this.updateDelta = 1.0f / updateRate;
}
private float getUpdateDelta()
{
return updateDelta;
}
private void noSet(float rate) { }
public void endGameScreen()
{
// In menu, enable mouse
Input.SetMouseMode(Input.MouseMode.Visible);
GetTree().ChangeScene(endResultScreen);
}
public void EnterLobbyScreen()
{
_gameType = GameType.MULTI_PLAYER;
// In menu, enable mouse
Input.SetMouseMode(Input.MouseMode.Visible);
current_level = 1;
GetTree().CurrentScene.QueueFree();
GetTree().ChangeScene(levels[current_level]);
}
public void EnterTitleScreen()
{
_gameType = GameType.SIMULATION;
// In menu, enable mouse
Input.SetMouseMode(Input.MouseMode.Visible);
current_level = 0;
GetTree().CurrentScene.QueueFree();
GetTree().ChangeScene(levels[current_level]);
}
public void EnterNetworkLevel()
{
current_level = 2;
// In game, disable mouse
Input.SetMouseMode(Input.MouseMode.Hidden);
GetTree().CurrentScene.QueueFree();
GetTree().ChangeScene(levels[current_level]);
}
}