Added basic turret blob structures
This commit is contained in:
@@ -7,7 +7,7 @@ import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.defense.*;
|
||||
|
||||
public class DefenseBlocks extends BlockList implements ContentList{
|
||||
public static Block copperWall, copperWallLarge, compositeWall, compositeWallLarge, thoriumWall, thoriumWallLarge, door, doorLarge, deflectorwall, deflectorwalllarge,
|
||||
public static Block copperWall, copperWallLarge, compositeWall, compositeWallLarge, thoriumWall, thoriumWallLarge, door, doorLarge,
|
||||
phaseWall, phaseWallLarge, surgeWall, surgeWallLarge, mendProjector;
|
||||
|
||||
@Override
|
||||
@@ -41,15 +41,6 @@ public class DefenseBlocks extends BlockList implements ContentList{
|
||||
size = 2;
|
||||
}};
|
||||
|
||||
deflectorwall = new DeflectorWall("deflector-wall"){{
|
||||
health = 150 * wallHealthMultiplier;
|
||||
}};
|
||||
|
||||
deflectorwalllarge = new DeflectorWall("deflector-wall-large"){{
|
||||
health = 150 * 4 * wallHealthMultiplier;
|
||||
size = 2;
|
||||
}};
|
||||
|
||||
phaseWall = new DeflectorWall("phase-wall"){{
|
||||
health = 150 * wallHealthMultiplier;
|
||||
}};
|
||||
|
||||
@@ -522,7 +522,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
isBoosting = true;
|
||||
}
|
||||
|
||||
float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed;
|
||||
float speed = isBoosting && !mech.flying ? debug ? 5f : mech.boostSpeed : mech.speed;
|
||||
//fraction of speed when at max load
|
||||
float carrySlowdown = 0.7f;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.maps.generation;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Predicate;
|
||||
@@ -9,8 +10,18 @@ import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Edges;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.defense.Door;
|
||||
import io.anuke.mindustry.world.blocks.defense.Wall;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.ItemTurret;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.PowerTurret;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.Turret;
|
||||
import io.anuke.mindustry.world.blocks.power.PowerGenerator;
|
||||
import io.anuke.mindustry.world.blocks.power.SolarGenerator;
|
||||
import io.anuke.mindustry.world.blocks.production.Drill;
|
||||
import io.anuke.mindustry.world.consumers.ConsumePower;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class FortressGenerator{
|
||||
private final static int coreDst = 60;
|
||||
@@ -31,33 +42,96 @@ public class FortressGenerator{
|
||||
}
|
||||
|
||||
void gen(){
|
||||
gen.tiles[enemyX][enemyY].setBlock(StorageBlocks.core, team);
|
||||
Item[] acceptedItems = {Items.copper, Items.densealloy, Items.silicon, Items.thorium};
|
||||
gen.setBlock(enemyX, enemyY, StorageBlocks.core, team);
|
||||
|
||||
Array<Block> turrets = find(b -> (b instanceof ItemTurret && accepts(((ItemTurret) b).getAmmoTypes(), acceptedItems) || b instanceof PowerTurret));
|
||||
float difficultyScl = Mathf.clamp(gen.sector.difficulty / 25f + Mathf.range(1f/2f), 0f, 0.9999f);
|
||||
|
||||
Array<Block> turrets = find(b -> (b instanceof ItemTurret && accepts(((ItemTurret) b).getAmmoTypes(), Items.copper) || b instanceof PowerTurret));
|
||||
Array<Block> drills = find(b -> b instanceof Drill && !b.consumes.has(ConsumePower.class));
|
||||
Array<Block> gens = find(b -> b instanceof SolarGenerator);
|
||||
Array<Block> walls = find(b -> b instanceof Wall && !(b instanceof Door) && b.size == 1);
|
||||
|
||||
Block wall = walls.get((int)(difficultyScl * walls.size));
|
||||
Drill drill = (Drill) drills.get((int)(difficultyScl * drills.size));
|
||||
|
||||
//place down drills
|
||||
for(int x = 0; x < gen.width; x++){
|
||||
for(int y = 0; y < gen.height; y++){
|
||||
if(Vector2.dst(x, y, enemyX, enemyY) > coreDst){
|
||||
continue;
|
||||
}
|
||||
|
||||
Block turret = turrets.first();
|
||||
Item item = gen.drillItem(x, y, drill);
|
||||
|
||||
if(gen.random.chance(0.01) && gen.canPlace(x, y, turret)){
|
||||
if(item != null && item == Items.copper && gen.canPlace(x, y, drill)){
|
||||
gen.setBlock(x, y, drill, team);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Turret turret = (Turret) turrets.first();
|
||||
|
||||
//place down turrets
|
||||
for(int x = 0; x < gen.width; x++){
|
||||
for(int y = 0; y < gen.height; y++){
|
||||
if(Vector2.dst(x, y, enemyX, enemyY) > coreDst + 4 || !gen.canPlace(x, y, turret)){
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for(GridPoint2 point : Edges.getEdges(turret.size)){
|
||||
Tile tile = gen.tile(x + point.x, y + point.y);
|
||||
|
||||
if(tile != null){
|
||||
tile = tile.target();
|
||||
|
||||
if(turret instanceof PowerTurret && tile.target().block() instanceof PowerGenerator){
|
||||
found = true;
|
||||
break;
|
||||
}else if(turret instanceof ItemTurret && tile.block() instanceof Drill && accepts(((ItemTurret) turret).getAmmoTypes(), gen.drillItem(tile.x, tile.y, (Drill) tile.block()))){
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(found){
|
||||
gen.setBlock(x, y, turret, team);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//place down drills
|
||||
for(int x = 0; x < gen.width; x++){
|
||||
for(int y = 0; y < gen.height; y++){
|
||||
if(Vector2.dst(x, y, enemyX, enemyY) > coreDst || !gen.canPlace(x, y, wall)){
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
for(GridPoint2 point : Edges.getEdges(wall.size)){
|
||||
Tile tile = gen.tile(x + point.x, y + point.y);
|
||||
if(tile != null){
|
||||
tile = tile.target();
|
||||
if(tile.getTeamID() == team.ordinal() && !(tile.block() instanceof Wall)){
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(found){
|
||||
gen.setBlock(x, y, wall, team);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boolean accepts(AmmoType[] types, Item[] items){
|
||||
boolean accepts(AmmoType[] types, Item item){
|
||||
for(AmmoType type : types){
|
||||
for(Item item : items){
|
||||
if(type.item == item){
|
||||
return true;
|
||||
}
|
||||
if(type.item == item){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -23,6 +23,13 @@ public class Generation{
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
Tile tile(int x, int y){
|
||||
if(!Mathf.inBounds(x, y, tiles)){
|
||||
return null;
|
||||
}
|
||||
return tiles[x][y];
|
||||
}
|
||||
|
||||
//TODO implement
|
||||
Item drillItem(int x, int y, Drill block){
|
||||
if(block.isMultiblock()){
|
||||
|
||||
Reference in New Issue
Block a user