Updated spawn lists, other minor fixes

This commit is contained in:
Anuken
2017-09-24 01:51:42 -04:00
parent 5f8e451750
commit 67b1fc4dbd
12 changed files with 204 additions and 190 deletions

View File

@@ -93,30 +93,46 @@ public class Control extends Module{
spawns = Array.with(
new EnemySpawn(Enemy.class){{
scaling = 2;
tierscaleback = 4;
}},
new EnemySpawn(FastEnemy.class){{
after = 2;
scaling = 3;
}},
new EnemySpawn(FlamerEnemy.class){{
after = 14;
spacing = 5;
scaling = 2;
}},
new EnemySpawn(BlastEnemy.class){{
after = 12;
spacing = 2;
scaling = 3;
}},
new EnemySpawn(RapidEnemy.class){{
after = 7;
spacing = 5;
}},
new EnemySpawn(TankEnemy.class){{
after = 4;
spacing = 2;
scaling = 3;
}},
new EnemySpawn(MortarEnemy.class){{
after = 20;
spacing = 3;
scaling = 5;
}}
);
printEnemies(100);
for(int i = 1; i < 60; i ++){
UCore.log("\n\n--WAVE " + i);
printEnemies(i);
}
}
public void reset(){
@@ -201,6 +217,7 @@ public class Control extends Module{
Constructor c = ClassReflection.getConstructor(spawn.type, int.class);
Enemy enemy = (Enemy)c.newInstance(fl);
enemy.set(tile.worldx(), tile.worldy());
enemy.tier = spawn.tier(wave, fl);
Effects.effect("spawn", enemy);
enemy.add();
@@ -231,7 +248,7 @@ public class Control extends Module{
int spawnamount = spawn.evaluate(wave, 0);
if(spawnamount > 0){
UCore.log(ClassReflection.getSimpleName(spawn.type) + " x" + spawnamount);
UCore.log(ClassReflection.getSimpleName(spawn.type) + " t" + spawn.tier(wave, 0) + " x" + spawnamount);
}
}
}
@@ -360,11 +377,13 @@ public class Control extends Module{
player.heal();
player.add();
Effects.sound("respawn");
ui.fadeRespawn(false);
}
}
if(enemies <= 0)
if(enemies <= 0){
wavetime -= delta();
}
if(wavetime <= 0 || (debug && Inputs.keyUp(Keys.F))){
runWave();

View File

@@ -9,7 +9,6 @@ import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.utils.Align;
@@ -23,7 +22,6 @@ import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.function.VisibilityProvider;
import io.anuke.ucore.graphics.Textures;
import io.anuke.ucore.modules.SceneModule;
import io.anuke.ucore.scene.actions.Actions;
import io.anuke.ucore.scene.builders.*;
@@ -32,7 +30,7 @@ import io.anuke.ucore.scene.ui.layout.*;
import io.anuke.ucore.util.Mathf;
public class UI extends SceneModule{
Table itemtable, weapontable, tools, loadingtable, desctable;
Table itemtable, weapontable, tools, loadingtable, desctable, respawntable;
SettingsDialog prefs;
KeybindDialog keys;
Dialog about, menu, restart, tutorial, levels, upgrades, load;
@@ -59,9 +57,6 @@ public class UI extends SceneModule{
Dialog.closePadR = -1;
Dialog.closePadT = 5;
Textures.load("sprites/");
Textures.repeatWrap("conveyort", Gdx.app.getType() == ApplicationType.WebGL ? "back-web" : "back", "background");
Colors.put("description", Color.WHITE);
Colors.put("turretinfo", Color.ORANGE);
Colors.put("missingitems", Color.SCARLET);
@@ -74,29 +69,11 @@ public class UI extends SceneModule{
Draw.color();
Texture back = Textures.get("background");
TextureRegion back = Draw.region("background");
float backscl = 5;
Draw.batch().draw(back, w/2 - back.getWidth()*backscl/2, h/2 - back.getHeight()*backscl/2,
back.getWidth()*backscl, back.getHeight()*backscl);
/*
Draw.color(Hue.lightness(0.6f));
int tw = w/64+1;
float scale = Unit.dp.inPixels(1f);
Texture texture = Textures.get(Gdx.app.getType() == ApplicationType.WebGL ? "back-web" : "back");
batch.draw(texture,
0, 0, w, h, 0, 0, (float)w/h/scale * h/texture.getHeight()/4f, -1f/scale * h/texture.getHeight()/4f);
for(int x = 0; x < tw; x ++){
float offset = (Timers.time()*2*(x%2-0.5f))/32f;
batch.draw(Textures.get("conveyort"), x*64*scale, 0, 32*scale, h*scale, 0, offset, 1, h/32 + offset);
}
*/
Draw.batch().draw(back, w/2 - back.getRegionWidth()*backscl/2, h/2 - back.getRegionHeight()*backscl/2,
back.getRegionWidth()*backscl, back.getRegionHeight()*backscl);
float logoscl = (int)Unit.dp.inPixels(7);
TextureRegion logo = skin.getRegion("logotext");
@@ -104,7 +81,6 @@ public class UI extends SceneModule{
float logoh = logo.getRegionHeight()*logoscl;
Draw.color();
//Draw.color(Color.CORAL);
Draw.batch().draw(logo, w/2 - logow/2, h - logoh + 15, logow, logoh);
Draw.color();
@@ -413,29 +389,27 @@ public class UI extends SceneModule{
}}.end();
}
new table("white"){{
respawntable = get();
respawntable.setColor(Color.CLEAR);
}}.end();
new table(){{
new table(){{
get().background("button");
new table("pane"){{
new label("Respawning in"){{
get().update(()->{
get().setText("[yellow]Respawning in " + (int)(control.getRespawnTime()/60));
});
get().setFontScale(0.75f);
}};
new label(()->"Respawning in " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10);
visible(()->{
return control.getRespawnTime() > 0 && !GameState.is(State.menu);
});
}};
visible(()->control.getRespawnTime() > 0 && !GameState.is(State.menu));
}}.end();
}}.end();
loadingtable = new table("loadDim"){{
new table("button"){{
new label("[yellow]Loading..."){{
new label("[orange]Loading..."){{
get().setName("namelabel");
}}.scale(1).pad(Unit.dp.inPixels(10));
}}.scale(2f*Vars.fontscale).pad(Unit.dp.inPixels(10));
}}.end();
}}.end().get();
@@ -469,6 +443,10 @@ public class UI extends SceneModule{
build.end();
}
public void fadeRespawn(boolean in){
respawntable.addAction(Actions.color(in ? new Color(0, 0, 0, 0.3f) : Color.CLEAR, 0.3f));
}
void updateRecipe(){
Recipe recipe = player.recipe;
desctable.clear();
@@ -557,7 +535,7 @@ public class UI extends SceneModule{
}
public void showLoading(){
showLoading("[yellow]Loading..");
showLoading("[orange]Loading..");
}
public void showLoading(String text){

View File

@@ -7,7 +7,6 @@ import io.anuke.mindustry.entities.Player;
import io.anuke.ucore.scene.ui.layout.Unit;
public class Vars{
//shorthand for whether or not this is running on android
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android);
//how far away from the player blocks can be placed

View File

@@ -1,22 +1,30 @@
package io.anuke.mindustry.entities;
import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.ucore.util.Mathf;
public class EnemySpawn{
public final Class<? extends Enemy> type;
int before = Integer.MAX_VALUE;
int after;
int spacing = 1;
float scaling = 9999f;
protected int before = Integer.MAX_VALUE;
protected int after;
protected int spacing = 1;
protected int tierscale = 15;
protected int tierscaleback = 1;
protected int max = 17;
protected float scaling = 9999f;
public EnemySpawn(Class<? extends Enemy> type){
this.type = type;
}
public int evaluate(int wave, int lane){
if(wave < after || wave > before || wave % spacing != 0){
if(wave < after || wave > before || (wave - after) % spacing != 0){
return 0;
}
return 1 * Math.max((int)((wave / spacing) / scaling), 1);
return Math.min(1 * Math.max((int)((wave / spacing) / scaling), 1) - (tier(wave, lane)-1) * tierscaleback, max);
}
public int tier(int wave, int lane){
return Mathf.clamp(1 + (wave-after)/tierscale, 1, Enemy.maxtier);
}
}

View File

@@ -38,6 +38,7 @@ public class Player extends DestructibleEntity{
Effects.sound("die", this);
Vars.control.setRespawnTime(respawnduration);
ui.fadeRespawn(true);
}
@Override

View File

@@ -19,7 +19,8 @@ import io.anuke.ucore.entities.*;
import io.anuke.ucore.util.Mathf;
public class Enemy extends DestructibleEntity{
public final static Color[] tierColors = {Color.YELLOW, Color.MAGENTA, Color.RED};
public final static Color[] tierColors = {Color.YELLOW, Color.ORANGE, Color.RED, Color.MAGENTA};
public final static int maxtier = 4;
protected float speed = 0.3f;
protected float reload = 40;
@@ -38,7 +39,7 @@ public class Enemy extends DestructibleEntity{
public Vector2 direction = new Vector2();
public float xvelocity, yvelocity;
public Entity target;
public int tier = Mathf.random(1, 3);
public int tier = 1;
public Enemy(int spawn){
@@ -64,11 +65,11 @@ public class Enemy extends DestructibleEntity{
target = World.findTileTarget(x, y, null, range, false);
//no tile found
if(target == null)
if(target == null){
target = Entities.getClosest(x, y, range, e->{
return e instanceof Player;
});
}
}
if(target != null && bullet != null){
@@ -162,8 +163,9 @@ public class Enemy extends DestructibleEntity{
public void draw(){
Draw.color();
String region = ClassReflection.getSimpleName(getClass()).toLowerCase() + "-t" + tier;
String region = ClassReflection.getSimpleName(getClass()).toLowerCase() + "-t" + Mathf.clamp(tier, 1, 3);
//TODO is this necessary?
Draw.getShader(Outline.class).color.set(tierColors[tier-1]);
Draw.getShader(Outline.class).region = Draw.region(region);