├── .github ├── dependabot.yml └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle.kts ├── core ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── gdx │ │ │ └── game │ │ │ ├── GdxGame.java │ │ │ ├── animation │ │ │ └── AnimatedImage.java │ │ │ ├── audio │ │ │ ├── AudioManager.java │ │ │ ├── AudioObserver.java │ │ │ └── AudioSubject.java │ │ │ ├── battle │ │ │ ├── BattleConversation.java │ │ │ ├── BattleHUD.java │ │ │ ├── BattleInventoryUI.java │ │ │ ├── BattleObserver.java │ │ │ ├── BattleState.java │ │ │ ├── BattleStatusUI.java │ │ │ ├── BattleSubject.java │ │ │ ├── BattleUI.java │ │ │ └── BattleUtils.java │ │ │ ├── camera │ │ │ └── CameraStyles.java │ │ │ ├── common │ │ │ ├── Constats.java │ │ │ ├── DefaultControlsMap.java │ │ │ └── UtilityClass.java │ │ │ ├── component │ │ │ ├── Component.java │ │ │ ├── ComponentObserver.java │ │ │ ├── ComponentSubject.java │ │ │ ├── GraphicsComponent.java │ │ │ ├── InputComponent.java │ │ │ └── PhysicsComponent.java │ │ │ ├── dialog │ │ │ ├── Conversation.java │ │ │ ├── ConversationChoice.java │ │ │ ├── ConversationGraph.java │ │ │ ├── ConversationGraphObserver.java │ │ │ ├── ConversationGraphSubject.java │ │ │ └── ConversationUI.java │ │ │ ├── entities │ │ │ ├── Entity.java │ │ │ ├── EntityBonus.java │ │ │ ├── EntityConfig.java │ │ │ ├── EntityFactory.java │ │ │ ├── npc │ │ │ │ ├── NPCGraphicsComponent.java │ │ │ │ ├── NPCInputComponent.java │ │ │ │ ├── NPCPhysicsComponent.java │ │ │ │ └── enemy │ │ │ │ │ └── EnemyPhysicsComponent.java │ │ │ └── player │ │ │ │ ├── CharacterRecord.java │ │ │ │ ├── PlayerGraphicsComponent.java │ │ │ │ ├── PlayerHUD.java │ │ │ │ ├── PlayerInputComponent.java │ │ │ │ ├── PlayerPhysicsComponent.java │ │ │ │ └── characterClass │ │ │ │ ├── ClassObserver.java │ │ │ │ ├── ClassSubject.java │ │ │ │ └── tree │ │ │ │ ├── Node.java │ │ │ │ └── Tree.java │ │ │ ├── inventory │ │ │ ├── InventoryObserver.java │ │ │ ├── InventorySubject.java │ │ │ ├── InventoryUI.java │ │ │ ├── item │ │ │ │ ├── InventoryItem.java │ │ │ │ ├── InventoryItemFactory.java │ │ │ │ └── InventoryItemLocation.java │ │ │ ├── set │ │ │ │ ├── EquipmentSet.java │ │ │ │ └── EquipmentSetFactory.java │ │ │ ├── slot │ │ │ │ ├── InventorySlot.java │ │ │ │ ├── InventorySlotObserver.java │ │ │ │ ├── InventorySlotSource.java │ │ │ │ ├── InventorySlotSubject.java │ │ │ │ ├── InventorySlotTarget.java │ │ │ │ ├── InventorySlotTooltip.java │ │ │ │ └── InventorySlotTooltipListener.java │ │ │ └── store │ │ │ │ ├── StoreInventoryObserver.java │ │ │ │ ├── StoreInventorySubject.java │ │ │ │ └── StoreInventoryUI.java │ │ │ ├── manager │ │ │ ├── AnimationManager.java │ │ │ ├── PreferenceManager.java │ │ │ └── ResourceManager.java │ │ │ ├── map │ │ │ ├── Map.java │ │ │ ├── MapFactory.java │ │ │ ├── MapManager.java │ │ │ └── worldMap │ │ │ │ ├── Topple.java │ │ │ │ └── ToppleRoad1.java │ │ │ ├── profile │ │ │ ├── ProfileManager.java │ │ │ ├── ProfileObserver.java │ │ │ └── ProfileSubject.java │ │ │ ├── quest │ │ │ ├── FetchQuestTaskHandler.java │ │ │ ├── QuestGraph.java │ │ │ ├── QuestTask.java │ │ │ ├── QuestTaskDependency.java │ │ │ ├── QuestTaskHandler.java │ │ │ └── QuestUI.java │ │ │ ├── screen │ │ │ ├── BaseScreen.java │ │ │ ├── BattleScreen.java │ │ │ ├── CharacterSelectionScreen.java │ │ │ ├── GameOverScreen.java │ │ │ ├── GameScreen.java │ │ │ ├── MenuLoadGameScreen.java │ │ │ ├── MenuNewGameScreen.java │ │ │ ├── MenuScreen.java │ │ │ ├── OptionScreen.java │ │ │ ├── TransitionScreen.java │ │ │ ├── cutscene │ │ │ │ ├── CreatorIntroScreen.java │ │ │ │ └── CutSceneBaseScreen.java │ │ │ └── transition │ │ │ │ ├── ImmediateModeRendererUtils.java │ │ │ │ ├── TimeTransition.java │ │ │ │ └── effects │ │ │ │ ├── FadeInTransitionEffect.java │ │ │ │ ├── FadeOutTransitionEffect.java │ │ │ │ ├── RotationTransitionEffect.java │ │ │ │ └── TransitionEffect.java │ │ │ └── status │ │ │ ├── LevelTable.java │ │ │ ├── StatsUpUI.java │ │ │ ├── StatusObserver.java │ │ │ ├── StatusSubject.java │ │ │ └── StatusUI.java │ └── resources │ │ ├── asset │ │ ├── background │ │ │ ├── battleBackground_meadow.png │ │ │ └── natureBackground_frames_sheet.png │ │ ├── data │ │ │ ├── default.fnt │ │ │ ├── default.png │ │ │ ├── uiskin.atlas │ │ │ ├── uiskin.json │ │ │ └── uiskin.png │ │ ├── map │ │ │ ├── Topple.tmx │ │ │ ├── Topple_Road_1.tmx │ │ │ ├── mana1.png │ │ │ ├── mana1.tsx │ │ │ ├── mana2.png │ │ │ ├── mana2.tsx │ │ │ ├── mana3.png │ │ │ ├── mana3.tsx │ │ │ ├── swordofmana_map1.png │ │ │ └── swordofmana_map1.tsx │ │ ├── textures.atlas │ │ ├── textures.png │ │ └── tool │ │ │ └── cursor.png │ │ ├── classes │ │ ├── tree_cleric.json │ │ ├── tree_grappler.json │ │ ├── tree_mage.json │ │ ├── tree_thief.json │ │ └── tree_warrior.json │ │ ├── conversations │ │ ├── conversation001.json │ │ ├── conversation002.json │ │ ├── conversation003.json │ │ ├── conversation004.json │ │ ├── conversation005.json │ │ ├── conversation006.json │ │ ├── conversation007.json │ │ ├── conversation_courtesy.json │ │ ├── quest_finished.json │ │ ├── return_quest.json │ │ └── testConversation001.json │ │ ├── entities │ │ └── hero │ │ │ └── hero_1_walking_up.png │ │ ├── fonts │ │ ├── SDS_6x6.fnt │ │ ├── SDS_6x6.hiero │ │ ├── SDS_6x6.png │ │ ├── SDS_6x6_small.fnt │ │ ├── SDS_6x6_small.hiero │ │ ├── SDS_6x6_small.png │ │ ├── pixel.fnt │ │ ├── sans_serif_18.fnt │ │ ├── sans_serif_18.hiero │ │ └── sans_serif_18.png │ │ ├── logback.xml │ │ ├── music │ │ ├── Challenge.mp3 │ │ ├── Dwarves'_Theme.mp3 │ │ ├── Requiem.mp3 │ │ ├── Rising_Sun.mp3 │ │ └── Village.mp3 │ │ ├── quests │ │ ├── quest001.json │ │ ├── quest002.json │ │ └── quest003.json │ │ ├── scripts │ │ ├── enemies.json │ │ ├── environmental_entities.json │ │ ├── equipment_sets.json │ │ ├── inventory_items.json │ │ ├── level_tables.json │ │ ├── player_cleric.json │ │ ├── player_grappler.json │ │ ├── player_mage.json │ │ ├── player_thief.json │ │ ├── player_warrior.json │ │ ├── quest001_task002.json │ │ ├── quest001_task003.json │ │ ├── quest002_task002.json │ │ ├── quest003_task002.json │ │ ├── town_blacksmith.json │ │ ├── town_folk.json │ │ ├── town_guard_walking.json │ │ ├── town_innkeeper.json │ │ └── town_mage.json │ │ ├── skins │ │ ├── items.atlas │ │ ├── items.png │ │ ├── items.proj │ │ ├── statusui.atlas │ │ ├── statusui.json │ │ ├── statusui.png │ │ └── statusui.proj │ │ └── sprites │ │ ├── characters │ │ ├── Cleric.png │ │ ├── Demon0.png │ │ ├── Demon1.png │ │ ├── Grappler.png │ │ ├── Mage.png │ │ ├── Paladin.png │ │ ├── Player0.png │ │ ├── Player1.png │ │ ├── Thief.png │ │ └── Warrior.png │ │ └── items │ │ ├── Ammo.png │ │ ├── Amulet.png │ │ ├── Armor.png │ │ ├── Book.png │ │ ├── Boot.png │ │ ├── Chest0.png │ │ ├── Chest1.png │ │ ├── Flesh.png │ │ ├── Food.png │ │ ├── Glove.png │ │ ├── Hat.png │ │ ├── Key.png │ │ ├── Light.png │ │ ├── LongWep.png │ │ ├── MedWep.png │ │ ├── Money.png │ │ ├── Music.png │ │ ├── Potion.png │ │ ├── Ring.png │ │ ├── Rock.png │ │ ├── Scroll.png │ │ ├── Shield.png │ │ ├── ShortWep.png │ │ ├── Tool.png │ │ └── Wand.png │ └── test │ ├── java │ └── com │ │ └── gdx │ │ └── game │ │ ├── GdxRunner.java │ │ ├── audio │ │ └── AudioManagerTest.java │ │ ├── battle │ │ ├── BattleHUDTest.java │ │ ├── BattleInventoryUITest.java │ │ ├── BattleStateTest.java │ │ ├── BattleStatusUITest.java │ │ ├── BattleUITest.java │ │ └── BattleUtilsTest.java │ │ ├── component │ │ └── PhysicsComponentTest.java │ │ ├── dialog │ │ ├── ConversationGraphTest.java │ │ └── ConversationUITest.java │ │ ├── entities │ │ ├── EntityFactoryTest.java │ │ ├── npc │ │ │ ├── NPCGraphicsComponentTest.java │ │ │ └── enemy │ │ │ │ └── EnemyPhysicsComponentTest.java │ │ └── player │ │ │ ├── PlayerGraphicsComponentTest.java │ │ │ ├── PlayerHUDTest.java │ │ │ ├── PlayerPhysicsComponentTest.java │ │ │ └── characterClass │ │ │ └── tree │ │ │ └── TreeTest.java │ │ ├── inventory │ │ ├── InventoryItemFactoryTest.java │ │ ├── InventoryItemLocationTest.java │ │ ├── InventoryItemTest.java │ │ ├── InventoryUITest.java │ │ ├── slot │ │ │ └── InventorySlotTest.java │ │ └── store │ │ │ └── StoreInventoryUITest.java │ │ ├── manager │ │ ├── AnimationManagerTest.java │ │ └── ResourceManagerTest.java │ │ ├── map │ │ ├── MapFactoryTest.java │ │ ├── MapManagerTest.java │ │ └── worldMap │ │ │ ├── ToppleRoad1Test.java │ │ │ └── ToppleTest.java │ │ ├── profile │ │ └── ProfileManagerTest.java │ │ ├── quest │ │ ├── QuestGraphTest.java │ │ ├── QuestTaskTest.java │ │ └── QuestUITest.java │ │ ├── screen │ │ ├── BattleScreenTest.java │ │ ├── CharacterSelectionScreenTest.java │ │ ├── GameOverScreenTest.java │ │ ├── MenuLoadGameScreenTest.java │ │ ├── MenuNewGameScreenTest.java │ │ ├── MenuScreenTest.java │ │ ├── OptionScreenTest.java │ │ ├── cutscene │ │ │ └── CreatorIntroScreenTest.java │ │ └── transition │ │ │ ├── ImmediateModeRendererUtilsTest.java │ │ │ └── TimeTransitionTest.java │ │ └── status │ │ ├── LevelTableTest.java │ │ ├── StatsUpUITest.java │ │ └── StatusUITest.java │ └── resources │ ├── classes │ └── tree_warrior.json │ └── entities │ └── hero │ └── hero_1_walking_up.png ├── desktop ├── build.gradle.kts └── src │ └── main │ ├── java │ └── com │ │ └── gdx │ │ └── game │ │ └── desktop │ │ └── DesktopLauncher.java │ └── resources │ └── demo │ ├── battle_demo.gif │ ├── demo.gif │ ├── demo_new_DA.gif │ └── demo_new_DA_battle.gif ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle.kts /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | labels: 8 | - "dependencies" 9 | 10 | - package-ecosystem: gradle 11 | directory: "/" 12 | schedule: 13 | interval: weekly 14 | labels: 15 | - "dependencies" 16 | open-pull-requests-limit: 20 17 | groups: 18 | gdx: 19 | patterns: 20 | - "com.badlogicgames.gdx*" 21 | gdx-vfx: 22 | patterns: 23 | - "com.crashinvaders.vfx*" 24 | junit-jupiter: 25 | patterns: 26 | - "org.junit.jupiter*" 27 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build Master 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Set up JDK 17 16 | uses: actions/setup-java@v4 17 | with: 18 | java-version: '17' 19 | distribution: 'adopt' 20 | - name: Validate Gradle wrapper 21 | uses: gradle/actions/wrapper-validation@v4 22 | - name: Cache Gradle packages 23 | uses: actions/cache@v4 24 | with: 25 | path: | 26 | ~/.gradle/caches 27 | ~/.gradle/wrapper 28 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 29 | restore-keys: | 30 | ${{ runner.os }}-gradle- 31 | - name: Build with Gradle 32 | run: ./gradlew build 33 | - name: Cleanup Gradle Cache 34 | # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. 35 | # Restoring these files from a GitHub Actions cache might cause problems for future builds. 36 | run: | 37 | rm -f ~/.gradle/caches/modules-2/modules-2.lock 38 | rm -f ~/.gradle/caches/modules-2/gc.properties 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /build/ 3 | lib/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | *.hprof 6 | .DS_Store 7 | *.sav 8 | **/settings 9 | 10 | ### STS ### 11 | .apt_generated 12 | .classpath 13 | .factorypath 14 | .project 15 | .settings 16 | .springBeans 17 | 18 | ### IntelliJ IDEA ### 19 | .idea 20 | *.iws 21 | *.iml 22 | *.ipr 23 | out/ 24 | 25 | ### NetBeans ### 26 | nbproject/private/ 27 | build/ 28 | nbbuild/ 29 | dist/ 30 | nbdist/ 31 | .nb-gradle/ 32 | 33 | ### VisualStudioCode ### 34 | .vscode/* 35 | .history 36 | bin/ -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | java 3 | `java-library` 4 | } 5 | 6 | allprojects { 7 | 8 | version = "2.6.1" 9 | 10 | apply(plugin = "java") 11 | apply(plugin = "java-library") 12 | 13 | tasks.named("test") { 14 | useJUnitPlatform() 15 | } 16 | 17 | repositories { 18 | mavenCentral() //keep an eye on this, see libgdx 1.10.0 19 | } 20 | 21 | dependencies { 22 | testImplementation(rootProject.libs.bundles.junit) 23 | testImplementation(rootProject.libs.mockito) 24 | testImplementation(rootProject.libs.assertj) 25 | testRuntimeOnly(rootProject.libs.junit.jupiter.engine) 26 | } 27 | } 28 | 29 | project(":desktop") { 30 | 31 | repositories { 32 | mavenCentral() 33 | } 34 | 35 | dependencies { 36 | implementation(project(":core")) 37 | implementation(rootProject.libs.gdx.lwjgl3) 38 | implementation(variantOf(rootProject.libs.gdx.freetype.platform) { classifier("natives-desktop") }) 39 | } 40 | } 41 | 42 | project(":core") { 43 | 44 | repositories { 45 | mavenCentral() 46 | } 47 | 48 | dependencies { 49 | implementation(rootProject.libs.gdx) 50 | implementation(variantOf(rootProject.libs.gdx.platform) { classifier("natives-desktop") }) 51 | implementation(rootProject.libs.bundles.gdx.vfx) 52 | implementation(rootProject.libs.logback) 53 | testImplementation(rootProject.libs.gdx.backend.headless) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/build.gradle.kts: -------------------------------------------------------------------------------- 1 | apply(plugin = "java") 2 | 3 | java { 4 | sourceCompatibility = JavaVersion.VERSION_17 5 | } 6 | 7 | configure { 8 | named("main") { 9 | java.srcDir("src/java/") 10 | resources.srcDir("src/resources") 11 | } 12 | named("test") { 13 | java.srcDir("src/java/") 14 | } 15 | } 16 | 17 | tasks { 18 | compileJava { 19 | options.encoding = "UTF-8" 20 | } 21 | compileTestJava { 22 | options.encoding = "UTF-8" 23 | } 24 | } -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/GdxGame.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game; 2 | 3 | import com.badlogic.gdx.Game; 4 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 5 | import com.gdx.game.manager.PreferenceManager; 6 | import com.gdx.game.manager.ResourceManager; 7 | import com.gdx.game.screen.CharacterSelectionScreen; 8 | import com.gdx.game.screen.GameScreen; 9 | import com.gdx.game.screen.MenuScreen; 10 | 11 | public class GdxGame extends Game { 12 | private SpriteBatch batch; 13 | private ResourceManager resourceManager; 14 | private PreferenceManager preferenceManager = new PreferenceManager(); 15 | private MenuScreen menuScreen; 16 | private CharacterSelectionScreen characterSelectionScreen; 17 | private GameScreen gameScreen; 18 | 19 | public SpriteBatch getBatch() { 20 | return batch; 21 | } 22 | 23 | public MenuScreen getMenuScreen() { 24 | return menuScreen; 25 | } 26 | 27 | public CharacterSelectionScreen getCharacterSelectionScreen() { 28 | return characterSelectionScreen; 29 | } 30 | 31 | public GameScreen getGameScreen() { 32 | return gameScreen; 33 | } 34 | 35 | public void setGameScreen(GameScreen gameScreen) { 36 | this.gameScreen = gameScreen; 37 | } 38 | 39 | public PreferenceManager getPreferenceManager() { 40 | return preferenceManager; 41 | } 42 | 43 | public void create() { 44 | batch = new SpriteBatch(); 45 | resourceManager = new ResourceManager(); 46 | 47 | menuScreen = new MenuScreen(this, resourceManager); 48 | characterSelectionScreen = new CharacterSelectionScreen(this, resourceManager); 49 | 50 | this.setScreen(menuScreen); 51 | } 52 | 53 | @Override 54 | public void dispose() { 55 | super.dispose(); 56 | batch.dispose(); 57 | menuScreen.dispose(); 58 | characterSelectionScreen.dispose(); 59 | gameScreen.dispose(); 60 | resourceManager.dispose(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/animation/AnimatedImage.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.animation; 2 | 3 | import com.badlogic.gdx.graphics.g2d.Animation; 4 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 5 | import com.badlogic.gdx.scenes.scene2d.Action; 6 | import com.badlogic.gdx.scenes.scene2d.ui.Image; 7 | import com.badlogic.gdx.scenes.scene2d.utils.Drawable; 8 | import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; 9 | import com.badlogic.gdx.utils.Align; 10 | import com.badlogic.gdx.utils.Scaling; 11 | import com.gdx.game.entities.Entity; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | 15 | public class AnimatedImage extends Image { 16 | 17 | private static final Logger LOGGER = LoggerFactory.getLogger(AnimatedImage.class); 18 | private float frameTime = 0; 19 | protected Entity entity; 20 | private Entity.AnimationType currentAnimationType = Entity.AnimationType.IDLE; 21 | 22 | public AnimatedImage() { 23 | super(); 24 | } 25 | 26 | public Entity getEntity() { 27 | return entity; 28 | } 29 | 30 | public void setEntity(Entity entity) { 31 | this.entity = entity; 32 | //set default 33 | setCurrentAnimation(Entity.AnimationType.IDLE); 34 | } 35 | 36 | public Entity.AnimationType getCurrentAnimationType() { 37 | return this.currentAnimationType; 38 | } 39 | 40 | public void setCurrentAnimation(Entity.AnimationType animationType){ 41 | Animation animation = entity.getAnimation(animationType); 42 | if ( animation == null ){ 43 | LOGGER.debug("Animation type {} does not exist!", animationType.toString()); 44 | return; 45 | } 46 | 47 | this.currentAnimationType = animationType; 48 | this.setDrawable(new TextureRegionDrawable(animation.getKeyFrame(0))); 49 | this.setScaling(Scaling.stretch); 50 | this.setAlign(Align.center); 51 | } 52 | 53 | @Override 54 | public void act(float delta) { 55 | super.act(delta); 56 | 57 | Drawable drawable = getDrawable(); 58 | if (drawable == null) { 59 | //Gdx.app.debug(TAG, "Drawable is NULL!"); 60 | return; 61 | } 62 | frameTime = (frameTime + delta)%5; 63 | TextureRegion currentRegion = entity.getAnimation(currentAnimationType).getKeyFrame(frameTime, true); 64 | //Gdx.app.debug(TAG, "Keyframe number is " + _animation.getKeyFrameIndex(_frameTime)); 65 | ((TextureRegionDrawable) drawable).setRegion(currentRegion); 66 | 67 | for (Action action : getActions()) { 68 | action.act(delta); 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/audio/AudioObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.audio; 2 | 3 | public interface AudioObserver { 4 | 5 | enum AudioTypeEvent { 6 | MENU_THEME("music/Rising_Sun.mp3"), 7 | TOPPLE_THEME("music/Village.mp3"), 8 | TEST_THEME("music/Dwarves'_Theme.mp3"), 9 | BATTLE_THEME("music/Challenge.mp3"), 10 | GAME_OVER_THEME("music/Requiem.mp3"), 11 | NONE(""); 12 | 13 | private String audioFullFilePath; 14 | 15 | AudioTypeEvent(String audioFullFilePath) { 16 | this.audioFullFilePath = audioFullFilePath; 17 | } 18 | 19 | public String getValue() { 20 | return audioFullFilePath; 21 | } 22 | } 23 | 24 | enum AudioCommand { 25 | MUSIC_LOAD, 26 | MUSIC_PLAY_ONCE, 27 | MUSIC_PLAY_LOOP, 28 | MUSIC_STOP, 29 | MUSIC_STOP_ALL 30 | } 31 | 32 | void onNotify(AudioCommand command, AudioTypeEvent event); 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/audio/AudioSubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.audio; 2 | 3 | public interface AudioSubject { 4 | void addObserver(AudioObserver audioObserver); 5 | void removeObserver(AudioObserver audioObserver); 6 | void removeAllObservers(); 7 | void notify(final AudioObserver.AudioCommand command, AudioObserver.AudioTypeEvent event); 8 | } 9 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/battle/BattleConversation.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.battle; 2 | 3 | import com.badlogic.gdx.utils.Json; 4 | import com.gdx.game.component.ComponentObserver; 5 | import com.gdx.game.component.ComponentSubject; 6 | import com.gdx.game.entities.Entity; 7 | 8 | public class BattleConversation extends ComponentSubject { 9 | 10 | private Json json; 11 | 12 | public BattleConversation() { 13 | json = new Json(); 14 | } 15 | 16 | public void notifBattleResume(Entity entity) { 17 | notify(json.toJson(entity.getEntityConfig()), ComponentObserver.ComponentEvent.LOAD_RESUME); 18 | notify(json.toJson(entity.getEntityConfig()), ComponentObserver.ComponentEvent.SHOW_RESUME); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/battle/BattleObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.battle; 2 | 3 | import com.gdx.game.entities.Entity; 4 | import com.gdx.game.inventory.InventoryObserver.InventoryEvent; 5 | 6 | public interface BattleObserver { 7 | enum BattleEvent { 8 | OPPONENT_ADDED, 9 | OPPONENT_HIT_DAMAGE, 10 | OPPONENT_DEFEATED, 11 | OPPONENT_TURN_DONE, 12 | PLAYER_ADDED, 13 | PLAYER_HIT_DAMAGE, 14 | PLAYER_RUNNING, 15 | PLAYER_TURN_DONE, 16 | PLAYER_TURN_START, 17 | PLAYER_PHASE_START, 18 | PLAYER_USED_MAGIC, 19 | RESUME_OVER, 20 | NONE 21 | } 22 | 23 | void onNotify(final Entity enemyEntity, BattleEvent event); 24 | 25 | void onNotify(final String drop, InventoryEvent event); 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/battle/BattleSubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.battle; 2 | 3 | import com.badlogic.gdx.utils.Array; 4 | import com.gdx.game.entities.Entity; 5 | import com.gdx.game.inventory.InventoryObserver; 6 | 7 | public class BattleSubject { 8 | private Array observers; 9 | 10 | public BattleSubject() { 11 | observers = new Array<>(); 12 | } 13 | 14 | public void addObserver(BattleObserver battleObserver) { 15 | observers.add(battleObserver); 16 | } 17 | 18 | public void removeObserver(BattleObserver battleObserver) { 19 | observers.removeValue(battleObserver, true); 20 | } 21 | 22 | protected void notify(final Entity entity, BattleObserver.BattleEvent event) { 23 | for(BattleObserver observer: observers) { 24 | observer.onNotify(entity, event); 25 | } 26 | } 27 | 28 | protected void notify(final String drop, InventoryObserver.InventoryEvent event) { 29 | for(BattleObserver observer: observers) { 30 | observer.onNotify(drop, event); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/battle/BattleUtils.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.battle; 2 | 3 | import com.badlogic.gdx.math.MathUtils; 4 | 5 | import java.math.BigDecimal; 6 | import java.math.RoundingMode; 7 | 8 | public class BattleUtils { 9 | 10 | static double escapeChance(double speedRatio) { 11 | double baseChance = 0.3d; 12 | return roundDown(Math.min(baseChance + speedRatio / 4d, 1d)); 13 | } 14 | 15 | static double criticalChance(double atkStat) { 16 | return roundDown((94 - (15260) / (atkStat + 163)) / 100); 17 | } 18 | 19 | static boolean isSuccessful(double statChance) { 20 | double randomVal = MathUtils.random(100f) / 100; 21 | 22 | return statChance > randomVal; 23 | } 24 | 25 | private static double roundDown(double number) { 26 | BigDecimal bigDecimal = new BigDecimal(number); 27 | bigDecimal = bigDecimal.setScale(4, RoundingMode.HALF_UP); 28 | return bigDecimal.doubleValue(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/camera/CameraStyles.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.camera; 2 | 3 | import com.badlogic.gdx.graphics.OrthographicCamera; 4 | import com.badlogic.gdx.math.Vector3; 5 | 6 | public class CameraStyles { 7 | 8 | private CameraStyles() { 9 | } 10 | 11 | public static void boundaries(OrthographicCamera camera, float startX, float startY, float width, float height) { 12 | Vector3 position = camera.position; 13 | 14 | if (position.x < startX) { 15 | position.x = startX; 16 | } 17 | if (position.y < startY) { 18 | position.y = startY; 19 | } 20 | 21 | if (position.x > startX + width) { 22 | position.x = startX + width; 23 | } 24 | if (position.y > startY + height) { 25 | position.y = startY + height; 26 | } 27 | 28 | camera.position.set(position); 29 | camera.update(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/common/Constats.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.common; 2 | 3 | public class Constats { 4 | 5 | public static final String FOE = "FOE"; 6 | 7 | public static final String COURTESY_PHRASES_PATH = "conversations/conversation_courtesy.json"; 8 | 9 | public static final String PARTIAL_CONTROLS_SETTINGS_PATH = "settings/keys.json"; 10 | public static final String FULL_CONTROLS_SETTINGS_PATH = "core/src/main/resources/settings/keys.json"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/common/DefaultControlsMap.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.common; 2 | 3 | import com.gdx.game.component.InputComponent; 4 | 5 | import java.util.HashMap; 6 | 7 | public class DefaultControlsMap { 8 | 9 | public static final HashMap DEFAULT_CONTROLS = new HashMap<>(); 10 | 11 | static { 12 | DEFAULT_CONTROLS.put("33", InputComponent.Keys.INTERACT.name()); 13 | DEFAULT_CONTROLS.put("43", InputComponent.Keys.OPTION.name()); 14 | DEFAULT_CONTROLS.put("32", InputComponent.Keys.RIGHT.name()); 15 | DEFAULT_CONTROLS.put("111", InputComponent.Keys.QUIT.name()); 16 | DEFAULT_CONTROLS.put("51", InputComponent.Keys.UP.name()); 17 | DEFAULT_CONTROLS.put("47", InputComponent.Keys.DOWN.name()); 18 | DEFAULT_CONTROLS.put("29", InputComponent.Keys.LEFT.name()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/common/UtilityClass.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.common; 2 | 3 | import com.badlogic.gdx.utils.Array; 4 | import com.gdx.game.entities.EntityBonus; 5 | import com.gdx.game.entities.EntityConfig; 6 | import com.gdx.game.profile.ProfileManager; 7 | 8 | import java.util.HashMap; 9 | import java.util.Hashtable; 10 | import java.util.Map; 11 | 12 | import static java.lang.Float.parseFloat; 13 | 14 | public class UtilityClass { 15 | 16 | public static HashMap mapInverter(HashMap hashMap){ 17 | 18 | HashMap newHashMap = new HashMap<>(); 19 | 20 | for(Map.Entry entry : hashMap.entrySet()){ 21 | newHashMap.put(entry.getValue(), entry.getKey()); 22 | } 23 | 24 | return newHashMap; 25 | } 26 | 27 | public static Map mapInverter(Map hashMap){ 28 | 29 | Map newMap = new HashMap<>(); 30 | 31 | for(Map.Entry entry : hashMap.entrySet()){ 32 | newMap.put(entry.getValue(), entry.getKey()); 33 | } 34 | 35 | return newMap; 36 | } 37 | 38 | public static HashMap calculateBonus(String bonusProperty) { 39 | final Hashtable attributeTable = new Hashtable<>() {{ 40 | put(EntityConfig.EntityProperties.ENTITY_PHYSICAL_ATTACK_POINTS.name(), "currentPlayerAP"); 41 | put(EntityConfig.EntityProperties.ENTITY_PHYSICAL_DEFENSE_POINTS.name(), "currentPlayerDP"); 42 | }}; 43 | 44 | HashMap bonusStatMap = new HashMap<>(); 45 | Array bonusArray = ProfileManager.getInstance().getProperty(bonusProperty, Array.class); 46 | 47 | if (bonusArray == null || bonusArray.isEmpty()) { 48 | return bonusStatMap; 49 | } 50 | 51 | HashMap bonusEntityValues = new HashMap<>(); 52 | for (EntityBonus entityBonus : bonusArray) { 53 | bonusEntityValues.put(entityBonus.getEntityProperty(), entityBonus.getValue()); 54 | } 55 | 56 | for (String key : attributeTable.keySet()) { 57 | float bonusValue = parseFloat(bonusEntityValues.get(key)); 58 | if (bonusValue > 1) { 59 | bonusStatMap.put(key, (int) bonusValue); 60 | } else { 61 | int playerStat = ProfileManager.getInstance().getProperty(attributeTable.get(key), Integer.class); 62 | int bonusStat = (int) Math.floor(playerStat * bonusValue); 63 | bonusStatMap.put(key, bonusStat); 64 | } 65 | } 66 | 67 | return bonusStatMap; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/component/Component.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.component; 2 | 3 | 4 | public interface Component { 5 | 6 | String MESSAGE_TOKEN = ":::::"; 7 | 8 | enum MESSAGE { 9 | CURRENT_POSITION, 10 | INIT_START_POSITION, 11 | RESET_POSITION, 12 | CURRENT_DIRECTION, 13 | CURRENT_STATE, 14 | COLLISION_WITH_MAP, 15 | COLLISION_WITH_ENTITY, 16 | COLLISION_WITH_FOE, 17 | LOAD_ANIMATIONS, 18 | INIT_DIRECTION, 19 | INIT_STATE, 20 | INIT_SELECT_ENTITY, 21 | ENTITY_SELECTED, 22 | ENTITY_DESELECTED, 23 | OPTION_INPUT 24 | } 25 | 26 | void dispose(); 27 | 28 | void receiveMessage(String message); 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/component/ComponentObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.component; 2 | 3 | public interface ComponentObserver { 4 | enum ComponentEvent { 5 | LOAD_CONVERSATION, 6 | SHOW_CONVERSATION, 7 | HIDE_CONVERSATION, 8 | LOAD_RESUME, 9 | SHOW_RESUME, 10 | QUEST_LOCATION_DISCOVERED, 11 | ENEMY_SPAWN_LOCATION_CHANGED, 12 | START_BATTLE, 13 | OPTION_INPUT 14 | } 15 | 16 | void onNotify(final String value, ComponentEvent event); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/component/ComponentSubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.component; 2 | 3 | import com.badlogic.gdx.utils.Array; 4 | 5 | public class ComponentSubject { 6 | private Array observers; 7 | 8 | public ComponentSubject() { 9 | observers = new Array<>(); 10 | } 11 | 12 | public void addObserver(ComponentObserver conversationObserver) { 13 | observers.add(conversationObserver); 14 | } 15 | 16 | public void removeObserver(ComponentObserver conversationObserver) { 17 | observers.removeValue(conversationObserver, true); 18 | } 19 | 20 | public void removeAllObservers() { 21 | for(ComponentObserver observer: observers) { 22 | observers.removeValue(observer, true); 23 | } 24 | } 25 | 26 | protected void notify(final String value, ComponentObserver.ComponentEvent event) { 27 | for(ComponentObserver observer: observers) { 28 | observer.onNotify(value, event); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/component/InputComponent.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.component; 2 | 3 | import com.badlogic.gdx.InputProcessor; 4 | import com.badlogic.gdx.utils.Json; 5 | import com.gdx.game.entities.Entity; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | import static com.gdx.game.common.UtilityClass.mapInverter; 11 | 12 | public abstract class InputComponent extends ComponentSubject implements Component, InputProcessor { 13 | 14 | protected Entity.Direction currentDirection = null; 15 | protected Entity.State currentState = null; 16 | protected Json json; 17 | 18 | public enum Keys { 19 | LEFT, RIGHT, UP, DOWN, QUIT, INTERACT, OPTION 20 | } 21 | 22 | protected enum Mouse { 23 | SELECT, DOACTION 24 | } 25 | 26 | protected static Map keys = new HashMap<>(); 27 | protected static Map mouseButtons = new HashMap<>(); 28 | 29 | //initialize the hashmap for inputs 30 | static { 31 | keys.put(Keys.LEFT, false); 32 | keys.put(Keys.RIGHT, false); 33 | keys.put(Keys.UP, false); 34 | keys.put(Keys.DOWN, false); 35 | keys.put(Keys.QUIT, false); 36 | keys.put(Keys.INTERACT, false); 37 | keys.put(Keys.OPTION, false); 38 | } 39 | 40 | static { 41 | mouseButtons.put(Mouse.SELECT, false); 42 | mouseButtons.put(Mouse.DOACTION, false); 43 | } 44 | 45 | public InputComponent() { 46 | json = new Json(); 47 | } 48 | 49 | public abstract void update(Entity entity, float delta); 50 | 51 | @Override 52 | public boolean scrolled(float amountX, float amountY) { 53 | return false; 54 | } 55 | 56 | public static HashMap playerControls = new HashMap<>(); 57 | 58 | public static void setPlayerControlMapFromJsonControlsMap(HashMap jsonMap){ 59 | HashMap newPlayerControls = new HashMap<>(); 60 | 61 | for (Map.Entry entry : jsonMap.entrySet()) { 62 | newPlayerControls.put(Integer.valueOf(entry.getKey()), InputComponent.Keys.valueOf(entry.getValue())); 63 | } 64 | 65 | playerControls = newPlayerControls; 66 | } 67 | 68 | public static HashMap mapJsonControlsToPlayerControl(HashMap playerControls){ 69 | HashMap result = new HashMap<>(); 70 | 71 | for (Map.Entry entry : playerControls.entrySet()) { 72 | result.put(entry.getKey().toString(), entry.getValue().toString()); 73 | } 74 | 75 | return result; 76 | } 77 | 78 | public static HashMap changeValueFromJsonControlsMap(HashMap jsonMap, Keys keyValue, Integer keyCode){ 79 | jsonMap = mapInverter(jsonMap); 80 | jsonMap.put(keyValue.name(), String.valueOf(keyCode)); 81 | jsonMap = mapInverter(jsonMap); 82 | 83 | return jsonMap; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/dialog/Conversation.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.dialog; 2 | 3 | public class Conversation { 4 | private String id; 5 | private String dialog = ""; 6 | 7 | public Conversation() { 8 | } 9 | 10 | public String getId() { 11 | return id; 12 | } 13 | 14 | public void setId(String id) { 15 | this.id = id; 16 | } 17 | 18 | public String getDialog() { 19 | return dialog; 20 | } 21 | 22 | public void setDialog(String dialog) { 23 | this.dialog = dialog; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/dialog/ConversationChoice.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.dialog; 2 | 3 | import com.gdx.game.dialog.ConversationGraphObserver.ConversationCommandEvent; 4 | 5 | public class ConversationChoice { 6 | private String sourceId; 7 | private String destinationId; 8 | private String choicePhrase; 9 | private ConversationCommandEvent conversationCommandEvent; 10 | 11 | public ConversationChoice() {} 12 | 13 | public String getSourceId() { 14 | return sourceId; 15 | } 16 | 17 | public void setSourceId(String sourceId) { 18 | this.sourceId = sourceId; 19 | } 20 | 21 | public String getDestinationId() { 22 | return destinationId; 23 | } 24 | 25 | public void setDestinationId(String destinationId) { 26 | this.destinationId = destinationId; 27 | } 28 | 29 | public String getChoicePhrase() { 30 | return choicePhrase; 31 | } 32 | 33 | public void setChoicePhrase(String choicePhrase) { 34 | this.choicePhrase = choicePhrase; 35 | } 36 | 37 | public ConversationCommandEvent getConversationCommandEvent() { 38 | return conversationCommandEvent; 39 | } 40 | 41 | public void setConversationCommandEvent(ConversationCommandEvent choiceCommand) { 42 | this.conversationCommandEvent = choiceCommand; 43 | } 44 | 45 | public String toString() { 46 | return choicePhrase; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/dialog/ConversationGraphObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.dialog; 2 | 3 | public interface ConversationGraphObserver { 4 | enum ConversationCommandEvent { 5 | LOAD_STORE_INVENTORY, 6 | EXIT_CONVERSATION, 7 | ACCEPT_QUEST, 8 | ADD_ENTITY_TO_INVENTORY, 9 | RETURN_QUEST, 10 | NONE 11 | } 12 | 13 | void onNotify(final ConversationGraph graph, ConversationCommandEvent event); 14 | } 15 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/dialog/ConversationGraphSubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.dialog; 2 | 3 | import com.badlogic.gdx.utils.Array; 4 | 5 | public class ConversationGraphSubject { 6 | private Array observers; 7 | 8 | public ConversationGraphSubject() { 9 | observers = new Array<>(); 10 | } 11 | 12 | public void addObserver(ConversationGraphObserver graphObserver) { 13 | observers.add(graphObserver); 14 | } 15 | 16 | public void removeObserver(ConversationGraphObserver graphObserver) { 17 | observers.removeValue(graphObserver, true); 18 | } 19 | 20 | public void removeAllObservers() { 21 | for(ConversationGraphObserver observer: observers) { 22 | observers.removeValue(observer, true); 23 | } 24 | } 25 | 26 | public void notify(final ConversationGraph graph, ConversationGraphObserver.ConversationCommandEvent event) { 27 | for(ConversationGraphObserver observer: observers) { 28 | observer.onNotify(graph, event); 29 | } 30 | }} 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/entities/EntityBonus.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities; 2 | 3 | public class EntityBonus { 4 | 5 | private String entityProperty; 6 | private String value; 7 | 8 | public EntityBonus() { 9 | } 10 | 11 | public EntityBonus(String entityProperty, String value) { 12 | this.entityProperty = entityProperty; 13 | this.value = value; 14 | } 15 | 16 | public String getEntityProperty() { 17 | return entityProperty; 18 | } 19 | 20 | public void setEntityProperty(String entityProperty) { 21 | this.entityProperty = entityProperty; 22 | } 23 | 24 | public String getValue() { 25 | return value; 26 | } 27 | 28 | public void setValue(String value) { 29 | this.value = value; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/entities/npc/NPCPhysicsComponent.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities.npc; 2 | 3 | import com.badlogic.gdx.math.Vector2; 4 | import com.badlogic.gdx.math.Vector3; 5 | import com.gdx.game.component.Component; 6 | import com.gdx.game.component.PhysicsComponent; 7 | import com.gdx.game.entities.Entity; 8 | import com.gdx.game.map.MapManager; 9 | 10 | public class NPCPhysicsComponent extends PhysicsComponent { 11 | 12 | protected Entity.State state; 13 | 14 | public NPCPhysicsComponent() { 15 | boundingBoxLocation = BoundingBoxLocation.CENTER; 16 | initBoundingBox(0.4f, 0.15f); 17 | } 18 | 19 | @Override 20 | public void dispose() { 21 | } 22 | 23 | @Override 24 | public void receiveMessage(String message) { 25 | String[] string = message.split(Component.MESSAGE_TOKEN); 26 | 27 | if (string.length == 0) { 28 | return; 29 | } 30 | 31 | //Specifically for messages with 1 object payload 32 | if (string.length == 2) { 33 | if (string[0].equalsIgnoreCase(MESSAGE.INIT_START_POSITION.toString())) { 34 | currentEntityPosition = json.fromJson(Vector2.class, string[1]); 35 | nextEntityPosition.set(currentEntityPosition.x, currentEntityPosition.y); 36 | } else if (string[0].equalsIgnoreCase(MESSAGE.CURRENT_STATE.toString())) { 37 | state = json.fromJson(Entity.State.class, string[1]); 38 | } else if (string[0].equalsIgnoreCase(MESSAGE.CURRENT_DIRECTION.toString())) { 39 | currentDirection = json.fromJson(Entity.Direction.class, string[1]); 40 | } 41 | } 42 | } 43 | 44 | @Override 45 | public void update(Entity entity, MapManager mapMgr, float delta) { 46 | updateBoundingBoxPosition(nextEntityPosition); 47 | 48 | if (isEntityFarFromPlayer(mapMgr)) { 49 | entity.sendMessage(MESSAGE.ENTITY_DESELECTED); 50 | } 51 | 52 | if (state == Entity.State.IMMOBILE) { 53 | return; 54 | } 55 | 56 | if (!isCollisionWithMapLayer(entity, mapMgr) && !isCollisionWithMapEntities(entity, mapMgr) && state == Entity.State.WALKING) { 57 | setNextPositionToCurrent(entity); 58 | } else { 59 | updateBoundingBoxPosition(currentEntityPosition); 60 | } 61 | calculateNextPosition(delta); 62 | } 63 | 64 | private boolean isEntityFarFromPlayer(MapManager mapMgr) { 65 | //Check distance 66 | float distance = calculateDistance(mapMgr); 67 | 68 | return !(distance <= SELECT_RAY_MAXIMUM_DISTANCE); 69 | } 70 | 71 | protected float calculateDistance(MapManager mapMgr) { 72 | Vector3 vec3Player = new Vector3(mapMgr.getPlayer().getCurrentBoundingBox().x, mapMgr.getPlayer().getCurrentBoundingBox().y, 0.0f); 73 | Vector3 vec3Npc = new Vector3(boundingBox.x, boundingBox.y, 0.0f); 74 | return vec3Player.dst(vec3Npc); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/entities/npc/enemy/EnemyPhysicsComponent.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities.npc.enemy; 2 | 3 | import com.gdx.game.entities.Entity; 4 | import com.gdx.game.entities.EntityConfig; 5 | import com.gdx.game.entities.npc.NPCPhysicsComponent; 6 | import com.gdx.game.map.MapManager; 7 | 8 | public class EnemyPhysicsComponent extends NPCPhysicsComponent { 9 | 10 | private static final float followRadius = 75.0f; 11 | 12 | @Override 13 | public void update(Entity entity, MapManager mapMgr, float delta) { 14 | updateBoundingBoxPosition(nextEntityPosition); 15 | 16 | if (calculateDistance(mapMgr) <= followRadius) { 17 | followPlayer(mapMgr, entity, delta); 18 | return; 19 | } 20 | 21 | if (state == Entity.State.IMMOBILE) { 22 | return; 23 | } 24 | 25 | if (!isCollisionWithMapLayer(entity, mapMgr) && !isCollisionWithMapEntities(entity, mapMgr) && state == Entity.State.WALKING) { 26 | setNextPositionToCurrent(entity); 27 | } else { 28 | updateBoundingBoxPosition(currentEntityPosition); 29 | } 30 | calculateNextPosition(delta); 31 | } 32 | 33 | private void followPlayer(MapManager mapMgr, Entity entity, float delta) { 34 | float speed = Float.parseFloat(entity.getEntityConfig().getEntityProperties().get(EntityConfig.EntityProperties.ENTITY_SPEED_POINTS.name())); 35 | 36 | float dx = mapMgr.getPlayer().getCurrentPosition().x - currentEntityPosition.x; 37 | float dy = mapMgr.getPlayer().getCurrentPosition().y - currentEntityPosition.y; 38 | 39 | // Check which axis has the greater distance 40 | if (Math.abs(dx) > Math.abs(dy)) { 41 | nextEntityPosition.x += Math.signum(dx) * speed/3 * delta; 42 | } else { 43 | nextEntityPosition.y += Math.signum(dy) * speed/3 * delta; 44 | } 45 | setNextPositionToCurrent(entity); 46 | updateBoundingBoxPosition(currentEntityPosition); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/entities/player/CharacterRecord.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities.player; 2 | 3 | import com.gdx.game.entities.Entity; 4 | import com.gdx.game.entities.EntityConfig; 5 | import com.gdx.game.entities.EntityFactory; 6 | 7 | import java.util.Arrays; 8 | import java.util.List; 9 | import java.util.Locale; 10 | 11 | import static com.gdx.game.entities.EntityFactory.EntityType.CLERIC; 12 | import static com.gdx.game.entities.EntityFactory.EntityType.GRAPPLER; 13 | import static com.gdx.game.entities.EntityFactory.EntityType.MAGE; 14 | import static com.gdx.game.entities.EntityFactory.EntityType.THIEF; 15 | import static com.gdx.game.entities.EntityFactory.EntityType.WARRIOR; 16 | 17 | public class CharacterRecord { 18 | 19 | private final int baseHP; 20 | private final int baseMP; 21 | private final int baseAttack; 22 | private final int baseDefense; 23 | private final int baseSpeed; 24 | private final String name; 25 | 26 | public static final List charactersList = Arrays.asList(WARRIOR, MAGE, THIEF, GRAPPLER, 27 | CLERIC); 28 | 29 | public static CharacterRecord[] CHARACTERS = charactersList.stream() 30 | .map(c -> new CharacterRecord(2, 2, 31 | loadStats(c.name(), EntityConfig.EntityProperties.ENTITY_PHYSICAL_ATTACK_POINTS), 32 | loadStats(c.name(), EntityConfig.EntityProperties.ENTITY_PHYSICAL_DEFENSE_POINTS), 33 | loadStats(c.name(), EntityConfig.EntityProperties.ENTITY_SPEED_POINTS), 34 | c.name())) 35 | .toArray(CharacterRecord[]::new); 36 | 37 | public CharacterRecord(int baseHP, int baseMP, int baseAttack, int baseDefense, int baseSpeed, String name) { 38 | this.baseHP = baseHP; 39 | this.baseMP = baseMP; 40 | this.baseAttack = baseAttack; 41 | this.baseDefense = baseDefense; 42 | this.baseSpeed = baseSpeed; 43 | this.name = name; 44 | } 45 | 46 | public int getBaseHP() { 47 | return baseHP; 48 | } 49 | 50 | public int getBaseMP() { 51 | return baseMP; 52 | } 53 | 54 | public int getBaseAttack() { 55 | return baseAttack; 56 | } 57 | 58 | public int getBaseDefense() { 59 | return baseDefense; 60 | } 61 | 62 | public int getBaseSpeed() { 63 | return baseSpeed; 64 | } 65 | 66 | public String getName() { 67 | return name; 68 | } 69 | 70 | private static int loadStats(String charName, EntityConfig.EntityProperties prop) { 71 | Entity entity = EntityFactory.getInstance().getEntity( EntityFactory.EntityType.valueOf(charName.toUpperCase(Locale.ROOT))); 72 | return Integer.parseInt(entity.getEntityConfig().getPropertyValue(prop.toString())); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/entities/player/characterClass/ClassObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities.player.characterClass; 2 | 3 | public interface ClassObserver { 4 | 5 | enum ClassEvent { 6 | CHECK_UPGRADE_TREE_CLASS 7 | } 8 | 9 | void onNotify(String value, ClassEvent event); 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/entities/player/characterClass/ClassSubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities.player.characterClass; 2 | 3 | public interface ClassSubject { 4 | 5 | void addObserver(ClassObserver classObserver); 6 | void removeObserver(ClassObserver classObserver); 7 | void removeAllObservers(); 8 | void notify(String value, ClassObserver.ClassEvent event); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/entities/player/characterClass/tree/Node.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities.player.characterClass.tree; 2 | 3 | import com.badlogic.gdx.utils.ObjectMap; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class Node { 9 | 10 | private int id; 11 | private String classId; 12 | private List classUpgrade; 13 | private ObjectMap requirements; 14 | private ObjectMap bonus; 15 | private Node left; 16 | private Node right; 17 | 18 | Node() { 19 | this.classUpgrade = new ArrayList<>(); 20 | this.requirements = new ObjectMap<>(); 21 | this.bonus = new ObjectMap<>(); 22 | } 23 | 24 | public Node(int id, String classId, List classUpgrade, ObjectMap requirements, ObjectMap bonus) { 25 | this.id = id; 26 | this.classId = classId; 27 | this.classUpgrade = classUpgrade; 28 | this.requirements = requirements; 29 | this.bonus = bonus; 30 | this.left = null; 31 | this.right = null; 32 | } 33 | 34 | public int getId() { 35 | return id; 36 | } 37 | 38 | public String getClassId() { 39 | return classId; 40 | } 41 | 42 | public List getClassUpgrade() { 43 | return classUpgrade; 44 | } 45 | 46 | public ObjectMap getRequirements() { 47 | return requirements; 48 | } 49 | 50 | public ObjectMap getBonus() { 51 | return bonus; 52 | } 53 | 54 | public Node getLeft() { 55 | return left; 56 | } 57 | 58 | public void setLeft(Node left) { 59 | this.left = left; 60 | } 61 | 62 | public Node getRight() { 63 | return right; 64 | } 65 | 66 | public void setRight(Node right) { 67 | this.right = right; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/InventoryObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory; 2 | 3 | public interface InventoryObserver { 4 | enum InventoryEvent { 5 | UPDATED_AP, 6 | UPDATED_DP, 7 | ITEM_CONSUMED, 8 | DROP_ITEM_ADDED, 9 | ADD_WAND_AP, 10 | REMOVE_WAND_AP, 11 | REFRESH_STATS, 12 | NONE 13 | } 14 | 15 | void onNotify(final String value, InventoryEvent event); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/InventorySubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory; 2 | 3 | public interface InventorySubject { 4 | void addObserver(InventoryObserver inventoryObserver); 5 | void removeObserver(InventoryObserver inventoryObserver); 6 | void removeAllObservers(); 7 | void notify(final String value, InventoryObserver.InventoryEvent event); 8 | } 9 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/item/InventoryItemFactory.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.item; 2 | 3 | 4 | import com.badlogic.gdx.Gdx; 5 | import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; 6 | import com.badlogic.gdx.utils.Json; 7 | import com.badlogic.gdx.utils.JsonValue; 8 | import com.badlogic.gdx.utils.Scaling; 9 | import com.gdx.game.inventory.item.InventoryItem.ItemTypeID; 10 | 11 | import java.util.ArrayList; 12 | import java.util.Hashtable; 13 | 14 | import static com.gdx.game.manager.ResourceManager.ITEMS_TEXTURE_ATLAS; 15 | 16 | public class InventoryItemFactory { 17 | 18 | private Json json = new Json(); 19 | private static final String INVENTORY_ITEM = "scripts/inventory_items.json"; 20 | private static InventoryItemFactory instance = null; 21 | private Hashtable inventoryItemList; 22 | 23 | public static InventoryItemFactory getInstance() { 24 | if (instance == null) { 25 | instance = new InventoryItemFactory(); 26 | } 27 | 28 | return instance; 29 | } 30 | 31 | private InventoryItemFactory() { 32 | ArrayList list = json.fromJson(ArrayList.class, Gdx.files.internal(INVENTORY_ITEM)); 33 | inventoryItemList = new Hashtable<>(); 34 | 35 | for(JsonValue jsonVal : list) { 36 | InventoryItem inventoryItem = json.readValue(InventoryItem.class, jsonVal); 37 | inventoryItemList.put(inventoryItem.getItemTypeID(), inventoryItem); 38 | } 39 | } 40 | 41 | public InventoryItem getInventoryItem(ItemTypeID inventoryItemType) { 42 | InventoryItem item = new InventoryItem(inventoryItemList.get(inventoryItemType)); 43 | item.setDrawable(new TextureRegionDrawable(ITEMS_TEXTURE_ATLAS.findRegion(item.getItemTypeID().toString()))); 44 | item.setScaling(Scaling.none); 45 | return item; 46 | } 47 | 48 | /* 49 | public void testAllItemLoad() { 50 | for(ItemTypeID itemTypeID : ItemTypeID.values()) { 51 | InventoryItem item = new InventoryItem(inventoryItemList.get(itemTypeID)); 52 | item.setDrawable(new TextureRegionDrawable(PlayerHUD.itemsTextureAtlas.findRegion(item.getItemTypeID().toString()))); 53 | item.setScaling(Scaling.none); 54 | } 55 | }*/ 56 | 57 | } 58 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/item/InventoryItemLocation.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.item; 2 | 3 | public class InventoryItemLocation { 4 | private int locationIndex; 5 | private String itemTypeAtLocation; 6 | private int numberItemsAtLocation; 7 | private String itemNameProperty; 8 | 9 | public InventoryItemLocation() { 10 | } 11 | 12 | public InventoryItemLocation( int locationIndex, String itemTypeAtLocation, int numberItemsAtLocation, String itemNameProperty) { 13 | this.locationIndex = locationIndex; 14 | this.itemTypeAtLocation = itemTypeAtLocation; 15 | this.numberItemsAtLocation = numberItemsAtLocation; 16 | this.itemNameProperty = itemNameProperty; 17 | } 18 | 19 | public String getItemNameProperty() { 20 | return itemNameProperty; 21 | } 22 | 23 | public void setItemNameProperty(String itemNameProperty) { 24 | this.itemNameProperty = itemNameProperty; 25 | } 26 | 27 | public String getItemTypeAtLocation() { 28 | return itemTypeAtLocation; 29 | } 30 | 31 | public void setItemTypeAtLocation(String itemTypeAtLocation) { 32 | this.itemTypeAtLocation = itemTypeAtLocation; 33 | } 34 | 35 | public int getLocationIndex() { 36 | return locationIndex; 37 | } 38 | 39 | public void setLocationIndex(int locationIndex) { 40 | this.locationIndex = locationIndex; 41 | } 42 | 43 | public int getNumberItemsAtLocation() { 44 | return numberItemsAtLocation; 45 | } 46 | 47 | public void setNumberItemsAtLocation(int numberItemsAtLocation) { 48 | this.numberItemsAtLocation = numberItemsAtLocation; 49 | } 50 | } -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/set/EquipmentSet.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.set; 2 | 3 | import com.gdx.game.inventory.item.InventoryItem; 4 | 5 | import java.util.HashMap; 6 | 7 | public class EquipmentSet { 8 | 9 | private InventoryItem.ItemSetID itemSetID; 10 | private String itemSetDescription; 11 | private HashMap bonus = new HashMap<>(); 12 | 13 | public EquipmentSet() { 14 | } 15 | 16 | public EquipmentSet(EquipmentSet equipmentSet) { 17 | this.itemSetID = equipmentSet.getItemSetID(); 18 | this.itemSetDescription = equipmentSet.getItemSetDescription(); 19 | this.bonus = equipmentSet.getBonus(); 20 | } 21 | 22 | public InventoryItem.ItemSetID getItemSetID() { 23 | return itemSetID; 24 | } 25 | 26 | public void setItemSetID(InventoryItem.ItemSetID itemSetID) { 27 | this.itemSetID = itemSetID; 28 | } 29 | 30 | public String getItemSetDescription() { 31 | return itemSetDescription; 32 | } 33 | 34 | public void setItemSetDescription(String itemSetDescription) { 35 | this.itemSetDescription = itemSetDescription; 36 | } 37 | 38 | public HashMap getBonus() { 39 | return bonus; 40 | } 41 | 42 | public void setBonus(HashMap bonus) { 43 | this.bonus = bonus; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/set/EquipmentSetFactory.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.set; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.utils.Json; 5 | import com.badlogic.gdx.utils.JsonValue; 6 | import com.gdx.game.inventory.item.InventoryItem; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Hashtable; 10 | 11 | public class EquipmentSetFactory { 12 | 13 | private Json json = new Json(); 14 | private static final String ITEM_SET = "scripts/equipment_sets.json"; 15 | private static EquipmentSetFactory instance = null; 16 | private Hashtable equipSetList; 17 | 18 | public static EquipmentSetFactory getInstance() { 19 | if (instance == null) { 20 | instance = new EquipmentSetFactory(); 21 | } 22 | 23 | return instance; 24 | } 25 | 26 | private EquipmentSetFactory() { 27 | ArrayList list = json.fromJson(ArrayList.class, Gdx.files.internal(ITEM_SET)); 28 | equipSetList = new Hashtable<>(); 29 | 30 | for(JsonValue jsonVal : list) { 31 | EquipmentSet equipSet = json.readValue(EquipmentSet.class, jsonVal); 32 | equipSetList.put(equipSet.getItemSetID(), equipSet); 33 | } 34 | } 35 | 36 | public EquipmentSet getEquipmentSet(InventoryItem.ItemSetID equipmentType) { 37 | return new EquipmentSet(equipSetList.get(equipmentType)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/slot/InventorySlotObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.slot; 2 | 3 | public interface InventorySlotObserver { 4 | enum SlotEvent { 5 | ADDED_ITEM, 6 | REMOVED_ITEM 7 | } 8 | 9 | void onNotify(final InventorySlot slot, SlotEvent event); 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/slot/InventorySlotSource.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.slot; 2 | 3 | import com.badlogic.gdx.scenes.scene2d.Actor; 4 | import com.badlogic.gdx.scenes.scene2d.InputEvent; 5 | import com.badlogic.gdx.scenes.scene2d.ui.Table; 6 | import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; 7 | import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Payload; 8 | import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Source; 9 | import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Target; 10 | 11 | import static com.gdx.game.inventory.InventoryUI.getInventory; 12 | 13 | public class InventorySlotSource extends Source { 14 | 15 | private DragAndDrop dragAndDrop; 16 | private InventorySlot sourceSlot; 17 | 18 | public InventorySlotSource(InventorySlot sourceSlot, DragAndDrop dragAndDrop) { 19 | super(sourceSlot.getTopInventoryItem()); 20 | this.sourceSlot = sourceSlot; 21 | this.dragAndDrop = dragAndDrop; 22 | } 23 | 24 | @Override 25 | public Payload dragStart(InputEvent event, float x, float y, int pointer) { 26 | Payload payload = new Payload(); 27 | 28 | Actor actor = getActor(); 29 | if (actor == null) { 30 | return null; 31 | } 32 | 33 | InventorySlot source = (InventorySlot)actor.getParent(); 34 | if (source == null) { 35 | return null; 36 | } else { 37 | sourceSlot = source; 38 | } 39 | 40 | sourceSlot.decrementItemCount(true); 41 | 42 | payload.setDragActor(getActor()); 43 | dragAndDrop.setDragActorPosition(-x, -y + getActor().getHeight()); 44 | 45 | return payload; 46 | } 47 | 48 | @Override 49 | public void dragStop (InputEvent event, float x, float y, int pointer, Payload payload, Target target) { 50 | if (target == null) { 51 | sourceSlot.add(payload.getDragActor()); 52 | } 53 | } 54 | 55 | public InventorySlot getSourceSlot() { 56 | return sourceSlot; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/slot/InventorySlotSubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.slot; 2 | 3 | public interface InventorySlotSubject { 4 | 5 | void addObserver(InventorySlotObserver inventorySlotObserver); 6 | void removeObserver(InventorySlotObserver inventorySlotObserver); 7 | void removeAllObservers(); 8 | void notify(final InventorySlot slot, InventorySlotObserver.SlotEvent event); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTarget.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.slot; 2 | 3 | import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Payload; 4 | import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Source; 5 | import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Target; 6 | import com.gdx.game.inventory.item.InventoryItem; 7 | 8 | public class InventorySlotTarget extends Target { 9 | 10 | InventorySlot targetSlot; 11 | 12 | public InventorySlotTarget(InventorySlot actor) { 13 | super(actor); 14 | targetSlot = actor; 15 | } 16 | 17 | @Override 18 | public boolean drag(Source source, Payload payload, float x, float y, int pointer) { 19 | return true; 20 | } 21 | 22 | @Override 23 | public void reset(Source source, Payload payload) { 24 | } 25 | 26 | @Override 27 | public void drop(Source source, Payload payload, float x, float y, int pointer) { 28 | InventoryItem sourceActor = (InventoryItem) payload.getDragActor(); 29 | InventoryItem targetActor = targetSlot.getTopInventoryItem(); 30 | InventorySlot sourceSlot = ((InventorySlotSource)source).getSourceSlot(); 31 | 32 | if (sourceActor == null) { 33 | return; 34 | } 35 | 36 | //First, does the slot accept the source item type? 37 | if (!targetSlot.doesAcceptItemUseType(sourceActor.getItemUseType())) { 38 | //Put item back where it came from, slot doesn't accept item 39 | sourceSlot.add(sourceActor); 40 | return; 41 | } 42 | 43 | if (!targetSlot.hasItem()) { 44 | targetSlot.add(sourceActor); 45 | } else { 46 | //If the same item and stackable, add 47 | if (sourceActor.isSameItemType(targetActor) && sourceActor.isStackable()) { 48 | targetSlot.add(sourceActor); 49 | } else { 50 | //If they aren't the same items or the items aren't stackable, then swap 51 | InventorySlot.swapSlots(sourceSlot, targetSlot, sourceActor); 52 | } 53 | } 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltip.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.slot; 2 | 3 | import com.badlogic.gdx.scenes.scene2d.ui.Label; 4 | import com.badlogic.gdx.scenes.scene2d.ui.Skin; 5 | import com.badlogic.gdx.scenes.scene2d.ui.Window; 6 | import com.gdx.game.inventory.item.InventoryItem; 7 | 8 | public class InventorySlotTooltip extends Window { 9 | 10 | private Skin skin; 11 | private Label description; 12 | 13 | public InventorySlotTooltip(final Skin skin) { 14 | super("", skin); 15 | this.skin = skin; 16 | 17 | description = new Label("", skin); 18 | 19 | this.add(description); 20 | this.padLeft(5).padRight(5); 21 | this.pack(); 22 | this.setVisible(false); 23 | } 24 | 25 | public void setVisible(InventorySlot inventorySlot, boolean visible) { 26 | super.setVisible(visible); 27 | 28 | if (inventorySlot == null) { 29 | return; 30 | } 31 | 32 | if (!inventorySlot.hasItem()) { 33 | super.setVisible(false); 34 | } 35 | } 36 | 37 | public void updateTooltip(InventorySlot inventorySlot) { 38 | if (inventorySlot.hasItem()) { 39 | StringBuilder string = new StringBuilder(); 40 | InventoryItem item = inventorySlot.getTopInventoryItem(); 41 | string.append(String.format("Rarity: %s", item.getItemRarity().getValue())); 42 | string.append(System.getProperty("line.separator")); 43 | string.append(item.getItemShortDescription()); 44 | if (item.isInventoryItemOffensive()) { 45 | string.append(System.getProperty("line.separator")); 46 | string.append(String.format("Attack Points: %s", item.getItemUseTypeValue())); 47 | } else if (item.isInventoryItemDefensive()) { 48 | string.append(System.getProperty("line.separator")); 49 | string.append(String.format("Defense Points: %s", item.getItemUseTypeValue())); 50 | } 51 | string.append(System.getProperty("line.separator")); 52 | string.append(String.format("Original Value: %s GP", item.getItemValue())); 53 | string.append(System.getProperty("line.separator")); 54 | string.append(String.format("Trade Value: %s GP", item.getTradeValue())); 55 | 56 | description.setText(string); 57 | 58 | this.getTitleLabel().setText(item.getItemTypeID().toString()); 59 | this.getTitleLabel().setColor(item.getItemRarity().getColor()); 60 | } else { 61 | description.setText(""); 62 | } 63 | this.pack(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/slot/InventorySlotTooltipListener.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.slot; 2 | 3 | import com.badlogic.gdx.math.Vector2; 4 | import com.badlogic.gdx.scenes.scene2d.Actor; 5 | import com.badlogic.gdx.scenes.scene2d.InputEvent; 6 | import com.badlogic.gdx.scenes.scene2d.InputListener; 7 | 8 | public class InventorySlotTooltipListener extends InputListener { 9 | 10 | private InventorySlotTooltip tooltip; 11 | private boolean isInside = false; 12 | private Vector2 currentCoords; 13 | private Vector2 offset; 14 | 15 | public InventorySlotTooltipListener(InventorySlotTooltip toolTip) { 16 | this.tooltip = toolTip; 17 | this.currentCoords = new Vector2(0,0); 18 | this.offset = new Vector2(20, 10); 19 | } 20 | 21 | @Override 22 | public boolean mouseMoved(InputEvent event, float x, float y) { 23 | InventorySlot inventorySlot = (InventorySlot)event.getListenerActor(); 24 | if (isInside) { 25 | currentCoords.set(x, y); 26 | inventorySlot.localToStageCoordinates(currentCoords); 27 | 28 | tooltip.setPosition(currentCoords.x+ offset.x, currentCoords.y+ offset.y); 29 | } 30 | return false; 31 | } 32 | 33 | 34 | @Override 35 | public void touchDragged(InputEvent event, float x, float y, int pointer) { 36 | InventorySlot inventorySlot = (InventorySlot)event.getListenerActor(); 37 | tooltip.setVisible(inventorySlot, false); 38 | } 39 | 40 | @Override 41 | public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { 42 | return true; 43 | } 44 | 45 | @Override 46 | public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { 47 | InventorySlot inventorySlot = (InventorySlot)event.getListenerActor(); 48 | 49 | isInside = true; 50 | 51 | currentCoords.set(x, y); 52 | inventorySlot.localToStageCoordinates(currentCoords); 53 | 54 | tooltip.updateTooltip(inventorySlot); 55 | tooltip.setPosition(currentCoords.x + offset.x, currentCoords.y + offset.y); 56 | tooltip.toFront(); 57 | tooltip.setVisible(inventorySlot, true); 58 | } 59 | 60 | @Override 61 | public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) { 62 | InventorySlot inventorySlot = (InventorySlot)event.getListenerActor(); 63 | tooltip.setVisible(inventorySlot, false); 64 | isInside = false; 65 | 66 | currentCoords.set(x, y); 67 | inventorySlot.localToStageCoordinates(currentCoords); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/store/StoreInventoryObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.store; 2 | 3 | public interface StoreInventoryObserver { 4 | enum StoreInventoryEvent { 5 | PLAYER_GP_TOTAL_UPDATED, 6 | PLAYER_INVENTORY_UPDATED 7 | } 8 | 9 | void onNotify(String value, StoreInventoryEvent event); 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/inventory/store/StoreInventorySubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.store; 2 | 3 | 4 | public interface StoreInventorySubject { 5 | void addObserver(StoreInventoryObserver storeObserver); 6 | void removeObserver(StoreInventoryObserver storeObserver); 7 | void removeAllObservers(); 8 | void notify(String value, StoreInventoryObserver.StoreInventoryEvent event); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/manager/AnimationManager.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.manager; 2 | 3 | import com.badlogic.gdx.graphics.Texture; 4 | import com.badlogic.gdx.graphics.g2d.Animation; 5 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 6 | 7 | public class AnimationManager { 8 | 9 | public TextureRegion[][] setTextureRegionsDouble(Texture texture, int tileWidth, int tileHeight) { 10 | return TextureRegion.split(texture, tileWidth, tileHeight); 11 | } 12 | 13 | public Animation setAnimation(TextureRegion[] textureRegions) { 14 | return new Animation<>(0.1f, textureRegions); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/manager/PreferenceManager.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.manager; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.Preferences; 5 | 6 | public class PreferenceManager { 7 | 8 | private static PreferenceManager instance = null; 9 | 10 | private static final String PREF_MUSIC_VOLUME = "music"; 11 | private static final String PREF_MUSIC_ENABLED = "music.enabled"; 12 | private static final String PREF_SOUND_ENABLED = "sound.enabled"; 13 | private static final String PREF_SOUND_VOLUME = "sound"; 14 | private static final String PREFS_NAME = "gdxGame"; 15 | 16 | public static PreferenceManager getInstance() { 17 | if (instance == null) { 18 | instance = new PreferenceManager(); 19 | } 20 | 21 | return instance; 22 | } 23 | 24 | protected static Preferences getPrefs() { 25 | return Gdx.app.getPreferences(PREFS_NAME); 26 | } 27 | 28 | public boolean isSoundEffectsEnabled() { 29 | return getPrefs().getBoolean(PREF_SOUND_ENABLED, true); 30 | } 31 | 32 | public void setSoundEffectsEnabled(boolean soundEffectsEnabled) { 33 | getPrefs().putBoolean(PREF_SOUND_ENABLED, soundEffectsEnabled); 34 | getPrefs().flush(); 35 | } 36 | 37 | public boolean isMusicEnabled() { 38 | return getPrefs().getBoolean(PREF_MUSIC_ENABLED, true); 39 | } 40 | 41 | public void setMusicEnabled(boolean musicEnabled) { 42 | getPrefs().putBoolean(PREF_MUSIC_ENABLED, musicEnabled); 43 | getPrefs().flush(); 44 | } 45 | 46 | public static float getMusicVolume() { 47 | return getPrefs().getFloat(PREF_MUSIC_VOLUME, 0.5f); 48 | } 49 | 50 | public void setMusicVolume(float volume) { 51 | getPrefs().putFloat(PREF_MUSIC_VOLUME, volume); 52 | getPrefs().flush(); 53 | } 54 | 55 | public float getSoundVolume() { 56 | return getPrefs().getFloat(PREF_SOUND_VOLUME, 0.5f); 57 | } 58 | 59 | public void setSoundVolume(float volume) { 60 | getPrefs().putFloat(PREF_SOUND_VOLUME, volume); 61 | getPrefs().flush(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/map/MapFactory.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.map; 2 | 3 | import com.gdx.game.map.worldMap.ToppleRoad1; 4 | import com.gdx.game.map.worldMap.Topple; 5 | 6 | import java.util.Hashtable; 7 | 8 | public class MapFactory { 9 | //All maps for the game 10 | private static Hashtable mapTable = new Hashtable<>(); 11 | 12 | public enum MapType { 13 | TOPPLE_ROAD_1, 14 | TOPPLE 15 | } 16 | 17 | public static Hashtable getMapTable() { 18 | return mapTable; 19 | } 20 | 21 | public static Map getMap(MapType mapType) { 22 | Map map = null; 23 | switch(mapType) { 24 | case TOPPLE_ROAD_1: 25 | map = mapTable.get(MapType.TOPPLE_ROAD_1); 26 | if (map == null) { 27 | map = new ToppleRoad1(); 28 | mapTable.put(MapType.TOPPLE_ROAD_1, map); 29 | } 30 | break; 31 | case TOPPLE: 32 | map = mapTable.get(MapType.TOPPLE); 33 | if (map == null) { 34 | map = new Topple(); 35 | mapTable.put(MapType.TOPPLE, map); 36 | } 37 | break; 38 | default: 39 | break; 40 | } 41 | return map; 42 | } 43 | 44 | public static void clearCache() { 45 | for(Map map: mapTable.values()) { 46 | map.dispose(); 47 | } 48 | mapTable.clear(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/map/worldMap/Topple.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.map.worldMap; 2 | 3 | import com.badlogic.gdx.math.Vector2; 4 | import com.badlogic.gdx.utils.Json; 5 | import com.gdx.game.audio.AudioObserver; 6 | import com.gdx.game.component.Component; 7 | import com.gdx.game.entities.Entity; 8 | import com.gdx.game.entities.EntityConfig; 9 | import com.gdx.game.entities.EntityFactory; 10 | import com.gdx.game.map.Map; 11 | import com.gdx.game.map.MapFactory; 12 | import com.gdx.game.profile.ProfileManager; 13 | 14 | import static com.gdx.game.audio.AudioObserver.AudioTypeEvent.TOPPLE_THEME; 15 | 16 | public class Topple extends Map { 17 | 18 | private static String mapPath = "asset/map/Topple.tmx"; 19 | private Json json; 20 | 21 | public Topple() { 22 | super(MapFactory.MapType.TOPPLE, mapPath); 23 | 24 | json = new Json(); 25 | 26 | Entity innKeeper = EntityFactory.getInstance().getEntityByName(EntityFactory.EntityName.TOWN_INNKEEPER); 27 | initSpecialEntityPosition(innKeeper); 28 | mapEntities.add(innKeeper); 29 | 30 | Entity townfolk1 = EntityFactory.getInstance().getEntityByName(EntityFactory.EntityName.TOWN_FOLK1); 31 | initSpecialEntityPosition(townfolk1); 32 | mapEntities.add(townfolk1); 33 | 34 | Entity townfolk2 = EntityFactory.getInstance().getEntityByName(EntityFactory.EntityName.TOWN_FOLK2); 35 | initSpecialEntityPosition(townfolk2); 36 | mapEntities.add(townfolk2); 37 | 38 | Entity townfolk3 = EntityFactory.getInstance().getEntityByName(EntityFactory.EntityName.TOWN_FOLK3); 39 | initSpecialEntityPosition(townfolk3); 40 | mapEntities.add(townfolk3); 41 | 42 | Entity townfolk4 = EntityFactory.getInstance().getEntityByName(EntityFactory.EntityName.TOWN_FOLK4); 43 | initSpecialEntityPosition(townfolk4); 44 | mapEntities.add(townfolk4); 45 | } 46 | 47 | @Override 48 | public AudioObserver.AudioTypeEvent getMusicTheme() { 49 | return TOPPLE_THEME; 50 | } 51 | 52 | @Override 53 | public void unloadMusic() { 54 | notify(AudioObserver.AudioCommand.MUSIC_STOP, getMusicTheme()); 55 | } 56 | 57 | @Override 58 | public void loadMusic() { 59 | notify(AudioObserver.AudioCommand.MUSIC_LOAD, getMusicTheme()); 60 | notify(AudioObserver.AudioCommand.MUSIC_PLAY_LOOP, getMusicTheme()); 61 | } 62 | 63 | private void initSpecialEntityPosition(Entity entity) { 64 | Vector2 position = new Vector2(0,0); 65 | 66 | if (specialNPCStartPositions.containsKey(entity.getEntityConfig().getEntityID())) { 67 | position = specialNPCStartPositions.get(entity.getEntityConfig().getEntityID()); 68 | } 69 | entity.sendMessage(Component.MESSAGE.INIT_START_POSITION, json.toJson(position)); 70 | 71 | //Overwrite default if special config is found 72 | EntityConfig entityConfig = ProfileManager.getInstance().getProperty(entity.getEntityConfig().getEntityID(), EntityConfig.class); 73 | if (entityConfig != null ) { 74 | entity.setEntityConfig(entityConfig); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/map/worldMap/ToppleRoad1.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.map.worldMap; 2 | 3 | import com.badlogic.gdx.math.Vector2; 4 | import com.gdx.game.audio.AudioObserver; 5 | import com.gdx.game.component.Component; 6 | import com.gdx.game.entities.Entity; 7 | import com.gdx.game.entities.EntityConfig; 8 | import com.gdx.game.entities.EntityFactory; 9 | import com.gdx.game.map.Map; 10 | import com.gdx.game.map.MapFactory; 11 | import com.gdx.game.profile.ProfileManager; 12 | 13 | import static com.gdx.game.audio.AudioObserver.AudioTypeEvent.TEST_THEME; 14 | 15 | public class ToppleRoad1 extends Map { 16 | 17 | private static String mapPath = "asset/map/Topple_Road_1.tmx"; 18 | 19 | public ToppleRoad1() { 20 | super(MapFactory.MapType.TOPPLE_ROAD_1, mapPath); 21 | 22 | //Special cases 23 | Entity rabite = EntityFactory.getInstance().getEntityByName(EntityFactory.EntityName.RABITE); 24 | initSpecialEntityPosition(rabite); 25 | mapEntities.add(rabite); 26 | 27 | Entity rabite2 = EntityFactory.getInstance().getEntityByName(EntityFactory.EntityName.RABITE2); 28 | initSpecialEntityPosition(rabite2); 29 | mapEntities.add(rabite2); 30 | 31 | } 32 | 33 | @Override 34 | public AudioObserver.AudioTypeEvent getMusicTheme() { 35 | return TEST_THEME; 36 | } 37 | 38 | @Override 39 | public void unloadMusic() { 40 | notify(AudioObserver.AudioCommand.MUSIC_STOP, getMusicTheme()); 41 | } 42 | 43 | @Override 44 | public void loadMusic() { 45 | notify(AudioObserver.AudioCommand.MUSIC_LOAD, getMusicTheme()); 46 | notify(AudioObserver.AudioCommand.MUSIC_PLAY_LOOP, getMusicTheme()); 47 | } 48 | 49 | private void initSpecialEntityPosition(Entity entity) { 50 | Vector2 position = new Vector2(0,0); 51 | 52 | if (enemyStartPositions.containsKey(entity.getEntityConfig().getEntityID())) { 53 | position = enemyStartPositions.get(entity.getEntityConfig().getEntityID()); 54 | } 55 | entity.sendMessage(Component.MESSAGE.INIT_START_POSITION, json.toJson(position)); 56 | 57 | //Overwrite default if special config is found 58 | EntityConfig entityConfig = ProfileManager.getInstance().getProperty(entity.getEntityConfig().getEntityID(), EntityConfig.class); 59 | if (entityConfig != null ) { 60 | entity.setEntityConfig(entityConfig); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/profile/ProfileObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.profile; 2 | 3 | public interface ProfileObserver { 4 | enum ProfileEvent { 5 | PROFILE_LOADED, 6 | SAVING_PROFILE, 7 | CLEAR_CURRENT_PROFILE 8 | } 9 | 10 | void onNotify(final ProfileManager profileManager, ProfileEvent event); 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/profile/ProfileSubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.profile; 2 | 3 | import com.badlogic.gdx.utils.Array; 4 | 5 | public class ProfileSubject { 6 | 7 | private Array observers; 8 | 9 | public ProfileSubject() { 10 | observers = new Array<>(); 11 | } 12 | 13 | public void addObserver(ProfileObserver profileObserver) { 14 | observers.add(profileObserver); 15 | } 16 | 17 | public void removeObserver(ProfileObserver profileObserver) { 18 | observers.removeValue(profileObserver, true); 19 | } 20 | 21 | public void removeAllObservers() { 22 | observers.removeAll(observers, true); 23 | } 24 | 25 | protected void notify(final ProfileManager profileManager, ProfileObserver.ProfileEvent event) { 26 | for(ProfileObserver observer: observers) { 27 | observer.onNotify(profileManager, event); 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/quest/FetchQuestTaskHandler.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.quest; 2 | 3 | import com.badlogic.gdx.math.Vector2; 4 | import com.badlogic.gdx.utils.Array; 5 | import com.gdx.game.entities.Entity; 6 | import com.gdx.game.entities.EntityConfig; 7 | import com.gdx.game.map.MapManager; 8 | import com.gdx.game.profile.ProfileManager; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | public class FetchQuestTaskHandler implements QuestTaskHandler { 13 | 14 | private static final Logger LOGGER = LoggerFactory.getLogger(QuestGraph.class); 15 | 16 | @Override 17 | public void handleUpdate(QuestTask questTask, String questID) { 18 | String taskConfig = questTask.getPropertyValue(QuestTask.QuestTaskPropertyType.TARGET_TYPE.toString()); 19 | if (taskConfig == null || taskConfig.isEmpty()) 20 | return; 21 | EntityConfig config = Entity.getEntityConfig(taskConfig); 22 | 23 | Array questItemPositions = ProfileManager.getInstance().getProperty(config.getEntityID(), Array.class); 24 | //Case where all the items have been picked up 25 | if (questItemPositions != null && questItemPositions.size == 0) { 26 | questTask.setTaskComplete(); 27 | LOGGER.debug("TASK : {} is complete of Quest: {}", questTask.getId(), questID); 28 | LOGGER.debug("INFO : {}", QuestTask.QuestTaskPropertyType.TARGET_TYPE); 29 | } 30 | } 31 | 32 | @Override 33 | public void handleInit(MapManager mapManager, QuestTask questTask, String questID) { 34 | 35 | String taskConfig = questTask.getPropertyValue(QuestTask.QuestTaskPropertyType.TARGET_TYPE.toString()); 36 | if (taskConfig == null || taskConfig.isEmpty()) 37 | return; 38 | 39 | Array questEntities = new Array<>(); 40 | Array positions = mapManager.getQuestItemSpawnPositions(questID, questTask.getId()); 41 | EntityConfig config = Entity.getEntityConfig(taskConfig); 42 | Array questItemPositions = ProfileManager.getInstance().getProperty(config.getEntityID(), Array.class); 43 | 44 | if (questItemPositions == null) { 45 | questItemPositions = new Array<>(positions); 46 | addQuestEntities(config, positions, questID, questEntities); 47 | } else { 48 | addQuestEntities(config, positions, questID, questEntities); 49 | } 50 | 51 | mapManager.addMapQuestEntities(questEntities); 52 | ProfileManager.getInstance().setProperty(config.getEntityID(), questItemPositions); 53 | } 54 | 55 | private void addQuestEntities(EntityConfig config, Array positions, String questID, Array questEntities) { 56 | for (Vector2 position : positions) { 57 | Entity entity = Entity.initEntity(config, position); 58 | entity.getEntityConfig().setCurrentQuestID(questID); 59 | questEntities.add(entity); 60 | } 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/quest/QuestTask.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.quest; 2 | 3 | import com.badlogic.gdx.utils.ObjectMap; 4 | 5 | public class QuestTask { 6 | 7 | public enum QuestType{ 8 | FETCH, 9 | KILL, 10 | DELIVERY, 11 | GUARD, 12 | ESCORT, 13 | RETURN, 14 | DISCOVER 15 | } 16 | 17 | public enum QuestTaskPropertyType { 18 | IS_TASK_COMPLETE, 19 | TARGET_TYPE, 20 | TARGET_NUM, 21 | TARGET_LOCATION, 22 | NONE 23 | } 24 | 25 | private ObjectMap taskProperties; 26 | private String id; 27 | private String taskPhrase; 28 | private QuestType questType; 29 | 30 | public QuestTask() { 31 | taskProperties = new ObjectMap<>(); 32 | } 33 | 34 | public String getId() { 35 | return id; 36 | } 37 | 38 | public void setId(String id) { 39 | this.id = id; 40 | } 41 | 42 | public String getTaskPhrase() { 43 | return taskPhrase; 44 | } 45 | 46 | public void setTaskPhrase(String taskPhrase) { 47 | this.taskPhrase = taskPhrase; 48 | } 49 | 50 | public QuestType getQuestType() { 51 | return questType; 52 | } 53 | 54 | public void setQuestType(QuestType questType) { 55 | this.questType = questType; 56 | } 57 | 58 | public ObjectMap getTaskProperties() { 59 | return taskProperties; 60 | } 61 | 62 | public void setTaskProperties(ObjectMap taskProperties) { 63 | this.taskProperties = taskProperties; 64 | } 65 | 66 | public boolean isTaskComplete() { 67 | if (!taskProperties.containsKey(QuestTaskPropertyType.IS_TASK_COMPLETE.toString())) { 68 | setPropertyValue(QuestTaskPropertyType.IS_TASK_COMPLETE.toString(), "false"); 69 | return false; 70 | } 71 | String val = taskProperties.get(QuestTaskPropertyType.IS_TASK_COMPLETE.toString()).toString(); 72 | return Boolean.parseBoolean(val); 73 | } 74 | 75 | public void setTaskComplete() { 76 | setPropertyValue(QuestTaskPropertyType.IS_TASK_COMPLETE.toString(), "true"); 77 | } 78 | 79 | public void resetAllProperties() { 80 | taskProperties.put(QuestTaskPropertyType.IS_TASK_COMPLETE.toString(), "false"); 81 | } 82 | 83 | public void setPropertyValue(String key, String value) { 84 | taskProperties.put(key, value); 85 | } 86 | 87 | public String getPropertyValue(String key) { 88 | Object propertyVal = taskProperties.get(key); 89 | if (propertyVal == null) { 90 | return ""; 91 | } 92 | return propertyVal.toString(); 93 | } 94 | 95 | public String toString() { 96 | return taskPhrase; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/quest/QuestTaskDependency.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.quest; 2 | 3 | public class QuestTaskDependency { 4 | private String sourceId; 5 | private String destinationId; 6 | 7 | public QuestTaskDependency() { 8 | 9 | } 10 | 11 | public String getSourceId() { 12 | return sourceId; 13 | } 14 | 15 | public void setSourceId(String sourceId) { 16 | this.sourceId = sourceId; 17 | } 18 | 19 | public String getDestinationId() { 20 | return destinationId; 21 | } 22 | 23 | public void setDestinationId(String destinationId) { 24 | this.destinationId = destinationId; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/quest/QuestTaskHandler.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.quest; 2 | 3 | import com.gdx.game.map.MapManager; 4 | 5 | public interface QuestTaskHandler { 6 | 7 | void handleUpdate(QuestTask questTask, String questID); 8 | 9 | void handleInit(MapManager mapManager, QuestTask questTask, String questID); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/screen/TransitionScreen.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen; 2 | 3 | import com.badlogic.gdx.Game; 4 | import com.gdx.game.GdxGame; 5 | import com.gdx.game.audio.AudioObserver; 6 | import com.gdx.game.screen.transition.effects.TransitionEffect; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Arrays; 10 | 11 | public class TransitionScreen extends BaseScreen { 12 | 13 | private Game game; 14 | private BaseScreen current; 15 | private BaseScreen next; 16 | 17 | int currentTransitionEffect; 18 | ArrayList transitionEffects; 19 | 20 | TransitionScreen(Game game, BaseScreen current, BaseScreen next, ArrayList transitionEffects) { 21 | super((GdxGame) game, null); 22 | this.current = current; 23 | this.next = next; 24 | this.transitionEffects = transitionEffects; 25 | this.currentTransitionEffect = 0; 26 | this.game = game; 27 | } 28 | 29 | @Override 30 | public void render(float delta) { 31 | if (next.getClass() != OptionScreen.class) { 32 | Arrays.stream(AudioObserver.AudioTypeEvent.values()) 33 | .filter(e -> e.equals(current.getMusicTheme())) 34 | .findFirst() 35 | .filter(a -> !a.equals(next.getMusicTheme())) 36 | .ifPresent(a -> notify(AudioObserver.AudioCommand.MUSIC_STOP, a)); 37 | } 38 | 39 | if (currentTransitionEffect >= transitionEffects.size()) { 40 | game.setScreen(next); 41 | return; 42 | } 43 | 44 | transitionEffects.get(currentTransitionEffect).update(delta); 45 | transitionEffects.get(currentTransitionEffect).render(current, next); 46 | 47 | if (transitionEffects.get(currentTransitionEffect).isFinished()) { 48 | currentTransitionEffect++; 49 | } 50 | 51 | } 52 | 53 | @Override 54 | public void show() { 55 | // Nothing 56 | } 57 | 58 | @Override 59 | public void resize(int width, int height) { 60 | // Nothing 61 | } 62 | 63 | @Override 64 | public void pause() { 65 | // Nothing 66 | } 67 | 68 | @Override 69 | public void resume() { 70 | // Nothing 71 | } 72 | 73 | @Override 74 | public void hide() { 75 | // Nothing 76 | } 77 | 78 | @Override 79 | public void dispose() { 80 | current.dispose(); 81 | next.dispose(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/screen/cutscene/CreatorIntroScreen.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.cutscene; 2 | 3 | import com.badlogic.gdx.math.Interpolation; 4 | import com.badlogic.gdx.scenes.scene2d.Action; 5 | import com.badlogic.gdx.scenes.scene2d.actions.Actions; 6 | import com.badlogic.gdx.scenes.scene2d.actions.RunnableAction; 7 | import com.gdx.game.GdxGame; 8 | import com.gdx.game.animation.AnimatedImage; 9 | import com.gdx.game.entities.Entity; 10 | import com.gdx.game.entities.EntityFactory; 11 | import com.gdx.game.manager.ResourceManager; 12 | import com.gdx.game.map.MapFactory; 13 | 14 | public class CreatorIntroScreen extends CutSceneBaseScreen { 15 | private Action setupScene01; 16 | private AnimatedImage creator; 17 | 18 | public CreatorIntroScreen(GdxGame game, ResourceManager resourceManager) { 19 | super(game, resourceManager); 20 | 21 | creator = getAnimatedImage(EntityFactory.EntityType.THIEF); 22 | creator.setName("Creator"); 23 | 24 | setupScene01 = new RunnableAction() { 25 | @Override 26 | public void run() { 27 | hideMessage(); 28 | mapManager.loadMap(MapFactory.MapType.TOPPLE); 29 | mapManager.disableCurrentMapMusic(); 30 | setCameraPosition(17, 10); 31 | 32 | creator.setCurrentAnimation(Entity.AnimationType.WALK_UP); 33 | creator.setVisible(true); 34 | creator.setPosition(17, 0); 35 | } 36 | }; 37 | 38 | getStage().addActor(creator); 39 | } 40 | 41 | Action getCutsceneAction() { 42 | setupScene01.reset(); 43 | getSwitchScreenAction().reset(); 44 | 45 | return Actions.sequence( 46 | Actions.addAction(setupScene01), 47 | Actions.delay(1), 48 | Actions.addAction(Actions.moveTo(17, 10, 5, Interpolation.linear), creator), 49 | Actions.delay(Float.parseFloat("2.5")), 50 | Actions.addAction(Actions.run(() -> creator.setCurrentAnimation(Entity.AnimationType.IMMOBILE))), 51 | Actions.run(() -> showMessage(creator, "Hello adventurer! Welcome to my game, or at least my prototype game!")), 52 | Actions.delay(5), 53 | Actions.run(() -> showMessage(creator, "Many thanks for your interest in my project, i hope you will like it.")), 54 | Actions.delay(5), 55 | Actions.run(() -> showMessage(creator, "Do not hesitate to contribute or suggest any idea that you might have. Help is always welcome!")), 56 | Actions.delay(5), 57 | Actions.run(() -> showMessage(creator, "Have fun :)")), 58 | Actions.delay(3), 59 | Actions.after(getSwitchScreenAction()) 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/screen/transition/ImmediateModeRendererUtils.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.transition; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.Color; 5 | import com.badlogic.gdx.graphics.GL20; 6 | import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer; 7 | import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20; 8 | import com.badlogic.gdx.graphics.glutils.ShapeRenderer; 9 | import com.badlogic.gdx.math.Matrix4; 10 | 11 | public class ImmediateModeRendererUtils { 12 | 13 | private static final ImmediateModeRenderer renderer = new ImmediateModeRenderer20(true, true, 0); 14 | private static Matrix4 projectionMatrix = null; 15 | 16 | private ImmediateModeRendererUtils() { 17 | } 18 | 19 | public static Matrix4 getProjectionMatrix() { 20 | if (projectionMatrix == null) { 21 | projectionMatrix = new Matrix4(); 22 | projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); 23 | } 24 | return projectionMatrix; 25 | } 26 | 27 | public static void drawFillArcCircle(float x, float y, float radius, Color color) { 28 | int angle = 0; 29 | int segNum = 24; 30 | int arcNum = 360 / segNum; 31 | ShapeRenderer shapeRenderer = new ShapeRenderer(); 32 | 33 | shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); 34 | shapeRenderer.setColor(color.r, color.g, color.b, color.a); 35 | 36 | for (int i = 0; i <= segNum + 1; i++, angle = i * arcNum) { 37 | shapeRenderer.arc(x, y, radius, 0, angle); 38 | } 39 | 40 | shapeRenderer.end(); 41 | } 42 | 43 | public static void fillRectangle(float x0, float y0, float x1, float y1, Color color) { 44 | renderer.begin(getProjectionMatrix(), GL20.GL_TRIANGLES); 45 | 46 | // first triangle 47 | renderer.color(color.r, color.g, color.b, color.a); 48 | renderer.vertex(x0, y0, 0f); 49 | 50 | renderer.color(color.r, color.g, color.b, color.a); 51 | renderer.vertex(x0, y1, 0f); 52 | 53 | renderer.color(color.r, color.g, color.b, color.a); 54 | renderer.vertex(x1, y1, 0f); 55 | 56 | // second triangle 57 | renderer.color(color.r, color.g, color.b, color.a); 58 | renderer.vertex(x1, y1, 0f); 59 | 60 | renderer.color(color.r, color.g, color.b, color.a); 61 | renderer.vertex(x1, y0, 0f); 62 | 63 | renderer.color(color.r, color.g, color.b, color.a); 64 | renderer.vertex(x0, y0, 0f); 65 | 66 | renderer.end(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/screen/transition/TimeTransition.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.transition; 2 | 3 | public class TimeTransition { 4 | 5 | private float transitionTime; 6 | private float currentTime; 7 | 8 | private boolean finished = true; 9 | private boolean started = false; 10 | 11 | public boolean isFinished() { 12 | return finished; 13 | } 14 | 15 | /** 16 | * Returns the percentage of the current time over the total time. 17 | */ 18 | public float get() { 19 | if (transitionTime == 0) { 20 | return 1f; 21 | } 22 | return (currentTime / transitionTime); 23 | } 24 | 25 | public void start(float time) { 26 | this.transitionTime = time; 27 | this.currentTime = 0; 28 | this.finished = false; 29 | this.started = true; 30 | } 31 | 32 | public void stop() { 33 | this.started = false; 34 | this.finished = false; 35 | } 36 | 37 | public void update(float time) { 38 | if (!started) { 39 | return; 40 | } 41 | if (finished) { 42 | return; 43 | } 44 | this.currentTime += time; 45 | if (currentTime >= transitionTime) { 46 | currentTime = transitionTime; 47 | finished = true; 48 | } 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/screen/transition/effects/FadeInTransitionEffect.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.transition.effects; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.Screen; 5 | import com.badlogic.gdx.graphics.Color; 6 | import com.badlogic.gdx.graphics.GL20; 7 | import com.gdx.game.screen.transition.ImmediateModeRendererUtils; 8 | 9 | public class FadeInTransitionEffect extends TransitionEffect { 10 | 11 | private Color color = new Color(); 12 | 13 | public FadeInTransitionEffect(float duration) { 14 | super(duration); 15 | } 16 | 17 | @Override 18 | public void render(Screen current, Screen next) { 19 | //next.show(); 20 | next.render(Gdx.graphics.getDeltaTime()); 21 | color.set(0f, 0f, 0f, 1f - getAlpha()); 22 | 23 | Gdx.gl20.glEnable(GL20.GL_BLEND); 24 | ImmediateModeRendererUtils.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); 25 | ImmediateModeRendererUtils.fillRectangle(0f, 0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), color); 26 | Gdx.gl20.glDisable(GL20.GL_BLEND); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/screen/transition/effects/FadeOutTransitionEffect.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.transition.effects; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.Screen; 5 | import com.badlogic.gdx.graphics.Color; 6 | import com.badlogic.gdx.graphics.GL20; 7 | import com.gdx.game.screen.transition.ImmediateModeRendererUtils; 8 | 9 | public class FadeOutTransitionEffect extends TransitionEffect { 10 | 11 | private Color color = new Color(); 12 | 13 | public FadeOutTransitionEffect(float duration) { 14 | super(duration); 15 | } 16 | 17 | @Override 18 | public void render(Screen current, Screen next) { 19 | //current.show(); 20 | current.render(Gdx.graphics.getDeltaTime()); 21 | color.set(0f, 0f, 0f, getAlpha()); 22 | 23 | Gdx.gl20.glEnable(GL20.GL_BLEND); 24 | ImmediateModeRendererUtils.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); 25 | ImmediateModeRendererUtils.fillRectangle(0f, 0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), color); 26 | Gdx.gl20.glDisable(GL20.GL_BLEND); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/screen/transition/effects/RotationTransitionEffect.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.transition.effects; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.Screen; 5 | import com.badlogic.gdx.graphics.Color; 6 | import com.badlogic.gdx.graphics.GL20; 7 | import com.gdx.game.screen.transition.ImmediateModeRendererUtils; 8 | 9 | public class RotationTransitionEffect extends TransitionEffect { 10 | 11 | private Color color = new Color(); 12 | 13 | public RotationTransitionEffect(float duration) { 14 | super(duration); 15 | } 16 | 17 | @Override 18 | public void render(Screen current, Screen next) { 19 | current.render(Gdx.graphics.getDeltaTime()); 20 | color.set(0f, 0f, 0f, getAlpha()); 21 | 22 | Gdx.gl20.glEnable(GL20.GL_BLEND); 23 | ImmediateModeRendererUtils.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); 24 | ImmediateModeRendererUtils.drawFillArcCircle((float) Gdx.graphics.getWidth()/2, (float) Gdx.graphics.getHeight()/2, Gdx.graphics.getWidth(), color); 25 | Gdx.gl20.glDisable(GL20.GL_BLEND); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/screen/transition/effects/TransitionEffect.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.transition.effects; 2 | 3 | import com.badlogic.gdx.Screen; 4 | import com.gdx.game.screen.transition.TimeTransition; 5 | 6 | public class TransitionEffect { 7 | 8 | private TimeTransition timeTransition; 9 | 10 | public TransitionEffect(float duration) { 11 | timeTransition = new TimeTransition(); 12 | timeTransition.start(duration); 13 | } 14 | 15 | protected float getAlpha() { 16 | return timeTransition.get(); 17 | } 18 | 19 | public void update(float delta) { 20 | timeTransition.update(delta); 21 | } 22 | 23 | public void render(Screen current, Screen next) { 24 | // Nothing 25 | } 26 | 27 | public boolean isFinished() { 28 | return timeTransition.isFinished(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/status/LevelTable.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.status; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.utils.Array; 5 | import com.badlogic.gdx.utils.Json; 6 | import com.badlogic.gdx.utils.JsonValue; 7 | 8 | import java.util.ArrayList; 9 | import java.util.stream.Stream; 10 | 11 | public class LevelTable { 12 | private String levelID; 13 | private int xpMax; 14 | private int hpMax; 15 | private int mpMax; 16 | 17 | public String getLevelID() { 18 | return levelID; 19 | } 20 | 21 | public void setLevelID(String levelID) { 22 | this.levelID = levelID; 23 | } 24 | 25 | public int getXpMax() { 26 | return xpMax; 27 | } 28 | 29 | public void setXpMax(int xpMax) { 30 | this.xpMax = xpMax; 31 | } 32 | 33 | public int getHpMax() { 34 | return hpMax; 35 | } 36 | 37 | public void setHpMax(int hpMax) { 38 | this.hpMax = hpMax; 39 | } 40 | 41 | public int getMpMax() { 42 | return mpMax; 43 | } 44 | 45 | public void setMpMax(int mpMax) { 46 | this.mpMax = mpMax; 47 | } 48 | 49 | static public Array getLevelTables(String configFilePath){ 50 | Json json = new Json(); 51 | Array levelTable = new Array<>(); 52 | 53 | ArrayList list = json.fromJson(ArrayList.class, Gdx.files.internal(configFilePath)); 54 | list.forEach(v -> levelTable.add(json.readValue(LevelTable.class, v))); 55 | 56 | return levelTable; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/status/StatusObserver.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.status; 2 | 3 | public interface StatusObserver { 4 | enum StatusEvent { 5 | UPDATED_GP, 6 | UPDATED_LEVEL, 7 | UPDATED_LEVEL_FROM_QUEST, 8 | UPDATED_HP, 9 | UPDATED_MP, 10 | UPDATED_XP, 11 | LEVELED_UP 12 | } 13 | 14 | void onNotify(final int value, StatusEvent event); 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/gdx/game/status/StatusSubject.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.status; 2 | 3 | 4 | public interface StatusSubject { 5 | void addObserver(StatusObserver statusObserver); 6 | void removeObserver(StatusObserver statusObserver); 7 | void removeAllObservers(); 8 | void notify(final int value, StatusObserver.StatusEvent event); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/resources/asset/background/battleBackground_meadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/background/battleBackground_meadow.png -------------------------------------------------------------------------------- /core/src/main/resources/asset/background/natureBackground_frames_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/background/natureBackground_frames_sheet.png -------------------------------------------------------------------------------- /core/src/main/resources/asset/data/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/data/default.png -------------------------------------------------------------------------------- /core/src/main/resources/asset/data/uiskin.json: -------------------------------------------------------------------------------- 1 | { 2 | BitmapFont: { default-font: { file: default.fnt } }, 3 | Color: { 4 | green: { a: 1, b: 0, g: 1, r: 0 }, 5 | white: { a: 1, b: 1, g: 1, r: 1 }, 6 | red: { a: 1, b: 0, g: 0, r: 1 }, 7 | black: { a: 1, b: 0, g: 0, r: 0 }, 8 | gray: { a: 1, b: 0.8, g: 0.8, r: 0.8 }, 9 | }, 10 | TintedDrawable: { 11 | dialogDim: { name: white, color: { r: 0, g: 0, b: 0, a: 0.45 } }, 12 | }, 13 | ButtonStyle: { 14 | default: { down: default-round-down, up: default-round, disabled: default-round }, 15 | toggle: { parent: default, checked: default-round-down }, 16 | }, 17 | TextButtonStyle: { 18 | default: { parent: default, font: default-font, fontColor: white, disabledFontColor: gray }, 19 | toggle: { parent: default, checked: default-round-down, downFontColor: red } 20 | }, 21 | ImageButtonStyle: { 22 | plus: { down: default-round-down, up: default-round, imageUp: tree-plus }, 23 | minus: { down: default-round-down, up: default-round, imageUp: tree-minus } 24 | }, 25 | ScrollPaneStyle: { 26 | default: { vScroll: default-scroll, hScrollKnob: default-round-large, background: default-rect, hScroll: default-scroll, vScrollKnob: default-round-large } 27 | }, 28 | SelectBoxStyle: { 29 | default: { 30 | font: default-font, fontColor: white, background: default-select, 31 | scrollStyle: default, 32 | listStyle: { font: default-font, selection: default-select-selection } 33 | } 34 | }, 35 | SplitPaneStyle: { 36 | default-vertical: { handle: default-splitpane-vertical }, 37 | default-horizontal: { handle: default-splitpane } 38 | }, 39 | WindowStyle: { 40 | default: { titleFont: default-font, background: default-window, titleFontColor: white }, 41 | dialog: { parent: default, stageBackground: dialogDim } 42 | }, 43 | ProgressBarStyle: { 44 | default-horizontal: { background: default-slider, knob: default-slider-knob }, 45 | default-vertical: { background: default-slider, knob: default-round-large } 46 | }, 47 | SliderStyle: { 48 | default-horizontal: { parent: default-horizontal }, 49 | default-vertical: { parent: default-vertical } 50 | }, 51 | LabelStyle: { 52 | default: { font: default-font, fontColor: white } 53 | }, 54 | TextFieldStyle: { 55 | default: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor } 56 | }, 57 | CheckBoxStyle: { 58 | default: { checkboxOn: check-on, checkboxOff: check-off, font: default-font, fontColor: white } 59 | }, 60 | ListStyle: { 61 | default: { fontColorUnselected: white, selection: selection, fontColorSelected: white, font: default-font } 62 | }, 63 | TouchpadStyle: { 64 | default: { background: default-pane, knob: default-round-large } 65 | }, 66 | TreeStyle: { 67 | default: { minus: tree-minus, plus: tree-plus, selection: default-select-selection } 68 | }, 69 | TextTooltipStyle: { 70 | default: { 71 | label: { font: default-font, fontColor: white }, 72 | background: default-pane, wrapWidth: 150 73 | } 74 | }, 75 | } -------------------------------------------------------------------------------- /core/src/main/resources/asset/data/uiskin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/data/uiskin.png -------------------------------------------------------------------------------- /core/src/main/resources/asset/map/mana1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/map/mana1.png -------------------------------------------------------------------------------- /core/src/main/resources/asset/map/mana1.tsx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /core/src/main/resources/asset/map/mana2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/map/mana2.png -------------------------------------------------------------------------------- /core/src/main/resources/asset/map/mana2.tsx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /core/src/main/resources/asset/map/mana3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/map/mana3.png -------------------------------------------------------------------------------- /core/src/main/resources/asset/map/mana3.tsx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /core/src/main/resources/asset/map/swordofmana_map1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/map/swordofmana_map1.png -------------------------------------------------------------------------------- /core/src/main/resources/asset/map/swordofmana_map1.tsx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /core/src/main/resources/asset/textures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/textures.png -------------------------------------------------------------------------------- /core/src/main/resources/asset/tool/cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/asset/tool/cursor.png -------------------------------------------------------------------------------- /core/src/main/resources/conversations/conversation002.json: -------------------------------------------------------------------------------- 1 | { 2 | conversations: { 3 | 1: { 4 | id: 1 5 | dialog: No time to conversate stranger. I must stay viligant at all times for the safety of our town! 6 | } 7 | } 8 | associatedChoices: { 9 | } 10 | currentConversationID: 1 11 | } -------------------------------------------------------------------------------- /core/src/main/resources/conversations/conversation003.json: -------------------------------------------------------------------------------- 1 | { 2 | conversations: { 3 | 1: { 4 | id: 1 5 | dialog: Hello Traveler. Would you like to see my wares? 6 | } 7 | 2: { 8 | id: 2 9 | dialog: Ok 10 | } 11 | 3: { 12 | id: 3 13 | dialog: Ok 14 | } 15 | } 16 | associatedChoices: { 17 | 1: [ 18 | { 19 | class: com.gdx.game.dialog.ConversationChoice 20 | sourceId: 1 21 | destinationId: 2 22 | choicePhrase: Yes 23 | conversationCommandEvent: LOAD_STORE_INVENTORY 24 | } 25 | { 26 | class: com.gdx.game.dialog.ConversationChoice 27 | sourceId: 1 28 | destinationId: 3 29 | choicePhrase: No 30 | conversationCommandEvent: EXIT_CONVERSATION 31 | } 32 | ] 33 | } 34 | currentConversationID: 1 35 | } -------------------------------------------------------------------------------- /core/src/main/resources/conversations/conversation004.json: -------------------------------------------------------------------------------- 1 | { 2 | conversations: { 3 | 1: { 4 | id: 1 5 | dialog: Can you please help me mister? My mother is sick but I can't find the herbs she needs around town! 6 | } 7 | 2: { 8 | id: 2 9 | dialog: Ok 10 | } 11 | 3: { 12 | id: 3 13 | dialog: Ok 14 | } 15 | } 16 | associatedChoices: { 17 | 1: [ 18 | { 19 | class: com.gdx.game.dialog.ConversationChoice 20 | sourceId: 1 21 | destinationId: 2 22 | choicePhrase: "Yes, of course I will help you!" 23 | conversationCommandEvent: ACCEPT_QUEST 24 | } 25 | { 26 | class: com.gdx.game.dialog.ConversationChoice 27 | sourceId: 1 28 | destinationId: 3 29 | choicePhrase: "No, sorry, I can't help you." 30 | conversationCommandEvent: EXIT_CONVERSATION 31 | } 32 | ] 33 | } 34 | currentConversationID: 1 35 | } -------------------------------------------------------------------------------- /core/src/main/resources/conversations/conversation005.json: -------------------------------------------------------------------------------- 1 | { 2 | conversations: { 3 | 1: { 4 | id: 1 5 | dialog: Would you like to pick up the item? 6 | } 7 | 2: { 8 | id: 2 9 | dialog: Ok 10 | } 11 | 3: { 12 | id: 3 13 | dialog: Ok 14 | } 15 | } 16 | associatedChoices: { 17 | 1: [ 18 | { 19 | class: com.gdx.game.dialog.ConversationChoice 20 | sourceId: 1 21 | destinationId: 2 22 | choicePhrase: Yes 23 | conversationCommandEvent: ADD_ENTITY_TO_INVENTORY 24 | } 25 | { 26 | class: com.gdx.game.dialog.ConversationChoice 27 | sourceId: 1 28 | destinationId: 3 29 | choicePhrase: No 30 | conversationCommandEvent: EXIT_CONVERSATION 31 | } 32 | ] 33 | } 34 | currentConversationID: 1 35 | } -------------------------------------------------------------------------------- /core/src/main/resources/conversations/conversation006.json: -------------------------------------------------------------------------------- 1 | { 2 | conversations: { 3 | 1: { 4 | id: 1 5 | dialog: Can you please help me? I seem to have lost my baby! 6 | } 7 | 2: { 8 | id: 2 9 | dialog: Ok 10 | } 11 | 3: { 12 | id: 3 13 | dialog: Ok 14 | } 15 | } 16 | associatedChoices: { 17 | 1: [ 18 | { 19 | class: com.gdx.game.dialog.ConversationChoice 20 | sourceId: 1 21 | destinationId: 2 22 | choicePhrase: "Yes, of course I will help you!" 23 | conversationCommandEvent: ACCEPT_QUEST 24 | } 25 | { 26 | class: com.gdx.game.dialog.ConversationChoice 27 | sourceId: 1 28 | destinationId: 3 29 | choicePhrase: "No, sorry, I can't help you." 30 | conversationCommandEvent: EXIT_CONVERSATION 31 | } 32 | ] 33 | } 34 | currentConversationID: 1 35 | } -------------------------------------------------------------------------------- /core/src/main/resources/conversations/conversation007.json: -------------------------------------------------------------------------------- 1 | { 2 | conversations: { 3 | 1: { 4 | id: 1 5 | dialog: "Can you please help me? I need some items outside town, and I am in no shape to fight those evil creatures." 6 | } 7 | 2: { 8 | id: 2 9 | dialog: Ok 10 | } 11 | 3: { 12 | id: 3 13 | dialog: Ok 14 | } 15 | } 16 | associatedChoices: { 17 | 1: [ 18 | { 19 | class: com.gdx.game.dialog.ConversationChoice 20 | sourceId: 1 21 | destinationId: 2 22 | choicePhrase: "Yes, of course I will help you!" 23 | conversationCommandEvent: ACCEPT_QUEST 24 | } 25 | { 26 | class: com.gdx.game.dialog.ConversationChoice 27 | sourceId: 1 28 | destinationId: 3 29 | choicePhrase: "No, sorry, I can't help you." 30 | conversationCommandEvent: EXIT_CONVERSATION 31 | } 32 | ] 33 | } 34 | currentConversationID: 1 35 | } -------------------------------------------------------------------------------- /core/src/main/resources/conversations/quest_finished.json: -------------------------------------------------------------------------------- 1 | { 2 | conversations: { 3 | 1: { 4 | id: 1 5 | dialog: Thank you! 6 | } 7 | } 8 | associatedChoices: { 9 | } 10 | currentConversationID: 1 11 | } -------------------------------------------------------------------------------- /core/src/main/resources/conversations/return_quest.json: -------------------------------------------------------------------------------- 1 | { 2 | conversations: { 3 | 1: { 4 | id: 1 5 | dialog: Have you finished my quest? 6 | } 7 | 2: { 8 | id: 2 9 | dialog: Ok 10 | } 11 | 3: { 12 | id: 3 13 | dialog: Ok 14 | } 15 | } 16 | associatedChoices: { 17 | 1: [ 18 | { 19 | class: com.gdx.game.dialog.ConversationChoice 20 | sourceId: 1 21 | destinationId: 2 22 | choicePhrase: Yes 23 | conversationCommandEvent: RETURN_QUEST 24 | } 25 | { 26 | class: com.gdx.game.dialog.ConversationChoice 27 | sourceId: 1 28 | destinationId: 3 29 | choicePhrase: No 30 | conversationCommandEvent: EXIT_CONVERSATION 31 | } 32 | ] 33 | } 34 | currentConversationID: 1 35 | } -------------------------------------------------------------------------------- /core/src/main/resources/conversations/testConversation001.json: -------------------------------------------------------------------------------- 1 | { 2 | conversations: { 3 | 802: { 4 | id: 802 5 | dialog: Too bad! 6 | } 7 | 250: { 8 | id: 250 9 | dialog: I am unconnected 10 | } 11 | 601: { 12 | id: 601 13 | dialog: BOOM! Bombs dropping everywhere 14 | } 15 | 500: { 16 | id: 500 17 | dialog: Do you want to play a game? 18 | } 19 | } 20 | associatedChoices: { 21 | 601: [ 22 | { 23 | class: com.gdx.game.dialog.ConversationChoice 24 | sourceId: 601 25 | destinationId: 500 26 | choicePhrase: Go to beginning! 27 | conversationCommandEvent: NONE 28 | } 29 | ] 30 | 250: [] 31 | 500: [ 32 | { 33 | class: com.gdx.game.dialog.ConversationChoice 34 | sourceId: 500 35 | destinationId: 601 36 | choicePhrase: YES 37 | conversationCommandEvent: NONE 38 | } 39 | { 40 | class: com.gdx.game.dialog.ConversationChoice 41 | sourceId: 500 42 | destinationId: 802 43 | choicePhrase: NO 44 | conversationCommandEvent: NONE 45 | } 46 | ] 47 | 802: [ 48 | { 49 | class: com.gdx.game.dialog.ConversationChoice 50 | sourceId: 802 51 | destinationId: 500 52 | choicePhrase: Go to beginning! 53 | conversationCommandEvent: NONE 54 | } 55 | ] 56 | } 57 | currentConversationID: 500 58 | } -------------------------------------------------------------------------------- /core/src/main/resources/entities/hero/hero_1_walking_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/entities/hero/hero_1_walking_up.png -------------------------------------------------------------------------------- /core/src/main/resources/fonts/SDS_6x6.hiero: -------------------------------------------------------------------------------- 1 | font.name=SDS_6x6 2 | font.size=18 3 | font.bold=false 4 | font.italic=false 5 | 6 | font2.file=D:\My Documents\Personal\My Projects\Mastering LibGDX Game Development\Chapters\04\work\SDS_6x6.ttf 7 | font2.use=true 8 | 9 | pad.top=0 10 | pad.right=0 11 | pad.bottom=0 12 | pad.left=0 13 | pad.advance.x=0 14 | pad.advance.y=0 15 | 16 | glyph.native.rendering=false 17 | glyph.page.width=512 18 | glyph.page.height=512 19 | glyph.text=ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\n1234567890\n"!`?'.,;:()[]{}<>|/@\^$-%+=#_&~* 20 | 21 | effect.class=com.badlogic.gdx.tools.hiero.unicodefont.effects.ColorEffect 22 | effect.Color=ffffff 23 | 24 | -------------------------------------------------------------------------------- /core/src/main/resources/fonts/SDS_6x6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/fonts/SDS_6x6.png -------------------------------------------------------------------------------- /core/src/main/resources/fonts/SDS_6x6_small.hiero: -------------------------------------------------------------------------------- 1 | font.name=SDS_6x6 2 | font.size=11 3 | font.bold=false 4 | font.italic=false 5 | 6 | font2.file=D:\My Documents\Personal\My Projects\Mastering LibGDX Game Development\Chapters\04\work\SDS_6x6.ttf 7 | font2.use=true 8 | 9 | pad.top=0 10 | pad.right=0 11 | pad.bottom=0 12 | pad.left=0 13 | pad.advance.x=0 14 | pad.advance.y=0 15 | 16 | glyph.native.rendering=false 17 | glyph.page.width=512 18 | glyph.page.height=512 19 | glyph.text=ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\n1234567890\n"!`?'.,;:()[]{}<>|/@\^$-%+=#_&~* 20 | 21 | effect.class=com.badlogic.gdx.tools.hiero.unicodefont.effects.ColorEffect 22 | effect.Color=ffffff 23 | 24 | -------------------------------------------------------------------------------- /core/src/main/resources/fonts/SDS_6x6_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/fonts/SDS_6x6_small.png -------------------------------------------------------------------------------- /core/src/main/resources/fonts/sans_serif_18.hiero: -------------------------------------------------------------------------------- 1 | font.name=SansSerif 2 | font.size=18 3 | font.bold=true 4 | font.italic=false 5 | 6 | font2.file=D:\My Documents\Personal\My Projects\Mastering LibGDX Game Development\Chapters\04\work\SDS_6x6.ttf 7 | font2.use=false 8 | 9 | pad.top=0 10 | pad.right=0 11 | pad.bottom=0 12 | pad.left=0 13 | pad.advance.x=0 14 | pad.advance.y=0 15 | 16 | glyph.native.rendering=false 17 | glyph.page.width=512 18 | glyph.page.height=512 19 | glyph.text=ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\n1234567890\n"!`?'.,;:()[]{}<>|/@\^$-%+=#_&~*\n€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œ\nžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»\n¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙ\nÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷\nøùúûüýþÿ 20 | 21 | effect.class=com.badlogic.gdx.tools.hiero.unicodefont.effects.ColorEffect 22 | effect.Color=ffffff 23 | 24 | -------------------------------------------------------------------------------- /core/src/main/resources/fonts/sans_serif_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/fonts/sans_serif_18.png -------------------------------------------------------------------------------- /core/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /core/src/main/resources/music/Challenge.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/music/Challenge.mp3 -------------------------------------------------------------------------------- /core/src/main/resources/music/Dwarves'_Theme.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/music/Dwarves'_Theme.mp3 -------------------------------------------------------------------------------- /core/src/main/resources/music/Requiem.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/music/Requiem.mp3 -------------------------------------------------------------------------------- /core/src/main/resources/music/Rising_Sun.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/music/Rising_Sun.mp3 -------------------------------------------------------------------------------- /core/src/main/resources/music/Village.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/music/Village.mp3 -------------------------------------------------------------------------------- /core/src/main/resources/quests/quest001.json: -------------------------------------------------------------------------------- 1 | { 2 | questTitle : "Beast Feast Leftovers" 3 | questID : 1 4 | goldReward : 100 5 | xpReward : 100 6 | isQuestComplete : FALSE 7 | questTasks: { 8 | 4: { 9 | taskProperties: { 10 | IS_TASK_COMPLETE: { 11 | class: java.lang.String 12 | value: "false" 13 | } 14 | TARGET_TYPE: { 15 | class: java.lang.String 16 | value: "BEAST_AREA" 17 | } 18 | TARGET_LOCATION: { 19 | class: java.lang.String 20 | value: "TOP_WORLD" 21 | } 22 | } 23 | id: 4 24 | taskPhrase: "Find the area where the Tuskan beast feasts, East of Town" 25 | questType : DISCOVER 26 | } 27 | 3: { 28 | taskProperties: { 29 | IS_TASK_COMPLETE: { 30 | class: java.lang.String 31 | value: "false" 32 | } 33 | TARGET_TYPE: { 34 | class: java.lang.String 35 | value: "scripts/quest001_task003.json" 36 | } 37 | TARGET_NUM: { 38 | class: java.lang.String 39 | value: "5" 40 | } 41 | TARGET_LOCATION: { 42 | class: java.lang.String 43 | value: "TOP_WORLD" 44 | } 45 | } 46 | id: 3 47 | taskPhrase: "Collect 5 furs" 48 | questType : FETCH 49 | } 50 | 2: { 51 | taskProperties: { 52 | IS_TASK_COMPLETE: { 53 | class: java.lang.String 54 | value: "false" 55 | } 56 | TARGET_TYPE: { 57 | class: java.lang.String 58 | value: "scripts/quest001_task002.json" 59 | } 60 | TARGET_NUM: { 61 | class: java.lang.String 62 | value: "5" 63 | } 64 | TARGET_LOCATION: { 65 | class: java.lang.String 66 | value: "TOP_WORLD" 67 | } 68 | } 69 | id: 2 70 | taskPhrase: "Collect 5 horns" 71 | questType : FETCH 72 | } 73 | 1: { 74 | taskProperties: { 75 | IS_TASK_COMPLETE: { 76 | class: java.lang.String 77 | value: "false" 78 | } 79 | TARGET_TYPE: { 80 | class: java.lang.String 81 | value: "TOWN_FOLK4" 82 | } 83 | TARGET_LOCATION: { 84 | class: java.lang.String 85 | value: "TOWN" 86 | } 87 | } 88 | id: 1 89 | taskPhrase: "Come back to me with the items" 90 | questType : RETURN 91 | } 92 | } 93 | questTaskDependencies: { 94 | 4: [] 95 | 3: [ 96 | { 97 | class: com.gdx.game.quest.QuestTaskDependency 98 | sourceId: 3 99 | destinationId: 4 100 | } 101 | ] 102 | 2: [ 103 | { 104 | class: com.gdx.game.quest.QuestTaskDependency 105 | sourceId: 2 106 | destinationId: 4 107 | } 108 | ] 109 | 1: [ 110 | { 111 | class: com.gdx.game.quest.QuestTaskDependency 112 | sourceId: 1 113 | destinationId: 2 114 | } 115 | { 116 | class: com.gdx.game.quest.QuestTaskDependency 117 | sourceId: 1 118 | destinationId: 3 119 | } 120 | ] 121 | } 122 | } -------------------------------------------------------------------------------- /core/src/main/resources/quests/quest002.json: -------------------------------------------------------------------------------- 1 | { 2 | questTitle : "Herbs for Mother" 3 | questID : 2 4 | goldReward : 20 5 | xpReward : 20 6 | isQuestComplete : FALSE 7 | questTasks: { 8 | 2: { 9 | taskProperties: { 10 | IS_TASK_COMPLETE: { 11 | class: java.lang.String 12 | value: "false" 13 | } 14 | TARGET_TYPE: { 15 | class: java.lang.String 16 | value: "scripts/quest002_task002.json" 17 | } 18 | TARGET_NUM: { 19 | class: java.lang.String 20 | value: "5" 21 | } 22 | TARGET_LOCATION: { 23 | class: java.lang.String 24 | value: "TOWN" 25 | } 26 | 27 | } 28 | id: 2 29 | taskPhrase: Please collect 5 herbs for my sick mother 30 | questType : FETCH 31 | } 32 | 1: { 33 | taskProperties: { 34 | IS_TASK_COMPLETE: { 35 | class: java.lang.String 36 | value: "false" 37 | } 38 | TARGET_TYPE: { 39 | class: java.lang.String 40 | value: "TOWN_FOLK1" 41 | } 42 | TARGET_LOCATION: { 43 | class: java.lang.String 44 | value: "TOWN" 45 | } 46 | } 47 | id: 1 48 | taskPhrase: Come back to me with the herbs 49 | questType : RETURN 50 | } 51 | } 52 | questTaskDependencies: { 53 | 1: [ 54 | { 55 | class: com.gdx.game.quest.QuestTaskDependency 56 | sourceId: 1 57 | destinationId: 2 58 | } 59 | ] 60 | 2: [] 61 | } 62 | } -------------------------------------------------------------------------------- /core/src/main/resources/quests/quest003.json: -------------------------------------------------------------------------------- 1 | { 2 | questTitle : "Give Me My Baby Back!" 3 | questID : 3 4 | goldReward : 20 5 | xpReward : 605 6 | isQuestComplete : FALSE 7 | questTasks: { 8 | 2: { 9 | taskProperties: { 10 | IS_TASK_COMPLETE: { 11 | class: java.lang.String 12 | value: "false" 13 | } 14 | TARGET_TYPE: { 15 | class: java.lang.String 16 | value: "scripts/quest003_task002.json" 17 | } 18 | TARGET_NUM: { 19 | class: java.lang.String 20 | value: "1" 21 | } 22 | TARGET_LOCATION: { 23 | class: java.lang.String 24 | value: "TOPPLE" 25 | } 26 | 27 | } 28 | id: 2 29 | taskPhrase: Please find my missing baby! 30 | questType : FETCH 31 | } 32 | 1: { 33 | taskProperties: { 34 | IS_TASK_COMPLETE: { 35 | class: java.lang.String 36 | value: "false" 37 | } 38 | TARGET_TYPE: { 39 | class: java.lang.String 40 | value: "TOWN_FOLK2" 41 | } 42 | TARGET_LOCATION: { 43 | class: java.lang.String 44 | value: "TOPPLE" 45 | } 46 | } 47 | id: 1 48 | taskPhrase: Give me my baby! 49 | questType : RETURN 50 | } 51 | } 52 | questTaskDependencies: { 53 | 1: [ 54 | { 55 | class: com.gdx.game.quest.QuestTaskDependency 56 | sourceId: 1 57 | destinationId: 2 58 | } 59 | ] 60 | 2: [] 61 | } 62 | } -------------------------------------------------------------------------------- /core/src/main/resources/scripts/environmental_entities.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | entityID : FIRE 4 | state : IMMOBILE 5 | direction : DOWN 6 | conversationConfigPath : "" 7 | resumeConfigPath : "" 8 | questConfigPath : "" 9 | currentQuestID : "" 10 | itemTypeID: NONE 11 | animationConfig: [ 12 | { 13 | frameDuration: 1.0 14 | animationType: IDLE 15 | texturePaths: [ 16 | sprites/objects/Effect0.png 17 | sprites/objects/Effect1.png 18 | ] 19 | gridPoints: [ 20 | { 21 | x: 21 22 | y: 1 23 | } 24 | 25 | { 26 | x: 21 27 | y: 1 28 | } 29 | ] 30 | } 31 | { 32 | frameDuration: 1.0 33 | animationType: IMMOBILE 34 | texturePaths: [ 35 | sprites/objects/Effect0.png 36 | sprites/objects/Effect1.png 37 | ] 38 | gridPoints: [ 39 | { 40 | x: 21 41 | y: 1 42 | } 43 | 44 | { 45 | x: 21 46 | y: 1 47 | } 48 | ] 49 | } 50 | ] 51 | } 52 | ] -------------------------------------------------------------------------------- /core/src/main/resources/scripts/equipment_sets.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | itemSetID: PEASANT_SET 4 | itemSetDescription: Increase physical attack by 10% 5 | bonus: { 6 | ENTITY_PHYSICAL_ATTACK_POINTS: { 7 | class: java.lang.String 8 | value: 0.1 9 | } 10 | ENTITY_PHYSICAL_DEFENSE_POINTS: { 11 | class: java.lang.String 12 | value: 0.1 13 | } 14 | } 15 | } 16 | ] -------------------------------------------------------------------------------- /core/src/main/resources/scripts/level_tables.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | levelID : 1 4 | xpMax : 200 5 | hpMax : 50 6 | mpMax : 50 7 | }, 8 | { 9 | levelID : 2 10 | xpMax : 400 11 | hpMax : 70 12 | mpMax : 70 13 | }, 14 | { 15 | levelID : 3 16 | xpMax : 800 17 | hpMax : 90 18 | mpMax : 90 19 | }, 20 | { 21 | levelID : 4 22 | xpMax : 1600 23 | hpMax : 110 24 | mpMax : 110 25 | }, 26 | { 27 | levelID : 5 28 | xpMax : 3200 29 | hpMax : 130 30 | mpMax : 130 31 | }, 32 | { 33 | levelID : 6 34 | xpMax : 6400 35 | hpMax : 160 36 | mpMax : 160 37 | }, 38 | { 39 | levelID : 7 40 | xpMax : 10000 41 | hpMax : 200 42 | mpMax : 200 43 | }, 44 | { 45 | levelID : 8 46 | xpMax : 14000 47 | hpMax : 240 48 | mpMax : 240 49 | }, 50 | { 51 | levelID : 9 52 | xpMax : 20000 53 | hpMax : 300 54 | mpMax : 300 55 | }, 56 | { 57 | levelID : 10 58 | xpMax : 25000 59 | hpMax : 400 60 | mpMax : 400 61 | }, 62 | ] -------------------------------------------------------------------------------- /core/src/main/resources/scripts/quest001_task002.json: -------------------------------------------------------------------------------- 1 | { 2 | entityID : QUEST001_TASK002 3 | state : IMMOBILE 4 | direction : DOWN 5 | conversationConfigPath : "conversations/conversation005.json" 6 | resumeConfigPath : "" 7 | questConfigPath : "" 8 | currentQuestID : "" 9 | itemTypeID: HORNS001 10 | inventory : [ 11 | ] 12 | animationConfig: [ 13 | { 14 | frameDuration: 1.0 15 | animationType: IMMOBILE 16 | texturePaths: [ 17 | sprites/items/Flesh.png 18 | ] 19 | gridPoints: [ 20 | { 21 | x: 8 22 | y: 4 23 | } 24 | ] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /core/src/main/resources/scripts/quest001_task003.json: -------------------------------------------------------------------------------- 1 | { 2 | entityID : QUEST001_TASK003 3 | state : IMMOBILE 4 | direction : DOWN 5 | conversationConfigPath : "conversations/conversation005.json" 6 | resumeConfigPath : "" 7 | questConfigPath : "" 8 | currentQuestID : "" 9 | itemTypeID: FUR001 10 | inventory : [ 11 | ] 12 | animationConfig: [ 13 | { 14 | frameDuration: 1.0 15 | animationType: IMMOBILE 16 | texturePaths: [ 17 | sprites/items/Flesh.png 18 | ] 19 | gridPoints: [ 20 | { 21 | x: 8 22 | y: 0 23 | } 24 | ] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /core/src/main/resources/scripts/quest002_task002.json: -------------------------------------------------------------------------------- 1 | { 2 | entityID : QUEST002_TASK002 3 | state : IMMOBILE 4 | direction : DOWN 5 | conversationConfigPath : "conversations/conversation005.json" 6 | resumeConfigPath : "" 7 | questConfigPath : "" 8 | currentQuestID : "" 9 | itemTypeID: HERB001 10 | inventory : [ 11 | ] 12 | animationConfig: [ 13 | { 14 | frameDuration: 1.0 15 | animationType: IMMOBILE 16 | texturePaths: [ 17 | sprites/items/Food.png 18 | ] 19 | gridPoints: [ 20 | { 21 | x: 3 22 | y: 2 23 | } 24 | ] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /core/src/main/resources/scripts/quest003_task002.json: -------------------------------------------------------------------------------- 1 | { 2 | entityID : QUEST003_TASK002 3 | state : IMMOBILE 4 | direction : DOWN 5 | conversationConfigPath : "conversations/conversation005.json" 6 | resumeConfigPath : "" 7 | questConfigPath : "" 8 | currentQuestID : "" 9 | itemTypeID: BABY001 10 | inventory : [ 11 | ] 12 | animationConfig: [ 13 | { 14 | frameDuration: 1.0 15 | animationType: IMMOBILE 16 | texturePaths: [ 17 | sprites/characters/Player0.png 18 | sprites/characters/Player1.png 19 | ] 20 | gridPoints: [ 21 | { 22 | x: 1 23 | y: 1 24 | } 25 | { 26 | x: 1 27 | y: 1 28 | } 29 | ] 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /core/src/main/resources/scripts/town_blacksmith.json: -------------------------------------------------------------------------------- 1 | { 2 | entityID : TOWN_BLACKSMITH 3 | entityStatus : VILLAGER 4 | state : IMMOBILE 5 | direction : DOWN 6 | conversationConfigPath : "conversations/conversation003.json" 7 | resumeConfigPath : "" 8 | questConfigPath : "" 9 | currentQuestID : "" 10 | itemTypeID: NONE 11 | inventory : [ 12 | { 13 | value: SHIELD01 14 | }, 15 | { 16 | value: SHIELD02 17 | }, 18 | { 19 | value: SHIELD03 20 | }, 21 | { 22 | value: SHIELD04 23 | }, 24 | { 25 | value: SHIELD05 26 | }, 27 | { 28 | value: ARMOR01 29 | }, 30 | { 31 | value: ARMOR02 32 | }, 33 | { 34 | value: ARMOR03 35 | }, 36 | { 37 | value: ARMOR04 38 | }, 39 | { 40 | value: ARMOR05 41 | }, 42 | { 43 | value: BOOTS01 44 | }, 45 | { 46 | value: BOOTS02 47 | }, 48 | { 49 | value: BOOTS03 50 | }, 51 | { 52 | value: BOOTS04 53 | }, 54 | { 55 | value: BOOTS05 56 | }, 57 | { 58 | value: HELMET01 59 | }, 60 | { 61 | value: HELMET02 62 | }, 63 | { 64 | value: HELMET03 65 | }, 66 | { 67 | value: HELMET04 68 | }, 69 | { 70 | value: HELMET05 71 | }, 72 | { 73 | value: WEAPON01 74 | }, 75 | { 76 | value: WEAPON02 77 | }, 78 | { 79 | value: WEAPON03 80 | }, 81 | { 82 | value: WEAPON04 83 | }, 84 | { 85 | value: WEAPON05 86 | }, 87 | ] 88 | animationConfig: [ 89 | { 90 | frameDuration: 1.0 91 | animationType: IDLE 92 | texturePaths: [ 93 | sprites/characters/Player0.png 94 | sprites/characters/Player1.png 95 | ] 96 | gridPoints: [ 97 | { 98 | x: 3 99 | y: 1 100 | } 101 | 102 | { 103 | x: 3 104 | y: 1 105 | } 106 | ] 107 | } 108 | { 109 | frameDuration: 1.0 110 | animationType: IMMOBILE 111 | texturePaths: [ 112 | sprites/characters/Player0.png 113 | sprites/characters/Player1.png 114 | ] 115 | gridPoints: [ 116 | { 117 | x: 3 118 | y: 1 119 | } 120 | 121 | { 122 | x: 3 123 | y: 1 124 | } 125 | ] 126 | } 127 | ] 128 | } -------------------------------------------------------------------------------- /core/src/main/resources/scripts/town_guard_walking.json: -------------------------------------------------------------------------------- 1 | { 2 | entityID : TOWN_GUARD 3 | entityStatus : GUARD 4 | state : IDLE 5 | direction : DOWN 6 | conversationConfigPath : "conversations/conversation002.json" 7 | resumeConfigPath : "" 8 | questConfigPath : "" 9 | currentQuestID : "" 10 | itemTypeID: NONE 11 | animationConfig: [ 12 | { 13 | frameDuration: 0.25 14 | animationType: IDLE 15 | texturePaths: [ 16 | sprites/characters/Paladin.png 17 | ] 18 | gridPoints: [ 19 | { 20 | x: 0 21 | y: 0 22 | } 23 | 24 | { 25 | x: 0 26 | y: 1 27 | } 28 | { 29 | x: 0 30 | y: 2 31 | } 32 | { 33 | x: 0 34 | y: 3 35 | } 36 | ] 37 | } 38 | { 39 | frameDuration: 0.25 40 | animationType: WALK_DOWN 41 | texturePaths: [ 42 | sprites/characters/Paladin.png 43 | ] 44 | gridPoints: [ 45 | { 46 | x: 0 47 | y: 0 48 | } 49 | 50 | { 51 | x: 0 52 | y: 1 53 | } 54 | { 55 | x: 0 56 | y: 2 57 | } 58 | { 59 | x: 0 60 | y: 3 61 | } 62 | ] 63 | } 64 | { 65 | frameDuration: 0.25 66 | animationType: WALK_LEFT 67 | texturePaths: [ 68 | sprites/characters/Paladin.png 69 | ] 70 | gridPoints: [ 71 | { 72 | x: 1 73 | y: 0 74 | } 75 | 76 | { 77 | x: 1 78 | y: 1 79 | } 80 | { 81 | x: 1 82 | y: 2 83 | } 84 | { 85 | x: 1 86 | y: 3 87 | } 88 | ] 89 | } 90 | { 91 | frameDuration: 0.25 92 | animationType: WALK_RIGHT 93 | texturePaths: [ 94 | sprites/characters/Paladin.png 95 | ] 96 | gridPoints: [ 97 | { 98 | x: 2 99 | y: 0 100 | } 101 | 102 | { 103 | x: 2 104 | y: 1 105 | } 106 | { 107 | x: 2 108 | y: 2 109 | } 110 | { 111 | x: 2 112 | y: 3 113 | } 114 | ] 115 | } 116 | { 117 | frameDuration: 0.25 118 | animationType: WALK_UP 119 | texturePaths: [ 120 | sprites/characters/Paladin.png 121 | ] 122 | gridPoints: [ 123 | { 124 | x: 3 125 | y: 0 126 | } 127 | 128 | { 129 | x: 3 130 | y: 1 131 | } 132 | { 133 | x: 3 134 | y: 2 135 | } 136 | { 137 | x: 3 138 | y: 3 139 | } 140 | ] 141 | } 142 | ] 143 | } -------------------------------------------------------------------------------- /core/src/main/resources/scripts/town_innkeeper.json: -------------------------------------------------------------------------------- 1 | { 2 | entityID : TOWN_INNKEEPER 3 | entityStatus : VILLAGER 4 | state : IMMOBILE 5 | direction : DOWN 6 | conversationConfigPath : "" 7 | resumeConfigPath : "" 8 | questConfigPath : "" 9 | currentQuestID : "" 10 | itemTypeID: NONE 11 | animationConfig: [ 12 | { 13 | frameDuration: 1.0 14 | animationType: IDLE 15 | texturePaths: [ 16 | sprites/characters/Player0.png 17 | sprites/characters/Player1.png 18 | ] 19 | gridPoints: [ 20 | { 21 | x: 0 22 | y: 5 23 | } 24 | 25 | { 26 | x: 0 27 | y: 5 28 | } 29 | ] 30 | } 31 | { 32 | frameDuration: 1.0 33 | animationType: IMMOBILE 34 | texturePaths: [ 35 | sprites/characters/Player0.png 36 | sprites/characters/Player1.png 37 | ] 38 | gridPoints: [ 39 | { 40 | x: 0 41 | y: 5 42 | } 43 | 44 | { 45 | x: 0 46 | y: 5 47 | } 48 | ] 49 | } 50 | ] 51 | } -------------------------------------------------------------------------------- /core/src/main/resources/scripts/town_mage.json: -------------------------------------------------------------------------------- 1 | { 2 | entityID : TOWN_MAGE 3 | entityStatus : VILLAGER 4 | state : IMMOBILE 5 | direction : DOWN 6 | conversationConfigPath : "conversations/conversation003.json" 7 | resumeConfigPath : "" 8 | questConfigPath : "" 9 | currentQuestID : "" 10 | itemTypeID: NONE 11 | inventory : [ 12 | { 13 | value: WANDS01 14 | }, 15 | { 16 | value: WANDS02 17 | }, 18 | { 19 | value: WANDS03 20 | }, 21 | { 22 | value: WANDS04 23 | }, 24 | { 25 | value: WANDS05 26 | }, 27 | { 28 | value: POTIONS01 29 | }, 30 | { 31 | value: POTIONS01 32 | }, 33 | { 34 | value: POTIONS01 35 | }, 36 | { 37 | value: POTIONS02 38 | }, 39 | { 40 | value: POTIONS02 41 | }, 42 | { 43 | value: POTIONS02 44 | }, 45 | { 46 | value: POTIONS03 47 | }, 48 | { 49 | value: POTIONS03 50 | }, 51 | { 52 | value: POTIONS03 53 | }, 54 | { 55 | value: SCROLL01 56 | }, 57 | { 58 | value: SCROLL01 59 | }, 60 | { 61 | value: SCROLL02 62 | }, 63 | { 64 | value: SCROLL02 65 | }, 66 | { 67 | value: SCROLL03 68 | }, 69 | { 70 | value: SCROLL03 71 | }, 72 | ] 73 | animationConfig: [ 74 | { 75 | frameDuration: 1.0 76 | animationType: IDLE 77 | texturePaths: [ 78 | sprites/characters/Player0.png 79 | sprites/characters/Player1.png 80 | ] 81 | gridPoints: [ 82 | { 83 | x: 3 84 | y: 6 85 | } 86 | 87 | { 88 | x: 3 89 | y: 6 90 | } 91 | ] 92 | } 93 | { 94 | frameDuration: 1.0 95 | animationType: IMMOBILE 96 | texturePaths: [ 97 | sprites/characters/Player0.png 98 | sprites/characters/Player1.png 99 | ] 100 | gridPoints: [ 101 | { 102 | x: 3 103 | y: 6 104 | } 105 | 106 | { 107 | x: 3 108 | y: 6 109 | } 110 | ] 111 | } 112 | ] 113 | } -------------------------------------------------------------------------------- /core/src/main/resources/skins/items.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/skins/items.png -------------------------------------------------------------------------------- /core/src/main/resources/skins/items.proj: -------------------------------------------------------------------------------- 1 | name=items 2 | filename=items.atlas 3 | input=..\..\..\..\..\work\item_sprites 4 | output= 5 | 6 | alias=true 7 | alphaThreshold=0 8 | debug=false 9 | duplicatePadding=true 10 | edgePadding=true 11 | fast=false 12 | filterMag=Nearest 13 | filterMin=Nearest 14 | format=RGBA8888 15 | ignoreBlankImages=true 16 | jpegQuality=1.0 17 | maxHeight=512 18 | maxWidth=512 19 | minHeight=16 20 | minWidth=16 21 | outputFormat=png 22 | paddingX=2 23 | paddingY=2 24 | pot=false 25 | rotation=false 26 | stripWhitespaceX=false 27 | stripWhitespaceY=false 28 | wrapX=ClampToEdge 29 | wrapY=ClampToEdge -------------------------------------------------------------------------------- /core/src/main/resources/skins/statusui.json: -------------------------------------------------------------------------------- 1 | { 2 | "com.badlogic.gdx.graphics.Color": { 3 | green: { a: 1, b: 0, g: 1, r: 0 }, 4 | white: { a: 1, b: 1, g: 1, r: 1 }, 5 | red: { a: 1, b: 0, g: 0, r: 1 }, 6 | black: { a: 1, b: 0, g: 0, r: 0 }, 7 | grey: { a: 1, b: 0.5, g: 0.5, r: 0.5 }, 8 | cyan: { a: 1, b: 1, g: 0.9, r: 0.72 } 9 | }, 10 | "com.badlogic.gdx.graphics.g2d.BitmapFont": { 11 | "default-font": { "file": "fonts/SDS_6x6.fnt" }, 12 | "small-font" : { "file" : "fonts/SDS_6x6_small.fnt" }, 13 | "smooth-font" : { "file" : "fonts/sans_serif_18.fnt" }, 14 | }, 15 | "com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle": { 16 | "default": { "font": "default-font" }, 17 | "inventory-item-count": { "font": "small-font" }, 18 | "credits": { "font" : "smooth-font" }, 19 | }, 20 | "com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle": { 21 | "default": { "titleFont": "default-font", "background": "dialogDim" }, 22 | "solidbackground": { "titleFont": "default-font", "background": "dialog" }, 23 | }, 24 | "com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle": { 25 | "inventory-button": { "imageUp": "inventory_button_closed", "imageChecked": "inventory_button_open" }, 26 | "quest-button": { "imageUp": "quest_book_off", "imageChecked": "quest_book_on" }, 27 | }, 28 | "com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": { 29 | default: { down: default-round-down, up: default-round, font: default-font, fontColor: white }, 30 | toggle: { down: default-round-down, up: default-round, checked: default-round-down, font: default-font, fontColor: white, downFontColor: red }, 31 | inventory: { down: default-round-down, up: default-round, font: default-font, fontColor: white, disabledFontColor: grey } 32 | }, 33 | "com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle": { 34 | default: { fontColorUnselected: white, selection: default-rect-pad, fontColorSelected: black, font: default-font }, 35 | inventory: { fontColorUnselected: white, selection: default-rect-pad, fontColorSelected: black, font: default-font }, 36 | }, 37 | "com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle": { 38 | default: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor }, 39 | inventory: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor } 40 | }, 41 | com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: { 42 | default: { vScroll: default-scroll, hScrollKnob: default-round-large, background: default-rect, hScroll: default-scroll, vScrollKnob: default-round-large }, 43 | inventoryPane: { vScroll: default-scroll, hScrollKnob: default-round-large, hScroll: default-scroll, vScrollKnob: default-round-large } 44 | }, 45 | } -------------------------------------------------------------------------------- /core/src/main/resources/skins/statusui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/skins/statusui.png -------------------------------------------------------------------------------- /core/src/main/resources/skins/statusui.proj: -------------------------------------------------------------------------------- 1 | name=statusui 2 | filename=statusui.atlas 3 | input=..\..\..\..\..\work\sprites 4 | output= 5 | 6 | alias=true 7 | alphaThreshold=0 8 | debug=false 9 | duplicatePadding=true 10 | edgePadding=true 11 | fast=false 12 | filterMag=Nearest 13 | filterMin=Nearest 14 | format=RGBA8888 15 | ignoreBlankImages=true 16 | jpegQuality=1.0 17 | maxHeight=512 18 | maxWidth=512 19 | minHeight=16 20 | minWidth=16 21 | outputFormat=png 22 | paddingX=2 23 | paddingY=2 24 | pot=false 25 | rotation=false 26 | stripWhitespaceX=false 27 | stripWhitespaceY=false 28 | wrapX=ClampToEdge 29 | wrapY=ClampToEdge -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Cleric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Cleric.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Demon0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Demon0.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Demon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Demon1.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Grappler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Grappler.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Mage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Mage.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Paladin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Paladin.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Player0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Player0.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Player1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Player1.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Thief.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Thief.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/characters/Warrior.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/characters/Warrior.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Ammo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Ammo.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Amulet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Amulet.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Armor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Armor.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Book.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Boot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Boot.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Chest0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Chest0.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Chest1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Chest1.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Flesh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Flesh.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Food.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Food.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Glove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Glove.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Hat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Hat.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Key.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Light.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/LongWep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/LongWep.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/MedWep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/MedWep.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Money.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Money.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Music.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Music.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Potion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Potion.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Ring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Ring.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Rock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Rock.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Scroll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Scroll.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Shield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Shield.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/ShortWep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/ShortWep.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Tool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Tool.png -------------------------------------------------------------------------------- /core/src/main/resources/sprites/items/Wand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/main/resources/sprites/items/Wand.png -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/GdxRunner.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game; 2 | 3 | import com.badlogic.gdx.ApplicationListener; 4 | import com.badlogic.gdx.backends.headless.HeadlessApplication; 5 | import com.badlogic.gdx.backends.headless.HeadlessApplicationConfiguration; 6 | import org.junit.jupiter.api.extension.Extension; 7 | import org.junit.platform.launcher.TestExecutionListener; 8 | 9 | import java.lang.reflect.Method; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | /** 14 | * Allow to run test on Gdx app logic. 15 | */ 16 | public class GdxRunner implements ApplicationListener, Extension { 17 | 18 | private final Map invokeInRender = new HashMap<>(); 19 | 20 | public GdxRunner() { 21 | HeadlessApplicationConfiguration conf = new HeadlessApplicationConfiguration(); 22 | 23 | new HeadlessApplication(this, conf); 24 | } 25 | 26 | @Override 27 | public void create() { 28 | } 29 | 30 | @Override 31 | public void resume() { 32 | } 33 | 34 | @Override 35 | public void render() { 36 | synchronized (invokeInRender) { 37 | for (Map.Entry each : invokeInRender.entrySet()) { 38 | runChild(each.getKey(), each.getValue()); 39 | } 40 | invokeInRender.clear(); 41 | } 42 | } 43 | 44 | @Override 45 | public void resize(int width, int height) { 46 | } 47 | 48 | @Override 49 | public void pause() { 50 | } 51 | 52 | @Override 53 | public void dispose() { 54 | } 55 | 56 | protected void runChild(Method method, TestExecutionListener testExecutionListener) { 57 | synchronized (invokeInRender) { 58 | //add for invoking in render phase, where gl context is available 59 | invokeInRender.put(method, testExecutionListener); 60 | } 61 | //wait until that test was invoked 62 | waitUntilInvokedInRenderMethod(); 63 | } 64 | 65 | private void waitUntilInvokedInRenderMethod() { 66 | try { 67 | while (true) { 68 | Thread.sleep(10); 69 | synchronized (invokeInRender) { 70 | if (invokeInRender.isEmpty()) break; 71 | } 72 | } 73 | } catch (InterruptedException e) { 74 | e.printStackTrace(); 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/audio/AudioManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.audio; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.manager.ResourceManager; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | import org.junit.jupiter.params.ParameterizedTest; 11 | import org.junit.jupiter.params.provider.Arguments; 12 | import org.junit.jupiter.params.provider.MethodSource; 13 | 14 | import java.util.stream.Stream; 15 | 16 | import static com.gdx.game.audio.AudioObserver.AudioTypeEvent.MENU_THEME; 17 | import static com.gdx.game.audio.AudioObserver.AudioTypeEvent.TOPPLE_THEME; 18 | import static org.assertj.core.api.Assertions.assertThat; 19 | import static org.mockito.Mockito.mock; 20 | 21 | @ExtendWith(GdxRunner.class) 22 | class AudioManagerTest { 23 | 24 | @BeforeEach 25 | void init() { 26 | Gdx.gl = mock(GL20.class); 27 | } 28 | 29 | @Test 30 | void testGetInstance_ShouldSucceed() { 31 | AudioManager audioManager = AudioManager.getInstance(); 32 | 33 | assertThat(audioManager).isNotNull(); 34 | } 35 | 36 | @ParameterizedTest 37 | @MethodSource("loadMusic") 38 | void testOnNotify(AudioObserver.AudioCommand command, AudioObserver.AudioTypeEvent event) { 39 | new ResourceManager(); 40 | AudioManager audioManager = AudioManager.getInstance(); 41 | audioManager.setCurrentMusic(null); 42 | 43 | audioManager.onNotify(AudioObserver.AudioCommand.MUSIC_LOAD, event); 44 | audioManager.onNotify(command, event); 45 | 46 | assertThat(audioManager.getCurrentMusic()).isEqualTo(ResourceManager.getMusicAsset(event.getValue())); 47 | } 48 | 49 | private static Stream loadMusic() { 50 | return Stream.of( 51 | Arguments.of(AudioObserver.AudioCommand.MUSIC_PLAY_ONCE, MENU_THEME), 52 | Arguments.of(AudioObserver.AudioCommand.MUSIC_PLAY_LOOP, TOPPLE_THEME) 53 | ); 54 | } 55 | 56 | @Test 57 | void testOnNotify_ShouldSucceedWithMusicStop() { 58 | new ResourceManager(); 59 | AudioManager audioManager = AudioManager.getInstance(); 60 | audioManager.setCurrentMusic(null); 61 | 62 | audioManager.onNotify(AudioObserver.AudioCommand.MUSIC_LOAD, MENU_THEME); 63 | audioManager.onNotify(AudioObserver.AudioCommand.MUSIC_PLAY_ONCE, MENU_THEME); 64 | audioManager.onNotify(AudioObserver.AudioCommand.MUSIC_STOP, MENU_THEME); 65 | 66 | assertThat(audioManager.getCurrentMusic().isPlaying()).isFalse(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/battle/BattleInventoryUITest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.battle; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.manager.ResourceManager; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import java.util.Arrays; 12 | 13 | import static org.assertj.core.api.Assertions.assertThat; 14 | import static org.mockito.Mockito.mock; 15 | 16 | @ExtendWith(GdxRunner.class) 17 | public class BattleInventoryUITest { 18 | 19 | @BeforeEach 20 | void init() { 21 | Gdx.gl = mock(GL20.class); 22 | Gdx.gl20 = mock(GL20.class); 23 | new ResourceManager(); 24 | } 25 | 26 | @Test 27 | public void testBattleInventoryUI_ShouldSucceed() { 28 | BattleInventoryUI battleInventoryUI = new BattleInventoryUI(); 29 | 30 | assertThat(battleInventoryUI).isNotNull(); 31 | assertThat(battleInventoryUI.getChildren().size).isEqualTo(2); 32 | assertThat(Arrays.stream(battleInventoryUI.getChildren().items).count()).isEqualTo(4); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/battle/BattleStatusUITest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.battle; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.profile.ProfileManager; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | import org.junit.jupiter.params.ParameterizedTest; 11 | import org.junit.jupiter.params.provider.Arguments; 12 | import org.junit.jupiter.params.provider.MethodSource; 13 | 14 | import java.util.Arrays; 15 | import java.util.stream.Stream; 16 | 17 | import static org.assertj.core.api.Assertions.assertThat; 18 | import static org.mockito.Mockito.mock; 19 | 20 | @ExtendWith(GdxRunner.class) 21 | public class BattleStatusUITest { 22 | 23 | @BeforeEach 24 | void init() { 25 | Gdx.gl = mock(GL20.class); 26 | Gdx.gl20 = mock(GL20.class); 27 | 28 | ProfileManager profileManager = ProfileManager.getInstance(); 29 | profileManager.setProperty("currentPlayerXPMax", 200); 30 | profileManager.setProperty("currentPlayerXP", 0); 31 | profileManager.setProperty("currentPlayerHPMax", 50); 32 | profileManager.setProperty("currentPlayerHP", 40); 33 | profileManager.setProperty("currentPlayerMPMax", 50); 34 | profileManager.setProperty("currentPlayerMP", 45); 35 | profileManager.setProperty("currentPlayerLevel", 1); 36 | } 37 | 38 | @Test 39 | public void testBattleStatusUI_ShouldSucceed() { 40 | BattleStatusUI battleStatusUI = new BattleStatusUI(); 41 | 42 | assertThat(battleStatusUI).isNotNull(); 43 | assertThat(battleStatusUI.getChildren().size).isEqualTo(16); 44 | assertThat(Arrays.stream(battleStatusUI.getChildren().items).count()).isEqualTo(24); 45 | } 46 | 47 | @ParameterizedTest 48 | @MethodSource("xpValue") 49 | void testSetXpValue(int xp, int xpRemainder, int level) { 50 | BattleStatusUI battleStatusUI = new BattleStatusUI(); 51 | battleStatusUI.setXPValue(xp); 52 | 53 | assertThat(battleStatusUI).isNotNull(); 54 | assertThat(battleStatusUI.getXPValue()).isEqualTo(xpRemainder); 55 | assertThat(battleStatusUI.getLevelValue()).isEqualTo(level); 56 | } 57 | 58 | private static Stream xpValue() { 59 | return Stream.of( 60 | Arguments.of(210, 10, 2), 61 | Arguments.of(650, 50, 3) 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/battle/BattleUITest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.battle; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.utils.Array; 6 | import com.gdx.game.GdxRunner; 7 | import com.gdx.game.entities.EntityBonus; 8 | import com.gdx.game.entities.EntityConfig; 9 | import com.gdx.game.manager.ResourceManager; 10 | import com.gdx.game.profile.ProfileManager; 11 | import org.junit.jupiter.api.BeforeEach; 12 | import org.junit.jupiter.api.Test; 13 | import org.junit.jupiter.api.extension.ExtendWith; 14 | 15 | import static org.assertj.core.api.Assertions.assertThat; 16 | import static org.mockito.Mockito.mock; 17 | 18 | @ExtendWith(GdxRunner.class) 19 | public class BattleUITest { 20 | 21 | @BeforeEach 22 | void init() { 23 | Gdx.gl = mock(GL20.class); 24 | Gdx.gl20 = mock(GL20.class); 25 | new ResourceManager(); 26 | } 27 | 28 | @Test 29 | public void testBattleUI_ShouldSucceed() { 30 | ProfileManager profileManager = ProfileManager.getInstance(); 31 | profileManager.setProperty("currentPlayerAP", 5); 32 | profileManager.setProperty("currentPlayerDP", 5); 33 | EntityBonus entityBonusAtk = new EntityBonus(EntityConfig.EntityProperties.ENTITY_PHYSICAL_ATTACK_POINTS.name(), "0.3"); 34 | EntityBonus entityBonusDef = new EntityBonus(EntityConfig.EntityProperties.ENTITY_PHYSICAL_DEFENSE_POINTS.name(), "0.1"); 35 | profileManager.setProperty("bonusSet", new Array<>(new EntityBonus[]{entityBonusAtk, entityBonusDef})); 36 | 37 | BattleState battleState = new BattleState(); 38 | BattleInventoryUI battleInventoryUI = new BattleInventoryUI(); 39 | BattleUI battleUI = new BattleUI(battleState, battleInventoryUI); 40 | 41 | assertThat(battleUI).isNotNull(); 42 | assertThat(battleUI.getChildren()).hasSize(2); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/battle/BattleUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.battle; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; 6 | 7 | public class BattleUtilsTest { 8 | 9 | @Test 10 | public void testEscapeChance_ShouldSucceedWithInfOne() { 11 | double result = BattleUtils.escapeChance(0.4d); 12 | 13 | assertEquals(0.4d, result); 14 | } 15 | 16 | @Test 17 | public void testEscapeChance_ShouldSucceedWithSupOne() { 18 | double result = BattleUtils.escapeChance(3d); 19 | 20 | assertEquals(1d, result); 21 | } 22 | 23 | @Test 24 | public void testCriticalChance_ShouldSucceed() { 25 | double result = BattleUtils.criticalChance(18); 26 | 27 | assertEquals(0.0969, result); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/component/PhysicsComponentTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.component; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.graphics.glutils.ShapeRenderer; 6 | import com.gdx.game.GdxRunner; 7 | import com.gdx.game.entities.Entity; 8 | import com.gdx.game.entities.EntityFactory; 9 | import com.gdx.game.entities.npc.NPCPhysicsComponent; 10 | import com.gdx.game.map.MapFactory; 11 | import com.gdx.game.map.MapManager; 12 | import org.junit.jupiter.api.AfterEach; 13 | import org.junit.jupiter.api.BeforeEach; 14 | import org.junit.jupiter.api.extension.ExtendWith; 15 | import org.junit.jupiter.params.ParameterizedTest; 16 | import org.junit.jupiter.params.provider.Arguments; 17 | import org.junit.jupiter.params.provider.MethodSource; 18 | import org.mockito.MockedConstruction; 19 | 20 | import java.util.stream.Stream; 21 | 22 | import static org.junit.jupiter.api.Assertions.assertTrue; 23 | import static org.mockito.Mockito.mock; 24 | import static org.mockito.Mockito.mockConstruction; 25 | import static org.mockito.Mockito.spy; 26 | import static org.mockito.Mockito.verify; 27 | 28 | @ExtendWith(GdxRunner.class) 29 | public class PhysicsComponentTest { 30 | 31 | private MockedConstruction mockShapeRenderer; 32 | 33 | @BeforeEach 34 | void init() { 35 | Gdx.gl = mock(GL20.class); 36 | Gdx.gl20 = mock(GL20.class); 37 | mockShapeRenderer = mockConstruction(ShapeRenderer.class); 38 | } 39 | 40 | @AfterEach 41 | void end() { 42 | mockShapeRenderer.close(); 43 | } 44 | 45 | @ParameterizedTest 46 | @MethodSource("collisionMapData") 47 | public void testCollisionMapEntities(MapFactory.MapType mapType, Component.MESSAGE message, String entityId) { 48 | Entity player = spy(EntityFactory.getInstance().getEntity(EntityFactory.EntityType.WARRIOR)); 49 | MapManager mapManager = new MapManager(); 50 | mapManager.setPlayer(player); 51 | mapManager.loadMap(mapType); 52 | NPCPhysicsComponent npcPhysicsComponent = new NPCPhysicsComponent(); 53 | 54 | boolean result = npcPhysicsComponent.isCollisionWithMapEntities(player, mapManager); 55 | 56 | verify(player).sendMessage(message, entityId); 57 | assertTrue(result); 58 | } 59 | 60 | private static Stream collisionMapData() { 61 | return Stream.of( 62 | Arguments.of(MapFactory.MapType.TOPPLE_ROAD_1, Component.MESSAGE.COLLISION_WITH_ENTITY, "RABITE"), 63 | Arguments.of(MapFactory.MapType.TOPPLE, Component.MESSAGE.COLLISION_WITH_ENTITY, "TOWN_INNKEEPER") 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/entities/EntityFactoryTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.entities.npc.NPCGraphicsComponent; 7 | import com.gdx.game.entities.npc.NPCInputComponent; 8 | import com.gdx.game.entities.player.PlayerGraphicsComponent; 9 | import com.gdx.game.entities.player.PlayerInputComponent; 10 | import org.junit.jupiter.api.AfterEach; 11 | import org.junit.jupiter.api.BeforeEach; 12 | import org.junit.jupiter.api.Test; 13 | import org.junit.jupiter.api.extension.ExtendWith; 14 | import org.mockito.MockedConstruction; 15 | 16 | import static org.assertj.core.api.Assertions.assertThat; 17 | import static org.mockito.Mockito.mock; 18 | import static org.mockito.Mockito.mockConstruction; 19 | 20 | @ExtendWith(GdxRunner.class) 21 | public class EntityFactoryTest { 22 | 23 | private MockedConstruction mockPlayerGraphics; 24 | 25 | private MockedConstruction mockNPCGraphics; 26 | 27 | @BeforeEach 28 | void init() { 29 | Gdx.gl = mock(GL20.class); 30 | Gdx.gl20 = mock(GL20.class); 31 | mockPlayerGraphics = mockConstruction(PlayerGraphicsComponent.class); 32 | mockNPCGraphics = mockConstruction(NPCGraphicsComponent.class); 33 | } 34 | 35 | @AfterEach 36 | void end() { 37 | mockPlayerGraphics.close(); 38 | mockNPCGraphics.close(); 39 | } 40 | 41 | @Test 42 | public void testGetInstance_ShouldSucceed() { 43 | EntityFactory entityFactory = EntityFactory.getInstance(); 44 | 45 | assertThat(entityFactory).isNotNull(); 46 | } 47 | 48 | @Test 49 | public void testGetEntity_ShouldSucceedWithPlayer() { 50 | Entity entity = EntityFactory.getInstance().getEntity(EntityFactory.EntityType.WARRIOR); 51 | 52 | assertThat(entity).isNotNull(); 53 | assertThat(entity.getEntityConfig().getEntityID()).isEqualTo(Entity.getEntityConfig(EntityFactory.PLAYER_WARRIOR_CONFIG).getEntityID()); 54 | assertThat(entity.getInputProcessor()).isInstanceOf(PlayerInputComponent.class); 55 | } 56 | 57 | @Test 58 | public void testGetEntity_ShouldSucceedWithNPC() { 59 | Entity entity = EntityFactory.getInstance().getEntity(EntityFactory.EntityType.NPC); 60 | 61 | assertThat(entity).isNotNull(); 62 | assertThat(entity.getInputProcessor()).isInstanceOf(NPCInputComponent.class); 63 | } 64 | 65 | @Test 66 | public void testGetEntityByName_ShouldSucceed() { 67 | Entity entity = EntityFactory.getInstance().getEntityByName(EntityFactory.EntityName.TOWN_BLACKSMITH); 68 | 69 | assertThat(entity).isNotNull(); 70 | assertThat(entity.getInputProcessor()).isInstanceOf(NPCInputComponent.class); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/entities/npc/enemy/EnemyPhysicsComponentTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities.npc.enemy; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.graphics.OrthographicCamera; 6 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 7 | import com.badlogic.gdx.graphics.glutils.ShapeRenderer; 8 | import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; 9 | import com.badlogic.gdx.math.Vector2; 10 | import com.badlogic.gdx.utils.Json; 11 | import com.gdx.game.GdxRunner; 12 | import com.gdx.game.component.Component; 13 | import com.gdx.game.entities.Entity; 14 | import com.gdx.game.entities.EntityFactory; 15 | import com.gdx.game.map.Map; 16 | import com.gdx.game.map.MapFactory; 17 | import com.gdx.game.map.MapManager; 18 | import org.junit.jupiter.api.AfterEach; 19 | import org.junit.jupiter.api.BeforeEach; 20 | import org.junit.jupiter.api.Test; 21 | import org.junit.jupiter.api.extension.ExtendWith; 22 | import org.mockito.MockedConstruction; 23 | 24 | import static org.junit.jupiter.api.Assertions.assertTrue; 25 | import static org.mockito.Mockito.mock; 26 | import static org.mockito.Mockito.mockConstruction; 27 | 28 | @ExtendWith(GdxRunner.class) 29 | public class EnemyPhysicsComponentTest { 30 | 31 | private MockedConstruction mockSpriteBatch; 32 | private MockedConstruction mockShapeRenderer; 33 | 34 | @BeforeEach 35 | void init() { 36 | Gdx.gl = mock(GL20.class); 37 | Gdx.gl20 = mock(GL20.class); 38 | mockSpriteBatch = mockConstruction(SpriteBatch.class); 39 | mockShapeRenderer = mockConstruction(ShapeRenderer.class); 40 | } 41 | 42 | @AfterEach 43 | void end() { 44 | mockSpriteBatch.close(); 45 | mockShapeRenderer.close(); 46 | } 47 | 48 | @Test 49 | public void should_follow_player_when_close_enough() { 50 | Json json = new Json(); 51 | Entity player = EntityFactory.getInstance().getEntity(EntityFactory.EntityType.WARRIOR); 52 | MapManager mapManager = new MapManager(); 53 | mapManager.setCamera(new OrthographicCamera()); 54 | mapManager.setPlayer(player); 55 | mapManager.loadMap(MapFactory.MapType.TOPPLE_ROAD_1); 56 | OrthogonalTiledMapRenderer mapRenderer = new OrthogonalTiledMapRenderer(mapManager.getCurrentTiledMap(), Map.UNIT_SCALE); 57 | Entity enemy = mapManager.getCurrentMapEntities().get(1); 58 | 59 | Vector2 currentEntityPosition = new Vector2(13,14); 60 | player.sendMessage(Component.MESSAGE.INIT_START_POSITION, json.toJson(currentEntityPosition)); 61 | player.update(mapManager, mapRenderer.getBatch(), 1.0f); 62 | 63 | float dy = player.getCurrentPosition().y - enemy.getCurrentPosition().y; 64 | 65 | enemy.update(mapManager, mapRenderer.getBatch(), 1.0f); 66 | 67 | float dy2 = player.getCurrentPosition().y - enemy.getCurrentPosition().y; 68 | assertTrue(Math.abs(dy2) < Math.abs(dy)); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/entities/player/PlayerPhysicsComponentTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.entities.player; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.graphics.OrthographicCamera; 6 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 7 | import com.badlogic.gdx.graphics.glutils.ShapeRenderer; 8 | import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; 9 | import com.gdx.game.GdxRunner; 10 | import com.gdx.game.component.Component; 11 | import com.gdx.game.entities.Entity; 12 | import com.gdx.game.entities.EntityFactory; 13 | import com.gdx.game.map.Map; 14 | import com.gdx.game.map.MapFactory; 15 | import com.gdx.game.map.MapManager; 16 | import org.junit.jupiter.api.AfterEach; 17 | import org.junit.jupiter.api.BeforeEach; 18 | import org.junit.jupiter.api.extension.ExtendWith; 19 | import org.junit.jupiter.params.ParameterizedTest; 20 | import org.junit.jupiter.params.provider.Arguments; 21 | import org.junit.jupiter.params.provider.MethodSource; 22 | import org.mockito.MockedConstruction; 23 | 24 | import java.util.stream.Stream; 25 | 26 | import static org.mockito.Mockito.mock; 27 | import static org.mockito.Mockito.mockConstruction; 28 | import static org.mockito.Mockito.spy; 29 | import static org.mockito.Mockito.verify; 30 | 31 | @ExtendWith(GdxRunner.class) 32 | public class PlayerPhysicsComponentTest { 33 | 34 | private MockedConstruction mockSpriteBatch; 35 | private MockedConstruction mockShapeRenderer; 36 | 37 | @BeforeEach 38 | void init() { 39 | Gdx.gl = mock(GL20.class); 40 | Gdx.gl20 = mock(GL20.class); 41 | mockSpriteBatch = mockConstruction(SpriteBatch.class); 42 | mockShapeRenderer = mockConstruction(ShapeRenderer.class); 43 | } 44 | 45 | @AfterEach 46 | void end() { 47 | mockSpriteBatch.close(); 48 | mockShapeRenderer.close(); 49 | } 50 | 51 | @ParameterizedTest 52 | @MethodSource("collisionMapData") 53 | public void testCollisionMapEntities(MapFactory.MapType mapType, Component.MESSAGE message, String entityId) { 54 | Entity player = spy(EntityFactory.getInstance().getEntity(EntityFactory.EntityType.WARRIOR)); 55 | MapManager mapManager = new MapManager(); 56 | mapManager.setCamera(new OrthographicCamera()); 57 | mapManager.setPlayer(player); 58 | mapManager.loadMap(mapType); 59 | OrthogonalTiledMapRenderer mapRenderer = new OrthogonalTiledMapRenderer(mapManager.getCurrentTiledMap(), Map.UNIT_SCALE); 60 | 61 | player.update(mapManager, mapRenderer.getBatch(), 1.0f); 62 | 63 | verify(player).sendMessage(message, entityId); 64 | } 65 | 66 | private static Stream collisionMapData() { 67 | return Stream.of( 68 | Arguments.of(MapFactory.MapType.TOPPLE_ROAD_1, Component.MESSAGE.COLLISION_WITH_FOE, "RABITE"), 69 | Arguments.of(MapFactory.MapType.TOPPLE, Component.MESSAGE.COLLISION_WITH_ENTITY, "TOWN_INNKEEPER") 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/inventory/InventoryItemFactoryTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.inventory.item.InventoryItem; 7 | import com.gdx.game.inventory.item.InventoryItemFactory; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.extension.ExtendWith; 11 | 12 | import static org.assertj.core.api.Assertions.assertThat; 13 | import static org.mockito.Mockito.mock; 14 | 15 | @ExtendWith(GdxRunner.class) 16 | public class InventoryItemFactoryTest { 17 | 18 | @BeforeEach 19 | void init() { 20 | Gdx.gl = mock(GL20.class); 21 | Gdx.gl20 = mock(GL20.class); 22 | } 23 | 24 | @Test 25 | public void testGetInstance_ShouldSucceed() { 26 | InventoryItemFactory inventoryItemFactory = InventoryItemFactory.getInstance(); 27 | 28 | assertThat(inventoryItemFactory).isNotNull(); 29 | } 30 | 31 | @Test 32 | public void testGetInventoryItem_ShouldSucceed() { 33 | InventoryItemFactory inventoryItemFactory = InventoryItemFactory.getInstance(); 34 | 35 | InventoryItem inventoryItem = inventoryItemFactory.getInventoryItem(InventoryItem.ItemTypeID.ARMOR01); 36 | 37 | assertThat(inventoryItemFactory).isNotNull(); 38 | assertThat(inventoryItem).isNotNull(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/inventory/InventoryItemLocationTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.inventory.item.InventoryItemLocation; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import static org.assertj.core.api.Assertions.assertThat; 12 | import static org.mockito.Mockito.mock; 13 | 14 | @ExtendWith(GdxRunner.class) 15 | public class InventoryItemLocationTest { 16 | 17 | @BeforeEach 18 | void init() { 19 | Gdx.gl = mock(GL20.class); 20 | Gdx.gl20 = mock(GL20.class); 21 | } 22 | 23 | @Test 24 | public void testInventoryItemLocation_ShouldSucceed() { 25 | int locationIndex = 0; 26 | String itemTypeAtLocation = "ARMOR04"; 27 | int numberItemAtLocation = 1; 28 | String itemNameProperty = "Player_Inventory"; 29 | 30 | InventoryItemLocation inventoryItemLocation = new InventoryItemLocation(locationIndex, itemTypeAtLocation, numberItemAtLocation, itemNameProperty); 31 | 32 | assertThat(inventoryItemLocation).isNotNull(); 33 | assertThat(inventoryItemLocation.getItemTypeAtLocation()).isEqualTo(itemTypeAtLocation); 34 | assertThat(inventoryItemLocation.getLocationIndex()).isEqualTo(locationIndex); 35 | assertThat(inventoryItemLocation.getNumberItemsAtLocation()).isEqualTo(numberItemAtLocation); 36 | assertThat(inventoryItemLocation.getItemNameProperty()).isEqualTo(itemNameProperty); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/inventory/slot/InventorySlotTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.slot; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | import static org.mockito.Mockito.mock; 12 | 13 | @ExtendWith(GdxRunner.class) 14 | public class InventorySlotTest { 15 | 16 | @BeforeEach 17 | void init() { 18 | Gdx.gl = mock(GL20.class); 19 | Gdx.gl20 = mock(GL20.class); 20 | } 21 | 22 | @Test 23 | public void testInventorySlot_ShouldSucceed() { 24 | InventorySlot inventorySlot = new InventorySlot(); 25 | 26 | assertThat(inventorySlot).isNotNull(); 27 | assertThat(inventorySlot.hasItem()).isFalse(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/inventory/store/StoreInventoryUITest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.inventory.store; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | 10 | import static org.assertj.core.api.Assertions.assertThat; 11 | import static org.mockito.Mockito.mock; 12 | 13 | @ExtendWith(GdxRunner.class) 14 | public class StoreInventoryUITest { 15 | 16 | @BeforeEach 17 | void init() { 18 | Gdx.gl = mock(GL20.class); 19 | Gdx.gl20 = mock(GL20.class); 20 | } 21 | 22 | @Test 23 | public void testStoreInventoryUI_ShouldSucceed() { 24 | StoreInventoryUI storeInventoryUI = new StoreInventoryUI(); 25 | 26 | assertThat(storeInventoryUI).isNotNull(); 27 | assertThat(storeInventoryUI.getCloseButton()).isNotNull(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/manager/AnimationManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.manager; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.Graphics; 5 | import com.badlogic.gdx.graphics.GL20; 6 | import com.badlogic.gdx.graphics.g2d.Animation; 7 | import com.badlogic.gdx.graphics.g2d.TextureRegion; 8 | import com.gdx.game.GdxRunner; 9 | import org.junit.jupiter.api.BeforeEach; 10 | import org.junit.jupiter.api.Test; 11 | import org.junit.jupiter.api.extension.ExtendWith; 12 | 13 | import static org.assertj.core.api.Assertions.assertThat; 14 | import static org.mockito.Mockito.mock; 15 | 16 | @ExtendWith(GdxRunner.class) 17 | class AnimationManagerTest { 18 | 19 | @BeforeEach 20 | void init() { 21 | Gdx.graphics = mock(Graphics.class); 22 | Gdx.gl = mock(GL20.class); 23 | } 24 | 25 | @Test 26 | void testSetTextureRegionsDouble_ShouldSucceed() { 27 | ResourceManager resourceManager = new ResourceManager(); 28 | AnimationManager animationManager = new AnimationManager(); 29 | 30 | TextureRegion[][] textureRegions = animationManager.setTextureRegionsDouble(resourceManager.heroWalkUp, 32, 37); 31 | 32 | assertThat(textureRegions.length).isEqualTo(1); 33 | assertThat(textureRegions[0].length).isEqualTo(3); 34 | } 35 | 36 | @Test 37 | void testSetAnimation_ShouldSucceed() { 38 | ResourceManager resourceManager = new ResourceManager(); 39 | AnimationManager animationManager = new AnimationManager(); 40 | TextureRegion[] textureRegions = TextureRegion.split(resourceManager.heroWalkUp, 32, 37)[0]; 41 | 42 | Animation animation = animationManager.setAnimation(textureRegions); 43 | 44 | assertThat(animation.getFrameDuration()).isEqualTo(0.1f); 45 | assertThat(animation.getKeyFrame(0.1f)).isEqualTo(textureRegions[1]); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/manager/ResourceManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.manager; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.manager.ResourceManager; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import static org.assertj.core.api.Assertions.assertThat; 12 | import static org.mockito.Mockito.mock; 13 | 14 | @ExtendWith(GdxRunner.class) 15 | class ResourceManagerTest { 16 | 17 | @BeforeEach 18 | void init() { 19 | Gdx.gl = mock(GL20.class); 20 | } 21 | 22 | @Test 23 | void testResourceManager_ShouldSucceed() { 24 | ResourceManager resourceManager = new ResourceManager(); 25 | 26 | assertThat(resourceManager).isNotNull() 27 | .hasFieldOrPropertyWithValue("isOptionScreen", false); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/map/MapFactoryTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.map; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.entities.npc.NPCGraphicsComponent; 7 | import com.gdx.game.map.worldMap.Topple; 8 | import com.gdx.game.map.worldMap.ToppleRoad1; 9 | import org.junit.jupiter.api.AfterEach; 10 | import org.junit.jupiter.api.BeforeEach; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | import org.junit.jupiter.params.ParameterizedTest; 14 | import org.junit.jupiter.params.provider.Arguments; 15 | import org.junit.jupiter.params.provider.MethodSource; 16 | import org.mockito.MockedConstruction; 17 | 18 | import java.util.stream.Stream; 19 | 20 | import static java.util.Map.entry; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.mockito.Mockito.mock; 23 | import static org.mockito.Mockito.mockConstruction; 24 | 25 | @ExtendWith(GdxRunner.class) 26 | public class MapFactoryTest { 27 | 28 | private MockedConstruction mockNPCGraphics; 29 | 30 | @BeforeEach 31 | void init() { 32 | Gdx.gl = mock(GL20.class); 33 | Gdx.gl20 = mock(GL20.class); 34 | mockNPCGraphics = mockConstruction(NPCGraphicsComponent.class); 35 | } 36 | 37 | @AfterEach 38 | void end() { 39 | mockNPCGraphics.close(); 40 | } 41 | 42 | @ParameterizedTest 43 | @MethodSource("getMap") 44 | void testGetMap(MapFactory.MapType mapType, Class mapClass) { 45 | Map map = MapFactory.getMap(mapType); 46 | 47 | assertThat(map).isInstanceOf(mapClass); 48 | assertThat(MapFactory.getMapTable()).contains(entry(mapType, map)); 49 | } 50 | 51 | private static Stream getMap() { 52 | return Stream.of( 53 | Arguments.of(MapFactory.MapType.TOPPLE, Topple.class), 54 | Arguments.of(MapFactory.MapType.TOPPLE_ROAD_1, ToppleRoad1.class) 55 | ); 56 | } 57 | 58 | @Test 59 | public void testClearCache_ShouldSucceed() { 60 | MapFactory.getMap(MapFactory.MapType.TOPPLE); 61 | assertThat(MapFactory.getMapTable()).containsKey(MapFactory.MapType.TOPPLE); 62 | 63 | MapFactory.clearCache(); 64 | 65 | assertThat(MapFactory.getMapTable()).isEmpty(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/map/worldMap/ToppleRoad1Test.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.map.worldMap; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.entities.npc.NPCGraphicsComponent; 7 | import com.gdx.game.map.MapFactory; 8 | import org.junit.jupiter.api.AfterEach; 9 | import org.junit.jupiter.api.BeforeEach; 10 | import org.junit.jupiter.api.Test; 11 | import org.junit.jupiter.api.extension.ExtendWith; 12 | import org.mockito.MockedConstruction; 13 | 14 | import static org.assertj.core.api.Assertions.assertThat; 15 | import static org.mockito.Mockito.mock; 16 | import static org.mockito.Mockito.mockConstruction; 17 | 18 | @ExtendWith(GdxRunner.class) 19 | public class ToppleRoad1Test { 20 | 21 | private MockedConstruction mockNPCGraphics; 22 | 23 | @BeforeEach 24 | void init() { 25 | Gdx.gl = mock(GL20.class); 26 | Gdx.gl20 = mock(GL20.class); 27 | mockNPCGraphics = mockConstruction(NPCGraphicsComponent.class); 28 | } 29 | 30 | @AfterEach 31 | void end() { 32 | mockNPCGraphics.close(); 33 | } 34 | 35 | @Test 36 | public void testToppleRoad1_ShouldSucceed() { 37 | ToppleRoad1 toppleRoad1 = new ToppleRoad1(); 38 | 39 | assertThat(toppleRoad1.getMusicTheme()).isNotNull(); 40 | assertThat(toppleRoad1.getCollisionLayer()).isNotNull(); 41 | assertThat(toppleRoad1.getEnemySpawnLayer()).isNotNull(); 42 | assertThat(toppleRoad1.getMapQuestEntities()).isEmpty(); 43 | assertThat(toppleRoad1.getQuestDiscoverLayer()).isNull(); 44 | assertThat(toppleRoad1.getQuestItemSpawnLayer()).isNull(); 45 | assertThat(toppleRoad1.getPortalLayer()).isNotNull(); 46 | assertThat(toppleRoad1.getPlayerStart()).isNotNull(); 47 | assertThat(toppleRoad1.getCurrentMapType()).isEqualTo(MapFactory.MapType.TOPPLE_ROAD_1); 48 | assertThat(toppleRoad1.getMapEntities().size).isEqualTo(2); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/map/worldMap/ToppleTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.map.worldMap; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.entities.npc.NPCGraphicsComponent; 7 | import com.gdx.game.map.MapFactory; 8 | import org.junit.jupiter.api.AfterEach; 9 | import org.junit.jupiter.api.BeforeEach; 10 | import org.junit.jupiter.api.Test; 11 | import org.junit.jupiter.api.extension.ExtendWith; 12 | import org.mockito.MockedConstruction; 13 | 14 | import static org.assertj.core.api.Assertions.assertThat; 15 | import static org.mockito.Mockito.mock; 16 | import static org.mockito.Mockito.mockConstruction; 17 | 18 | @ExtendWith(GdxRunner.class) 19 | public class ToppleTest { 20 | 21 | private MockedConstruction mockNPCGraphics; 22 | 23 | @BeforeEach 24 | void init() { 25 | Gdx.gl = mock(GL20.class); 26 | Gdx.gl20 = mock(GL20.class); 27 | mockNPCGraphics = mockConstruction(NPCGraphicsComponent.class); 28 | } 29 | 30 | @AfterEach 31 | void end() { 32 | mockNPCGraphics.close(); 33 | } 34 | 35 | @Test 36 | public void testTopple_ShouldSucceed() { 37 | Topple topple = new Topple(); 38 | 39 | assertThat(topple.getMusicTheme()).isNotNull(); 40 | assertThat(topple.getCollisionLayer()).isNotNull(); 41 | assertThat(topple.getEnemySpawnLayer()).isNull(); 42 | assertThat(topple.getMapQuestEntities()).isEmpty(); 43 | assertThat(topple.getQuestDiscoverLayer()).isNull(); 44 | assertThat(topple.getQuestItemSpawnLayer()).isNotNull(); 45 | assertThat(topple.getPortalLayer()).isNotNull(); 46 | assertThat(topple.getPlayerStart()).isNotNull(); 47 | assertThat(topple.getCurrentMapType()).isEqualTo(MapFactory.MapType.TOPPLE); 48 | assertThat(topple.getMapEntities().size).isEqualTo(5); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/profile/ProfileManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.profile; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.math.Vector2; 6 | import com.gdx.game.GdxRunner; 7 | import org.junit.jupiter.api.BeforeEach; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | import static com.gdx.game.profile.ProfileManager.DEFAULT_PROFILE; 12 | import static org.assertj.core.api.Assertions.assertThat; 13 | import static org.mockito.Mockito.mock; 14 | 15 | @ExtendWith(GdxRunner.class) 16 | public class ProfileManagerTest { 17 | 18 | @BeforeEach 19 | void init() { 20 | Gdx.gl = mock(GL20.class); 21 | Gdx.gl20 = mock(GL20.class); 22 | } 23 | 24 | @Test 25 | public void testProfileManager_ShouldSucceed() { 26 | ProfileManager profileManager = new ProfileManager(); 27 | 28 | assertThat(profileManager.getProfileList()).isNotNull(); 29 | 30 | Gdx.files.local(DEFAULT_PROFILE + ".sav").delete(); 31 | } 32 | 33 | @Test 34 | public void testGetInstance_ShouldSucceed() { 35 | ProfileManager profileManager = ProfileManager.getInstance(); 36 | 37 | assertThat(profileManager).isNotNull(); 38 | assertThat(profileManager.getProfileList()).isNotNull(); 39 | 40 | Gdx.files.local(DEFAULT_PROFILE + ".sav").delete(); 41 | } 42 | 43 | @Test 44 | public void testWriteProfileToStorage_ShouldSucceed() { 45 | ProfileManager profileManager = new ProfileManager(); 46 | profileManager.setProperty("toppleMapStartPosition", new Vector2(10,10)); 47 | 48 | profileManager.saveProfile(); 49 | 50 | assertThat(profileManager.getProfileList()).hasSize(1); 51 | assertThat(profileManager.getProfileList()).contains(DEFAULT_PROFILE); 52 | 53 | Gdx.files.local(DEFAULT_PROFILE + ".sav").delete(); 54 | } 55 | 56 | @Test 57 | public void testLoadProfile_ShouldSucceedWithNewProfile() { 58 | ProfileManager profileManager = new ProfileManager(); 59 | profileManager.setIsNewProfile(true); 60 | 61 | profileManager.loadProfile(); 62 | 63 | assertThat(profileManager.getIsNewProfile()).isFalse(); 64 | assertThat(profileManager.getProfileList()).hasSize(1); 65 | assertThat(profileManager.getProfileList()).contains(DEFAULT_PROFILE); 66 | 67 | Gdx.files.local(DEFAULT_PROFILE + ".sav").delete(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/quest/QuestTaskTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.quest; 2 | 3 | import com.badlogic.gdx.utils.ObjectMap; 4 | import com.gdx.game.GdxRunner; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | @ExtendWith(GdxRunner.class) 11 | public class QuestTaskTest { 12 | 13 | @Test 14 | public void testIsTaskComplete_ShouldSucceed() { 15 | QuestTask questTask = new QuestTask(); 16 | ObjectMap taskProperties = questTask.getTaskProperties(); 17 | taskProperties.put(QuestTask.QuestTaskPropertyType.IS_TASK_COMPLETE.toString(), true); 18 | 19 | boolean isQuestTaskComplete = questTask.isTaskComplete(); 20 | 21 | assertThat(isQuestTaskComplete).isTrue(); 22 | } 23 | 24 | @Test 25 | public void testIsTaskComplete_ShouldSucceedReturnFalse() { 26 | QuestTask questTask = new QuestTask(); 27 | 28 | boolean isQuestTaskComplete = questTask.isTaskComplete(); 29 | 30 | assertThat(isQuestTaskComplete).isFalse(); 31 | } 32 | 33 | @Test 34 | public void testGetPropertyValue_ShouldSucceed() { 35 | QuestTask questTask = new QuestTask(); 36 | ObjectMap taskProperties = questTask.getTaskProperties(); 37 | taskProperties.put(QuestTask.QuestTaskPropertyType.IS_TASK_COMPLETE.toString(), true); 38 | 39 | String propertyValue = questTask.getPropertyValue(QuestTask.QuestTaskPropertyType.IS_TASK_COMPLETE.toString()); 40 | 41 | assertThat(propertyValue).isEqualTo("true"); 42 | } 43 | 44 | @Test 45 | public void testGetPropertyValue_ShouldSucceedWhenNullValue() { 46 | QuestTask questTask = new QuestTask(); 47 | ObjectMap taskProperties = questTask.getTaskProperties(); 48 | taskProperties.put(QuestTask.QuestTaskPropertyType.IS_TASK_COMPLETE.toString(), null); 49 | 50 | String propertyValue = questTask.getPropertyValue(QuestTask.QuestTaskPropertyType.IS_TASK_COMPLETE.toString()); 51 | 52 | assertThat(propertyValue).isEmpty(); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/screen/CharacterSelectionScreenTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 6 | import com.badlogic.gdx.scenes.scene2d.Stage; 7 | import com.gdx.game.GdxGame; 8 | import com.gdx.game.GdxRunner; 9 | import com.gdx.game.entities.player.PlayerGraphicsComponent; 10 | import com.gdx.game.manager.ResourceManager; 11 | import org.junit.jupiter.api.AfterEach; 12 | import org.junit.jupiter.api.BeforeEach; 13 | import org.junit.jupiter.api.Test; 14 | import org.junit.jupiter.api.extension.ExtendWith; 15 | import org.mockito.MockedConstruction; 16 | 17 | import static org.junit.jupiter.api.Assertions.assertNotNull; 18 | import static org.mockito.Mockito.mock; 19 | import static org.mockito.Mockito.mockConstruction; 20 | 21 | @ExtendWith(GdxRunner.class) 22 | public class CharacterSelectionScreenTest { 23 | 24 | private MockedConstruction mockPlayerGraphics; 25 | private MockedConstruction mockSpriteBatch; 26 | private MockedConstruction mockStage; 27 | 28 | @BeforeEach 29 | void init() { 30 | Gdx.gl = mock(GL20.class); 31 | Gdx.gl20 = mock(GL20.class); 32 | mockPlayerGraphics = mockConstruction(PlayerGraphicsComponent.class); 33 | mockSpriteBatch = mockConstruction(SpriteBatch.class); 34 | mockStage = mockConstruction(Stage.class); 35 | } 36 | 37 | @AfterEach 38 | void end() { 39 | mockPlayerGraphics.close(); 40 | mockSpriteBatch.close(); 41 | mockStage.close(); 42 | } 43 | 44 | @Test 45 | void screen_instance() { 46 | GdxGame gdxGame = mock(GdxGame.class); 47 | ResourceManager resourceManager = new ResourceManager(); 48 | CharacterSelectionScreen screen = new CharacterSelectionScreen(gdxGame, resourceManager); 49 | 50 | assertNotNull(screen); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/screen/GameOverScreenTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.scenes.scene2d.Stage; 6 | import com.gdx.game.GdxGame; 7 | import com.gdx.game.GdxRunner; 8 | import com.gdx.game.manager.ResourceManager; 9 | import com.gdx.game.map.MapManager; 10 | import org.junit.jupiter.api.AfterEach; 11 | import org.junit.jupiter.api.BeforeEach; 12 | import org.junit.jupiter.api.Test; 13 | import org.junit.jupiter.api.extension.ExtendWith; 14 | import org.mockito.MockedConstruction; 15 | 16 | import static org.junit.jupiter.api.Assertions.assertNotNull; 17 | import static org.mockito.Mockito.mock; 18 | import static org.mockito.Mockito.mockConstruction; 19 | 20 | @ExtendWith(GdxRunner.class) 21 | public class GameOverScreenTest { 22 | 23 | private MockedConstruction mockStage; 24 | 25 | @BeforeEach 26 | void init() { 27 | Gdx.gl = mock(GL20.class); 28 | Gdx.gl20 = mock(GL20.class); 29 | mockStage = mockConstruction(Stage.class); 30 | } 31 | 32 | @AfterEach 33 | void end() { 34 | mockStage.close(); 35 | } 36 | 37 | @Test 38 | void screen_instance() { 39 | GdxGame gdxGame = mock(GdxGame.class); 40 | MapManager mapManager = new MapManager(); 41 | ResourceManager resourceManager = new ResourceManager(); 42 | GameOverScreen screen = new GameOverScreen(gdxGame, mapManager, resourceManager); 43 | 44 | assertNotNull(screen); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/screen/MenuLoadGameScreenTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.scenes.scene2d.Stage; 6 | import com.gdx.game.GdxGame; 7 | import com.gdx.game.GdxRunner; 8 | import com.gdx.game.manager.ResourceManager; 9 | import org.junit.jupiter.api.AfterEach; 10 | import org.junit.jupiter.api.BeforeEach; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | import org.mockito.MockedConstruction; 14 | 15 | import static org.junit.jupiter.api.Assertions.assertNotNull; 16 | import static org.mockito.Mockito.mock; 17 | import static org.mockito.Mockito.mockConstruction; 18 | 19 | @ExtendWith(GdxRunner.class) 20 | public class MenuLoadGameScreenTest { 21 | 22 | private MockedConstruction mockStage; 23 | 24 | @BeforeEach 25 | void init() { 26 | Gdx.gl = mock(GL20.class); 27 | Gdx.gl20 = mock(GL20.class); 28 | mockStage = mockConstruction(Stage.class); 29 | } 30 | 31 | @AfterEach 32 | void end() { 33 | mockStage.close(); 34 | } 35 | 36 | @Test 37 | void screen_instance() { 38 | GdxGame gdxGame = mock(GdxGame.class); 39 | BaseScreen baseScreen = mock(BaseScreen.class); 40 | ResourceManager resourceManager = new ResourceManager(); 41 | MenuLoadGameScreen screen = new MenuLoadGameScreen(gdxGame, baseScreen, resourceManager); 42 | 43 | assertNotNull(screen); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/screen/MenuNewGameScreenTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.scenes.scene2d.Stage; 6 | import com.gdx.game.GdxGame; 7 | import com.gdx.game.GdxRunner; 8 | import com.gdx.game.manager.ResourceManager; 9 | import org.junit.jupiter.api.AfterEach; 10 | import org.junit.jupiter.api.BeforeEach; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | import org.mockito.MockedConstruction; 14 | 15 | import static org.junit.jupiter.api.Assertions.assertNotNull; 16 | import static org.mockito.Mockito.mock; 17 | import static org.mockito.Mockito.mockConstruction; 18 | 19 | @ExtendWith(GdxRunner.class) 20 | public class MenuNewGameScreenTest { 21 | 22 | private MockedConstruction mockStage; 23 | 24 | @BeforeEach 25 | void init() { 26 | Gdx.gl = mock(GL20.class); 27 | Gdx.gl20 = mock(GL20.class); 28 | mockStage = mockConstruction(Stage.class); 29 | } 30 | 31 | @AfterEach 32 | void end() { 33 | mockStage.close(); 34 | } 35 | 36 | @Test 37 | void screen_instance() { 38 | GdxGame gdxGame = mock(GdxGame.class); 39 | BaseScreen baseScreen = mock(BaseScreen.class); 40 | ResourceManager resourceManager = new ResourceManager(); 41 | MenuNewGameScreen screen = new MenuNewGameScreen(gdxGame, baseScreen, resourceManager); 42 | 43 | assertNotNull(screen); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/screen/MenuScreenTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.scenes.scene2d.Stage; 6 | import com.gdx.game.GdxGame; 7 | import com.gdx.game.GdxRunner; 8 | import com.gdx.game.manager.ResourceManager; 9 | import org.junit.jupiter.api.AfterEach; 10 | import org.junit.jupiter.api.BeforeEach; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | import org.mockito.MockedConstruction; 14 | 15 | import static org.junit.jupiter.api.Assertions.assertNotNull; 16 | import static org.mockito.Mockito.mock; 17 | import static org.mockito.Mockito.mockConstruction; 18 | 19 | @ExtendWith(GdxRunner.class) 20 | public class MenuScreenTest { 21 | 22 | private MockedConstruction mockStage; 23 | 24 | @BeforeEach 25 | void init() { 26 | Gdx.gl = mock(GL20.class); 27 | Gdx.gl20 = mock(GL20.class); 28 | mockStage = mockConstruction(Stage.class); 29 | } 30 | 31 | @AfterEach 32 | void end() { 33 | mockStage.close(); 34 | } 35 | 36 | @Test 37 | void screen_instance() { 38 | GdxGame gdxGame = mock(GdxGame.class); 39 | ResourceManager resourceManager = new ResourceManager(); 40 | MenuScreen screen = new MenuScreen(gdxGame, resourceManager); 41 | 42 | assertNotNull(screen); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/screen/OptionScreenTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.scenes.scene2d.Stage; 6 | import com.crashinvaders.vfx.VfxManager; 7 | import com.crashinvaders.vfx.effects.GaussianBlurEffect; 8 | import com.gdx.game.GdxGame; 9 | import com.gdx.game.GdxRunner; 10 | import com.gdx.game.manager.ResourceManager; 11 | import org.junit.jupiter.api.AfterEach; 12 | import org.junit.jupiter.api.BeforeEach; 13 | import org.junit.jupiter.api.Test; 14 | import org.junit.jupiter.api.extension.ExtendWith; 15 | import org.mockito.MockedConstruction; 16 | 17 | import static org.junit.jupiter.api.Assertions.assertNotNull; 18 | import static org.mockito.Mockito.mock; 19 | import static org.mockito.Mockito.mockConstruction; 20 | 21 | @ExtendWith(GdxRunner.class) 22 | public class OptionScreenTest { 23 | 24 | private MockedConstruction mockStage; 25 | private MockedConstruction mockVfxManager; 26 | private MockedConstruction mockGaussianEffect; 27 | 28 | @BeforeEach 29 | void init() { 30 | Gdx.gl = mock(GL20.class); 31 | Gdx.gl20 = mock(GL20.class); 32 | mockStage = mockConstruction(Stage.class); 33 | mockVfxManager = mockConstruction(VfxManager.class); 34 | mockGaussianEffect = mockConstruction(GaussianBlurEffect.class); 35 | } 36 | 37 | @AfterEach 38 | void end() { 39 | mockStage.close(); 40 | mockVfxManager.close(); 41 | mockGaussianEffect.close(); 42 | } 43 | 44 | @Test 45 | void screen_instance() { 46 | GdxGame gdxGame = mock(GdxGame.class); 47 | BaseScreen baseScreen = mock(BaseScreen.class); 48 | ResourceManager resourceManager = new ResourceManager(); 49 | OptionScreen screen = new OptionScreen(gdxGame, baseScreen, resourceManager); 50 | 51 | assertNotNull(screen); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/screen/cutscene/CreatorIntroScreenTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.cutscene; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.graphics.g2d.SpriteBatch; 6 | import com.badlogic.gdx.graphics.glutils.ShapeRenderer; 7 | import com.badlogic.gdx.scenes.scene2d.Stage; 8 | import com.gdx.game.GdxGame; 9 | import com.gdx.game.GdxRunner; 10 | import com.gdx.game.entities.EntityFactory; 11 | import com.gdx.game.entities.player.PlayerGraphicsComponent; 12 | import com.gdx.game.manager.ResourceManager; 13 | import com.gdx.game.profile.ProfileManager; 14 | import org.junit.jupiter.api.AfterEach; 15 | import org.junit.jupiter.api.BeforeEach; 16 | import org.junit.jupiter.api.Test; 17 | import org.junit.jupiter.api.extension.ExtendWith; 18 | import org.mockito.MockedConstruction; 19 | 20 | import static org.junit.jupiter.api.Assertions.assertNotNull; 21 | import static org.mockito.Mockito.mock; 22 | import static org.mockito.Mockito.mockConstruction; 23 | 24 | @ExtendWith(GdxRunner.class) 25 | public class CreatorIntroScreenTest { 26 | 27 | private MockedConstruction mockPlayerGraphics; 28 | private MockedConstruction mockShapeRenderer; 29 | private MockedConstruction mockSpriteBatch; 30 | private MockedConstruction mockStage; 31 | 32 | @BeforeEach 33 | void init() { 34 | Gdx.gl = mock(GL20.class); 35 | Gdx.gl20 = mock(GL20.class); 36 | mockPlayerGraphics = mockConstruction(PlayerGraphicsComponent.class); 37 | mockShapeRenderer = mockConstruction(ShapeRenderer.class); 38 | mockSpriteBatch = mockConstruction(SpriteBatch.class); 39 | mockStage = mockConstruction(Stage.class); 40 | ProfileManager profileManager = ProfileManager.getInstance(); 41 | profileManager.setProperty("playerCharacter", EntityFactory.EntityType.WARRIOR); 42 | profileManager.setProperty("currentPlayerCharacterAP", 15); 43 | profileManager.setProperty("currentPlayerCharacterDP", 15); 44 | profileManager.setProperty("currentPlayerCharacterSPDP", 10); 45 | } 46 | 47 | @AfterEach 48 | void end() { 49 | mockPlayerGraphics.close(); 50 | mockShapeRenderer.close(); 51 | mockSpriteBatch.close(); 52 | mockStage.close(); 53 | } 54 | 55 | @Test 56 | void screen_instance() { 57 | GdxGame gdxGame = mock(GdxGame.class); 58 | ResourceManager resourceManager = new ResourceManager(); 59 | CreatorIntroScreen screen = new CreatorIntroScreen(gdxGame, resourceManager); 60 | 61 | assertNotNull(screen); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/screen/transition/ImmediateModeRendererUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.transition; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.Graphics; 5 | import com.badlogic.gdx.graphics.GL20; 6 | import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20; 7 | import com.badlogic.gdx.math.Matrix4; 8 | import com.gdx.game.GdxRunner; 9 | import org.junit.jupiter.api.AfterEach; 10 | import org.junit.jupiter.api.BeforeEach; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | import org.mockito.MockedConstruction; 14 | 15 | import static com.badlogic.gdx.math.Matrix4.M00; 16 | import static com.badlogic.gdx.math.Matrix4.M03; 17 | import static com.badlogic.gdx.math.Matrix4.M11; 18 | import static com.badlogic.gdx.math.Matrix4.M13; 19 | import static com.badlogic.gdx.math.Matrix4.M22; 20 | import static com.badlogic.gdx.math.Matrix4.M23; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.mockito.Mockito.mock; 23 | import static org.mockito.Mockito.mockConstruction; 24 | 25 | @ExtendWith(GdxRunner.class) 26 | class ImmediateModeRendererUtilsTest { 27 | 28 | private MockedConstruction mockRenderer; 29 | 30 | @BeforeEach 31 | void init() { 32 | Gdx.graphics = mock(Graphics.class); 33 | Gdx.gl20 = mock(GL20.class); 34 | mockRenderer = mockConstruction(ImmediateModeRenderer20.class); 35 | } 36 | 37 | @AfterEach 38 | void end() { 39 | mockRenderer.close(); 40 | } 41 | 42 | @Test 43 | void testGetProjectionMatrix_ShouldSucceed() { 44 | Matrix4 matrix4 = ImmediateModeRendererUtils.getProjectionMatrix(); 45 | 46 | assertThat(matrix4).isNotNull(); 47 | assertThat(matrix4.val[M00]).isEqualTo(Float.POSITIVE_INFINITY); 48 | assertThat(matrix4.val[M11]).isEqualTo(Float.POSITIVE_INFINITY); 49 | assertThat(matrix4.val[M22]).isEqualTo(-2.0f); 50 | assertThat(matrix4.val[M03]).isNaN(); 51 | assertThat(matrix4.val[M13]).isNaN(); 52 | assertThat(matrix4.val[M23]).isEqualTo(-1.0f); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/screen/transition/TimeTransitionTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.screen.transition; 2 | 3 | import com.gdx.game.GdxRunner; 4 | import com.gdx.game.screen.transition.TimeTransition; 5 | import org.junit.jupiter.api.Test; 6 | import org.junit.jupiter.api.extension.ExtendWith; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | @ExtendWith(GdxRunner.class) 11 | class TimeTransitionTest { 12 | 13 | @Test 14 | void testGet_ShouldSucceedWithTimeNull() { 15 | TimeTransition timeTransition = new TimeTransition(); 16 | 17 | float time = timeTransition.get(); 18 | 19 | assertThat(time).isEqualTo(1f); 20 | } 21 | 22 | @Test 23 | void testGet_ShouldSucceedWithTimeNotZero() { 24 | float duration = 1f; 25 | TimeTransition timeTransition = new TimeTransition(); 26 | timeTransition.start(duration); 27 | 28 | float time = timeTransition.get(); 29 | 30 | assertThat(time).isZero(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/status/LevelTableTest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.status; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.badlogic.gdx.utils.Array; 6 | import com.gdx.game.GdxRunner; 7 | import com.gdx.game.status.LevelTable; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.extension.ExtendWith; 11 | 12 | import static org.assertj.core.api.Assertions.assertThat; 13 | import static org.mockito.Mockito.mock; 14 | 15 | @ExtendWith(GdxRunner.class) 16 | public class LevelTableTest { 17 | 18 | @BeforeEach 19 | void init() { 20 | Gdx.gl = mock(GL20.class); 21 | Gdx.gl20 = mock(GL20.class); 22 | } 23 | 24 | @Test 25 | public void testGetLevelTables_ShouldSucceed() { 26 | Array levelTables = LevelTable.getLevelTables("scripts/level_tables.json"); 27 | 28 | assertThat(levelTables).isNotNull(); 29 | assertThat(levelTables).hasSize(10); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/com/gdx/game/status/StatsUpUITest.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.status; 2 | 3 | import com.badlogic.gdx.Gdx; 4 | import com.badlogic.gdx.graphics.GL20; 5 | import com.gdx.game.GdxRunner; 6 | import com.gdx.game.manager.ResourceManager; 7 | import com.gdx.game.profile.ProfileManager; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.extension.ExtendWith; 11 | 12 | import java.util.Arrays; 13 | 14 | import static org.assertj.core.api.Assertions.assertThat; 15 | import static org.mockito.Mockito.mock; 16 | 17 | @ExtendWith(GdxRunner.class) 18 | public class StatsUpUITest { 19 | 20 | @BeforeEach 21 | void init() { 22 | Gdx.gl = mock(GL20.class); 23 | Gdx.gl20 = mock(GL20.class); 24 | new ResourceManager(); 25 | } 26 | 27 | @Test 28 | public void testStatsUpUI_ShouldSucceed() { 29 | ProfileManager profileManager = ProfileManager.getInstance(); 30 | profileManager.setProperty("currentPlayerCharacterAP", 5); 31 | profileManager.setProperty("currentPlayerCharacterDP", 5); 32 | profileManager.setProperty("currentPlayerCharacterSPDP", 5); 33 | 34 | StatsUpUI statsUpUI = new StatsUpUI(1); 35 | 36 | assertThat(statsUpUI).isNotNull(); 37 | assertThat(statsUpUI.getChildren().size).isEqualTo(22); 38 | assertThat(Arrays.stream(statsUpUI.getChildren().items).count()).isEqualTo(24); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/resources/entities/hero/hero_1_walking_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/core/src/test/resources/entities/hero/hero_1_walking_up.png -------------------------------------------------------------------------------- /desktop/build.gradle.kts: -------------------------------------------------------------------------------- 1 | apply(plugin = "java") 2 | 3 | java { 4 | sourceCompatibility = JavaVersion.VERSION_17 5 | } 6 | 7 | configure { 8 | named("main") { 9 | java.srcDir("src/java/") 10 | } 11 | named("test") { 12 | java.srcDir("src/java/") 13 | } 14 | } -------------------------------------------------------------------------------- /desktop/src/main/java/com/gdx/game/desktop/DesktopLauncher.java: -------------------------------------------------------------------------------- 1 | package com.gdx.game.desktop; 2 | 3 | import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; 4 | import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; 5 | import com.gdx.game.GdxGame; 6 | 7 | public class DesktopLauncher { 8 | public static void main (String[] arg) { 9 | Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); 10 | config.setWindowedMode(800, 600); 11 | 12 | new Lwjgl3Application(new GdxGame(), config); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /desktop/src/main/resources/demo/battle_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/desktop/src/main/resources/demo/battle_demo.gif -------------------------------------------------------------------------------- /desktop/src/main/resources/demo/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/desktop/src/main/resources/demo/demo.gif -------------------------------------------------------------------------------- /desktop/src/main/resources/demo/demo_new_DA.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/desktop/src/main/resources/demo/demo_new_DA.gif -------------------------------------------------------------------------------- /desktop/src/main/resources/demo/demo_new_DA_battle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/desktop/src/main/resources/demo/demo_new_DA_battle.gif -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.daemon=true 2 | org.gradle.jvmargs=-Xms128m -Xmx1500m 3 | org.gradle.configureondemand=false 4 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | libgdx = "1.13.5" 3 | gdx-vfx = "0.5.4" 4 | logback = "1.5.18" 5 | junit-platform = "1.13.0" 6 | junit-jupiter = "5.13.0" 7 | mockito = "5.18.0" 8 | assertj = "3.27.3" 9 | 10 | [libraries] 11 | gdx-lwjgl3 = { group = "com.badlogicgames.gdx", name = "gdx-backend-lwjgl3", version.ref = "libgdx" } 12 | gdx-freetype-platform = { group = "com.badlogicgames.gdx", name = "gdx-freetype-platform", version.ref = "libgdx"} 13 | gdx = { group = "com.badlogicgames.gdx", name = "gdx", version.ref = "libgdx" } 14 | gdx-platform = { group = "com.badlogicgames.gdx", name = "gdx-platform", version.ref = "libgdx"} 15 | gdx-backend-headless = { group = "com.badlogicgames.gdx", name = "gdx-backend-headless", version.ref = "libgdx"} 16 | vfx-core = { group = "com.crashinvaders.vfx", name = "gdx-vfx-core", version.ref = "gdx-vfx" } 17 | vfx-effects = { group = "com.crashinvaders.vfx", name = "gdx-vfx-effects", version.ref = "gdx-vfx" } 18 | logback = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logback" } 19 | junit-platform = { group = "org.junit.platform", name = "junit-platform-launcher", version.ref = "junit-platform" } 20 | junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit-jupiter" } 21 | junit-jupiter-params = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junit-jupiter" } 22 | junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit-jupiter" } 23 | mockito = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" } 24 | assertj = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" } 25 | 26 | [bundles] 27 | junit = ["junit-platform", "junit-jupiter-api", "junit-jupiter-params"] 28 | gdx-vfx = ["vfx-core", "vfx-effects"] -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdescottes/GdxGame/a855544d45d7a0aadad7904a6aad10adb4bb9216/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "GdxGame" 2 | include("desktop", "core") --------------------------------------------------------------------------------