Compare commits
No commits in common. "efe5607f60ad487b34ca0413becb703b02063ca7" and "5277ac62816f30546cadd92c8f1f91a8eb097e53" have entirely different histories.
efe5607f60
...
5277ac6281
|
@ -4,18 +4,17 @@ HeadsUpDisplay *HeadsUpDisplay::singleton_instance{ nullptr };
|
|||
|
||||
void HeadsUpDisplay::_bind_methods() {
|
||||
ClassDB::bind_static_method("HeadsUpDisplay", D_METHOD("get_singleton"), &self_type::get_singleton);
|
||||
ClassDB::bind_method(D_METHOD("set_tooltip", "tooltip"), &self_type::set_tooltip);
|
||||
ClassDB::bind_method(D_METHOD("set_health_percentage", "percentage"), &self_type::set_health_percentage);
|
||||
ClassDB::bind_method(D_METHOD("set_tooltip"), &self_type::set_tooltip);
|
||||
}
|
||||
|
||||
void HeadsUpDisplay::on_child_entered(Node *child) {
|
||||
child->connect("child_entered_tree", callable_mp(this, &self_type::on_child_entered));
|
||||
if (child->is_unique_name_in_owner() && child->get_name() == "Reticle") {
|
||||
this->reticle = cast_to<Control>(child);
|
||||
}
|
||||
if (child->is_unique_name_in_owner() && child->get_name() == "Tooltip") {
|
||||
this->tooltip = cast_to<Label>(child);
|
||||
}
|
||||
if (child->is_unique_name_in_owner() && child->get_name() == "Healthbar") {
|
||||
this->healthbar = cast_to<ProgressBar>(child);
|
||||
}
|
||||
}
|
||||
|
||||
void HeadsUpDisplay::enter_tree() {
|
||||
|
@ -47,10 +46,12 @@ HeadsUpDisplay *HeadsUpDisplay::get_singleton() {
|
|||
return singleton_instance;
|
||||
}
|
||||
|
||||
void HeadsUpDisplay::set_reticle_visibility(bool visible) {
|
||||
if (this->reticle) {
|
||||
this->reticle->set_visible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
void HeadsUpDisplay::set_tooltip(String const &tooltip) {
|
||||
this->tooltip->set_text(tooltip);
|
||||
}
|
||||
|
||||
void HeadsUpDisplay::set_health_percentage(double health_percentage) {
|
||||
this->healthbar->set_value(health_percentage);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/gui/label.h"
|
||||
#include "scene/gui/progress_bar.h"
|
||||
|
||||
class HeadsUpDisplay : public Control {
|
||||
GDCLASS(HeadsUpDisplay, Control);
|
||||
|
@ -18,12 +17,12 @@ protected:
|
|||
|
||||
public:
|
||||
static HeadsUpDisplay *get_singleton();
|
||||
void set_reticle_visibility(bool visible);
|
||||
void set_tooltip(String const &tooltip);
|
||||
void set_health_percentage(double health_percentage);
|
||||
|
||||
private:
|
||||
Control *reticle{ nullptr };
|
||||
Label *tooltip{ nullptr };
|
||||
ProgressBar *healthbar{ nullptr };
|
||||
};
|
||||
|
||||
#endif // !HEADS_UP_DISPLAY_H
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "rifle.h"
|
||||
#include "scene/animation/animation_player.h"
|
||||
#include "wave_survival/heads_up_display.h"
|
||||
#include "wave_survival/hitscan_muzzle.h"
|
||||
#include "wave_survival/macros.h"
|
||||
#include "wave_survival/player_body.h"
|
||||
|
@ -87,9 +88,14 @@ void Rifle::on_animation_changed(String new_animation) {
|
|||
if (new_animation == "aim") {
|
||||
this->in_alt_mode = true;
|
||||
this->fov = this->ads_factor;
|
||||
HeadsUpDisplay::get_singleton()->set_reticle_visibility(false);
|
||||
} else if (new_animation == "hip") {
|
||||
this->in_alt_mode = false;
|
||||
this->fov = 1.0;
|
||||
HeadsUpDisplay::get_singleton()->set_reticle_visibility(true);
|
||||
}
|
||||
if (new_animation == "reload") {
|
||||
HeadsUpDisplay::get_singleton()->set_reticle_visibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,6 +182,9 @@ void Rifle::notify_deselected() {
|
|||
get_input()->disconnect(PlayerInput::sig_alt_mode, callable_mp(this, &self_type::on_alt_mode));
|
||||
get_input()->disconnect(PlayerInput::sig_reload, callable_mp(this, &self_type::on_reload));
|
||||
this->running = false;
|
||||
if (HeadsUpDisplay * hud{ HeadsUpDisplay::get_singleton() }) {
|
||||
hud->set_reticle_visibility(true);
|
||||
}
|
||||
this->in_alt_mode = false;
|
||||
this->fov = 1.f;
|
||||
}
|
||||
|
|
|
@ -1,28 +1,4 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dqo1pfy3r00ai"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_sbqmm"]
|
||||
content_margin_left = 2.0
|
||||
content_margin_top = 2.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_bottom = 2.0
|
||||
bg_color = Color(0.43, 0.43, 0.43, 1)
|
||||
corner_radius_top_left = 6
|
||||
corner_radius_top_right = 6
|
||||
corner_radius_bottom_right = 6
|
||||
corner_radius_bottom_left = 6
|
||||
corner_detail = 6
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hsy36"]
|
||||
content_margin_left = 2.0
|
||||
content_margin_top = 2.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_bottom = 2.0
|
||||
bg_color = Color(0.45, 0.198, 0.198, 1)
|
||||
corner_radius_top_left = 6
|
||||
corner_radius_top_right = 6
|
||||
corner_radius_bottom_right = 6
|
||||
corner_radius_bottom_left = 6
|
||||
corner_detail = 6
|
||||
[gd_scene format=3 uid="uid://dqo1pfy3r00ai"]
|
||||
|
||||
[node name="HeadsUpDisplay" type="HeadsUpDisplay"]
|
||||
anchors_preset = 15
|
||||
|
@ -56,19 +32,3 @@ offset_bottom = 44.0
|
|||
grow_horizontal = 2
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 2
|
||||
|
||||
[node name="Healthbar" type="ProgressBar" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -37.0
|
||||
offset_right = 280.0
|
||||
grow_vertical = 0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_sbqmm")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_hsy36")
|
||||
max_value = 1.0
|
||||
value = 1.0
|
||||
rounded = true
|
||||
show_percentage = false
|
||||
|
|
|
@ -137,6 +137,10 @@ size = Vector3(5.24, 4.325, 8.29)
|
|||
collision_layer = 0
|
||||
collision_mask = 12
|
||||
|
||||
[node name="RegionShape" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.013977, 8.283193, 2.03331)
|
||||
shape = SubResource("BoxShape3D_plog7")
|
||||
|
||||
[node name="EnemySpawner" type="EnemySpawner" parent="." node_paths=PackedStringArray("patrol_path")]
|
||||
patrol_path = NodePath("../PatrolPath4")
|
||||
transform = Transform3D(0.79057205, 0, 0.6123691, 0, 1, 0, -0.6123691, 0, 0.79057205, -12.619162, 0.0069880486, -38.1304)
|
||||
|
@ -155,63 +159,47 @@ transform = Transform3D(0.5298895, 0, 0.8480667, 0, 1, 0, -0.8480667, 0, 0.52988
|
|||
|
||||
[node name="PatrolPath" type="PatrolPath" parent="."]
|
||||
|
||||
[node name="Marker3D" type="Marker3D" parent="PatrolPath"]
|
||||
[node name="Node3D2" type="Node3D" parent="PatrolPath"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.827816, 0.0069885254, 10.865434)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="Marker3D2" type="Marker3D" parent="PatrolPath"]
|
||||
[node name="Node3D" type="Node3D" parent="PatrolPath"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.7229576, 0.0069904327, -37.2033)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="PatrolPath2" type="PatrolPath" parent="."]
|
||||
|
||||
[node name="Marker3D2" type="Marker3D" parent="PatrolPath2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.927498, 0.00699234, 25.454576)
|
||||
gizmo_extents = 1.0
|
||||
[node name="Node3D" type="Node3D" parent="PatrolPath2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -17.893959, 0.00699234, 26.294456)
|
||||
|
||||
[node name="Marker3D3" type="Marker3D" parent="PatrolPath2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.9936185, 0.0069847107, 36.142963)
|
||||
gizmo_extents = 1.0
|
||||
[node name="Node3D2" type="Node3D" parent="PatrolPath2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.7306204, 0.0069847107, 34.39205)
|
||||
|
||||
[node name="Marker3D4" type="Marker3D" parent="PatrolPath2"]
|
||||
[node name="Node3D3" type="Node3D" parent="PatrolPath2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.565522, 0.0069885254, 30.594238)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="Marker3D5" type="Marker3D" parent="PatrolPath2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -15.675129, 0.0069847107, 19.280876)
|
||||
gizmo_extents = 1.0
|
||||
[node name="Node3D4" type="Node3D" parent="PatrolPath2"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -15.77895, 0.0069847107, 18.390038)
|
||||
|
||||
[node name="PatrolPath3" type="PatrolPath" parent="."]
|
||||
|
||||
[node name="Marker3D2" type="Marker3D" parent="PatrolPath3"]
|
||||
[node name="Node3D" type="Node3D" parent="PatrolPath3"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10.196421, 0.0069885254, -10.055055)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="Marker3D3" type="Marker3D" parent="PatrolPath3"]
|
||||
[node name="Node3D2" type="Node3D" parent="PatrolPath3"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 19.02306, 0.0069885254, 32.04124)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="Marker3D4" type="Marker3D" parent="PatrolPath3"]
|
||||
[node name="Node3D3" type="Node3D" parent="PatrolPath3"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.4872932, 0.0069885254, 18.856342)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="PatrolPath4" type="PatrolPath" parent="."]
|
||||
|
||||
[node name="Marker3D2" type="Marker3D" parent="PatrolPath4"]
|
||||
[node name="Node3D" type="Node3D" parent="PatrolPath4"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.4771805, 0.0069885254, -35.369995)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="Marker3D3" type="Marker3D" parent="PatrolPath4"]
|
||||
[node name="Node3D2" type="Node3D" parent="PatrolPath4"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.5512285, 0.00699234, -9.606326)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="Marker3D4" type="Marker3D" parent="PatrolPath4"]
|
||||
[node name="Node3D3" type="Node3D" parent="PatrolPath4"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -17.570858, 0.006986618, -21.56891)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="RegionShape" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.013977, 8.283193, 2.03331)
|
||||
shape = SubResource("BoxShape3D_plog7")
|
||||
|
||||
[node name="WeaponPickup" parent="." instance=ExtResource("13_qwrat")]
|
||||
transform = Transform3D(0.1816346, 0, 0.98336625, 0, 1, 0, -0.98336625, 0, 0.1816346, -13.889109, 0.05698805, -23.451344)
|
||||
|
|
Loading…
Reference in a new issue