Make projectiles collide with the arena battle barrier

This commit is contained in:
Raxki 2024-11-24 15:18:55 -05:00
parent c1d13e566d
commit 64a513efce
5 changed files with 55 additions and 18 deletions

View file

@ -10,7 +10,7 @@ extends Node2D
@onready var cutscene_manager = $CutsceneManager
@onready var sound_manager = $SoundManager
@onready var fader_animation = $Fades/Control/FaderRect/AnimationPlayer
@onready var barrier = $Barrier
@onready var barrier = $BattleBarriers
@onready var credits = $Fades/Control/Credits
@onready var reward_nsfw = $Fades/Control/NSFWReward
@onready var reward_sfw = $Fades/Control/SFWReward

View file

@ -0,0 +1,3 @@
class_name CollidableBarrier extends StaticBody2D
@export_flags("Horizontal:1", "Vertical:2") var detect_projectile_direction = 0

View file

@ -37,4 +37,10 @@ func _boom():
collision.set_deferred("disabled", true)
func _on_collision_body_entered(body):
var is_vertical = abs(direction.dot(Vector2.RIGHT)) == 0.0
if body is CollidableBarrier:
if body.detect_projectile_direction & 1 and is_vertical:
return
if body.detect_projectile_direction & 2 and not is_vertical:
return
_boom()

View file

@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://deqprytehbffv"]
[ext_resource type="Script" path="res://Scripts/collidable_barrier.gd" id="1_6daip"]
[node name="CollidableBarrier" type="StaticBody2D"]
collision_mask = 33
script = ExtResource("1_6daip")

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=57 format=3 uid="uid://bxuxjqxxqy7ce"]
[gd_scene load_steps=58 format=3 uid="uid://bxuxjqxxqy7ce"]
[ext_resource type="PackedScene" uid="uid://di21xheryhp0k" path="res://Hiro/hiro_player.tscn" id="1_c1gpq"]
[ext_resource type="PackedScene" uid="uid://b8sfype1vx5ad" path="res://Nem/nem_npc.tscn" id="1_sqt7d"]
@ -42,6 +42,7 @@
[ext_resource type="Script" path="res://Scripts/game_state.gd" id="24_6ypry"]
[ext_resource type="PackedScene" uid="uid://bbybt6r6351yp" path="res://Audio/sound_manager.tscn" id="25_hm8b0"]
[ext_resource type="PackedScene" uid="uid://dd2km6qhpdicx" path="res://Hiro/hiro_ai.tscn" id="30_le27a"]
[ext_resource type="Script" path="res://Scripts/collidable_barrier.gd" id="43_8q2dl"]
[sub_resource type="LabelSettings" id="LabelSettings_f2g0a"]
font = ExtResource("2_64thh")
@ -473,31 +474,51 @@ position = Vector2(50, 5)
[node name="Marker0" type="Marker2D" parent="PositionMarkers"]
position = Vector2(0, 80)
[node name="Barrier" type="StaticBody2D" parent="."]
[node name="BattleBarriers" type="Node2D" parent="."]
process_mode = 4
collision_layer = 17
collision_mask = 17
[node name="CollisionShape2D" type="CollisionShape2D" parent="Barrier"]
position = Vector2(-107.5, -19.5)
shape = SubResource("RectangleShape2D_c5p72")
[node name="Barrier" type="StaticBody2D" parent="BattleBarriers"]
collision_layer = 49
collision_mask = 25
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Barrier"]
position = Vector2(111, -19)
shape = SubResource("RectangleShape2D_ledaf")
[node name="CollisionShape2D3" type="CollisionShape2D" parent="Barrier"]
position = Vector2(-9, -97.5)
shape = SubResource("RectangleShape2D_hkvwf")
[node name="CollisionShape2D4" type="CollisionPolygon2D" parent="Barrier"]
[node name="CollisionShape2D4" type="CollisionPolygon2D" parent="BattleBarriers/Barrier"]
polygon = PackedVector2Array(-84, -31, -76, -57, -43, -71, -84, -71)
[node name="CollisionShape2D5" type="CollisionPolygon2D" parent="Barrier"]
[node name="CollisionShape2D5" type="CollisionPolygon2D" parent="BattleBarriers/Barrier"]
position = Vector2(14, 13)
rotation = 1.5708
polygon = PackedVector2Array(-84, -31, -76, -57, -43, -71, -84, -71)
[node name="CollidableBarrier1" type="StaticBody2D" parent="BattleBarriers"]
collision_layer = 49
collision_mask = 25
script = ExtResource("43_8q2dl")
detect_projectile_direction = 1
[node name="CollisionShape2D" type="CollisionShape2D" parent="BattleBarriers/CollidableBarrier1"]
position = Vector2(-107.5, -19.5)
shape = SubResource("RectangleShape2D_c5p72")
[node name="CollidableBarrier2" type="StaticBody2D" parent="BattleBarriers"]
collision_layer = 49
collision_mask = 25
script = ExtResource("43_8q2dl")
detect_projectile_direction = 1
[node name="CollisionShape2D2" type="CollisionShape2D" parent="BattleBarriers/CollidableBarrier2"]
position = Vector2(111, -19)
shape = SubResource("RectangleShape2D_ledaf")
[node name="CollidableBarrier3" type="StaticBody2D" parent="BattleBarriers"]
collision_layer = 49
collision_mask = 25
script = ExtResource("43_8q2dl")
detect_projectile_direction = 2
[node name="CollisionShape2D3" type="CollisionShape2D" parent="BattleBarriers/CollidableBarrier3"]
position = Vector2(-9, -97.5)
shape = SubResource("RectangleShape2D_hkvwf")
[connection signal="finished" from="CutsceneManager" to="." method="_on_cutscene_finished"]
[connection signal="issued_command" from="CutsceneManager" to="." method="_on_cutscene_manager_issued_command"]
[connection signal="issued_command" from="CutsceneManager" to="CutsceneManager" method="_on_issued_command"]