Compare commits
2 Commits
6545f54cfc
...
29a98c686c
| Author | SHA1 | Date | |
|---|---|---|---|
| 29a98c686c | |||
| b10acbeb96 |
@ -6,6 +6,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://2sfy0vq0fqt3" path="res://scenes/ui/player_listing.tscn" id="4_okac2"]
|
||||
[ext_resource type="PackedScene" uid="uid://ffh5txda3j1" path="res://scenes/ui/chat_box.tscn" id="5_cv68x"]
|
||||
[ext_resource type="Texture2D" uid="uid://bdfqu6p74pfwe" path="res://raw_assets/crosshair/Crosshair 1.png" id="6_7awel"]
|
||||
[ext_resource type="AudioStream" uid="uid://bfg31e3s4jv8c" path="res://raw_assets/sfx/Hit.mp3" id="7_dguuj"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_3nx84"]
|
||||
glow_enabled = true
|
||||
@ -179,6 +180,9 @@ text = "100"
|
||||
label_settings = SubResource("LabelSettings_7awel")
|
||||
vertical_alignment = 2
|
||||
|
||||
[node name="hit_sound" type="AudioStreamPlayer" parent="." unique_id=1224745673]
|
||||
stream = ExtResource("7_dguuj")
|
||||
|
||||
[connection signal="pressed" from="pause_menu/v_box_container/settings" to="settings" method="open"]
|
||||
[connection signal="pressed" from="pause_menu/v_box_container/exit_to_lobby" to="." method="exit_to_lobby"]
|
||||
[connection signal="pressed" from="pause_menu/v_box_container/exit" to="." method="exit"]
|
||||
|
||||
@ -878,6 +878,14 @@ impl Game {
|
||||
|
||||
// Handle for when a player is killed, run both on client and server
|
||||
pub fn on_kill(&mut self, source: DamageSource, player_id: u16) {
|
||||
if let DamageSource::Player(source_player_id) = source
|
||||
&& let Some(player) = self.find_player(source_player_id)
|
||||
&& let Some(character) = player.character.clone()
|
||||
&& let Ok(mut local_player) = character.try_cast::<LocalPlayer>()
|
||||
{
|
||||
local_player.bind_mut().play_local_hit_sound();
|
||||
}
|
||||
|
||||
let total_prev_kills: u16 = self.players.iter().map(|p| p.data.kills).sum();
|
||||
|
||||
if let Some(chat) = &mut Chat::singleton() {
|
||||
@ -897,6 +905,8 @@ impl Game {
|
||||
};
|
||||
|
||||
if let Some(player) = self.find_player_mut(player_id) {
|
||||
player.killing_spree = 0;
|
||||
player.killing_spree_cd = 0.;
|
||||
player.data.deaths += 1;
|
||||
}
|
||||
self.run_deferred(move |s| {
|
||||
|
||||
@ -2,8 +2,8 @@ use std::{f32::consts::PI, ops::Neg};
|
||||
|
||||
use godot::{
|
||||
classes::{
|
||||
Button, Camera3D, CharacterBody3D, CollisionShape3D, ICharacterBody3D, Input, InputEvent,
|
||||
InputEventMouseMotion, Label, Panel, PanelContainer, input::MouseMode,
|
||||
AudioStreamPlayer, Button, Camera3D, CharacterBody3D, CollisionShape3D, ICharacterBody3D,
|
||||
Input, InputEvent, InputEventMouseMotion, Label, Panel, PanelContainer, input::MouseMode,
|
||||
},
|
||||
obj::WithBaseField,
|
||||
prelude::*,
|
||||
@ -68,6 +68,8 @@ pub struct LocalPlayer {
|
||||
#[export]
|
||||
health_label: Option<Gd<Label>>,
|
||||
#[export]
|
||||
hit_sound: Option<Gd<AudioStreamPlayer>>,
|
||||
#[export]
|
||||
health: i32,
|
||||
|
||||
pub player_id: Option<u16>,
|
||||
@ -653,6 +655,12 @@ impl LocalPlayer {
|
||||
camera.set_fov(settings.fov as f32);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play_local_hit_sound(&mut self) {
|
||||
if let Some(hit_sound) = &mut self.hit_sound {
|
||||
hit_sound.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[godot_dyn]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user