Relative movement pattern

This commit is contained in:
Marco 2025-06-30 17:59:07 +02:00
commit cd309ca49c
7 changed files with 139 additions and 95 deletions

File diff suppressed because one or more lines are too long

View file

@ -3715,7 +3715,7 @@
( -48 264 -24 ) ( -49 264 -24 ) ( -48 264 -23 ) Floors/Floor278 [ -1 0 0 0 ] [ 0 0 1 -8 ] 0 1 -1
( 80 408 -32 ) ( 79 408 -32 ) ( 80 407 -32 ) Floors/Floor278 [ -1 0 0 0 ] [ 0 1 0 -8 ] 270 1 1
( -48 280 -24 ) ( -48 279 -24 ) ( -49 280 -24 ) Floors/Floor278 [ -1 0 0 0 ] [ 0 1 0 -8 ] 90 1 1
( 80 408 -56 ) ( 80 408 -55 ) ( 79 408 -56 ) Floors/Floor278 [ -1 0 0 0 ] [ 0 0 1 -8 ] 180 1 -1
( 80 536 -56 ) ( 80 536 -55 ) ( 79 536 -56 ) Floors/Floor278 [ -1 0 0 0 ] [ 0 0 1 -8 ] 0 1 -1
( 112 408 -56 ) ( 112 407 -56 ) ( 112 408 -55 ) Floors/Floor278 [ 0 -1 0 8 ] [ 0 0 1 -8 ] 0 1 -1
}
// brush 197
@ -3742,17 +3742,17 @@
( -280 256 8 ) ( -281 256 8 ) ( -280 256 9 ) Walls/Wall0 [ -1 0 0 -8 ] [ 0 0 1 -8 ] 270 1 -1
( -152 544 -24 ) ( -153 544 -24 ) ( -152 543 -24 ) Walls/Wall0 [ -1 0 0 -8 ] [ 0 1 0 0 ] 270 1 1
( -280 416 8 ) ( -280 415 8 ) ( -281 416 8 ) Manual/Black [ -1 0 0 0 ] [ 0 1 0 0 ] 180 1 1
( -152 416 -24 ) ( -152 416 -23 ) ( -153 416 -24 ) Walls/Wall0 [ -1 0 0 -8 ] [ 0 0 1 -8 ] 0 1 -1
( -152 544 -24 ) ( -152 544 -23 ) ( -153 544 -24 ) Walls/Wall0 [ -1 0 0 -8 ] [ 0 0 1 -8 ] 90 1 -1
( -160 544 -24 ) ( -160 543 -24 ) ( -160 544 -23 ) Walls/Wall0 [ 0 -1 0 0 ] [ 0 0 1 0 ] 180 1 -1
}
// brush 200
{
( -160 536 -56 ) ( -160 536 -55 ) ( -160 535 -56 ) __TB_empty [ 0 -1 0 24 ] [ 0 0 1 -8 ] 180 1 -1
( 8 408 -24 ) ( 7 408 -24 ) ( 8 408 -23 ) __TB_empty [ -1 0 0 8 ] [ 0 0 1 -8 ] 90 1 -1
( 136 536 -32 ) ( 135 536 -32 ) ( 136 535 -32 ) __TB_empty [ -1 0 0 8 ] [ 0 1 0 -24 ] 270 1 1
( 8 408 8 ) ( 8 407 8 ) ( 7 408 8 ) Manual/Black [ -1 0 0 0 ] [ 0 1 0 0 ] 90 1 1
( 136 416 -56 ) ( 136 416 -55 ) ( 135 416 -56 ) Walls/Wall0 [ -1 0 0 -8 ] [ 0 0 1 -8 ] 270 1 -1
( 112 536 -56 ) ( 112 535 -56 ) ( 112 536 -55 ) __TB_empty [ 0 -1 0 24 ] [ 0 0 1 -8 ] 0 1 -1
( -160 664 -56 ) ( -160 664 -55 ) ( -160 663 -56 ) __TB_empty [ 0 -1 0 -8 ] [ 0 0 1 -8 ] 270 1 -1
( 8 536 -24 ) ( 7 536 -24 ) ( 8 536 -23 ) __TB_empty [ -1 0 0 8 ] [ 0 0 1 -8 ] 0 1 -1
( 136 664 -32 ) ( 135 664 -32 ) ( 136 663 -32 ) __TB_empty [ -1 0 0 8 ] [ 0 1 0 8 ] 0 1 1
( 8 536 8 ) ( 8 535 8 ) ( 7 536 8 ) Manual/Black [ -1 0 0 0 ] [ 0 1 0 0 ] 180 1 1
( 136 544 -56 ) ( 136 544 -55 ) ( 135 544 -56 ) Walls/Wall0 [ -1 0 0 8 ] [ 0 0 1 -8 ] 0 1 -1
( 112 664 -56 ) ( 112 663 -56 ) ( 112 664 -55 ) __TB_empty [ 0 -1 0 -8 ] [ 0 0 1 -8 ] 270 1 -1
}
// brush 201
{
@ -3835,6 +3835,15 @@
( -272 96 -32 ) ( -136 96 -32 ) ( -272 96 -24 ) Floors/Floor187 [ -1 0 0 0 ] [ 0 0 1 -8 ] 90 1 -1
( -188 -56 -24 ) ( -188 136 -24 ) ( -188 -56 -32 ) Walls/Wall0 [ 0 -1 0 -8 ] [ 0 0 1 -8 ] 90 1 -1
}
// brush 210
{
( 112 528 8 ) ( 112 528 9 ) ( 112 527 8 ) Walls/Wall0 [ 0 -1 0 0 ] [ 0 0 1 -8 ] 180 1 -1
( 0 416 8 ) ( -1 416 8 ) ( 0 416 9 ) Walls/Wall0 [ -1 0 0 0 ] [ 0 0 1 -8 ] 90 1 -1
( 128 656 -24 ) ( 127 656 -24 ) ( 128 655 -24 ) Walls/Wall0 [ -1 0 0 0 ] [ 0 1 0 -16 ] 270 1 1
( 0 528 8 ) ( 0 527 8 ) ( -1 528 8 ) Manual/Black [ -1 0 0 0 ] [ 0 1 0 0 ] 0 1 1
( 128 544 -24 ) ( 128 544 -23 ) ( 127 544 -24 ) Walls/Wall0 [ -1 0 0 0 ] [ 0 0 1 -8 ] 180 1 -1
( 120 656 -24 ) ( 120 655 -24 ) ( 120 656 -23 ) Walls/Wall0 [ 0 -1 0 0 ] [ 0 0 1 0 ] 180 1 -1
}
}
// entity 151
{

View file

@ -44,7 +44,7 @@ shadow_enabled = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.84862, 0, -4.8932)
[node name="StartPosition" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 112.949, -1.17626, -35.1522)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 121.891, -1.17626, -36.039)
[node name="CameraTarget" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 21.0389, 2.33215, 3.16925)

