2022-06-11 00:26:11 -04:00
|
|
|
#include "coin/CoinCollected.h"
|
|
|
|
#include <AnimationPlayer.hpp>
|
|
|
|
|
|
|
|
using namespace godot;
|
|
|
|
|
|
|
|
void CoinCollected::_register_methods()
|
|
|
|
{
|
|
|
|
register_method("_state_enter", &CoinCollected::_state_enter);
|
|
|
|
register_method("_state_exit", &CoinCollected::_state_exit);
|
|
|
|
register_method("_on_animation_finished", &CoinCollected::_on_animation_finished);
|
2022-07-16 18:36:38 -04:00
|
|
|
register_signal<CoinCollected>("coin_collected", "amount", GODOT_VARIANT_TYPE_INT);
|
2022-06-11 00:26:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CoinCollected::CoinCollected()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CoinCollected::~CoinCollected()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoinCollected::_init()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoinCollected::_state_enter()
|
|
|
|
{
|
|
|
|
auto node = get_parent()->find_node("AnimationPlayer");
|
|
|
|
|
|
|
|
if (node != nullptr)
|
|
|
|
{
|
|
|
|
auto animation_player = Object::cast_to<AnimationPlayer>(node);
|
|
|
|
animation_player->play("jump");
|
|
|
|
}
|
2022-07-15 23:04:06 -04:00
|
|
|
|
2022-06-11 00:26:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoinCollected::_state_exit()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoinCollected::_on_animation_finished(String anim_name)
|
|
|
|
{
|
2022-07-16 18:36:38 -04:00
|
|
|
emit_signal("coin_collected", 1);
|
2022-06-11 00:26:11 -04:00
|
|
|
this->get_parent()->queue_free();
|
|
|
|
|
2022-07-16 18:36:38 -04:00
|
|
|
|
2022-07-15 23:04:06 -04:00
|
|
|
// get_state_machine()->change("CoinCounter");
|
|
|
|
|
2022-06-11 00:26:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|