Boss healthbar
This commit is contained in:
12
Scripts/GodCircuit.cs
Normal file
12
Scripts/GodCircuit.cs
Normal 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
28
Scripts/HealthPoints.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
9
Scripts/HealthbarProgress.cs
Normal file
9
Scripts/HealthbarProgress.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Godot;
|
||||
|
||||
public partial class HealthbarProgress : TextureProgressBar
|
||||
{
|
||||
public void UpdateBar(long amount, long full)
|
||||
{
|
||||
Value = amount;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
using Godot;
|
||||
|
||||
public partial class Level2 : Node3D
|
||||
{
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user