2020-08-31 07:35:52 +00:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
var ShowInventory = 0
|
|
|
|
var LeftClick = 0
|
2020-10-07 20:24:10 +00:00
|
|
|
var player_inventory_items = []
|
2021-08-26 14:52:21 +00:00
|
|
|
var loadedscenes = {"RiverIntersectionHome":"res://Maps/river_intersection_home.tscn"}
|
2021-04-15 20:14:31 +00:00
|
|
|
var loadgame_screen = null
|
2020-10-08 19:56:03 +00:00
|
|
|
var current_scene = null
|
2021-04-03 14:06:23 +00:00
|
|
|
var current_camera = null
|
|
|
|
var dev_stats = true
|
2021-04-15 20:14:31 +00:00
|
|
|
var dbname = "storage.db"
|
2021-05-26 20:59:30 +00:00
|
|
|
var mainscene = ""
|
2021-11-20 22:48:39 +00:00
|
|
|
var base_tilemap = preload("res://Other/base_tilemap/base_tilemap.tscn")
|
2020-10-10 20:23:11 +00:00
|
|
|
|
|
|
|
func AddInventoryItem(itemid, amount):
|
|
|
|
for x in range(40):
|
|
|
|
if(player_inventory_items[x].item_id == itemid):
|
2021-04-02 21:24:35 +00:00
|
|
|
print(str(player_inventory_items[x]))
|
2020-10-10 20:23:11 +00:00
|
|
|
player_inventory_items[x].amount += amount
|
|
|
|
return
|
|
|
|
#if we reached here then no exisiting item is found and we iterate the array again
|
|
|
|
print("adding item")
|
|
|
|
for x in range(40):
|
|
|
|
if(player_inventory_items[x].item_id == 0):
|
|
|
|
player_inventory_items[x].id = x
|
|
|
|
player_inventory_items[x].item_name = "name"
|
|
|
|
player_inventory_items[x].shortdesc = "desc"
|
|
|
|
player_inventory_items[x].item_id = itemid
|
|
|
|
player_inventory_items[x].amount = amount
|
2021-04-05 20:59:49 +00:00
|
|
|
return
|
2020-10-08 19:56:03 +00:00
|
|
|
|
2021-11-20 22:48:39 +00:00
|
|
|
#Add scene as child
|
|
|
|
func AddScene(scene):
|
|
|
|
print("Adding scene ", scene)
|
|
|
|
var camera = get_node("/root/base_scene/Camera2D")
|
|
|
|
var addedscene = load(scene).instance()
|
|
|
|
addedscene.set_position(Vector2(-617,-300))
|
|
|
|
camera.add_child(addedscene)
|
2021-05-26 20:02:51 +00:00
|
|
|
|
2021-11-20 22:48:39 +00:00
|
|
|
# Remove the child
|
|
|
|
func RemoveScene(scene):
|
|
|
|
print("Removing scene ", scene)
|
|
|
|
var camera = get_node("/root/base_scene/Camera2D")
|
|
|
|
camera.remove_child(scene)
|
|
|
|
|
|
|
|
#Go to scene by name
|
2020-10-08 19:56:03 +00:00
|
|
|
func GoToScene(scene):
|
2021-11-20 22:48:39 +00:00
|
|
|
print("Going to scene ", scene)
|
|
|
|
var nextscene = load(scene)
|
|
|
|
get_tree().change_scene_to(nextscene)
|
2020-10-08 19:56:03 +00:00
|
|
|
|
2021-04-15 20:14:31 +00:00
|
|
|
func LoadSave(target="Storage.db"):
|
|
|
|
dbname = target
|
2020-10-07 20:24:10 +00:00
|
|
|
Database.OpenConnection()
|
2020-08-31 07:35:52 +00:00
|
|
|
|
2021-04-08 20:58:04 +00:00
|
|
|
#Save everything
|
|
|
|
func Save():
|
|
|
|
Database.SaveInventory(player_inventory_items)
|
|
|
|
print(player_inventory_items)
|
|
|
|
|
2021-04-03 14:06:23 +00:00
|
|
|
func Log(msg, level=1):
|
|
|
|
match level:
|
|
|
|
1:
|
|
|
|
print("[Log]" + msg)
|
|
|
|
2:
|
|
|
|
print("[Warn]" + msg)
|
|
|
|
3:
|
|
|
|
print("[Err]" + msg)
|