Added base items on buy/sell, new valuables icons

This commit is contained in:
2ndbeam 2024-05-20 18:29:44 +03:00
commit 20de519cd1
25 changed files with 113 additions and 22 deletions

View file

@ -0,0 +1,15 @@
[gd_resource type="Resource" script_class="Menu" load_steps=4 format=3 uid="uid://cbvax7aprnrig"]
[ext_resource type="Script" path="res://scripts/Classes/Menu/combo_menu_resource.gd" id="1_xamua"]
[ext_resource type="Script" path="res://scripts/Classes/Menu/menu.gd" id="2_f8fna"]
[sub_resource type="Resource" id="Resource_5pmle"]
script = ExtResource("1_xamua")
item_script = &"res://scripts/Base/Menu/send_message.gd"
item_menu = &"res://menus/Base Menu/root_menu.tres"
[resource]
script = ExtResource("2_f8fna")
item_ids = Array[String](["BASE_FETCH_BUY_CANCEL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"])
item_actions = Array[int]([3, 0, 0, 0, 0, 0, 0, 0])
item_data = Array[Resource("res://scripts/Classes/Menu/menu_resource.gd")]([SubResource("Resource_5pmle"), null, null, null, null, null, null, null])

View file

@ -0,0 +1,15 @@
[gd_resource type="Resource" script_class="Menu" load_steps=4 format=3 uid="uid://cgxrk15hgidts"]
[ext_resource type="Script" path="res://scripts/Classes/Menu/combo_menu_resource.gd" id="1_u5y0w"]
[ext_resource type="Script" path="res://scripts/Classes/Menu/menu.gd" id="2_0edl4"]
[sub_resource type="Resource" id="Resource_5pmle"]
script = ExtResource("1_u5y0w")
item_script = &"res://scripts/Base/Menu/send_message.gd"
item_menu = &"res://menus/Base Menu/root_menu.tres"
[resource]
script = ExtResource("2_0edl4")
item_ids = Array[String](["BASE_FETCH_SELL_CANCEL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"])
item_actions = Array[int]([3, 0, 0, 0, 0, 0, 0, 0])
item_data = Array[Resource("res://scripts/Classes/Menu/menu_resource.gd")]([SubResource("Resource_5pmle"), null, null, null, null, null, null, null])

View file

@ -0,0 +1,20 @@
[gd_resource type="Resource" script_class="Menu" load_steps=5 format=3 uid="uid://2ohcxoor22hr"]
[ext_resource type="Script" path="res://scripts/Classes/Menu/combo_menu_resource.gd" id="1_d2x8v"]
[ext_resource type="Script" path="res://scripts/Classes/Menu/menu.gd" id="1_h4chp"]
[sub_resource type="Resource" id="Resource_iiy7m"]
script = ExtResource("1_d2x8v")
item_script = &"res://scripts/Base/Menu/send_message.gd"
item_menu = &"res://menus/Base Menu/BuySell/menu_buy.tres"
[sub_resource type="Resource" id="Resource_pbhiw"]
script = ExtResource("1_d2x8v")
item_script = &"res://scripts/Base/Menu/send_message.gd"
item_menu = &"res://menus/Base Menu/BuySell/menu_sell.tres"
[resource]
script = ExtResource("1_h4chp")
item_ids = Array[String](["BASE_FETCH_BUY", "BASE_FETCH_SELL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"])
item_actions = Array[int]([3, 3, 0, 0, 0, 0, 0, 0])
item_data = Array[Resource("res://scripts/Classes/Menu/menu_resource.gd")]([SubResource("Resource_iiy7m"), SubResource("Resource_pbhiw"), null, null, null, null, null, null])

View file