View file

@ -0,0 +1,30 @@
[gd_resource type="Resource" script_class="ShootingPattern3D" load_steps=4 format=3 uid="uid://bmdxhsjh2qla6"]
[ext_resource type="Resource" uid="uid://dl3nq7odtrnum" path="res://Resources/Bullets/Boss/Rumia/Rumia_Red_Chase_Bullet_3D.tres" id="1_5q7h7"]
[ext_resource type="Script" uid="uid://b5s5mjuk1rng5" path="res://Scripts/Resources/TimeModifier.cs" id="2_x15n1"]
[ext_resource type="Script" uid="uid://bxiprx5nwmpnu" path="res://Scripts/AttackPatterns/ShootingPattern3D.cs" id="3_3bs8m"]
[resource]
script = ExtResource("3_3bs8m")
BulletResource = ExtResource("1_5q7h7")
EmitterOffset = Vector3(0, 0, 0)
bulletCount = 10
rotationSpeed = 0.0
_rotationOffset = 0.0
duration = 2.0
spread = 0.0
burstInterval = 0.3
ShotsPerBurst = 100
BurstRate = 0.0
_targetPlayer = true
_predictPlayer = false
OverrideOwner = false
Owner = 0
OverrideDamageType = false
DamageType = 0
OverrideControllable = false
Controllable = false
OverrideCreationModifier = false
TimeModifiers = Array[ExtResource("2_x15n1")]([])
WaitForCompletion = true
metadata/_custom_type_script = "uid://bxiprx5nwmpnu"

View file

@ -1,51 +1,26 @@
[gd_resource type="Resource" script_class="BossScript" load_steps=13 format=3 uid="uid://1u4y6hvc318e"]
[gd_resource type="Resource" script_class="BossScript" load_steps=10 format=3 uid="uid://1u4y6hvc318e"]
[ext_resource type="Script" uid="uid://cdd6q2h0t1hhq" path="res://Scripts/Resources/BossPhase.cs" id="1_k3wbt"]
[ext_resource type="Script" uid="uid://fo8sf11p058s" path="res://Scripts/Resources/BulletScripts/SimpleMovementPattern3D.cs" id="2_mi6hp"]
[ext_resource type="Script" uid="uid://inasa76li3ym" path="res://Scripts/Resources/ScriptableBullets/BossScript.cs" id="2_t8f0y"]
[ext_resource type="Script" uid="uid://b5s5mjuk1rng5" path="res://Scripts/Resources/TimeModifier.cs" id="3_mi6hp"]
[ext_resource type="Resource" uid="uid://dl3nq7odtrnum" path="res://Resources/Bullets/Boss/Rumia/Rumia_Red_Chase_Bullet_3D.tres" id="3_xfnue"]
[ext_resource type="Script" uid="uid://bxiprx5nwmpnu" path="res://Scripts/AttackPatterns/ShootingPattern3D.cs" id="4_xfnue"]
[ext_resource type="Resource" uid="uid://bmdxhsjh2qla6" path="res://Resources/BossPhases/Rumia/Rumia_NS_1_Chase.tres" id="3_ovn8y"]
[ext_resource type="Script" uid="uid://cg7gi3tva4gvw" path="res://Scripts/AttackPatterns/WaitPattern.cs" id="6_xfnue"]
[sub_resource type="Resource" id="Resource_xfnue"]
script = ExtResource("2_mi6hp")
relativeTargetPosition = Vector2(-1, 0)
moveDuration = 1.0
relativeTargetPosition = Vector2(-4, 0)
moveDuration = 2.0
RelativeToPlayer = true
transitionType = 0
easeType = 2
WaitForCompletion = false
metadata/_custom_type_script = "uid://fo8sf11p058s"
[sub_resource type="Resource" id="Resource_231tu"]
script = ExtResource("4_xfnue")
BulletResource = ExtResource("3_xfnue")
EmitterOffset = Vector3(0, 0, 0)
bulletCount = 10
rotationSpeed = 0.0
_rotationOffset = 0.0
duration = 2.0
spread = 0.0
burstInterval = 0.3
ShotsPerBurst = 100
BurstRate = 0.0
_targetPlayer = true
_predictPlayer = false
OverrideOwner = false
Owner = 0
OverrideDamageType = false
DamageType = 0
OverrideControllable = false
Controllable = false
OverrideCreationModifier = false
TimeModifiers = Array[ExtResource("3_mi6hp")]([])
WaitForCompletion = true
metadata/_custom_type_script = "uid://bxiprx5nwmpnu"
[sub_resource type="Resource" id="Resource_lrsat"]
script = ExtResource("2_mi6hp")
relativeTargetPosition = Vector2(0, 0)
moveDuration = 1.0
RelativeToPlayer = false
transitionType = 0
easeType = 2
WaitForCompletion = true
@ -53,7 +28,7 @@ metadata/_custom_type_script = "uid://fo8sf11p058s"
[sub_resource type="Resource" id="Resource_0t311"]
script = ExtResource("6_xfnue")
SecondsToWait = 10.0
SecondsToWait = 2.0
WaitForCompletion = true
metadata/_custom_type_script = "uid://cg7gi3tva4gvw"
@ -62,7 +37,7 @@ script = ExtResource("1_k3wbt")
PhaseName = ""
Threshold = 0
PlayAnimation = false
Patterns = Array[Object]([SubResource("Resource_xfnue"), SubResource("Resource_231tu"), SubResource("Resource_lrsat"), SubResource("Resource_0t311")])
Patterns = Array[Object]([SubResource("Resource_xfnue"), ExtResource("3_ovn8y"), SubResource("Resource_lrsat"), SubResource("Resource_0t311")])
metadata/_custom_type_script = "uid://cdd6q2h0t1hhq"
[resource]

View file

@ -7,7 +7,7 @@
[sub_resource type="Resource" id="Resource_jeq72"]
script = ExtResource("2_hgq8i")
decreaseRate = 0.2
decreaseRate = 0.4
[sub_resource type="Resource" id="Resource_edsop"]
script = ExtResource("3_eppnc")
@ -19,7 +19,7 @@ Continuous = false
[resource]
script = ExtResource("4_2o0fq")
BulletScene = ExtResource("1_2ooja")
BulletSpeed = 4.0
BulletSpeed = 6.0
Direction = Vector2(1, 0)
BulletDamage = 20.0
MaxDamage = 1.0

View file

@ -10,6 +10,7 @@ public partial class SimpleMovementPattern3D : AttackPattern
{
[Export] private Vector2 relativeTargetPosition;
[Export] private float moveDuration = 2f;
[Export] public bool RelativeToPlayer { get; private set; }
[Export] private Tween.TransitionType transitionType = Tween.TransitionType.Linear;
[Export] private Tween.EaseType easeType = Tween.EaseType.InOut;
@ -36,8 +37,31 @@ public partial class SimpleMovementPattern3D : AttackPattern
tween = Parent.CreateTween();
isComplete = false;
Vector2 targetPosition = (Boss?.HomePosition.ToVector2() ?? boss.ParentObject.GlobalPosition.ToVector2()) + pattern.relativeTargetPosition;
// Vector2 targetPosition = (Boss?.HomePosition.ToVector2() ?? boss.ParentObject.GlobalPosition.ToVector2()) + pattern.relativeTargetPosition;
var offset = pattern.relativeTargetPosition;
var targetPosition = (Boss?.HomePosition.ToVector2() ?? boss.ParentObject.GlobalPosition.ToVector2());
if (pattern.RelativeToPlayer && GameController.Instance.PlayerPosition.HasValue)
{
var bossPos2D = boss.ParentObject.GlobalPosition.ToVector2();
var playerPos2D = GameController.Instance.PlayerPosition.Value.ToVector2();
var toPlayer = (playerPos2D - bossPos2D).Normalized();
var left = new Vector2(-toPlayer.Y, toPlayer.X); // Perpendicular toPlayer (left)
// Transform the relative offset into the rotated coordinate space
Vector2 transformedOffset = toPlayer * offset.Y + left * offset.X;
targetPosition += transformedOffset;
}
else
{
// Apply default offset from home
targetPosition += offset;
}
var targetPosition3D = targetPosition.ToVector3(boss.ParentObject.GlobalPosition.Y);
boss.ChangeSpriteDirection(-(boss.ParentObject.GlobalPosition.ToVector2() - targetPosition));