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