From 2eed3ffe4140a28395a1fd40d3d9b75d0ad4700e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Hor=C3=A1=C4=8Dek?= <horaceklubos@gmail.com> Date: Tue, 23 Jun 2015 16:48:14 +0200 Subject: [PATCH] #31 Asset access refactoring - passing just library instances that delegate to game instance --- .../gfx/background.png | Bin .../gfx/box_bad.png | Bin .../gfx/box_good.png | Bin .../gfx/carousel.png | Bin .../gfx/effects/1smoke.png | Bin .../gfx/effects/2smoke.png | Bin .../gfx/effects/3smoke.png | Bin .../gfx/effects/4smoke.png | Bin .../gfx/effects/5smoke.png | Bin .../gfx/effects/bad_fast.png | Bin .../gfx/effects/bad_minus5.png | Bin .../gfx/effects/bad_minus7.png | Bin .../gfx/effects/good_plus1.png | Bin .../gfx/effects/good_plus5.png | Bin .../gfx/effects/good_plus7.png | Bin .../gfx/effects/good_slow.png | Bin .../gfx/flowers/._1.png | Bin .../gfx/flowers/._10.png | Bin .../gfx/flowers/._11.png | Bin .../gfx/flowers/._12.png | Bin .../gfx/flowers/._13.png | Bin .../gfx/flowers/._14.png | Bin .../gfx/flowers/._15.png | Bin .../gfx/flowers/._16.png | Bin .../gfx/flowers/._17.png | Bin .../gfx/flowers/._18.png | Bin .../gfx/flowers/._19.png | Bin .../gfx/flowers/._2.png | Bin .../gfx/flowers/._20.png | Bin .../gfx/flowers/._21.png | Bin .../gfx/flowers/._22.png | Bin .../gfx/flowers/._23.png | Bin .../gfx/flowers/._24.png | Bin .../gfx/flowers/._3.png | Bin .../gfx/flowers/._4.png | Bin .../gfx/flowers/._5.png | Bin .../gfx/flowers/._6.png | Bin .../gfx/flowers/._7.png | Bin .../gfx/flowers/._8.png | Bin .../gfx/flowers/._9.png | Bin .../gfx/flowers/1.png | Bin .../gfx/flowers/10.png | Bin .../gfx/flowers/11.png | Bin .../gfx/flowers/12.png | Bin .../gfx/flowers/13.png | Bin .../gfx/flowers/14.png | Bin .../gfx/flowers/15.png | Bin .../gfx/flowers/16.png | Bin .../gfx/flowers/17.png | Bin .../gfx/flowers/18.png | Bin .../gfx/flowers/19.png | Bin .../gfx/flowers/2.png | Bin .../gfx/flowers/20.png | Bin .../gfx/flowers/21.png | Bin .../gfx/flowers/22.png | Bin .../gfx/flowers/23.png | Bin .../gfx/flowers/24.png | Bin .../gfx/flowers/3.png | Bin .../gfx/flowers/4.png | Bin .../gfx/flowers/5.png | Bin .../gfx/flowers/6.png | Bin .../gfx/flowers/7.png | Bin .../gfx/flowers/8.png | Bin .../gfx/flowers/9.png | Bin .../gfx/frame.png | Bin .../gfx/plan_1.png | Bin .../gfx/plan_2.png | Bin .../gfx/plan_3.png | Bin .../gfx/watch.png | Bin .../gfx/watch_hand.png | Bin .../sfx/bell.mp3 | Bin .../sfx/box_fast.mp3 | Bin .../sfx/box_slow.mp3 | Bin .../sfx/box_smoke.mp3 | Bin .../sfx/carousel_1.mp3 | Bin .../sfx/carousel_2.mp3 | Bin .../sfx/hit_1.mp3 | Bin .../sfx/hit_2.mp3 | Bin .../sfx/hit_3.mp3 | Bin .../sfx/hit_4.mp3 | Bin .../sfx/miss.mp3 | Bin .../sfx/swoosh_in.mp3 | Bin .../sfx/wrong.mp3 | Bin .../src/cz/nic/tablexia/TablexiaSettings.java | 4 +- .../game/common/media/AssetDescription.java | 8 ++ .../game/common/media/GfxLibrary.java | 60 +++++++++++++ .../media/SfxLibrary.java | 23 +++-- .../game/games/kidnapping/KidnappingGame.java | 24 +++--- .../game/games/kidnapping/actors/Map.java | 18 ++-- .../games/kidnapping/actors/ReplayButton.java | 1 + .../game/games/kidnapping/actors/Tile.java | 38 ++++----- .../games/kidnapping/media/GfxLibrary.java | 53 ------------ .../games/kidnapping/media/MfxLibrary.java | 49 ----------- .../games/kidnapping/media/TileLibrary.java | 65 -------------- .../kidnapping/media/assets/SoundType.java | 56 ++++++------ .../{TextureType.java => TextureTypes.java} | 6 +- .../kidnapping/media/assets/TileType.java | 12 ++- .../shooting_range/ShootingRangeGame.java | 28 ++++-- .../games/shooting_range/actors/Frame.java | 13 --- .../games/shooting_range/actors/Scene.java | 20 +++++ .../games/shooting_range/actors/Target.java | 14 +-- .../shooting_range/media/GfxLibrary.java | 45 ---------- .../games/shooting_range/media/SoundType.java | 4 +- .../shooting_range/media/TextureType.java | 79 ----------------- .../games/shooting_range/media/Textures.java | 80 ++++++++++++++++++ .../shooting_range/tools/TargetGenerator.java | 38 ++++----- 106 files changed, 312 insertions(+), 426 deletions(-) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/background.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/box_bad.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/box_good.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/carousel.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/1smoke.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/2smoke.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/3smoke.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/4smoke.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/5smoke.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/bad_fast.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/bad_minus5.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/bad_minus7.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/good_plus1.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/good_plus5.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/good_plus7.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/effects/good_slow.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._1.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._10.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._11.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._12.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._13.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._14.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._15.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._16.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._17.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._18.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._19.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._2.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._20.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._21.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._22.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._23.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._24.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._3.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._4.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._5.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._6.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._7.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._8.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/._9.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/1.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/10.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/11.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/12.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/13.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/14.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/15.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/16.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/17.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/18.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/19.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/2.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/20.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/21.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/22.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/23.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/24.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/3.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/4.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/5.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/6.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/7.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/8.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/flowers/9.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/frame.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/plan_1.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/plan_2.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/plan_3.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/watch.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/gfx/watch_hand.png (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/bell.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/box_fast.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/box_slow.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/box_smoke.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/carousel_1.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/carousel_2.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/hit_1.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/hit_2.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/hit_3.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/hit_4.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/miss.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/swoosh_in.mp3 (100%) rename core/assets/common/game/{shooting_range => shootingrange}/sfx/wrong.mp3 (100%) create mode 100644 core/src/cz/nic/tablexia/game/common/media/AssetDescription.java create mode 100644 core/src/cz/nic/tablexia/game/common/media/GfxLibrary.java rename core/src/cz/nic/tablexia/game/{games/shooting_range => common}/media/SfxLibrary.java (66%) delete mode 100644 core/src/cz/nic/tablexia/game/games/kidnapping/media/GfxLibrary.java delete mode 100644 core/src/cz/nic/tablexia/game/games/kidnapping/media/MfxLibrary.java delete mode 100644 core/src/cz/nic/tablexia/game/games/kidnapping/media/TileLibrary.java rename core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/{TextureType.java => TextureTypes.java} (91%) delete mode 100644 core/src/cz/nic/tablexia/game/games/shooting_range/actors/Frame.java create mode 100644 core/src/cz/nic/tablexia/game/games/shooting_range/actors/Scene.java delete mode 100644 core/src/cz/nic/tablexia/game/games/shooting_range/media/GfxLibrary.java delete mode 100644 core/src/cz/nic/tablexia/game/games/shooting_range/media/TextureType.java create mode 100644 core/src/cz/nic/tablexia/game/games/shooting_range/media/Textures.java diff --git a/core/assets/common/game/shooting_range/gfx/background.png b/core/assets/common/game/shootingrange/gfx/background.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/background.png rename to core/assets/common/game/shootingrange/gfx/background.png diff --git a/core/assets/common/game/shooting_range/gfx/box_bad.png b/core/assets/common/game/shootingrange/gfx/box_bad.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/box_bad.png rename to core/assets/common/game/shootingrange/gfx/box_bad.png diff --git a/core/assets/common/game/shooting_range/gfx/box_good.png b/core/assets/common/game/shootingrange/gfx/box_good.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/box_good.png rename to core/assets/common/game/shootingrange/gfx/box_good.png diff --git a/core/assets/common/game/shooting_range/gfx/carousel.png b/core/assets/common/game/shootingrange/gfx/carousel.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/carousel.png rename to core/assets/common/game/shootingrange/gfx/carousel.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/1smoke.png b/core/assets/common/game/shootingrange/gfx/effects/1smoke.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/1smoke.png rename to core/assets/common/game/shootingrange/gfx/effects/1smoke.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/2smoke.png b/core/assets/common/game/shootingrange/gfx/effects/2smoke.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/2smoke.png rename to core/assets/common/game/shootingrange/gfx/effects/2smoke.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/3smoke.png b/core/assets/common/game/shootingrange/gfx/effects/3smoke.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/3smoke.png rename to core/assets/common/game/shootingrange/gfx/effects/3smoke.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/4smoke.png b/core/assets/common/game/shootingrange/gfx/effects/4smoke.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/4smoke.png rename to core/assets/common/game/shootingrange/gfx/effects/4smoke.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/5smoke.png b/core/assets/common/game/shootingrange/gfx/effects/5smoke.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/5smoke.png rename to core/assets/common/game/shootingrange/gfx/effects/5smoke.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/bad_fast.png b/core/assets/common/game/shootingrange/gfx/effects/bad_fast.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/bad_fast.png rename to core/assets/common/game/shootingrange/gfx/effects/bad_fast.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/bad_minus5.png b/core/assets/common/game/shootingrange/gfx/effects/bad_minus5.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/bad_minus5.png rename to core/assets/common/game/shootingrange/gfx/effects/bad_minus5.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/bad_minus7.png b/core/assets/common/game/shootingrange/gfx/effects/bad_minus7.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/bad_minus7.png rename to core/assets/common/game/shootingrange/gfx/effects/bad_minus7.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/good_plus1.png b/core/assets/common/game/shootingrange/gfx/effects/good_plus1.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/good_plus1.png rename to core/assets/common/game/shootingrange/gfx/effects/good_plus1.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/good_plus5.png b/core/assets/common/game/shootingrange/gfx/effects/good_plus5.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/good_plus5.png rename to core/assets/common/game/shootingrange/gfx/effects/good_plus5.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/good_plus7.png b/core/assets/common/game/shootingrange/gfx/effects/good_plus7.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/good_plus7.png rename to core/assets/common/game/shootingrange/gfx/effects/good_plus7.png diff --git a/core/assets/common/game/shooting_range/gfx/effects/good_slow.png b/core/assets/common/game/shootingrange/gfx/effects/good_slow.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/effects/good_slow.png rename to core/assets/common/game/shootingrange/gfx/effects/good_slow.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._1.png b/core/assets/common/game/shootingrange/gfx/flowers/._1.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._1.png rename to core/assets/common/game/shootingrange/gfx/flowers/._1.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._10.png b/core/assets/common/game/shootingrange/gfx/flowers/._10.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._10.png rename to core/assets/common/game/shootingrange/gfx/flowers/._10.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._11.png b/core/assets/common/game/shootingrange/gfx/flowers/._11.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._11.png rename to core/assets/common/game/shootingrange/gfx/flowers/._11.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._12.png b/core/assets/common/game/shootingrange/gfx/flowers/._12.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._12.png rename to core/assets/common/game/shootingrange/gfx/flowers/._12.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._13.png b/core/assets/common/game/shootingrange/gfx/flowers/._13.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._13.png rename to core/assets/common/game/shootingrange/gfx/flowers/._13.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._14.png b/core/assets/common/game/shootingrange/gfx/flowers/._14.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._14.png rename to core/assets/common/game/shootingrange/gfx/flowers/._14.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._15.png b/core/assets/common/game/shootingrange/gfx/flowers/._15.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._15.png rename to core/assets/common/game/shootingrange/gfx/flowers/._15.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._16.png b/core/assets/common/game/shootingrange/gfx/flowers/._16.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._16.png rename to core/assets/common/game/shootingrange/gfx/flowers/._16.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._17.png b/core/assets/common/game/shootingrange/gfx/flowers/._17.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._17.png rename to core/assets/common/game/shootingrange/gfx/flowers/._17.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._18.png b/core/assets/common/game/shootingrange/gfx/flowers/._18.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._18.png rename to core/assets/common/game/shootingrange/gfx/flowers/._18.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._19.png b/core/assets/common/game/shootingrange/gfx/flowers/._19.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._19.png rename to core/assets/common/game/shootingrange/gfx/flowers/._19.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._2.png b/core/assets/common/game/shootingrange/gfx/flowers/._2.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._2.png rename to core/assets/common/game/shootingrange/gfx/flowers/._2.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._20.png b/core/assets/common/game/shootingrange/gfx/flowers/._20.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._20.png rename to core/assets/common/game/shootingrange/gfx/flowers/._20.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._21.png b/core/assets/common/game/shootingrange/gfx/flowers/._21.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._21.png rename to core/assets/common/game/shootingrange/gfx/flowers/._21.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._22.png b/core/assets/common/game/shootingrange/gfx/flowers/._22.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._22.png rename to core/assets/common/game/shootingrange/gfx/flowers/._22.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._23.png b/core/assets/common/game/shootingrange/gfx/flowers/._23.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._23.png rename to core/assets/common/game/shootingrange/gfx/flowers/._23.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._24.png b/core/assets/common/game/shootingrange/gfx/flowers/._24.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._24.png rename to core/assets/common/game/shootingrange/gfx/flowers/._24.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._3.png b/core/assets/common/game/shootingrange/gfx/flowers/._3.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._3.png rename to core/assets/common/game/shootingrange/gfx/flowers/._3.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._4.png b/core/assets/common/game/shootingrange/gfx/flowers/._4.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._4.png rename to core/assets/common/game/shootingrange/gfx/flowers/._4.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._5.png b/core/assets/common/game/shootingrange/gfx/flowers/._5.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._5.png rename to core/assets/common/game/shootingrange/gfx/flowers/._5.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._6.png b/core/assets/common/game/shootingrange/gfx/flowers/._6.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._6.png rename to core/assets/common/game/shootingrange/gfx/flowers/._6.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._7.png b/core/assets/common/game/shootingrange/gfx/flowers/._7.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._7.png rename to core/assets/common/game/shootingrange/gfx/flowers/._7.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._8.png b/core/assets/common/game/shootingrange/gfx/flowers/._8.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._8.png rename to core/assets/common/game/shootingrange/gfx/flowers/._8.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/._9.png b/core/assets/common/game/shootingrange/gfx/flowers/._9.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/._9.png rename to core/assets/common/game/shootingrange/gfx/flowers/._9.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/1.png b/core/assets/common/game/shootingrange/gfx/flowers/1.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/1.png rename to core/assets/common/game/shootingrange/gfx/flowers/1.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/10.png b/core/assets/common/game/shootingrange/gfx/flowers/10.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/10.png rename to core/assets/common/game/shootingrange/gfx/flowers/10.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/11.png b/core/assets/common/game/shootingrange/gfx/flowers/11.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/11.png rename to core/assets/common/game/shootingrange/gfx/flowers/11.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/12.png b/core/assets/common/game/shootingrange/gfx/flowers/12.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/12.png rename to core/assets/common/game/shootingrange/gfx/flowers/12.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/13.png b/core/assets/common/game/shootingrange/gfx/flowers/13.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/13.png rename to core/assets/common/game/shootingrange/gfx/flowers/13.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/14.png b/core/assets/common/game/shootingrange/gfx/flowers/14.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/14.png rename to core/assets/common/game/shootingrange/gfx/flowers/14.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/15.png b/core/assets/common/game/shootingrange/gfx/flowers/15.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/15.png rename to core/assets/common/game/shootingrange/gfx/flowers/15.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/16.png b/core/assets/common/game/shootingrange/gfx/flowers/16.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/16.png rename to core/assets/common/game/shootingrange/gfx/flowers/16.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/17.png b/core/assets/common/game/shootingrange/gfx/flowers/17.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/17.png rename to core/assets/common/game/shootingrange/gfx/flowers/17.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/18.png b/core/assets/common/game/shootingrange/gfx/flowers/18.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/18.png rename to core/assets/common/game/shootingrange/gfx/flowers/18.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/19.png b/core/assets/common/game/shootingrange/gfx/flowers/19.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/19.png rename to core/assets/common/game/shootingrange/gfx/flowers/19.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/2.png b/core/assets/common/game/shootingrange/gfx/flowers/2.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/2.png rename to core/assets/common/game/shootingrange/gfx/flowers/2.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/20.png b/core/assets/common/game/shootingrange/gfx/flowers/20.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/20.png rename to core/assets/common/game/shootingrange/gfx/flowers/20.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/21.png b/core/assets/common/game/shootingrange/gfx/flowers/21.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/21.png rename to core/assets/common/game/shootingrange/gfx/flowers/21.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/22.png b/core/assets/common/game/shootingrange/gfx/flowers/22.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/22.png rename to core/assets/common/game/shootingrange/gfx/flowers/22.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/23.png b/core/assets/common/game/shootingrange/gfx/flowers/23.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/23.png rename to core/assets/common/game/shootingrange/gfx/flowers/23.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/24.png b/core/assets/common/game/shootingrange/gfx/flowers/24.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/24.png rename to core/assets/common/game/shootingrange/gfx/flowers/24.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/3.png b/core/assets/common/game/shootingrange/gfx/flowers/3.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/3.png rename to core/assets/common/game/shootingrange/gfx/flowers/3.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/4.png b/core/assets/common/game/shootingrange/gfx/flowers/4.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/4.png rename to core/assets/common/game/shootingrange/gfx/flowers/4.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/5.png b/core/assets/common/game/shootingrange/gfx/flowers/5.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/5.png rename to core/assets/common/game/shootingrange/gfx/flowers/5.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/6.png b/core/assets/common/game/shootingrange/gfx/flowers/6.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/6.png rename to core/assets/common/game/shootingrange/gfx/flowers/6.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/7.png b/core/assets/common/game/shootingrange/gfx/flowers/7.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/7.png rename to core/assets/common/game/shootingrange/gfx/flowers/7.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/8.png b/core/assets/common/game/shootingrange/gfx/flowers/8.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/8.png rename to core/assets/common/game/shootingrange/gfx/flowers/8.png diff --git a/core/assets/common/game/shooting_range/gfx/flowers/9.png b/core/assets/common/game/shootingrange/gfx/flowers/9.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/flowers/9.png rename to core/assets/common/game/shootingrange/gfx/flowers/9.png diff --git a/core/assets/common/game/shooting_range/gfx/frame.png b/core/assets/common/game/shootingrange/gfx/frame.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/frame.png rename to core/assets/common/game/shootingrange/gfx/frame.png diff --git a/core/assets/common/game/shooting_range/gfx/plan_1.png b/core/assets/common/game/shootingrange/gfx/plan_1.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/plan_1.png rename to core/assets/common/game/shootingrange/gfx/plan_1.png diff --git a/core/assets/common/game/shooting_range/gfx/plan_2.png b/core/assets/common/game/shootingrange/gfx/plan_2.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/plan_2.png rename to core/assets/common/game/shootingrange/gfx/plan_2.png diff --git a/core/assets/common/game/shooting_range/gfx/plan_3.png b/core/assets/common/game/shootingrange/gfx/plan_3.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/plan_3.png rename to core/assets/common/game/shootingrange/gfx/plan_3.png diff --git a/core/assets/common/game/shooting_range/gfx/watch.png b/core/assets/common/game/shootingrange/gfx/watch.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/watch.png rename to core/assets/common/game/shootingrange/gfx/watch.png diff --git a/core/assets/common/game/shooting_range/gfx/watch_hand.png b/core/assets/common/game/shootingrange/gfx/watch_hand.png similarity index 100% rename from core/assets/common/game/shooting_range/gfx/watch_hand.png rename to core/assets/common/game/shootingrange/gfx/watch_hand.png diff --git a/core/assets/common/game/shooting_range/sfx/bell.mp3 b/core/assets/common/game/shootingrange/sfx/bell.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/bell.mp3 rename to core/assets/common/game/shootingrange/sfx/bell.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/box_fast.mp3 b/core/assets/common/game/shootingrange/sfx/box_fast.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/box_fast.mp3 rename to core/assets/common/game/shootingrange/sfx/box_fast.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/box_slow.mp3 b/core/assets/common/game/shootingrange/sfx/box_slow.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/box_slow.mp3 rename to core/assets/common/game/shootingrange/sfx/box_slow.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/box_smoke.mp3 b/core/assets/common/game/shootingrange/sfx/box_smoke.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/box_smoke.mp3 rename to core/assets/common/game/shootingrange/sfx/box_smoke.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/carousel_1.mp3 b/core/assets/common/game/shootingrange/sfx/carousel_1.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/carousel_1.mp3 rename to core/assets/common/game/shootingrange/sfx/carousel_1.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/carousel_2.mp3 b/core/assets/common/game/shootingrange/sfx/carousel_2.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/carousel_2.mp3 rename to core/assets/common/game/shootingrange/sfx/carousel_2.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/hit_1.mp3 b/core/assets/common/game/shootingrange/sfx/hit_1.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/hit_1.mp3 rename to core/assets/common/game/shootingrange/sfx/hit_1.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/hit_2.mp3 b/core/assets/common/game/shootingrange/sfx/hit_2.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/hit_2.mp3 rename to core/assets/common/game/shootingrange/sfx/hit_2.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/hit_3.mp3 b/core/assets/common/game/shootingrange/sfx/hit_3.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/hit_3.mp3 rename to core/assets/common/game/shootingrange/sfx/hit_3.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/hit_4.mp3 b/core/assets/common/game/shootingrange/sfx/hit_4.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/hit_4.mp3 rename to core/assets/common/game/shootingrange/sfx/hit_4.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/miss.mp3 b/core/assets/common/game/shootingrange/sfx/miss.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/miss.mp3 rename to core/assets/common/game/shootingrange/sfx/miss.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/swoosh_in.mp3 b/core/assets/common/game/shootingrange/sfx/swoosh_in.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/swoosh_in.mp3 rename to core/assets/common/game/shootingrange/sfx/swoosh_in.mp3 diff --git a/core/assets/common/game/shooting_range/sfx/wrong.mp3 b/core/assets/common/game/shootingrange/sfx/wrong.mp3 similarity index 100% rename from core/assets/common/game/shooting_range/sfx/wrong.mp3 rename to core/assets/common/game/shootingrange/sfx/wrong.mp3 diff --git a/core/src/cz/nic/tablexia/TablexiaSettings.java b/core/src/cz/nic/tablexia/TablexiaSettings.java index 5cc5b83bb..7aad607c2 100644 --- a/core/src/cz/nic/tablexia/TablexiaSettings.java +++ b/core/src/cz/nic/tablexia/TablexiaSettings.java @@ -11,7 +11,7 @@ import cz.nic.tablexia.bus.ApplicationBus; import cz.nic.tablexia.bus.event.LocaleChangedEvent; import cz.nic.tablexia.game.GameDefinition; import cz.nic.tablexia.game.difficulty.GameDifficulty; -import cz.nic.tablexia.game.games.shooting_range.ShootingRangeGame; +import cz.nic.tablexia.game.games.kidnapping.KidnappingGame; import cz.nic.tablexia.loader.application.ApplicationTextManager; import cz.nic.tablexia.screen.AbstractTablexiaScreen; import cz.nic.tablexia.util.Log; @@ -24,7 +24,7 @@ public class TablexiaSettings { private static final int MIN_SCREEN_HEIGHT = (int) (DEFAULT_SCREEN_WIDTH * MAXIMUM_RATIO); private static final boolean DEBUG_SHOW_BOUNDING_BOXES = true; - public static final Class<? extends AbstractTablexiaScreen<?>> INITIAL_SCREEN = ShootingRangeGame.class; + public static final Class<? extends AbstractTablexiaScreen<?>> INITIAL_SCREEN = KidnappingGame.class; public static final int AVATAR_COUNT = 8; private static final String PREFERENCES_KEY = "cz.nic.tablexia."; diff --git a/core/src/cz/nic/tablexia/game/common/media/AssetDescription.java b/core/src/cz/nic/tablexia/game/common/media/AssetDescription.java new file mode 100644 index 000000000..007f40f98 --- /dev/null +++ b/core/src/cz/nic/tablexia/game/common/media/AssetDescription.java @@ -0,0 +1,8 @@ +package cz.nic.tablexia.game.common.media; + +/** + * Created by lhoracek on 6/23/15. + */ +public interface AssetDescription { + public String getResource(); +} diff --git a/core/src/cz/nic/tablexia/game/common/media/GfxLibrary.java b/core/src/cz/nic/tablexia/game/common/media/GfxLibrary.java new file mode 100644 index 000000000..6e9336334 --- /dev/null +++ b/core/src/cz/nic/tablexia/game/common/media/GfxLibrary.java @@ -0,0 +1,60 @@ +/** + * **************************************************************************** + * Tablexia + * <p/> + * Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz> + * <p/> + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * <p/> + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * <p/> + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * **************************************************************************** + */ + +package cz.nic.tablexia.game.common.media; + +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +import java.util.HashMap; + +import cz.nic.tablexia.game.AbstractTablexiaGame; + + +/** + * Library of all kidnapping assets except tiles + * + * @author lhoracek + */ +public class GfxLibrary extends HashMap<AssetDescription, String> { + + private static final long serialVersionUID = -4016629019721509061L; + private static final String DEFAULT_TETURE_DIR = "gfx/"; + private final String textureDir; + + AbstractTablexiaGame shootingRangeGame; + + public GfxLibrary(AbstractTablexiaGame shootingRangeGame, AssetDescription[] textures, String dir) { + this.shootingRangeGame = shootingRangeGame; + this.textureDir = dir == null ? DEFAULT_TETURE_DIR : dir; + for (AssetDescription assetDescription : textures) { + String path = textureDir + assetDescription.getResource(); + put(assetDescription, path); + } + } + + public GfxLibrary(AbstractTablexiaGame shootingRangeGame, AssetDescription[] textures) { + this(shootingRangeGame, textures, null); + } + + public TextureRegion getTextureRegion(AssetDescription assetDescription) { + return shootingRangeGame.getScreenTextureRegion(get(assetDescription)); + } +} diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/media/SfxLibrary.java b/core/src/cz/nic/tablexia/game/common/media/SfxLibrary.java similarity index 66% rename from core/src/cz/nic/tablexia/game/games/shooting_range/media/SfxLibrary.java rename to core/src/cz/nic/tablexia/game/common/media/SfxLibrary.java index 2551b1f4b..fcdf33cfe 100644 --- a/core/src/cz/nic/tablexia/game/games/shooting_range/media/SfxLibrary.java +++ b/core/src/cz/nic/tablexia/game/common/media/SfxLibrary.java @@ -19,30 +19,35 @@ * **************************************************************************** */ -package cz.nic.tablexia.game.games.shooting_range.media; +package cz.nic.tablexia.game.common.media; +import com.badlogic.gdx.audio.Sound; + import java.util.HashMap; +import cz.nic.tablexia.game.AbstractTablexiaGame; + /** * @author lhoracek */ -public class SfxLibrary extends HashMap<SoundType, String> { +public class SfxLibrary extends HashMap<AssetDescription, String> { private static final String SOUNDS_DIR = "mfx/"; public static final String SOUNDS_EXTENSION = ".mp3"; + private AbstractTablexiaGame abstractTablexiaGame; - public SfxLibrary() { - super(); - loadSounds(); - } - - private void loadSounds() { - for (SoundType sound : SoundType.values()) { + public SfxLibrary(AbstractTablexiaGame abstractTablexiaGame, AssetDescription[] assetDescriptions) { + this.abstractTablexiaGame = abstractTablexiaGame; + for (AssetDescription sound : assetDescriptions) { String path = SOUNDS_DIR + sound.getResource() + SOUNDS_EXTENSION; put(sound, path); } } + + public Sound getSound(AssetDescription assetDescription) { + return abstractTablexiaGame.getSound(get(assetDescription)); + } } diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/KidnappingGame.java b/core/src/cz/nic/tablexia/game/games/kidnapping/KidnappingGame.java index 556c97ab4..15c964d7c 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/KidnappingGame.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/KidnappingGame.java @@ -5,12 +5,16 @@ import com.badlogic.gdx.scenes.scene2d.EventListener; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.google.common.collect.ObjectArrays; import java.util.Arrays; import java.util.List; import cz.nic.tablexia.TablexiaSettings; import cz.nic.tablexia.game.AbstractTablexiaGame; +import cz.nic.tablexia.game.common.media.AssetDescription; +import cz.nic.tablexia.game.common.media.GfxLibrary; +import cz.nic.tablexia.game.common.media.SfxLibrary; import cz.nic.tablexia.game.games.kidnapping.actions.ArrowMusicAction; import cz.nic.tablexia.game.games.kidnapping.actions.CenterTileAction; import cz.nic.tablexia.game.games.kidnapping.actions.fades.CorrectAlphaAction; @@ -23,9 +27,9 @@ import cz.nic.tablexia.game.games.kidnapping.actions.fades.WrongAlphaAction; import cz.nic.tablexia.game.games.kidnapping.actors.Arrow; import cz.nic.tablexia.game.games.kidnapping.actors.Map; import cz.nic.tablexia.game.games.kidnapping.media.DirectionSounds; -import cz.nic.tablexia.game.games.kidnapping.media.GfxLibrary; -import cz.nic.tablexia.game.games.kidnapping.media.MfxLibrary; import cz.nic.tablexia.game.games.kidnapping.media.assets.SoundType; +import cz.nic.tablexia.game.games.kidnapping.media.assets.TextureTypes; +import cz.nic.tablexia.game.games.kidnapping.media.assets.TileType; import cz.nic.tablexia.game.games.kidnapping.model.Direction; import cz.nic.tablexia.game.games.kidnapping.model.GameState; import cz.nic.tablexia.game.games.kidnapping.model.Position; @@ -37,14 +41,14 @@ import cz.nic.tablexia.util.Log; */ public class KidnappingGame extends AbstractTablexiaGame<GameState> { - private GfxLibrary gfxLibrary = new GfxLibrary(); - private MfxLibrary mfxLibrary = new MfxLibrary(); - private Map map; + private GfxLibrary gfxLibrary = new GfxLibrary(this, ObjectArrays.concat(TextureTypes.values(), TileType.values(), AssetDescription.class)); + private SfxLibrary sfxLibrary = new SfxLibrary(this, SoundType.values()); + private Map map; @Override protected void prepareScreenSoundAssetNames(List<String> soundsFileNames) { super.prepareScreenSoundAssetNames(soundsFileNames); - soundsFileNames.addAll(mfxLibrary.values()); + soundsFileNames.addAll(sfxLibrary.values()); } @Override @@ -61,7 +65,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> { // TODO show rule screen // TODO show sub-rule screen getStage().setDebugAll(TablexiaSettings.getInstance().isShowBoundingBoxes()); - getStage().addActor(map = Map.MapFactory.createInstance(this, getData())); + getStage().addActor(map = Map.MapFactory.createInstance(this, gfxLibrary, getData())); map.setBounds(0, getStage().getCamera().position.y - getStage().getHeight() / 2, getStage().getWidth(), getStage().getHeight()); // scaling viewport camera y-position adjustment map.setMapScale(0.5f); // center first tile and start game @@ -133,7 +137,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> { } }))); } else { - getSound(mfxLibrary.get(SoundType.SOUND_ERROR)).play(); + sfxLibrary.getSound(SoundType.SOUND_ERROR).play(); map.addAction(Actions.sequence(WrongAlphaAction.fadeIn(), WrongAlphaAction.fadeOut())); wrong(); } @@ -165,8 +169,8 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> { return gfxLibrary; } - public MfxLibrary getMfxLibrary() { - return mfxLibrary; + public SfxLibrary getSfxLibrary() { + return sfxLibrary; } public String getVictoryText(int progress) { diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Map.java b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Map.java index 9c9924a1b..29c1f40f5 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Map.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Map.java @@ -7,9 +7,10 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image; import java.util.HashMap; +import cz.nic.tablexia.game.common.media.GfxLibrary; import cz.nic.tablexia.game.games.kidnapping.KidnappingGame; import cz.nic.tablexia.game.games.kidnapping.Properties; -import cz.nic.tablexia.game.games.kidnapping.media.assets.TextureType; +import cz.nic.tablexia.game.games.kidnapping.media.assets.TextureTypes; import cz.nic.tablexia.game.games.kidnapping.model.Direction; import cz.nic.tablexia.game.games.kidnapping.model.GameState; import cz.nic.tablexia.game.games.kidnapping.model.Position; @@ -29,13 +30,14 @@ public class Map extends Group { private Image correct, wrong; private DragActorListener debugListener = new DragActorListener(tiles); - public Map(KidnappingGame screen) { + public Map(KidnappingGame screen, GfxLibrary library) { addActor(tiles); addActor(replayButton = new ReplayButton(screen)); replayButton.setVisible(false); - addActor(overlay = new EarOverlay(screen.getText("game_kidnapping_instructions_pay_attention"),ApplicationAtlasManager.getInstance().getColorTexture(Color.BLACK), screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.EAR)))); - addActor(correct = new Image(screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.CORRECT)))); - addActor(wrong = new Image(screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.WRONG)))); + // TODO fix getting text through screen + addActor(overlay = new EarOverlay(screen.getText("game_kidnapping_instructions_pay_attention"),ApplicationAtlasManager.getInstance().getColorTexture(Color.BLACK), screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureTypes.EAR)))); + addActor(correct = new Image(library.getTextureRegion(TextureTypes.CORRECT))); + addActor(wrong = new Image(library.getTextureRegion(TextureTypes.WRONG))); wrong.setVisible(false); correct.setVisible(false); } @@ -111,10 +113,10 @@ public class Map extends Group { } public static class MapFactory { - public static Map createInstance(KidnappingGame screen, GameState gameState) { - Map map = new Map(screen); + public static Map createInstance(KidnappingGame game, GfxLibrary gfxLibrary, GameState gameState) { + Map map = new Map(game, gfxLibrary); for (Position position : gameState.getMap().keySet()) { - map.addTile(position, Tile.TileFactory.createInstance(screen, gameState.getMap().get(position))); + map.addTile(position, Tile.TileFactory.createInstance(gfxLibrary, gameState.getMap().get(position))); } map.getOverlay().setVisible(false); return map; diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/ReplayButton.java b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/ReplayButton.java index 5fc0b3d48..e87b3ef8a 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/ReplayButton.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/ReplayButton.java @@ -10,6 +10,7 @@ import cz.nic.tablexia.util.ui.TablexiaButton; public class ReplayButton extends TablexiaButton { public ReplayButton(KidnappingGame screen) { + // TODO fix getting text through screen super(screen.getText("game_kidnapping_replay"), ButtonType.GREEN); setSize(150, 80); } diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Tile.java b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Tile.java index ac4951ffb..7eef40289 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Tile.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/actors/Tile.java @@ -29,8 +29,8 @@ import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Label; -import cz.nic.tablexia.game.games.kidnapping.KidnappingGame; -import cz.nic.tablexia.game.games.kidnapping.media.assets.TextureType; +import cz.nic.tablexia.game.common.media.GfxLibrary; +import cz.nic.tablexia.game.games.kidnapping.media.assets.TextureTypes; import cz.nic.tablexia.game.games.kidnapping.media.assets.TileType; import cz.nic.tablexia.game.games.kidnapping.model.Position; @@ -119,59 +119,59 @@ public class Tile extends Group { } public static class TileFactory { - public static Tile createInstance(KidnappingGame screen, TileType tileType) { + public static Tile createInstance(GfxLibrary gfxLibrary, TileType tileType) { Tile tile = new Tile(); tile.tileType = tileType; - TextureRegion tileTexture = screen.getScreenTextureRegion(screen.getGfxLibrary().getTileLibrary().get(tileType)); + TextureRegion tileTexture = gfxLibrary.getTextureRegion(tileType); tile.street = new Image(tileTexture); tile.addActor(tile.street); tile.street.setTouchable(Touchable.disabled); - addPath(screen, tile); - addArrows(screen, tile); + addPath(gfxLibrary, tile); + addArrows(gfxLibrary, tile); return tile; } - private static void addPath(KidnappingGame screen, Tile tile) { - TextureRegion flagTexture = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_CURRENT)); + private static void addPath(GfxLibrary gfxLibrary, Tile tile) { + TextureRegion flagTexture = gfxLibrary.getTextureRegion(TextureTypes.POSITION_CURRENT); tile.addActor(tile.flag = new Image(flagTexture)); tile.flag.setPosition(351, -29); tile.flag.setVisible(false); - TextureRegion lineNE = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_LINE_NESW)); + TextureRegion lineNE = gfxLibrary.getTextureRegion(TextureTypes.POSITION_LINE_NESW); tile.addActor(tile.pathNorthEast = new Image(lineNE)); tile.pathNorthEast.setPosition(464, 86); tile.pathNorthEast.setVisible(false); - TextureRegion lineNW = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_LINE_NWSE)); + TextureRegion lineNW = gfxLibrary.getTextureRegion(TextureTypes.POSITION_LINE_NWSE); tile.addActor(tile.pathNorthWest = new Image(lineNW)); tile.pathNorthWest.setPosition(59, 88); tile.pathNorthWest.setVisible(false); } - private static void addArrows(KidnappingGame screen, Tile tile) { - TextureRegion arrowNE = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_NEXT_NE)); - TextureRegion arrowNEPressed = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_NEXT_NE_PRESSED)); + private static void addArrows(GfxLibrary gfxLibrary, Tile tile) { + TextureRegion arrowNE = gfxLibrary.getTextureRegion(TextureTypes.POSITION_NEXT_NE); + TextureRegion arrowNEPressed = gfxLibrary.getTextureRegion(TextureTypes.POSITION_NEXT_NE_PRESSED); tile.addActor(tile.northEastOut = new Arrow(arrowNE, arrowNEPressed)); tile.northEastOut.setPosition(531, 110); tile.northEastOut.setVisible(false); - TextureRegion arrowNW = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_NEXT_NW)); - TextureRegion arrowNWPressed = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_NEXT_NW_PRESSED)); + TextureRegion arrowNW = gfxLibrary.getTextureRegion(TextureTypes.POSITION_NEXT_NW); + TextureRegion arrowNWPressed = gfxLibrary.getTextureRegion(TextureTypes.POSITION_NEXT_NW_PRESSED); tile.addActor(tile.northWestOut = new Arrow(arrowNW, arrowNWPressed)); tile.northWestOut.setPosition(127, 112); tile.northWestOut.setVisible(false); - TextureRegion arrowSE = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_NEXT_SE)); - TextureRegion arrowSEPressed = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_NEXT_SE_PRESSED)); + TextureRegion arrowSE = gfxLibrary.getTextureRegion(TextureTypes.POSITION_NEXT_SE); + TextureRegion arrowSEPressed = gfxLibrary.getTextureRegion(TextureTypes.POSITION_NEXT_SE_PRESSED); tile.addActor(tile.northWestIn = new Arrow(arrowSE, arrowSEPressed)); tile.northWestIn.setPosition(137, 112); tile.northWestIn.setVisible(false); - TextureRegion arrowSW = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_NEXT_SW)); - TextureRegion arrowSWPressed = screen.getScreenTextureRegion(screen.getGfxLibrary().get(TextureType.POSITION_NEXT_SW_PRESSED)); + TextureRegion arrowSW = gfxLibrary.getTextureRegion(TextureTypes.POSITION_NEXT_SW); + TextureRegion arrowSWPressed = gfxLibrary.getTextureRegion(TextureTypes.POSITION_NEXT_SW_PRESSED); tile.addActor(tile.northEastIn = new Arrow(arrowSW, arrowSWPressed)); tile.northEastIn.setPosition(515, 106); tile.northEastIn.setVisible(false); diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/media/GfxLibrary.java b/core/src/cz/nic/tablexia/game/games/kidnapping/media/GfxLibrary.java deleted file mode 100644 index f50f4d3f6..000000000 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/media/GfxLibrary.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * **************************************************************************** - * Tablexia - * <p/> - * Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz> - * <p/> - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * <p/> - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * <p/> - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * **************************************************************************** - */ - -package cz.nic.tablexia.game.games.kidnapping.media; - -import java.util.HashMap; - -import cz.nic.tablexia.game.games.kidnapping.Properties; -import cz.nic.tablexia.game.games.kidnapping.media.assets.TextureType; - -/** - * Library of all kidnapping assets except tiles - * - * @author lhoracek - */ -public class GfxLibrary extends HashMap<TextureType, String> { - - private static final long serialVersionUID = -4016629019721509061L; - private static final String TEXTURE_DIR = "gfx/"; - - private final TileLibrary tileLibrary; - - public GfxLibrary() { - super(); - tileLibrary = new TileLibrary(); - for (TextureType textureType : TextureType.values()) { - String path = TEXTURE_DIR + textureType.getResource(); - put(textureType, path); - } - } - - public TileLibrary getTileLibrary() { - return tileLibrary; - } -} diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/media/MfxLibrary.java b/core/src/cz/nic/tablexia/game/games/kidnapping/media/MfxLibrary.java deleted file mode 100644 index 536eff45e..000000000 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/media/MfxLibrary.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * **************************************************************************** - * Tablexia - * <p/> - * Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz> - * <p/> - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * <p/> - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * <p/> - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * **************************************************************************** - */ - -package cz.nic.tablexia.game.games.kidnapping.media; - - -import java.util.HashMap; - -import cz.nic.tablexia.game.games.kidnapping.media.assets.SoundType; - -/** - * @author lhoracek - */ -public class MfxLibrary extends HashMap<SoundType, String> { - - private static final String SOUNDS_DIR = "mfx/"; - public static final String SOUNDS_EXTENSION = ".mp3"; - - - public MfxLibrary() { - super(); - loadSounds(); - } - - private void loadSounds() { - for (SoundType sound : SoundType.values()) { - String path = SOUNDS_DIR + sound.getResource() + SOUNDS_EXTENSION; - put(sound, path); - } - } -} diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/media/TileLibrary.java b/core/src/cz/nic/tablexia/game/games/kidnapping/media/TileLibrary.java deleted file mode 100644 index d1a269cc3..000000000 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/media/TileLibrary.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * **************************************************************************** - * Tablexia - * <p/> - * Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz> - * <p/> - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * <p/> - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * <p/> - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * **************************************************************************** - */ - -package cz.nic.tablexia.game.games.kidnapping.media; - - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; - -import cz.nic.tablexia.game.games.kidnapping.media.assets.TileType; - -/** - * Library of tile image paths - * - * @author lhoracek - */ -public class TileLibrary extends HashMap<TileType, String> { - - private static final long serialVersionUID = 7306787996311196671L; - private static final String TILES_DIR = "gfx/tiles/"; - - - public TileLibrary() { - for (TileType tile : TileType.values()) { - if (!containsKey(tile)) { - String path = TILES_DIR + tile.getName(); - put(tile, path); - } - } - } - - /** - * Metrod prepared for future. Supposed to filter only tiles used in map to speed up loading times - * - * @param tiles - * @return - */ - public Collection<String> getTileRecords(Collection<TileType> tiles) { - Set<String> paths = new HashSet<String>(); - for (TileType tile : tiles) { - paths.add(get(tiles)); - } - return paths; - } -} diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/SoundType.java b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/SoundType.java index d4c69cb8d..9d486341e 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/SoundType.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/SoundType.java @@ -1,28 +1,32 @@ -/******************************************************************************* - * Tablexia - * - * Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - ******************************************************************************/ +/** + * **************************************************************************** + * Tablexia + * <p/> + * Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz> + * <p/> + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * <p/> + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * <p/> + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * **************************************************************************** + */ package cz.nic.tablexia.game.games.kidnapping.media.assets; +import cz.nic.tablexia.game.common.media.AssetDescription; + /** * @author lhoracek */ -public enum SoundType { +public enum SoundType implements AssetDescription { SOUND_ERROR("error", SoundClass.SOUND, true); // @@ -32,23 +36,11 @@ public enum SoundType { private SoundType(String resource, SoundClass soundClass, boolean eager) { this.resource = resource; - this.eager = eager; - this.soundClass = soundClass; } - private final String resource; - private final boolean eager; - private final SoundClass soundClass; + private final String resource; public String getResource() { return resource; } - - public boolean isEager() { - return eager; - } - - public SoundClass getSoundClass() { - return soundClass; - } } diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureType.java b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureTypes.java similarity index 91% rename from core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureType.java rename to core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureTypes.java index 6b8c025c1..0b2cb6277 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureType.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TextureTypes.java @@ -21,10 +21,12 @@ package cz.nic.tablexia.game.games.kidnapping.media.assets; +import cz.nic.tablexia.game.common.media.AssetDescription; + /** * @author lhoracek */ -public enum TextureType { +public enum TextureTypes implements AssetDescription { POSITION_CURRENT("zde-jsi"), // OVERLAY("overlay"), // @@ -48,7 +50,7 @@ public enum TextureType { private final String resource; - private TextureType(String resource) { + private TextureTypes(String resource) { this.resource = resource; } diff --git a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TileType.java b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TileType.java index 9be071f28..5cdda7352 100644 --- a/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TileType.java +++ b/core/src/cz/nic/tablexia/game/games/kidnapping/media/assets/TileType.java @@ -2,10 +2,14 @@ package cz.nic.tablexia.game.games.kidnapping.media.assets; import java.util.Random; +import cz.nic.tablexia.game.common.media.AssetDescription; + /** * Created by lhoracek on 5/15/15. */ -public enum TileType { +public enum TileType implements AssetDescription { + + DOME1(1, 1, "domek1", 78), // DOME2(1, 1, "domek2", 78), // DOME3(1, 1, "domek3", 78), // @@ -23,7 +27,7 @@ public enum TileType { VILA3(1, 1, "vila3", 78), // VILA4(1, 1, "vila4", 78); // - + public static final String BASE_DIR = "tiles/"; private final int swSize, seSize; private final String name; private final int yOffset; @@ -43,8 +47,8 @@ public enum TileType { return seSize; } - public String getName() { - return name; + public String getResource() { + return BASE_DIR + name; } public int getyOffset() { diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/ShootingRangeGame.java b/core/src/cz/nic/tablexia/game/games/shooting_range/ShootingRangeGame.java index b64ff1249..199af4e02 100644 --- a/core/src/cz/nic/tablexia/game/games/shooting_range/ShootingRangeGame.java +++ b/core/src/cz/nic/tablexia/game/games/shooting_range/ShootingRangeGame.java @@ -5,8 +5,11 @@ import com.badlogic.gdx.scenes.scene2d.Actor; import java.util.List; import cz.nic.tablexia.game.AbstractTablexiaGame; -import cz.nic.tablexia.game.games.shooting_range.media.GfxLibrary; -import cz.nic.tablexia.game.games.shooting_range.media.SfxLibrary; +import cz.nic.tablexia.game.games.shooting_range.actors.Scene; +import cz.nic.tablexia.game.common.media.GfxLibrary; +import cz.nic.tablexia.game.common.media.SfxLibrary; +import cz.nic.tablexia.game.games.shooting_range.media.SoundType; +import cz.nic.tablexia.game.games.shooting_range.media.Textures; import cz.nic.tablexia.game.games.shooting_range.model.GameState; /** @@ -14,14 +17,16 @@ import cz.nic.tablexia.game.games.shooting_range.model.GameState; */ public class ShootingRangeGame extends AbstractTablexiaGame<GameState> { - private GfxLibrary gfxLibrary = new GfxLibrary(); - private SfxLibrary sfxLibrary = new SfxLibrary(); + private GfxLibrary gfxLibrary = new GfxLibrary(this, Textures.values()); + private SfxLibrary sfxLibrary = new SfxLibrary(this, SoundType.values()); private Actor watch; private Actor watchHand; private Actor carousel; private Actor scoreText; + Scene scene; + @Override protected void prepareScreenSoundAssetNames(List<String> soundsFileNames) { super.prepareScreenSoundAssetNames(soundsFileNames); @@ -30,19 +35,24 @@ public class ShootingRangeGame extends AbstractTablexiaGame<GameState> { @Override protected GameState prepareGameData() { - // TODO prepare round - GameState gameState = new GameState(getGameDifficulty(), getRandomAccess().getRandom()); + GameState gameState = new GameState(getGameDifficulty(), getRandom()); // TODO generate flower rows - return null; + return gameState; } @Override protected void gameLoaded() { super.gameLoaded(); + initScene(); + + // TODO start game + } + + private void initScene() { + getStage().addActor(scene = new Scene(gfxLibrary)); + scene.setBounds(0, getStage().getCamera().position.y - getStage().getHeight() / 2, getStage().getWidth(), getStage().getHeight()); // scaling viewport camera y-position adjustment // TODO prepare scene // TODO prepare carousel // TODO prepare stopwatch - - // TODO start game } } diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Frame.java b/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Frame.java deleted file mode 100644 index 4c095d77e..000000000 --- a/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Frame.java +++ /dev/null @@ -1,13 +0,0 @@ -package cz.nic.tablexia.game.games.shooting_range.actors; - -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.scenes.scene2d.ui.Image; - -/** - * Created by lhoracek on 6/23/15. - */ -public class Frame extends Image { - public Frame(Texture texture) { - super(texture); - } -} diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Scene.java b/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Scene.java new file mode 100644 index 000000000..dc6095543 --- /dev/null +++ b/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Scene.java @@ -0,0 +1,20 @@ +package cz.nic.tablexia.game.games.shooting_range.actors; + +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.ui.Stack; + +import cz.nic.tablexia.game.common.media.GfxLibrary; +import cz.nic.tablexia.game.games.shooting_range.media.Textures; + +/** + * Created by lhoracek on 6/23/15. + */ +public class Scene extends Stack { + private final Image frame; + private final Image background; + + public Scene(GfxLibrary gfxLibrary) { + add(background = new Image(gfxLibrary.getTextureRegion(Textures.BACKGROUND))); + add(frame = new Image(gfxLibrary.getTextureRegion(Textures.FRAME))); + } +} diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Target.java b/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Target.java index 1b36e68b6..e7df83650 100644 --- a/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Target.java +++ b/core/src/cz/nic/tablexia/game/games/shooting_range/actors/Target.java @@ -4,16 +4,16 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.scenes.scene2d.ui.Image; -import cz.nic.tablexia.game.games.shooting_range.media.TextureType; +import cz.nic.tablexia.game.games.shooting_range.media.Textures; import cz.nic.tablexia.game.games.shooting_range.model.Wave; /** * Created by lhoracek on 6/22/15. */ public class Target extends Image { - private final float startTime; - private TextureType textureType; - private final Wave wave; + private final float startTime; + private Textures textureType; + private final Wave wave; private boolean shot = false; private Sprite effect; private Sprite overlay; @@ -29,7 +29,7 @@ public class Target extends Image { }; } - public Target(float pX, float pY, float pWidth, float pHeight, Texture texture, Float startTime, Wave wave, TextureType textureType) { + public Target(float pX, float pY, float pWidth, float pHeight, Texture texture, Float startTime, Wave wave, Textures textureType) { this.startTime = startTime; this.textureType = textureType; this.wave = wave; @@ -47,11 +47,11 @@ public class Target extends Image { return startTime; } - public void setTextureType(TextureType textureType) { + public void setTextureType(Textures textureType) { this.textureType = textureType; } - public TextureType getTextureType() { + public Textures getTextureType() { return textureType; } diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/media/GfxLibrary.java b/core/src/cz/nic/tablexia/game/games/shooting_range/media/GfxLibrary.java deleted file mode 100644 index b326d8e6b..000000000 --- a/core/src/cz/nic/tablexia/game/games/shooting_range/media/GfxLibrary.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * **************************************************************************** - * Tablexia - * <p/> - * Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz> - * <p/> - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * <p/> - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * <p/> - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * **************************************************************************** - */ - -package cz.nic.tablexia.game.games.shooting_range.media; - -import java.util.HashMap; - - -/** - * Library of all kidnapping assets except tiles - * - * @author lhoracek - */ -public class GfxLibrary extends HashMap<TextureType, String> { - - private static final long serialVersionUID = -4016629019721509061L; - private static final String TEXTURE_DIR = "gfx/"; - - - public GfxLibrary() { - super(); - for (TextureType textureType : TextureType.values()) { - String path = TEXTURE_DIR + textureType.getResource(); - put(textureType, path); - } - } -} diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/media/SoundType.java b/core/src/cz/nic/tablexia/game/games/shooting_range/media/SoundType.java index a95c9f437..e0414951a 100644 --- a/core/src/cz/nic/tablexia/game/games/shooting_range/media/SoundType.java +++ b/core/src/cz/nic/tablexia/game/games/shooting_range/media/SoundType.java @@ -21,10 +21,12 @@ package cz.nic.tablexia.game.games.shooting_range.media; +import cz.nic.tablexia.game.common.media.AssetDescription; + /** * @author lhoracek */ -public enum SoundType { +public enum SoundType implements AssetDescription { BELL("bell"), // CAROUSEL_1("carousel_1"), // diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/media/TextureType.java b/core/src/cz/nic/tablexia/game/games/shooting_range/media/TextureType.java deleted file mode 100644 index fc7c323e4..000000000 --- a/core/src/cz/nic/tablexia/game/games/shooting_range/media/TextureType.java +++ /dev/null @@ -1,79 +0,0 @@ -package cz.nic.tablexia.game.games.shooting_range.media; - -/** - * Created by lhoracek on 6/22/15. - */ -public enum TextureType { - - WATCH("watch.png"), // - WATCH_HAND("watch_hand.png"), // - - CAROUSEL("carousel.png"), // - - BACKGROUND("background.png"), // - FRAME("frame.png"), // - - BOX_BAD("box_bad.png"), // - BOX_GOOD("bokx_good.png"), // - - WAVE_1("plan_2.png"), // - WAVE_2("plan_1.png"), // - WAVE_3("plan_3.png"), // - - FLOWER_1("flowers/1.png"), // - FLOWER_2("flowers/2.png"), // - FLOWER_3("flowers/3.png"), // - FLOWER_4("flowers/4.png"), // - FLOWER_5("flowers/5.png"), // - FLOWER_6("flowers/6.png"), // - FLOWER_7("flowers/7.png"), // - FLOWER_8("flowers/8.png"), // - FLOWER_9("flowers/9.png"), // - FLOWER_10("flowers/10.png"), // - FLOWER_11("flowers/11.png"), // - FLOWER_12("flowers/12.png"), // - FLOWER_13("flowers/13.png"), // - FLOWER_14("flowers/14.png"), // - FLOWER_15("flowers/15.png"), // - FLOWER_16("flowers/16.png"), // - FLOWER_17("flowers/17.png"), // - FLOWER_18("flowers/18.png"), // - FLOWER_19("flowers/19.png"), // - FLOWER_20("flowers/20.png"), // - FLOWER_21("flowers/21.png"), // - FLOWER_22("flowers/22.png"), // - FLOWER_23("flowers/23.png"), // - FLOWER_24("flowers/24.png"), // - - BOX_SMOKE_1("effects/1smoke.png"), // - BOX_SMOKE_2("effects/2smoke.png"), // - BOX_SMOKE_3("effects/3smoke.png"), // - BOX_SMOKE_4("effects/4smoke.png"), // - BOX_SMOKE_5("effects/5smoke.png"), // - BOX_HIT("effects/good_plus1.png"), // - BOX_TIME_MINUS_7("effects/bad_minus7.png"), // - BOX_TIME_MINUS_5("effects/bad_minus5.png"), // - BOX_TIME_PLUS_5("effects/good_plus5.png"), // - BOX_TIME_PLUS_7("effects/good_plus7.png"), // - BOX_SPEED_UP("effects/bad_fast.png"), // - BOX_SPEED_DOWN("effects/good_slow.png"), // - - ; // - - public static final TextureType[] BOXES = { BOX_BAD, BOX_GOOD }; - public static final TextureType[] EFFECTS = { BOX_SMOKE_1, BOX_SMOKE_2, BOX_SMOKE_3, BOX_SMOKE_4, BOX_SMOKE_5, BOX_TIME_MINUS_5, BOX_TIME_MINUS_7, BOX_TIME_PLUS_5, BOX_TIME_PLUS_7, BOX_SPEED_UP, BOX_SPEED_DOWN }; - public static final TextureType[] FLOWERS_LEVEL_EASY = { FLOWER_1, FLOWER_6, FLOWER_9, FLOWER_13, FLOWER_17, FLOWER_21 }; - public static final TextureType[] FLOWERS_LEVEL_MEDIUM = { FLOWER_2, FLOWER_4, FLOWER_5, FLOWER_7, FLOWER_11, FLOWER_12, FLOWER_14, FLOWER_15, FLOWER_17, FLOWER_19, FLOWER_21, FLOWER_22 }; - public static final TextureType[] FLOWERS_LEVEL_HARD = { FLOWER_1, FLOWER_2, FLOWER_3, FLOWER_4, FLOWER_5, FLOWER_6, FLOWER_7, FLOWER_8, FLOWER_9, FLOWER_10, FLOWER_11, FLOWER_12, FLOWER_13, FLOWER_14, FLOWER_15, FLOWER_16, FLOWER_17, FLOWER_18, FLOWER_19, FLOWER_20, FLOWER_21, FLOWER_22, FLOWER_23, FLOWER_24 }; - - private final String resource; - - private TextureType(String resource) { - this.resource = resource; - - } - - public String getResource() { - return resource; - } -} \ No newline at end of file diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/media/Textures.java b/core/src/cz/nic/tablexia/game/games/shooting_range/media/Textures.java new file mode 100644 index 000000000..9d097c406 --- /dev/null +++ b/core/src/cz/nic/tablexia/game/games/shooting_range/media/Textures.java @@ -0,0 +1,80 @@ +package cz.nic.tablexia.game.games.shooting_range.media; + +import cz.nic.tablexia.game.common.media.AssetDescription; + +/** + * Created by lhoracek on 6/22/15. + */ +public enum Textures implements AssetDescription { + + WATCH("watch"), // + WATCH_HAND("watch_hand"), // + + CAROUSEL("carousel"), // + + BACKGROUND("background"), // + FRAME("frame"), // + + BOX_BAD("box_bad"), // + BOX_GOOD("box_good"), // + + WAVE_1("plan_2"), // + WAVE_2("plan_1"), // + WAVE_3("plan_3"), // + + FLOWER_1("flowers/1"), // + FLOWER_2("flowers/2"), // + FLOWER_3("flowers/3"), // + FLOWER_4("flowers/4"), // + FLOWER_5("flowers/5"), // + FLOWER_6("flowers/6"), // + FLOWER_7("flowers/7"), // + FLOWER_8("flowers/8"), // + FLOWER_9("flowers/9"), // + FLOWER_10("flowers/10"), // + FLOWER_11("flowers/11"), // + FLOWER_12("flowers/12"), // + FLOWER_13("flowers/13"), // + FLOWER_14("flowers/14"), // + FLOWER_15("flowers/15"), // + FLOWER_16("flowers/16"), // + FLOWER_17("flowers/17"), // + FLOWER_18("flowers/18"), // + FLOWER_19("flowers/19"), // + FLOWER_20("flowers/20"), // + FLOWER_21("flowers/21"), // + FLOWER_22("flowers/22"), // + FLOWER_23("flowers/23"), // + FLOWER_24("flowers/24"), // + + BOX_SMOKE_1("effects/1smoke"), // + BOX_SMOKE_2("effects/2smoke"), // + BOX_SMOKE_3("effects/3smoke"), // + BOX_SMOKE_4("effects/4smoke"), // + BOX_SMOKE_5("effects/5smoke"), // + BOX_HIT("effects/good_plus1"), // + BOX_TIME_MINUS_7("effects/bad_minus7"), // + BOX_TIME_MINUS_5("effects/bad_minus5"), // + BOX_TIME_PLUS_5("effects/good_plus5"), // + BOX_TIME_PLUS_7("effects/good_plus7"), // + BOX_SPEED_UP("effects/bad_fast"), // + BOX_SPEED_DOWN("effects/good_slow"), // + + ; // + + public static final Textures[] BOXES = {BOX_BAD, BOX_GOOD}; + public static final Textures[] EFFECTS = {BOX_SMOKE_1, BOX_SMOKE_2, BOX_SMOKE_3, BOX_SMOKE_4, BOX_SMOKE_5, BOX_TIME_MINUS_5, BOX_TIME_MINUS_7, BOX_TIME_PLUS_5, BOX_TIME_PLUS_7, BOX_SPEED_UP, BOX_SPEED_DOWN}; + public static final Textures[] FLOWERS_LEVEL_EASY = {FLOWER_1, FLOWER_6, FLOWER_9, FLOWER_13, FLOWER_17, FLOWER_21}; + public static final Textures[] FLOWERS_LEVEL_MEDIUM = {FLOWER_2, FLOWER_4, FLOWER_5, FLOWER_7, FLOWER_11, FLOWER_12, FLOWER_14, FLOWER_15, FLOWER_17, FLOWER_19, FLOWER_21, FLOWER_22}; + public static final Textures[] FLOWERS_LEVEL_HARD = {FLOWER_1, FLOWER_2, FLOWER_3, FLOWER_4, FLOWER_5, FLOWER_6, FLOWER_7, FLOWER_8, FLOWER_9, FLOWER_10, FLOWER_11, FLOWER_12, FLOWER_13, FLOWER_14, FLOWER_15, FLOWER_16, FLOWER_17, FLOWER_18, FLOWER_19, FLOWER_20, FLOWER_21, FLOWER_22, FLOWER_23, FLOWER_24}; + + private final String resource; + + private Textures(String resource) { + this.resource = resource; + } + + public String getResource() { + return resource; + } +} \ No newline at end of file diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/tools/TargetGenerator.java b/core/src/cz/nic/tablexia/game/games/shooting_range/tools/TargetGenerator.java index 783202c5a..879816468 100644 --- a/core/src/cz/nic/tablexia/game/games/shooting_range/tools/TargetGenerator.java +++ b/core/src/cz/nic/tablexia/game/games/shooting_range/tools/TargetGenerator.java @@ -8,7 +8,7 @@ import java.util.Map; import java.util.Random; import cz.nic.tablexia.game.difficulty.GameDifficulty; -import cz.nic.tablexia.game.games.shooting_range.media.TextureType; +import cz.nic.tablexia.game.games.shooting_range.media.Textures; import cz.nic.tablexia.game.games.shooting_range.actors.Target; import cz.nic.tablexia.game.games.shooting_range.model.Wave; @@ -35,8 +35,8 @@ public class TargetGenerator { this.gameDifficulty = gameDifficulty; } - public TextureType getRandomFlowerType(GameDifficulty gameDifficulty) { - List<TextureType> textureTypeBag = getTextureTypeBag(gameDifficulty); + public Textures getRandomFlowerType(GameDifficulty gameDifficulty) { + List<Textures> textureTypeBag = getTextureTypeBag(gameDifficulty); int random = (int) (Math.random() * textureTypeBag.size()); return textureTypeBag.get(random); } @@ -47,18 +47,18 @@ public class TargetGenerator { return lastTargetsForWave.get(wave); } - public Target addNewTargetToWave(Wave wave, TextureType requiredTextureType) { + public Target addNewTargetToWave(Wave wave, Textures requiredTextureType) { Target prevLastTarget = getLastTargetInWave(wave); float targetPeriod = wave.getRunningTime() / wave.getFlowerOnScreen(); return addNewTargetToWave(wave, requiredTextureType, prevLastTarget.getStartTime() + targetPeriod); } - public Target addNewTargetToWave(Wave wave, TextureType requiredTextureType, float startTime) { + public Target addNewTargetToWave(Wave wave, Textures requiredTextureType, float startTime) { return addNewTargetToWave(wave, requiredTextureType, startTime, true); } - public Target addNewTargetToWave(Wave wave, TextureType requiredTextureType, float startTime, boolean asLast) { - List<TextureType> textureTypeBag = new ArrayList<TextureType>(requiredTextureType == null ? getTextureTypeBag(gameDifficulty) : Arrays.asList((new TextureType[]{requiredTextureType}))); + public Target addNewTargetToWave(Wave wave, Textures requiredTextureType, float startTime, boolean asLast) { + List<Textures> textureTypeBag = new ArrayList<Textures>(requiredTextureType == null ? getTextureTypeBag(gameDifficulty) : Arrays.asList((new Textures[]{requiredTextureType}))); Target target = getRandomTarget(textureTypeBag, startTime, wave); if (asLast) { lastTargetsForWave.put(wave, target); @@ -71,7 +71,7 @@ public class TargetGenerator { */ public List<Target> generateFlowerRow(Wave wave) { List<Target> flowers = new ArrayList<Target>(); - List<TextureType> textureTypeBag = new ArrayList<TextureType>(getTextureTypeBag(gameDifficulty)); + List<Textures> textureTypeBag = new ArrayList<Textures>(getTextureTypeBag(gameDifficulty)); int flowerNumber = wave.getFlowerOnScreen(); float targetPeriod = wave.getRunningTime() / wave.getFlowerOnScreen(); @@ -88,22 +88,22 @@ public class TargetGenerator { return flowers; } - private TextureType getRandomBoxType() { + private Textures getRandomBoxType() { float boxTypeIndex = random.nextFloat(); if ((gameDifficulty == GameDifficulty.EASY) && (boxTypeIndex > EASY_GOOD_PROBABILITY)) { - return TextureType.BOX_BAD; + return Textures.BOX_BAD; } else if ((gameDifficulty == GameDifficulty.MEDIUM) && (boxTypeIndex > HARD_GOOD_PROBABILITY)) { - return TextureType.BOX_BAD; + return Textures.BOX_BAD; } else if ((gameDifficulty == GameDifficulty.HARD) && (boxTypeIndex > HARD_GOOD_PROBABILITY)) { - return TextureType.BOX_BAD; + return Textures.BOX_BAD; } - return TextureType.BOX_GOOD; + return Textures.BOX_GOOD; } - private Target getRandomTarget(List<TextureType> textureTypeBag, float startTime, Wave wave) { + private Target getRandomTarget(List<Textures> textureTypeBag, float startTime, Wave wave) { float boxIndex = random.nextFloat(); - TextureType textureType = getRandomBoxType(); + Textures textureType = getRandomBoxType(); if (boxIndex > getBoxProbability(wave.getDifficulty())) { int random = (int) (Math.random() * textureTypeBag.size()); textureType = textureTypeBag.get(random); @@ -128,14 +128,14 @@ public class TargetGenerator { } } - private List<TextureType> getTextureTypeBag(GameDifficulty gameDifficulty) { + private List<Textures> getTextureTypeBag(GameDifficulty gameDifficulty) { switch (gameDifficulty) { case EASY: - return Arrays.asList(TextureType.FLOWERS_LEVEL_EASY); + return Arrays.asList(Textures.FLOWERS_LEVEL_EASY); case MEDIUM: - return Arrays.asList(TextureType.FLOWERS_LEVEL_MEDIUM); + return Arrays.asList(Textures.FLOWERS_LEVEL_MEDIUM); case HARD: - return Arrays.asList(TextureType.FLOWERS_LEVEL_HARD); + return Arrays.asList(Textures.FLOWERS_LEVEL_HARD); default: throw new IllegalStateException("Unknown difficulty"); } -- GitLab