28 lines
553 B
C#
28 lines
553 B
C#
using Godot;
|
|
using System;
|
|
|
|
public partial class Bucket : Node2D
|
|
{
|
|
|
|
[Signal]
|
|
public delegate void AttackEnteredEventHandler(Attack ATTACK);
|
|
public int _minX = -500, _maxX = 500, _movementSign = 1, _movementSpeed = 3;
|
|
|
|
public void Move()
|
|
{
|
|
Position += new Vector2(_movementSign * _movementSpeed, 0);
|
|
if (Position.X >= _maxX || Position.X <= _minX)
|
|
{
|
|
_movementSign *= -1;
|
|
}
|
|
}
|
|
public void OnBodyEntered(Node2D BODY)
|
|
{
|
|
if (BODY is Attack attack)
|
|
{
|
|
EmitSignal(SignalName.AttackEntered, attack);
|
|
attack.EnteredBucket();
|
|
}
|
|
}
|
|
}
|