workers running toward factory

This commit is contained in:
incredibleLeitman 2020-01-26 22:31:35 +01:00
parent 113c2eca4d
commit 2603ee53a0
3 changed files with 135 additions and 103 deletions

View File

@ -1,21 +1,30 @@
extends Spatial extends Spatial
const SPAWN_TIME_MIN = 3000 # min spawntime in ms export(NodePath) var _nodepath
const SPAWN_TIME_MAX = 7000 # max spawntime in ms export(float) var _offset
const SPAWN_TIME_MIN = 5000 # min spawntime in ms
const SPAWN_TIME_MAX = 8000 # max spawntime in ms
var _worker var _worker
var _lastSpawn = 0 # timestamp of last spawned worker var _lastSpawn = 0 # timestamp of last spawned worker
var _path: Path
func _ready(): func _ready():
_worker = load("res://Characters/Worker/Worker.tscn") _worker = load("res://Characters/Worker/Worker.tscn")
assert(null != _worker) assert(null != _worker)
_path = get_node(_nodepath)
assert(null != _path)
func _process(delta): func _process(delta):
# spawns new workers after defined time # spawns new workers after defined time
var cur_time = OS.get_ticks_msec() var cur_time = OS.get_ticks_msec()
var diff = rand_range(SPAWN_TIME_MIN, SPAWN_TIME_MAX) var diff = rand_range(SPAWN_TIME_MIN, SPAWN_TIME_MAX)
if cur_time - _lastSpawn > diff: if cur_time - _lastSpawn > diff:
#Logger.info(name + " spawning new worker") #Logger.info(name + " spawning new worker")
var new_worker = _worker.instance() var pathFollow = PathFollow.new()
add_child(new_worker) pathFollow.offset = _offset
pathFollow.add_child(_worker.instance())
_path.add_child(pathFollow)
_lastSpawn = cur_time _lastSpawn = cur_time

File diff suppressed because one or more lines are too long

View File

@ -4,20 +4,19 @@
[ext_resource path="res://UI/PlayButton.gd" type="Script" id=2] [ext_resource path="res://UI/PlayButton.gd" type="Script" id=2]
[ext_resource path="res://UI/ExitButton.gd" type="Script" id=3] [ext_resource path="res://UI/ExitButton.gd" type="Script" id=3]
[sub_resource type="DynamicFont" id=4]
size = 180
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=1]
size = 32 size = 180
font_data = ExtResource( 1 ) font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=2] [sub_resource type="DynamicFont" id=2]
size = 32 size = 32
font_data = ExtResource( 1 ) font_data = ExtResource( 1 )
[sub_resource type="Animation" id=3] [sub_resource type="DynamicFont" id=3]
resource_name = "Text" size = 32
font_data = ExtResource( 1 )
[sub_resource type="Animation" id=4]
length = 5.0 length = 5.0
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/path = NodePath("ForegroundGoesUp:rect_position") tracks/0/path = NodePath("ForegroundGoesUp:rect_position")
@ -86,7 +85,7 @@ margin_left = 1.0
margin_top = -1.16635 margin_top = -1.16635
margin_right = 1025.0 margin_right = 1025.0
margin_bottom = 398.834 margin_bottom = 398.834
custom_fonts/font = SubResource( 4 ) custom_fonts/font = SubResource( 1 )
custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_shadow = Color( 1, 0, 0, 1 ) custom_colors/font_color_shadow = Color( 1, 0, 0, 1 )
custom_constants/shadow_offset_x = 4 custom_constants/shadow_offset_x = 4
@ -111,7 +110,7 @@ margin_left = 380.0
margin_top = 410.0 margin_top = 410.0
margin_right = 620.0 margin_right = 620.0
margin_bottom = 470.0 margin_bottom = 470.0
custom_fonts/font = SubResource( 1 ) custom_fonts/font = SubResource( 2 )
custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_hover = Color( 0.980392, 0.839216, 0.619608, 1 ) custom_colors/font_color_hover = Color( 0.980392, 0.839216, 0.619608, 1 )
text = "Embark" text = "Embark"
@ -123,7 +122,7 @@ margin_left = 380.0
margin_top = 470.0 margin_top = 470.0
margin_right = 620.0 margin_right = 620.0
margin_bottom = 530.0 margin_bottom = 530.0
custom_fonts/font = SubResource( 2 ) custom_fonts/font = SubResource( 3 )
custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 )
text = "Disembark" text = "Disembark"
flat = true flat = true
@ -131,6 +130,6 @@ script = ExtResource( 3 )
[node name="AnimateForeground" type="AnimationPlayer" parent="."] [node name="AnimateForeground" type="AnimationPlayer" parent="."]
autoplay = "Text" autoplay = "Text"
anims/Text = SubResource( 3 ) anims/Text = SubResource( 4 )
[connection signal="pressed" from="PlayButton" to="PlayButton" method="_on_PlayButton_pressed"] [connection signal="pressed" from="PlayButton" to="PlayButton" method="_on_PlayButton_pressed"]
[connection signal="pressed" from="ExitButton" to="ExitButton" method="_on_ExitButton_pressed"] [connection signal="pressed" from="ExitButton" to="ExitButton" method="_on_ExitButton_pressed"]