Unit creation, team switch
This commit is contained in:
@@ -216,6 +216,8 @@ waves.copied = Waves copied.
|
|||||||
editor.default = [LIGHT_GRAY]<Default>
|
editor.default = [LIGHT_GRAY]<Default>
|
||||||
edit = Edit...
|
edit = Edit...
|
||||||
editor.name = Name:
|
editor.name = Name:
|
||||||
|
editor.spawn = Spawn Unit
|
||||||
|
editor.removeunit = Remove Unit
|
||||||
editor.teams = Teams
|
editor.teams = Teams
|
||||||
editor.elevation = Elevation
|
editor.elevation = Elevation
|
||||||
editor.errorload = Error loading file:\n[accent]{0}
|
editor.errorload = Error loading file:\n[accent]{0}
|
||||||
|
|||||||
@@ -166,15 +166,17 @@ public class Logic implements ApplicationListener{
|
|||||||
Entities.update(groundEffectGroup);
|
Entities.update(groundEffectGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(EntityGroup group : unitGroups){
|
if(!state.isEditor()){
|
||||||
Entities.update(group);
|
for(EntityGroup group : unitGroups){
|
||||||
}
|
Entities.update(group);
|
||||||
|
}
|
||||||
|
|
||||||
Entities.update(puddleGroup);
|
Entities.update(puddleGroup);
|
||||||
Entities.update(shieldGroup);
|
Entities.update(shieldGroup);
|
||||||
Entities.update(bulletGroup);
|
Entities.update(bulletGroup);
|
||||||
Entities.update(tileGroup);
|
Entities.update(tileGroup);
|
||||||
Entities.update(fireGroup);
|
Entities.update(fireGroup);
|
||||||
|
}
|
||||||
Entities.update(playerGroup);
|
Entities.update(playerGroup);
|
||||||
|
|
||||||
//effect group only contains item transfers in the headless version, update it!
|
//effect group only contains item transfers in the headless version, update it!
|
||||||
@@ -182,15 +184,17 @@ public class Logic implements ApplicationListener{
|
|||||||
Entities.update(effectGroup);
|
Entities.update(effectGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(EntityGroup group : unitGroups){
|
if(!state.isEditor()){
|
||||||
if(group.isEmpty()) continue;
|
|
||||||
|
|
||||||
collisions.collideGroups(bulletGroup, group);
|
for(EntityGroup group : unitGroups){
|
||||||
|
if(group.isEmpty()) continue;
|
||||||
|
collisions.collideGroups(bulletGroup, group);
|
||||||
|
}
|
||||||
|
|
||||||
|
collisions.collideGroups(bulletGroup, playerGroup);
|
||||||
|
collisions.collideGroups(playerGroup, playerGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
collisions.collideGroups(bulletGroup, playerGroup);
|
|
||||||
collisions.collideGroups(playerGroup, playerGroup);
|
|
||||||
|
|
||||||
world.pathfinder.update();
|
world.pathfinder.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -187,6 +187,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
});
|
});
|
||||||
|
|
||||||
shown(() -> {
|
shown(() -> {
|
||||||
|
//clear units, rules and other unnecessary stuff
|
||||||
|
logic.reset();
|
||||||
saved = true;
|
saved = true;
|
||||||
if(!Core.settings.getBool("landscape")) Platform.instance.beginForceLandscape();
|
if(!Core.settings.getBool("landscape")) Platform.instance.beginForceLandscape();
|
||||||
editor.clearOp();
|
editor.clearOp();
|
||||||
@@ -222,7 +224,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
menu.hide();
|
menu.hide();
|
||||||
ui.loadAnd(() -> {
|
ui.loadAnd(() -> {
|
||||||
hide();
|
hide();
|
||||||
logic.reset();
|
//only reset the player; logic.reset() will clear entities, which we do not want
|
||||||
|
player.reset();
|
||||||
state.rules = Gamemode.editor.get();
|
state.rules = Gamemode.editor.get();
|
||||||
world.setMap(new Map(StringMap.of(
|
world.setMap(new Map(StringMap.of(
|
||||||
"name", "Editor Playtesting",
|
"name", "Editor Playtesting",
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
|||||||
|
|
||||||
Tile tile = world.tile(request.x, request.y);
|
Tile tile = world.tile(request.x, request.y);
|
||||||
|
|
||||||
if(dst(tile) > placeDistance){
|
if(dst(tile) > placeDistance && !state.isEditor()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void updateShooting(){
|
protected void updateShooting(){
|
||||||
if(isShooting() && mech.canShoot(this)){
|
if(!state.isEditor() && isShooting() && mech.canShoot(this)){
|
||||||
mech.weapon.update(this, pointerX, pointerY);
|
mech.weapon.update(this, pointerX, pointerY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -646,6 +646,10 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
|||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(state.isEditor()){
|
||||||
|
target = null;
|
||||||
|
}
|
||||||
|
|
||||||
float targetX = Core.camera.position.x, targetY = Core.camera.position.y;
|
float targetX = Core.camera.position.x, targetY = Core.camera.position.y;
|
||||||
float attractDst = 15f;
|
float attractDst = 15f;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public enum Gamemode{
|
|||||||
editor(true, () -> new Rules(){{
|
editor(true, () -> new Rules(){{
|
||||||
infiniteResources = true;
|
infiniteResources = true;
|
||||||
editor = true;
|
editor = true;
|
||||||
waves = true;
|
waves = false;
|
||||||
enemyCoreBuildRadius = 0f;
|
enemyCoreBuildRadius = 0f;
|
||||||
waveTimer = false;
|
waveTimer = false;
|
||||||
respawnTime = 0f;
|
respawnTime = 0f;
|
||||||
|
|||||||
@@ -7,15 +7,18 @@ import io.anuke.arc.graphics.Color;
|
|||||||
import io.anuke.arc.input.KeyCode;
|
import io.anuke.arc.input.KeyCode;
|
||||||
import io.anuke.arc.math.Interpolation;
|
import io.anuke.arc.math.Interpolation;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.scene.Element;
|
import io.anuke.arc.scene.Element;
|
||||||
import io.anuke.arc.scene.Group;
|
import io.anuke.arc.scene.Group;
|
||||||
import io.anuke.arc.scene.actions.Actions;
|
import io.anuke.arc.scene.actions.Actions;
|
||||||
import io.anuke.arc.scene.event.Touchable;
|
import io.anuke.arc.scene.event.Touchable;
|
||||||
|
import io.anuke.arc.scene.style.TextureRegionDrawable;
|
||||||
import io.anuke.arc.scene.ui.*;
|
import io.anuke.arc.scene.ui.*;
|
||||||
import io.anuke.arc.scene.ui.layout.*;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
import io.anuke.arc.scene.utils.Elements;
|
import io.anuke.arc.scene.utils.Elements;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
|
import io.anuke.mindustry.entities.type.BaseUnit;
|
||||||
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.game.UnlockableContent;
|
import io.anuke.mindustry.game.UnlockableContent;
|
||||||
@@ -24,6 +27,8 @@ import io.anuke.mindustry.graphics.Pal;
|
|||||||
import io.anuke.mindustry.input.Binding;
|
import io.anuke.mindustry.input.Binding;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.Packets.AdminAction;
|
import io.anuke.mindustry.net.Packets.AdminAction;
|
||||||
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
import io.anuke.mindustry.type.UnitType;
|
||||||
import io.anuke.mindustry.ui.*;
|
import io.anuke.mindustry.ui.*;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
|
|
||||||
@@ -173,6 +178,40 @@ public class HudFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).left();
|
}).left();
|
||||||
|
t.row();
|
||||||
|
t.addImageTextButton("$editor.spawn", "icon-add", 8*3, () -> {
|
||||||
|
FloatingDialog dialog = new FloatingDialog("$editor.spawn");
|
||||||
|
int i = 0;
|
||||||
|
for(UnitType type : content.<UnitType>getBy(ContentType.unit)){
|
||||||
|
dialog.cont.addImageButton("white", 48, () -> {
|
||||||
|
BaseUnit unit = type.create(player.getTeam());
|
||||||
|
unit.set(player.x, player.y);
|
||||||
|
unit.rotation = player.rotation;
|
||||||
|
unit.add();
|
||||||
|
//trigger the entity to become visible
|
||||||
|
unitGroups[player.getTeam().ordinal()].updateEvents();
|
||||||
|
dialog.hide();
|
||||||
|
}).get().getStyle().imageUp = new TextureRegionDrawable(type.iconRegion);
|
||||||
|
if(++i % 4 == 0) dialog.cont.row();
|
||||||
|
}
|
||||||
|
dialog.addCloseButton();
|
||||||
|
dialog.setFillParent(false);
|
||||||
|
dialog.show();
|
||||||
|
}).fillX();
|
||||||
|
|
||||||
|
t.row();
|
||||||
|
t.addImageTextButton("$editor.removeunit", "icon-quit", "toggle", 8*3, () -> {
|
||||||
|
|
||||||
|
}).fillX().update(b -> {
|
||||||
|
if(b.isChecked() && Core.input.keyTap(KeyCode.MOUSE_LEFT)){
|
||||||
|
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
||||||
|
if(e == null){
|
||||||
|
Vector2 world = Core.input.mouseWorld();
|
||||||
|
|
||||||
|
//TODO check for unit removal, remove unit if needed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}).width(dsize * 4 + 3f);
|
}).width(dsize * 4 + 3f);
|
||||||
editorMain.visible(() -> shown && state.isEditor());
|
editorMain.visible(() -> shown && state.isEditor());
|
||||||
}
|
}
|
||||||
@@ -180,7 +219,7 @@ public class HudFragment extends Fragment{
|
|||||||
//fps display
|
//fps display
|
||||||
cont.table(info -> {
|
cont.table(info -> {
|
||||||
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps"));
|
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps"));
|
||||||
info.update(() -> info.setTranslation(state.rules.waves ? 0f : -Unit.dp.scl(dsize * 4 + 3), 0));
|
info.update(() -> info.setTranslation(state.rules.waves || state.isEditor() ? 0f : -Unit.dp.scl(dsize * 4 + 3), 0));
|
||||||
IntFormat fps = new IntFormat("fps");
|
IntFormat fps = new IntFormat("fps");
|
||||||
IntFormat ping = new IntFormat("ping");
|
IntFormat ping = new IntFormat("ping");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user