-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathglobal.gd
35 lines (28 loc) · 949 Bytes
/
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
extends Node
# Define signals for weapon switching
signal weapon_switched(weapon_name)
# Inventory slots
var guns = ["Glock-19", "AK-47"]
var melees = ["Knife"]
var current_ammo
var spare_ammo
var player
# Add weapons to the inventory
func add_weapon(weapon_name, weapon_type):
if weapon_type == "gun" and guns.size() < 3:
guns.append(weapon_name)
elif weapon_type == "melee" and melees.size() < 3:
melees.append(weapon_name)
# Switch weapons based on the inventory slot for each individual of it
func switch_weapon(weapon_slot):
var weapon_name = ""
if weapon_slot == 1 and guns.size() > 0:
weapon_name = guns[0] # Switch to 'Glock-19'
elif weapon_slot == 2 and guns.size() > 1:
weapon_name = guns[1] # Switch to 'AK-47'
elif weapon_slot == 3 and melees.size() > 0:
weapon_name = melees[0] # Switch to 'Knife'
else:
print("No weapon to switch for!")
if weapon_name != "":
emit_signal("weapon_switched", weapon_name)