This commit is contained in:
Tirith 2025-11-14 14:59:50 +01:00
parent 500cdaa6c9
commit 12221b0995
17 changed files with 203 additions and 24 deletions

BIN
assets/ships/fregata.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d35tsxrdu12mi"
path="res://.godot/imported/fregata.png-db9b929ff88fcab21e463787d5bfafbd.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ships/fregata.png"
dest_files=["res://.godot/imported/fregata.png-db9b929ff88fcab21e463787d5bfafbd.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
assets/ships/transport.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://isv0twji5ech"
path="res://.godot/imported/transport.png-0c67e23931680d08182c4c1f33f70fef.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ships/transport.png"
dest_files=["res://.godot/imported/transport.png-0c67e23931680d08182c4c1f33f70fef.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -25,6 +25,7 @@ GameData="*res://scripts/GameData.gd"
BuildingsList="*res://scripts/BuildingsList.gd" BuildingsList="*res://scripts/BuildingsList.gd"
PlayerData="*res://scripts/PlayerData.gd" PlayerData="*res://scripts/PlayerData.gd"
Technologies="*res://scripts/technologies.gd" Technologies="*res://scripts/technologies.gd"
ShipsType="*res://scripts/ships_type.gd"
[display] [display]

View File

@ -83,28 +83,32 @@ offset_bottom = 142.0
size_flags_horizontal = 0 size_flags_horizontal = 0
[node name="TechPanel" parent="UI" instance=ExtResource("9_lwv00")] [node name="TechPanel" parent="UI" instance=ExtResource("9_lwv00")]
offset_left = -1031.4401 visible = false
offset_top = -379.12006 offset_left = -1265.4401
offset_right = -375.44006 offset_top = -430.12006
offset_bottom = -203.12006 offset_right = -609.44006
offset_bottom = -254.12006
[node name="StationPanel" parent="UI" instance=ExtResource("10_ntfcv")] [node name="StationPanel" parent="UI" instance=ExtResource("10_ntfcv")]
visible = false visible = false
offset_left = 989.0 offset_left = 17.0
offset_top = 158.0 offset_top = 394.0
offset_right = 1633.0 offset_right = 661.0
offset_bottom = 727.0 offset_bottom = 963.0
[node name="Label" parent="UI/StationPanel" index="0"] [node name="Label" parent="UI/StationPanel" index="0"]
offset_right = 636.0 offset_right = 636.0
[node name="Button" parent="UI/StationPanel" index="1"] [node name="Button" parent="UI/StationPanel" index="1"]
offset_left = 205.0 offset_left = 38.0
offset_top = 216.0 offset_top = 98.0
offset_right = 442.0 offset_right = 257.0
offset_bottom = 363.0 offset_bottom = 138.0
[node name="Button2" parent="UI/StationPanel" index="2"] [node name="Button3" parent="UI/StationPanel" index="2"]
offset_right = 257.0
[node name="Button2" parent="UI/StationPanel" index="3"]
offset_left = 607.0 offset_left = 607.0
offset_top = 9.0 offset_top = 9.0
offset_right = 636.0 offset_right = 636.0

9
scenes/ship.tscn Normal file
View File

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://ctvmetux3loj7"]
[ext_resource type="Script" uid="uid://d4adbk672ye2t" path="res://scripts/ship.gd" id="1_q631a"]
[node name="ship" type="Node2D"]
script = ExtResource("1_q631a")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.03125, 0.035156246)

View File

@ -30,12 +30,20 @@ horizontal_alignment = 1
[node name="Button" type="Button" parent="."] [node name="Button" type="Button" parent="."]
layout_mode = 0 layout_mode = 0
offset_left = 287.0 offset_left = 40.0
offset_top = 220.0 offset_top = 100.0
offset_right = 524.0 offset_right = 221.0
offset_bottom = 367.0 offset_bottom = 140.0
text = "Zbuduj fregatę" text = "Zbuduj fregatę"
[node name="Button3" type="Button" parent="."]
layout_mode = 0
offset_left = 38.0
offset_top = 152.0
offset_right = 195.0
offset_bottom = 192.0
text = "Zbuduj transportowiec"
[node name="Button2" type="Button" parent="."] [node name="Button2" type="Button" parent="."]
layout_mode = 0 layout_mode = 0
offset_left = 770.0 offset_left = 770.0
@ -44,4 +52,6 @@ offset_right = 799.0
offset_bottom = 39.0 offset_bottom = 39.0
text = "X" text = "X"
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
[connection signal="pressed" from="Button3" to="." method="_on_button_3_pressed"]
[connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"] [connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"]

View File

@ -8,7 +8,7 @@ var race: String = "Ludzie"
# Zasoby globalne # Zasoby globalne
var resources := { var resources := {
"iron": 11.0, "iron": 18.0,
"copper": 0.0, "copper": 0.0,
"water": 0.0, "water": 0.0,
"carbon": 0.0, "carbon": 0.0,

View File

@ -61,7 +61,7 @@ func _generate_galaxy(count: int):
var planet = PlanetScene.instantiate() var planet = PlanetScene.instantiate()
planet.parent_star = star planet.parent_star = star
planet.pname = Names.planet_names[randi() % Names.planet_names.size()] planet.pname = Names.planet_names[randi() % Names.planet_names.size()]
planet.orbit_radius = 65 + j * 40 planet.orbit_radius = 70 + j * 40
planet.orbit_speed = randf_range(0.004, 0.01) planet.orbit_speed = randf_range(0.004, 0.01)
planet.since_potential = 0.1 + (2.0 - 0.1) * pow(randf(), 4.0) planet.since_potential = 0.1 + (2.0 - 0.1) * pow(randf(), 4.0)
planet.size = randi_range(1, 3) planet.size = randi_range(1, 3)

View File

@ -9,13 +9,13 @@ var map_speed = 0.02
#ustawienia mapy #ustawienia mapy
var x = 12000 var x = 12000
var y = 12000 var y = 12000
const MIN_DISTANCE: float = 900 const MIN_DISTANCE: float = 1000
const MAX_PLACEMENT_ATTEMPTS: int = 50 const MAX_PLACEMENT_ATTEMPTS: int = 50
const MARGIN: float = 50.0 const MARGIN: float = 50.0
var NUMBER_OF_SYSTEMS: int = 100 var NUMBER_OF_SYSTEMS: int = 50
#Ilosc systemów #Ilosc systemów
var min_planet = 1 var min_planet = 1
var max_planet = 5 var max_planet = 6
#Zmiana upływu czasu #Zmiana upływu czasu
#var TIME_SCALE = 1 #var TIME_SCALE = 1

15
scripts/ship.gd Normal file
View File

@ -0,0 +1,15 @@
extends Node2D
class_name Ship
var ship_type : String
var speed := 100.0
var target_position
func setup(type):
ship_type = type
speed = ShipsType.SHIP_TYPES[type].speed
# Ustawienie tekstury ze słownika
var tex_path = ShipsType.SHIP_TYPES[type]["texture"]
var texture = load(tex_path)
$Sprite2D.texture = texture

1
scripts/ship.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://d4adbk672ye2t

17
scripts/ships_type.gd Normal file
View File

@ -0,0 +1,17 @@
const SHIP_TYPES = {
"transport": {
"name": "Transportowiec",
"cost": {"iron": 10},
"speed": 80,
"cargo_capacity": 50,
"texture": "res://assets/ships/transport.png"
},
"frigate": {
"name": "Fregata",
"cost": {"iron": 10, "copper": 10},
"speed": 120,
"attack": 10,
"hp": 50,
"texture": "res://assets/ships/fregata.png"
}
}

View File

@ -0,0 +1 @@
uid://b0jcuf156wbp

View File

@ -1,7 +1,7 @@
extends Node2D extends Node2D
class_name Star class_name Star
# Parametry ustawiane w Inspektorze (łatwe do edycji!) # Parametry ustawiane w Inspektorze (łatwe do edycji!)
@export var radius: float = 400.0 # Promień okręgu @export var radius: float = 500.0 # Promień okręgu
@export var color: Color = Color.GRAY @export var color: Color = Color.GRAY
@export var thickness: float = 0.5 # Grubość linii konturu @export var thickness: float = 0.5 # Grubość linii konturu
@export var segments: int = 64 @export var segments: int = 64

View File

@ -19,10 +19,51 @@ func _gui_input(event):
position += event.relative position += event.relative
var current_station = null
func show_for_station(station): func show_for_station(station):
self.visible = true self.visible = true
#planet_name_label.text = planet.name current_station = station
func _on_button_2_pressed() -> void: func _on_button_2_pressed() -> void:
self.visible = false self.visible = false
func _on_button_pressed() -> void:
build_ship("frigate")
func _on_button_3_pressed() -> void:
build_ship("transport")
func build_ship(type: String):
if current_station == null:
print("Brak stacji nie można budować statku")
return
var cost = ShipsType.SHIP_TYPES[type].cost
# 1. Sprawdź zasoby gracza
for res in cost.keys():
if PlayerData.resources[res] < cost[res]:
print("Brakuje:", res)
return
# 2. Odejmij zasoby gracza
for res in cost.keys():
PlayerData.resources[res] -= cost[res]
PlayerData.emit_signal("stats_changed")
# 3. Stwórz statek
var ship = preload("res://scenes/ship.tscn").instantiate()
ship.setup(type)
# POZYCJA SPAWNU — np. obok stacji
ship.position = current_station.position + Vector2(15, 15)
# Dodaj do sceny
get_tree().root.get_node("Galaxy").add_child(ship)
print("Zbudowano statek:", type)