diff --git a/Resources/BossPhases/testphase.tres b/Resources/BossPhases/testphase.tres new file mode 100644 index 00000000..a1b50a3d --- /dev/null +++ b/Resources/BossPhases/testphase.tres @@ -0,0 +1,27 @@ +[gd_resource type="Resource" script_class="BossPhase" load_steps=4 format=3 uid="uid://c2xhuinmhit15"] + +[ext_resource type="Script" path="res://Scripts/Resources/BossPhase.cs" id="1_cxesb"] +[ext_resource type="Script" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="1_q8vp4"] + +[sub_resource type="Resource" id="Resource_8caj3"] +script = ExtResource("1_q8vp4") +bulletSpeed = 5.0 +bulletCount = 16 +rotationSpeed = 0.0 +_rotationOffset = 0.0 +duration = 5.0 +burstInterval = 0.5 +spread = 360.0 +owner = 2 +_damageType = 0 +_bulletDamage = 1.0 +_timeModifiers = Array[Resource]([null]) +_targetPlayer = false +WaitForCompletion = true + +[resource] +script = ExtResource("1_cxesb") +PhaseName = "asdf" +Threshold = 0 +PlayAnimation = false +Patterns = Array[Object]([SubResource("Resource_8caj3")]) diff --git a/Scripts/AttackPatterns/SpiralPattern.cs b/Scripts/AttackPatterns/SpiralPattern.cs index 426bba98..99179601 100644 --- a/Scripts/AttackPatterns/SpiralPattern.cs +++ b/Scripts/AttackPatterns/SpiralPattern.cs @@ -22,7 +22,7 @@ public partial class SpiralPattern : AttackPattern [Export] private BulletOwner owner = BulletOwner.Enemy; [Export] private DamageType _damageType = DamageType.Neutral; [Export] private float _bulletDamage = 1f; - [Export] private Resource _modifier; + [Export] private BulletCreationModifier _modifier; [Export] private Array _timeModifiers; [Export] private bool _targetPlayer = false; @@ -69,7 +69,7 @@ public partial class SpiralPattern : AttackPattern Spread = spread, BulletScene = BulletScene, RotationOffset = angleOffset, - Modifier = _modifier as IBulletModifier, + Modifier = _modifier, TimeModifiers = _timeModifiers?.Where(mod => mod is TimeModifier).Cast().ToList() ?? new List() }); diff --git a/Scripts/AttackPatterns/TargetedPattern.cs b/Scripts/AttackPatterns/TargetedPattern.cs index 195a1b4a..cde42b14 100644 --- a/Scripts/AttackPatterns/TargetedPattern.cs +++ b/Scripts/AttackPatterns/TargetedPattern.cs @@ -17,7 +17,7 @@ public partial class TargetedPattern : AttackPattern [Export] private int bulletsPerShot = 1; [Export] private float spread = 0f; [Export] private BulletOwner owner = BulletOwner.Enemy; - [Export] private Resource modifier; + [Export] private BulletCreationModifier modifier; private double timer; private double burstTimer; @@ -42,7 +42,7 @@ public partial class TargetedPattern : AttackPattern burstTimer += delta; if (timer < duration && burstTimer >= burstInterval && _gameManager.PlayerPosition.HasValue) { - spawner.SpawnTargetedBullet(Boss.GlobalPosition, _gameManager.PlayerPosition.Value, bulletSpeed, owner, BulletScene, bulletsPerShot, spread, modifier as IBulletModifier); + spawner.SpawnTargetedBullet(Boss.GlobalPosition, _gameManager.PlayerPosition.Value, bulletSpeed, owner, BulletScene, bulletsPerShot, spread, modifier); burstTimer = 0; } } diff --git a/Scripts/Resources/BulletCreationModifier.cs b/Scripts/Resources/BulletCreationModifier.cs new file mode 100644 index 00000000..16bd9323 --- /dev/null +++ b/Scripts/Resources/BulletCreationModifier.cs @@ -0,0 +1,9 @@ +using Godot; + +namespace Cirno.Scripts.Resources; + +[GlobalClass] +public abstract partial class BulletCreationModifier : Resource, IBulletModifier +{ + public abstract float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets); +} \ No newline at end of file diff --git a/Scripts/Resources/BulletResource.cs b/Scripts/Resources/BulletResource.cs index 34d98790..e9d19625 100644 --- a/Scripts/Resources/BulletResource.cs +++ b/Scripts/Resources/BulletResource.cs @@ -19,7 +19,7 @@ public partial class BulletResource : Resource [Export] public DamageType DamageType = DamageType.Neutral; [Export] - public Resource Modifier; + public BulletCreationModifier Modifier; [Export] public Array TimeModifiers; public BulletInfo MakeBullet(Vector2 position, int count = 1, float spread = 0f, float rotationOffset = 0f) @@ -36,7 +36,7 @@ public partial class BulletResource : Resource Spread = spread, BulletScene = BulletScene, RotationOffset = rotationOffset, - Modifier = Modifier as IBulletModifier, + Modifier = Modifier, LifeTime = LifeTime, DestructionParticlesScene = DestructionParticlesScene, TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast().ToList() ?? diff --git a/Scripts/Resources/DecreasingSpeedModifier.cs b/Scripts/Resources/DecreasingSpeedModifier.cs index bce1a105..a3a66ad1 100644 --- a/Scripts/Resources/DecreasingSpeedModifier.cs +++ b/Scripts/Resources/DecreasingSpeedModifier.cs @@ -3,11 +3,11 @@ namespace Cirno.Scripts.Resources; [GlobalClass] -public partial class DecreasingSpeedModifier : Resource, IBulletModifier +public partial class DecreasingSpeedModifier : BulletCreationModifier, IBulletModifier { [Export] private float decreaseRate = 0.1f; - public float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets) + public override float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets) { return Mathf.Max(0, baseSpeed - (decreaseRate * bulletIndex)); } diff --git a/Scripts/Resources/SpeedModifier.cs b/Scripts/Resources/SpeedModifier.cs index d305bd54..f05061f3 100644 --- a/Scripts/Resources/SpeedModifier.cs +++ b/Scripts/Resources/SpeedModifier.cs @@ -3,7 +3,7 @@ namespace Cirno.Scripts.Resources; [GlobalClass] -public partial class SpeedModifier : Resource, IBulletModifier +public partial class SpeedModifier : BulletCreationModifier, IBulletModifier { [Export] public SpeedModifierType ModifierType; [Export] public EasingType Easing; @@ -11,7 +11,7 @@ public partial class SpeedModifier : Resource, IBulletModifier [Export] public float MinimumSpeed = 10f; [Export] public float ScalingFactor = 10.0f; - public float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets) + public override float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets) { if (totalBullets <= 1) return baseSpeed;