New items + base typing + price generation + new menu template

This commit is contained in:
gotfishmakesticks 2023-11-13 13:38:43 +03:00
commit 50be4a0bb2
20 changed files with 408 additions and 37 deletions

View file

@ -13,7 +13,7 @@ var color_enemy
@export var map_width = 8192
@export var map_height = 8192
@onready var ship = $MainShip
@onready var base = $StarterBase
@onready var bases = $Bases
@onready var enemy_faction = $EnemyFaction
func _ready():
@ -63,22 +63,29 @@ func _process(_delta):
pause()
func pause():
var menu = get_node_or_null("MainShip/GUI/BaseMenu")
if menu != null:
menu.visible = false
get_tree().paused = true
ship.pause_controller.visible = true
func unpause():
get_tree().paused = false
ship.pause_controller.visible = false
var menu = get_node_or_null("MainShip/GUI/BaseMenu")
if menu != null:
menu.visible = true
func recolor():
color_player = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1))
color_base = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1))
color_enemy = Color.from_hsv(randf(), randf_range(0.8, 1), randf_range(0.8, 1))
ship.modulate = color_player
base.modulate = color_base
bases.modulate = color_base
enemy_faction.modulate = color_enemy
enemy_faction.changeitemscolor()
bases.changeitemscolor()
ship.changeinterfacecolor()
var menu = get_node_or_null("MainShip/GUI/StarterBaseMenu")
if menu != null:
menu.modulate = base.modulate
menu.modulate = bases.modulate

View file

@ -4,6 +4,7 @@ class_name Game
enum ITEM_TYPE {VALUABLE, WEAPON, MODULE, AMMUNITION}
enum AMMO_TYPE {NULL, LASER_ENERGY, ROCKETS}
enum BASE_TYPE {POWER, MINING, FOOD, TRADING, MODULE}
const DEFAULT_ITEM = preload("res://items/test_item.tres")
const DEFAULT_WEAPON = preload("res://scenes/weapons/presets/SingleLaserMk1.tscn")

View file

@ -6,7 +6,7 @@ class_name Item
@export var description : String
@export var min_price : float
@export var max_price : float
@export var stack_size : int
@export var weight : float
@export var icon : Texture
@export var image : Texture
@export var type : Game.ITEM_TYPE

3
scripts/menu/BaseMenu.gd Normal file
View file

@ -0,0 +1,3 @@
extends Control
var base

View file

@ -0,0 +1,10 @@
extends BaseButton
@onready var main_menu = $"../../MainMenu"
func _ready():
button_up.connect(close)
func close():
get_parent().visible = false
main_menu.visible = true

View file

@ -19,7 +19,8 @@ func _ready():
change_menu(0)
else:
change_menu(5)
profile_status.text = "Current profile: [{profile}]".format({"profile": Game.profile.profile_meta['meta']['profile_name']})
var format = {"profile": Game.profile.profile_meta['meta']['profile_name']}
profile_status.text = "Current profile: [{profile}]".format(format)
func change_menu(id):
input.visible = false

View file

@ -0,0 +1,23 @@
extends BaseButton
@onready var trading_menu = $"../../TradingMenu"
@onready var quest_menu = $"../../QuestMenu"
@onready var equipment_menu = $"../../EquipmentMenu"
@onready var info_menu = $"../../InfoMenu"
func _ready():
button_up.connect(open)
func open():
var menu
match name:
"TradingMenuGoto":
menu = trading_menu
"QuestMenuGoto":
menu = quest_menu
"EquipmentMenuGoto":
menu = equipment_menu
"InfoMenuGoto":
menu = info_menu
menu.visible = true
get_parent().visible = false

View file

@ -15,6 +15,7 @@ func _on_body_entered(body):
menu_inst = menu.instantiate()
body.find_child("GUI").add_child(menu_inst)
menu_inst.modulate = get_parent().modulate
menu_inst.base = get_parent()
func _on_body_exited(body):
if body is MainShip:

View file

@ -1,8 +1,11 @@
extends Node2D
@export var faction : bool
func changeitemscolor():
var items = get_children()
var ship = get_tree().current_scene.get_node("MainShip")
var ship = get_tree().current_scene.ship
for item in items:
item.modulate = modulate
ship.minimap.add_marker(item, "hostile")
if faction:
ship.minimap.add_marker(item, "hostile")

View file

@ -1,7 +0,0 @@
extends Node2D
@onready var menu = $MenuCollider
@onready var ship = get_tree().current_scene.get_node("MainShip")
func _ready():
ship.minimap.add_marker(self, "base")

55
scripts/objects/Base.gd Normal file
View file

@ -0,0 +1,55 @@
extends Node2D
@export var type : Game.BASE_TYPE
@onready var menu : Area2D = $MenuCollider
@onready var ship : MainShip = get_tree().current_scene.get_node("MainShip")
var want_to_sell : Array[Item] = []
var want_to_buy : Array[Item] = []
var sell_prices : Array[float] = []
var buy_prices : Array[float] = []
func _ready():
ship.minimap.add_marker(self, "base")
match type:
Game.BASE_TYPE.POWER:
want_to_sell.append(Game.get_item("Energy Cell"))
want_to_buy.append(Game.get_item("Raw Materials"))
want_to_buy.append(Game.get_item("Water Barrel"))
want_to_buy.append(Game.get_item("Food Supplies"))
Game.BASE_TYPE.MINING:
want_to_sell.append(Game.get_item("Raw Materials"))
want_to_sell.append(Game.get_item("Water Barrel"))
want_to_buy.append(Game.get_item("Energy Cell"))
want_to_buy.append(Game.get_item("Food Supplies"))
Game.BASE_TYPE.FOOD:
want_to_sell.append(Game.get_item("Food Supplies"))
want_to_buy.append(Game.get_item("Water Barrel"))
want_to_buy.append(Game.get_item("Energy Cell"))
want_to_buy.append(Game.get_item("Raw Materials"))
Game.BASE_TYPE.TRADING:
want_to_sell.append(Game.get_item("Food Supplies"))
want_to_sell.append(Game.get_item("Water Barrel"))
want_to_sell.append(Game.get_item("Energy Cell"))
want_to_sell.append(Game.get_item("Raw Materials"))
want_to_buy.append(Game.get_item("Food Supplies"))
want_to_buy.append(Game.get_item("Water Barrel"))
want_to_buy.append(Game.get_item("Energy Cell"))
want_to_buy.append(Game.get_item("Raw Materials"))
update_prices()
func update_prices():
sell_prices = []
buy_prices = []
var price : float
for item in want_to_sell:
price = randi_range(item.min_price * 100, item.max_price * 100) / 100
sell_prices.append(price)
for item in want_to_buy:
if type != Game.BASE_TYPE.TRADING:
price = randi_range((item.max_price + item.min_price) / 2 * 100, item.max_price * 100) / 100
else:
price = randi_range(item.min_price * 100, (item.max_price + item.min_price) / 2 * 100) / 100
buy_prices.append(price)
print(sell_prices, buy_prices)

View file

@ -2,12 +2,14 @@ extends Node2D
class_name Hull
@export var max_hp : int = 30
@export var max_fuel : int = 1000
@onready var hp = max_hp
@export var max_hp : float = 30
@export var max_fuel : float = 1000
@export var max_weight : float = 100
@onready var hp : float = max_hp
@onready var fuel : float = max_fuel
var weight : float = 0
var ammunition = {
"n/a" : 0,
"Laser Energy" : 100,
@ -19,3 +21,5 @@ var max_ammunition = {
"Laser Energy" : 100,
"Rockets" : 20
}
var cargo = {}