53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using Godot;
|
|
using System;
|
|
|
|
public partial class ActorPanel : Panel
|
|
{
|
|
public bool _hovered = false;
|
|
public Actor _actor;
|
|
public static ActorPanel _Create(Actor ACTOR)
|
|
{
|
|
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/actor_panel.tscn");
|
|
ActorPanel newActorPanel = scene.Instantiate<ActorPanel>();
|
|
|
|
newActorPanel._actor = ACTOR;
|
|
newActorPanel.SetSprite(newActorPanel._actor.GetNode<Sprite2D>("Sprite").Texture);
|
|
newActorPanel.SetMax(newActorPanel._actor._healthMax);
|
|
newActorPanel.SetValue(newActorPanel._actor._health);
|
|
newActorPanel.SetPosition(new Vector2(50, 300));
|
|
|
|
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<Control>("Health").GetNode<RichTextLabel>("Value").Text = VALUE.ToString();
|
|
GetNode<Control>("Health").GetNode<ProgressBar>("Bar").Value = VALUE;
|
|
}
|
|
public void SetMax(int MAX)
|
|
{
|
|
GetNode<Control>("Health").GetNode<RichTextLabel>("Max").Text = MAX.ToString();
|
|
GetNode<Control>("Health").GetNode<ProgressBar>("Bar").MaxValue = MAX;
|
|
}
|
|
|
|
private void OnMouseEntered()
|
|
{
|
|
_hovered = true;
|
|
GD.Print(_hovered);
|
|
}
|
|
|
|
private void OnMouseExited()
|
|
{
|
|
_hovered = false;
|
|
GD.Print(_hovered);
|
|
}
|
|
}
|