More balancing, made door interacting sync properly
This commit is contained in:
@@ -261,6 +261,11 @@ public class NetClient extends Module {
|
|||||||
player.weaponLeft = (Weapon)Upgrade.getByID(packet.left);
|
player.weaponLeft = (Weapon)Upgrade.getByID(packet.left);
|
||||||
player.weaponRight = (Weapon)Upgrade.getByID(packet.right);
|
player.weaponRight = (Weapon)Upgrade.getByID(packet.right);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Net.handle(BlockTapPacket.class, packet -> {
|
||||||
|
Tile tile = Vars.world.tile(packet.position);
|
||||||
|
tile.block().tapped(tile);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -274,6 +279,12 @@ public class NetClient extends Module {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleBlockTap(Tile tile){
|
||||||
|
BlockTapPacket packet = new BlockTapPacket();
|
||||||
|
packet.position = tile.packedPosition();
|
||||||
|
Net.send(packet, SendMode.tcp);
|
||||||
|
}
|
||||||
|
|
||||||
public void handleWeaponSwitch(){
|
public void handleWeaponSwitch(){
|
||||||
WeaponSwitchPacket packet = new WeaponSwitchPacket();
|
WeaponSwitchPacket packet = new WeaponSwitchPacket();
|
||||||
packet.left = Vars.player.weaponLeft.id;
|
packet.left = Vars.player.weaponLeft.id;
|
||||||
|
|||||||
@@ -174,6 +174,13 @@ public class NetServer extends Module{
|
|||||||
|
|
||||||
Net.sendExcept(player.clientid, packet, SendMode.tcp);
|
Net.sendExcept(player.clientid, packet, SendMode.tcp);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Net.handleServer(BlockTapPacket.class, packet -> {
|
||||||
|
Tile tile = Vars.world.tile(packet.position);
|
||||||
|
tile.block().tapped(tile);
|
||||||
|
|
||||||
|
Net.sendExcept(Net.getLastConnection(), packet, SendMode.tcp);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(String message){
|
public void sendMessage(String message){
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ public class World extends Module{
|
|||||||
return currentMap.getHeight();
|
return currentMap.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Tile tile(int packed){
|
||||||
|
return tile(packed % width(), packed / width());
|
||||||
|
}
|
||||||
|
|
||||||
public Tile tile(int x, int y){
|
public Tile tile(int x, int y){
|
||||||
if(tiles == null){
|
if(tiles == null){
|
||||||
ui.showError("$text.error.crashmessage");
|
ui.showError("$text.error.crashmessage");
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
|||||||
DamageArea.damage(!(b.owner instanceof Enemy), b.x, b.y, 25f, (int)(damage * 2f/3f));
|
DamageArea.damage(!(b.owner instanceof Enemy), b.x, b.y, 25f, (int)(damage * 2f/3f));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
flak = new BulletType(3f, 8) {
|
flak = new BulletType(2.9f, 8) {
|
||||||
|
|
||||||
public void init(Bullet b) {
|
public void init(Bullet b) {
|
||||||
b.velocity.scl(Mathf.random(0.6f, 1f));
|
b.velocity.scl(Mathf.random(0.6f, 1f));
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||||
@@ -79,6 +80,11 @@ public class AndroidInput extends InputHandler{
|
|||||||
}else if(!ui.configfrag.hasConfigMouse()){
|
}else if(!ui.configfrag.hasConfigMouse()){
|
||||||
ui.configfrag.hideConfig();
|
ui.configfrag.hideConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(linked != null) {
|
||||||
|
linked.block().tapped(linked);
|
||||||
|
if(Net.active()) netClient.handleBlockTap(linked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||||
@@ -96,6 +97,11 @@ public class DesktopInput extends InputHandler{
|
|||||||
}else if(!ui.configfrag.hasConfigMouse()){
|
}else if(!ui.configfrag.hasConfigMouse()){
|
||||||
ui.configfrag.hideConfig();
|
ui.configfrag.hideConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(linked != null) {
|
||||||
|
linked.block().tapped(linked);
|
||||||
|
if(Net.active()) netClient.handleBlockTap(linked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Inputs.keyTap("break")){
|
if(Inputs.keyTap("break")){
|
||||||
|
|||||||
@@ -123,4 +123,8 @@ public class Packets {
|
|||||||
public int playerid;
|
public int playerid;
|
||||||
public byte left, right;
|
public byte left, right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class BlockTapPacket{
|
||||||
|
public int position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public class Registrator {
|
|||||||
KickPacket.class,
|
KickPacket.class,
|
||||||
UpgradePacket.class,
|
UpgradePacket.class,
|
||||||
WeaponSwitchPacket.class,
|
WeaponSwitchPacket.class,
|
||||||
|
BlockTapPacket.class,
|
||||||
|
|
||||||
Class.class,
|
Class.class,
|
||||||
byte[].class,
|
byte[].class,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class Recipes {
|
|||||||
new Recipe(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)),
|
new Recipe(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)),
|
||||||
|
|
||||||
new Recipe(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
|
new Recipe(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
|
||||||
new Recipe(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
|
new Recipe(crafting, ProductionBlocks.crucible, stack(Item.titanium, 50), stack(Item.steel, 50)),
|
||||||
new Recipe(crafting, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
|
new Recipe(crafting, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
|
||||||
new Recipe(crafting, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)),
|
new Recipe(crafting, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)),
|
||||||
new Recipe(crafting, ProductionBlocks.oilrefinery, stack(Item.steel, 15), stack(Item.iron, 15)),
|
new Recipe(crafting, ProductionBlocks.oilrefinery, stack(Item.steel, 15), stack(Item.iron, 15)),
|
||||||
@@ -60,9 +60,9 @@ public class Recipes {
|
|||||||
new Recipe(production, ProductionBlocks.stonedrill, stack(Item.stone, 12)),
|
new Recipe(production, ProductionBlocks.stonedrill, stack(Item.stone, 12)),
|
||||||
new Recipe(production, ProductionBlocks.irondrill, stack(Item.stone, 25)),
|
new Recipe(production, ProductionBlocks.irondrill, stack(Item.stone, 25)),
|
||||||
new Recipe(production, ProductionBlocks.coaldrill, stack(Item.stone, 25), stack(Item.iron, 40)),
|
new Recipe(production, ProductionBlocks.coaldrill, stack(Item.stone, 25), stack(Item.iron, 40)),
|
||||||
new Recipe(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 40), stack(Item.steel, 50)),
|
new Recipe(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 50), stack(Item.steel, 50)),
|
||||||
new Recipe(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)),
|
new Recipe(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)),
|
||||||
new Recipe(production, ProductionBlocks.omnidrill, stack(Item.titanium, 30), stack(Item.dirium, 40)),
|
new Recipe(production, ProductionBlocks.omnidrill, stack(Item.titanium, 40), stack(Item.dirium, 40)),
|
||||||
|
|
||||||
new Recipe(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
|
new Recipe(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
|
||||||
new Recipe(power, ProductionBlocks.thermalgenerator, stack(Item.steel, 30), stack(Item.iron, 30)),
|
new Recipe(power, ProductionBlocks.thermalgenerator, stack(Item.steel, 30), stack(Item.iron, 30)),
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ public class Block{
|
|||||||
public void drawPlace(int x, int y, int rotation, boolean valid){}
|
public void drawPlace(int x, int y, int rotation, boolean valid){}
|
||||||
public void postInit(){}
|
public void postInit(){}
|
||||||
public void placed(Tile tile){}
|
public void placed(Tile tile){}
|
||||||
|
public void tapped(Tile tile){}
|
||||||
|
|
||||||
public void getStats(Array<String> list){
|
public void getStats(Array<String> list){
|
||||||
list.add("[gray]size: " + width + "x" + height);
|
list.add("[gray]size: " + width + "x" + height);
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ public class ProductionBlocks{
|
|||||||
weaponFactory = new WeaponFactory("weaponfactory"){
|
weaponFactory = new WeaponFactory("weaponfactory"){
|
||||||
{
|
{
|
||||||
width = height = 2;
|
width = height = 2;
|
||||||
|
health = 250;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,10 +102,10 @@ public class WeaponBlocks{
|
|||||||
shootsound = "bigshot";
|
shootsound = "bigshot";
|
||||||
rotatespeed = 0.2f;
|
rotatespeed = 0.2f;
|
||||||
range = 120;
|
range = 120;
|
||||||
reload = 65f;
|
reload = 70f;
|
||||||
bullet = BulletType.flak;
|
bullet = BulletType.flak;
|
||||||
shots = 3;
|
shots = 3;
|
||||||
inaccuracy = 8f;
|
inaccuracy = 9f;
|
||||||
ammo = Item.coal;
|
ammo = Item.coal;
|
||||||
ammoMultiplier = 5;
|
ammoMultiplier = 5;
|
||||||
health = 110;
|
health = 110;
|
||||||
|
|||||||
@@ -1,30 +1,28 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.defense;
|
package io.anuke.mindustry.world.blocks.types.defense;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
|
||||||
import io.anuke.mindustry.world.blocks.types.Wall;
|
import io.anuke.mindustry.world.blocks.types.Wall;
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
import io.anuke.ucore.core.Effects.Effect;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
import io.anuke.ucore.entities.SolidEntity;
|
import io.anuke.ucore.entities.SolidEntity;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
|
||||||
import io.anuke.ucore.util.Tmp;
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
public class Door extends Wall implements Configurable{
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.player;
|
||||||
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
|
public class Door extends Wall{
|
||||||
protected Effect openfx = Fx.dooropen;
|
protected Effect openfx = Fx.dooropen;
|
||||||
protected Effect closefx = Fx.doorclose;
|
protected Effect closefx = Fx.doorclose;
|
||||||
|
|
||||||
@@ -54,7 +52,7 @@ public class Door extends Wall implements Configurable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildTable(Tile tile, Table table){
|
public void tapped(Tile tile){
|
||||||
DoorEntity entity = tile.entity();
|
DoorEntity entity = tile.entity();
|
||||||
|
|
||||||
if(anyEntities(tile) && entity.open){
|
if(anyEntities(tile) && entity.open){
|
||||||
|
|||||||
Reference in New Issue
Block a user