Initial commit

This commit is contained in:
2020-10-01 19:53:08 +02:00
parent dea479a784
commit ace4593b46
82 changed files with 2570 additions and 0 deletions

71
Items/Wifi/Wifi.gd Normal file
View File

@@ -0,0 +1,71 @@
extends Node2D
onready var interact_message = get_node("/root/Node2D/Hints/KeyPress/Interact") as HBoxContainer
onready var task = get_node("Task/UI") as Control
onready var progressbar = get_node("Task/UI/ProgressBar") as ProgressBar
onready var timer = get_node("Timer") as Timer
var rng = RandomNumberGenerator.new()
func _ready():
rng.randomize()
task.visible = false
pass
func _physics_process(delta):
# Handle when player is around task
for player in $Area2D.get_overlapping_bodies():
if player is KinematicBody2D:
# Open task if user presses E
if Input.is_action_just_pressed("interact") and interact_message.visible and $Area2D.overlaps_body(player):
print("Show!")
Networking.move = false
task.visible = !task.visible
var distance = position.distance_to(player.position) * 0.004
# GUI
if distance < 0.11:
interact_message.visible = true
else:
interact_message.visible = false
# Light texture scale
if distance < 0.2:
$Light2D.energy = sqrt(4 * distance + 0.1)
if distance >= 0.1:
$Light2D.texture_scale = distance
func _on_Area2D_body_entered(body):
interact_message.visible = true
func _on_Area2D_body_exited(body):
interact_message.visible = false
func _on_Close_pressed():
timer.stop()
progressbar.value = 0
task.visible = false
Networking.move = true
$Task/UI/Begin.disabled = false
# Change progressbar
func _on_Timer_timeout():
# We finished!
if progressbar.value >= 100:
$Light2D.visible = false
$Area2D/CollisionShape2D.disabled = true
_on_Close_pressed()
timer.wait_time = rng.randf_range(0.1, 0.5)
progressbar.value += rng.randf_range(1, 4.3)
if progressbar.value >= 100:
$Task/UI/Close.visible = false
timer.wait_time = 3
# Download button was pressed
func _on_Begin_pressed():
$Task/UI/Begin.disabled = true
timer.start()

93
Items/Wifi/Wifi.tscn Normal file
View File

@@ -0,0 +1,93 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Lightmaps/PlayerLight.png" type="Texture" id=1]
[ext_resource path="res://Items/Wifi/Wifi.gd" type="Script" id=2]
[sub_resource type="CircleShape2D" id=1]
radius = 75.0
[node name="Wifi" type="Node2D"]
script = ExtResource( 2 )
[node name="Area2D" type="Area2D" parent="." groups=[
"Wifi",
]]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
[node name="Light2D" type="Light2D" parent="."]
position = Vector2( -0.561218, 0 )
texture = ExtResource( 1 )
texture_scale = 0.2
color = Color( 0.996078, 0, 0, 1 )
energy = 0.9
[node name="Task" type="CanvasLayer" parent="."]
layer = 4
[node name="UI" type="Control" parent="Task"]
margin_right = 1021.0
margin_bottom = 603.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ColorRect" type="ColorRect" parent="Task/UI"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -333.5
margin_top = -154.0
margin_right = 333.5
margin_bottom = 154.0
color = Color( 0.176471, 0.176471, 0.176471, 0.792157 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ProgressBar" type="ProgressBar" parent="Task/UI"]
anchor_left = 0.37904
anchor_top = 0.475954
anchor_right = 0.62096
anchor_bottom = 0.524046
margin_left = -1.0
margin_top = -53.0
margin_right = -1.0
margin_bottom = -53.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Begin" type="Button" parent="Task/UI"]
margin_left = 446.546
margin_top = 284.817
margin_right = 573.546
margin_bottom = 310.817
text = "Download"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Close" type="Button" parent="Task/UI"]
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -23.5
margin_top = -221.839
margin_right = 23.5
margin_bottom = -201.839
text = "Close"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Timer" type="Timer" parent="."]
wait_time = 0.228
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_Area2D_body_exited"]
[connection signal="pressed" from="Task/UI/Begin" to="." method="_on_Begin_pressed"]
[connection signal="pressed" from="Task/UI/Close" to="." method="_on_Close_pressed"]
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]

32
Items/interactables.gd Normal file
View File

@@ -0,0 +1,32 @@
extends TileMap
var timer = false
var animate_forwards = true
func _ready():
# Spawn new light for all tablets
for cell in get_used_cells_by_id(0):
var wifi = load("res://Items/Wifi/Wifi.tscn").instance() as Node2D
var center = Vector2(8, 8) + cell * 16
wifi.position = center
add_child(wifi)
func _process(delta):
if timer:
for cell in get_used_cells_by_id(0):
var tile = get_cell_autotile_coord(cell.x, cell.y)
if int(tile.x + 1) % 3 == 0 and animate_forwards:
animate_forwards = false
if int(tile.x) % 3 == 0 and !animate_forwards:
animate_forwards = true
if animate_forwards:
set_cell(cell.x, cell.y, 0, false, false, false, Vector2(tile.x+1, tile.y))
else:
set_cell(cell.x, cell.y, 0, false, false, false, Vector2(tile.x-1, tile.y))
timer = false
func _on_Timer_timeout():
timer = true