CannonShooter/core/src/de/samdev/cannonshooter/level/StandardLevel.java

107 lines
3.2 KiB
Java
Raw Normal View History

2015-08-29 12:18:10 +02:00
package de.samdev.cannonshooter.level;
2015-09-17 19:46:38 +02:00
import java.util.ArrayList;
import java.util.List;
2015-09-25 15:30:50 +02:00
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
2015-09-14 16:40:30 +02:00
import com.badlogic.gdx.math.Vector2;
2015-08-29 12:18:10 +02:00
import de.samdev.absgdx.framework.AgdxGame;
import de.samdev.absgdx.framework.layer.GameLayer;
import de.samdev.absgdx.framework.map.TileMap;
2015-09-17 15:35:24 +02:00
import de.samdev.absgdx.framework.map.background.RepeatingBackground;
2015-09-14 16:40:30 +02:00
import de.samdev.absgdx.framework.map.mapscaleresolver.ShowCompleteMapScaleResolver;
2016-01-09 00:48:17 +01:00
import de.samdev.absgdx.framework.menu.elements.MenuBaseElement;
2015-09-25 15:30:50 +02:00
import de.samdev.absgdx.framework.util.exceptions.AgdxmlParsingException;
2015-08-29 12:18:10 +02:00
import de.samdev.cannonshooter.Textures;
2015-09-14 16:40:30 +02:00
import de.samdev.cannonshooter.entities.Cannon;
2015-09-17 19:46:38 +02:00
import de.samdev.cannonshooter.teams.Team;
2015-09-18 18:37:16 +02:00
import de.samdev.cannonshooter.tiles.StandardTile;
2015-08-29 12:18:10 +02:00
public class StandardLevel extends GameLayer {
2015-09-17 19:46:38 +02:00
private List<Team> teams = new ArrayList<Team>();
public Team team_neutral = Team.GenerateTeamNeutral();
public Team team_player = Team.GenerateTeamPlayer();
private Team team_computer1 = new Team(10, Team.COL_P2, false, true, false, Team.MULTIPLIER_AI_D0);
private Team team_computer2 = new Team(11, Team.COL_P3, false, true, false, Team.MULTIPLIER_AI_D0);
private Team team_computer3 = new Team(12, Team.COL_P4, false, true, false, Team.MULTIPLIER_AI_D0);
2015-08-29 12:18:10 +02:00
public StandardLevel(AgdxGame owner) {
2015-09-20 14:36:56 +02:00
super(owner, TileMap.createEmptyMapUnsafe(70, 40, StandardTile.class));
2015-09-14 16:40:30 +02:00
2015-09-17 19:46:38 +02:00
initTeams();
initMap();
2015-09-23 19:49:55 +02:00
2016-01-09 00:48:17 +01:00
/*
2015-09-25 15:30:50 +02:00
try {
setHUDFromAgdxml(Gdx.files.internal("standard_hud.agdxml"), Textures.spritesheet, new BitmapFont(Gdx.files.internal("consolefont.fnt")));
} catch (AgdxmlParsingException e) {
throw new RuntimeException(e);
}
2016-01-09 00:48:17 +01:00
*/
2015-09-25 15:30:50 +02:00
//setTimeMultiplier(3);
2015-09-17 19:46:38 +02:00
}
2015-09-14 16:40:30 +02:00
2015-09-17 19:46:38 +02:00
private void initMap() {
addBackground(new RepeatingBackground(Textures.level_background, 1/32f));
2015-09-14 16:40:30 +02:00
setMapScaleResolver(new ShowCompleteMapScaleResolver());
2015-09-20 14:36:56 +02:00
addEntity(new Cannon(6, 25, team_player));
addEntity(new Cannon(36, 25, team_player));
2015-09-20 14:36:56 +02:00
addEntity(new Cannon(48, 6, team_computer1));
addEntity(new Cannon(60, 34, team_neutral));
2015-09-17 19:46:38 +02:00
}
private void initTeams() {
teams.add(team_neutral);
teams.add(team_player);
teams.add(team_computer1);
teams.add(team_computer2);
teams.add(team_computer3);
2015-09-14 16:40:30 +02:00
}
@Override
public void onResize() {
super.onResize();
// Center Map
2015-09-14 16:40:30 +02:00
setRawOffset(new Vector2(-(getVisibleMapBox().width - getMap().width)/2, -(getVisibleMapBox().height - getMap().height)/2));
2015-08-29 12:18:10 +02:00
}
@Override
public void onUpdate(float arg0) {
//
2015-08-29 12:18:10 +02:00
}
2016-01-09 00:48:17 +01:00
@SuppressWarnings("unused") // event listener
public void setSpeed_0(MenuBaseElement element, String identifier) {
setTimeMultiplier(1);
}
@SuppressWarnings("unused") // event listener
public void setSpeed_1(MenuBaseElement element, String identifier) {
setTimeMultiplier(1);
}
@SuppressWarnings("unused") // event listener
public void setSpeed_2(MenuBaseElement element, String identifier) {
setTimeMultiplier(2);
}
@SuppressWarnings("unused") // event listener
public void setSpeed_3(MenuBaseElement element, String identifier) {
setTimeMultiplier(3);
}
@SuppressWarnings("unused") // event listener
public void exitLevel(MenuBaseElement element, String identifier) {
Gdx.app.exit();
}
2015-08-29 12:18:10 +02:00
}