Changes to break/place system

This commit is contained in:
Anuken 2017-12-16 10:47:06 -05:00
parent 97d1542ff4
commit 93f58bb458
15 changed files with 230 additions and 233 deletions

View File

@ -12,7 +12,6 @@ _Keep in mind that this is just a basic outline of planned features, and will be
- More indicators for when the core is damaged and/or under attack
- Fix bugs with junction not accepting blocks (low FPS)
- Fix bugs with tunnel merging and/or removing items (low FPS)
- Investigate #6
- Edit descriptions for conveyors to be more clear about how to use them
- Add link to Mindustry discord everywhere
- Balancing to slow down progression

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

@ -15,6 +15,7 @@ import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.effect.Fx;
import io.anuke.mindustry.entities.effect.Shield;
import io.anuke.mindustry.entities.enemies.BlastEnemy;
import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.entities.enemies.HealerEnemy;
@ -45,6 +46,7 @@ public class Control extends Module{
public final EntityGroup<Enemy> enemyGroup = Entities.addGroup(Enemy.class);
public final EntityGroup<TileEntity> tileGroup = Entities.addGroup(TileEntity.class, false);
public final EntityGroup<Bullet> bulletGroup = Entities.addGroup(Bullet.class);
public final EntityGroup<Shield> shieldGroup = Entities.addGroup(Shield.class);
Array<EnemySpawn> spawns = new Array<>();
int wave = 1;

View File

@ -268,6 +268,14 @@ public class Renderer extends RendererModule{
}
void drawShield(){
if(control.shieldGroup.amount() == 0) return;
Graphics.surface(Vars.renderer.shieldSurface, false);
Draw.color(Color.ROYAL);
Entities.draw(control.shieldGroup);
Draw.reset();
Graphics.surface();
for(int i = 0; i < shieldHits.size / 3; i++){
//float x = hits.get(i*3+0);
//float y = hits.get(i*3+1);

View File

@ -183,7 +183,7 @@ public class World extends Module{
Generator.generate(mapPixmaps[map.ordinal()], tiles);
//TODO multiblock core
control.getInput().placeBlock(control.getCore().x, control.getCore().y, ProductionBlocks.core, 0, false);
control.getInput().placeBlock(control.getCore().x, control.getCore().y, ProductionBlocks.core, 0, false, false);
if(map != Map.tutorial){
setDefaultBlocks();

View File

@ -27,7 +27,7 @@ public class Player extends DestructibleEntity{
public transient Recipe recipe;
public transient int rotation;
public transient PlaceMode placeMode = android ? PlaceMode.cursor : PlaceMode.hold;
public transient PlaceMode breakMode = PlaceMode.holdDelete;
public transient PlaceMode breakMode = android ? PlaceMode.none : PlaceMode.holdDelete;
public Player(){
hitbox.setSize(5);

View File

@ -1,6 +1,5 @@
package io.anuke.mindustry.entities.effect;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Interpolation;
import io.anuke.mindustry.Vars;
@ -8,7 +7,6 @@ import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.defense.ShieldBlock;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.BulletEntity;
import io.anuke.ucore.entities.Entities;
@ -75,13 +73,7 @@ public class Shield extends Entity{
}
float rad = drawRadius();
Graphics.surface(Vars.renderer.shieldSurface, false);
Draw.color(Color.ROYAL);
Draw.thick(2f);
Draw.rect("circle2", x, y, rad, rad);
Draw.reset();
Graphics.surface();
}
float drawRadius(){
@ -92,6 +84,11 @@ public class Shield extends Entity{
active = false;
}
@Override
public Shield add(){
return add(Vars.control.shieldGroup);
}
@Override
public void added(){
active = true;

View File

@ -8,7 +8,6 @@ import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.Configurable;
import io.anuke.ucore.core.Graphics;
@ -33,7 +32,7 @@ public class AndroidInput extends InputHandler{
@Override public float getCursorEndY(){ return Gdx.input.getY(0); }
@Override public float getCursorX(){ return mousex; }
@Override public float getCursorY(){ return mousey; }
@Override public boolean drawPlace(){ return placing || (player.placeMode.pan && player.recipe != null); }
@Override public boolean drawPlace(){ return (placing && !brokeBlock) || (player.placeMode.pan && player.recipe != null); }
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button){
@ -108,26 +107,15 @@ public class AndroidInput extends InputHandler{
if(player.breaktime >= tile.block().breaktime){
brokeBlock = true;
breakBlock(tile.x, tile.y);
breakBlock(tile.x, tile.y, true);
player.breaktime = 0f;
}
}
public void tryPlaceBlock(int tilex, int tiley){
if(player.recipe != null && control.hasItems(player.recipe.requirements) && validPlace(tilex, tiley, player.recipe.result)){
placeBlock(tilex, tiley, player.recipe.result, player.rotation, true);
for(ItemStack stack : player.recipe.requirements){
control.removeItem(stack);
}
}
}
@Override
public void update(){
if(Gdx.input.isTouched(0) && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.inPixels(50))
if(player.recipe != null && Gdx.input.isTouched(0) && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.inPixels(50))
&& !ui.hasMouse()){
warmup += Timers.delta();

View File

@ -9,7 +9,6 @@ import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.Configurable;
@ -110,7 +109,7 @@ public class DesktopInput extends InputHandler{
Tile tile = cursor;
player.breaktime += Timers.delta();
if(player.breaktime >= tile.getBreakTime()){
breakBlock(cursor.x, cursor.y);
breakBlock(cursor.x, cursor.y, true);
player.breaktime = 0f;
}
}else{
@ -118,23 +117,6 @@ public class DesktopInput extends InputHandler{
}
}
public void tryPlaceBlock(int x, int y){
if(player.recipe != null &&
validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() &&
control.hasItems(player.recipe.requirements)){
placeBlock(x, y, player.recipe.result, player.rotation, true);
for(ItemStack stack : player.recipe.requirements){
control.removeItem(stack);
}
if(!control.hasItems(player.recipe.requirements)){
Cursors.restoreCursor();
}
}
}
public int tilex(){
return (player.recipe != null && player.recipe.result.isMultiblock() &&

View File

@ -49,12 +49,12 @@ public abstract class InputHandler extends InputAdapter{
return Vector2.dst(player.x, player.y, getBlockX() * tilesize, getBlockY() * tilesize) <= placerange;
}
public void tryPlaceBlock(int x, int y){
public void tryPlaceBlock(int x, int y, boolean sound){
if(player.recipe != null &&
validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() &&
Vars.control.hasItems(player.recipe.requirements)){
placeBlock(x, y, player.recipe.result, player.rotation, true);
placeBlock(x, y, player.recipe.result, player.rotation, true, sound);
for(ItemStack stack : player.recipe.requirements){
Vars.control.removeItem(stack);
@ -66,9 +66,9 @@ public abstract class InputHandler extends InputAdapter{
}
}
public void tryDeleteBlock(int x, int y){
public void tryDeleteBlock(int x, int y, boolean sound){
if(cursorNear() && validBreak(x, y)){
breakBlock(x, y);
breakBlock(x, y, sound);
}
}
@ -167,7 +167,7 @@ public abstract class InputHandler extends InputAdapter{
return tile.breakable();
}
public void placeBlock(int x, int y, Block result, int rotation, boolean effects){
public void placeBlock(int x, int y, Block result, int rotation, boolean effects, boolean sound){
Tile tile = world.tile(x, y);
//just in case
@ -196,10 +196,10 @@ public abstract class InputHandler extends InputAdapter{
if(effects) Effects.effect(Fx.place, x * Vars.tilesize, y * Vars.tilesize);
}
if(effects) Sounds.play("place");
if(effects && sound) Sounds.play("place");
}
public void breakBlock(int x, int y){
public void breakBlock(int x, int y, boolean sound){
Tile tile = world.tile(x, y);
if(tile == null) return;
@ -225,7 +225,7 @@ public abstract class InputHandler extends InputAdapter{
}
//Effects.shake(3f, 1f, player);
Sounds.play("break");
if(sound)Sounds.play("break");
if(!tile.block().isMultiblock() && !tile.isLinked()){
tile.setBlock(Blocks.air);

View File

@ -58,7 +58,7 @@ public enum PlaceMode{
}
public void tapped(int tilex, int tiley){
control.getInput().tryPlaceBlock(tilex, tiley);
control.getInput().tryPlaceBlock(tilex, tiley, true);
}
},
touch{
@ -70,13 +70,19 @@ public enum PlaceMode{
}
public void tapped(int x, int y){
control.getInput().tryPlaceBlock(x, y);
control.getInput().tryPlaceBlock(x, y, true);
}
},
none{
{
delete = true;
shown = true;
}
},
holdDelete{
{
delete = true;
shown = true;
shown = false;
}
public void draw(int tilex, int tiley, int endx, int endy){
@ -109,7 +115,7 @@ public enum PlaceMode{
}
public void tapped(int x, int y){
control.getInput().tryDeleteBlock(x, y);
control.getInput().tryDeleteBlock(x, y, true);
}
},
areaDelete{
@ -173,9 +179,12 @@ public enum PlaceMode{
tilex = this.tilex; tiley = this.tiley;
endx = this.endx; endy = this.endy;
boolean first = true;
for(int cx = tilex; cx <= endx; cx ++){
for(int cy = tiley; cy <= endy; cy ++){
control.getInput().tryDeleteBlock(cx, cy);
control.getInput().tryDeleteBlock(cx, cy, first);
first = false;
}
}
}
@ -207,7 +216,7 @@ public enum PlaceMode{
this.tiley = tiley;
}
},
hold{ //TODO multiblock support!
hold{
int maxlen = 10;
int tilex;
int tiley;
@ -293,11 +302,13 @@ public enum PlaceMode{
player.rotation = this.rotation;
boolean first = true;
for(int x = 0; x <= Math.abs(this.endx - this.tilex); x ++){
for(int y = 0; y <= Math.abs(this.endy - this.tiley); y ++){
control.getInput().tryPlaceBlock(
tilex + x * Mathf.sign(endx - tilex),
tiley + y * Mathf.sign(endy - tiley));
tiley + y * Mathf.sign(endy - tiley), first);
first = false;
}
}
}

View File

@ -8,9 +8,7 @@ import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.input.PlaceMode;
import io.anuke.ucore.scene.builders.button;
import io.anuke.ucore.scene.builders.imagebutton;
import io.anuke.ucore.scene.builders.table;
import io.anuke.ucore.scene.builders.*;
import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.ImageButton;
@ -44,6 +42,8 @@ public class PlacementFragment implements Fragment{
touchable(Touchable.enabled);
aleft();
new label("place mode");
row();
new table("pane"){{
get().pad(5);
@ -90,6 +90,9 @@ public class PlacementFragment implements Fragment{
abottom();
aleft();
new label("break mode");
row();
new table("pane"){{
get().pad(5);
touchable(Touchable.enabled);

View File

@ -17,9 +17,9 @@ public class DesktopLauncher {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setTitle("Mindustry");
config.setMaximized(true);
//config.useVsync(false);
config.setWindowedMode(800, 600);
config.setWindowedMode(960, 540);
config.setWindowIcon("sprites/icon.png");
//config.useVsync(false);
Mindustry.formatter = new Formatter(){
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm");