mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-04 22:50:29 +07:00
Added some base classes for functional blocks
This commit is contained in:
parent
670d080fae
commit
1336a657fd
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="io.anuke.mindustry"
|
package="io.anuke.mindustry"
|
||||||
android:versionCode="14"
|
android:versionCode="15"
|
||||||
android:versionName="2.3.1" >
|
android:versionName="2.4" >
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25" />
|
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25" />
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ project(":html") {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(":core")
|
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-backend-gwt:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
|
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
|
||||||
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
|
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
|
||||||
|
@ -84,6 +84,7 @@ public class Control extends Module{
|
|||||||
"down", Keys.S,
|
"down", Keys.S,
|
||||||
"right", Keys.D,
|
"right", Keys.D,
|
||||||
"rotate", Keys.R,
|
"rotate", Keys.R,
|
||||||
|
"rotate_back", Keys.E,
|
||||||
"menu", Gdx.app.getType() == ApplicationType.Android ? Keys.BACK : Keys.ESCAPE,
|
"menu", Gdx.app.getType() == ApplicationType.Android ? Keys.BACK : Keys.ESCAPE,
|
||||||
"pause", Keys.SPACE
|
"pause", Keys.SPACE
|
||||||
);
|
);
|
||||||
|
@ -182,7 +182,7 @@ public class Tutorial{
|
|||||||
{
|
{
|
||||||
canBack = false;
|
canBack = false;
|
||||||
canPlace = true;
|
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(){
|
void onSwitch(){
|
||||||
@ -219,7 +219,7 @@ public class Tutorial{
|
|||||||
{
|
{
|
||||||
androidOnly = true;
|
androidOnly = true;
|
||||||
canBack = false;
|
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. "
|
+ "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.";
|
+ "Press [yellow]next[] to try it out.";
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ public class Tutorial{
|
|||||||
blockPlaceX = 0;
|
blockPlaceX = 0;
|
||||||
blockPlaceY = -2;
|
blockPlaceY = -2;
|
||||||
targetBlock = ProductionBlocks.stonedrill;
|
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(){
|
void onSwitch(){
|
||||||
@ -365,14 +365,14 @@ public class Tutorial{
|
|||||||
pausingDesktop{
|
pausingDesktop{
|
||||||
{
|
{
|
||||||
desktopOnly = true;
|
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.";
|
+ "to pause the game. You can still select and place blocks while paused, but cannot move or shoot.";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pausingAndroid{
|
pausingAndroid{
|
||||||
{
|
{
|
||||||
androidOnly = true;
|
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.";
|
+ " to pause the game. You can still place select and place blocks while paused.";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -465,7 +465,7 @@ public class UI extends SceneModule{
|
|||||||
if(android){
|
if(android){
|
||||||
//placement table
|
//placement table
|
||||||
new table(){{
|
new table(){{
|
||||||
visible(()->player.recipe != null);
|
visible(()->player.recipe != null && !GameState.is(State.menu));
|
||||||
abottom();
|
abottom();
|
||||||
aleft();
|
aleft();
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ public class Vars{
|
|||||||
//respawn time in frames
|
//respawn time in frames
|
||||||
public static final float respawnduration = 60*4;
|
public static final float respawnduration = 60*4;
|
||||||
//time between waves in frames
|
//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
|
//waves can last no longer than 6 minutes, otherwise the next one spawns
|
||||||
public static final float maxwavespace = 60*60*6;
|
public static final float maxwavespace = 60*60*6;
|
||||||
//how far away from spawn points the player can't place blocks
|
//how far away from spawn points the player can't place blocks
|
||||||
|
18
core/src/io/anuke/mindustry/entities/effect/Shield.java
Normal file
18
core/src/io/anuke/mindustry/entities/effect/Shield.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -22,23 +22,18 @@ public class Input{
|
|||||||
|
|
||||||
if(Inputs.scrolled()){
|
if(Inputs.scrolled()){
|
||||||
Vars.renderer.scaleCamera(Inputs.scroll());
|
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"))
|
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;
|
player.rotation %= 4;
|
||||||
|
|
||||||
//TODO restore cursor when requirements are back
|
|
||||||
|
|
||||||
for(int i = 0; i < 9; i ++){
|
for(int i = 0; i < 9; i ++){
|
||||||
if(Inputs.keyUp(Keys.valueOf(""+(i+1))) && i < control.getWeapons().size){
|
if(Inputs.keyUp(Keys.valueOf(""+(i+1))) && i < control.getWeapons().size){
|
||||||
|
@ -43,7 +43,7 @@ public enum Recipe{
|
|||||||
crucible(production, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
|
crucible(production, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
|
||||||
coalpurifier(production, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
|
coalpurifier(production, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
|
||||||
titaniumpurifier(production, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)),
|
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)),
|
conduit(distribution, ProductionBlocks.conduit, stack(Item.steel, 1)),
|
||||||
liquidrouter(distribution, ProductionBlocks.liquidrouter, stack(Item.steel, 2)),
|
liquidrouter(distribution, ProductionBlocks.liquidrouter, stack(Item.steel, 2)),
|
||||||
|
@ -28,6 +28,7 @@ public class Block{
|
|||||||
//stuff that drops when broken
|
//stuff that drops when broken
|
||||||
public ItemStack drops = null;
|
public ItemStack drops = null;
|
||||||
public Liquid liquidDrop = null;
|
public Liquid liquidDrop = null;
|
||||||
|
public int width, height;
|
||||||
|
|
||||||
public Block(String name) {
|
public Block(String name) {
|
||||||
blocks.add(this);
|
blocks.add(this);
|
||||||
|
@ -178,7 +178,7 @@ public class ProductionBlocks{
|
|||||||
|
|
||||||
omnidrill = new Drill("omnidrill"){
|
omnidrill = new Drill("omnidrill"){
|
||||||
{
|
{
|
||||||
time = 3;
|
time = 2;
|
||||||
formalName = "omnidrill";
|
formalName = "omnidrill";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.types;
|
||||||
|
|
||||||
|
public class Generator extends PowerBlock{
|
||||||
|
|
||||||
|
public Generator(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user