diff --git a/BoundingBoxes/CameraTrigger.cs b/BoundingBoxes/CameraTrigger.cs new file mode 100644 index 0000000..57e763f --- /dev/null +++ b/BoundingBoxes/CameraTrigger.cs @@ -0,0 +1,32 @@ +using Godot; + +namespace SupaLidlGame.BoundingBoxes; + +public partial class CameraTrigger : Area2D +{ + [Export] + public Node Camera { get; set; } + + [Export] + public int EnablePriority { get; set; } = 2; + + [Export] + public int DisablePriority { get; set; } = 0; + + public override void _Ready() + { + Connect(SignalName.BodyEntered, new Callable(this, nameof(OnBodyEntered))); + Connect(SignalName.BodyExited, new Callable(this, nameof(OnBodyExited))); + } + + private void OnBodyEntered(Node2D node) + { + Camera.Set("priority", EnablePriority); + Camera.Set("follow_target", node); + } + + private void OnBodyExited(Node2D node) + { + Camera.Set("priority", DisablePriority); + } +} diff --git a/Scenes/Maps/Arena.tscn b/Scenes/Maps/Arena.tscn index 38f7266..fa8d1e7 100644 --- a/Scenes/Maps/Arena.tscn +++ b/Scenes/Maps/Arena.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=20 format=3 uid="uid://b2x17su05ou5w"] +[gd_scene load_steps=26 format=3 uid="uid://b2x17su05ou5w"] [ext_resource type="PackedScene" uid="uid://clwv2owvk6abe" path="res://Scenes/BaseMap.tscn" id="1_ifiic"] [ext_resource type="TileSet" uid="uid://l61kbx31ug4p" path="res://Scenes/Maps/ArenaTileset.tres" id="2_x0mh7"] @@ -9,8 +9,10 @@ [ext_resource type="Texture2D" uid="uid://d1ukste16yq6v" path="res://Assets/Sprites/Particles/player-light.png" id="7_y7j0e"] [ext_resource type="AudioStream" uid="uid://dy4qjflo1k28b" path="res://Assets/Sounds/calm-storm-ambient.mp3" id="8_wox7d"] [ext_resource type="Script" path="res://BoundingBoxes/ConnectorBox.cs" id="9_fg062"] -[ext_resource type="PackedScene" uid="uid://malbos18dh7l" path="res://BoundingBoxes/CameraBounds.tscn" id="11_j2620"] +[ext_resource type="Script" path="res://BoundingBoxes/CameraTrigger.cs" id="11_0u80h"] +[ext_resource type="Script" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="11_q01ik"] [ext_resource type="Texture2D" uid="uid://c1a7lvb4uuwfy" path="res://Assets/Sprites/Particles/circle-16.png" id="11_yjp7m"] +[ext_resource type="Script" path="res://addons/phantom_camera/scripts/resources/tween_resource.gd" id="12_ca3oh"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_i5p65"] resource_local_to_scene = true @@ -52,7 +54,22 @@ turbulence_enabled = true size = Vector2(40, 20) [sub_resource type="RectangleShape2D" id="RectangleShape2D_iw8cv"] -size = Vector2(64, 360) +size = Vector2(32, 256) + +[sub_resource type="Resource" id="Resource_jab5j"] +script = ExtResource("12_ca3oh") +duration = 1.0 +transition = 0 +ease = 2 + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_28nvi"] +size = Vector2(1024, 384) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_8id2f"] +size = Vector2(256, 256) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_idjmj"] +size = Vector2(512, 384) [node name="Arena" node_paths=PackedStringArray("Entities", "Areas", "Spawners", "Markers") instance=ExtResource("1_ifiic")] tile_set = ExtResource("2_x0mh7") @@ -188,24 +205,56 @@ ToConnector = "ArenaEntrance" [node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Entrance" index="0"] shape = SubResource("RectangleShape2D_2xagi") -[node name="EntranceCameraBounds" parent="Areas" index="1" node_paths=PackedStringArray("Trigger", "TopLeft", "BottomRight") instance=ExtResource("11_j2620")] -Trigger = NodePath("Area2D") -TopLeft = NodePath("TopLeft") -BottomRight = NodePath("BottomRight") +[node name="Area2D" type="Area2D" parent="Areas" index="1" node_paths=PackedStringArray("Camera")] +position = Vector2(0, 384) +collision_layer = 0 +collision_mask = 4 +monitorable = false +script = ExtResource("11_0u80h") +Camera = NodePath("Node/PhantomCamera2D") -[node name="Area2D" parent="Areas/EntranceCameraBounds" index="0"] -position = Vector2(0, 377) - -[node name="CollisionShape2D" parent="Areas/EntranceCameraBounds/Area2D" index="0"] +[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Area2D" index="0"] shape = SubResource("RectangleShape2D_iw8cv") +debug_color = Color(0.631373, 0.345098, 1, 0.419608) -[node name="TopLeft" parent="Areas/EntranceCameraBounds" index="1"] -position = Vector2(-256, 0) +[node name="Node" type="Node" parent="Areas/Area2D" index="1"] -[node name="BottomRight" parent="Areas/EntranceCameraBounds" index="2"] -position = Vector2(256, 384) +[node name="PhantomCamera2D" type="Node2D" parent="Areas/Area2D/Node" index="0"] +position = Vector2(0, 248) +script = ExtResource("11_q01ik") +zoom = Vector2(4, 4) +tween_resource = SubResource("Resource_jab5j") +limit_left = -384 +limit_top = -400 +limit_right = 384 +limit_bottom = 400 +limit_target = NodePath("../CollisionShape2D") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Area2D/Node" index="1"] +position = Vector2(0, 192) +shape = SubResource("RectangleShape2D_28nvi") + +[node name="Area2D2" type="Area2D" parent="Areas" index="2" node_paths=PackedStringArray("Camera")] +position = Vector2(0, -3) +collision_layer = 0 +collision_mask = 4 +monitorable = false +script = ExtResource("11_0u80h") +Camera = NodePath("Node/PhantomCamera2D") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Area2D2" index="0"] +shape = SubResource("RectangleShape2D_8id2f") +debug_color = Color(0.631373, 0.345098, 1, 0.419608) + +[node name="Node" type="Node" parent="Areas/Area2D2" index="1"] + +[node name="PhantomCamera2D" type="Node2D" parent="Areas/Area2D2/Node" index="0"] +script = ExtResource("11_q01ik") +zoom = Vector2(3, 3) +tween_resource = SubResource("Resource_jab5j") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Areas/Area2D2/Node" index="1"] +shape = SubResource("RectangleShape2D_idjmj") [node name="Entrance" type="Marker2D" parent="Markers" index="0"] position = Vector2(0, 352) - -[editable path="Areas/EntranceCameraBounds"]