Search in sources :

Example 1 with ScreenManager

use of com.relic.highflyer.screens.ScreenManager in project high-flyer by sangngh.

the class BuildingCollisionDetectorTest method testDetect_hasCollision.

@Test
public void testDetect_hasCollision() {
    GameState state = new GameState();
    state.setScore(110);
    GameEngine game = new GameEngine(new GameSettings(800, 600), state, new ScreenManager());
    List<Cell> nextCells = new ArrayList<>();
    Cell collisionCell = new Cell();
    TiledMapTile mockTile = Mockito.mock(TiledMapTile.class);
    MapProperties mapProperties = new MapProperties();
    mapProperties.put("damage", true);
    Mockito.when(mockTile.getProperties()).thenReturn(mapProperties);
    collisionCell.setTile(mockTile);
    nextCells.add(collisionCell);
    subject.detect(game, nextCells, mockPlayer, 100, 100);
    Mockito.verify(mockPlayer).setX(Mockito.eq(0f));
    Mockito.verify(mockPlayer).setY(Mockito.eq(260f));
    Mockito.verify(mockSoundPlayer).playSound(Mockito.eq("data/sounds/Shutdown.wav"));
    assertEquals("Mismatching game score", 10, state.getScore());
}
Also used : ScreenManager(com.relic.highflyer.screens.ScreenManager) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) ArrayList(java.util.ArrayList) MapProperties(com.badlogic.gdx.maps.MapProperties) GameState(com.relic.highflyer.GameState) GameEngine(com.relic.highflyer.GameEngine) GameSettings(com.relic.highflyer.GameSettings) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell) Test(org.junit.Test)

Example 2 with ScreenManager

use of com.relic.highflyer.screens.ScreenManager in project high-flyer by sangngh.

the class LandingDetectorTest method testDetect_hasMulCell.

@Test
public void testDetect_hasMulCell() {
    GameState state = new GameState();
    // state.setScore(110);
    GameEngine game = new GameEngine(new GameSettings(800, 600), state, new ScreenManager());
    Mockito.when(mockScreenManager.getScreen(Mockito.anyInt())).thenReturn(Mockito.mock(Screen.class));
    List<Cell> nextCells = new ArrayList<>();
    Cell landingCell1 = new Cell();
    Cell landingCell2 = new Cell();
    Cell landingCell3 = new Cell();
    TiledMapTile mockTile = Mockito.mock(TiledMapTile.class);
    MapProperties mapProperties = new MapProperties();
    mapProperties.put("landing", true);
    Mockito.when(mockTile.getProperties()).thenReturn(mapProperties);
    landingCell1.setTile(mockTile);
    nextCells.add(landingCell1);
    nextCells.add(landingCell2);
    nextCells.add(landingCell3);
    subject.detect(game, nextCells, mockPlayer, 100, 100);
    assertEquals("Mismatching game level", 2, game.getState().getLvl());
    Mockito.verify(mockPlayer).setX(Mockito.eq(0f));
    Mockito.verify(mockPlayer).setY(Mockito.eq(260f));
    Mockito.verify(mockSoundPlayer).playSound(Mockito.eq("data/sounds/Finish.wav"));
// assertEquals("Mismatching game score", 10, state.getScore());
}
Also used : ScreenManager(com.relic.highflyer.screens.ScreenManager) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Screen(com.badlogic.gdx.Screen) ArrayList(java.util.ArrayList) MapProperties(com.badlogic.gdx.maps.MapProperties) GameState(com.relic.highflyer.GameState) GameEngine(com.relic.highflyer.GameEngine) GameSettings(com.relic.highflyer.GameSettings) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell) Test(org.junit.Test)

Example 3 with ScreenManager

use of com.relic.highflyer.screens.ScreenManager in project high-flyer by sangngh.

the class PowerUpDetectorTest method testDetect_hasCollisionMulCells.

