More tutorial

This commit is contained in:
Anuken
2019-08-08 17:26:20 -04:00
parent 4811578c95
commit b587b6bb4d
4 changed files with 49 additions and 18 deletions

View File

@@ -53,6 +53,11 @@ public class EventType{
}
/** Called when a turret recieves ammo, but only when the tutorial is active! */
public static class AmmoDeliverEvent{
}
public static class GameOverEvent{
public final Team winner;

View File

@@ -32,14 +32,19 @@ public class Tutorial{
});
Events.on(LineConfirmEvent.class, event -> events.add("lineconfirm"));
Events.on(AmmoDeliverEvent.class, event -> events.add("ammo"));
}
/** update tutorial state, transition if needed */
public void update(){
if(stage.done.get()){
next();
}else{
stage.update();
}
}
/** draw UI overlay */
public void draw(){
stage.draw();
}
@@ -82,6 +87,23 @@ public class Tutorial{
outline("category-turrets");
outline("block-duo");
}
},
drillturret(() -> event("ammo")){
void draw(){
outline("category-production");
outline("block-mechanical-drill");
}
},
waves(() -> Vars.state.wave > 2 && Vars.state.enemies() <= 0){
void begin(){
Vars.state.rules.waveTimer = true;
}
void update(){
if(Vars.state.wave > 2){
Vars.state.rules.waveTimer = false;
}
}
};
protected final String line = Core.bundle.has("tutorial." + name() + ".mobile") && Vars.mobile ? "tutorial." + name() + ".mobile" : "tutorial." + name();
@@ -98,10 +120,22 @@ public class Tutorial{
this.done = done;
}
/** displayed tutorial stage text.*/
public String text(){
return text.get(line);
}
/** called every frame when this stage is active.*/
void update(){
}
/** called when a stage begins.*/
void begin(){
}
/** called when a stage needs to draw itself, usually over highlighted UI elements. */
void draw(){
}

View File

@@ -1,11 +1,12 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.arc.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.entities.bullet.*;
import io.anuke.mindustry.entities.type.Unit;
import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.*;
@@ -127,6 +128,11 @@ public class ItemTurret extends CooledTurret{
//must not be found
entity.ammo.add(new ItemEntry(item, (int)type.ammoMultiplier));
//fire events for the tutorial
if(state.rules.tutorial){
Events.fire(new AmmoDeliverEvent());
}
}
@Override