Full command center implementation
This commit is contained in:
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 |
+695
-660
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 |
@@ -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.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
|
||||
new Recipe(liquid, LiquidBlocks.conduit, new ItemStack(Items.lead, 1))
|
||||
|
||||
@@ -65,7 +65,7 @@ public class UnitBlocks extends BlockList implements ContentList{
|
||||
}};
|
||||
|
||||
commandCenter = new CommandCenter("command-center"){{
|
||||
|
||||
size = 2;
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
private Object data;
|
||||
private boolean supressCollision;
|
||||
|
||||
/**
|
||||
* Internal use only!
|
||||
*/
|
||||
/**Internal use only!*/
|
||||
public Bullet(){
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
package io.anuke.mindustry.world.blocks.units;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitCommand;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||
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.util.EnumSet;
|
||||
|
||||
import static io.anuke.mindustry.Vars.unitGroups;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class CommandCenter extends Block{
|
||||
protected TextureRegion[] commandRegions = new TextureRegion[UnitCommand.values().length];
|
||||
protected Color topColor = Color.valueOf("eab678");
|
||||
protected Color bottomColor = Color.valueOf("d4986b");
|
||||
|
||||
public CommandCenter(String name){
|
||||
super(name);
|
||||
@@ -29,6 +35,17 @@ public class CommandCenter extends Block{
|
||||
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
|
||||
public void load(){
|
||||
super.load();
|
||||
@@ -43,19 +60,29 @@ public class CommandCenter extends Block{
|
||||
CommandCenterEntity entity = tile.entity();
|
||||
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.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
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)
|
||||
public static void onCommandCenterSet(Player player, Tile tile, UnitCommand command){
|
||||
for(Tile center : world.indexer().getAllied(tile.getTeam(), BlockFlag.comandCenter)){
|
||||
if(center.block() instanceof CommandCenter){
|
||||
CommandCenterEntity entity = tile.entity();
|
||||
CommandCenterEntity entity = center.entity();
|
||||
entity.command = command;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user