Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Office Rooms into the map #304

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interact_data = {
}
advanced/network_sync = false

[sub_resource type="Resource" id=4]
[sub_resource type="Resource" id=2]
resource_local_to_scene = true
resource_name = "InteractUI"
script = ExtResource( 4 )
Expand All @@ -33,7 +33,7 @@ resource_local_to_scene = true
resource_name = "InteractTask"
script = ExtResource( 5 )
task_text = ""
ui_resource = SubResource( 4 )
ui_resource = SubResource( 2 )
outputs/toggle_map_interactions = false
outputs/output_map_interactions = [ ]
is_task_global = false
Expand Down
47 changes: 47 additions & 0 deletions src/assets/maps/test/horizontal_wall.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
extends StaticBody2D
class_name HorizWall

onready var wall_sprite = $Sprite
onready var light_occluder = $LightOccluder2D

const fade_speed: float = 5.0
var fading_in: bool
var fading_out: bool
var occluder_height: float
var occluder_top: float
var occluder_bottom: float

func _ready():
occluder_top = light_occluder.position.y
occluder_bottom = 0
occluder_height = occluder_top - occluder_bottom

func _process(delta: float) -> void:
if fading_in:
wall_sprite.modulate.a += delta * fade_speed
light_occluder.position.y += delta * fade_speed * occluder_height
if wall_sprite.modulate.a >= 1.0:
light_occluder.position.y = occluder_top
fading_in = false
if fading_out:
wall_sprite.modulate.a -= delta * fade_speed
light_occluder.position.y -= delta * fade_speed * occluder_height
if wall_sprite.modulate.a <= 0.0:
light_occluder.position.y = occluder_bottom
fading_out = false

func _on_FadeTrigger_body_entered(body: Node) -> void:
_check_fade(body, true)

func _on_FadeTrigger_body_exited(body: Node) -> void:
_check_fade(body, false)

func _check_fade(body: KinematicBody2D, entered: bool) -> void:
"""Fade the bottom wall in or out if the main player is moving away from or towards it."""
if body.is_in_group("players") and body.main_player:
if entered:
fading_in = false
fading_out = true
else:
fading_in = true
fading_out = false
22 changes: 22 additions & 0 deletions src/assets/maps/test/horizontal_wall.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://assets/maps/test/horizontal_wall.gd" type="Script" id=1]

[node name="HorizontalWall" type="StaticBody2D"]
script = ExtResource( 1 )

[node name="Sprite" type="Sprite" parent="."]
centered = false

[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
position = Vector2( 0, -32 )

[node name="PlayerCollision" type="CollisionShape2D" parent="."]

[node name="AreaDetection" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 2

[node name="DetectorArea" type="CollisionPolygon2D" parent="AreaDetection"]
[connection signal="body_entered" from="AreaDetection" to="." method="_on_FadeTrigger_body_entered"]
[connection signal="body_exited" from="AreaDetection" to="." method="_on_FadeTrigger_body_exited"]
66 changes: 66 additions & 0 deletions src/assets/maps/test/offices/kitchen-bottom-wall.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[gd_scene load_steps=11 format=2]

[ext_resource path="res://assets/maps/test/horizontal_wall.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/maps/test/offices/textures/kitchen-bottom-wall.png" type="Texture" id=2]

[sub_resource type="OccluderPolygon2D" id=1]
polygon = PoolVector2Array( 91, -24.5, 91, -7, 123.5, -7, 123.5, 17, 330, 17, 330, -45, 313, -45, 313, 0, 140.5, 0, 140.5, -24.5 )

[sub_resource type="OccluderPolygon2D" id=2]
polygon = PoolVector2Array( 34, -24.5, 47.5, -24.5, 47.5, -7, 0, -7, 0, -24.5 )

[sub_resource type="OccluderPolygon2D" id=8]
polygon = PoolVector2Array( 0, 0, 17, 0, 17, 15, 0, 15 )

[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 103.5, 9 )

[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 24, 9 )

[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 25, 9 )

[sub_resource type="RectangleShape2D" id=6]
extents = Vector2( 9, 10 )

[sub_resource type="RectangleShape2D" id=7]
extents = Vector2( 9, 47.5 )

[node name="KitchenBottomWall" instance=ExtResource( 1 )]

[node name="Sprite" parent="." index="0"]
scale = Vector2( 0.13, 0.13 )
texture = ExtResource( 2 )
offset = Vector2( 0, -725 )

[node name="LightOccluder2D" parent="." index="1"]
position = Vector2( 0, -49.5 )
occluder = SubResource( 1 )

[node name="LightOccluder2D" type="LightOccluder2D" parent="LightOccluder2D" index="0"]
occluder = SubResource( 2 )

[node name="LightOccluder2D2" type="LightOccluder2D" parent="LightOccluder2D" index="1"]
position = Vector2( 123.5, 17 )
occluder = SubResource( 8 )

[node name="PlayerCollision" parent="." index="2"]
position = Vector2( 226.5, 8 )
shape = SubResource( 3 )

[node name="PlayerCollision2" type="CollisionShape2D" parent="." index="3"]
position = Vector2( 23.8, -16 )
shape = SubResource( 4 )

[node name="PlayerCollision3" type="CollisionShape2D" parent="." index="4"]
position = Vector2( 115.5, -16 )
shape = SubResource( 5 )

[node name="PlayerCollision4" type="CollisionShape2D" parent="." index="5"]
position = Vector2( 132, -1 )
shape = SubResource( 6 )

[node name="PlayerCollision5" type="CollisionShape2D" parent="." index="6"]
position = Vector2( 321, -47 )
shape = SubResource( 7 )
45 changes: 45 additions & 0 deletions src/assets/maps/test/offices/meeting-bottom-wall.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[gd_scene load_steps=8 format=2]

[ext_resource path="res://assets/maps/test/horizontal_wall.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/maps/test/offices/textures/meeting-bottom-wall.png" type="Texture" id=2]

[sub_resource type="OccluderPolygon2D" id=1]
polygon = PoolVector2Array( 153.5, 17, 330, 17, 330, -32.5, 313, -32.5, 313, 0, 153.5, 0 )

[sub_resource type="OccluderPolygon2D" id=2]
polygon = PoolVector2Array( 34, 0, 104.5, 0, 104.5, 17, 0, 17, 0, 0 )

[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 88.2, 9 )

[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 53, 9 )

[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 9, 42.121 )

[node name="MeetingBottomWall" instance=ExtResource( 1 )]

[node name="Sprite" parent="." index="0"]
scale = Vector2( 0.13, 0.13 )
texture = ExtResource( 2 )
offset = Vector2( 0, -630 )

[node name="LightOccluder2D" parent="." index="1"]
position = Vector2( 0, -49.6 )
occluder = SubResource( 1 )

[node name="LightOccluder2D" type="LightOccluder2D" parent="LightOccluder2D" index="0"]
occluder = SubResource( 2 )

[node name="PlayerCollision" parent="." index="2"]
position = Vector2( 241.5, 8.5 )
shape = SubResource( 3 )

[node name="PlayerCollision2" type="CollisionShape2D" parent="." index="3"]
position = Vector2( 52.5, 8.5 )
shape = SubResource( 4 )

[node name="PlayerCollision5" type="CollisionShape2D" parent="." index="4"]
position = Vector2( 321, -40 )
shape = SubResource( 5 )
Loading