mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-07 08:05:54 +00:00
Added offsets and remade modifiers system
This commit is contained in:
parent
881a4897da
commit
aab69fb609
16 changed files with 474 additions and 426 deletions
|
|
@ -1,55 +0,0 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.AttackPatterns;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class PatternTest : AttackPattern
|
||||
{
|
||||
[Export] public PackedScene BulletScene;
|
||||
[Export] public float bulletSpeed = 5f;
|
||||
[Export] public int bulletCount = 12;
|
||||
[Export] public float duration = 3f;
|
||||
[Export] public float burstInterval = 0.5f;
|
||||
[Export] public BulletOwner owner = BulletOwner.Enemy;
|
||||
|
||||
public override IPatternMachine MakeMachine(Node2D parent)
|
||||
{
|
||||
return new PatternTestMachine(this, parent);
|
||||
}
|
||||
|
||||
public class PatternTestMachine(PatternTest pattern, Node2D parent) : IPatternMachine
|
||||
{
|
||||
public Node2D Parent => parent;
|
||||
private double timer;
|
||||
private double burstTimer;
|
||||
private BulletSpawner spawner;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
timer = 0;
|
||||
burstTimer = 0;
|
||||
spawner = Parent.GetNode<BulletSpawner>("BulletSpawner");
|
||||
}
|
||||
|
||||
public void UpdatePattern(double delta)
|
||||
{
|
||||
timer += delta;
|
||||
burstTimer += delta;
|
||||
if (timer < pattern.duration && burstTimer >= pattern.burstInterval)
|
||||
{
|
||||
spawner.SpawnBullet(Parent.GlobalPosition, Vector2.Right, pattern.bulletSpeed, pattern.owner, pattern.bulletCount, bulletScene: pattern.BulletScene);
|
||||
burstTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsComplete()
|
||||
{
|
||||
return timer >= pattern.duration;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://bay71pcaj4nj2
|
||||
|
|
@ -16,6 +16,8 @@ public partial class SpiralPattern : AttackPattern
|
|||
{
|
||||
[Export] public BulletResource BulletResource { get; set; }
|
||||
|
||||
[Export] public Vector2 EmitterOffset { get; set; } = Vector2.Zero;
|
||||
|
||||
//Export] public PackedScene BulletScene;
|
||||
//[Export] private float _bulletLifeTime = 20f; // Switch to res
|
||||
//[Export] private bool _destroyOnCollision = false; // Switch to res
|
||||
|
|
@ -242,7 +244,7 @@ public partial class SpiralPattern : AttackPattern
|
|||
}
|
||||
}
|
||||
|
||||
var bullet = pattern.MakeBullet(Parent.GlobalPosition, pattern.bulletCount,
|
||||
var bullet = pattern.MakeBullet(Parent.GlobalPosition + pattern.EmitterOffset, pattern.bulletCount,
|
||||
pattern.spread, angleOffset);
|
||||
|
||||
bullet.Direction = direction;
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Cirno.Scripts.Components;
|
||||
using Cirno.Scripts.Resources;
|
||||
|
||||
namespace Cirno.Scripts.AttackPatterns;
|
||||
|
||||
using Godot;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class TargetedPattern : AttackPattern
|
||||
{
|
||||
[Export] public PackedScene BulletScene;
|
||||
|
||||
[Export] private float bulletSpeed = 5f;
|
||||
[Export] private float duration = 3f;
|
||||
[Export] private float burstInterval = 0.5f;
|
||||
[Export] private int bulletsPerShot = 1;
|
||||
[Export] private float spread = 0f;
|
||||
[Export] private BulletOwner owner = BulletOwner.Enemy;
|
||||
[Export] private BulletCreationModifier modifier;
|
||||
|
||||
public override IPatternMachine MakeMachine(Node2D parent)
|
||||
{
|
||||
return new TargetedPatternMachine(this, parent);
|
||||
}
|
||||
|
||||
public class TargetedPatternMachine(TargetedPattern pattern, Node2D parent) : IPatternMachine
|
||||
{
|
||||
public Node2D Parent => parent;
|
||||
|
||||
private double timer;
|
||||
private double burstTimer;
|
||||
private BulletSpawner spawner;
|
||||
//private Node2D player;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
timer = 0;
|
||||
burstTimer = 0;
|
||||
spawner = Parent.GetNode<BulletSpawner>("BulletSpawner");
|
||||
|
||||
}
|
||||
|
||||
public void UpdatePattern(double delta)
|
||||
{
|
||||
timer += delta;
|
||||
burstTimer += delta;
|
||||
if (timer < pattern.duration && burstTimer >= pattern.burstInterval && GameManager.Instance.PlayerPosition.HasValue)
|
||||
{
|
||||
spawner.SpawnTargetedBullet(Parent.GlobalPosition, GameManager.Instance.PlayerPosition.Value, pattern.bulletSpeed, pattern.owner, pattern.BulletScene, pattern.bulletsPerShot, pattern.spread, pattern.modifier);
|
||||
burstTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsComplete()
|
||||
{
|
||||
return timer >= pattern.duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://by0fm3opaexcs
|
||||
Loading…
Add table
Add a link
Reference in a new issue