Skip to content

Commit

Permalink
Final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahShomette committed Apr 8, 2023
1 parent 387bfb9 commit ed1c70f
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 85 deletions.
Binary file removed assets/audio/Gain-Tile_3wrrrc.wav
Binary file not shown.
Binary file removed assets/audio/Gain-Tile_6downpictheddhsds.wav
Binary file not shown.
Binary file removed assets/audio/gain_tile.wav
Binary file not shown.
Binary file removed assets/audio/gain_tile_2.wav
Binary file not shown.
8 changes: 4 additions & 4 deletions src/actions/game_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ pub fn place_building(
},
},
BuildingCooldown {
timer: Timer::from_seconds(0.15, TimerMode::Once),
timer_reset: 0.15,
timer: Timer::from_seconds(0.13, TimerMode::Once),
timer_reset: 0.13,
},
BuildingMarker::default(),
),
Expand Down Expand Up @@ -202,8 +202,8 @@ pub fn place_building(
building_type: Line { strength: 8 },
},
BuildingCooldown {
timer: Timer::from_seconds(0.12, TimerMode::Once),
timer_reset: 0.12,
timer: Timer::from_seconds(0.15, TimerMode::Once),
timer_reset: 0.15,
},
BuildingMarker::default(),
),
Expand Down
10 changes: 6 additions & 4 deletions src/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use bevy_ggf::player::{Player, PlayerMarker};
use ns_defaults::camera::CursorWorldPos;

use crate::buildings::BuildingTypes;
use crate::game::{simulate_game, GameBuildSettings, GameData, BORDER_PADDING_TOTAL};
use crate::color_system::PlayerColors;
use crate::game::draw::draw_game;
use crate::game::{simulate_game, GameBuildSettings, GameData, BORDER_PADDING_TOTAL};
use crate::menu::MenuNavigation;
use crate::GameState;

Expand Down Expand Up @@ -101,6 +102,7 @@ pub fn paused_controls(
objects: Query<Entity, With<Object>>,
players: Query<Entity, With<Player>>,
player_marker: Query<Entity, With<PlayerMarker>>,
player_colors: Res<PlayerColors>,
) {
let mut term = term_query.single_mut();
let term_size = term.size();
Expand All @@ -113,15 +115,15 @@ pub fn paused_controls(
(term_size.x / 2) - (BORDER_PADDING_TOTAL / 2),
game.map_size_y + (BORDER_PADDING_TOTAL / 2) + 6,
],
"!!! PAUSED !!!".fg(Color::GREEN),
"!!! PAUSED !!!".fg(player_colors.get_color(0)),
);
let max_nav = 2;

if menu_nav.0 == 0 {
term.put_string([0, term_size.y - 3], "PLAY".fg(Color::BLUE));
term.put_string([0, term_size.y - 3], "PLAY".fg(player_colors.get_color(0)));
}
if menu_nav.0 == 1 {
term.put_string([0, term_size.y - 5], "MENU".fg(Color::BLUE));
term.put_string([0, term_size.y - 5], "MENU".fg(player_colors.get_color(0)));
}

if keyboard_input.just_pressed(KeyCode::Escape) {
Expand Down
4 changes: 2 additions & 2 deletions src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn control_gain_tile_sound(
) {
let changed_tiles = game.game_world.resource::<PlayerTileChangedCount>();
if changed_tiles.player_gained_tiles > 0 {
audio.play(audio_assets.gain_tile.clone()).with_volume(0.1);
//audio.play(audio_assets.gain_tile.clone()).with_volume(0.01);
}
}

Expand All @@ -88,7 +88,7 @@ fn control_lost_tile_sound(
) {
let changed_tiles = game.game_world.resource::<PlayerTileChangedCount>();
if changed_tiles.player_lost_tiles > 0 {
audio.play(audio_assets.lost_tile.clone()).with_volume(0.01);
//audio.play(audio_assets.lost_tile.clone()).with_volume(0.01);
}
}

Expand Down
124 changes: 102 additions & 22 deletions src/color_system.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::player::PlayerPoints;
use bevy::app::{App, Plugin};
use bevy::prelude::{
Color, Commands, Component, Entity, EventReader, EventWriter, FromReflect, Mut, Query, ResMut,
Resource, With, Without,
unwrap, Color, Commands, Component, Entity, EventReader, EventWriter, FromReflect, Mut, Query,
ResMut, Resource, With, Without,
};
use bevy::reflect::Reflect;
use bevy::utils::HashMap;
Expand All @@ -20,7 +20,7 @@ pub struct ColorSystemPlugin;

impl Plugin for ColorSystemPlugin {
fn build(&self, app: &mut App) {
todo!()
app.init_resource::<PlayerColors>();
}
}

Expand Down Expand Up @@ -574,28 +574,108 @@ impl TileColor {
}
}

