mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-04 15:27:19 +07:00
Unit creation, team switch
This commit is contained in:
@ -216,6 +216,8 @@ waves.copied = Waves copied.
|
||||
editor.default = [LIGHT_GRAY]<Default>
|
||||
edit = Edit...
|
||||
editor.name = Name:
|
||||
editor.spawn = Spawn Unit
|
||||
editor.removeunit = Remove Unit
|
||||
editor.teams = Teams
|
||||
editor.elevation = Elevation
|
||||
editor.errorload = Error loading file:\n[accent]{0}
|
||||
|
@ -166,15 +166,17 @@ public class Logic implements ApplicationListener{
|
||||
Entities.update(groundEffectGroup);
|
||||
}
|
||||
|
||||
for(EntityGroup group : unitGroups){
|
||||
Entities.update(group);
|
||||
}
|
||||
if(!state.isEditor()){
|
||||
for(EntityGroup group : unitGroups){
|
||||
Entities.update(group);
|
||||
}
|
||||
|
||||
Entities.update(puddleGroup);
|
||||
Entities.update(shieldGroup);
|
||||
Entities.update(bulletGroup);
|
||||
Entities.update(tileGroup);
|
||||
Entities.update(fireGroup);
|
||||
Entities.update(puddleGroup);
|
||||
Entities.update(shieldGroup);
|
||||
Entities.update(bulletGroup);
|
||||
Entities.update(tileGroup);
|
||||
Entities.update(fireGroup);
|
||||
}
|
||||
Entities.update(playerGroup);
|
||||
|
||||
//effect group only contains item transfers in the headless version, update it!
|
||||
@ -182,15 +184,17 @@ public class Logic implements ApplicationListener{
|
||||
Entities.update(effectGroup);
|
||||
}
|
||||
|
||||
for(EntityGroup group : unitGroups){
|
||||
if(group.isEmpty()) continue;
|
||||
if(!state.isEditor()){
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -187,6 +187,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
});
|
||||
|
||||
shown(() -> {
|
||||
//clear units, rules and other unnecessary stuff
|
||||
logic.reset();
|
||||
saved = true;
|
||||
if(!Core.settings.getBool("landscape")) Platform.instance.beginForceLandscape();
|
||||
editor.clearOp();
|
||||
@ -222,7 +224,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
menu.hide();
|
||||
ui.loadAnd(() -> {
|
||||
hide();
|
||||
logic.reset();
|
||||
//only reset the player; logic.reset() will clear entities, which we do not want
|
||||
player.reset();
|
||||
state.rules = Gamemode.editor.get();
|
||||
world.setMap(new Map(StringMap.of(
|
||||
"name", "Editor Playtesting",
|
||||
|
@ -292,7 +292,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
||||
|
||||
Tile tile = world.tile(request.x, request.y);
|
||||
|
||||
if(dst(tile) > placeDistance){
|
||||
if(dst(tile) > placeDistance && !state.isEditor()){
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -636,7 +636,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
||||
}
|
||||
|
||||
protected void updateShooting(){
|
||||
if(isShooting() && mech.canShoot(this)){
|
||||
if(!state.isEditor() && isShooting() && mech.canShoot(this)){
|
||||
mech.weapon.update(this, pointerX, pointerY);
|
||||
}
|
||||
}
|
||||
@ -646,6 +646,10 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
||||
target = null;
|
||||
}
|
||||
|
||||
if(state.isEditor()){
|
||||
target = null;
|
||||
}
|
||||
|
||||
float targetX = Core.camera.position.x, targetY = Core.camera.position.y;
|
||||
float attractDst = 15f;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public enum Gamemode{
|
||||
editor(true, () -> new Rules(){{
|
||||
infiniteResources = true;
|
||||
editor = true;
|
||||
waves = true;
|
||||
waves = false;
|
||||
enemyCoreBuildRadius = 0f;
|
||||
waveTimer = false;
|
||||
respawnTime = 0f;
|
||||
|
@ -7,15 +7,18 @@ import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.math.Interpolation;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.Group;
|
||||
import io.anuke.arc.scene.actions.Actions;
|
||||
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.layout.*;
|
||||
import io.anuke.arc.scene.utils.Elements;
|
||||
import io.anuke.arc.util.*;
|
||||
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.Team;
|
||||
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.net.Net;
|
||||
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.dialogs.FloatingDialog;
|
||||
|
||||
@ -173,6 +178,40 @@ public class HudFragment extends Fragment{
|
||||
}
|
||||
}
|
||||
}).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);
|
||||
editorMain.visible(() -> shown && state.isEditor());
|
||||
}
|
||||
@ -180,7 +219,7 @@ public class HudFragment extends Fragment{
|
||||
//fps display
|
||||
cont.table(info -> {
|
||||
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 ping = new IntFormat("ping");
|
||||
|
||||
|
Reference in New Issue
Block a user