Files
hotdesking/Gameplay/ActorPanel.cs
2025-07-17 03:55:30 -04:00

37 lines
1.1 KiB
C#

using Godot;
using System;
public partial class ActorPanel : Panel
{
public static ActorPanel _Create(Actor ACTOR)
{
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/actor_panel.tscn");
ActorPanel newActorPanel = scene.Instantiate<ActorPanel>();
newActorPanel.SetSprite(ACTOR.Texture);
newActorPanel.SetMax(ACTOR._healthMax);
newActorPanel.SetValue(ACTOR._health);
newActorPanel.SetPosition(new Vector2(1500, 0));
return newActorPanel;
}
public void SetPosition(Vector2 POSITION)
{
Position = POSITION;
}
public void SetSprite(Texture2D TEXTURE)
{
GetNode<Sprite2D>("Image").Texture = TEXTURE;
}
public void SetValue(int VALUE)
{
GetNode<Node2D>("Health").GetNode<RichTextLabel>("Value").Text = VALUE.ToString();
GetNode<Node2D>("Health").GetNode<ProgressBar>("Bar").Value = VALUE;
}
public void SetMax(int MAX)
{
GetNode<Node2D>("Health").GetNode<RichTextLabel>("Max").Text = MAX.ToString();
GetNode<Node2D>("Health").GetNode<ProgressBar>("Bar").MaxValue = MAX;
}
}