Local multiplayer initial commit

This commit is contained in:
Anuken
2018-05-11 07:59:10 -07:00
parent 90b9ba71de
commit 959f756ff5
11 changed files with 350 additions and 299 deletions

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetEvents;
import io.anuke.mindustry.resource.ItemStack;
@@ -26,7 +27,8 @@ public class AndroidInput extends InputHandler{
private float warmup;
private float warmupDelay = 20;
public AndroidInput(){
public AndroidInput(Player player){
super(player);
Inputs.addProcessor(new GestureDetector(20, 0.5f, 2, 0.15f, new GestureHandler(this)));
}

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.input;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetEvents;
import io.anuke.mindustry.resource.Weapon;
@@ -23,7 +24,10 @@ public class DesktopInput extends InputHandler{
float endx, endy;
private boolean enableHold = false;
private boolean beganBreak;
private boolean rotated = false, rotatedAlt, zoomed;
public DesktopInput(Player player){
super(player);
}
@Override public float getCursorEndX(){ return endx; }
@Override public float getCursorEndY(){ return endy; }
@@ -75,27 +79,13 @@ public class DesktopInput extends InputHandler{
if(Inputs.getAxisActive("zoom") && (Inputs.keyDown("zoom_hold") || controller)
&& !state.is(State.menu) && !ui.hasDialog()){
if((!zoomed || !controller)) {
renderer.scaleCamera((int) Inputs.getAxis("zoom"));
}
zoomed = true;
}else{
zoomed = false;
renderer.scaleCamera((int) Inputs.getAxisTapped("zoom"));
}
renderer.minimap().zoomBy(-(int)Inputs.getAxisTapped("zoom_minimap"));
if(!rotated) {
rotation += Inputs.getAxis("rotate_alt");
rotated = true;
}
if(!Inputs.getAxisActive("rotate_alt")) rotated = false;
if(!rotatedAlt) {
rotation += Inputs.getAxis("rotate");
rotatedAlt = true;
}
if(!Inputs.getAxisActive("rotate")) rotatedAlt = false;
rotation += Inputs.getAxisTapped("rotate_alt");
rotation += Inputs.getAxis("rotate");
rotation = Mathf.mod(rotation, 4);
@@ -192,7 +182,7 @@ public class DesktopInput extends InputHandler{
}
if(recipe != null){
showCursor = validPlace(tilex(), tiley(), control.input().recipe.result) && control.input().cursorNear();
showCursor = validPlace(tilex(), tiley(), recipe.result) && cursorNear();
}
if(canBeginShoot){

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.entities.ItemAnimationEffect;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetEvents;
import io.anuke.mindustry.resource.ItemStack;
@@ -25,6 +26,7 @@ public abstract class InputHandler extends InputAdapter{
public float breaktime = 0;
public Recipe recipe;
public int rotation;
public Player player;
public PlaceMode placeMode = mobile ? PlaceMode.cursor : PlaceMode.hold;
public PlaceMode breakMode = mobile ? PlaceMode.none : PlaceMode.holdDelete;
public PlaceMode lastPlaceMode = placeMode;
@@ -35,6 +37,10 @@ public abstract class InputHandler extends InputAdapter{
private Translator stackTrns = new Translator();
public InputHandler(Player player){
this.player = player;
}
public abstract void update();
public abstract float getCursorX();
public abstract float getCursorY();