-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLaunch.gd
122 lines (95 loc) · 4.22 KB
/
Launch.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
extends Control
class_name Launch
var time = 0.
var launch_in_progress = false
var launching_matter = false
var launching_humans = false
var launch_counter = 0.
var build_in_progress = false
var build_counter = 0.
var time_to_launch_matter = 7.
var time_to_launch_humans = 14.
var cost_to_launch_humans = 100
var humans_transported = 1
var matter_cost = 1000. # cred/ton
var time_to_build_drone = 5
var drone_matter_cost = 1 # ton
var drone_energy_cost = 100 # kWh
@onready var progress_launch_m = %ProgressLaunchM
@onready var progress_launch_h = %ProgressLaunchH
@onready var box_launch_m = %BoxLaunchM
@onready var progress_build_md = %ProgressBuildMD
@onready var station = $"../PanelStation"
@onready var control = $".."
@onready var tab_bar = %TabBar
var travelling = false
var description_humans = ""
var description_matter = ""
var description_drone = ""
# Called when the node enters the scene tree for the first time.
func _ready():
update_descriptions()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
var time_multi = tab_bar.current_tab*tab_bar.current_tab
delta = delta*time_multi
time += delta
if launch_in_progress:
launch_counter +=delta
if launching_matter:
progress_launch_m.value = launch_counter
if launch_counter > time_to_launch_matter:
launch_in_progress = false
launching_matter = false
launching_humans = false
launch_counter = 0.
progress_launch_m.value = 0.
station.matter += box_launch_m.value
control.credits -= box_launch_m.value*matter_cost
if launching_humans:
progress_launch_h.value = launch_counter
if launching_humans && launch_counter > time_to_launch_humans:
launch_in_progress = false
launching_matter = false
launching_humans = false
launch_counter = 0.
progress_launch_h.value = 0.
station.humans += humans_transported
if build_in_progress:
build_counter += delta
progress_build_md.value = build_counter
station.matter -= drone_matter_cost/progress_build_md.max_value*delta
if build_counter > progress_build_md.max_value:
build_in_progress = false
build_counter = 0.
progress_build_md.value = 0.
station.drones += 1
func _on_launch_humans_pressed():
if station.humans_cap >= station.humans + humans_transported && control.credits >= cost_to_launch_humans && ! travelling:
launch_in_progress = true
launch_counter = 0
launching_matter = false
launching_humans = true
control.credits -= cost_to_launch_humans
progress_launch_h.max_value = time_to_launch_humans
func _on_launch_matter_pressed():
print("launch ", box_launch_m.value*matter_cost)
if control.credits >= box_launch_m.value*matter_cost && ! travelling:
print("ok")
launch_in_progress = true
launch_counter = 0
launching_matter = true
launching_humans = false
progress_launch_m.max_value = time_to_launch_matter
func _on_build_drone_pressed():
if station.matter >= drone_matter_cost && station.drones_cap > station.drones:
build_in_progress = true
build_counter = 0
progress_build_md.max_value = time_to_build_drone/log(station.humans+1)*log(2)
if station.Hotel == false and station.Modules.count(station.LUXURY_LIVING) > 0:
progress_build_md.max_value = time_to_build_drone/log(station.humans+1)*log(2)/1.5
func update_descriptions():
description_humans = "Will launch an astronaut adding them to your station's crew.\nIt takes time to get them ready and you pay in advance.\nYou are allowed to prepare one launch at any given time.\n\ntime to launch: " + str(time_to_launch_humans) + "\ncost to launch: " + str(cost_to_launch_humans) + "\nhumans: " + str(humans_transported)
description_matter = "Will launch some matter. Specify the amount of matter in the box, you will pay the corresponding amount.\nYou are allowed to prepare one launch at any given time.\n\ntime to launch: " + str(time_to_launch_matter) + "\ncost to launch: " + str(matter_cost) + " credits/ton\nhumans: " + str(humans_transported)
description_drone = "Will build a faithful little drone that will collect matter for you \n\ntime to build: " + str(time_to_build_drone) + "\nmatter cost: " + str(drone_matter_cost) + " ton\nenergy cost: "+ str(drone_energy_cost) + " kWh"