new version
This commit is contained in:
parent
b534d5fbde
commit
e061a1405a
File diff suppressed because it is too large
Load Diff
|
|
@ -6,7 +6,6 @@ use platformer::GameConstructor;
|
||||||
fn main() {
|
fn main() {
|
||||||
let event_loop = EventLoop::new().unwrap();
|
let event_loop = EventLoop::new().unwrap();
|
||||||
let mut editor = Editor::new(
|
let mut editor = Editor::new(
|
||||||
&event_loop,
|
|
||||||
Some(StartupData {
|
Some(StartupData {
|
||||||
working_directory: Default::default(),
|
working_directory: Default::default(),
|
||||||
scenes: vec!["data/scene.rgs".into()],
|
scenes: vec!["data/scene.rgs".into()],
|
||||||
|
|
|
||||||
|
|
@ -187,29 +187,19 @@ impl Enemy {
|
||||||
if !self.fight {
|
if !self.fight {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let index = ctx
|
let player_script = ctx
|
||||||
.scene
|
.scene
|
||||||
.graph
|
.graph
|
||||||
.try_get_script_index_of::<Player>(self.player_handle)
|
.try_get_script_of_mut::<Player>(self.player_handle)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
match ctx
|
if player_script.get_health() <= 0.0 {
|
||||||
.scene
|
|
||||||
.graph
|
|
||||||
.try_get_mut(self.player_handle)
|
|
||||||
.and_then(|node| node.try_get_script_mut::<Player>(index))
|
|
||||||
{
|
|
||||||
Some(script) => {
|
|
||||||
if script.get_health() <= 0.0 {
|
|
||||||
self.fight = false;
|
self.fight = false;
|
||||||
self.block = false;
|
self.block = false;
|
||||||
self.win = true;
|
self.win = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.block = false;
|
self.block = false;
|
||||||
script.take_damage(&self.attack_damage);
|
player_script.take_damage(&self.attack_damage);
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_player_position(&self, context: &mut ScriptContext) -> Vector3<f32> {
|
fn get_player_position(&self, context: &mut ScriptContext) -> Vector3<f32> {
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ impl EnemySpawn {
|
||||||
.with_name(format!("Sceleton ({x}, {y})",))
|
.with_name(format!("Sceleton ({x}, {y})",))
|
||||||
// Set position of tile
|
// Set position of tile
|
||||||
.with_local_transform(rb_transform)
|
.with_local_transform(rb_transform)
|
||||||
.with_script(Script::new(enemy)),
|
.with_script(enemy),
|
||||||
)
|
)
|
||||||
.with_mass(20.0)
|
.with_mass(20.0)
|
||||||
// Turn off gravity for tile
|
// Turn off gravity for tile
|
||||||
|
|
|
||||||
|
|
@ -363,23 +363,12 @@ impl Player {
|
||||||
parent = Some(d.parent());
|
parent = Some(d.parent());
|
||||||
}
|
}
|
||||||
if let Some(d) = parent {
|
if let Some(d) = parent {
|
||||||
let index = context
|
let enemy_script = context
|
||||||
.scene
|
.scene
|
||||||
.graph
|
.graph
|
||||||
.try_get_script_index_of::<Enemy>(d)
|
.try_get_script_of_mut::<Enemy>(d)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
match context
|
enemy_script.take_damage(&self.damage);
|
||||||
.scene
|
|
||||||
.graph
|
|
||||||
.try_get_mut(d)
|
|
||||||
.and_then(|node| node.try_get_script_mut::<Enemy>(index))
|
|
||||||
{
|
|
||||||
Some(script) => {
|
|
||||||
script.take_damage(&self.damage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
873
settings.ron
873
settings.ron
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue