New features and plenty of code still in testing. This includes a level select, basic inventory, and a basic HUD.
This commit is contained in:
45
Player/Inventory.gd
Normal file
45
Player/Inventory.gd
Normal file
@@ -0,0 +1,45 @@
|
||||
extends Node
|
||||
|
||||
signal update_currency(amount)
|
||||
|
||||
var __currency: int
|
||||
|
||||
var __weapons: Array
|
||||
var __accessories: Array
|
||||
var __categories: Dictionary
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
self.__currency = 100
|
||||
|
||||
self.__weapons = []
|
||||
self.__accessories = []
|
||||
self.__categories = {
|
||||
'Weapon': self.__weapons,
|
||||
'Accessory': self.__accessories}
|
||||
return
|
||||
|
||||
|
||||
func get_currency() -> int:
|
||||
return self.__currency
|
||||
|
||||
|
||||
func add_currency(amount: int) -> void:
|
||||
self.__currency += amount
|
||||
emit_signal('update_currency', self.__currency)
|
||||
return
|
||||
|
||||
|
||||
func add(item) -> void:
|
||||
self.__categories[item.type].append(item)
|
||||
return
|
||||
|
||||
|
||||
func discard(item) -> void:
|
||||
var index: int = 0
|
||||
for itr in self.__categories[item.type]:
|
||||
if itr.equals(item):
|
||||
self.__categories[item.type].remove(index)
|
||||
break
|
||||
index += 1
|
||||
return
|
Reference in New Issue
Block a user