Dodanie surowców/czas gry
Zródło surowców - true/false Dalsza implementacja czasu gry
This commit is contained in:
parent
f82795e006
commit
1020d96c00
68
Manager.gd
68
Manager.gd
@ -10,11 +10,14 @@ extends Node
|
|||||||
var sectors_data: Array = [] # Każdy element: {"name", "position", "planets", "star"}
|
var sectors_data: Array = [] # Każdy element: {"name", "position", "planets", "star"}
|
||||||
var placed_star_positions: Array[Vector2] = []
|
var placed_star_positions: Array[Vector2] = []
|
||||||
var current_sector: int = -1
|
var current_sector: int = -1
|
||||||
|
var year = 3980
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Timer aktualizacji
|
# Timer aktualizacji
|
||||||
var update_timer := 0.0
|
var update_timer := 0.0
|
||||||
|
|
||||||
# Nazwy sektorów i planet
|
var game_time := 0.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +38,10 @@ func _ready():
|
|||||||
Input.set_custom_mouse_cursor(load(Settings.CURSOR))
|
Input.set_custom_mouse_cursor(load(Settings.CURSOR))
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
update_timer += delta
|
|
||||||
|
game_time += delta * Settings.TIME_SCALE
|
||||||
|
#print(game_time)
|
||||||
|
update_timer += delta * Settings.TIME_SCALE
|
||||||
if update_timer >= Settings.UPDATE_INTERVAL:
|
if update_timer >= Settings.UPDATE_INTERVAL:
|
||||||
update_timer = 0.0
|
update_timer = 0.0
|
||||||
_update_planets()
|
_update_planets()
|
||||||
@ -92,6 +98,11 @@ func _initialize_sectors():
|
|||||||
func _add_random_planet(sector_index: int):
|
func _add_random_planet(sector_index: int):
|
||||||
var size = randi_range(1, 3)
|
var size = randi_range(1, 3)
|
||||||
var growth_rate = randf_range(0.1, 1.0)
|
var growth_rate = randf_range(0.1, 1.0)
|
||||||
|
var iron_exist = 1 if randf() < 0.8 else 0
|
||||||
|
var titan_exist = 1 if randf() < 0.6 else 0
|
||||||
|
var alu_exist = 1 if randf() < 0.4 else 0
|
||||||
|
var uran_exist = 1 if randf() < 0.2 else 0
|
||||||
|
|
||||||
var texture_planet: String
|
var texture_planet: String
|
||||||
if growth_rate > 0.7:
|
if growth_rate > 0.7:
|
||||||
texture_planet = "res://assets/planets/p%d.png" % randi_range(1,9)
|
texture_planet = "res://assets/planets/p%d.png" % randi_range(1,9)
|
||||||
@ -103,7 +114,16 @@ func _add_random_planet(sector_index: int):
|
|||||||
"size": size,
|
"size": size,
|
||||||
"population": 0,
|
"population": 0,
|
||||||
"max_population": get_max_population(size),
|
"max_population": get_max_population(size),
|
||||||
"resources": 0.0,
|
|
||||||
|
"iron_exist": iron_exist,
|
||||||
|
"iron": 0.0,
|
||||||
|
"titan_exist": titan_exist,
|
||||||
|
"titan": 0.0,
|
||||||
|
"alu_exist": alu_exist,
|
||||||
|
"alu": 0.0,
|
||||||
|
"uran_exist": uran_exist,
|
||||||
|
"uran": 0.0,
|
||||||
|
|
||||||
"mining_rate": randf_range(0.1, 1.0),
|
"mining_rate": randf_range(0.1, 1.0),
|
||||||
"growth_rate": growth_rate,
|
"growth_rate": growth_rate,
|
||||||
"is_colonized": false,
|
"is_colonized": false,
|
||||||
@ -121,10 +141,28 @@ func _update_planets():
|
|||||||
if planet["is_colonized"]:
|
if planet["is_colonized"]:
|
||||||
var growth = int(max(1, planet["population"] * 0.05 * planet["growth_rate"]))
|
var growth = int(max(1, planet["population"] * 0.05 * planet["growth_rate"]))
|
||||||
planet["population"] = min(planet["population"] + growth, planet["max_population"])
|
planet["population"] = min(planet["population"] + growth, planet["max_population"])
|
||||||
planet["resources"] += get_mined_per_cycle(planet)
|
if planet["iron_exist"] == 1:
|
||||||
|
planet["iron"] += get_iron_per_cycle(planet)
|
||||||
|
if planet["titan_exist"] == 1:
|
||||||
|
planet["titan"] += get_titan_per_cycle(planet)
|
||||||
|
if planet["alu_exist"] == 1:
|
||||||
|
planet["alu"] += get_alu_per_cycle(planet)
|
||||||
|
if planet["uran_exist"] == 1:
|
||||||
|
planet["uran"] += get_uran_per_cycle(planet)
|
||||||
|
#print(planet["iron"])
|
||||||
|
|
||||||
|
|
||||||
func get_mined_per_cycle(planet: Dictionary) -> float:
|
func get_iron_per_cycle(planet: Dictionary) -> float:
|
||||||
|
return planet["mining_rate"] * pow(planet["population"], 0.5) * 0.06
|
||||||
|
|
||||||
|
func get_titan_per_cycle(planet: Dictionary) -> float:
|
||||||
return planet["mining_rate"] * pow(planet["population"], 0.5) * 0.05
|
return planet["mining_rate"] * pow(planet["population"], 0.5) * 0.05
|
||||||
|
|
||||||
|
func get_alu_per_cycle(planet: Dictionary) -> float:
|
||||||
|
return planet["mining_rate"] * pow(planet["population"], 0.5) * 0.04
|
||||||
|
|
||||||
|
func get_uran_per_cycle(planet: Dictionary) -> float:
|
||||||
|
return planet["mining_rate"] * pow(planet["population"], 0.5) * 0.03
|
||||||
|
|
||||||
func get_max_population(size: int) -> int:
|
func get_max_population(size: int) -> int:
|
||||||
match size:
|
match size:
|
||||||
@ -146,27 +184,7 @@ func get_planets(index: int) -> Array:
|
|||||||
return sector["planets"]
|
return sector["planets"]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
func register_planet(sector_index: int, planet_name: String, size: int, mining_rate: float, growth_rate: float) -> Dictionary:
|
|
||||||
if sectors_data.size() <= sector_index:
|
|
||||||
sectors_data.resize(sector_index + 1)
|
|
||||||
if sectors_data[sector_index] == null:
|
|
||||||
sectors_data[sector_index] = {"planets": [], "name":"Unknown", "position": Vector2.ZERO, "star":{}}
|
|
||||||
|
|
||||||
var planet = {
|
|
||||||
"name": planet_name,
|
|
||||||
"size": size,
|
|
||||||
"population": 0,
|
|
||||||
"max_population": get_max_population(size),
|
|
||||||
"resources": 0.0,
|
|
||||||
"mining_rate": mining_rate,
|
|
||||||
"growth_rate": growth_rate,
|
|
||||||
"is_colonized": false,
|
|
||||||
"angle": randf() * TAU,
|
|
||||||
"rotation_speed": randf_range(0.01, 0.03),
|
|
||||||
"texture_path": "res://assets/planets/p%d.png" % randi_range(1,18)
|
|
||||||
}
|
|
||||||
sectors_data[sector_index]["planets"].append(planet)
|
|
||||||
return planet
|
|
||||||
|
|
||||||
# --- LOSOWANIE GWIAZD ---
|
# --- LOSOWANIE GWIAZD ---
|
||||||
func _random_star_texture() -> String:
|
func _random_star_texture() -> String:
|
||||||
|
|||||||
BIN
assets/buildings/starbase.png
Normal file
BIN
assets/buildings/starbase.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 448 KiB |
40
assets/buildings/starbase.png.import
Normal file
40
assets/buildings/starbase.png.import
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c1npf2gngyyxp"
|
||||||
|
path="res://.godot/imported/starbase.png-56a51666c571cc3f4aea2d820635166d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/buildings/starbase.png"
|
||||||
|
dest_files=["res://.godot/imported/starbase.png-56a51666c571cc3f4aea2d820635166d.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
|
||||||
@ -1,5 +1,7 @@
|
|||||||
key,pl,en,de
|
key,pl,en,de
|
||||||
menu_start,Start,Start,Starten
|
menu_start,Nowa Gra,New Game,Neues Spiel
|
||||||
menu_options,Opcje,Options,Einstellungen
|
menu_options,Opcje,Options,Einstellungen
|
||||||
menu_exit,Zamknij,Exit,Beenden
|
menu_exit,Zamknij,Exit,Beenden
|
||||||
|
menu_load,Wczytaj,Load,Laden
|
||||||
language,Język,Language,Sprache
|
language,Język,Language,Sprache
|
||||||
|
time_display,Data,Date,Datum
|
||||||
|
|||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://krtvmtme8s5f"]
|
[gd_scene load_steps=3 format=3 uid="uid://krtvmtme8s5f"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://2x1k6uk86wqj" path="res://scripts/galaxy.gd" id="1_n7ltq"]
|
[ext_resource type="Script" uid="uid://2x1k6uk86wqj" path="res://scripts/galaxy.gd" id="1_n7ltq"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bbgymc0drqpbx" path="res://scenes/time_display.tscn" id="2_jxn3g"]
|
||||||
|
|
||||||
[node name="galaxy" type="Control"]
|
[node name="galaxy" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
@ -15,3 +16,13 @@ script = ExtResource("1_n7ltq")
|
|||||||
anchors_preset = 0
|
anchors_preset = 0
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
offset_bottom = 40.0
|
offset_bottom = 40.0
|
||||||
|
|
||||||
|
[node name="TimeDisplay" parent="." instance=ExtResource("2_jxn3g")]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
offset_left = -128.0
|
||||||
|
offset_bottom = 23.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
grow_vertical = 1
|
||||||
|
|||||||
@ -173,9 +173,9 @@ vertical_alignment = 1
|
|||||||
[node name="start" type="TextureButton" parent="TextureRect"]
|
[node name="start" type="TextureButton" parent="TextureRect"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_left = 7.0
|
offset_left = 7.0
|
||||||
offset_top = 494.00003
|
offset_top = 449.0
|
||||||
offset_right = 1257.0
|
offset_right = 1257.0
|
||||||
offset_bottom = 724.0
|
offset_bottom = 679.0
|
||||||
scale = Vector2(0.15, 0.15)
|
scale = Vector2(0.15, 0.15)
|
||||||
texture_normal = ExtResource("3_v86rl")
|
texture_normal = ExtResource("3_v86rl")
|
||||||
texture_hover = ExtResource("4_13sgg")
|
texture_hover = ExtResource("4_13sgg")
|
||||||
@ -204,6 +204,40 @@ text = "menu_start"
|
|||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="load" type="TextureButton" parent="TextureRect"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 7.050003
|
||||||
|
offset_top = 494.10004
|
||||||
|
offset_right = 1257.05
|
||||||
|
offset_bottom = 724.1
|
||||||
|
scale = Vector2(0.15, 0.15)
|
||||||
|
texture_normal = ExtResource("3_v86rl")
|
||||||
|
texture_hover = ExtResource("4_13sgg")
|
||||||
|
stretch_mode = 0
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="TextureRect/load"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -618.6667
|
||||||
|
offset_top = -115.66679
|
||||||
|
offset_right = 621.3331
|
||||||
|
offset_bottom = 104.333206
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
theme_override_colors/font_color = Color(3.008172e-09, 0.06855638, 0.14010939, 1)
|
||||||
|
theme_override_colors/font_shadow_color = Color(0.7570387, 0.75415635, 0.7885611, 0)
|
||||||
|
theme_override_colors/font_outline_color = Color(0.9954526, 0.93959796, 0.9103491, 1)
|
||||||
|
theme_override_constants/outline_size = 23
|
||||||
|
theme_override_fonts/font = ExtResource("5_13sgg")
|
||||||
|
theme_override_font_sizes/font_size = 120
|
||||||
|
text = "menu_load"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="TextureRect"]
|
[node name="Sprite2D" type="Sprite2D" parent="TextureRect"]
|
||||||
modulate = Color(1, 1, 1, 0)
|
modulate = Color(1, 1, 1, 0)
|
||||||
position = Vector2(563.00006, 328.00003)
|
position = Vector2(563.00006, 328.00003)
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://b1a8a10jb4auf"]
|
[gd_scene load_steps=6 format=3 uid="uid://b1a8a10jb4auf"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cntq3qk522oqg" path="res://scripts/sector.gd" id="1_l8itw"]
|
[ext_resource type="Script" uid="uid://cntq3qk522oqg" path="res://scripts/sector.gd" id="1_l8itw"]
|
||||||
[ext_resource type="Texture2D" uid="uid://di7qrtp4lusa3" path="res://assets/icons/galaxy_button.png" id="2_c2nvg"]
|
[ext_resource type="Texture2D" uid="uid://di7qrtp4lusa3" path="res://assets/icons/galaxy_button.png" id="2_c2nvg"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cxanptjcnnwh" path="res://assets/icons/galaxy_button_hover.png" id="3_d5vc0"]
|
[ext_resource type="Texture2D" uid="uid://cxanptjcnnwh" path="res://assets/icons/galaxy_button_hover.png" id="3_d5vc0"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bbgymc0drqpbx" path="res://scenes/time_display.tscn" id="4_mad1q"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c1npf2gngyyxp" path="res://assets/buildings/starbase.png" id="5_d1pn0"]
|
||||||
|
|
||||||
[node name="Sector" type="Node2D"]
|
[node name="Sector" type="Node2D"]
|
||||||
script = ExtResource("1_l8itw")
|
script = ExtResource("1_l8itw")
|
||||||
@ -12,14 +14,13 @@ position = Vector2(572.00006, 328.5)
|
|||||||
|
|
||||||
[node name="PlanetStatPanel" type="Panel" parent="."]
|
[node name="PlanetStatPanel" type="Panel" parent="."]
|
||||||
offset_right = 320.0
|
offset_right = 320.0
|
||||||
offset_bottom = 204.0
|
offset_bottom = 512.0
|
||||||
|
|
||||||
[node name="PlanetName" type="Label" parent="PlanetStatPanel"]
|
[node name="PlanetName" type="Label" parent="PlanetStatPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_left = 8.0
|
offset_left = 8.0
|
||||||
offset_top = 16.0
|
offset_right = 312.0
|
||||||
offset_right = 278.0
|
offset_bottom = 25.0
|
||||||
offset_bottom = 41.0
|
|
||||||
theme_override_colors/font_color = Color(0.15989491, 0.40655294, 0.47780138, 1)
|
theme_override_colors/font_color = Color(0.15989491, 0.40655294, 0.47780138, 1)
|
||||||
|
|
||||||
[node name="PopulationPanel" type="Label" parent="PlanetStatPanel"]
|
[node name="PopulationPanel" type="Label" parent="PlanetStatPanel"]
|
||||||
@ -27,30 +28,79 @@ layout_mode = 1
|
|||||||
anchors_preset = -1
|
anchors_preset = -1
|
||||||
anchor_bottom = 0.277
|
anchor_bottom = 0.277
|
||||||
offset_left = 8.0
|
offset_left = 8.0
|
||||||
offset_top = 48.0
|
offset_top = 40.0
|
||||||
offset_right = 278.0
|
offset_right = 312.0
|
||||||
offset_bottom = 16.491997
|
offset_bottom = -77.824005
|
||||||
|
|
||||||
[node name="ResourcePlanet" type="Label" parent="PlanetStatPanel"]
|
[node name="IronPlanet" type="Label" parent="PlanetStatPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_left = 8.0
|
offset_left = 8.0
|
||||||
offset_top = 80.0
|
offset_top = 96.0
|
||||||
offset_right = 278.0
|
offset_right = 312.0
|
||||||
offset_bottom = 105.0
|
offset_bottom = 121.0
|
||||||
|
|
||||||
|
[node name="IronExist" type="Label" parent="PlanetStatPanel"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 72.0
|
||||||
|
offset_right = 312.0
|
||||||
|
offset_bottom = 97.0
|
||||||
|
|
||||||
|
[node name="TitanExist" type="Label" parent="PlanetStatPanel"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 136.0
|
||||||
|
offset_right = 312.0
|
||||||
|
offset_bottom = 161.0
|
||||||
|
|
||||||
|
[node name="TitanPlanet" type="Label" parent="PlanetStatPanel"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 160.0
|
||||||
|
offset_right = 312.0
|
||||||
|
offset_bottom = 185.0
|
||||||
|
|
||||||
|
[node name="AluExist" type="Label" parent="PlanetStatPanel"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 200.0
|
||||||
|
offset_right = 312.0
|
||||||
|
offset_bottom = 225.0
|
||||||
|
|
||||||
|
[node name="AluPlanet" type="Label" parent="PlanetStatPanel"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 224.0
|
||||||
|
offset_right = 312.0
|
||||||
|
offset_bottom = 249.0
|
||||||
|
|
||||||
|
[node name="UranExist" type="Label" parent="PlanetStatPanel"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 265.0
|
||||||
|
offset_right = 312.0
|
||||||
|
offset_bottom = 290.0
|
||||||
|
|
||||||
|
[node name="UranPlanet" type="Label" parent="PlanetStatPanel"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 289.0
|
||||||
|
offset_right = 312.0
|
||||||
|
offset_bottom = 314.0
|
||||||
|
|
||||||
[node name="MiningRate" type="Label" parent="PlanetStatPanel"]
|
[node name="MiningRate" type="Label" parent="PlanetStatPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_left = 8.0
|
offset_left = 8.0
|
||||||
offset_top = 112.0
|
offset_top = 361.0
|
||||||
offset_right = 278.0
|
offset_right = 312.0
|
||||||
offset_bottom = 137.0
|
offset_bottom = 386.0
|
||||||
|
|
||||||
[node name="GrowthRate" type="Label" parent="PlanetStatPanel"]
|
[node name="GrowthRate" type="Label" parent="PlanetStatPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_left = 8.0
|
offset_left = 8.0
|
||||||
offset_top = 144.0
|
offset_top = 321.0
|
||||||
offset_right = 278.0
|
offset_right = 312.0
|
||||||
offset_bottom = 169.0
|
offset_bottom = 346.0
|
||||||
|
|
||||||
[node name="BackButton" type="TextureButton" parent="."]
|
[node name="BackButton" type="TextureButton" parent="."]
|
||||||
anchors_preset = 3
|
anchors_preset = 3
|
||||||
@ -70,3 +120,22 @@ texture_normal = ExtResource("2_c2nvg")
|
|||||||
texture_hover = ExtResource("3_d5vc0")
|
texture_hover = ExtResource("3_d5vc0")
|
||||||
ignore_texture_size = true
|
ignore_texture_size = true
|
||||||
stretch_mode = 0
|
stretch_mode = 0
|
||||||
|
|
||||||
|
[node name="TimeDisplay" parent="." instance=ExtResource("4_mad1q")]
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
offset_left = 1024.0
|
||||||
|
offset_right = 1152.0
|
||||||
|
offset_bottom = 24.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
grow_vertical = 1
|
||||||
|
|
||||||
|
[node name="TextureButton" type="TextureButton" parent="."]
|
||||||
|
offset_left = 504.0
|
||||||
|
offset_top = 360.0
|
||||||
|
offset_right = 544.0
|
||||||
|
offset_bottom = 400.0
|
||||||
|
texture_normal = ExtResource("5_d1pn0")
|
||||||
|
ignore_texture_size = true
|
||||||
|
stretch_mode = 0
|
||||||
|
|||||||
51
scenes/time_display.tscn
Normal file
51
scenes/time_display.tscn
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
[gd_scene load_steps=3 format=3 uid="uid://bbgymc0drqpbx"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://hustgmwvdd3e" path="res://scripts/time_label.gd" id="1_3uj10"]
|
||||||
|
[ext_resource type="FontFile" uid="uid://8sj6q1y0q32u" path="res://assets/fonts/redlinecondital.ttf" id="2_qjjb1"]
|
||||||
|
|
||||||
|
[node name="TimeDisplay" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_3uj10")
|
||||||
|
|
||||||
|
[node name="TimeLabel" type="Label" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 39.0
|
||||||
|
offset_right = 164.0
|
||||||
|
offset_bottom = 20.0
|
||||||
|
theme_override_fonts/font = ExtResource("2_qjjb1")
|
||||||
|
text = "time_display"
|
||||||
|
|
||||||
|
[node name="pause" type="Button" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 12.0
|
||||||
|
offset_top = 2.0
|
||||||
|
offset_right = 32.0
|
||||||
|
offset_bottom = 24.0
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
theme_override_font_sizes/font_size = 10
|
||||||
|
text = "||"
|
||||||
|
|
||||||
|
[node name="faster" type="Button" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 23.0
|
||||||
|
offset_top = 2.0
|
||||||
|
offset_right = 41.0
|
||||||
|
offset_bottom = 24.0
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
theme_override_font_sizes/font_size = 10
|
||||||
|
text = ">"
|
||||||
|
|
||||||
|
[node name="slower" type="Button" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 2.0
|
||||||
|
offset_top = 2.0
|
||||||
|
offset_right = 20.0
|
||||||
|
offset_bottom = 24.0
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
theme_override_font_sizes/font_size = 10
|
||||||
|
text = "<"
|
||||||
@ -12,6 +12,7 @@ func _on_Opcje_pressed():
|
|||||||
|
|
||||||
|
|
||||||
func _on_start_pressed():
|
func _on_start_pressed():
|
||||||
|
Manager.game_time = 0.0
|
||||||
get_tree().change_scene_to_file("res://scenes/galaxy.tscn")
|
get_tree().change_scene_to_file("res://scenes/galaxy.tscn")
|
||||||
MusicManager.play_music()
|
MusicManager.play_music()
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ func _ensure_sprite():
|
|||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
# Ruch orbitalny
|
# Ruch orbitalny
|
||||||
angle += rotation_speed * delta
|
angle += rotation_speed * Settings.TIME_SCALE * delta
|
||||||
if orbit_center != Vector2.ZERO and orbit_radius > 0.0:
|
if orbit_center != Vector2.ZERO and orbit_radius > 0.0:
|
||||||
position = orbit_center + Vector2(cos(angle), sin(angle)) * orbit_radius
|
position = orbit_center + Vector2(cos(angle), sin(angle)) * orbit_radius
|
||||||
if data != null:
|
if data != null:
|
||||||
@ -74,9 +74,9 @@ func set_texture(tex: Texture2D):
|
|||||||
func get_scale_for_size(size: int) -> Vector2:
|
func get_scale_for_size(size: int) -> Vector2:
|
||||||
match size:
|
match size:
|
||||||
1: return Vector2(0.10, 0.10)
|
1: return Vector2(0.10, 0.10)
|
||||||
2: return Vector2(0.15, 0.15)
|
2: return Vector2(0.12, 0.12)
|
||||||
3: return Vector2(0.20, 0.20)
|
3: return Vector2(0.15, 0.15)
|
||||||
4: return Vector2(0.25, 0.25)
|
4: return Vector2(0.20, 0.20)
|
||||||
return Vector2(0.3, 0.3)
|
return Vector2(0.3, 0.3)
|
||||||
|
|
||||||
func _on_area_input(viewport, event, shape_idx):
|
func _on_area_input(viewport, event, shape_idx):
|
||||||
|
|||||||
@ -27,6 +27,7 @@ func _ready():
|
|||||||
func _process(delta):
|
func _process(delta):
|
||||||
if tracked_planet and PlanetStatPanel.visible:
|
if tracked_planet and PlanetStatPanel.visible:
|
||||||
_update_panel()
|
_update_panel()
|
||||||
|
#planet_data["rotation_speed"] = planet_node.rotation_speed*Settings.TIME_SCALE
|
||||||
|
|
||||||
|
|
||||||
func _on_back_pressed():
|
func _on_back_pressed():
|
||||||
@ -60,9 +61,9 @@ func spawn_planets():
|
|||||||
planet_node.data = planet_data
|
planet_node.data = planet_data
|
||||||
planet_node.orbit_center = center
|
planet_node.orbit_center = center
|
||||||
if i == 0:
|
if i == 0:
|
||||||
planet_node.orbit_radius = planet_data.get("orbit_radius", Settings.FIRST_ORBIT_STEP * (i + 1))
|
planet_node.orbit_radius = planet_data.get("orbit_radius", Settings.FIRST_ORBIT_STEP)
|
||||||
else:
|
else:
|
||||||
planet_node.orbit_radius = planet_data.get("orbit_radius", Settings.ORBIT_STEP * (i + 1))
|
planet_node.orbit_radius = planet_data.get("orbit_radius", Settings.FIRST_ORBIT_STEP + (i * Settings.ORBIT_STEP))
|
||||||
|
|
||||||
planet_node.angle = planet_data.get("angle", randf() * TAU)
|
planet_node.angle = planet_data.get("angle", randf() * TAU)
|
||||||
planet_node.rotation_speed = planet_data.get("rotation_speed", randf_range(0.00001, 1))
|
planet_node.rotation_speed = planet_data.get("rotation_speed", randf_range(0.00001, 1))
|
||||||
@ -81,7 +82,7 @@ func spawn_planets():
|
|||||||
# Zapis aktualnych parametrów do Managera
|
# Zapis aktualnych parametrów do Managera
|
||||||
planet_data["orbit_radius"] = planet_node.orbit_radius
|
planet_data["orbit_radius"] = planet_node.orbit_radius
|
||||||
planet_data["angle"] = planet_node.angle
|
planet_data["angle"] = planet_node.angle
|
||||||
planet_data["rotation_speed"] = planet_node.rotation_speed
|
planet_data["rotation_speed"] = planet_node.rotation_speed
|
||||||
|
|
||||||
# --- Star ---
|
# --- Star ---
|
||||||
func spawn_star():
|
func spawn_star():
|
||||||
@ -142,6 +143,25 @@ func _update_panel():
|
|||||||
PlanetStatPanel.get_node("PlanetName").text = "Nazwa: " + tracked_planet.data["name"] + colonized_text
|
PlanetStatPanel.get_node("PlanetName").text = "Nazwa: " + tracked_planet.data["name"] + colonized_text
|
||||||
PlanetStatPanel.get_node("PopulationPanel").text = "Populacja: %d / %d" % [tracked_planet.data["population"], tracked_planet.data["max_population"]]
|
PlanetStatPanel.get_node("PopulationPanel").text = "Populacja: %d / %d" % [tracked_planet.data["population"], tracked_planet.data["max_population"]]
|
||||||
PlanetStatPanel.get_node("MiningRate").text = "Potencjał surowcowy: %.2f" % tracked_planet.data["mining_rate"]
|
PlanetStatPanel.get_node("MiningRate").text = "Potencjał surowcowy: %.2f" % tracked_planet.data["mining_rate"]
|
||||||
var mined_per_cycle = Manager.get_mined_per_cycle(tracked_planet.data)
|
var iron_mined_per_cycle = Manager.get_iron_per_cycle(tracked_planet.data)
|
||||||
PlanetStatPanel.get_node("ResourcePlanet").text = "Surowce: %.2f (+%.2f)" % [tracked_planet.data["resources"], mined_per_cycle]
|
var titan_mined_per_cycle = Manager.get_titan_per_cycle(tracked_planet.data)
|
||||||
|
var alu_mined_per_cycle = Manager.get_alu_per_cycle(tracked_planet.data)
|
||||||
|
var uran_mined_per_cycle = Manager.get_uran_per_cycle(tracked_planet.data)
|
||||||
|
|
||||||
|
var iron_text = "Tak" if tracked_planet.data["iron_exist"] == 1 else "Nie"
|
||||||
|
PlanetStatPanel.get_node("IronExist").text = "Źródło żelaza: " + iron_text
|
||||||
|
PlanetStatPanel.get_node("IronPlanet").text = "Żelazo: %.2f (+%.2f)" % [tracked_planet.data["iron"], iron_mined_per_cycle*tracked_planet.data["iron_exist"]]
|
||||||
|
|
||||||
|
var titan_text = "Tak" if tracked_planet.data["titan_exist"] == 1 else "Nie"
|
||||||
|
PlanetStatPanel.get_node("TitanExist").text = "Źródło tytanu: " + titan_text
|
||||||
|
PlanetStatPanel.get_node("TitanPlanet").text = "Tytan: %.2f (+%.2f)" % [tracked_planet.data["titan"], titan_mined_per_cycle*tracked_planet.data["titan_exist"]]
|
||||||
|
|
||||||
|
var alu_text = "Tak" if tracked_planet.data["alu_exist"] == 1 else "Nie"
|
||||||
|
PlanetStatPanel.get_node("AluExist").text = "Źródło aluminium: " + alu_text
|
||||||
|
PlanetStatPanel.get_node("AluPlanet").text = "Aluminium: %.2f (+%.2f)" % [tracked_planet.data["alu"], alu_mined_per_cycle*tracked_planet.data["alu_exist"]]
|
||||||
|
|
||||||
|
var uran_text = "Tak" if tracked_planet.data["uran_exist"] == 1 else "Nie"
|
||||||
|
PlanetStatPanel.get_node("UranExist").text = "Źródło uranu: " + uran_text
|
||||||
|
PlanetStatPanel.get_node("UranPlanet").text = "Uran: %.2f (+%.2f)" % [tracked_planet.data["uran"], uran_mined_per_cycle*tracked_planet.data["uran_exist"]]
|
||||||
|
|
||||||
PlanetStatPanel.get_node("GrowthRate").text = "Biosfera: %.2f" % tracked_planet.data["growth_rate"]
|
PlanetStatPanel.get_node("GrowthRate").text = "Biosfera: %.2f" % tracked_planet.data["growth_rate"]
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
extends Node
|
extends Node
|
||||||
const UPDATE_INTERVAL := 30.0 #Cykl w sekundach
|
const UPDATE_INTERVAL := 10.0 #Cykl w sekundach
|
||||||
var ORBIT_STEP = 60 #odległośc miedzy orbitami
|
var ORBIT_STEP = randf_range(30, 50) #odległośc miedzy orbitami
|
||||||
const FIRST_ORBIT_STEP = 80 #pierwsza planeta od gwiazdy
|
const FIRST_ORBIT_STEP = 120 #pierwsza planeta od gwiazdy
|
||||||
const SECTOR_COUNT = 13 #ilość sektorów
|
const SECTOR_COUNT = 13 #ilość sektorów
|
||||||
const PLANET_PER_SECTOR: Vector2 = Vector2(1, 5)
|
const PLANET_PER_SECTOR: Vector2 = Vector2(5, 5)
|
||||||
const MIN_DISTANCE = 80.0 # Minimalna odległość (promień) między środkami gwiazd
|
const MIN_DISTANCE = 80.0 # Minimalna odległość (promień) między środkami gwiazd
|
||||||
const MAX_ATTEMPTS = 50 # Maksymalna liczba prób znalezienia miejsca
|
const MAX_ATTEMPTS = 50 # Maksymalna liczba prób znalezienia miejsca
|
||||||
|
var TIME_SCALE = 1.0; #Predkosc gry
|
||||||
#const PLANET_NUMBER = Vector2(1, 5)
|
#const PLANET_NUMBER = Vector2(1, 5)
|
||||||
|
|
||||||
#GRAFIKI
|
#GRAFIKI
|
||||||
|
|||||||
35
scripts/time_label.gd
Normal file
35
scripts/time_label.gd
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
@onready var time_label: Label = $TimeLabel
|
||||||
|
@onready var faster = $faster
|
||||||
|
@onready var slower = $slower
|
||||||
|
@onready var pause = $pause
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
faster.pressed.connect(_on_faster_pressed)
|
||||||
|
slower.pressed.connect(_on_slower_pressed)
|
||||||
|
pause.pressed.connect(_on_pause_pressed)
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
var total_days = int(Manager.game_time)
|
||||||
|
var numer_roku = 3980 + total_days / 365
|
||||||
|
var day_of_year = total_days % 365
|
||||||
|
var dzien_cykliczny: int
|
||||||
|
|
||||||
|
if day_of_year == 0:
|
||||||
|
dzien_cykliczny = 365
|
||||||
|
if total_days > 0:
|
||||||
|
numer_roku -= 1
|
||||||
|
else:
|
||||||
|
dzien_cykliczny = day_of_year
|
||||||
|
var full_date = tr("time_display") + ": " + str(numer_roku) + "." + str(dzien_cykliczny)
|
||||||
|
time_label.text = full_date
|
||||||
|
|
||||||
|
func _on_faster_pressed():
|
||||||
|
if Settings.TIME_SCALE < 10:
|
||||||
|
Settings.TIME_SCALE +=1
|
||||||
|
func _on_slower_pressed():
|
||||||
|
if Settings.TIME_SCALE > 0:
|
||||||
|
Settings.TIME_SCALE -=1
|
||||||
|
func _on_pause_pressed():
|
||||||
|
Settings.TIME_SCALE = 0
|
||||||
1
scripts/time_label.gd.uid
Normal file
1
scripts/time_label.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://hustgmwvdd3e
|
||||||
Loading…
x
Reference in New Issue
Block a user