mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-21 12:03:29 -08:00
Added unlock messages for all content
This commit is contained in:
parent
6510d83524
commit
4344af1f02
6 changed files with 39 additions and 50 deletions
|
|
@ -43,8 +43,7 @@ about.button = About
|
|||
name = Name:
|
||||
noname = Pick a[accent] player name[] first.
|
||||
filename = File Name:
|
||||
unlocked = New Block Unlocked!
|
||||
unlocked.plural = New Blocks Unlocked!
|
||||
unlocked = New content unlocked!
|
||||
players = {0} players online
|
||||
players.single = {0} player online
|
||||
server.closing = [accent]Closing server...
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ public class Mechs implements ContentList{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateAlt(Player player){
|
||||
|
||||
public boolean alwaysUnlocked(){
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -182,18 +182,25 @@ public class Mechs implements ContentList{
|
|||
}
|
||||
};
|
||||
|
||||
dart = new Mech("dart-ship", true){{
|
||||
drillPower = 1;
|
||||
mineSpeed = 0.9f;
|
||||
speed = 0.4f;
|
||||
drag = 0.1f;
|
||||
armor = 10f;
|
||||
weapon = Weapons.blasterSmall;
|
||||
weaponOffsetX = -1;
|
||||
weaponOffsetY = -1;
|
||||
trailColor = Palette.lightTrail;
|
||||
cellTrnsY = 1f;
|
||||
}};
|
||||
dart = new Mech("dart-ship", true){
|
||||
{
|
||||
drillPower = 1;
|
||||
mineSpeed = 0.9f;
|
||||
speed = 0.4f;
|
||||
drag = 0.1f;
|
||||
armor = 10f;
|
||||
weapon = Weapons.blasterSmall;
|
||||
weaponOffsetX = -1;
|
||||
weaponOffsetY = -1;
|
||||
trailColor = Palette.lightTrail;
|
||||
cellTrnsY = 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alwaysUnlocked(){
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
javelin = new Mech("javelin-ship", true){
|
||||
float minV = 3.6f;
|
||||
|
|
|
|||
|
|
@ -133,6 +133,8 @@ public class Control implements ApplicationListener{
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(UnlockEvent.class, e -> ui.hudfrag.showUnlock(e.content));
|
||||
}
|
||||
|
||||
public void addPlayer(int index){
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ public class EventType{
|
|||
}
|
||||
|
||||
public static class UnlockEvent implements Event{
|
||||
public final Content content;
|
||||
public final UnlockableContent content;
|
||||
|
||||
public UnlockEvent(Content content){
|
||||
public UnlockEvent(UnlockableContent content){
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,23 +57,17 @@ public class GlobalData{
|
|||
* Makes this piece of content 'unlocked', if possible.
|
||||
* If this piece of content is already unlocked or cannot be unlocked due to dependencies, nothing changes.
|
||||
* Results are not saved until you call {@link #save()}.
|
||||
*
|
||||
* @return whether or not this content was newly unlocked.
|
||||
*/
|
||||
public boolean unlockContent(UnlockableContent content){
|
||||
if(!content.canBeUnlocked() || content.alwaysUnlocked()) return false;
|
||||
|
||||
boolean ret = unlocked.getOr(content.getContentType(), ObjectSet::new).add(content.getContentName());
|
||||
public void unlockContent(UnlockableContent content){
|
||||
if(!content.canBeUnlocked() || content.alwaysUnlocked()) return;
|
||||
|
||||
//fire unlock event so other classes can use it
|
||||
if(ret){
|
||||
if(unlocked.getOr(content.getContentType(), ObjectSet::new).add(content.getContentName())){
|
||||
modified = true;
|
||||
content.onUnlock();
|
||||
Events.fire(new UnlockEvent(content));
|
||||
save();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Clears all unlocked content. Automatically saves.*/
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import io.anuke.arc.Core;
|
|||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Interpolation;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.scene.Element;
|
||||
|
|
@ -13,7 +12,6 @@ import io.anuke.arc.scene.actions.Actions;
|
|||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.Image;
|
||||
import io.anuke.arc.scene.ui.ImageButton;
|
||||
import io.anuke.arc.scene.ui.Label;
|
||||
import io.anuke.arc.scene.ui.TextButton;
|
||||
import io.anuke.arc.scene.ui.layout.Stack;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
|
|
@ -24,12 +22,12 @@ import io.anuke.arc.util.Time;
|
|||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.Packets.AdminAction;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.IntFormat;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
|
||||
|
|
@ -229,7 +227,9 @@ public class HudFragment extends Fragment{
|
|||
}
|
||||
|
||||
/** Show unlock notification for a new recipe. */
|
||||
public void showUnlock(Recipe recipe){
|
||||
public void showUnlock(UnlockableContent content){
|
||||
//some content may not have icons... yet
|
||||
if(content.getContentIcon() == null) return;
|
||||
|
||||
//if there's currently no unlock notification...
|
||||
if(lastUnlockTable == null){
|
||||
|
|
@ -246,14 +246,10 @@ public class HudFragment extends Fragment{
|
|||
Table in = new Table();
|
||||
|
||||
//create texture stack for displaying
|
||||
Stack stack = new Stack();
|
||||
for(TextureRegion region : recipe.result.getCompactIcon()){
|
||||
Image image = new Image(region);
|
||||
image.setScaling(Scaling.fit);
|
||||
stack.add(image);
|
||||
}
|
||||
Image image = new Image(content.getContentIcon());
|
||||
image.setScaling(Scaling.fit);
|
||||
|
||||
in.add(stack).size(48f).pad(2);
|
||||
in.add(image).size(48f).pad(2);
|
||||
|
||||
//add to table
|
||||
table.add(in).padRight(8);
|
||||
|
|
@ -289,11 +285,6 @@ public class HudFragment extends Fragment{
|
|||
//get size of each element
|
||||
float size = 48f / Math.min(elements.size + 1, col);
|
||||
|
||||
//correct plurals if needed
|
||||
if(esize == 1){
|
||||
((Label) lastUnlockLayout.getParent().find(e -> e instanceof Label)).setText("$unlocked.plural");
|
||||
}
|
||||
|
||||
lastUnlockLayout.clearChildren();
|
||||
lastUnlockLayout.defaults().size(size).pad(2);
|
||||
|
||||
|
|
@ -308,14 +299,10 @@ public class HudFragment extends Fragment{
|
|||
//if there's space, add it
|
||||
if(esize < cap){
|
||||
|
||||
Stack stack = new Stack();
|
||||
for(TextureRegion region : recipe.result.getCompactIcon()){
|
||||
Image image = new Image(region);
|
||||
image.setScaling(Scaling.fit);
|
||||
stack.add(image);
|
||||
}
|
||||
Image image = new Image(content.getContentIcon());
|
||||
image.setScaling(Scaling.fit);
|
||||
|
||||
lastUnlockLayout.add(stack);
|
||||
lastUnlockLayout.add(image);
|
||||
}else{ //else, add a specific icon to denote no more space
|
||||
lastUnlockLayout.addImage("icon-add");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue