Add EnemyControllerComponent and PeriodicShootingComponent; implement enemy shooting behavior and bullet spawning
This commit is contained in:
20
scripts/components/EnemyControllerComponent.cs
Normal file
20
scripts/components/EnemyControllerComponent.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class EnemyControllerComponent : Node
|
||||
{
|
||||
[Export] public SideToSideMovementComponent MovementComponent { get; set; }
|
||||
[Export] public PeriodicShootingComponent ShootingComponent { get; set; }
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (MovementComponent == null || ShootingComponent == null) return;
|
||||
|
||||
if (MovementComponent.Direction != Vector2.Zero)
|
||||
{
|
||||
ShootingComponent.ShootDirection = MovementComponent.Direction;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user