Better unit control effects
This commit is contained in:
@@ -11,6 +11,7 @@ public enum Binding implements KeyBind{
|
||||
move_y(new Axis(KeyCode.S, KeyCode.W)),
|
||||
mouse_move(KeyCode.MOUSE_BACK),
|
||||
dash(KeyCode.SHIFT_LEFT),
|
||||
control(KeyCode.ALT_LEFT),
|
||||
select(KeyCode.MOUSE_LEFT),
|
||||
deselect(KeyCode.MOUSE_RIGHT),
|
||||
break_block(KeyCode.MOUSE_RIGHT),
|
||||
|
||||
@@ -174,13 +174,10 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(!scene.hasMouse()){
|
||||
if(Core.input.keyTap(Binding.select)){
|
||||
Unitc unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, u -> true);
|
||||
if(unit != null){
|
||||
unit.hitbox(Tmp.r1);
|
||||
if(Tmp.r1.contains(Core.input.mouseWorld())){
|
||||
Call.onUnitControl(player, unit);
|
||||
}
|
||||
if(Core.input.keyDown(Binding.control) && Core.input.keyTap(Binding.select)){
|
||||
Unitc on = selectedUnit();
|
||||
if(on != null){
|
||||
Call.onUnitControl(player, on);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,6 +175,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
//make sure it's AI controlled, so players can't overwrite each other
|
||||
}else if(unit.isAI() && unit.team() == player.team()){
|
||||
player.unit(unit);
|
||||
Time.run(Fx.unitSpirit.lifetime, () -> Fx.unitControl.at(unit.x(), unit.y(), 0f, unit));
|
||||
if(!player.dead()){
|
||||
Fx.unitSpirit.at(player.x(), player.y(), 0f, unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,6 +710,18 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
return Core.input.mouseWorld(getMouseX(), getMouseY()).sub(x, y).angle();
|
||||
}
|
||||
|
||||
public @Nullable Unitc selectedUnit(){
|
||||
Unitc unit = Units.closest(player.team(), Core.input.mouseWorld().x, Core.input.mouseWorld().y, 40f, Unitc::isAI);
|
||||
if(unit != null){
|
||||
unit.hitbox(Tmp.r1);
|
||||
Tmp.r1.grow(6f);
|
||||
if(Tmp.r1.contains(Core.input.mouseWorld())){
|
||||
return unit;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
Core.input.removeProcessor(this);
|
||||
frag.remove();
|
||||
|
||||
Reference in New Issue
Block a user