Added basic enemy spawning, fixed turret base sprite, input place lag

This commit is contained in:
Anuken 2018-05-21 15:03:34 -04:00
parent 4a250b4e27
commit 5602cb8920
15 changed files with 515 additions and 517 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 383 B

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 496 B

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 319 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 107 KiB

View File

@ -65,8 +65,7 @@ io.anuke.ucore.scene.ui.ImageButton$ImageButtonStyle: {
static-down: {up: button-down },
toggle: {checked: button-down, down: button-down, up: button, imageDisabledColor: lightgray, imageUpColor: white },
togglemap: {down: button-map-down, up: button-map },
select: {checked: button-select, up: clear },
close-window: {up: button, imageUp: icon-close, imageOver: icon-close-over, imageDown: icon-close-down, disabled: button }
select: {checked: button-select, up: clear }
},
io.anuke.ucore.scene.ui.ScrollPane$ScrollPaneStyle: {
default: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical},

View File

@ -1,8 +1,11 @@
package io.anuke.mindustry.core;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.content.AmmoTypes;
import io.anuke.mindustry.content.UnitTypes;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.game.EventType.GameOverEvent;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.game.EventType.PlayEvent;
import io.anuke.mindustry.game.EventType.ResetEvent;
import io.anuke.mindustry.game.EventType.WaveEvent;
@ -10,7 +13,6 @@ import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.game.TeamInfo;
import io.anuke.mindustry.game.TeamInfo.TeamData;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetEvents;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Events;
@ -75,6 +77,13 @@ public class Logic extends Module {
public void runWave(){
//TODO spawn enemies
for(int i = 0; i < 10; i ++){
BaseUnit unit = new BaseUnit(UnitTypes.vtol, Team.red);
Vector2 offset = new Vector2().setToRandomDirection().scl(world.width()/2f*tilesize).add(world.width()/2f*tilesize, world.height()/2f*tilesize);
unit.inventory.addAmmo(AmmoTypes.basicIron);
unit.inventory.setInfiniteAmmo(true);
unit.set(offset.x, offset.y).add();
}
state.wave ++;
state.wavetime = wavespace * state.difficulty.timeScaling;
@ -104,11 +113,11 @@ public class Logic extends Module {
}
}
if(gameOver && !state.gameOver){ //TODO better gameover state, victory state?
/* if(gameOver && !state.gameOver){ //TODO better gameover state, victory state?
state.gameOver = true;
if(Net.server()) NetEvents.handleGameOver();
Events.fire(GameOverEvent.class);
}
}*/
if(!state.is(State.paused) || Net.active()){

View File

@ -6,6 +6,7 @@ import io.anuke.ucore.function.BiConsumer;
import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Mathf;
public class MapResizeDialog extends FloatingDialog{
int[] validMapSizes = {200, 300, 400, 500};
@ -21,14 +22,14 @@ public class MapResizeDialog extends FloatingDialog{
Table table = new Table();
for(int d = 0; d < 2; d ++){
boolean w = d == 0;
int curr = d == 0 ? data.width() : data.height();
for(boolean w : Mathf.booleans){
int curr = w ? data.width() : data.height();
int idx = 0;
for(int i = 0; i < validMapSizes.length; i ++)
if(validMapSizes[i] == curr) idx = i;
for(int i = 0; i < validMapSizes.length; i ++) {
if (validMapSizes[i] == curr) idx = i;
}
table.add(d == 0 ? "$text.width": "$text.height").padRight(8f);
table.add(w ? "$text.width": "$text.height").padRight(8f);
ButtonGroup<TextButton> group = new ButtonGroup<>();
for(int i = 0; i < validMapSizes.length; i ++){
int size = validMapSizes[i];

View File

@ -92,7 +92,6 @@ public class Player extends Unit implements BlockBuilder {
@Override
public void damage(float amount){
//if(debug || mech.flying) return;
hitTime = hitDuration;
if(!debug) {
health -= amount;
@ -111,6 +110,7 @@ public class Player extends Unit implements BlockBuilder {
@Override
public void onDeath(){
dead = true;
placeQueue.clear();
if(Net.active()){
NetEvents.handleUnitDeath(this);
}
@ -215,7 +215,7 @@ public class Player extends Unit implements BlockBuilder {
@Override
public void drawOver(){
if(!isShooting() && getCurrentRequest() != null) {
if(!isShooting() && getCurrentRequest() != null && !dead) {
drawBuilding(this);
}
}

View File

@ -15,12 +15,17 @@ public class UnitInventory {
private int totalAmmo;
private ItemStack item;
private int capacity, ammoCapacity;
private boolean infiniteAmmo;
public UnitInventory(int capacity, int ammoCapacity) {
this.capacity = capacity;
this.ammoCapacity = ammoCapacity;
}
public void setInfiniteAmmo(boolean infinite){
infiniteAmmo = infinite;
}
public void write(DataOutputStream stream) throws IOException {
stream.writeInt(item == null ? 0 : item.amount);
stream.writeByte(item == null ? 0 : item.item.id);
@ -57,6 +62,7 @@ public class UnitInventory {
}
public void useAmmo(){
if(infiniteAmmo) return;
AmmoEntry entry = ammos.peek();
entry.amount --;
if(entry.amount == 0) ammos.pop();

View File

@ -52,6 +52,12 @@ public class FlyingUnitType extends UnitType {
}
}
@Override
public UnitState getStartState(){
return attack;
}
protected void circle(BaseUnit unit, float circleLength){
vec.set(unit.target.x - unit.x, unit.target.y - unit.y);

View File

@ -5,7 +5,6 @@ import io.anuke.mindustry.content.fx.UnitFx;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.FlyingUnitType;
import io.anuke.mindustry.entities.units.UnitState;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
@ -66,9 +65,4 @@ public class Vtol extends FlyingUnitType {
}
}
@Override
public UnitState getStartState(){
return resupply;
}
}

View File

@ -20,6 +20,7 @@ import static io.anuke.mindustry.Vars.*;
public class DesktopInput extends InputHandler{
float mousex, mousey;
float endx, endy;
float prmousex, prmousey;
private float controlx, controly;
private boolean beganBreak;
private boolean controlling;
@ -34,8 +35,8 @@ public class DesktopInput extends InputHandler{
@Override public float getCursorEndX(){ return endx; }
@Override public float getCursorEndY(){ return endy; }
@Override public float getCursorX(){ return Graphics.screen(mousex, mousey).x; }
@Override public float getCursorY(){ return Gdx.graphics.getHeight() - 1 - Graphics.screen(mousex, mousey).y; }
@Override public float getCursorX(){ return prmousex; }
@Override public float getCursorY(){ return prmousey; }
@Override public boolean drawPlace(){ return !beganBreak; }
@Override
@ -82,6 +83,9 @@ public class DesktopInput extends InputHandler{
endx = getMouseX();
endy = getMouseY();
prmousex = Graphics.screen(mousex, mousey).x;
prmousey = Gdx.graphics.getHeight() - 1 - Graphics.screen(mousex, mousey).y;
boolean controller = KeyBinds.getSection(section).device.type == DeviceType.controller;
if(Inputs.getAxisActive("zoom") && (Inputs.keyDown(section,"zoom_hold") || controller)