@Test
public void testDetect_hasCollisionMulCells() {
    GameState state = new GameState();
    state.setScore(100);
    typePower = "";
    GameEngine game = new GameEngine(new GameSettings(800, 600), state, new ScreenManager());
    List<Cell> nextCells = new ArrayList<>();
    Cell collisionCell1 = new Cell();
    Cell collisionCell2 = new Cell();
    Cell collisionCell3 = new Cell();
    TiledMapTile mockTile = Mockito.mock(TiledMapTile.class);
    TiledMapTile mockTile1 = Mockito.mock(TiledMapTile.class);
    MapProperties mapProperties = new MapProperties();
    mapProperties.put("nopower", "star");
    Mockito.when(mockTile.getProperties()).thenReturn(mapProperties);
    collisionCell1.setTile(mockTile);
    nextCells.add(collisionCell1);
    collisionCell2.setTile(mockTile);
    nextCells.add(collisionCell2);
    MapProperties mapProperties1 = new MapProperties();
    mapProperties1.put("power", "star");
    Mockito.when(mockTile.getProperties()).thenReturn(mapProperties1);
    collisionCell3.setTile(mockTile1);
    nextCells.add(collisionCell3);
    subject.detect(game, nextCells, mockPlayer, 100, 100);
    Mockito.verify(mockSoundPlayer).playSound(Mockito.eq("data/sounds/PowerUp.wav"));
    assertEquals("Mismatching game score", 110, state.getScore());
}
Also used : ScreenManager(com.relic.highflyer.screens.ScreenManager) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) ArrayList(java.util.ArrayList) MapProperties(com.badlogic.gdx.maps.MapProperties) GameState(com.relic.highflyer.GameState) GameEngine(com.relic.highflyer.GameEngine) GameSettings(com.relic.highflyer.GameSettings) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell) Test(org.junit.Test)

Example 4 with ScreenManager

use of com.relic.highflyer.screens.ScreenManager in project high-flyer by sangngh.

the class PowerUpDetectorTest method testDetect_hasCollision.

@Test
public void testDetect_hasCollision() {
    GameState state = new GameState();
    state.setScore(100);
    typePower = "";
    GameEngine game = new GameEngine(new GameSettings(800, 600), state, new ScreenManager());
    List<Cell> nextCells = new ArrayList<>();
    Cell collisionCell = new Cell();
    TiledMapTile mockTile = Mockito.mock(TiledMapTile.class);
    MapProperties mapProperties = new MapProperties();
    mapProperties.put("power", "star");
    Mockito.when(mockTile.getProperties()).thenReturn(mapProperties);
    collisionCell.setTile(mockTile);
    nextCells.add(collisionCell);
    subject.detect(game, nextCells, mockPlayer, 100, 100);
    Mockito.verify(mockSoundPlayer).playSound(Mockito.eq("data/sounds/PowerUp.wav"));
    assertEquals("Mismatching game score", 110, state.getScore());
}
Also used : ScreenManager(com.relic.highflyer.screens.ScreenManager) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) ArrayList(java.util.ArrayList) MapProperties(com.badlogic.gdx.maps.MapProperties) GameState(com.relic.highflyer.GameState) GameEngine(com.relic.highflyer.GameEngine) GameSettings(com.relic.highflyer.GameSettings) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell) Test(org.junit.Test)

Example 5 with ScreenManager

use of com.relic.highflyer.screens.ScreenManager in project high-flyer by sangngh.

the class LandingDetectorTest method testDetect_noLanding.

@Test
public void testDetect_noLanding() {
    GameState state = new GameState();
    GameEngine game = new GameEngine(new GameSettings(800, 600), state, new ScreenManager());
    Mockito.when(mockScreenManager.getScreen(Mockito.anyInt())).thenReturn(Mockito.mock(Screen.class));
    List<Cell> nextCells = new ArrayList<>();
    Cell landingCell = new Cell();
    TiledMapTile mockTile = Mockito.mock(TiledMapTile.class);
    MapProperties mapProperties = new MapProperties();
    mapProperties.put("notlanding", true);
    Mockito.when(mockTile.getProperties()).thenReturn(mapProperties);
    landingCell.setTile(mockTile);
    nextCells.add(landingCell);
    subject.detect(game, nextCells, mockPlayer, 100, 100);
    assertEquals("Mismatching game level", 1, game.getState().getLvl());
    Mockito.verifyZeroInteractions(mockSoundPlayer);
}
Also used : ScreenManager(com.relic.highflyer.screens.ScreenManager) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) Screen(com.badlogic.gdx.Screen) ArrayList(java.util.ArrayList) MapProperties(com.badlogic.gdx.maps.MapProperties) GameState(com.relic.highflyer.GameState) GameEngine(com.relic.highflyer.GameEngine) GameSettings(com.relic.highflyer.GameSettings) Cell(com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell) Test(org.junit.Test)

Aggregations

MapProperties (com.badlogic.gdx.maps.MapProperties)7 TiledMapTile (com.badlogic.gdx.maps.tiled.TiledMapTile)7 Cell (com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell)7 GameEngine (com.relic.highflyer.GameEngine)7 GameSettings (com.relic.highflyer.GameSettings)7 GameState (com.relic.highflyer.GameState)7 ScreenManager (com.relic.highflyer.screens.ScreenManager)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 Screen (com.badlogic.gdx.Screen)3