Added some base classes for functional blocks

This commit is contained in:
Anuken 2017-10-19 20:46:13 -04:00
parent 670d080fae
commit 1336a657fd
14 changed files with 108 additions and 24 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.anuke.mindustry"
android:versionCode="14"
android:versionName="2.3.1" >
android:versionCode="15"
android:versionName="2.4" >
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25" />

View File

@ -50,7 +50,7 @@ project(":html") {
dependencies {
compile project(":core")
//compile fileTree(dir: '../core/lib', include: '*.jar')
compile fileTree(dir: '../core/lib', include: '*.jar')
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"

View File

@ -84,6 +84,7 @@ public class Control extends Module{
"down", Keys.S,
"right", Keys.D,
"rotate", Keys.R,
"rotate_back", Keys.E,
"menu", Gdx.app.getType() == ApplicationType.Android ? Keys.BACK : Keys.ESCAPE,
"pause", Keys.SPACE
);

View File

@ -182,7 +182,7 @@ public class Tutorial{
{
canBack = false;
canPlace = true;
text = "Try selecting a [yellow]conveyor[] from the block menu in the bottom left.";
text = "Try selecting a [yellow]conveyor[] from the block menu in the bottom right.";
}
void onSwitch(){
@ -219,7 +219,7 @@ public class Tutorial{
{
androidOnly = true;
canBack = false;
text = "Alternatively, you can press the crosshair icon to switch to [orange][[touch mode][], and "
text = "Alternatively, you can press the crosshair icon in the bottom left to switch to [orange][[touch mode][], and "
+ "place blocks by tapping on the screen. In touch mode, blocks can be rotated with the arrow at the bottom left. "
+ "Press [yellow]next[] to try it out.";
}
@ -237,7 +237,7 @@ public class Tutorial{
blockPlaceX = 0;
blockPlaceY = -2;
targetBlock = ProductionBlocks.stonedrill;
text = "Now, select and place a [yellow]stone drill[] at the marked location.";
text = "Now, select and place a [yellow]stone drill[] at the marked location.";
}
void onSwitch(){
@ -365,14 +365,14 @@ public class Tutorial{
pausingDesktop{
{
desktopOnly = true;
text = "If you ever need to take a break, press the [orange]pause button[] in the top right or [orange]space[] "
text = "If you ever need to take a break, press the [orange]pause button[] in the top left or [orange]space[] "
+ "to pause the game. You can still select and place blocks while paused, but cannot move or shoot.";
}
},
pausingAndroid{
{
androidOnly = true;
text = "If you ever need to take a break, press the [orange]pause button[] in the top right"
text = "If you ever need to take a break, press the [orange]pause button[] in the top left"
+ " to pause the game. You can still place select and place blocks while paused.";
}
},

View File

@ -465,7 +465,7 @@ public class UI extends SceneModule{
if(android){
//placement table
new table(){{
visible(()->player.recipe != null);
visible(()->player.recipe != null && !GameState.is(State.menu));
abottom();
aleft();

View File

@ -14,7 +14,7 @@ public class Vars{
//respawn time in frames
public static final float respawnduration = 60*4;
//time between waves in frames
public static final float wavespace = 35*60*(android ? 1 : 1);
public static final float wavespace = 40*60*(android ? 1 : 1);
//waves can last no longer than 6 minutes, otherwise the next one spawns
public static final float maxwavespace = 60*60*6;
//how far away from spawn points the player can't place blocks

View File

@ -0,0 +1,18 @@
package io.anuke.mindustry.entities.effect;
import io.anuke.ucore.entities.Entity;
public class Shield extends Entity{
public boolean active;
//TODO
@Override
public void added(){
active = true;
}
@Override
public void removed(){
active = false;
}
}

View File

@ -22,23 +22,18 @@ public class Input{
if(Inputs.scrolled()){
Vars.renderer.scaleCamera(Inputs.scroll());
//TODO
/*
int index = currentWeapon();
index -= Inputs.scroll();
player.weapon = control.getWeapons().get(Mathf.clamp(index, 0, control.getWeapons().size-1));
ui.updateWeapons();
*/
}
if(Inputs.keyUp("rotate"))
player.rotation++;
player.rotation ++;
if(Inputs.keyUp("rotate_back"))
player.rotation --;
if(player.rotation < 0)
player.rotation += 4;
player.rotation %= 4;
//TODO restore cursor when requirements are back
for(int i = 0; i < 9; i ++){
if(Inputs.keyUp(Keys.valueOf(""+(i+1))) && i < control.getWeapons().size){

View File

@ -43,7 +43,7 @@ public enum Recipe{
crucible(production, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
coalpurifier(production, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
titaniumpurifier(production, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)),
omnidrill(production, ProductionBlocks.omnidrill, stack(Item.titanium, 20), stack(Item.dirium, 20)),
omnidrill(production, ProductionBlocks.omnidrill, stack(Item.titanium, 10), stack(Item.dirium, 10)),
conduit(distribution, ProductionBlocks.conduit, stack(Item.steel, 1)),
liquidrouter(distribution, ProductionBlocks.liquidrouter, stack(Item.steel, 2)),

View File

@ -28,6 +28,7 @@ public class Block{
//stuff that drops when broken
public ItemStack drops = null;
public Liquid liquidDrop = null;
public int width, height;
public Block(String name) {
blocks.add(this);

View File

@ -178,7 +178,7 @@ public class ProductionBlocks{
omnidrill = new Drill("omnidrill"){
{
time = 3;
time = 2;
formalName = "omnidrill";
}

View File

@ -0,0 +1,9 @@
package io.anuke.mindustry.world.blocks.types;
public class Generator extends PowerBlock{
public Generator(String name) {
super(name);
}
}

View File

@ -0,0 +1,15 @@
package io.anuke.mindustry.world.blocks.types;
import io.anuke.mindustry.world.Block;
public abstract class PowerBlock extends Block{
public float powerCapacity;
public float power;
public PowerBlock(String name) {
super(name);
update = true;
solid = true;
}
}

View File

@ -0,0 +1,45 @@
package io.anuke.mindustry.world.blocks.types;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.effect.Shield;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers;
public class ShieldBlock extends PowerBlock{
public float shieldRadius = 40f;
public float powerDrain = 0.01f;
public ShieldBlock(String name) {
super(name);
}
@Override
public void update(Tile tile){
ShieldEntity entity = tile.entity();
if(entity.shield == null){
entity.shield = new Shield();
}
if(power > powerDrain * Timers.delta()){
if(!entity.shield.active){
entity.shield.add();
}
power -= powerDrain * Timers.delta();
}else{
if(entity.shield.active){
entity.shield.remove();
}
}
}
@Override
public TileEntity getEntity(){
return new ShieldEntity();
}
static class ShieldEntity extends TileEntity{
Shield shield;
}
}