Full command center implementation

This commit is contained in:
Anuken
2018-07-26 17:51:25 -04:00
parent 49e19ab34d
commit c832a7b93f
10 changed files with 729 additions and 668 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 136 KiB

View File

@@ -138,6 +138,7 @@ public class Recipes implements ContentList{
new Recipe(units, UnitBlocks.repairPoint, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30)); new Recipe(units, UnitBlocks.repairPoint, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30));
new Recipe(units, UnitBlocks.resupplyPoint, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30)); new Recipe(units, UnitBlocks.resupplyPoint, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30));
new Recipe(units, UnitBlocks.commandCenter, new ItemStack(Items.lead, 30), new ItemStack(Items.tungsten, 30), new ItemStack(Items.silicon, 30));
//LIQUIDS //LIQUIDS
new Recipe(liquid, LiquidBlocks.conduit, new ItemStack(Items.lead, 1)) new Recipe(liquid, LiquidBlocks.conduit, new ItemStack(Items.lead, 1))

View File

@@ -65,7 +65,7 @@ public class UnitBlocks extends BlockList implements ContentList{
}}; }};
commandCenter = new CommandCenter("command-center"){{ commandCenter = new CommandCenter("command-center"){{
size = 2;
}}; }};
} }
} }

View File

@@ -32,9 +32,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
private Object data; private Object data;
private boolean supressCollision; private boolean supressCollision;
/** /**Internal use only!*/
* Internal use only!
*/
public Bullet(){ public Bullet(){
} }

View File

@@ -1,24 +1,30 @@
package io.anuke.mindustry.world.blocks.units; package io.anuke.mindustry.world.blocks.units;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote; import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.units.BaseUnit; import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.UnitCommand; import io.anuke.mindustry.entities.units.UnitCommand;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockFlag; import io.anuke.mindustry.world.meta.BlockFlag;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.EnumSet; import io.anuke.ucore.util.EnumSet;
import static io.anuke.mindustry.Vars.unitGroups; import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.world;
public class CommandCenter extends Block{ public class CommandCenter extends Block{
protected TextureRegion[] commandRegions = new TextureRegion[UnitCommand.values().length]; protected TextureRegion[] commandRegions = new TextureRegion[UnitCommand.values().length];
protected Color topColor = Color.valueOf("eab678");
protected Color bottomColor = Color.valueOf("d4986b");
public CommandCenter(String name){ public CommandCenter(String name){
super(name); super(name);
@@ -29,6 +35,17 @@ public class CommandCenter extends Block{
configurable = true; configurable = true;
} }
@Override
public void placed(Tile tile){
ObjectSet<Tile> set = world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter);
if(set.size > 0){
CommandCenterEntity entity = tile.entity();
CommandCenterEntity oe = set.first().entity();
entity.command = oe.command;
}
}
@Override @Override
public void load(){ public void load(){
super.load(); super.load();
@@ -43,19 +60,29 @@ public class CommandCenter extends Block{
CommandCenterEntity entity = tile.entity(); CommandCenterEntity entity = tile.entity();
super.draw(tile); super.draw(tile);
Draw.colorl(0.3f);
Draw.rect(commandRegions[entity.command.ordinal()], tile.drawx(), tile.drawy() - 1);
Draw.color(topColor);
Draw.rect(commandRegions[entity.command.ordinal()], tile.drawx(), tile.drawy()); Draw.rect(commandRegions[entity.command.ordinal()], tile.drawx(), tile.drawy());
Draw.color();
} }
@Override @Override
public void buildTable(Tile tile, Table table){ public void buildTable(Tile tile, Table table){
//TODO CommandCenterEntity entity = tile.entity();
ButtonGroup<ImageButton> group = new ButtonGroup<>();
for(UnitCommand cmd : UnitCommand.values()){
table.addImageButton("command-" + cmd.name(), "toggle", 8*3, () -> threads.run(() -> Call.onCommandCenterSet(players[0], tile, cmd))).size(40f, 44f)
.checked(entity.command == cmd).group(group);
}
} }
@Remote(called = Loc.server, forward = true, targets = Loc.both) @Remote(called = Loc.server, forward = true, targets = Loc.both)
public static void onCommandCenterSet(Player player, Tile tile, UnitCommand command){ public static void onCommandCenterSet(Player player, Tile tile, UnitCommand command){
for(Tile center : world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter)){ for(Tile center : world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter)){
if(center.block() instanceof CommandCenter){ if(center.block() instanceof CommandCenter){
CommandCenterEntity entity = tile.entity(); CommandCenterEntity entity = center.entity();
entity.command = command; entity.command = command;
} }
} }