Added battle misson / Team block colors / Mission worldgen
This commit is contained in:
@@ -4,8 +4,8 @@ import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
import io.anuke.mindustry.maps.goals.Goal;
|
||||
import io.anuke.mindustry.maps.goals.WaveGoal;
|
||||
import io.anuke.mindustry.maps.goals.Mission;
|
||||
import io.anuke.mindustry.maps.goals.WaveMission;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
@@ -21,11 +21,15 @@ public class Sector{
|
||||
public int size = 1;
|
||||
/**Display texture. Needs to be disposed.*/
|
||||
public transient Texture texture;
|
||||
/**Goal of this sector-- what needs to be accomplished to unlock it.*/
|
||||
public transient Goal goal = new WaveGoal(30);
|
||||
/**Mission of this sector-- what needs to be accomplished to unlock it.*/
|
||||
public transient Mission mission = new WaveMission(30);
|
||||
/**Enemies spawned at this sector.*/
|
||||
public transient Array<SpawnGroup> spawns = new Array<>();
|
||||
|
||||
public int getSeed(){
|
||||
return Bits.packInt(x, y);
|
||||
}
|
||||
|
||||
public SaveSlot getSave(){
|
||||
return control.getSaves().getByID(saveID);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.maps.goals.BattleMission;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.Edges;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
@@ -75,6 +76,7 @@ public class Sectors{
|
||||
sector.y = (short)y;
|
||||
sector.complete = false;
|
||||
sector.size = isLarge ? 2 : 1;
|
||||
initSector(sector);
|
||||
|
||||
for(int cx = 0; cx < sector.size; cx++){
|
||||
for(int cy = 0; cy < sector.size; cy++){
|
||||
@@ -90,6 +92,7 @@ public class Sectors{
|
||||
|
||||
for(Sector sector : out){
|
||||
createTexture(sector);
|
||||
initSector(sector);
|
||||
for(int cx = 0; cx < sector.size; cx++){
|
||||
for(int cy = 0; cy < sector.size; cy++){
|
||||
grid.put(sector.x + cx, sector.y + cy, sector);
|
||||
@@ -113,6 +116,10 @@ public class Sectors{
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
private void initSector(Sector sector){
|
||||
sector.mission = new BattleMission();
|
||||
}
|
||||
|
||||
private int round2(int i){
|
||||
if(i < 0){
|
||||
i --;
|
||||
|
||||
@@ -11,6 +11,7 @@ import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.MapTileData;
|
||||
import io.anuke.mindustry.maps.MapTileData.TileDataMarker;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -18,7 +19,6 @@ import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.noise.RidgedPerlin;
|
||||
import io.anuke.ucore.noise.Simplex;
|
||||
import io.anuke.ucore.noise.VoronoiNoise;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.SeedRandom;
|
||||
@@ -167,14 +167,13 @@ public class WorldGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
public void generateMap(Tile[][] tiles, int sectorX, int sectorY){
|
||||
public void generateMap(Tile[][] tiles, Sector sector){
|
||||
int width = tiles.length, height = tiles[0].length;
|
||||
long seed = Bits.packLong(sectorX, sectorY);
|
||||
SeedRandom rnd = new SeedRandom(seed);
|
||||
SeedRandom rnd = new SeedRandom(sector.getSeed());
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
GenResult result = generateTile(sectorX, sectorY, x, y);
|
||||
GenResult result = generateTile(sector.x, sector.y, x, y);
|
||||
Tile tile = new Tile(x, y, (byte)result.floor.id, (byte)result.wall.id, (byte)0, (byte)0, result.elevation);
|
||||
tiles[x][y] = tile;
|
||||
}
|
||||
@@ -204,7 +203,9 @@ public class WorldGenerator{
|
||||
tiles[coreX][coreY].setBlock(StorageBlocks.core);
|
||||
tiles[coreX][coreY].setTeam(Team.blue);
|
||||
|
||||
prepareTiles(tiles, seed, true);
|
||||
sector.mission.generate(tiles, sector);
|
||||
|
||||
prepareTiles(tiles, sector.getSeed(), true);
|
||||
}
|
||||
|
||||
public GenResult generateTile(int sectorX, int sectorY, int localX, int localY){
|
||||
|
||||
26
core/src/io/anuke/mindustry/maps/goals/BattleMission.java
Normal file
26
core/src/io/anuke/mindustry/maps/goals/BattleMission.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package io.anuke.mindustry.maps.goals;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class BattleMission implements Mission{
|
||||
|
||||
@Override
|
||||
public void generate(Tile[][] tiles, Sector sector){
|
||||
int x = Mathf.randomSeed(sector.getSeed(), 1, tiles.length - 2);
|
||||
int y = Mathf.randomSeed(sector.getSeed(), 1, tiles[0].length - 2);
|
||||
|
||||
tiles[x][y].setBlock(StorageBlocks.core);
|
||||
tiles[x][y].setTeam(Team.red);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
//TODO check all enemy teams, not just the first
|
||||
return Vars.state.teams.getTeams(false).first().cores.size == 0;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package io.anuke.mindustry.maps.goals;
|
||||
|
||||
public interface Goal{
|
||||
boolean isComplete();
|
||||
}
|
||||
10
core/src/io/anuke/mindustry/maps/goals/Mission.java
Normal file
10
core/src/io/anuke/mindustry/maps/goals/Mission.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package io.anuke.mindustry.maps.goals;
|
||||
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public interface Mission{
|
||||
boolean isComplete();
|
||||
|
||||
default void generate(Tile[][] tiles, Sector sector){}
|
||||
}
|
||||
@@ -2,10 +2,10 @@ package io.anuke.mindustry.maps.goals;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class WaveGoal implements Goal{
|
||||
public class WaveMission implements Mission{
|
||||
private final int target;
|
||||
|
||||
public WaveGoal(int target){
|
||||
public WaveMission(int target){
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user