archer
This commit is contained in:
parent
c9b33d3557
commit
82831eaa20
|
|
@ -1607,68 +1607,68 @@ function __wbg_get_imports() {
|
||||||
const ret = wasm.memory;
|
const ret = wasm.memory;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper5074 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper5083 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 5134, __wbg_adapter_32);
|
const ret = makeMutClosure(arg0, arg1, 5140, __wbg_adapter_32);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper5075 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper5084 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 5134, __wbg_adapter_32);
|
const ret = makeMutClosure(arg0, arg1, 5140, __wbg_adapter_32);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper5076 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper5085 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 5134, __wbg_adapter_32);
|
const ret = makeMutClosure(arg0, arg1, 5140, __wbg_adapter_32);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper5077 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper5086 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 5134, __wbg_adapter_32);
|
const ret = makeMutClosure(arg0, arg1, 5140, __wbg_adapter_32);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper5078 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper5087 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 5134, __wbg_adapter_41);
|
const ret = makeMutClosure(arg0, arg1, 5140, __wbg_adapter_41);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper5079 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper5088 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 5134, __wbg_adapter_44);
|
const ret = makeMutClosure(arg0, arg1, 5140, __wbg_adapter_44);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper5080 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper5089 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 5134, __wbg_adapter_32);
|
const ret = makeMutClosure(arg0, arg1, 5140, __wbg_adapter_32);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper41460 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper41469 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 36198, __wbg_adapter_49);
|
const ret = makeMutClosure(arg0, arg1, 36204, __wbg_adapter_49);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper42715 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper42724 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 36817, __wbg_adapter_52);
|
const ret = makeMutClosure(arg0, arg1, 36823, __wbg_adapter_52);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper42716 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper42725 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 36817, __wbg_adapter_55);
|
const ret = makeMutClosure(arg0, arg1, 36823, __wbg_adapter_55);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper42717 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper42726 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 36817, __wbg_adapter_55);
|
const ret = makeMutClosure(arg0, arg1, 36823, __wbg_adapter_55);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper42718 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper42727 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 36817, __wbg_adapter_55);
|
const ret = makeMutClosure(arg0, arg1, 36823, __wbg_adapter_55);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper42719 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper42728 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 36817, __wbg_adapter_55);
|
const ret = makeMutClosure(arg0, arg1, 36823, __wbg_adapter_55);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper42720 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper42729 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 36817, __wbg_adapter_55);
|
const ret = makeMutClosure(arg0, arg1, 36823, __wbg_adapter_55);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper42721 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper42730 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 36817, __wbg_adapter_55);
|
const ret = makeMutClosure(arg0, arg1, 36823, __wbg_adapter_55);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper45016 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper45025 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 37310, __wbg_adapter_68);
|
const ret = makeMutClosure(arg0, arg1, 37316, __wbg_adapter_68);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::Game;
|
||||||
use crate::Player;
|
use crate::Player;
|
||||||
use fyrox::graph::SceneGraph;
|
use fyrox::graph::SceneGraph;
|
||||||
use fyrox::{
|
use fyrox::{
|
||||||
|
|
@ -22,7 +23,6 @@ use fyrox::{
|
||||||
},
|
},
|
||||||
script::{ScriptContext, ScriptTrait},
|
script::{ScriptContext, ScriptTrait},
|
||||||
};
|
};
|
||||||
use crate::Game;
|
|
||||||
|
|
||||||
impl_component_provider!(Archer,);
|
impl_component_provider!(Archer,);
|
||||||
uuid_provider!(Archer = "a5671d19-9f1a-4286-8486-add4ebaadaec");
|
uuid_provider!(Archer = "a5671d19-9f1a-4286-8486-add4ebaadaec");
|
||||||
|
|
@ -32,9 +32,9 @@ enum Animations {
|
||||||
#[default]
|
#[default]
|
||||||
Idle = 0,
|
Idle = 0,
|
||||||
Run = 1,
|
Run = 1,
|
||||||
Fight = 2,
|
Shot = 2,
|
||||||
Dead = 3,
|
Dead = 3,
|
||||||
Block = 4,
|
Fight = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
const DISTANCE_TO_FIGHT: f32 = 5.0;
|
const DISTANCE_TO_FIGHT: f32 = 5.0;
|
||||||
|
|
@ -44,6 +44,8 @@ const END_MAP_RIGHT: f32 = 30.0;
|
||||||
const SPEED: f32 = 2.1;
|
const SPEED: f32 = 2.1;
|
||||||
const DAMAGE: f32 = 20.0;
|
const DAMAGE: f32 = 20.0;
|
||||||
const ATTACK_SPEED: f32 = 1.0;
|
const ATTACK_SPEED: f32 = 1.0;
|
||||||
|
const SUPER_DAMAGE: f32 = 30.0;
|
||||||
|
const SUPER_ATTACK_SPEED: f32 = 0.3;
|
||||||
|
|
||||||
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
||||||
pub struct Archer {
|
pub struct Archer {
|
||||||
|
|
@ -52,10 +54,10 @@ pub struct Archer {
|
||||||
move_right: bool,
|
move_right: bool,
|
||||||
jump: bool,
|
jump: bool,
|
||||||
pub animations: Vec<SpriteSheetAnimation>,
|
pub animations: Vec<SpriteSheetAnimation>,
|
||||||
fight: bool,
|
shot: bool,
|
||||||
win: bool,
|
win: bool,
|
||||||
dead: bool,
|
dead: bool,
|
||||||
block: bool,
|
fight: bool,
|
||||||
|
|
||||||
#[reflect(hidden)]
|
#[reflect(hidden)]
|
||||||
#[visit(skip)]
|
#[visit(skip)]
|
||||||
|
|
@ -81,6 +83,13 @@ impl Archer {
|
||||||
return a.round() as i32;
|
return a.round() as i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn take_damage(&mut self, _damage: &f32) {
|
||||||
|
if self.dead {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.fight = true;
|
||||||
|
}
|
||||||
|
|
||||||
fn intersections_box(&self, graph: &mut Graph) -> bool {
|
fn intersections_box(&self, graph: &mut Graph) -> bool {
|
||||||
if self.dead {
|
if self.dead {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -176,11 +185,11 @@ impl Archer {
|
||||||
return Some(buffer);
|
return Some(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn attack_player(&mut self, ctx: &mut ScriptContext) {
|
fn attack_player(&mut self, ctx: &mut ScriptContext, damage: f32) {
|
||||||
if self.win {
|
if self.win {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if !self.fight {
|
if !self.shot {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let player_script = ctx
|
let player_script = ctx
|
||||||
|
|
@ -189,13 +198,13 @@ impl Archer {
|
||||||
.try_get_script_of_mut::<Player>(self.player_handle)
|
.try_get_script_of_mut::<Player>(self.player_handle)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if player_script.get_health() <= 0.0 {
|
if player_script.get_health() <= 0.0 {
|
||||||
|
self.shot = false;
|
||||||
self.fight = false;
|
self.fight = false;
|
||||||
self.block = false;
|
|
||||||
self.win = true;
|
self.win = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.block = false;
|
self.fight = false;
|
||||||
player_script.take_damage(&self.attack_damage);
|
player_script.take_damage(&damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_player_position(&self, context: &mut ScriptContext) -> Vector3<f32> {
|
fn get_player_position(&self, context: &mut ScriptContext) -> Vector3<f32> {
|
||||||
|
|
@ -333,7 +342,7 @@ impl Archer {
|
||||||
fn move_do(&mut self, context: &mut ScriptContext) {
|
fn move_do(&mut self, context: &mut ScriptContext) {
|
||||||
let x_speed = self.get_speed(context);
|
let x_speed = self.get_speed(context);
|
||||||
if x_speed > 0.0 {
|
if x_speed > 0.0 {
|
||||||
self.block = false;
|
self.fight = false;
|
||||||
}
|
}
|
||||||
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 {
|
||||||
|
|
@ -346,8 +355,8 @@ impl Archer {
|
||||||
if self.win {
|
if self.win {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if self.block {
|
if self.fight {
|
||||||
self.current_animation = Animations::Block;
|
self.current_animation = Animations::Fight;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if self.dead {
|
if self.dead {
|
||||||
|
|
@ -358,8 +367,8 @@ impl Archer {
|
||||||
self.current_animation = Animations::Run;
|
self.current_animation = Animations::Run;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if self.fight {
|
if self.shot {
|
||||||
self.current_animation = Animations::Fight;
|
self.current_animation = Animations::Shot;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -371,18 +380,21 @@ impl Archer {
|
||||||
if self.dead {
|
if self.dead {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if self.block {
|
let mut damage = self.attack_damage;
|
||||||
return;
|
let mut speed = self.attack_speed;
|
||||||
|
if self.fight {
|
||||||
|
damage = SUPER_DAMAGE;
|
||||||
|
speed = SUPER_ATTACK_SPEED;
|
||||||
}
|
}
|
||||||
let distance = self.distance_to_player(context);
|
let distance = self.distance_to_player(context);
|
||||||
self.fight = distance < DISTANCE_TO_FIGHT && distance > -1.0 * DISTANCE_TO_FIGHT;
|
self.shot = distance < DISTANCE_TO_FIGHT && distance > -1.0 * DISTANCE_TO_FIGHT;
|
||||||
if !self.fight {
|
if !self.shot {
|
||||||
self.attack_timer = 0.0;
|
self.attack_timer = 0.0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.attack_timer += context.dt;
|
self.attack_timer += context.dt;
|
||||||
if self.attack_timer >= self.attack_speed {
|
if self.attack_timer >= speed {
|
||||||
self.attack_player(context);
|
self.attack_player(context, damage);
|
||||||
self.attack_timer = 0.0;
|
self.attack_timer = 0.0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ use fyrox::{
|
||||||
};
|
};
|
||||||
|
|
||||||
impl_component_provider!(ArcherSpawn,);
|
impl_component_provider!(ArcherSpawn,);
|
||||||
uuid_provider!(ArcherSpawn = "b5671d19-9f1a-4286-8486-add4ebaadaec");
|
uuid_provider!(ArcherSpawn = "c5671d19-9f1a-4286-8486-add4ebaadaec");
|
||||||
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
#[derive(Visit, Reflect, Debug, Clone, Default)]
|
||||||
pub struct ArcherSpawn {
|
pub struct ArcherSpawn {
|
||||||
x: f32,
|
x: f32,
|
||||||
|
|
@ -42,27 +42,27 @@ impl ArcherSpawn {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn block_anmation(&self, resource_manager: &ResourceManager) -> SpriteSheetAnimation<fyrox::asset::Resource<Texture>> {
|
fn fight_anmation(&self, resource_manager: &ResourceManager) -> SpriteSheetAnimation<fyrox::asset::Resource<Texture>> {
|
||||||
let idle = resource_manager.request::<Texture>(
|
let idle = resource_manager.request::<Texture>(
|
||||||
"assets/data/characters/skeleton/Skeleton_Archer/Evasion.png".to_owned(),
|
"assets/data/characters/skeleton/Skeleton_Archer/Attack_3.png".to_owned(),
|
||||||
);
|
);
|
||||||
let mut idle_animation = SpriteSheetAnimation::new_from_image_parameters(ImageParameters {
|
let mut idle_animation = SpriteSheetAnimation::new_from_image_parameters(ImageParameters {
|
||||||
width: 768,
|
width: 384,
|
||||||
height: 128,
|
height: 128,
|
||||||
frame_width: 128,
|
frame_width: 128,
|
||||||
frame_height: 128,
|
frame_height: 128,
|
||||||
first_frame: 0,
|
first_frame: 0,
|
||||||
last_frame: 1,
|
last_frame: 3,
|
||||||
column_major: false,
|
column_major: false,
|
||||||
});
|
});
|
||||||
idle_animation.set_texture(Some(idle));
|
idle_animation.set_texture(Some(idle));
|
||||||
idle_animation.set_looping(false);
|
idle_animation.set_looping(true);
|
||||||
idle_animation.set_speed(20.);
|
idle_animation.set_speed(5.);
|
||||||
idle_animation.play();
|
idle_animation.play();
|
||||||
return idle_animation;
|
return idle_animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn attack_anmation(&self, resource_manager: &ResourceManager) -> SpriteSheetAnimation<fyrox::asset::Resource<Texture>> {
|
fn shot_anmation(&self, resource_manager: &ResourceManager) -> SpriteSheetAnimation<fyrox::asset::Resource<Texture>> {
|
||||||
let idle = resource_manager.request::<Texture>(
|
let idle = resource_manager.request::<Texture>(
|
||||||
"assets/data/characters/skeleton/Skeleton_Archer/Shot_1.png".to_owned(),
|
"assets/data/characters/skeleton/Skeleton_Archer/Shot_1.png".to_owned(),
|
||||||
);
|
);
|
||||||
|
|
@ -153,9 +153,9 @@ impl ArcherSpawn {
|
||||||
enemy.animations = vec![
|
enemy.animations = vec![
|
||||||
self.idle_anmation(resource_manager),
|
self.idle_anmation(resource_manager),
|
||||||
self.run_anmation(resource_manager),
|
self.run_anmation(resource_manager),
|
||||||
self.attack_anmation(resource_manager),
|
self.shot_anmation(resource_manager),
|
||||||
self.die_anmation(resource_manager),
|
self.die_anmation(resource_manager),
|
||||||
self.block_anmation(resource_manager),
|
self.fight_anmation(resource_manager),
|
||||||
];
|
];
|
||||||
material
|
material
|
||||||
.set_property(
|
.set_property(
|
||||||
|
|
|
||||||
|
|
@ -219,11 +219,7 @@ impl Plugin for Game {
|
||||||
SwordmanSpawn::new().spawn_enemy(graph, resource_manager, -5.0);
|
SwordmanSpawn::new().spawn_enemy(graph, resource_manager, -5.0);
|
||||||
}
|
}
|
||||||
if self.level == 2 {
|
if self.level == 2 {
|
||||||
ArcherSpawn::new().spawn_enemy(graph, resource_manager, -5.0);
|
ArcherSpawn::new().spawn_enemy(graph, resource_manager, -25.0);
|
||||||
}
|
|
||||||
if self.level == 3 {
|
|
||||||
SwordmanSpawn::new().spawn_enemy(graph, resource_manager, -5.0);
|
|
||||||
ArcherSpawn::new().spawn_enemy(graph, resource_manager, 15.0);
|
|
||||||
}
|
}
|
||||||
let ui_ctx = &mut context.user_interface.build_ctx();
|
let ui_ctx = &mut context.user_interface.build_ctx();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,23 @@
|
||||||
use fyrox::{
|
use fyrox::{
|
||||||
asset::manager::ResourceManager,
|
asset::manager::ResourceManager,
|
||||||
core::{algebra::{Vector2, Vector3}, math::Rect, sstorage::ImmutableString},
|
core::{
|
||||||
|
algebra::{Vector2, Vector3},
|
||||||
|
math::Rect,
|
||||||
|
sstorage::ImmutableString,
|
||||||
|
},
|
||||||
material::{shader::SamplerFallback, Material, MaterialResource, PropertyValue},
|
material::{shader::SamplerFallback, Material, MaterialResource, PropertyValue},
|
||||||
resource::texture::Texture,
|
resource::texture::Texture,
|
||||||
scene::{
|
scene::{
|
||||||
base::BaseBuilder, collider::InteractionGroups, dim2::{
|
base::BaseBuilder,
|
||||||
|
collider::InteractionGroups,
|
||||||
|
dim2::{
|
||||||
collider::{ColliderBuilder, ColliderShape, CuboidShape},
|
collider::{ColliderBuilder, ColliderShape, CuboidShape},
|
||||||
rectangle::RectangleBuilder,
|
rectangle::RectangleBuilder,
|
||||||
rigidbody::RigidBodyBuilder,
|
rigidbody::RigidBodyBuilder,
|
||||||
}, graph::Graph, rigidbody::RigidBodyType, transform::TransformBuilder
|
},
|
||||||
|
graph::Graph,
|
||||||
|
rigidbody::RigidBodyType,
|
||||||
|
transform::TransformBuilder,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// /mnt/23154027-2dd3-43ea-93f1-02a8df7a3c5a/projects/fyrox/platformer/assets/data/tiles/
|
// /mnt/23154027-2dd3-43ea-93f1-02a8df7a3c5a/projects/fyrox/platformer/assets/data/tiles/
|
||||||
|
|
@ -184,10 +193,7 @@ fn build_stone_block(resource_manager: &ResourceManager, graph: &mut Graph, x: f
|
||||||
x as f32,
|
x as f32,
|
||||||
y + 0.7,
|
y + 0.7,
|
||||||
1.0,
|
1.0,
|
||||||
build_material(
|
build_material(resource_manager, "assets/data/objects/Stone.png".to_owned()),
|
||||||
resource_manager,
|
|
||||||
"assets/data/objects/Stone.png".to_owned(),
|
|
||||||
),
|
|
||||||
shape,
|
shape,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -238,20 +244,19 @@ pub fn build_map(graph: &mut Graph, resource_manager: &ResourceManager, level: u
|
||||||
build_stone_block(resource_manager, graph, 30.0, bottom_y);
|
build_stone_block(resource_manager, graph, 30.0, bottom_y);
|
||||||
build_tree_block(resource_manager, graph, 35.0, bottom_y);
|
build_tree_block(resource_manager, graph, 35.0, bottom_y);
|
||||||
build_stone_block(resource_manager, graph, -30.0, bottom_y);
|
build_stone_block(resource_manager, graph, -30.0, bottom_y);
|
||||||
|
if level != 3 {
|
||||||
build_tree_block(resource_manager, graph, -35.0, bottom_y);
|
build_tree_block(resource_manager, graph, -35.0, bottom_y);
|
||||||
|
}
|
||||||
build_box_block(resource_manager, graph, 10.0, bottom_y);
|
build_box_block(resource_manager, graph, 10.0, bottom_y);
|
||||||
|
|
||||||
build_air_island_block(resource_manager, graph, 15.0, bottom_y + 2.5);
|
build_air_island_block(resource_manager, graph, 15.0, bottom_y + 2.5);
|
||||||
build_air_island_block(resource_manager, graph, 18.0, bottom_y + 4.0);
|
build_air_island_block(resource_manager, graph, 18.0, bottom_y + 4.0);
|
||||||
build_air_island_block(resource_manager, graph, 21.0, bottom_y + 5.5);
|
build_air_island_block(resource_manager, graph, 21.0, bottom_y + 5.5);
|
||||||
if level != 2 {
|
if level != 2 {
|
||||||
build_box_block(resource_manager, graph, 21.0, bottom_y+ 5.5);
|
build_box_block(resource_manager, graph, 21.0, bottom_y + 5.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
build_air_island_block(resource_manager, graph, -15.0, bottom_y + 2.5);
|
build_air_island_block(resource_manager, graph, -15.0, bottom_y + 2.5);
|
||||||
build_air_island_block(resource_manager, graph, -18.0, bottom_y + 4.0);
|
build_air_island_block(resource_manager, graph, -18.0, bottom_y + 4.0);
|
||||||
build_air_island_block(resource_manager, graph, -21.0, bottom_y + 5.5);
|
build_air_island_block(resource_manager, graph, -21.0, bottom_y + 5.5);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
use crate::msg::Message;
|
use crate::msg::Message;
|
||||||
use crate::Swordman;
|
|
||||||
use fyrox::graph::BaseSceneGraph;
|
use fyrox::graph::BaseSceneGraph;
|
||||||
use fyrox::{
|
use fyrox::{
|
||||||
core::{
|
core::{
|
||||||
|
|
@ -31,6 +30,8 @@ use fyrox::{
|
||||||
script::{ScriptContext, ScriptMessageContext, ScriptMessagePayload, ScriptTrait},
|
script::{ScriptContext, ScriptMessageContext, ScriptMessagePayload, ScriptTrait},
|
||||||
};
|
};
|
||||||
use crate::Game;
|
use crate::Game;
|
||||||
|
use crate::Swordman;
|
||||||
|
use crate::Archer;
|
||||||
|
|
||||||
const JUMP_HEIGHT: f32 = 6.0;
|
const JUMP_HEIGHT: f32 = 6.0;
|
||||||
const SPEED: f32 = 2.9;
|
const SPEED: f32 = 2.9;
|
||||||
|
|
@ -340,7 +341,7 @@ impl Player {
|
||||||
RayCastOptions {
|
RayCastOptions {
|
||||||
ray_origin: Point2::new(self_position.x, self_position.y),
|
ray_origin: Point2::new(self_position.x, self_position.y),
|
||||||
ray_direction: Vector2::new(x.clone(), 0.0),
|
ray_direction: Vector2::new(x.clone(), 0.0),
|
||||||
max_len: 1.0,
|
max_len: 0.5,
|
||||||
groups: InteractionGroups::default(),
|
groups: InteractionGroups::default(),
|
||||||
// groups: InteractionGroups::default(),
|
// groups: InteractionGroups::default(),
|
||||||
// Sort the results by distance
|
// Sort the results by distance
|
||||||
|
|
@ -370,6 +371,13 @@ impl Player {
|
||||||
if let Some(enemy) = enemy_script {
|
if let Some(enemy) = enemy_script {
|
||||||
enemy.take_damage(&self.damage);
|
enemy.take_damage(&self.damage);
|
||||||
}
|
}
|
||||||
|
let enemy_script = context
|
||||||
|
.scene
|
||||||
|
.graph
|
||||||
|
.try_get_script_of_mut::<Archer>(d);
|
||||||
|
if let Some(enemy) = enemy_script {
|
||||||
|
enemy.take_damage(&self.damage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue