-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added required animations and sprite for income tower
- Loading branch information
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
econ-tower.png | ||
size: 256, 64 | ||
format: RGBA8888 | ||
filter: Nearest, Nearest | ||
repeat: none | ||
move1 | ||
rotate: false | ||
xy: 122, 2 | ||
size: 28, 31 | ||
orig: 28, 31 | ||
offset: 0, 0 | ||
index: -1 | ||
move2 | ||
rotate: false | ||
xy: 32, 2 | ||
size: 28, 31 | ||
orig: 28, 31 | ||
offset: 0, 0 | ||
index: -1 | ||
move3 | ||
rotate: false | ||
xy: 182, 2 | ||
size: 28, 31 | ||
orig: 28, 31 | ||
offset: 0, 0 | ||
index: -1 | ||
move4 | ||
rotate: false | ||
xy: 92, 2 | ||
size: 28, 31 | ||
orig: 28, 31 | ||
offset: 0, 0 | ||
index: -1 | ||
move5 | ||
rotate: false | ||
xy: 2, 2 | ||
size: 28, 31 | ||
orig: 28, 31 | ||
offset: 0, 0 | ||
index: -1 | ||
move6 | ||
rotate: false | ||
xy: 152, 2 | ||
size: 28, 31 | ||
orig: 28, 31 | ||
offset: 0, 0 | ||
index: -1 | ||
move7 | ||
rotate: false | ||
xy: 62, 2 | ||
size: 28, 31 | ||
orig: 28, 31 | ||
offset: 0, 0 | ||
index: -1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions
71
source/core/src/main/com/csse3200/game/components/tower/EconTowerAnimationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.csse3200.game.components.tower; | ||
|
||
import com.badlogic.gdx.audio.Sound; | ||
import com.csse3200.game.components.Component; | ||
import com.csse3200.game.rendering.AnimationRenderComponent; | ||
import com.csse3200.game.services.ServiceLocator; | ||
|
||
/** | ||
* Listens for events relevant to a weapon tower state. | ||
* Each event will trigger a certain animation | ||
*/ | ||
public class TowerAnimationController extends Component { | ||
// Event name constants | ||
private static final String IDLE = "idleStart"; | ||
private static final String DEPLOY = "deployStart"; | ||
private static final String FIRING = "firingStart"; | ||
private static final String STOW = "stowStart"; | ||
// Animation name constants | ||
private static final String IDLE_ANIM = "idle"; | ||
private static final String DEPLOY_ANIM = "deploy"; | ||
private static final String FIRE_ANIM = "firing"; | ||
private static final String STOW_ANIM = "stow"; | ||
// Sound effects constants | ||
private static final String DEPLOY_SFX = "sounds/towers/deploy.mp3"; | ||
private static final String FIRE_SFX = "sounds/towers/gun_shot_trimmed.mp3"; | ||
private static final String STOW_SFX = "sounds/towers/stow.mp3"; | ||
|
||
AnimationRenderComponent animator; | ||
Sound deploySound = ServiceLocator.getResourceService().getAsset( | ||
DEPLOY_SFX, Sound.class); | ||
Sound attackSound = ServiceLocator.getResourceService().getAsset( | ||
FIRE_SFX, Sound.class); | ||
Sound stowSound = ServiceLocator.getResourceService().getAsset( | ||
STOW_SFX, Sound.class); | ||
|
||
/** | ||
* Creation call for a TowerAnimationController, fetches the animationRenderComponent that this controller will | ||
* be attached to and registers all the event listeners required to trigger the animations and sounds. | ||
*/ | ||
@Override | ||
public void create() { | ||
super.create(); | ||
animator = this.entity.getComponent(AnimationRenderComponent.class); | ||
entity.getEvents().addListener(IDLE, this::animateIdle); | ||
entity.getEvents().addListener(STOW, this::animateStow); | ||
entity.getEvents().addListener(DEPLOY, this::animateDeploy); | ||
entity.getEvents().addListener(FIRING, this::animateFiring); | ||
} | ||
|
||
/** | ||
* Starts the | ||
*/ | ||
void animateIdle() { | ||
animator.startAnimation(IDLE_ANIM); | ||
} | ||
|
||
void animateStow() { | ||
animator.startAnimation(STOW_ANIM); | ||
stowSound.play(); | ||
} | ||
|
||
void animateDeploy() { | ||
animator.startAnimation(DEPLOY_ANIM); | ||
deploySound.play(); | ||
} | ||
|
||
void animateFiring() { | ||
animator.startAnimation(FIRE_ANIM); | ||
attackSound.play(); | ||
} | ||
} |