feat: work on running and weapon inventory
This commit is contained in:
parent
43c5863e89
commit
6cdb2cbd4f
Binary file not shown.
Binary file not shown.
|
@ -27,8 +27,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool try_running{ false };
|
bool try_running{ false };
|
||||||
float walk_speed{ 7.f };
|
float walk_speed{ 6.f };
|
||||||
float run_speed{ 10.f };
|
float run_speed{ 8.f };
|
||||||
float acceleration{ 40.f };
|
float acceleration{ 40.f };
|
||||||
float jump_strength{ 3.5f };
|
float jump_strength{ 3.5f };
|
||||||
Vector2 movement_input{};
|
Vector2 movement_input{};
|
||||||
|
|
|
@ -37,3 +37,11 @@ AnimationPlayer *WeaponBase::get_anim() const {
|
||||||
PlayerCamera *WeaponBase::get_camera() const {
|
PlayerCamera *WeaponBase::get_camera() const {
|
||||||
return this->camera;
|
return this->camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WeaponBase::set_body(PlayerBody *body) {
|
||||||
|
this->body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerBody *WeaponBase::get_body() const {
|
||||||
|
return this->body;
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "scene/3d/node_3d.h"
|
#include "scene/3d/node_3d.h"
|
||||||
class AnimationPlayer;
|
class AnimationPlayer;
|
||||||
class PlayerCamera;
|
class PlayerCamera;
|
||||||
|
class PlayerBody;
|
||||||
|
|
||||||
class WeaponBase : public Node3D {
|
class WeaponBase : public Node3D {
|
||||||
GDCLASS(WeaponBase, Node3D);
|
GDCLASS(WeaponBase, Node3D);
|
||||||
|
@ -16,12 +17,15 @@ protected:
|
||||||
public:
|
public:
|
||||||
void set_anim(AnimationPlayer *player);
|
void set_anim(AnimationPlayer *player);
|
||||||
AnimationPlayer *get_anim() const;
|
AnimationPlayer *get_anim() const;
|
||||||
|
|
||||||
PlayerCamera *get_camera() const;
|
PlayerCamera *get_camera() const;
|
||||||
|
|
||||||
|
void set_body(PlayerBody *body);
|
||||||
|
PlayerBody *get_body() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AnimationPlayer *anim{ nullptr };
|
AnimationPlayer *anim{ nullptr };
|
||||||
PlayerCamera *camera{ nullptr };
|
PlayerCamera *camera{ nullptr };
|
||||||
|
PlayerBody *body{ nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !WEAPON_BASE_H
|
#endif // !WEAPON_BASE_H
|
||||||
|
|
10
modules/wave_survival/weapon_inventory.cpp
Normal file
10
modules/wave_survival/weapon_inventory.cpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#include "weapon_inventory.h"
|
||||||
|
|
||||||
|
void WeaponInventory::_bind_methods() {}
|
||||||
|
|
||||||
|
void WeaponInventory::on_switch_input() {
|
||||||
|
this->current = (this->current + 1) % 1;
|
||||||
|
this->select_weapon(this->weapons[this->current]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
33
modules/wave_survival/weapon_inventory.h
Normal file
33
modules/wave_survival/weapon_inventory.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef WEAPON_INVENTORY_H
|
||||||
|
#define WEAPON_INVENTORY_H
|
||||||
|
|
||||||
|
#include "scene/main/node.h"
|
||||||
|
#include "scene/resources/packed_scene.h"
|
||||||
|
class PlayerBody;
|
||||||
|
class WeaponBase;
|
||||||
|
|
||||||
|
class WeaponInventory : public Node {
|
||||||
|
GDCLASS(WeaponInventory, Node);
|
||||||
|
static void _bind_methods();
|
||||||
|
void on_switch_input();
|
||||||
|
void ready();
|
||||||
|
void select_weapon(WeaponBase *next);
|
||||||
|
protected:
|
||||||
|
void _notification(int what);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void set_fallback_weapon(Ref<PackedScene> scene);
|
||||||
|
Ref<PackedScene> get_fallback_weapon() const;
|
||||||
|
|
||||||
|
WeaponBase *get_current_weapon() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned current{ 0 };
|
||||||
|
LocalVector<WeaponBase *> weapons{ nullptr, nullptr };
|
||||||
|
WeaponBase *current_weapon{ nullptr };
|
||||||
|
WeaponBase *fallback_weapon{ nullptr };
|
||||||
|
|
||||||
|
Ref<PackedScene> default_weapon_scene{};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !WEAPON_INVENTORY_H
|
Loading…
Reference in a new issue