Skip to content

Commit

Permalink
refactor level props
Browse files Browse the repository at this point in the history
  • Loading branch information
aratama committed Jan 25, 2025
1 parent 5686e4c commit 9cfc4f8
Show file tree
Hide file tree
Showing 24 changed files with 257 additions and 341 deletions.
Binary file modified assets/image/level.aseprite
Binary file not shown.
109 changes: 68 additions & 41 deletions assets/registry.game.ron
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#![enable(implicit_some)]
GameRegistry(
debug_wands: [
["InfinityClone", None, None, None, None, None, None, None],
["DualCast", "Levitation", "MagicBolt", None, None, None, None, None],
["QuickCast", "QuickCast", "HeavyShot", "HeavyShot", "TripleCast", "MagicBolt", "MagicBolt", "MagicBolt"],
["Bomb", None, None, None, None, None, None, None],
["Dash", "Lantern", None, None, None, None, None, None]
["InfinityClone", None, None, None, None, None, None, None],
["DualCast", "Dash", "Jump", "Lantern", None, None, None, None]
],

debug_items: [
Expand Down Expand Up @@ -65,8 +65,9 @@ GameRegistry(
"InfinityClone",
],

levels: [
(
levels: {
"home": (
next: ["level_1_0"],
name: Dict (
ja: "ウサギ族のキャンプ",
en: "Rabbit's Camp",
Expand All @@ -83,9 +84,12 @@ GameRegistry(
enemy_types: [],
items: 0,
item_ranks: [],
biome: StoneTile
biome: StoneTile,
bgm: "bgm/水のしたたる洞窟.ogg",
brightness: 0.4
),
(
"level_1_0": (
next: ["level_2_0"],
name: Dict (
ja: "図書館跡",
en: "Library Ruins",
Expand All @@ -102,9 +106,12 @@ GameRegistry(
enemy_types: [Slime],
items: 3,
item_ranks: [0, 1, 2],
biome: StoneTile
biome: StoneTile,
bgm: "bgm/森のいざない.ogg",
brightness: 0.4
),
(
"level_2_0": (
next: ["level_3_0"],
name: Dict (
ja: "地下草原",
en: "Underground Grassland",
Expand All @@ -121,9 +128,12 @@ GameRegistry(
enemy_types: [Slime, Spider],
items: 3,
item_ranks: [1, 2, 3],
biome: Grassland
biome: Grassland,
bgm: "bgm/midnight-forest-184304.ogg",
brightness: 0.02,
),
(
"level_3_0": (
next: ["level_4_0"],
name: Dict (
ja: "古城",
en: "Ancient Castle",
Expand All @@ -140,9 +150,12 @@ GameRegistry(
enemy_types: [Spider, EyeBall],
items: 3,
item_ranks: [2, 3, 4],
biome: StoneTile
biome: StoneTile,
bgm: "bgm/迷宮.ogg",
brightness: 0.4
),
(
"level_4_0": (
next: ["level_5_0"],
name: Dict (
ja: "スライムの巣窟",
en: "Slime Nest",
Expand All @@ -159,9 +172,12 @@ GameRegistry(
enemy_types: [EyeBall, Shadow],
items: 3,
item_ranks: [3, 4, 5],
biome: StoneTile
biome: StoneTile,
bgm: "bgm/ダンジョンを踏破せし者.ogg",
brightness: 0.4
),
(
"level_5_0": (
next: ["level_6_0"],
name: Dict (
ja: "氷の洞窟",
en: "Ice Cave",
Expand All @@ -178,9 +194,12 @@ GameRegistry(
enemy_types: [Shadow, Salamander],
items: 3,
item_ranks: [4, 5, 6],
biome: Ice
biome: Ice,
bgm: "bgm/森のいざない.ogg",
brightness: 0.4
),
(
"level_6_0": (
next: ["boss"],
name: Dict (
ja: "古の回廊",
en: "Ancient Corridor",
Expand All @@ -197,9 +216,12 @@ GameRegistry(
enemy_types: [Slime, Spider, EyeBall, Shadow, Salamander],
items: 3,
item_ranks: [4, 5, 6],
biome: StoneTile
biome: StoneTile,
bgm: "bgm/忘れられた神殿.ogg",
brightness: 0.4
),
(
"boss": (
next: ["home"],
name: Dict (
ja: "大空洞",
en: "Great Cavern",
Expand All @@ -216,29 +238,34 @@ GameRegistry(
enemy_types: [],
items: 3,
item_ranks: [],
biome: StoneTile
biome: StoneTile,
bgm: "bgm/炎神の吐息.ogg",
brightness: 0.4
),
],
arena: (
name: Dict (
ja: "対決の洞窟",
en: "Cave of Confrontation",
zh_cn: "对决洞穴",
zh_tw: "對決洞穴",
es: "Cueva de Confrontación",
fr: "Grotte de Confrontation",
pt: "Caverna de Confronto",
de: "Höhle der Konfrontation",
ko: "대결의 동굴",
ru: "Пещера противостояния"
),
enemies: 0,
enemy_types: [],
items: 3,
item_ranks: [],
biome: StoneTile
),

"arena": (
next: ["home"],
name: Dict (
ja: "対決の洞窟",
en: "Cave of Confrontation",
zh_cn: "对决洞穴",
zh_tw: "對決洞穴",
es: "Cueva de Confrontación",
fr: "Grotte de Confrontation",
pt: "Caverna de Confronto",
de: "Höhle der Konfrontation",
ko: "대결의 동굴",
ru: "Пещера противостояния"
),
enemies: 0,
enemy_types: [],
items: 3,
item_ranks: [],
biome: StoneTile,
bgm: "bgm/森のいざない.ogg",
brightness: 0.4
),
},


tiles: {
(203, 219, 252, 255): (
Expand Down
6 changes: 3 additions & 3 deletions src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ pub struct CastEffects {
pub web: u8,

pub slash: Vec<u32>,

pub levitation: u32,
}

#[derive(Reflect, Default, Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
Expand Down Expand Up @@ -331,9 +333,7 @@ impl ActorExtra {
pub struct ActorLevitationEffect;

/// Actor のスプライトをまとめる子エンティティのマーカーです
/// ボスキャラクターなどの一部のActorはこのマーカーを使いませんが、
/// 通常のキャラクターはこのマーカーでスプライトをまとめます
/// このマーカーを使うと、その子には浮遊エフェクトの子が追加され、浮遊魔法での浮遊アニメーションが描画されるようになります
/// ActorSpriteGroupにはx座標とy座標に応じて自動的にz座標が割り当てられます
///
/// 通常、キャラクターのスプライトはルートのエンティティに直接アタッチされず、
/// この ActorSpriteGroup の子、ルートのエンティティ孫としてアタッチされます
Expand Down
4 changes: 3 additions & 1 deletion src/actor/bomb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use bevy::prelude::*;
use bevy_aseprite_ultra::prelude::*;
use bevy_rapier2d::prelude::*;

use super::ActorSpriteGroup;

#[derive(Default, Component, Reflect)]
struct Bomb;

Expand Down Expand Up @@ -49,7 +51,7 @@ pub fn spawn_bomb(
),
))
.with_children(move |parent| {
parent.spawn((
parent.spawn(ActorSpriteGroup).with_child((
LifeBeingSprite,
CounterAnimated,
AseSpriteAnimation {
Expand Down
37 changes: 20 additions & 17 deletions src/actor/rabbit.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::ActorSpriteGroup;
use super::ActorType;
use crate::actor::Actor;
use crate::actor::ActorExtra;
Expand Down Expand Up @@ -118,23 +119,25 @@ pub fn spawn_rabbit(
Transform::from_xyz(0.0, 0.0, SHADOW_LAYER_Z),
));

builder.spawn((
CounterAnimated,
AseSpriteAnimation {
aseprite: match rabbit_type {
RabbitType::Shop => registry.assets.rabbit_yellow.clone(),
RabbitType::Training => registry.assets.rabbit_red.clone(),
RabbitType::Singleplay => registry.assets.rabbit_white.clone(),
RabbitType::Guide => registry.assets.rabbit_blue.clone(),
RabbitType::MultiPlay => registry.assets.rabbit_black.clone(),
RabbitType::Reading => registry.assets.rabbit_green.clone(),
RabbitType::SpellList => registry.assets.rabbit_blue.clone(),
}
.clone(),
animation: "idle_d".into(),
},
ChildEntityDepth { offset: 0.0 },
));
builder.spawn(ActorSpriteGroup).with_children(|builder| {
builder.spawn((
CounterAnimated,
AseSpriteAnimation {
aseprite: match rabbit_type {
RabbitType::Shop => registry.assets.rabbit_yellow.clone(),
RabbitType::Training => registry.assets.rabbit_red.clone(),
RabbitType::Singleplay => registry.assets.rabbit_white.clone(),
RabbitType::Guide => registry.assets.rabbit_blue.clone(),
RabbitType::MultiPlay => registry.assets.rabbit_black.clone(),
RabbitType::Reading => registry.assets.rabbit_green.clone(),
RabbitType::SpellList => registry.assets.rabbit_blue.clone(),
}
.clone(),
animation: "idle_d".into(),
},
ChildEntityDepth { offset: 0.0 },
));
});

match rabbit_type {
RabbitType::Shop => {
Expand Down
7 changes: 4 additions & 3 deletions src/actor/rock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use bevy::prelude::*;
use bevy_aseprite_ultra::prelude::*;
use bevy_rapier2d::prelude::*;

use super::ActorSpriteGroup;

#[derive(Default, Component, Reflect)]
struct FallingRock;

Expand All @@ -38,8 +40,7 @@ pub fn spawn_falling_rock(commands: &mut Commands, registry: &Registry, position
},
))
.with_children(|parent| {
parent.spawn((
Vertical::new(0.0, -0.1),
parent.spawn(ActorSpriteGroup).with_child((
LifeBeingSprite,
CounterAnimated,
AseSpriteSlice {
Expand Down Expand Up @@ -118,7 +119,7 @@ pub fn spawn_fallen_rock(
),
))
.with_children(|parent| {
parent.spawn((
parent.spawn(ActorSpriteGroup).with_child((
LifeBeingSprite,
CounterAnimated,
AseSpriteSlice {
Expand Down
13 changes: 7 additions & 6 deletions src/asset_credit.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use bevy::asset::AssetPath;
use bevy::audio::AudioSource;
use bevy::prelude::*;

Expand All @@ -8,15 +9,15 @@ pub struct AssetCredit {
pub appendix: &'static str,
}

pub fn path_to_string(path: &AssetPath) -> String {
path.path().to_str().unwrap_or("").to_string()
}

pub fn asset_to_credit(handle: &Handle<AudioSource>) -> AssetCredit {
if let Some(path) = handle.path() {
let name = path
.path()
.file_stem()
.and_then(|s| s.to_str())
.unwrap_or("");
let name = path_to_string(path);

match name {
match name.as_str() {
// 拠点
"茫漠たる庭" => AssetCredit {
authoer: "のる",
Expand Down
15 changes: 6 additions & 9 deletions src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::controller::player::Player;
use crate::controller::player::PlayerServant;
use crate::entity::explosion::ExplosionPointLight;
use crate::entity::explosion::EXPLOSION_COUNT;
use crate::page::in_game::GameLevel;
use crate::page::in_game::LevelSetup;
use crate::registry::Registry;
use crate::set::FixedUpdateGameActiveSet;
use crate::states::GameState;
use bevy::core::FrameCount;
Expand Down Expand Up @@ -126,20 +126,17 @@ fn update_camera_position(
}

fn update_camera_brightness(
registry: Registry,
mut camera_query: Query<&mut AmbientLight2d, With<Camera2d>>,
state: Res<State<GameState>>,
level: Res<LevelSetup>,
explosion_query: Query<&ExplosionPointLight>,
) {
if let Ok(mut light) = camera_query.get_single_mut() {
// 爆発エフェクトを考慮しない、レベルごとの画面の明るさ
let brightness = match state.get() {
GameState::InGame => match level.level {
Some(GameLevel::Level(2)) => 0.02,
_ => BLIGHTNESS_IN_GAME,
},
_ => 1.0,
let Some(level) = &level.level else {
return;
};
let props = registry.get_level(&level);
let brightness = props.brightness;

let max_explosion = explosion_query
.iter()
Expand Down
Loading

0 comments on commit 9cfc4f8

Please sign in to comment.