Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

using Godot;

using System;

public partial class Boss : CharacterBody2D


{
public int Bspeed = 100;
private float Gravity = 100;
AnimationPlayer Bap;
private Knight knight;
public bool Bactive;
public bool Babletoattack;
public float BattackTimer = 1f;
private float BattackTimerReset = 1f;
public float Bhealth = 3;
public override void _Process(double delta)
{
if (Bactive)
{
if (Babletoattack)
{
GD.Print("attack");
Babletoattack = false;
BattackTimer = BattackTimerReset;
}
}
if (BattackTimer <= 0)
{
Babletoattack = true;
}
else BattackTimer -= (float)delta;
}
private void AnimationUpdate()
{
Vector2 velocity = Velocity;
Velocity = velocity;

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();

}
}

You might also like