mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-13 17:27:35 +07:00
Changed spawn system
This commit is contained in:
@ -2,4 +2,5 @@
|
|||||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://raw.githubusercontent.com/gwtproject/gwt/master/distro-source/core/src/gwt-module.dtd">
|
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://raw.githubusercontent.com/gwtproject/gwt/master/distro-source/core/src/gwt-module.dtd">
|
||||||
<module>
|
<module>
|
||||||
<source path="io/anuke/mindustry" />
|
<source path="io/anuke/mindustry" />
|
||||||
|
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.enemies" />
|
||||||
</module>
|
</module>
|
@ -7,11 +7,14 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.input.GestureDetector;
|
import com.badlogic.gdx.input.GestureDetector;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||||
|
|
||||||
import io.anuke.mindustry.GameState.State;
|
import io.anuke.mindustry.GameState.State;
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
import io.anuke.mindustry.ai.Pathfind;
|
||||||
|
import io.anuke.mindustry.entities.EnemySpawn;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.enemies.*;
|
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||||
|
import io.anuke.mindustry.entities.enemies.TestEnemy;
|
||||||
import io.anuke.mindustry.input.AndroidInput;
|
import io.anuke.mindustry.input.AndroidInput;
|
||||||
import io.anuke.mindustry.input.GestureHandler;
|
import io.anuke.mindustry.input.GestureHandler;
|
||||||
import io.anuke.mindustry.input.Input;
|
import io.anuke.mindustry.input.Input;
|
||||||
@ -36,6 +39,7 @@ public class Control extends ControlModule{
|
|||||||
|
|
||||||
final Array<Weapon> weapons = new Array<>();
|
final Array<Weapon> weapons = new Array<>();
|
||||||
|
|
||||||
|
Array<EnemySpawn> spawns = new Array<>();
|
||||||
int wave = 1;
|
int wave = 1;
|
||||||
float wavetime;
|
float wavetime;
|
||||||
int enemies = 0;
|
int enemies = 0;
|
||||||
@ -165,38 +169,31 @@ public class Control extends ControlModule{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void runWave(){
|
void runWave(){
|
||||||
int amount = wave;
|
|
||||||
Sounds.play("spawn");
|
Sounds.play("spawn");
|
||||||
|
|
||||||
Pathfind.updatePath();
|
Pathfind.updatePath();
|
||||||
|
|
||||||
for(int i = 0; i < amount; i ++){
|
for(EnemySpawn spawn : spawns){
|
||||||
int pos = i;
|
for(int lane = 0; lane < World.spawnpoints.size; lane ++){
|
||||||
|
Tile tile = World.spawnpoints.get(lane);
|
||||||
|
int spawnamount = spawn.evaluate(wave, lane);
|
||||||
|
|
||||||
for(int w = 0; w < World.spawnpoints.size; w ++){
|
for(int i = 0; i < spawnamount; i ++){
|
||||||
int point = w;
|
int index = i;
|
||||||
Tile tile = World.spawnpoints.get(w);
|
|
||||||
|
|
||||||
Timers.run(i*30f, ()->{
|
|
||||||
|
|
||||||
Enemy enemy = null;
|
|
||||||
|
|
||||||
if(wave%5 == 0 & pos < wave/5){
|
|
||||||
enemy = new BossEnemy(point);
|
|
||||||
}else if(wave > 3 && pos < amount/2){
|
|
||||||
enemy = new FastEnemy(point);
|
|
||||||
}else if(wave > 8 && pos % 3 == 0 && wave%2==1){
|
|
||||||
enemy = new FlameEnemy(point);
|
|
||||||
}else{
|
|
||||||
enemy = new Enemy(point);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Timers.run(index*30f, ()->{
|
||||||
|
try{
|
||||||
|
Enemy enemy = (Enemy)ClassReflection.newInstance(spawn.type);
|
||||||
enemy.set(tile.worldx(), tile.worldy());
|
enemy.set(tile.worldx(), tile.worldy());
|
||||||
Effects.effect("spawn", enemy);
|
Effects.effect("spawn", enemy);
|
||||||
enemy.add();
|
enemy.add();
|
||||||
});
|
|
||||||
|
|
||||||
enemies ++;
|
enemies ++;
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
core/src/io/anuke/mindustry/entities/EnemySpawn.java
Normal file
18
core/src/io/anuke/mindustry/entities/EnemySpawn.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package io.anuke.mindustry.entities;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||||
|
|
||||||
|
public class EnemySpawn{
|
||||||
|
public final Class<? extends Enemy> type;
|
||||||
|
int before = Integer.MAX_VALUE;
|
||||||
|
int after;
|
||||||
|
int spacing;
|
||||||
|
|
||||||
|
public EnemySpawn(Class<? extends Enemy> type){
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int evaluate(int wave, int lane){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@ -48,8 +48,6 @@ public enum Recipe{
|
|||||||
liquidrouter(distribution, ProductionBlocks.liquidrouter, stack(Item.steel, 5)),
|
liquidrouter(distribution, ProductionBlocks.liquidrouter, stack(Item.steel, 5)),
|
||||||
pump(production, ProductionBlocks.pump, stack(Item.steel, 20));
|
pump(production, ProductionBlocks.pump, stack(Item.steel, 20));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Block result;
|
public Block result;
|
||||||
public ItemStack[] requirements;
|
public ItemStack[] requirements;
|
||||||
public Section section;
|
public Section section;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types;
|
package io.anuke.mindustry.world.blocks.types;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
|
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
@ -42,7 +41,9 @@ public class LiquidRouter extends Conduit{
|
|||||||
ConduitEntity entity = tile.entity();
|
ConduitEntity entity = tile.entity();
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy());
|
Draw.rect(name(), tile.worldx(), tile.worldy());
|
||||||
|
|
||||||
Draw.color(Color.ROYAL);
|
if(entity.liquid == null) return;
|
||||||
|
|
||||||
|
Draw.color(entity.liquid.color);
|
||||||
Draw.alpha(entity.liquidAmount / liquidCapacity);
|
Draw.alpha(entity.liquidAmount / liquidCapacity);
|
||||||
Draw.rect("blank", tile.worldx(), tile.worldy(), 2, 2);
|
Draw.rect("blank", tile.worldx(), tile.worldy(), 2, 2);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
@ -32,7 +32,9 @@ public class Purifier extends Conduit{
|
|||||||
ConduitEntity entity = tile.entity();
|
ConduitEntity entity = tile.entity();
|
||||||
Draw.rect(name(), tile.worldx(), tile.worldy());
|
Draw.rect(name(), tile.worldx(), tile.worldy());
|
||||||
|
|
||||||
Draw.color(Color.ROYAL);
|
if(entity.liquid == null) return;
|
||||||
|
|
||||||
|
Draw.color(entity.liquid.color);
|
||||||
Draw.alpha(entity.liquidAmount / liquidCapacity);
|
Draw.alpha(entity.liquidAmount / liquidCapacity);
|
||||||
Draw.rect("blank", tile.worldx(), tile.worldy(), 2, 2);
|
Draw.rect("blank", tile.worldx(), tile.worldy(), 2, 2);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
Reference in New Issue
Block a user