Added item resource
This commit is contained in:
parent
a46e5eb53a
commit
679a3187f7
3 changed files with 50 additions and 22 deletions
15
items/test_item.tres
Normal file
15
items/test_item.tres
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
[gd_resource type="Resource" script_class="Item" load_steps=4 format=3 uid="uid://bii3yrhoqcket"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c3gei46k8muk3" path="res://sprites/laserbox.png" id="1_e5k7o"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/item.gd" id="1_s7nhb"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dbwvej0c5bl52" path="res://sprites/ship mk1.png" id="2_l1qse"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_s7nhb")
|
||||||
|
name = "Test Item"
|
||||||
|
min_price = 10.0
|
||||||
|
max_price = 100.0
|
||||||
|
stack_size = 5
|
||||||
|
icon = ExtResource("1_e5k7o")
|
||||||
|
image = ExtResource("2_l1qse")
|
||||||
|
type = 0
|
||||||
|
|
@ -2,33 +2,35 @@ extends Node
|
||||||
|
|
||||||
class_name Game
|
class_name Game
|
||||||
|
|
||||||
|
enum ITEM_TYPE {VALUABLE, WEAPON, MODULE}
|
||||||
|
|
||||||
static var gameversion = "Ictar 1.1"
|
static var gameversion = "Ictar 1.1"
|
||||||
|
|
||||||
static func profile_create(profile_name):
|
static func profile_create(profile_name):
|
||||||
var path = "user://"+profile_name+".cosmic"
|
var path = "user://"+profile_name+".cosmic"
|
||||||
if not FileAccess.file_exists(path):
|
if FileAccess.file_exists(path):
|
||||||
var profile_meta = {
|
|
||||||
'hash' : {},
|
|
||||||
'meta' : {
|
|
||||||
'created_in_version' : gameversion,
|
|
||||||
'creation_date' : Time.get_datetime_string_from_system(),
|
|
||||||
'last_version' : gameversion,
|
|
||||||
'last_updated' : Time.get_datetime_string_from_system(),
|
|
||||||
'profile_name' : profile_name,
|
|
||||||
'legit' : true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var profile_meta_keys = profile_meta['meta'].keys()
|
|
||||||
for i in range(len(profile_meta_keys)):
|
|
||||||
if profile_meta_keys[i][0] == "_":
|
|
||||||
profile_meta_keys.remove_at(i)
|
|
||||||
for i in range(len(profile_meta_keys)):
|
|
||||||
profile_meta['hash'][i] = str(profile_meta['meta'][profile_meta_keys[i]]).sha256_buffer().hex_encode()
|
|
||||||
var file = FileAccess.open(path, FileAccess.WRITE)
|
|
||||||
var json_string = JSON.stringify(profile_meta, "\t")
|
|
||||||
file.store_string(json_string)
|
|
||||||
else:
|
|
||||||
profile_save(profile_name, "menu")
|
profile_save(profile_name, "menu")
|
||||||
|
return
|
||||||
|
var profile_meta = {
|
||||||
|
'hash' : {},
|
||||||
|
'meta' : {
|
||||||
|
'created_in_version' : gameversion,
|
||||||
|
'creation_date' : Time.get_datetime_string_from_system(),
|
||||||
|
'last_version' : gameversion,
|
||||||
|
'last_updated' : Time.get_datetime_string_from_system(),
|
||||||
|
'profile_name' : profile_name,
|
||||||
|
'legit' : true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var profile_meta_keys = profile_meta['meta'].keys()
|
||||||
|
for i in range(len(profile_meta_keys)):
|
||||||
|
if profile_meta_keys[i][0] == "_":
|
||||||
|
profile_meta_keys.remove_at(i)
|
||||||
|
for i in range(len(profile_meta_keys)):
|
||||||
|
profile_meta['hash'][i] = str(profile_meta['meta'][profile_meta_keys[i]]).sha256_buffer().hex_encode()
|
||||||
|
var file = FileAccess.open(path, FileAccess.WRITE)
|
||||||
|
var json_string = JSON.stringify(profile_meta, "\t")
|
||||||
|
file.store_string(json_string)
|
||||||
|
|
||||||
static func profile_save(profile_name, _gamestate):
|
static func profile_save(profile_name, _gamestate):
|
||||||
var path = "user://"+profile_name+".cosmic"
|
var path = "user://"+profile_name+".cosmic"
|
||||||
|
|
|
||||||
11
scripts/item.gd
Normal file
11
scripts/item.gd
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
extends Resource
|
||||||
|
|
||||||
|
class_name Item
|
||||||
|
|
||||||
|
@export var name : String
|
||||||
|
@export var min_price : float
|
||||||
|
@export var max_price : float
|
||||||
|
@export var stack_size : int
|
||||||
|
@export var icon : Texture
|
||||||
|
@export var image : Texture
|
||||||
|
@export var type : Game.ITEM_TYPE
|
||||||
Loading…
Add table
Add a link
Reference in a new issue