fix some bugs

This commit is contained in:
artem 2024-02-24 22:38:22 +03:00
parent 26991b0d90
commit dd3549216b
5 changed files with 522 additions and 510 deletions

View File

@ -2,10 +2,6 @@ use fyrox::{
core::{
algebra::{Point2, Vector2, Vector3}, impl_component_provider, pool::Handle, reflect::prelude::*, uuid_provider, visitor::prelude::*
},
gui::{
message::MessageDirection,
widget::WidgetMessage,
},
scene::{
animation::spritesheet::SpriteSheetAnimation,
collider::{BitMask, InteractionGroups},
@ -78,6 +74,9 @@ impl Enemy {
}
pub fn take_damage(&mut self, _damage: &f32) {
if self.dead {
return;
}
self.block = true;
}
@ -189,11 +188,6 @@ impl Enemy {
self.fight = false;
self.block = false;
self.win = true;
ctx.user_interface.send_message(WidgetMessage::visibility(
ctx.user_interface.root(),
MessageDirection::ToWidget,
true,
));
return;
}
self.block = false;
@ -305,7 +299,7 @@ impl Enemy {
}
let enemy_rigid_body = context.scene.graph[context.handle].cast_mut::<RigidBody>();
if let Some(enemy_rigid_data) = enemy_rigid_body {
enemy_rigid_data.set_lin_vel(Vector2::new(x_speed, enemy_rigid_data.lin_vel().y));
enemy_rigid_data.set_lin_vel(Vector2::new(x_speed, -1.0));
}
}

View File

@ -135,6 +135,13 @@ impl Plugin for Game {
_data: &[u8],
context: &mut PluginContext,
) {
context
.user_interface
.send_message(WidgetMessage::visibility(
context.user_interface.root(),
MessageDirection::ToWidget,
false,
));
self.scene = scene;
let graph: &mut Graph = &mut context.scenes[self.scene].graph;

View File

@ -161,7 +161,7 @@ fn build_right_block(resource_manager: &ResourceManager, graph: &mut Graph, x: f
fn build_tree_block(resource_manager: &ResourceManager, graph: &mut Graph, x: f32, y: f32) {
let tree_shape = ColliderShape::Cuboid(CuboidShape {
half_extents: Vector2::new(0.5, 0.5),
half_extents: Vector2::new(0.5, 1.5),
});
build_block(
@ -223,7 +223,7 @@ fn build_box_block(resource_manager: &ResourceManager, graph: &mut Graph, x: f32
}
fn build_air_island_block(resource_manager: &ResourceManager, graph: &mut Graph, x: f32, y: f32) {
build_left_block(resource_manager, graph, x + 1.0, y);
build_left_block(resource_manager, graph, x + 0.5, y);
build_center_block(resource_manager, graph, x, y);
build_right_block(resource_manager, graph, x - 1.0, y);
}

View File

@ -14,6 +14,7 @@ use fyrox::{
visitor::prelude::*,
},
event::{ElementState, Event, TouchPhase, WindowEvent},
gui::{message::MessageDirection, widget::WidgetMessage},
keyboard::{KeyCode, PhysicalKey},
scene::{
animation::spritesheet::SpriteSheetAnimation,
@ -82,6 +83,7 @@ impl Player {
None => {}
}
self.health_bar(context);
self.health = 100.0;
}
fn health_bar(&mut self, context: &mut ScriptContext) {
@ -422,6 +424,15 @@ impl Player {
health_bar_scale.z,
));
}
if self.health <= 0.0 {
context
.user_interface
.send_message(WidgetMessage::visibility(
context.user_interface.root(),
MessageDirection::ToWidget,
true,
));
}
}
pub fn animation_do(&mut self, context: &mut ScriptContext) {

File diff suppressed because it is too large Load Diff