Made core 3x3

This commit is contained in:
Anuken
2017-10-25 16:51:00 -04:00
parent c3c83dc13b
commit d2a678f0b8
10 changed files with 194 additions and 182 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 552 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -166,7 +166,7 @@ public class Control extends Module{
Vars.renderer.clearTiles();
player.x = World.core.worldx();
player.y = World.core.worldy() - 8f - ((int)(Gdx.graphics.getWidth() / (float)Core.cameraScale * 2) % 2 == 0 ? 0.5f : 0);
player.y = World.core.worldy() - Vars.tilesize*2 - ((int)(Gdx.graphics.getWidth() / (float)Core.cameraScale * 2) % 2 == 0 ? 0.5f : 0);
Core.camera.position.set(player.x, player.y, 0);
@ -435,7 +435,7 @@ public class Control extends Module{
respawntime -= delta();
if(respawntime <= 0){
player.set(World.core.worldx(), World.core.worldy()-8);
player.set(World.core.worldx(), World.core.worldy()-Vars.tilesize*2);
player.heal();
player.add();
Effects.sound("respawn");

View File

@ -342,8 +342,11 @@ public class Renderer extends RendererModule{
//block breaking
if(Inputs.buttonDown(Buttons.RIGHT) && World.validBreak(Input.tilex(), Input.tiley())){
Tile tile = World.tile(Input.tilex(), Input.tiley());
if(tile.isLinked()) tile = tile.getLinked();
Vector2 offset = tile.block().getPlaceOffset();
Draw.color(Color.YELLOW, Color.SCARLET, player.breaktime / tile.getBreakTime());
Draw.square(tile.worldx(), tile.worldy(), 4);
Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize);
Draw.reset();
}else if(android && player.breaktime > 0){ //android block breaking
Vector2 vec = Graphics.world(Gdx.input.getX(0), Gdx.input.getY(0));

View File

@ -7,6 +7,8 @@ import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.World;
import io.anuke.ucore.core.Graphics;
@ -72,7 +74,11 @@ public class AndroidInput extends InputAdapter{
if(player.recipe != null &&
World.validPlace(tilex, tiley, player.recipe.result)){
World.placeBlock(tilex, tiley);
World.placeBlock(tilex, tiley, player.recipe.result, player.rotation);
for(ItemStack stack : player.recipe.requirements){
Vars.control.removeItem(stack);
}
}
}

View File

@ -7,6 +7,7 @@ import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.World;
@ -48,7 +49,15 @@ public class Input{
World.validPlace(tilex(), tiley(), player.recipe.result) && !ui.hasMouse() && cursorNear() &&
Vars.control.hasItems(player.recipe.requirements)){
World.placeBlock(tilex(), tiley());
World.placeBlock(tilex(), tiley(), player.recipe.result, player.rotation);
for(ItemStack stack : player.recipe.requirements){
Vars.control.removeItem(stack);
}
if(!Vars.control.hasItems(player.recipe.requirements)){
Cursors.restoreCursor();
}
}

View File

@ -88,7 +88,7 @@ public class Tile{
}
public boolean passable(){
return !(floor.solid || (block.solid && !block.update));
return isLinked() || !(floor.solid || (block.solid && !block.update));
}
public boolean solid(){

View File

@ -11,14 +11,12 @@ import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.ai.Pathfind;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.world.blocks.*;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Sounds;
import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.entities.SolidEntity;
import io.anuke.ucore.scene.utils.Cursors;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Tmp;
@ -149,7 +147,8 @@ public class World{
Pathfind.reset();
core.setBlock(ProductionBlocks.core);
//TODO multiblock core
placeBlock(core.x, core.y, ProductionBlocks.core, 0);
if(map != Map.tutorial){
setDefaultBlocks();
@ -163,7 +162,7 @@ public class World{
static void setDefaultBlocks(){
int x = core.x, y = core.y;
set(x, y-1, DistributionBlocks.conveyor, 1);
//set(x, y-1, DistributionBlocks.conveyor, 1);
set(x, y-2, DistributionBlocks.conveyor, 1);
set(x, y-3, DistributionBlocks.conveyor, 1);
@ -200,17 +199,15 @@ public class World{
}
//TODO move to control or player?
public static void placeBlock(int x, int y){
public static void placeBlock(int x, int y, Block result, int rotation){
Tile tile = tile(x, y);
//just in case
if(tile == null)
return;
Block result = player.recipe.result;
tile.setBlock(result);
tile.rotation = (byte)player.rotation;
tile.rotation = (byte)rotation;
if(result.isMultiblock()){
int offsetx = -(result.width-1)/2;
@ -221,7 +218,6 @@ public class World{
int worldx = dx + offsetx + x;
int worldy = dy + offsety + y;
if(!(worldx == x && worldy == y)){
//TODO make sure this is correct
Tile toplace = tile(worldx, worldy);
toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety));
}
@ -235,14 +231,6 @@ public class World{
Effects.shake(2f, 2f, player);
Sounds.play("place");
for(ItemStack stack : player.recipe.requirements){
Vars.control.removeItem(stack);
}
if(!Vars.control.hasItems(player.recipe.requirements)){
Cursors.restoreCursor();
}
}
//TODO move this to control?
@ -337,6 +325,10 @@ public class World{
if(tile == null || tile.block() == ProductionBlocks.core) return false;
if(tile.isLinked() && tile.getLinked().block() == ProductionBlocks.core){
return false;
}
if(Vars.control.getTutorial().active()){
if(Vars.control.getTutorial().showBlock()){

View File

@ -14,9 +14,11 @@ public class ProductionBlocks{
core = new Block("core"){
{
health = 300;
health = 600;
solid = true;
update = true;
width = 3;
height = 3;
}
@Override