@ -7,7 +7,7 @@
[ext_resource type="Script" path="res://scripts/Base/actions_menu.gd" id="4_3gtyd"] [ext_resource type="Script" path="res://scripts/Base/actions_menu.gd" id="4_3gtyd"]
[ext_resource type="Script" path="res://scripts/Base/close_button.gd" id="4_68ool"] [ext_resource type="Script" path="res://scripts/Base/close_button.gd" id="4_68ool"]
[ext_resource type="Script" path="res://scripts/Base/Menu/dialogue.gd" id="4_swpa1"] [ext_resource type="Script" path="res://scripts/Base/Menu/dialogue.gd" id="4_swpa1"]
[ext_resource type="Resource" uid="uid://c4jg3vwtxskjm" path="res://menus/Base Menu/test_menu_1.tres" id="5_rkret"] [ext_resource type="Resource" uid="uid://2ohcxoor22hr" path="res://menus/Base Menu/root_menu.tres" id="6_78in3"]
[node name="BaseMenu" type="Control"] [node name="BaseMenu" type="Control"]
layout_mode = 3 layout_mode = 3
@ -119,7 +119,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
columns = 2 columns = 2
script = ExtResource("4_3gtyd") script = ExtResource("4_3gtyd")
menu = ExtResource("5_rkret") menu = ExtResource("6_78in3")
metadata/_edit_use_anchors_ = true metadata/_edit_use_anchors_ = true
[node name="Action1" type="Button" parent="MenuBackground/Actions/ActionsMenu"] [node name="Action1" type="Button" parent="MenuBackground/Actions/ActionsMenu"]

View file

@ -17,9 +17,19 @@ signal dock_requested
## Menu which will instantiate on docking ## Menu which will instantiate on docking
@export var menu: PackedScene @export var menu: PackedScene
## Faction that this base represents
@export var faction: Game.Faction @export var faction: Game.Faction
## List of items that this base sells
@export var items_on_sell: Array[Item]
## List of items that this base buys
@export var items_on_buy: Array[Item]
## List of prices for items that this base sells
var sell_prices: Array[float]
## List of prices for items that this base buys
var buy_prices: Array[float]
## Decides whether ship is docked or in process ## Decides whether ship is docked or in process
var dock_state: DockState = DockState.Ready var dock_state: DockState = DockState.Ready
@ -37,6 +47,7 @@ func _ready():
dock_area.body_exited.connect(dock_area_body_exited) dock_area.body_exited.connect(dock_area_body_exited)
dock_requested.connect(on_dock_requested) dock_requested.connect(on_dock_requested)
dock_ready() dock_ready()
generate_prices()
## Switches dock state ## Switches dock state
func on_dock_requested(): func on_dock_requested():
@ -90,20 +101,38 @@ func dock_busy():
var menu_instance = menu.instantiate() var menu_instance = menu.instantiate()
menu_instance.base = self menu_instance.base = self
player_ship.non_colorable_gui.add_child(menu_instance) player_ship.non_colorable_gui.add_child(menu_instance)
## Sets dock state to Leave ## Sets dock state to Leave
func dock_leave(): func dock_leave():
dock_state = DockState.Leave dock_state = DockState.Leave
disable_gate() disable_gate()
## Shows gate
func enable_gate(): func enable_gate():
gate_static.visible = true gate_static.visible = true
gate_static.process_mode = Node.PROCESS_MODE_INHERIT gate_static.process_mode = Node.PROCESS_MODE_INHERIT
gate_area.visible = false gate_area.visible = false
dock_area.visible = false dock_area.visible = false
## Hides gate so base is accessible to enter/exit
func disable_gate(): func disable_gate():
gate_static.visible = false gate_static.visible = false
gate_static.process_mode = Node.PROCESS_MODE_DISABLED gate_static.process_mode = Node.PROCESS_MODE_DISABLED
gate_area.visible = true gate_area.visible = true
dock_area.visible = true dock_area.visible = true
## Generates prices for valuable items
func generate_prices():
# gen prices for buyable items
for i in range(len(items_on_buy)):
var item = items_on_buy[i]
if item in items_on_sell:
# buy not higher than avg price
buy_prices[i] = randi_range(item.min_price * 100, (item.max_price + item.min_price) * 50) / 100.0
else:
buy_prices[i] = randi_range(item.min_price * 100, item.max_price * 100) / 100.0
# gen prices for items in sell
for i in range(len(items_on_sell)):
var item = items_on_sell[i]
if item in items_on_buy:
# sell not lower than avg price
sell_prices[i] = randi_range((item.min_price + item.max_price) * 50, item.max_price * 100) / 100.0
else:
sell_prices[i] = randi_range(item.min_price * 100, item.max_price * 100) / 100.0

View file

@ -3,7 +3,7 @@ class_name Game
## TODO: rewrite item system ## TODO: rewrite item system
enum ItemType {Valuable, Weapon, Hull, Shield, Engine, Ammunition}
enum AmmoType {None, LaserEnergy, Rockets} enum AmmoType {None, LaserEnergy, Rockets}
enum BaseType {Power, Mining, Food, Trading, Module} enum BaseType {Power, Mining, Food, Trading, Module}
enum Faction {None, Player, Peaceful, Neutral, Aggressive} enum Faction {None, Player, Peaceful, Neutral, Aggressive}

View file

@ -2,10 +2,12 @@ extends Resource
class_name Item class_name Item
enum ItemType {Valuable, Weapon, Hull, Shield, Engine, Ammunition}
@export var name : String @export var name : String
@export var description : String @export var description : String
@export var min_price : float @export var min_price : float
@export var max_price : float @export var max_price : float
@export var weight : float @export var weight : float
@export var icon : Texture @export var icon : Texture
@export var type : Game.ITEM_TYPE @export var type : ItemType

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 B

View file

@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://cova10yh1rlk1" uid="uid://buh2eg0sjlcx0"
path="res://.godot/imported/water.png-c8b3df05b2aab92358df5a49fb5a60ba.ctex" path="res://.godot/imported/energy_cell.png-9715829585386ce4220f2bb1d67cdd9c.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://sprites/items_icons/water.png" source_file="res://sprites/items_icons/energy_cell.png"
dest_files=["res://.godot/imported/water.png-c8b3df05b2aab92358df5a49fb5a60ba.ctex"] dest_files=["res://.godot/imported/energy_cell.png-9715829585386ce4220f2bb1d67cdd9c.ctex"]
[params] [params]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://w3aft10s2hxd" uid="uid://bvun3kxlvs712"
path="res://.godot/imported/food.png-d786f9d11f7b590dd57cbb0e0eba166e.ctex" path="res://.godot/imported/food_supplies.png-ae0622133a25efc1a080a47bd9df0359.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://sprites/items_icons/food.png" source_file="res://sprites/items_icons/food_supplies.png"
dest_files=["res://.godot/imported/food.png-d786f9d11f7b590dd57cbb0e0eba166e.ctex"] dest_files=["res://.godot/imported/food_supplies.png-ae0622133a25efc1a080a47bd9df0359.ctex"]
[params] [params]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Before After
Before After

View file

@ -2,7 +2,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://dlh6eyywjrsk4" uid="uid://fttis3gwgq02"
path="res://.godot/imported/raw_materials.png-17c645253a86197988c3802ae3935bdc.ctex" path="res://.godot/imported/raw_materials.png-17c645253a86197988c3802ae3935bdc.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

View file

@ -2,16 +2,16 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://daojdy0tpvsoh" uid="uid://cvimydsdecmom"
path="res://.godot/imported/energy.png-56852b83575bd48e69877e4e7f810483.ctex" path="res://.godot/imported/water_barrel.png-fab99a878661fcb2fc07982bd58602b7.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://sprites/items_icons/energy.png" source_file="res://sprites/items_icons/water_barrel.png"
dest_files=["res://.godot/imported/energy.png-56852b83575bd48e69877e4e7f810483.ctex"] dest_files=["res://.godot/imported/water_barrel.png-fab99a878661fcb2fc07982bd58602b7.ctex"]
[params] [params]

View file

