Maps updated / 100 starting copper in custom maps
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -15,6 +15,7 @@ import io.anuke.mindustry.game.EventType.*;
|
|||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
@@ -59,6 +60,15 @@ public class Logic implements ApplicationListener{
|
|||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
state.wavetime = state.rules.waveSpacing * 2; //grace period of 2x wave time before game starts
|
state.wavetime = state.rules.waveSpacing * 2; //grace period of 2x wave time before game starts
|
||||||
Events.fire(new PlayEvent());
|
Events.fire(new PlayEvent());
|
||||||
|
|
||||||
|
//add starting items
|
||||||
|
if(!world.isZone()){
|
||||||
|
for(Tile core : state.teams.get(defaultTeam).cores){
|
||||||
|
for(ItemStack stack : state.rules.startingItems){
|
||||||
|
core.entity.items.add(stack.item, stack.amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(){
|
public void reset(){
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package io.anuke.mindustry.game;
|
|||||||
|
|
||||||
import io.anuke.annotations.Annotations.Serialize;
|
import io.anuke.annotations.Annotations.Serialize;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
|
import io.anuke.mindustry.content.Items;
|
||||||
import io.anuke.mindustry.io.JsonIO;
|
import io.anuke.mindustry.io.JsonIO;
|
||||||
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
import io.anuke.mindustry.type.Zone;
|
import io.anuke.mindustry.type.Zone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,6 +65,8 @@ public class Rules{
|
|||||||
public boolean attackMode = false;
|
public boolean attackMode = false;
|
||||||
/** Whether this is the editor gamemode. */
|
/** Whether this is the editor gamemode. */
|
||||||
public boolean editor = false;
|
public boolean editor = false;
|
||||||
|
/** Items that the player starts with here. Not applicable to zones.*/
|
||||||
|
public Array<ItemStack> startingItems = Array.with(new ItemStack(Items.copper, 100));
|
||||||
|
|
||||||
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
||||||
public Rules copy(){
|
public Rules copy(){
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import io.anuke.arc.util.serialization.JsonValue;
|
|||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.game.Rules;
|
import io.anuke.mindustry.game.Rules;
|
||||||
import io.anuke.mindustry.game.SpawnGroup;
|
import io.anuke.mindustry.game.SpawnGroup;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.type.Zone;
|
|
||||||
|
|
||||||
public class JsonIO{
|
public class JsonIO{
|
||||||
private static Json json = new Json(){{
|
private static Json json = new Json(){{
|
||||||
setIgnoreUnknownFields(true);
|
setIgnoreUnknownFields(true);
|
||||||
setElementType(Rules.class, "spawns", SpawnGroup.class);
|
setElementType(Rules.class, "spawns", SpawnGroup.class);
|
||||||
|
setElementType(Rules.class, "startingItems", ItemStack.class);
|
||||||
|
|
||||||
setSerializer(Zone.class, new Serializer<Zone>(){
|
setSerializer(Zone.class, new Serializer<Zone>(){
|
||||||
@Override
|
@Override
|
||||||
@@ -24,6 +24,18 @@ public class JsonIO{
|
|||||||
return Vars.content.getByName(ContentType.zone, jsonData.asString());
|
return Vars.content.getByName(ContentType.zone, jsonData.asString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setSerializer(Item.class, new Serializer<Item>(){
|
||||||
|
@Override
|
||||||
|
public void write(Json json, Item object, Class knownType){
|
||||||
|
json.writeValue(object.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item read(Json json, JsonValue jsonData, Class type){
|
||||||
|
return Vars.content.getByName(ContentType.item, jsonData.asString());
|
||||||
|
}
|
||||||
|
});
|
||||||
}};
|
}};
|
||||||
|
|
||||||
public static String write(Object object){
|
public static String write(Object object){
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ public class CustomRulesDialog extends FloatingDialog{
|
|||||||
|
|
||||||
title("$rules.title.waves");
|
title("$rules.title.waves");
|
||||||
check("$rules.waves", b -> rules.waves = b, () -> rules.waves);
|
check("$rules.waves", b -> rules.waves = b, () -> rules.waves);
|
||||||
check("$rules.wavetimer", b -> rules.waveTimer = b, () -> rules.waveTimer, () -> rules.waves);
|
check("$rules.wavetimer", b -> rules.waveTimer = b, () -> rules.waveTimer);
|
||||||
check("$rules.waitForWaveToEnd", b -> rules.waitForWaveToEnd = b, () -> rules.waitForWaveToEnd, () -> rules.waves);
|
check("$rules.waitForWaveToEnd", b -> rules.waitForWaveToEnd = b, () -> rules.waitForWaveToEnd);
|
||||||
number("$rules.wavespacing", false, f -> rules.waveSpacing = f * 60f, () -> rules.waveSpacing / 60f, () -> rules.waves);
|
number("$rules.wavespacing", false, f -> rules.waveSpacing = f * 60f, () -> rules.waveSpacing / 60f, () -> true);
|
||||||
number("$rules.dropzoneradius", false, f -> rules.dropZoneRadius = f * tilesize, () -> rules.dropZoneRadius / tilesize, () -> rules.waves);
|
number("$rules.dropzoneradius", false, f -> rules.dropZoneRadius = f * tilesize, () -> rules.dropZoneRadius / tilesize, () -> true);
|
||||||
|
|
||||||
title("$rules.title.respawns");
|
title("$rules.title.respawns");
|
||||||
check("$rules.limitedRespawns", b -> rules.limitedRespawns = b, () -> rules.limitedRespawns);
|
check("$rules.limitedRespawns", b -> rules.limitedRespawns = b, () -> rules.limitedRespawns);
|
||||||
|
|||||||
Reference in New Issue
Block a user