Boss healthbar

This commit is contained in:
2023-09-03 00:16:40 -07:00
parent 7764644b90
commit cf2642be2c
29 changed files with 301 additions and 167 deletions

12
Scripts/GodCircuit.cs Normal file
View File

@@ -0,0 +1,12 @@
using Godot;
public partial class GodCircuit : Node3D
{
private void OnHit(Node3D node)
{
GD.Print("Hit");
var hpComponent = GetNode<HealthPoints>("HP Component");
hpComponent.TakeDamage(800000);
hpComponent.UpdateHealthbar();
}
}

28
Scripts/HealthPoints.cs Normal file
View File

@@ -0,0 +1,28 @@
using Godot;
public partial class HealthPoints : Node
{
[Export]
public long MaximumHP { get; protected set; }
public long CurrentHP { get; protected set; }
[Export]
private TextureProgressBar _healthBar;
public override void _Ready()
{
CurrentHP = MaximumHP;
}
public void TakeDamage(long damage)
{
CurrentHP -= damage;
GD.Print(CurrentHP);
}
public void UpdateHealthbar()
{
_healthBar.Value = CurrentHP;
}
}

View File

@@ -0,0 +1,9 @@
using Godot;
public partial class HealthbarProgress : TextureProgressBar
{
public void UpdateBar(long amount, long full)
{
Value = amount;
}
}

View File

@@ -1,5 +0,0 @@
using Godot;
public partial class Level2 : Node3D
{
}

View File

@@ -16,6 +16,8 @@ public partial class MainMenu : Node2D
var bgmPlayer = GetTree().Root.GetNode<BGMPlayer>("BgmPlayer");
bgmPlayer.SetBGMFromFilepath("Audio/BGM/02 MovinOn.mp3");
bgmPlayer.PlayBGM();
var main = GetTree().Root.GetNode<Main>("/root/Main");
main.LoadLevel(0);
}
private void OnStartButtonPressed()

View File

@@ -56,7 +56,7 @@ public partial class TestCharacter : CharacterBody3D
private async void Fire()
{
var projectile = _fireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 1f, -3f);
projectile.Position = Position + new Vector3(0f, 1f, -1f);
GetParent().AddChild(projectile);
CanShoot = false;
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
@@ -66,7 +66,7 @@ public partial class TestCharacter : CharacterBody3D
private async void AltFire()
{
var projectile = _altFireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 1f, -3f);
projectile.Position = Position + new Vector3(0f, 1f, -1f);
GetParent().AddChild(projectile);
CanShoot = false;
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");

View File

@@ -14,7 +14,7 @@ public partial class TestEnemy : RigidBody3D
LookAt(player.Position);
}
public override async void _PhysicsProcess(double delta)
public override void _PhysicsProcess(double delta)
{
_pathFollow.Progress += _speed * (float)delta;
}