chill-jam-10-2024/scripts/NPC.cs

47 lines
831 B
C#

using Godot;
using System;
using Godot.Collections;
public partial class NPC : Node2D
{
[Export] public string NPCName;
[Export] public SpriteFrames Frames;
[Export] public Array<string> DialogLines = new Array<string>();
private AnimatedSprite2D _sprite;
public override void _Ready()
{
_sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
_sprite.SpriteFrames = Frames;
_sprite.Play("default");
}
public override void _Process(double delta)
{
}
public void test()
{
if (_sprite.Animation == "walk")
{
_sprite.Play("default");
}
else
{
_sprite.Play("walk");
}
}
private void _on_interactable_player_near_by(Player player)
{
player.InteractableObjects.Add(this);
}
private void _on_interactable_player_left(Player player)
{
player.InteractableObjects.Remove(this);
}
}