@ -1,4 +1,14 @@
,en,ru ,en,ru
DIALOGUE_ENTRY_POINT,Entering chat with {race}...\nLogged in as {profile_name}.\n> ,Осуществление связи с {race}...\nВы вошли в систему как {profile_name}\n> DIALOGUE_ENTRY_POINT,Entering chat with {race}...\nLogged in as {profile_name}.\n> ,Осуществление связи с {race}...\nВы вошли в систему как {profile_name}\n>
BASE_TEST_MESSAGE_LOCAL,Greet,Поприветствовать BASE_TEST_MESSAGE_LOCAL,Greet,Поприветствовать
BASE_TEST_MESSAGE_RECEIVED,"Hello, gryadki!\n\tBye, ponos!\n> ","Хеллоу, грядки!\n\tБай, понос!\n> " BASE_TEST_MESSAGE_RECEIVED,"Hello, gryadki!\nBye, ponos!\n> ","Хеллоу, грядки!\nБай, понос!\n> "
BASE_FETCH_BUY_LOCAL,"Ask, what they sell","Спросить, что они покупают"
BASE_FETCH_BUY_RECEIVED,I would like to buy something\nWe are selling:\n[ol]{sell_list}[/ol]\n> ,Я бы хотел что-нибудь купить\nМы продаём:\n[ol]{sell_list}[/ol]\n>
BASE_FETCH_SELL_LOCAL,"Ask, what they buy","Спросить, что они продают"
BASE_FETCH_SELL_RECEIVED,I have some items to sell\nWe can buy:\n[ol]{buy_list}[/ol]\n> ,У меня есть кое-что на продажу\nМы готовы купить:\n[ol]{buy_list}[/ol]\n>
BASE_FETCH_PRICE_ITEM,[li][img=26x26]{item_img}[/img]\t{item_name} — {item_price}[/li],[li][img=26x26]{item_img}[/img]\t{item_name} — {item_price}[/li]
BASE_FETCH_BUY_CANCEL_LOCAL,Buy nothing,Ничего не покупать
BASE_FETCH_BUY_CANCEL_RECEIVED,I changed my mind\nErm...Fine...\nAnything else?\n> ,Я передумал\nЧто ж...Ладно...\nЧто-то ещё?\n>
BASE_FETCH_SELL_CANCEL_LOCAL,Sell nothing,Ничего не продавать
BASE_FETCH_SELL_CANCEL_RECEIVED,I changed my mind\nErm...Fine...\nAnything else?\n> ,Я передумал\nЧто ж...Ладно...\nЧто-то ещё?\n>
NULL, ,
1 en ru
2 DIALOGUE_ENTRY_POINT Entering chat with {race}...\nLogged in as {profile_name}.\n> Осуществление связи с {race}...\nВы вошли в систему как {profile_name}\n>
3 BASE_TEST_MESSAGE_LOCAL Greet Поприветствовать
4 BASE_TEST_MESSAGE_RECEIVED Hello, gryadki!\n\tBye, ponos!\n> Hello, gryadki!\nBye, ponos!\n> Хеллоу, грядки!\n\tБай, понос!\n> Хеллоу, грядки!\nБай, понос!\n>
5 BASE_FETCH_BUY_LOCAL Ask, what they sell Спросить, что они покупают
6 BASE_FETCH_BUY_RECEIVED I would like to buy something\nWe are selling:\n[ol]{sell_list}[/ol]\n> Я бы хотел что-нибудь купить\nМы продаём:\n[ol]{sell_list}[/ol]\n>
7 BASE_FETCH_SELL_LOCAL Ask, what they buy Спросить, что они продают
8 BASE_FETCH_SELL_RECEIVED I have some items to sell\nWe can buy:\n[ol]{buy_list}[/ol]\n> У меня есть кое-что на продажу\nМы готовы купить:\n[ol]{buy_list}[/ol]\n>
9 BASE_FETCH_PRICE_ITEM [li][img=26x26]{item_img}[/img]\t{item_name} — {item_price}[/li] [li][img=26x26]{item_img}[/img]\t{item_name} — {item_price}[/li]
10 BASE_FETCH_BUY_CANCEL_LOCAL Buy nothing Ничего не покупать
11 BASE_FETCH_BUY_CANCEL_RECEIVED I changed my mind\nErm...Fine...\nAnything else?\n> Я передумал\nЧто ж...Ладно...\nЧто-то ещё?\n>
12 BASE_FETCH_SELL_CANCEL_LOCAL Sell nothing Ничего не продавать
13 BASE_FETCH_SELL_CANCEL_RECEIVED I changed my mind\nErm...Fine...\nAnything else?\n> Я передумал\nЧто ж...Ладно...\nЧто-то ещё?\n>
14 NULL