mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-04-25 23:11:47 -07:00
Finished basic tutorial
This commit is contained in:
parent
ba345b4421
commit
d55898ead5
14 changed files with 114 additions and 29 deletions
|
|
@ -79,7 +79,7 @@ project(":core") {
|
|||
apply plugin: "java"
|
||||
|
||||
dependencies {
|
||||
compile 'com.github.anuken:ucore:e3f3890a4c'
|
||||
//compile 'com.github.anuken:ucore:e3f3890a4c'
|
||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -641,6 +641,13 @@ enemies/enemy-t1
|
|||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
enemies/targetenemy-t1
|
||||
rotate: false
|
||||
xy: 359, 475
|
||||
size: 14, 14
|
||||
orig: 14, 14
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
enemies/enemy-t2
|
||||
rotate: false
|
||||
xy: 391, 461
|
||||
|
|
|
|||
|
|
@ -325,6 +325,10 @@ public class Control extends Module{
|
|||
return wave;
|
||||
}
|
||||
|
||||
public Tutorial getTutorial(){
|
||||
return tutorial;
|
||||
}
|
||||
|
||||
public void clearItems(){
|
||||
items.clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -225,6 +225,23 @@ public class Renderer extends RendererModule{
|
|||
}
|
||||
|
||||
void renderPixelOverlay(){
|
||||
|
||||
if(Vars.control.tutorial.showBlock()){
|
||||
int x = World.core.x + Vars.control.tutorial.getPlacePoint().x;
|
||||
int y = World.core.y + Vars.control.tutorial.getPlacePoint().y;
|
||||
int rot = Vars.control.tutorial.getPlaceRotation();
|
||||
|
||||
Draw.thick(1f);
|
||||
Draw.color(Color.YELLOW);
|
||||
Draw.square(x * tilesize, y * tilesize, tilesize/2f + Mathf.sin(Timers.time(), 4f, 1f));
|
||||
|
||||
Draw.color(Color.ORANGE);
|
||||
Draw.thick(2f);
|
||||
if(rot != -1){
|
||||
Draw.lineAngle(x * tilesize, y * tilesize, rot * 90, 6);
|
||||
}
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
if(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && (!ui.hasMouse() || android) && AndroidInput.mode == PlaceMode.cursor){
|
||||
float x = 0;
|
||||
|
|
@ -275,19 +292,17 @@ public class Renderer extends RendererModule{
|
|||
}
|
||||
|
||||
//block breaking
|
||||
if(Inputs.buttonDown(Buttons.RIGHT) && World.cursorNear()){
|
||||
if(Inputs.buttonDown(Buttons.RIGHT) && World.validBreak(World.tilex(), World.tiley())){
|
||||
Tile tile = World.cursorTile();
|
||||
if(tile.breakable() && tile.block() != ProductionBlocks.core){
|
||||
Draw.color(Color.YELLOW, Color.SCARLET, player.breaktime / tile.block().breaktime);
|
||||
Draw.square(tile.worldx(), tile.worldy(), 4);
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
|
||||
if(android && player.breaktime > 0){
|
||||
Draw.color(Color.YELLOW, Color.SCARLET, player.breaktime / tile.block().breaktime);
|
||||
Draw.square(tile.worldx(), tile.worldy(), 4);
|
||||
Draw.reset();
|
||||
}else if(android && player.breaktime > 0){ //android block breaking
|
||||
Vector2 vec = Graphics.world(Gdx.input.getX(0), Gdx.input.getY(0));
|
||||
Tile tile = World.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize));
|
||||
if(tile != null && tile.breakable() && tile.block() != ProductionBlocks.core){
|
||||
|
||||
if(World.validBreak(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize))){
|
||||
Tile tile = World.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize));
|
||||
|
||||
float fract = player.breaktime / tile.block().breaktime;
|
||||
Draw.color(Color.YELLOW, Color.SCARLET, fract);
|
||||
Draw.circle(tile.worldx(), tile.worldy(), 4 + (1f - fract) * 26);
|
||||
|
|
|
|||
|
|
@ -233,6 +233,7 @@ public class UI extends SceneModule{
|
|||
player.recipe = null;
|
||||
}
|
||||
});
|
||||
button.setName("sectionbutton" + sec.name());
|
||||
add(button).fill().height(54).padRight(-0.1f).padTop(-10).units(Unit.dp);
|
||||
button.getImageCell().size(40).padBottom(4).units(Unit.dp);
|
||||
group.add(button);
|
||||
|
|
@ -259,10 +260,11 @@ public class UI extends SceneModule{
|
|||
|
||||
image.update(()->{
|
||||
|
||||
boolean has = control.hasItems(r.requirements);
|
||||
boolean canPlace = !control.tutorial.active() || control.tutorial.canPlace();
|
||||
boolean has = control.hasItems(r.requirements) && canPlace;
|
||||
//image.setDisabled(!has);
|
||||
image.setChecked(player.recipe == r);
|
||||
//image.setTouchable(has ? Touchable.enabled : Touchable.disabled);
|
||||
image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled);
|
||||
image.getImage().setColor(has ? Color.WHITE : Color.DARK_GRAY);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class TestEnemy extends Enemy{
|
|||
}
|
||||
|
||||
void move(){
|
||||
if(Timers.get(this, "asd", 300)){
|
||||
if(Timers.get(this, "switch", 300)){
|
||||
dir = !dir;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import io.anuke.mindustry.resource.ItemStack;
|
|||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.World;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
|
@ -115,7 +114,7 @@ public class AndroidInput extends InputAdapter{
|
|||
|
||||
if(sel == null) return;
|
||||
|
||||
if(warmup > warmupDelay && sel.block() != ProductionBlocks.core && sel.breakable()){
|
||||
if(warmup > warmupDelay && World.validBreak(sel.x, sel.y)){
|
||||
player.breaktime += Timers.delta();
|
||||
|
||||
if(player.breaktime > selected().block().breaktime){
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import io.anuke.mindustry.resource.Weapon;
|
|||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.World;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
|
||||
|
|
@ -80,8 +79,7 @@ public class Input{
|
|||
Tile cursor = World.cursorTile();
|
||||
|
||||
//block breaking
|
||||
if(cursor != null && Inputs.buttonDown(Buttons.RIGHT) && World.cursorNear() && cursor.breakable()
|
||||
&& cursor.block() != ProductionBlocks.core){
|
||||
if(Inputs.buttonDown(Buttons.RIGHT) && World.validBreak(World.tilex(), World.tiley())){
|
||||
Tile tile = cursor;
|
||||
player.breaktime += Timers.delta();
|
||||
if(player.breaktime >= tile.block().breaktime){
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ public class SaveIO{
|
|||
int totalEnemies = 0;
|
||||
|
||||
for(Entity entity : Entities.all()){
|
||||
if(entity instanceof Enemy){
|
||||
if(entity instanceof Enemy && idEnemies.containsKey((Class<? extends Enemy>) entity.getClass())){
|
||||
totalEnemies ++;
|
||||
}
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ public class SaveIO{
|
|||
stream.writeInt(totalEnemies); //enemy amount
|
||||
|
||||
for(Entity entity : Entities.all()){
|
||||
if(entity instanceof Enemy){
|
||||
if(entity instanceof Enemy && idEnemies.containsKey((Class<? extends Enemy>) entity.getClass())){
|
||||
Enemy enemy = (Enemy)entity;
|
||||
stream.writeByte(idEnemies.get(enemy.getClass())); //type
|
||||
stream.writeByte(enemy.spawn); //lane
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.badlogic.gdx.graphics.Color;
|
|||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.enemies.TargetEnemy;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
import io.anuke.ucore.noise.Noise;
|
||||
|
|
@ -80,8 +82,15 @@ public class Generator{
|
|||
block = Blocks.shrub;
|
||||
}
|
||||
|
||||
if(color == Hue.rgb(Color.PURPLE)){
|
||||
if(!Vars.android) new TargetEnemy(0).set(x * Vars.tilesize, y * Vars.tilesize).add();
|
||||
floor = Blocks.stone;
|
||||
}
|
||||
|
||||
World.tile(x, y).setBlock(block);
|
||||
World.tile(x, y).setFloor(floor);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,14 @@ public class Tile{
|
|||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(Block type, int rotation){
|
||||
if(rotation < 0) rotation = (-rotation + 2);
|
||||
rotation %= 4;
|
||||
this.block = type;
|
||||
this.rotation = (byte)rotation;
|
||||
changed();
|
||||
}
|
||||
|
||||
public void setBlock(Block type){
|
||||
this.block = type;
|
||||
changed();
|
||||
|
|
|
|||
|
|
@ -5,11 +5,10 @@ import static io.anuke.mindustry.Vars.*;
|
|||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.math.*;
|
||||
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.world.blocks.Blocks;
|
||||
|
|
@ -154,6 +153,17 @@ public class World{
|
|||
Pathfind.reset();
|
||||
|
||||
core.setBlock(ProductionBlocks.core);
|
||||
|
||||
if(map != Map.tutorial){
|
||||
setDefaultBlocks();
|
||||
}else{
|
||||
Vars.control.getTutorial().setDefaultBlocks(core.x, core.y);
|
||||
}
|
||||
|
||||
Pathfind.updatePath();
|
||||
}
|
||||
|
||||
static void setDefaultBlocks(){
|
||||
int x = core.x, y = core.y;
|
||||
|
||||
set(x, y-1, ProductionBlocks.conveyor, 1);
|
||||
|
|
@ -173,8 +183,6 @@ public class World{
|
|||
set(x-2, y-2, ProductionBlocks.stonedrill, 0);
|
||||
set(x-2, y-1, ProductionBlocks.conveyor, 1);
|
||||
set(x-2, y, WeaponBlocks.turret, 0);
|
||||
|
||||
Pathfind.updatePath();
|
||||
}
|
||||
|
||||
static void set(int x, int y, Block type, int rot){
|
||||
|
|
@ -211,6 +219,18 @@ public class World{
|
|||
|
||||
if(tile == null) return false;
|
||||
|
||||
if(Vars.control.getTutorial().active() &&
|
||||
Vars.control.getTutorial().showBlock()){
|
||||
|
||||
GridPoint2 point = Vars.control.getTutorial().getPlacePoint();
|
||||
int rotation = Vars.control.getTutorial().getPlaceRotation();
|
||||
Block block = Vars.control.getTutorial().getPlaceBlock();
|
||||
|
||||
if(type != block || point.x != x - core.x || point.y != y - core.y || (rotation != -1 && rotation != Vars.player.rotation)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(tile.block() != type && type.canReplace(tile.block())){
|
||||
return true;
|
||||
}
|
||||
|
|
@ -218,6 +238,29 @@ public class World{
|
|||
return tile != null && tile.block() == Blocks.air;
|
||||
}
|
||||
|
||||
public static boolean validBreak(int x, int y){
|
||||
Tile tile = tile(x, y);
|
||||
|
||||
if(tile == null || tile.block() == ProductionBlocks.core) return false;
|
||||
|
||||
if(Vars.control.getTutorial().active()){
|
||||
|
||||
if(Vars.control.getTutorial().showBlock()){
|
||||
GridPoint2 point = Vars.control.getTutorial().getPlacePoint();
|
||||
int rotation = Vars.control.getTutorial().getPlaceRotation();
|
||||
Block block = Vars.control.getTutorial().getPlaceBlock();
|
||||
|
||||
if(block != Blocks.air || point.x != x - core.x || point.y != y - core.y || (rotation != -1 && rotation != Vars.player.rotation)){
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return tile.breakable();
|
||||
}
|
||||
|
||||
public static boolean cursorNear(){
|
||||
return Vector2.dst(player.x, player.y, tilex() * tilesize, tiley() * tilesize) <= placerange;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class Conduit extends Block{
|
|||
|
||||
@Override
|
||||
public String description(){
|
||||
return "Transports liquids";
|
||||
return "Transports liquids.";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class LiquidRouter extends Conduit{
|
|||
|
||||
@Override
|
||||
public String description(){
|
||||
return "Splits input liquid into 3 directions";
|
||||
return "Splits input liquid into 3 directions.";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue