fix some bugs
This commit is contained in:
parent
26991b0d90
commit
dd3549216b
|
|
@ -2,10 +2,6 @@ use fyrox::{
|
||||||
core::{
|
core::{
|
||||||
algebra::{Point2, Vector2, Vector3}, impl_component_provider, pool::Handle, reflect::prelude::*, uuid_provider, visitor::prelude::*
|
algebra::{Point2, Vector2, Vector3}, impl_component_provider, pool::Handle, reflect::prelude::*, uuid_provider, visitor::prelude::*
|
||||||
},
|
},
|
||||||
gui::{
|
|
||||||
message::MessageDirection,
|
|
||||||
widget::WidgetMessage,
|
|
||||||
},
|
|
||||||
scene::{
|
scene::{
|
||||||
animation::spritesheet::SpriteSheetAnimation,
|
animation::spritesheet::SpriteSheetAnimation,
|
||||||
collider::{BitMask, InteractionGroups},
|
collider::{BitMask, InteractionGroups},
|
||||||
|
|
@ -78,6 +74,9 @@ impl Enemy {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_damage(&mut self, _damage: &f32) {
|
pub fn take_damage(&mut self, _damage: &f32) {
|
||||||
|
if self.dead {
|
||||||
|
return;
|
||||||
|
}
|
||||||
self.block = true;
|
self.block = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,11 +188,6 @@ impl Enemy {
|
||||||
self.fight = false;
|
self.fight = false;
|
||||||
self.block = false;
|
self.block = false;
|
||||||
self.win = true;
|
self.win = true;
|
||||||
ctx.user_interface.send_message(WidgetMessage::visibility(
|
|
||||||
ctx.user_interface.root(),
|
|
||||||
MessageDirection::ToWidget,
|
|
||||||
true,
|
|
||||||
));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.block = false;
|
self.block = false;
|
||||||
|
|
@ -305,7 +299,7 @@ impl Enemy {
|
||||||
}
|
}
|
||||||
let enemy_rigid_body = context.scene.graph[context.handle].cast_mut::<RigidBody>();
|
let enemy_rigid_body = context.scene.graph[context.handle].cast_mut::<RigidBody>();
|
||||||
if let Some(enemy_rigid_data) = enemy_rigid_body {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,13 @@ impl Plugin for Game {
|
||||||
_data: &[u8],
|
_data: &[u8],
|
||||||
context: &mut PluginContext,
|
context: &mut PluginContext,
|
||||||
) {
|
) {
|
||||||
|
context
|
||||||
|
.user_interface
|
||||||
|
.send_message(WidgetMessage::visibility(
|
||||||
|
context.user_interface.root(),
|
||||||
|
MessageDirection::ToWidget,
|
||||||
|
false,
|
||||||
|
));
|
||||||
self.scene = scene;
|
self.scene = scene;
|
||||||
|
|
||||||
let graph: &mut Graph = &mut context.scenes[self.scene].graph;
|
let graph: &mut Graph = &mut context.scenes[self.scene].graph;
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
fn build_tree_block(resource_manager: &ResourceManager, graph: &mut Graph, x: f32, y: f32) {
|
||||||
let tree_shape = ColliderShape::Cuboid(CuboidShape {
|
let tree_shape = ColliderShape::Cuboid(CuboidShape {
|
||||||
half_extents: Vector2::new(0.5, 0.5),
|
half_extents: Vector2::new(0.5, 1.5),
|
||||||
});
|
});
|
||||||
|
|
||||||
build_block(
|
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) {
|
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_center_block(resource_manager, graph, x, y);
|
||||||
build_right_block(resource_manager, graph, x - 1.0, y);
|
build_right_block(resource_manager, graph, x - 1.0, y);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ use fyrox::{
|
||||||
visitor::prelude::*,
|
visitor::prelude::*,
|
||||||
},
|
},
|
||||||
event::{ElementState, Event, TouchPhase, WindowEvent},
|
event::{ElementState, Event, TouchPhase, WindowEvent},
|
||||||
|
gui::{message::MessageDirection, widget::WidgetMessage},
|
||||||
keyboard::{KeyCode, PhysicalKey},
|
keyboard::{KeyCode, PhysicalKey},
|
||||||
scene::{
|
scene::{
|
||||||
animation::spritesheet::SpriteSheetAnimation,
|
animation::spritesheet::SpriteSheetAnimation,
|
||||||
|
|
@ -82,6 +83,7 @@ impl Player {
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
self.health_bar(context);
|
self.health_bar(context);
|
||||||
|
self.health = 100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn health_bar(&mut self, context: &mut ScriptContext) {
|
fn health_bar(&mut self, context: &mut ScriptContext) {
|
||||||
|
|
@ -422,6 +424,15 @@ impl Player {
|
||||||
health_bar_scale.z,
|
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) {
|
pub fn animation_do(&mut self, context: &mut ScriptContext) {
|
||||||
|
|
|
||||||
996
settings.ron
996
settings.ron
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue