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

107 lines
3.2 KiB
Java

package de.samdev.cannonshooter.level;
import java.util.ArrayList;
import java.util.List;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.math.Vector2;
import de.samdev.absgdx.framework.AgdxGame;
import de.samdev.absgdx.framework.layer.GameLayer;
import de.samdev.absgdx.framework.map.TileMap;
import de.samdev.absgdx.framework.map.background.RepeatingBackground;
import de.samdev.absgdx.framework.map.mapscaleresolver.ShowCompleteMapScaleResolver;
import de.samdev.absgdx.framework.menu.elements.MenuBaseElement;
import de.samdev.absgdx.framework.util.exceptions.AgdxmlParsingException;
import de.samdev.cannonshooter.Textures;
import de.samdev.cannonshooter.entities.Cannon;
import de.samdev.cannonshooter.teams.Team;
import de.samdev.cannonshooter.tiles.StandardTile;
public class StandardLevel extends GameLayer {
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);
public StandardLevel(AgdxGame owner) {
super(owner, TileMap.createEmptyMapUnsafe(70, 40, StandardTile.class));
initTeams();
initMap();
/*
try {
setHUDFromAgdxml(Gdx.files.internal("standard_hud.agdxml"), Textures.spritesheet, new BitmapFont(Gdx.files.internal("consolefont.fnt")));
} catch (AgdxmlParsingException e) {
throw new RuntimeException(e);
}
*/
//setTimeMultiplier(3);
}
private void initMap() {
addBackground(new RepeatingBackground(Textures.level_background, 1/32f));
setMapScaleResolver(new ShowCompleteMapScaleResolver());
addEntity(new Cannon(6, 25, team_player));
addEntity(new Cannon(36, 25, team_player));
addEntity(new Cannon(48, 6, team_computer1));
addEntity(new Cannon(60, 34, team_neutral));
}
private void initTeams() {
teams.add(team_neutral);
teams.add(team_player);
teams.add(team_computer1);
teams.add(team_computer2);
teams.add(team_computer3);
}
@Override
public void onResize() {
super.onResize();
// Center Map
setRawOffset(new Vector2(-(getVisibleMapBox().width - getMap().width)/2, -(getVisibleMapBox().height - getMap().height)/2));
}
@Override
public void onUpdate(float arg0) {
//
}
@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();
}
}