mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 11:29:48 +07:00
Added basic enemy outposts
This commit is contained in:
parent
4e681b2dd1
commit
1dd6e66167
@ -95,6 +95,7 @@ public class NetServer extends Module{
|
||||
TraceInfo trace = admins.getTraceByID(uuid);
|
||||
PlayerInfo info = admins.getInfo(uuid);
|
||||
trace.uuid = uuid;
|
||||
trace.ip = connection.address;
|
||||
trace.android = packet.mobile;
|
||||
|
||||
if(admins.isIDBanned(uuid)){
|
||||
@ -224,6 +225,7 @@ public class NetServer extends Module{
|
||||
}else if(Vector2.dst(packet.x, packet.y, newx, newy) > correctDist){
|
||||
Call.onPositionSet(id, newx, newy); //teleport and correct position when necessary
|
||||
}
|
||||
|
||||
//reset player to previous synced position so it gets interpolated
|
||||
player.x = prevx;
|
||||
player.y = prevy;
|
||||
|
@ -547,7 +547,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
velocity.add(movement);
|
||||
}
|
||||
float prex = x, prey = y;
|
||||
updateVelocityStatus(mech.drag, mech.maxSpeed);
|
||||
updateVelocityStatus(mech.drag, debug ? 10f : mech.maxSpeed);
|
||||
moved = distanceTo(prex, prey) > 0.01f;
|
||||
}else{
|
||||
velocity.setZero();
|
||||
|
@ -9,6 +9,7 @@ import io.anuke.mindustry.content.Items;
|
||||
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.missions.BattleMission;
|
||||
import io.anuke.mindustry.maps.missions.WaveMission;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.Edges;
|
||||
@ -132,12 +133,13 @@ public class Sectors{
|
||||
}
|
||||
|
||||
private void initSector(Sector sector){
|
||||
sector.difficulty = (int)(Mathf.dst(sector.x, sector.y)/2);
|
||||
sector.difficulty = (int)(Mathf.dst(sector.x, sector.y));
|
||||
|
||||
if(sector.difficulty == 0){
|
||||
sector.missions.add(new WaveMission(10));
|
||||
}else{
|
||||
sector.missions.add(new WaveMission(Math.min(10 + sector.difficulty*5 + Mathf.randomSeed(sector.getSeed(), 0, 5)*5, 100)));
|
||||
sector.missions.add(new BattleMission());
|
||||
//sector.missions.add(new WaveMission(Math.min(10 + sector.difficulty*5 + Mathf.randomSeed(sector.getSeed(), 0, 5)*5, 100)));
|
||||
}
|
||||
|
||||
//add all ores for now since material differences aren't well handled yet
|
||||
|
@ -0,0 +1,68 @@
|
||||
package io.anuke.mindustry.maps.generation;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.content.blocks.DefenseBlocks;
|
||||
import io.anuke.mindustry.content.blocks.ProductionBlocks;
|
||||
import io.anuke.mindustry.content.blocks.TurretBlocks;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
|
||||
public class FortressGenerator{
|
||||
private final Block[] turretBlocks = {TurretBlocks.duo, TurretBlocks.hail, TurretBlocks.wave};
|
||||
private final Block[] drillBlocks = {ProductionBlocks.tungstenDrill, ProductionBlocks.carbideDrill};
|
||||
private final Block[] armorBlocks = {DefenseBlocks.tungstenWall, DefenseBlocks.carbideWall, DefenseBlocks.thoriumWall};
|
||||
private final int minCoreDst = 30;
|
||||
|
||||
private int enemyX, enemyY, coreX, coreY;
|
||||
private Team team;
|
||||
private Generation gen;
|
||||
|
||||
public void generate(Generation gen, Team team, int coreX, int coreY, int enemyX, int enemyY){
|
||||
this.enemyX = enemyX;
|
||||
this.enemyY = enemyY;
|
||||
this.coreX = coreX;
|
||||
this.coreY = coreY;
|
||||
this.gen = gen;
|
||||
this.team = team;
|
||||
|
||||
genOutposts();
|
||||
}
|
||||
|
||||
void genOutposts(){
|
||||
int index = 0;
|
||||
Block turret = turretBlocks[index], drill = drillBlocks[index], armor = armorBlocks[index];
|
||||
Item ore = Items.tungsten;
|
||||
|
||||
for(int x = 2; x < gen.width - 2; x++){
|
||||
for(int y = 2; y < gen.height - 2; y++){
|
||||
if(Vector2.dst(x, y, coreX, coreY) > minCoreDst &&
|
||||
gen.tiles[x][y].floor().dropsItem(ore) && gen.random.chance(0.03)){
|
||||
|
||||
int elevation = gen.tiles[x][y].getElevation();
|
||||
gen.tiles[x][y].setBlock(drill, team);
|
||||
|
||||
for(GridPoint2 point : Geometry.d4){
|
||||
gen.tiles[x + point.x][y + point.y].setBlock(turret, team);
|
||||
gen.tiles[x + point.x][y + point.y].setElevation(elevation);
|
||||
}
|
||||
|
||||
for(int cx = -2; cx <= 2; cx++){
|
||||
for(int cy = -2; cy <= 2; cy++){
|
||||
Tile tile = gen.tiles[x + cx][y + cy];
|
||||
if(tile.block().alwaysReplace || tile.block() == Blocks.air){
|
||||
tile.setElevation(elevation);
|
||||
tile.setBlock(armor, team);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
package io.anuke.mindustry.maps.generation;
|
||||
|
||||
public class GenProperties{
|
||||
public long seed;
|
||||
public MapStyle maps;
|
||||
public OreStyle ores;
|
||||
public RiverType riverType;
|
||||
public RiverStyle rivers;
|
||||
public TerrainStyle terrains;
|
||||
public FoliageStyle foliage;
|
||||
public EnvironmentStyle environment;
|
||||
|
||||
enum MapStyle{
|
||||
/**
|
||||
* 256x512
|
||||
*/
|
||||
longY,
|
||||
/**
|
||||
* 128x256
|
||||
*/
|
||||
smallY,
|
||||
/**
|
||||
* 128x128
|
||||
*/
|
||||
small,
|
||||
/**
|
||||
* 256x256
|
||||
*/
|
||||
normal
|
||||
}
|
||||
|
||||
enum OreStyle{
|
||||
/**
|
||||
* 'vanilla' noise-distributed ores
|
||||
*/
|
||||
normal,
|
||||
/**
|
||||
* ores hug the walls
|
||||
*/
|
||||
nearWalls,
|
||||
/**
|
||||
* ores hug all liquid rivers
|
||||
*/
|
||||
nearRivers,
|
||||
/**
|
||||
* large veins
|
||||
*/
|
||||
largeVeins
|
||||
}
|
||||
|
||||
enum RiverType{
|
||||
lava,
|
||||
water,
|
||||
oil,
|
||||
none
|
||||
}
|
||||
|
||||
enum RiverStyle{
|
||||
/**
|
||||
* long thin river spanning entire map
|
||||
*/
|
||||
longThin,
|
||||
/**
|
||||
* long river branching into many others
|
||||
*/
|
||||
longBranch,
|
||||
/**
|
||||
* one long, thick river
|
||||
*/
|
||||
longThick,
|
||||
/**
|
||||
* short, thick river that ends in a lake
|
||||
*/
|
||||
shortLake
|
||||
}
|
||||
|
||||
enum TerrainStyle{
|
||||
/**
|
||||
* bordered around by the normal material
|
||||
*/
|
||||
normal,
|
||||
/**
|
||||
* everything is islands
|
||||
*/
|
||||
waterIslands,
|
||||
/**
|
||||
* everything is islands: lava edition
|
||||
*/
|
||||
lavaIslands
|
||||
}
|
||||
|
||||
enum FoliageStyle{
|
||||
patches,
|
||||
veins,
|
||||
blobs,
|
||||
ridges
|
||||
}
|
||||
|
||||
enum FoilageType{
|
||||
grass,
|
||||
sand,
|
||||
darkStone,
|
||||
ice,
|
||||
}
|
||||
|
||||
enum EnvironmentStyle{
|
||||
desert,
|
||||
stoneDesert,
|
||||
grassy,
|
||||
dark,
|
||||
darkStone,
|
||||
stone,
|
||||
icy,
|
||||
}
|
||||
}
|
20
core/src/io/anuke/mindustry/maps/generation/Generation.java
Normal file
20
core/src/io/anuke/mindustry/maps/generation/Generation.java
Normal file
@ -0,0 +1,20 @@
|
||||
package io.anuke.mindustry.maps.generation;
|
||||
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.util.SeedRandom;
|
||||
|
||||
public class Generation{
|
||||
public final Sector sector;
|
||||
public final Tile[][] tiles;
|
||||
public final int width, height;
|
||||
public final SeedRandom random;
|
||||
|
||||
public Generation(Sector sector, Tile[][] tiles, int width, int height, SeedRandom random){
|
||||
this.sector = sector;
|
||||
this.tiles = tiles;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.random = random;
|
||||
}
|
||||
}
|
@ -66,10 +66,12 @@ public class WorldGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
prepareTiles(tiles, seed, genOres, null);
|
||||
prepareTiles(tiles);
|
||||
|
||||
generateOres(tiles, seed, genOres, null);
|
||||
}
|
||||
|
||||
public void prepareTiles(Tile[][] tiles, long seed, boolean genOres, Array<Item> usedOres){
|
||||
public void prepareTiles(Tile[][] tiles){
|
||||
|
||||
//find multiblocks
|
||||
IntArray multiblocks = new IntArray();
|
||||
@ -132,16 +134,18 @@ public class WorldGenerator{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void generateOres(Tile[][] tiles, long seed, boolean genOres, Array<Item> usedOres){
|
||||
oreIndex = 0;
|
||||
|
||||
if(genOres){
|
||||
Array<OreEntry> baseOres = Array.with(
|
||||
new OreEntry(Items.tungsten, 0.3f, seed),
|
||||
new OreEntry(Items.coal, 0.284f, seed),
|
||||
new OreEntry(Items.lead, 0.28f, seed),
|
||||
new OreEntry(Items.titanium, 0.27f, seed),
|
||||
new OreEntry(Items.thorium, 0.26f, seed)
|
||||
new OreEntry(Items.tungsten, 0.3f, seed),
|
||||
new OreEntry(Items.coal, 0.284f, seed),
|
||||
new OreEntry(Items.lead, 0.28f, seed),
|
||||
new OreEntry(Items.titanium, 0.27f, seed),
|
||||
new OreEntry(Items.thorium, 0.26f, seed)
|
||||
);
|
||||
|
||||
Array<OreEntry> ores = new Array<>();
|
||||
@ -165,8 +169,8 @@ public class WorldGenerator{
|
||||
for(int i = ores.size - 1; i >= 0; i--){
|
||||
OreEntry entry = ores.get(i);
|
||||
if(entry.noise.octaveNoise2D(1, 0.7, 1f / (4 + i * 2), x, y) / 4f +
|
||||
Math.abs(0.5f - entry.noise.octaveNoise2D(2, 0.7, 1f / (50 + i * 2), x, y)) > 0.48f &&
|
||||
Math.abs(0.5f - entry.noise.octaveNoise2D(1, 1, 1f / (55 + i * 4), x, y)) > 0.22f){
|
||||
Math.abs(0.5f - entry.noise.octaveNoise2D(2, 0.7, 1f / (50 + i * 2), x, y)) > 0.48f &&
|
||||
Math.abs(0.5f - entry.noise.octaveNoise2D(1, 1, 1f / (55 + i * 4), x, y)) > 0.22f){
|
||||
tile.setFloor((Floor) OreBlocks.get(tile.floor(), entry.item));
|
||||
break;
|
||||
}
|
||||
@ -207,11 +211,15 @@ public class WorldGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
generateOres(tiles, sector.getSeed(), true, sector.ores);
|
||||
|
||||
Generation gen = new Generation(sector, tiles, tiles.length, tiles[0].length, random);
|
||||
|
||||
for(Mission mission : sector.missions){
|
||||
mission.generate(tiles, sector);
|
||||
mission.generate(gen);
|
||||
}
|
||||
|
||||
prepareTiles(tiles, sector.getSeed(), true, sector.ores);
|
||||
prepareTiles(tiles);
|
||||
}
|
||||
|
||||
public GenResult generateTile(int sectorX, int sectorY, int localX, int localY){
|
||||
|
@ -3,16 +3,16 @@ package io.anuke.mindustry.maps.missions;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.maps.generation.FortressGenerator;
|
||||
import io.anuke.mindustry.maps.generation.Generation;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class BattleMission implements Mission{
|
||||
private final int difficulty;
|
||||
private final static int coreX = 60, coreY = 60;
|
||||
|
||||
public BattleMission(){
|
||||
|
||||
public BattleMission(int difficulty){
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,9 +31,13 @@ public class BattleMission implements Mission{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Tile[][] tiles, Sector sector){
|
||||
generateCoreAt(tiles, 60, 60, Team.blue);
|
||||
generateCoreAt(tiles, tiles.length-1-60, tiles[0].length-1-60, Team.red);
|
||||
public void generate(Generation gen){
|
||||
int enemyX = gen.width-1-coreX, enemyY = gen.height-1-coreX;
|
||||
|
||||
generateCoreAt(gen, coreX, coreY, Team.blue);
|
||||
generateCoreAt(gen, enemyX, enemyY, Team.red);
|
||||
|
||||
new FortressGenerator().generate(gen, Team.red, coreX, coreY, enemyX, enemyY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,8 +5,7 @@ import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.maps.generation.Generation;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.noise.Noise;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
@ -18,33 +17,33 @@ public interface Mission{
|
||||
GameMode getMode();
|
||||
void display(Table table);
|
||||
|
||||
default void generate(Tile[][] tiles, Sector sector){}
|
||||
default void generate(Generation gen){}
|
||||
|
||||
default void generateCoreAt(Tile[][] tiles, int coreX, int coreY, Team team){
|
||||
default void generateCoreAt(Generation gen, int coreX, int coreY, Team team){
|
||||
Noise.setSeed(0);
|
||||
float targetElevation = Math.max(tiles[coreX][coreY].getElevation(), 1);
|
||||
float targetElevation = Math.max(gen.tiles[coreX][coreY].getElevation(), 1);
|
||||
|
||||
int lerpDst = 20;
|
||||
for(int x = -lerpDst; x <= lerpDst; x++){
|
||||
for(int y = -lerpDst; y <= lerpDst; y++){
|
||||
int wx = tiles.length/2 + x, wy = tiles[0].length/2 + y;
|
||||
int wx = gen.width/2 + x, wy = gen.height/2 + y;
|
||||
|
||||
float dst = Vector2.dst(wx, wy, coreX, coreY);
|
||||
float elevation = tiles[wx][wy].getElevation();
|
||||
float elevation = gen.tiles[wx][wy].getElevation();
|
||||
|
||||
if(dst < lerpDst){
|
||||
elevation = Mathf.lerp(elevation, targetElevation, Mathf.clamp(2*(1f-(dst / lerpDst))) + Noise.nnoise(wx, wy, 8f, 1f));
|
||||
}
|
||||
|
||||
if(tiles[wx][wy].floor().liquidDrop == null){
|
||||
tiles[wx][wy].setElevation((int) elevation);
|
||||
if(gen.tiles[wx][wy].floor().liquidDrop == null){
|
||||
gen.tiles[wx][wy].setElevation((int) elevation);
|
||||
}else{
|
||||
tiles[wx][wy].setFloor((Floor) Blocks.sand);
|
||||
gen.tiles[wx][wy].setFloor((Floor) Blocks.sand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tiles[coreX][coreY].setBlock(StorageBlocks.core);
|
||||
tiles[coreX][coreY].setTeam(team);
|
||||
gen.tiles[coreX][coreY].setBlock(StorageBlocks.core);
|
||||
gen.tiles[coreX][coreY].setTeam(team);
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,7 @@ package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.maps.generation.Generation;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
@ -17,9 +16,9 @@ public class WaveMission implements Mission{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Tile[][] tiles, Sector sector){
|
||||
int coreX = tiles.length/2, coreY = tiles.length/2;
|
||||
generateCoreAt(tiles, coreX, coreY, Team.blue);
|
||||
public void generate(Generation gen){
|
||||
int coreX = gen.width/2, coreY = gen.height/2;
|
||||
generateCoreAt(gen, coreX, coreY, Team.blue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,7 @@ public class TraceInfo{
|
||||
|
||||
public String uuid;
|
||||
|
||||
public TraceInfo(String ip){
|
||||
this.ip = ip;
|
||||
public TraceInfo(String uuid){
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +161,10 @@ public class Block extends BaseBlock implements Content{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean dropsItem(Item item){
|
||||
return drops != null && drops.item == item;
|
||||
}
|
||||
|
||||
public boolean isLayer(Tile tile){
|
||||
return true;
|
||||
}
|
||||
|
@ -165,6 +165,11 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlock(Block type, Team team){
|
||||
setBlock(type);
|
||||
setTeam(team);
|
||||
}
|
||||
|
||||
public void setBlock(Block type){
|
||||
synchronized(tileSetLock){
|
||||
preChanged();
|
||||
|
Loading…
Reference in New Issue
Block a user