generated from Persson-dev/Godot-Xmake
Added zombie spawn animation, red screen and hit stagger when the player is hit.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "Zombie.h"
|
||||
|
||||
#include <godot_cpp/classes/engine.hpp>
|
||||
#include <godot_cpp/core/math.hpp>
|
||||
|
||||
using namespace godot;
|
||||
|
||||
@@ -12,6 +13,7 @@ static constexpr float ATTACK_RANGE = 2.0f;
|
||||
void Zombie::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_m_PlayerPath", "m_PlayerPath"), &Zombie::set_m_PlayerPath);
|
||||
ClassDB::bind_method(D_METHOD("get_m_PlayerPath"), &Zombie::get_m_PlayerPath);
|
||||
ClassDB::bind_method(D_METHOD("hit_finished"), &Zombie::hit_finished);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "m_PlayerPath"), "set_m_PlayerPath", "get_m_PlayerPath");
|
||||
}
|
||||
@@ -73,4 +75,11 @@ void Zombie::set_m_PlayerPath(const NodePath& path) {
|
||||
NodePath Zombie::get_m_PlayerPath() const {
|
||||
return m_PlayerPath;
|
||||
}
|
||||
|
||||
void Zombie::hit_finished() {
|
||||
if (this->get_global_position().distance_to(m_Player->get_global_position()) < (ATTACK_RANGE + 1.0)) {
|
||||
Vector3 dir = this->get_global_position().direction_to(m_Player->get_global_position());
|
||||
m_Player->hit(dir);
|
||||
}
|
||||
}
|
||||
} // namespace blitz
|
||||
Reference in New Issue
Block a user