Add score for touching/whipping monsters
This commit is contained in:
parent
b2672904c8
commit
b62f2759de
3 changed files with 11 additions and 3 deletions
|
@ -70,4 +70,8 @@ impl Stats {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_score(&mut self, score: u32) {
|
||||||
|
self.score += score;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,7 @@ impl State {
|
||||||
} else {
|
} else {
|
||||||
if let Some(e) = map.get_tile_content_at(destination) {
|
if let Some(e) = map.get_tile_content_at(destination) {
|
||||||
if let Some(monster) = monsters.get(e) {
|
if let Some(monster) = monsters.get(e) {
|
||||||
|
stats.add_score(damage_for_kind(monster.kind));
|
||||||
stats.take_gems(damage_for_kind(monster.kind));
|
stats.take_gems(damage_for_kind(monster.kind));
|
||||||
sound_output.play_sound(sound_effect_for_kind(
|
sound_output.play_sound(sound_effect_for_kind(
|
||||||
monster.kind,
|
monster.kind,
|
||||||
|
|
|
@ -4,8 +4,8 @@ use bracket_lib::prelude::*;
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
components::{Monster, Position, WantsToWhip},
|
components::{monster::damage_for_kind, Monster, Position, WantsToWhip},
|
||||||
resources::{Map, SoundEffects, SoundOutput, StopClock},
|
resources::{Map, SoundEffects, SoundOutput, Stats, StopClock},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct WhipSystem {}
|
pub struct WhipSystem {}
|
||||||
|
@ -17,6 +17,7 @@ impl<'a> System<'a> for WhipSystem {
|
||||||
WriteExpect<'a, StopClock>,
|
WriteExpect<'a, StopClock>,
|
||||||
WriteExpect<'a, SoundOutput>,
|
WriteExpect<'a, SoundOutput>,
|
||||||
ReadExpect<'a, SoundEffects>,
|
ReadExpect<'a, SoundEffects>,
|
||||||
|
WriteExpect<'a, Stats>,
|
||||||
ReadStorage<'a, Position>,
|
ReadStorage<'a, Position>,
|
||||||
WriteStorage<'a, WantsToWhip>,
|
WriteStorage<'a, WantsToWhip>,
|
||||||
WriteStorage<'a, Monster>,
|
WriteStorage<'a, Monster>,
|
||||||
|
@ -29,6 +30,7 @@ impl<'a> System<'a> for WhipSystem {
|
||||||
mut stop_clock,
|
mut stop_clock,
|
||||||
mut sound_output,
|
mut sound_output,
|
||||||
sound_effects,
|
sound_effects,
|
||||||
|
mut stats,
|
||||||
positions,
|
positions,
|
||||||
mut wants_to_whips,
|
mut wants_to_whips,
|
||||||
monsters,
|
monsters,
|
||||||
|
@ -93,7 +95,8 @@ impl<'a> System<'a> for WhipSystem {
|
||||||
|
|
||||||
if let Some(dest) = destination {
|
if let Some(dest) = destination {
|
||||||
if let Some(e) = map.get_tile_content_at(dest) {
|
if let Some(e) = map.get_tile_content_at(dest) {
|
||||||
if let Some(_monster) = monsters.get(e) {
|
if let Some(monster) = monsters.get(e) {
|
||||||
|
stats.add_score(damage_for_kind(monster.kind));
|
||||||
let _ = entities.delete(e);
|
let _ = entities.delete(e);
|
||||||
map.clear_tile_content_at(dest);
|
map.clear_tile_content_at(dest);
|
||||||
if let Some(sound) = &mut wants_to_whip.sound {
|
if let Some(sound) = &mut wants_to_whip.sound {
|
||||||
|
|
Loading…
Add table
Reference in a new issue