Professional Documents
Culture Documents
oldenemyai
oldenemyai
using System;
if (Bactive)
{
Bap.Play("BAttack");
}
}
private void OnPlayerDetectionBodyEntered(Node2D body)
{
GD.Print("enter" + body);
if (body is Knight)
{
Bap.Play("BAttack");
knight = body as Knight;
Bactive = true;
}
}
private void OnPlayerDetectionBodyExited(Node2D body)
{
GD.Print("exit" + body);
if (body is Knight)
{
knight = body as Knight;
Bactive = false;
}
}
public override void _Ready()
{
Bap = GetNode<AnimationPlayer>("AnimationPlayer");
}
private void OnHurtBoxAreaEntered(Area2D area)
{
Bhealth -= 1;
GD.Print(Bhealth);
}
public override void _PhysicsProcess(double delta)
{
Vector2 velocity = Velocity;
if (!IsOnFloor())
{
velocity.Y += Gravity*(float)delta;
}
if (Bhealth <= 0)
{
Bap.Play("BDeath");
QueueFree();
}
AnimationUpdate();
Velocity = velocity;
MoveAndSlide();
}
}