refactor: improve code formatting and readability in components and resources
This commit is contained in:
parent
4727c370d2
commit
9aad8dd130
|
@ -35,16 +35,16 @@ pub struct FormationTarget {
|
||||||
// Enum defining different ways an enemy can attack
|
// Enum defining different ways an enemy can attack
|
||||||
#[derive(Component, Clone, Copy, PartialEq, Debug)]
|
#[derive(Component, Clone, Copy, PartialEq, Debug)]
|
||||||
pub enum AttackPattern {
|
pub enum AttackPattern {
|
||||||
SwoopDive, // Original pattern: dive towards center, then off screen
|
SwoopDive, // Original pattern: dive towards center, then off screen
|
||||||
DirectDive, // Dive straight down
|
DirectDive, // Dive straight down
|
||||||
Kamikaze(Vec3), // Dive towards a specific target location (e.g., player's last known position) - Needs target Vec3
|
Kamikaze(Vec3), // Dive towards a specific target location (e.g., player's last known position) - Needs target Vec3
|
||||||
// Add more patterns later (e.g., FigureEight, Looping)
|
// Add more patterns later (e.g., FigureEight, Looping)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone, PartialEq, Debug)] // Added Debug derive
|
#[derive(Component, Clone, PartialEq, Debug)] // Added Debug derive
|
||||||
pub enum EnemyState {
|
pub enum EnemyState {
|
||||||
Entering, // Flying onto the screen towards formation target
|
Entering, // Flying onto the screen towards formation target
|
||||||
InFormation, // Holding position in the formation
|
InFormation, // Holding position in the formation
|
||||||
Attacking(AttackPattern), // Diving towards the player using a specific pattern
|
Attacking(AttackPattern), // Diving towards the player using a specific pattern
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,10 @@ impl Default for FormationLayout {
|
||||||
for i in 0..crate::constants::FORMATION_ENEMY_COUNT {
|
for i in 0..crate::constants::FORMATION_ENEMY_COUNT {
|
||||||
let row = i / crate::constants::FORMATION_COLS;
|
let row = i / crate::constants::FORMATION_COLS;
|
||||||
let col = i % crate::constants::FORMATION_COLS;
|
let col = i % crate::constants::FORMATION_COLS;
|
||||||
let target_x = (col as f32 - (crate::constants::FORMATION_COLS as f32 - 1.0) / 2.0) * crate::constants::FORMATION_X_SPACING;
|
let target_x = (col as f32 - (crate::constants::FORMATION_COLS as f32 - 1.0) / 2.0)
|
||||||
let target_y = crate::constants::FORMATION_BASE_Y - (row as f32 * crate::constants::FORMATION_Y_SPACING);
|
* crate::constants::FORMATION_X_SPACING;
|
||||||
|
let target_y = crate::constants::FORMATION_BASE_Y
|
||||||
|
- (row as f32 * crate::constants::FORMATION_Y_SPACING);
|
||||||
positions.push(Vec3::new(target_x, target_y, 0.0));
|
positions.push(Vec3::new(target_x, target_y, 0.0));
|
||||||
}
|
}
|
||||||
FormationLayout {
|
FormationLayout {
|
||||||
|
@ -81,15 +83,22 @@ impl Default for StageConfigurations {
|
||||||
let count = 16; // Example: Fewer enemies in a circle
|
let count = 16; // Example: Fewer enemies in a circle
|
||||||
for i in 0..count {
|
for i in 0..count {
|
||||||
let angle = (i as f32 / count as f32) * 2.0 * std::f32::consts::PI;
|
let angle = (i as f32 / count as f32) * 2.0 * std::f32::consts::PI;
|
||||||
positions.push(Vec3::new(angle.cos() * radius, center_y + angle.sin() * radius, 0.0));
|
positions.push(Vec3::new(
|
||||||
|
angle.cos() * radius,
|
||||||
|
center_y + angle.sin() * radius,
|
||||||
|
0.0,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
FormationLayout {
|
||||||
|
name: "Circle".to_string(),
|
||||||
|
positions,
|
||||||
}
|
}
|
||||||
FormationLayout { name: "Circle".to_string(), positions }
|
|
||||||
};
|
};
|
||||||
let stage2 = StageConfig {
|
let stage2 = StageConfig {
|
||||||
formation_layout: stage2_layout,
|
formation_layout: stage2_layout,
|
||||||
enemy_count: 16,
|
enemy_count: 16,
|
||||||
attack_patterns: vec![AttackPattern::SwoopDive, AttackPattern::DirectDive], // Add direct dive
|
attack_patterns: vec![AttackPattern::SwoopDive, AttackPattern::DirectDive], // Add direct dive
|
||||||
attack_dive_interval: 2.5, // Faster dives
|
attack_dive_interval: 2.5, // Faster dives
|
||||||
enemy_speed_multiplier: 1.2, // Faster enemies
|
enemy_speed_multiplier: 1.2, // Faster enemies
|
||||||
enemy_shoot_interval: ENEMY_SHOOT_INTERVAL * 0.8, // Faster shooting
|
enemy_shoot_interval: ENEMY_SHOOT_INTERVAL * 0.8, // Faster shooting
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue