Added base items on buy/sell, new valuables icons
This commit is contained in:
parent
bedeee894a
commit
20de519cd1
25 changed files with 113 additions and 22 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue