diff --git a/items/energy_cell.tres b/items/Valuables/energy_cell.tres similarity index 100% rename from items/energy_cell.tres rename to items/Valuables/energy_cell.tres diff --git a/items/food_supplies.tres b/items/Valuables/food_supplies.tres similarity index 100% rename from items/food_supplies.tres rename to items/Valuables/food_supplies.tres diff --git a/items/raw_materials.tres b/items/Valuables/raw_materials.tres similarity index 100% rename from items/raw_materials.tres rename to items/Valuables/raw_materials.tres diff --git a/items/water_barrel.tres b/items/Valuables/water_barrel.tres similarity index 100% rename from items/water_barrel.tres rename to items/Valuables/water_barrel.tres diff --git a/menus/Base Menu/BuySell/menu_buy.tres b/menus/Base Menu/BuySell/menu_buy.tres new file mode 100644 index 0000000..8688a26 --- /dev/null +++ b/menus/Base Menu/BuySell/menu_buy.tres @@ -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]) diff --git a/menus/Base Menu/BuySell/menu_sell.tres b/menus/Base Menu/BuySell/menu_sell.tres new file mode 100644 index 0000000..af1985c --- /dev/null +++ b/menus/Base Menu/BuySell/menu_sell.tres @@ -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]) diff --git a/menus/Base Menu/root_menu.tres b/menus/Base Menu/root_menu.tres new file mode 100644 index 0000000..cb42b86 --- /dev/null +++ b/menus/Base Menu/root_menu.tres @@ -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]) diff --git a/scenes/Base/base_menu.tscn b/scenes/Base/base_menu.tscn index 869f7fc..4ed0b35 100644 --- a/scenes/Base/base_menu.tscn +++ b/scenes/Base/base_menu.tscn @@ -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/close_button.gd" id="4_68ool"] [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"] layout_mode = 3 @@ -119,7 +119,7 @@ grow_horizontal = 2 grow_vertical = 2 columns = 2 script = ExtResource("4_3gtyd") -menu = ExtResource("5_rkret") +menu = ExtResource("6_78in3") metadata/_edit_use_anchors_ = true [node name="Action1" type="Button" parent="MenuBackground/Actions/ActionsMenu"] diff --git a/scripts/Base/base.gd b/scripts/Base/base.gd index f9e4cca..aa0e29c 100644 --- a/scripts/Base/base.gd +++ b/scripts/Base/base.gd @@ -17,9 +17,19 @@ signal dock_requested ## Menu which will instantiate on docking @export var menu: PackedScene - +## Faction that this base represents @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 var dock_state: DockState = DockState.Ready @@ -37,6 +47,7 @@ func _ready(): dock_area.body_exited.connect(dock_area_body_exited) dock_requested.connect(on_dock_requested) dock_ready() + generate_prices() ## Switches dock state func on_dock_requested(): @@ -90,20 +101,38 @@ func dock_busy(): var menu_instance = menu.instantiate() menu_instance.base = self player_ship.non_colorable_gui.add_child(menu_instance) - ## Sets dock state to Leave func dock_leave(): dock_state = DockState.Leave disable_gate() - +## Shows gate func enable_gate(): gate_static.visible = true gate_static.process_mode = Node.PROCESS_MODE_INHERIT gate_area.visible = false dock_area.visible = false - +## Hides gate so base is accessible to enter/exit func disable_gate(): gate_static.visible = false gate_static.process_mode = Node.PROCESS_MODE_DISABLED gate_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 diff --git a/scripts/Classes/game.gd b/scripts/Classes/game.gd index 4d1746d..4eb1d12 100644 --- a/scripts/Classes/game.gd +++ b/scripts/Classes/game.gd @@ -3,7 +3,7 @@ class_name Game ## TODO: rewrite item system -enum ItemType {Valuable, Weapon, Hull, Shield, Engine, Ammunition} + enum AmmoType {None, LaserEnergy, Rockets} enum BaseType {Power, Mining, Food, Trading, Module} enum Faction {None, Player, Peaceful, Neutral, Aggressive} diff --git a/scripts/Classes/item.gd b/scripts/Classes/item.gd index 16bf762..f2e7798 100644 --- a/scripts/Classes/item.gd +++ b/scripts/Classes/item.gd @@ -2,10 +2,12 @@ extends Resource class_name Item +enum ItemType {Valuable, Weapon, Hull, Shield, Engine, Ammunition} + @export var name : String @export var description : String @export var min_price : float @export var max_price : float @export var weight : float @export var icon : Texture -@export var type : Game.ITEM_TYPE +@export var type : ItemType diff --git a/sprites/items_icons/energy.png b/sprites/items_icons/energy.png deleted file mode 100644 index 25f8711..0000000 Binary files a/sprites/items_icons/energy.png and /dev/null differ diff --git a/sprites/items_icons/energy_cell.png b/sprites/items_icons/energy_cell.png new file mode 100644 index 0000000..9ce806e Binary files /dev/null and b/sprites/items_icons/energy_cell.png differ diff --git a/sprites/items_icons/water.png.import b/sprites/items_icons/energy_cell.png.import similarity index 67% rename from sprites/items_icons/water.png.import rename to sprites/items_icons/energy_cell.png.import index 43175fc..613ab98 100644 --- a/sprites/items_icons/water.png.import +++ b/sprites/items_icons/energy_cell.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://cova10yh1rlk1" -path="res://.godot/imported/water.png-c8b3df05b2aab92358df5a49fb5a60ba.ctex" +uid="uid://buh2eg0sjlcx0" +path="res://.godot/imported/energy_cell.png-9715829585386ce4220f2bb1d67cdd9c.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/items_icons/water.png" -dest_files=["res://.godot/imported/water.png-c8b3df05b2aab92358df5a49fb5a60ba.ctex"] +source_file="res://sprites/items_icons/energy_cell.png" +dest_files=["res://.godot/imported/energy_cell.png-9715829585386ce4220f2bb1d67cdd9c.ctex"] [params] diff --git a/sprites/items_icons/food.png b/sprites/items_icons/food.png deleted file mode 100644 index b1b8ea3..0000000 Binary files a/sprites/items_icons/food.png and /dev/null differ diff --git a/sprites/items_icons/food_supplies.png b/sprites/items_icons/food_supplies.png new file mode 100644 index 0000000..c126a6d Binary files /dev/null and b/sprites/items_icons/food_supplies.png differ diff --git a/sprites/items_icons/food.png.import b/sprites/items_icons/food_supplies.png.import similarity index 66% rename from sprites/items_icons/food.png.import rename to sprites/items_icons/food_supplies.png.import index 1aae01d..18ceec1 100644 --- a/sprites/items_icons/food.png.import +++ b/sprites/items_icons/food_supplies.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://w3aft10s2hxd" -path="res://.godot/imported/food.png-d786f9d11f7b590dd57cbb0e0eba166e.ctex" +uid="uid://bvun3kxlvs712" +path="res://.godot/imported/food_supplies.png-ae0622133a25efc1a080a47bd9df0359.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/items_icons/food.png" -dest_files=["res://.godot/imported/food.png-d786f9d11f7b590dd57cbb0e0eba166e.ctex"] +source_file="res://sprites/items_icons/food_supplies.png" +dest_files=["res://.godot/imported/food_supplies.png-ae0622133a25efc1a080a47bd9df0359.ctex"] [params] diff --git a/sprites/items_icons/raw_materials.png b/sprites/items_icons/raw_materials.png index c6b205a..2954220 100644 Binary files a/sprites/items_icons/raw_materials.png and b/sprites/items_icons/raw_materials.png differ diff --git a/sprites/items_icons/raw_materials.png.import b/sprites/items_icons/raw_materials.png.import index 4d6e26c..e37ddf1 100644 --- a/sprites/items_icons/raw_materials.png.import +++ b/sprites/items_icons/raw_materials.png.import @@ -2,7 +2,7 @@ importer="texture" type="CompressedTexture2D" -uid="uid://dlh6eyywjrsk4" +uid="uid://fttis3gwgq02" path="res://.godot/imported/raw_materials.png-17c645253a86197988c3802ae3935bdc.ctex" metadata={ "vram_texture": false diff --git a/sprites/items_icons/water.png b/sprites/items_icons/water.png deleted file mode 100644 index cbb1fb8..0000000 Binary files a/sprites/items_icons/water.png and /dev/null differ diff --git a/sprites/items_icons/water_barrel.png b/sprites/items_icons/water_barrel.png new file mode 100644 index 0000000..f39dc70 Binary files /dev/null and b/sprites/items_icons/water_barrel.png differ diff --git a/sprites/items_icons/energy.png.import b/sprites/items_icons/water_barrel.png.import similarity index 67% rename from sprites/items_icons/energy.png.import rename to sprites/items_icons/water_barrel.png.import index 4ff633f..9151394 100644 --- a/sprites/items_icons/energy.png.import +++ b/sprites/items_icons/water_barrel.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://daojdy0tpvsoh" -path="res://.godot/imported/energy.png-56852b83575bd48e69877e4e7f810483.ctex" +uid="uid://cvimydsdecmom" +path="res://.godot/imported/water_barrel.png-fab99a878661fcb2fc07982bd58602b7.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://sprites/items_icons/energy.png" -dest_files=["res://.godot/imported/energy.png-56852b83575bd48e69877e4e7f810483.ctex"] +source_file="res://sprites/items_icons/water_barrel.png" +dest_files=["res://.godot/imported/water_barrel.png-fab99a878661fcb2fc07982bd58602b7.ctex"] [params] diff --git a/translations/base_dialogue.csv b/translations/base_dialogue.csv index 3a7b810..0791d5b 100644 --- a/translations/base_dialogue.csv +++ b/translations/base_dialogue.csv @@ -1,4 +1,14 @@ ,en,ru 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_RECEIVED,"Hello, gryadki!\n\tBye, ponos!\n> ","Хеллоу, грядки!\n\tБай, понос!\n> " \ No newline at end of file +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, , \ No newline at end of file diff --git a/translations/base_dialogue.en.translation b/translations/base_dialogue.en.translation index 961cd2c..ef11769 100644 Binary files a/translations/base_dialogue.en.translation and b/translations/base_dialogue.en.translation differ diff --git a/translations/base_dialogue.ru.translation b/translations/base_dialogue.ru.translation index 480fa47..6c0c416 100644 Binary files a/translations/base_dialogue.ru.translation and b/translations/base_dialogue.ru.translation differ