mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 01:55:54 +00:00
Scriptable bullet emitter
This commit is contained in:
parent
d62538a382
commit
4261009c33
17 changed files with 251 additions and 74 deletions
|
|
@ -13,19 +13,19 @@ namespace Cirno.Scripts.AttackPatterns;
|
|||
public partial class SpiralPattern : AttackPattern
|
||||
{
|
||||
[Export] public BulletResource BulletResource { get; set; }
|
||||
[Export] public PackedScene BulletScene;
|
||||
[Export] private float _bulletLifeTime = 20f; // Switch to res
|
||||
[Export] private bool _destroyOnCollision = false; // Switch to res
|
||||
[Export] private float bulletSpeed = 5f; // Switch to res
|
||||
//Export] public PackedScene BulletScene;
|
||||
//[Export] private float _bulletLifeTime = 20f; // Switch to res
|
||||
//[Export] private bool _destroyOnCollision = false; // Switch to res
|
||||
//[Export] private float bulletSpeed = 5f; // Switch to res
|
||||
[Export] private int bulletCount = 16;
|
||||
[Export] private float rotationSpeed = 0f;
|
||||
[Export] private float _rotationOffset = 0f;
|
||||
[Export] private float duration = 5f;
|
||||
[Export] private float burstInterval = 0.5f;
|
||||
[Export] private float spread = 360f;
|
||||
[Export] private BulletOwner owner = BulletOwner.Enemy; // Switch to res
|
||||
[Export] private DamageType _damageType = DamageType.Neutral; // Switch to res
|
||||
[Export] private float _bulletDamage = 1f; // Switch to res
|
||||
//[Export] private BulletOwner owner = BulletOwner.Enemy; // Switch to res
|
||||
//[Export] private DamageType _damageType = DamageType.Neutral; // Switch to res
|
||||
//[Export] private float _bulletDamage = 1f; // Switch to res
|
||||
[ExportGroup("Modifiers")]
|
||||
[Export] private BulletCreationModifier _modifier;
|
||||
[ExportGroup("Modifiers")]
|
||||
|
|
@ -37,12 +37,12 @@ public partial class SpiralPattern : AttackPattern
|
|||
private double burstTimer;
|
||||
private BulletSpawner spawner;
|
||||
|
||||
public override void Start(Boss boss)
|
||||
public override void Start(Node2D parent)
|
||||
{
|
||||
Boss = boss;
|
||||
Parent = parent;
|
||||
timer = 0;
|
||||
burstTimer = burstInterval; // start immediately
|
||||
spawner = boss.GetNode<BulletSpawner>("BulletSpawner");
|
||||
spawner = parent.GetNode<BulletSpawner>("BulletSpawner");
|
||||
}
|
||||
|
||||
public override void UpdatePattern(double delta)
|
||||
|
|
@ -55,12 +55,12 @@ public partial class SpiralPattern : AttackPattern
|
|||
|
||||
Vector2 direction = BulletResource.Direction;
|
||||
|
||||
if (_targetPlayer && Boss.GameManager.PlayerPosition.HasValue)
|
||||
if (_targetPlayer && GameManager.Instance.PlayerPosition.HasValue)
|
||||
{
|
||||
direction = (Boss.GameManager.PlayerPosition.Value - Boss.GlobalPosition).Normalized();
|
||||
direction = (GameManager.Instance.PlayerPosition.Value - Parent.GlobalPosition).Normalized();
|
||||
}
|
||||
|
||||
var bullet = BulletResource.MakeBullet(Boss.GlobalPosition, bulletCount, spread, angleOffset);
|
||||
var bullet = BulletResource.MakeBullet(Parent.GlobalPosition, bulletCount, spread, angleOffset);
|
||||
bullet.Direction = direction;
|
||||
|
||||
//spawner.SpawnBullet(MakeBullet(Boss.GlobalPosition, direction, angleOffset));
|
||||
|
|
@ -94,25 +94,27 @@ public partial class SpiralPattern : AttackPattern
|
|||
{
|
||||
var bl = BulletResource.MakeBullet(position, bulletCount, angleOffset);
|
||||
bl.Direction = direction;
|
||||
|
||||
return bl;
|
||||
|
||||
return new BulletInfo()
|
||||
{
|
||||
Position = position,
|
||||
Direction = direction,
|
||||
LifeTime = _bulletLifeTime,
|
||||
DestroyOnCollision = _destroyOnCollision,
|
||||
Speed = bulletSpeed,
|
||||
Owner = owner,
|
||||
DamageType = _damageType,
|
||||
Damage = _bulletDamage,
|
||||
BulletCount = bulletCount,
|
||||
Spread = spread,
|
||||
BulletScene = BulletScene,
|
||||
RotationOffset = angleOffset,
|
||||
Modifier = _modifier,
|
||||
TimeModifiers = _timeModifiers.ToList()// _timeModifiers.Select(x => x.MakeClone()).ToList()
|
||||
// TimeModifiers = _timeModifiers?.Where(mod => mod != null).ToList() ?? new List<TimeModifier>()
|
||||
};
|
||||
// return new BulletInfo()
|
||||
// {
|
||||
// Position = position,
|
||||
// Direction = direction,
|
||||
// LifeTime = _bulletLifeTime,
|
||||
// DestroyOnCollision = _destroyOnCollision,
|
||||
// Speed = bulletSpeed,
|
||||
// Owner = owner,
|
||||
// DamageType = _damageType,
|
||||
// Damage = _bulletDamage,
|
||||
// BulletCount = bulletCount,
|
||||
// Spread = spread,
|
||||
// BulletScene = BulletScene,
|
||||
// RotationOffset = angleOffset,
|
||||
// Modifier = _modifier,
|
||||
// TimeModifiers = _timeModifiers.ToList()// _timeModifiers.Select(x => x.MakeClone()).ToList()
|
||||
// // TimeModifiers = _timeModifiers?.Where(mod => mod != null).ToList() ?? new List<TimeModifier>()
|
||||
// };
|
||||
}
|
||||
|
||||
public override bool IsComplete()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue