Moved scripts to namespaces
This commit is contained in:
parent
fd7060e5c5
commit
de2c6261b0
51 changed files with 128 additions and 29 deletions
33
scripts/components/LinearProjectile.cs
Normal file
33
scripts/components/LinearProjectile.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace Newlon.Components;
|
||||
|
||||
//
|
||||
// Projectile that travels from left to right
|
||||
//
|
||||
|
||||
public partial class LinearProjectile : Area2D, IProjectile
|
||||
{
|
||||
[Export(hintString: "suffix:tile/sec")]
|
||||
private float _speed;
|
||||
[Export]
|
||||
private int _damage;
|
||||
private int _line;
|
||||
public int Line { get => _line; set { _line = value; } }
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
Translate(Vector2.Right * _speed * (float)delta * Utility.TileWidth);
|
||||
}
|
||||
|
||||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
var entity = area.GetParent<IEntity>();
|
||||
if (entity != null && entity.Line == _line)
|
||||
{
|
||||
entity.TakeDamage(_damage);
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue