-
Notifications
You must be signed in to change notification settings - Fork 32
/
Global.gd
executable file
·135 lines (107 loc) · 3.16 KB
/
Global.gd
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
extends Node
var TrainerName : String = "TrainerName"
var TrainerGender = 0 # 0 is boy, 1 is neutral, 2 is girl
var badges = 0
var time : int = 0 # number of minutes spend in-game
var location : String = ""
var money : int = 0
var pokedex_seen = [] # list of id numbers
var pokedex_caught = [] # list of id numbers
var onStairsUp = false
var onStairsDown = false
var wasOnStairs = false
var debug = true
var onGrass = false
var lookingOnGrass = false
var grass_positions = []
var grassPos = ""
var exitGrassPos = ""
var grassSprite = "res://Graphics/Autotiles/Tall Grass2.png"
var printFPS = false
#var size
var sprint = false
var game : Node
var inventory
var can_run = false
var pokemon_group = [] # Cannot be more that 6 Pokemon objects
var past_events = [] # All events that had occured
var isMobile = false
var load_game_from_id # Used on loading a save
var player_starter # 0 = Raptorch, 1 = Orchynx, 2 = Electux
var block_wild = false
var rng
var registry
#signal setup_items
signal loaded
func _ready():
rng = RandomNumberGenerator.new()
rng.randomize()
add_to_group("save")
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
registry = load("res://Utilities/Battle/Database/Pokemon/registry.gd").new()
func _process(_delta):
if Input.is_action_just_pressed("toggle_fullscreen"):
OS.window_fullscreen = !OS.window_fullscreen
if Input.is_action_just_pressed("toggle_fps"):
printFPS = true
if printFPS == true:
print(Engine.get_frames_per_second())
pass
func save_state():
load_game_from_id = null
var state = {
"TrainerName": TrainerName,
"TrainerGender": TrainerGender,
"badges": badges,
"time": time,
"can_run": can_run,
"pokemon_group": pokemon_group,
"past_events": past_events,
"inventory": inventory.get_save_state(),
"pokedex_seen": pokedex_seen,
"pokedex_caught" : pokedex_caught
}
SaveSystem.set_state(filename, state)
func load_state():
if SaveSystem.has_state(filename):
var state = SaveSystem.get_state(filename)
TrainerName = state["TrainerName"]
TrainerGender = state["TrainerGender"]
badges = state["badges"]
if typeof(state["time"]) == TYPE_STRING:
time = 0
if typeof(state["time"]) == TYPE_INT:
time = state["time"]
can_run = state["can_run"]
pokemon_group = state["pokemon_group"]
past_events = state["past_events"]
pokedex_seen = state["pokedex_seen"]
if state.has("pokedex_caught"):
pokedex_caught = state["pokedex_caught"]
elif state.has("pokedex_owned"):
pokedex_caught = state["pokedex_owned"]
inventory = load("res://Utilities/Items/Inventory.gd").new()
inventory.set_save_state(state["inventory"])
badges = state["badges"]
emit_signal("loaded")
func heal_party(): # Heals all of the player's pokemon party.
for poke in pokemon_group:
poke.heal()
func add_poke_to_party(poke : Pokemon):
# Add to owned dex list
if !pokedex_caught.has(poke.ID):
pokedex_caught.append(poke.ID)
if !pokedex_seen.has(poke.ID):
pokedex_seen.append(poke.ID)
if pokemon_group.size() >= 6:
print("party already full")
# party already full
# TODO: Send to pc
else:
pokemon_group.append(poke)
pass
func remove_money(amount : int):
if money - amount < 0:
money = 0
else:
money = money - amount