pub enum PlayerColors {
Blue,
Red,
Green,
Purple,
#[derive(Clone, Resource)]
pub struct PlayerColors {
pub palette_index: usize,
pub current_palette: Palette,
pub palettes: Vec<Palette>,
}

impl Default for PlayerColors {
fn default() -> Self {
Self {
palette_index: 0,
current_palette: Palette {
player_colors: vec![
String::from("d3bf77"),
String::from("657a85"),
String::from("5e9d6a"),
String::from("45344a"),
],
noncolorable_tile: "272135".to_string(),
colorable_tile: "272135".to_string(),
},
palettes: vec![
Palette {
player_colors: vec![
String::from("d3bf77"),
String::from("657a85"),
String::from("5e9d6a"),
String::from("45344a"),
],
noncolorable_tile: "272135".to_string(),
colorable_tile: "272135".to_string(),
},
Palette {
player_colors: vec![
String::from("00177c"),
String::from("84396c"),
String::from("598344"),
String::from("d09071"),
],
noncolorable_tile: "272135".to_string(),
colorable_tile: "272135".to_string(),
},
Palette {
player_colors: vec![
String::from("425e9a"),
String::from("39a441"),
String::from("de9139"),
String::from("e6cb47"),
],
noncolorable_tile: "272135".to_string(),
colorable_tile: "272135".to_string(),
},
Palette {
player_colors: vec![
String::from("0392cf"),
String::from("ee4035"),
String::from("7bc043"),
String::from("f37736"),
],
noncolorable_tile: "272135".to_string(),
colorable_tile: "fdf498".to_string(),
},
Palette {
player_colors: vec![
String::from("fff200"),
String::from("e500ff"),
String::from("00ddff"),
String::from("000000"),
],
noncolorable_tile: "272135".to_string(),
colorable_tile: "ffffff".to_string(),
},
],
}
}
}

impl PlayerColors {
pub fn get_color(player_id: usize) -> Color {
return match player_id {
0 => Color::BLUE,
1 => Color::RED,
2 => Color::GREEN,
_ => Color::INDIGO,
};
pub fn get_color(&self, player_id: usize) -> Color {
return Color::hex(self.current_palette.player_colors[player_id].clone()).unwrap();
}
pub fn get_colors_from(&mut self) -> Color {
return match self {
PlayerColors::Blue => Color::BLUE,
PlayerColors::Red => Color::RED,
PlayerColors::Green => Color::GREEN,
PlayerColors::Purple => Color::INDIGO,
};
pub fn next_palette(&mut self) {
if self.palette_index.saturating_add(1) < self.palettes.len() {
self.palette_index = self.palette_index.saturating_add(1);
self.current_palette = self.palettes[self.palette_index].clone();
}
}
pub fn prev_palette(&mut self) {
self.palette_index = self.palette_index.saturating_sub(1);
self.current_palette = self.palettes[self.palette_index].clone();
}
pub fn get_noncolorable(&self) -> Color {
return Color::hex(self.current_palette.noncolorable_tile.clone()).unwrap();
}
pub fn get_colorable(&self) -> Color {
return Color::hex(self.current_palette.colorable_tile.clone()).unwrap();
}
}

#[derive(Clone)]
pub struct Palette {
pub player_colors: Vec<String>,
pub noncolorable_tile: String,
pub colorable_tile: String,
}
Loading

0 comments on commit ed1c70f

Please sign in to comment.