From 052a97e4415296812da6b12cbee38725773f4bed Mon Sep 17 00:00:00 2001 From: Sergei Surovtsev <97428129+stillonearth@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:39:31 -0600 Subject: [PATCH] updated --- src/cutscene.rs | 38 +++++++++---- src/entities/weapons/machete.rs | 22 ++++---- src/gameover.rs | 50 ++++++++++++++--- src/gameplay/waves.rs | 96 ++++++++++++++++++--------------- src/main.rs | 2 +- src/ui.rs | 27 +++++----- 6 files changed, 150 insertions(+), 85 deletions(-) diff --git a/src/cutscene.rs b/src/cutscene.rs index 6d0cc66..1e924e0 100644 --- a/src/cutscene.rs +++ b/src/cutscene.rs @@ -86,12 +86,14 @@ fn setup_cutscene( left: Val::Px(20.0), ..default() }, + z_index: ZIndex::Global(100), background_color: Color::WHITE.into(), ..default() }, UiImage::new(avatar_assets.alextime.clone()), Name::new("avatar alextime"), CutsceneAvatarAlextime, + // ZIndex::Local(100), )); parent.spawn(( @@ -104,6 +106,7 @@ fn setup_cutscene( ..default() }, background_color: Color::WHITE.into(), + z_index: ZIndex::Global(100), ..default() }, UiImage::new(avatar_assets.gennadiy.clone()), @@ -119,6 +122,7 @@ fn setup_cutscene( margin: UiRect::bottom(Val::Percent(10.)), ..default() }, + z_index: ZIndex::Global(101), ..default() }, Name::new("dialog text"), @@ -160,7 +164,7 @@ fn setup_cutscene( .with_children(|parent| { parent.spawn(( TextBundle::from_section( - " PRISON CPS 17\n <>\nMEXICO, BUENAVISTA", + " PRISON CPS 17\nMEXICO, BUENAVISTA", TextStyle { font: font_assets.pixeloid_mono.clone(), font_size: 40.0, @@ -261,14 +265,28 @@ fn handle_cutscene_text( fn get_cutscene_dialog_text() -> Vec<(usize, String)> { vec![ - (0, "LEGEND OF MIERDA".to_string()), - (1, "VERSION 24-4-4".to_string()), - // (0, "Privet gennadiy!.".to_string()), - // (0, "Shapka the snachala.".to_string()), - // (0, "Ya Alexey Viktorovich Makeev".to_string()), - // (0, "AlexTime".to_string()), - // (0, "Date of birth 08/22/1974".to_string()), - // (0, "Citizen of Russia".to_string()), - // (0, "CPS 17 Michoacan".to_string()), + ( + 1, + "Your Highness, they've charged you with smuggling red caviar into the mess hall." + .to_string(), + ), + ( + 0, + "Ah, Gena, they simply cannot resist my gourmet diplomacy".to_string(), + ), + ( + 1, + "Diplomacy, sire? It's more like high-seas gastronomy.".to_string(), + ), + ( + 0, + "Fear not, Gena. If they lock me up, I'll become the Cell Block Caviar Tsar!" + .to_string(), + ), + ( + 1, + "Your platform: From the Elecrostahl to the cell, promising red caviar for all!" + .to_string(), + ), ] } diff --git a/src/entities/weapons/machete.rs b/src/entities/weapons/machete.rs index 72351ab..8d98477 100644 --- a/src/entities/weapons/machete.rs +++ b/src/entities/weapons/machete.rs @@ -3,14 +3,11 @@ use std::time::Duration; use bevy::{prelude::*, sprite::MaterialMesh2dBundle}; use bevy_particle_systems::Lerpable; +use crate::GameState; +use crate::{controls::ControlEvent, entities::player::Player}; -use crate::{ - controls::ControlEvent, - entities::{ - player::Player, - }, -}; -use crate::{GameState}; +// note to self: attack happens every 1.3 seconds but there is delay +// for attack 0.3 secodns so i hinda hack this around // ---------- // Components @@ -96,8 +93,12 @@ fn animate_machete_indicator( mut materials: ResMut>, ) { for (_, mut material, timer) in q_machete.iter_mut() { - let current_value = timer.0.percent_left().max(0.2); - let percentage = timer.0.percent_left().max(0.2).lerp(0.8, current_value); + let elapsed = timer.0.elapsed_secs(); + let mut percentage = (1.0 - elapsed) / (1.0 - 0.3); + if elapsed < 0.3 { + percentage = 0.0; + } + *material = materials.add(ColorMaterial::from(Color::PURPLE.with_a(percentage))); } } @@ -106,6 +107,9 @@ fn animate_machete_indicator( // Plugin // ------ +// I--------I--------I +// x x + pub struct MachetePlugin; impl Plugin for MachetePlugin { diff --git a/src/gameover.rs b/src/gameover.rs index e4d1108..6775e80 100644 --- a/src/gameover.rs +++ b/src/gameover.rs @@ -6,15 +6,22 @@ use crate::{ui::UIGameOver, AudioAssets, ButtonColors, ChangeState, FontAssets, #[derive(Event, Clone)] pub struct GameOverEvent; +#[derive(Event, Clone)] +pub struct GameWinEvent; + #[derive(Component)] struct UIGameOverButton; +#[derive(Component)] +struct UIGameOverText; + pub fn event_game_over( mut ev_game_over: EventReader, mut q_ui_game_over: Query<(&mut Visibility, &UIGameOver)>, mut next_state: ResMut>, audio: Res