mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-08 21:36:45 +00:00
Fixed some debug commands. Added blueprint item deserialization, Added inventory SCAN and SEEK actions
This commit is contained in:
parent
71e88afdc9
commit
5de909cd9c
Plugin Cubot/src/main/java/net/simon987/cubotplugin
Plugin Misc HW/src/main/java/net/simon987/mischwplugin
Plugin NPC/src/main/java/net/simon987/npcplugin
Plugin Plant/src/main/java/net/simon987/biomassplugin
Plugin Radioactive Cloud/src/main/java/net/simon987/pluginradioactivecloud
Server/src/main
plugin-contruction/src/main/java/net/simon987/constructionplugin
@ -21,12 +21,14 @@ public class CubotInventory extends CubotHardwareModule {
|
|||||||
|
|
||||||
private static final int INV_CLEAR = 0;
|
private static final int INV_CLEAR = 0;
|
||||||
private static final int INV_POLL = 1;
|
private static final int INV_POLL = 1;
|
||||||
|
private static final int INV_SEEK = 2;
|
||||||
|
private static final int INV_SCAN = 3;
|
||||||
|
|
||||||
private int inventorySize = 4;
|
private int inventorySize = 4; //TODO: load from config
|
||||||
|
|
||||||
private Map<Integer, Item> inventory;
|
private Map<Integer, Item> inventory;
|
||||||
private int position = 0;
|
private int position = 0;
|
||||||
|
|
||||||
|
|
||||||
public CubotInventory(Cubot cubot) {
|
public CubotInventory(Cubot cubot) {
|
||||||
super(cubot);
|
super(cubot);
|
||||||
|
|
||||||
@ -51,7 +53,13 @@ public class CubotInventory extends CubotHardwareModule {
|
|||||||
inventory.put(position, item);
|
inventory.put(position, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item popItem() {
|
private void scanItem() {
|
||||||
|
int x = getCpu().getRegisterSet().getRegister("X").getValue();
|
||||||
|
Item item = inventory.get(position);
|
||||||
|
item.digitize(cubot.getCpu().getMemory(), x);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item clearItem() {
|
||||||
Item item = inventory.get(position);
|
Item item = inventory.get(position);
|
||||||
item.clear(cubot);
|
item.clear(cubot);
|
||||||
inventory.remove(position);
|
inventory.remove(position);
|
||||||
@ -92,7 +100,16 @@ public class CubotInventory extends CubotHardwareModule {
|
|||||||
getCpu().getRegisterSet().getRegister("B").setValue(result);
|
getCpu().getRegisterSet().getRegister("B").setValue(result);
|
||||||
|
|
||||||
} else if (a == INV_CLEAR) {
|
} else if (a == INV_CLEAR) {
|
||||||
popItem();
|
if (cubot.spendEnergy(100)) {
|
||||||
|
clearItem();
|
||||||
|
}
|
||||||
|
} else if (a == INV_SEEK) {
|
||||||
|
setPosition(getCpu().getRegisterSet().getRegister("X").getValue());
|
||||||
|
} else if (a == INV_SCAN) {
|
||||||
|
if (cubot.spendEnergy(200)) {
|
||||||
|
scanItem();
|
||||||
|
clearItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.simon987.cubotplugin;
|
package net.simon987.cubotplugin;
|
||||||
|
|
||||||
import net.simon987.cubotplugin.event.*;
|
import net.simon987.cubotplugin.event.*;
|
||||||
import net.simon987.server.ServerConfiguration;
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.game.objects.GameRegistry;
|
import net.simon987.server.game.objects.GameRegistry;
|
||||||
import net.simon987.server.logging.LogManager;
|
import net.simon987.server.logging.LogManager;
|
||||||
import net.simon987.server.plugin.ServerPlugin;
|
import net.simon987.server.plugin.ServerPlugin;
|
||||||
@ -10,7 +10,7 @@ public class CubotPlugin extends ServerPlugin {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ServerConfiguration config, GameRegistry registry) {
|
public void init(GameServer gameServer) {
|
||||||
listeners.add(new CpuInitialisationListener());
|
listeners.add(new CpuInitialisationListener());
|
||||||
listeners.add(new UserCreationListener());
|
listeners.add(new UserCreationListener());
|
||||||
//Debug commands
|
//Debug commands
|
||||||
@ -19,6 +19,8 @@ public class CubotPlugin extends ServerPlugin {
|
|||||||
listeners.add(new PutItemCommandListener());
|
listeners.add(new PutItemCommandListener());
|
||||||
listeners.add(new PopItemCommandListener());
|
listeners.add(new PopItemCommandListener());
|
||||||
|
|
||||||
|
GameRegistry registry = gameServer.getRegistry();
|
||||||
|
|
||||||
registry.registerGameObject(Cubot.class);
|
registry.registerGameObject(Cubot.class);
|
||||||
|
|
||||||
registry.registerHardware(CubotLeg.class);
|
registry.registerHardware(CubotLeg.class);
|
||||||
|
@ -20,7 +20,7 @@ public class PopItemCommandListener implements GameEventListener {
|
|||||||
|
|
||||||
DebugCommandEvent e = (DebugCommandEvent) event;
|
DebugCommandEvent e = (DebugCommandEvent) event;
|
||||||
|
|
||||||
if (e.getName().equals("popItem")) {
|
if (e.getName().equals("clearItem")) {
|
||||||
|
|
||||||
GameObject object = GameServer.INSTANCE.getGameUniverse().getObject(e.getObjectId("objectId"));
|
GameObject object = GameServer.INSTANCE.getGameUniverse().getObject(e.getObjectId("objectId"));
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class PopItemCommandListener implements GameEventListener {
|
|||||||
|
|
||||||
CubotInventory inventory = (CubotInventory) ((Cubot) object).getHardware(CubotInventory.class);
|
CubotInventory inventory = (CubotInventory) ((Cubot) object).getHardware(CubotInventory.class);
|
||||||
|
|
||||||
e.reply("Removed item from inventory: " + inventory.popItem());
|
e.reply("Removed item from inventory: " + inventory.clearItem());
|
||||||
} else {
|
} else {
|
||||||
e.reply("Object is not a Cubot");
|
e.reply("Object is not a Cubot");
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.simon987.mischwplugin;
|
package net.simon987.mischwplugin;
|
||||||
|
|
||||||
import net.simon987.mischwplugin.event.CpuInitialisationListener;
|
import net.simon987.mischwplugin.event.CpuInitialisationListener;
|
||||||
import net.simon987.server.ServerConfiguration;
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.game.objects.GameRegistry;
|
import net.simon987.server.game.objects.GameRegistry;
|
||||||
import net.simon987.server.logging.LogManager;
|
import net.simon987.server.logging.LogManager;
|
||||||
import net.simon987.server.plugin.ServerPlugin;
|
import net.simon987.server.plugin.ServerPlugin;
|
||||||
@ -13,9 +13,11 @@ public class MiscHWPlugin extends ServerPlugin {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ServerConfiguration config, GameRegistry registry) {
|
public void init(GameServer gameServer) {
|
||||||
listeners.add(new CpuInitialisationListener());
|
listeners.add(new CpuInitialisationListener());
|
||||||
|
|
||||||
|
GameRegistry registry = gameServer.getRegistry();
|
||||||
|
|
||||||
registry.registerHardware(RandomNumberGenerator.class);
|
registry.registerHardware(RandomNumberGenerator.class);
|
||||||
registry.registerHardware(Clock.class);
|
registry.registerHardware(Clock.class);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import net.simon987.npcplugin.event.VaultWorldUpdateListener;
|
|||||||
import net.simon987.npcplugin.event.WorldCreationListener;
|
import net.simon987.npcplugin.event.WorldCreationListener;
|
||||||
import net.simon987.npcplugin.world.TileVaultFloor;
|
import net.simon987.npcplugin.world.TileVaultFloor;
|
||||||
import net.simon987.npcplugin.world.TileVaultWall;
|
import net.simon987.npcplugin.world.TileVaultWall;
|
||||||
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.ServerConfiguration;
|
import net.simon987.server.ServerConfiguration;
|
||||||
import net.simon987.server.game.objects.GameRegistry;
|
import net.simon987.server.game.objects.GameRegistry;
|
||||||
import net.simon987.server.logging.LogManager;
|
import net.simon987.server.logging.LogManager;
|
||||||
@ -21,7 +22,10 @@ public class NpcPlugin extends ServerPlugin {
|
|||||||
private static ArrayList<RadioTower> radioTowers;
|
private static ArrayList<RadioTower> radioTowers;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ServerConfiguration configuration, GameRegistry registry) {
|
public void init(GameServer gameServer) {
|
||||||
|
|
||||||
|
ServerConfiguration configuration = gameServer.getConfig();
|
||||||
|
GameRegistry registry = gameServer.getRegistry();
|
||||||
|
|
||||||
listeners.add(new WorldCreationListener(configuration.getInt("factory_spawn_rate")));
|
listeners.add(new WorldCreationListener(configuration.getInt("factory_spawn_rate")));
|
||||||
listeners.add(new CpuInitialisationListener());
|
listeners.add(new CpuInitialisationListener());
|
||||||
|
@ -3,6 +3,7 @@ package net.simon987.biomassplugin;
|
|||||||
import net.simon987.biomassplugin.event.ObjectDeathListener;
|
import net.simon987.biomassplugin.event.ObjectDeathListener;
|
||||||
import net.simon987.biomassplugin.event.WorldCreationListener;
|
import net.simon987.biomassplugin.event.WorldCreationListener;
|
||||||
import net.simon987.biomassplugin.event.WorldUpdateListener;
|
import net.simon987.biomassplugin.event.WorldUpdateListener;
|
||||||
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.ServerConfiguration;
|
import net.simon987.server.ServerConfiguration;
|
||||||
import net.simon987.server.game.objects.GameRegistry;
|
import net.simon987.server.game.objects.GameRegistry;
|
||||||
import net.simon987.server.logging.LogManager;
|
import net.simon987.server.logging.LogManager;
|
||||||
@ -13,7 +14,10 @@ public class BiomassPlugin extends ServerPlugin {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ServerConfiguration config, GameRegistry registry) {
|
public void init(GameServer gameServer) {
|
||||||
|
|
||||||
|
ServerConfiguration config = gameServer.getConfig();
|
||||||
|
GameRegistry registry = gameServer.getRegistry();
|
||||||
|
|
||||||
listeners.add(new WorldCreationListener());
|
listeners.add(new WorldCreationListener());
|
||||||
listeners.add(new WorldUpdateListener(config));
|
listeners.add(new WorldUpdateListener(config));
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package net.simon987.pluginradioactivecloud;
|
package net.simon987.pluginradioactivecloud;
|
||||||
|
|
||||||
import net.simon987.server.ServerConfiguration;
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.game.objects.GameRegistry;
|
|
||||||
import net.simon987.server.logging.LogManager;
|
import net.simon987.server.logging.LogManager;
|
||||||
import net.simon987.server.plugin.ServerPlugin;
|
import net.simon987.server.plugin.ServerPlugin;
|
||||||
|
|
||||||
public class RadioactiveCloudPlugin extends ServerPlugin {
|
public class RadioactiveCloudPlugin extends ServerPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(ServerConfiguration config, GameRegistry registry) {
|
public void init(GameServer gameServer) {
|
||||||
|
|
||||||
LogManager.LOGGER.info("(Radioactive cloud Plugin) Initialised Radioactive cloud plugin.");
|
LogManager.LOGGER.info("(Radioactive cloud Plugin) Initialised Radioactive cloud plugin.");
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ public class GameServer implements Runnable {
|
|||||||
gameUniverse = new GameUniverse(config);
|
gameUniverse = new GameUniverse(config);
|
||||||
gameUniverse.setMongo(mongo);
|
gameUniverse.setMongo(mongo);
|
||||||
gameRegistry = new GameRegistry();
|
gameRegistry = new GameRegistry();
|
||||||
pluginManager = new PluginManager(config, gameRegistry);
|
pluginManager = new PluginManager(this);
|
||||||
|
|
||||||
maxExecutionTime = config.getInt("user_timeout");
|
maxExecutionTime = config.getInt("user_timeout");
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package net.simon987.server.crypto;
|
package net.simon987.server.crypto;
|
||||||
|
|
||||||
interface Cypher {
|
public interface Cypher {
|
||||||
|
|
||||||
char[] encrypt(char[] plainText, char[] key) throws CryptoException;
|
char[] encrypt(char[] plainText, char[] key) throws CryptoException;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class DebugCommandEvent extends GameEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ObjectId getObjectId(String key) {
|
public ObjectId getObjectId(String key) {
|
||||||
return (ObjectId) command.get(key);
|
return new ObjectId((String) command.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.simon987.server.game.item;
|
package net.simon987.server.game.item;
|
||||||
|
|
||||||
|
import net.simon987.server.assembly.Memory;
|
||||||
import net.simon987.server.game.objects.ControllableUnit;
|
import net.simon987.server.game.objects.ControllableUnit;
|
||||||
import net.simon987.server.io.JSONSerializable;
|
import net.simon987.server.io.JSONSerializable;
|
||||||
import net.simon987.server.io.MongoSerializable;
|
import net.simon987.server.io.MongoSerializable;
|
||||||
@ -27,6 +28,15 @@ public abstract class Item implements JSONSerializable, MongoSerializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the item is scanned
|
||||||
|
*
|
||||||
|
* @param memory result is written here
|
||||||
|
*/
|
||||||
|
public void digitize(Memory memory, int offset) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to uniquely identify an item type in the database and in the game
|
* Used to uniquely identify an item type in the database and in the game
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.simon987.server.plugin;
|
package net.simon987.server.plugin;
|
||||||
|
|
||||||
import net.simon987.server.ServerConfiguration;
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.game.objects.GameRegistry;
|
|
||||||
import net.simon987.server.logging.LogManager;
|
import net.simon987.server.logging.LogManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -21,12 +20,11 @@ public class PluginManager {
|
|||||||
|
|
||||||
private ArrayList<ServerPlugin> loadedPlugins;
|
private ArrayList<ServerPlugin> loadedPlugins;
|
||||||
private ArrayList<ServerPlugin> toLoadPlugins;
|
private ArrayList<ServerPlugin> toLoadPlugins;
|
||||||
private ServerConfiguration config;
|
|
||||||
private GameRegistry gameRegistry;
|
|
||||||
|
|
||||||
public PluginManager(ServerConfiguration config, GameRegistry registry) {
|
private GameServer gameServer;
|
||||||
this.config = config;
|
|
||||||
this.gameRegistry = registry;
|
public PluginManager(GameServer gameServer) {
|
||||||
|
this.gameServer = gameServer;
|
||||||
this.toLoadPlugins = new ArrayList<>(10);
|
this.toLoadPlugins = new ArrayList<>(10);
|
||||||
this.loadedPlugins = new ArrayList<>(10);
|
this.loadedPlugins = new ArrayList<>(10);
|
||||||
}
|
}
|
||||||
@ -162,7 +160,7 @@ public class PluginManager {
|
|||||||
|
|
||||||
toLoadPlugins.remove(plugin);
|
toLoadPlugins.remove(plugin);
|
||||||
loadedPlugins.add(plugin);
|
loadedPlugins.add(plugin);
|
||||||
plugin.init(config, gameRegistry);
|
plugin.init(gameServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ServerPlugin> getPlugins() {
|
public ArrayList<ServerPlugin> getPlugins() {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package net.simon987.server.plugin;
|
package net.simon987.server.plugin;
|
||||||
|
|
||||||
import net.simon987.server.ServerConfiguration;
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.event.GameEventListener;
|
import net.simon987.server.event.GameEventListener;
|
||||||
import net.simon987.server.game.objects.GameRegistry;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -29,7 +28,7 @@ public abstract class ServerPlugin {
|
|||||||
/**
|
/**
|
||||||
* Called when the plugin is loaded
|
* Called when the plugin is loaded
|
||||||
*/
|
*/
|
||||||
public abstract void init(ServerConfiguration config, GameRegistry gameRegistry);
|
public abstract void init(GameServer gameServer);
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
|
@ -28,6 +28,7 @@ public class UserInfoRequestHandler implements MessageHandler {
|
|||||||
json.put("worldX", object.getWorld().getX());
|
json.put("worldX", object.getWorld().getX());
|
||||||
json.put("worldY", object.getWorld().getY());
|
json.put("worldY", object.getWorld().getY());
|
||||||
json.put("dimension", object.getWorld().getDimension());
|
json.put("dimension", object.getWorld().getDimension());
|
||||||
|
json.put("id", object.getObjectId().toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ mar_address=ws://localhost:4567/socket
|
|||||||
server_name=MAR dev
|
server_name=MAR dev
|
||||||
# ALLOW | BLOCK
|
# ALLOW | BLOCK
|
||||||
guest_policy=ALLOW
|
guest_policy=ALLOW
|
||||||
|
# DEBUG
|
||||||
|
autologin=simon
|
||||||
|
|
||||||
#Database
|
#Database
|
||||||
mongo_dbname=mar_beta
|
mongo_dbname=mar_beta
|
||||||
|
234
Server/src/main/resources/static/js/mar.js
vendored
234
Server/src/main/resources/static/js/mar.js
vendored
@ -264,43 +264,66 @@ var RENDERER_WIDTH = document.getElementById("game").clientWidth * window.device
|
|||||||
var RENDERER_HEIGHT = (window.innerHeight / 1.40) * window.devicePixelRatio;
|
var RENDERER_HEIGHT = (window.innerHeight / 1.40) * window.devicePixelRatio;
|
||||||
var DEBUG = true;
|
var DEBUG = true;
|
||||||
var config = {
|
var config = {
|
||||||
portalTint: 0xff43c8,
|
kbBuffer: {
|
||||||
tileTint: 0xFFFFFF,
|
x: 350,
|
||||||
wallTint: 0xDDDDDD,
|
y: 35,
|
||||||
vaultWallTint: 0x3F2D2A,
|
},
|
||||||
vaultFloorTint: 0x2B1E1C,
|
cubot: {
|
||||||
fluidTint: 0x0ACED6,
|
tint: 0xFFFFFF,
|
||||||
oreTint: 0xF3F3F3,
|
hoverTint: 0x00FF00,
|
||||||
cubotHoverTint: 0x00FF00,
|
lowEnergyTint: 0xCC0000,
|
||||||
cubotTint: 0xFFFFFF,
|
walkDuration: 800,
|
||||||
textFill: "#FFFFFF",
|
lowEnergy: 100,
|
||||||
textStroke: "#9298a8",
|
otherCubotAlpha: 0.6,
|
||||||
biomassTint: 0x63B85F,
|
},
|
||||||
biomassHoverTint: 0x00FF00,
|
biomass: {
|
||||||
tileHoverTint: 0x00FF00,
|
tint: 0x63B85F,
|
||||||
itemIron: 0x434341,
|
tintHover: 0x00FF00,
|
||||||
textIron: "#434341",
|
},
|
||||||
itemCopper: 0xC87D38,
|
tile: {
|
||||||
textCopper: "#C87D38",
|
hover: 0x00FF00,
|
||||||
hologramFill: "#0aced6",
|
vaultWall: 0x3F2D2A,
|
||||||
hologramStroke: "#12FFB0",
|
vaultFloor: 0x2B1E1C,
|
||||||
copperFill: "#C87D38",
|
fluid: 0x0ACED6,
|
||||||
plainSprite: "tiles/tile",
|
ore: 0xF3F3F3,
|
||||||
magneticSprite: "tiles/magneticTile",
|
plain: 0xFFFFFF,
|
||||||
wallSprite: "tiles/bigTile",
|
wall: 0xDDDDDD,
|
||||||
wallSprite2: "tiles/bigTile2",
|
plainSprite: "tiles/tile",
|
||||||
walkDuration: 800,
|
magneticSprite: "tiles/magneticTile",
|
||||||
holoStyle: function (fill) {
|
wallSprite: "tiles/bigTile",
|
||||||
return {
|
wallSprite2: "tiles/bigTile2",
|
||||||
fontSize: 32,
|
},
|
||||||
fill: fill ? fill : config.hologramFill,
|
item: {
|
||||||
stroke: config.hologramStroke,
|
ironColor: 0x434341,
|
||||||
strokeThickness: 1,
|
copperColor: 0xC87D38,
|
||||||
font: "fixedsys"
|
blueprintColor: 0xaced6,
|
||||||
};
|
},
|
||||||
|
portal: {
|
||||||
|
tint: 0xff43c8,
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
textFill: "#FFFFFF",
|
||||||
|
textStroke: "#9298a8",
|
||||||
|
textIron: "#434341",
|
||||||
|
textCopper: "#C87D38",
|
||||||
|
hologramFill: "#0aced6",
|
||||||
|
hologramStroke: "#12FFB0",
|
||||||
|
selfUsername: 0xFB4D0A,
|
||||||
|
bigMessageFill: "#ff803d",
|
||||||
|
holoStyle: function (fill) {
|
||||||
|
return {
|
||||||
|
fontSize: 32,
|
||||||
|
fill: fill ? fill : config.text.hologramFill,
|
||||||
|
stroke: config.text.hologramStroke,
|
||||||
|
strokeThickness: 1,
|
||||||
|
font: "fixedsys"
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
arrow: {
|
||||||
|
tint: 0xFFFFFF,
|
||||||
|
tintHover: 0x00FF00,
|
||||||
},
|
},
|
||||||
kbBufferX: 350,
|
|
||||||
kbBufferY: 35,
|
|
||||||
arrowTextStyle: {
|
arrowTextStyle: {
|
||||||
fontSize: 32,
|
fontSize: 32,
|
||||||
fill: "#ffffff",
|
fill: "#ffffff",
|
||||||
@ -308,14 +331,9 @@ var config = {
|
|||||||
strokeThickness: 1,
|
strokeThickness: 1,
|
||||||
font: "fixedsys"
|
font: "fixedsys"
|
||||||
},
|
},
|
||||||
lowEnergy: 100,
|
world: {
|
||||||
lowEnergyTint: 0xCC0000,
|
defaultSize: 16
|
||||||
bigMessageFill: "#ff803d",
|
}
|
||||||
arrowTint: 0xFFFFFF,
|
|
||||||
arrowHoverTint: 0x00FF00,
|
|
||||||
selfUsernameColor: 0xFB4D0A,
|
|
||||||
otherCubotAlpha: 0.6,
|
|
||||||
defaultWorldSize: 16
|
|
||||||
};
|
};
|
||||||
var Util = (function () {
|
var Util = (function () {
|
||||||
function Util() {
|
function Util() {
|
||||||
@ -351,11 +369,13 @@ var Util = (function () {
|
|||||||
Util.itemColor = function (item) {
|
Util.itemColor = function (item) {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case 1:
|
case 1:
|
||||||
return config.biomassTint;
|
return config.biomass.tint;
|
||||||
case 3:
|
case 3:
|
||||||
return config.itemIron;
|
return config.item.ironColor;
|
||||||
case 4:
|
case 4:
|
||||||
return config.itemCopper;
|
return config.item.copperColor;
|
||||||
|
case 5:
|
||||||
|
return config.item.blueprintColor;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return Util;
|
return Util;
|
||||||
@ -463,6 +483,7 @@ var Debug = (function () {
|
|||||||
position: position
|
position: position
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Debug.SELF_ID = "";
|
||||||
return Debug;
|
return Debug;
|
||||||
}());
|
}());
|
||||||
DEBUG = false;
|
DEBUG = false;
|
||||||
@ -537,6 +558,7 @@ var UserInfoListener = (function () {
|
|||||||
mar.client.worldX = message.worldX;
|
mar.client.worldX = message.worldX;
|
||||||
mar.client.worldY = message.worldY;
|
mar.client.worldY = message.worldY;
|
||||||
mar.client.dimension = message.dimension;
|
mar.client.dimension = message.dimension;
|
||||||
|
Debug.SELF_ID = message.id;
|
||||||
mar.client.maxWidth = message.maxWidth;
|
mar.client.maxWidth = message.maxWidth;
|
||||||
mar.client.requestTerrain();
|
mar.client.requestTerrain();
|
||||||
};
|
};
|
||||||
@ -581,7 +603,7 @@ var TerrainListener = (function () {
|
|||||||
if (message.ok) {
|
if (message.ok) {
|
||||||
var worldSize = message.size;
|
var worldSize = message.size;
|
||||||
if (worldSize == undefined) {
|
if (worldSize == undefined) {
|
||||||
worldSize = config.defaultWorldSize;
|
worldSize = config.world.defaultSize;
|
||||||
}
|
}
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
console.log("[MAR] World is available");
|
console.log("[MAR] World is available");
|
||||||
@ -607,13 +629,13 @@ var TerrainListener = (function () {
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
console.log("[MAR] Updating World terrain");
|
console.log("[MAR] Updating World terrain");
|
||||||
}
|
}
|
||||||
mar.world.updateTerrain([], config.defaultWorldSize);
|
mar.world.updateTerrain([], config.world.defaultSize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
console.log("[MAR] Creating new World");
|
console.log("[MAR] Creating new World");
|
||||||
}
|
}
|
||||||
mar.world = new World([], config.defaultWorldSize);
|
mar.world = new World([], config.world.defaultSize);
|
||||||
}
|
}
|
||||||
if (mar.world) {
|
if (mar.world) {
|
||||||
mar.world.setBigMessage("[Uncharted World]");
|
mar.world.setBigMessage("[Uncharted World]");
|
||||||
@ -772,7 +794,7 @@ var GameClient = (function () {
|
|||||||
GameClient.prototype.initGame = function () {
|
GameClient.prototype.initGame = function () {
|
||||||
if (this.username != "guest") {
|
if (this.username != "guest") {
|
||||||
var self_1 = this;
|
var self_1 = this;
|
||||||
this.keyboardBuffer = new KeyboardBuffer(config.kbBufferX, config.kbBufferY);
|
this.keyboardBuffer = new KeyboardBuffer(config.kbBuffer.x, config.kbBuffer.y);
|
||||||
mar.addDebugMessage(this.keyboardBuffer);
|
mar.addDebugMessage(this.keyboardBuffer);
|
||||||
mar.game.input.keyboard.onDownCallback = function (event) {
|
mar.game.input.keyboard.onDownCallback = function (event) {
|
||||||
if (document.activeElement === document.getElementById("game")) {
|
if (document.activeElement === document.getElementById("game")) {
|
||||||
@ -858,8 +880,8 @@ var GameObject = (function (_super) {
|
|||||||
GameObject.prototype.setText = function (text) {
|
GameObject.prototype.setText = function (text) {
|
||||||
this.text = mar.game.make.text(0, 0, text, {
|
this.text = mar.game.make.text(0, 0, text, {
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fill: config.textFill,
|
fill: config.text.textFill,
|
||||||
stroke: config.textStroke,
|
stroke: config.text.textStroke,
|
||||||
strokeThickness: 2,
|
strokeThickness: 2,
|
||||||
font: "fixedsys"
|
font: "fixedsys"
|
||||||
});
|
});
|
||||||
@ -934,7 +956,7 @@ var Cubot = (function (_super) {
|
|||||||
Cubot.prototype.onTileHover = function () {
|
Cubot.prototype.onTileHover = function () {
|
||||||
mar.game.add.tween(this).to({ isoZ: 45 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({ isoZ: 45 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1.2, y: 1.2 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1.2, y: 1.2 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.cubotSprite.tint = config.cubotHoverTint;
|
this.cubotSprite.tint = config.cubot.hoverTint;
|
||||||
if (this.text !== undefined) {
|
if (this.text !== undefined) {
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
}
|
}
|
||||||
@ -974,15 +996,15 @@ var Cubot = (function (_super) {
|
|||||||
};
|
};
|
||||||
Cubot.prototype.getTint = function () {
|
Cubot.prototype.getTint = function () {
|
||||||
if (!this.hovered) {
|
if (!this.hovered) {
|
||||||
if (this.energy <= config.lowEnergy) {
|
if (this.energy <= config.cubot.lowEnergy) {
|
||||||
return config.lowEnergyTint;
|
return config.cubot.lowEnergyTint;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return config.cubotTint;
|
return config.cubot.tint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return config.cubotHoverTint;
|
return config.cubot.hoverTint;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Cubot.prototype.updateObject = function (json) {
|
Cubot.prototype.updateObject = function (json) {
|
||||||
@ -1034,10 +1056,10 @@ var Cubot = (function (_super) {
|
|||||||
this.hologram = mar.game.make.text(0, 32, "");
|
this.hologram = mar.game.make.text(0, 32, "");
|
||||||
this.hologram.anchor.set(0.5, 0);
|
this.hologram.anchor.set(0.5, 0);
|
||||||
this.addChild(this.hologram);
|
this.addChild(this.hologram);
|
||||||
this.hologram.setStyle(config.holoStyle(fillColor));
|
this.hologram.setStyle(config.text.holoStyle(fillColor));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.hologram.setStyle(config.holoStyle(fillColor));
|
this.hologram.setStyle(config.text.holoStyle(fillColor));
|
||||||
}
|
}
|
||||||
switch (holoMode) {
|
switch (holoMode) {
|
||||||
case HologramMode.CLEARED:
|
case HologramMode.CLEARED:
|
||||||
@ -1095,7 +1117,7 @@ var Cubot = (function (_super) {
|
|||||||
self.isoY = Util.getIsoY(self.tileY);
|
self.isoY = Util.getIsoY(self.tileY);
|
||||||
self.onTileExit();
|
self.onTileExit();
|
||||||
for (var i = 0; i < self.queuedAnimations.length; i++) {
|
for (var i = 0; i < self.queuedAnimations.length; i++) {
|
||||||
self.queuedAnimations[i](config.walkDuration / 2);
|
self.queuedAnimations[i](config.cubot.walkDuration / 2);
|
||||||
self.queuedAnimations.splice(i, 1);
|
self.queuedAnimations.splice(i, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1104,24 +1126,24 @@ var Cubot = (function (_super) {
|
|||||||
this.queuedAnimations.push(walkAnimation);
|
this.queuedAnimations.push(walkAnimation);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
walkAnimation(config.walkDuration);
|
walkAnimation(config.cubot.walkDuration);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Cubot.prototype.createUsername = function () {
|
Cubot.prototype.createUsername = function () {
|
||||||
var username = mar.game.make.text(0, -24, this.username, {
|
var username = mar.game.make.text(0, -24, this.username, {
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fill: config.textFill,
|
fill: config.text.textFill,
|
||||||
stroke: config.textStroke,
|
stroke: config.text.textStroke,
|
||||||
strokeThickness: 2,
|
strokeThickness: 2,
|
||||||
font: "fixedsys"
|
font: "fixedsys"
|
||||||
});
|
});
|
||||||
username.alpha = 0.85;
|
username.alpha = 0.85;
|
||||||
username.anchor.set(0.5, 0);
|
username.anchor.set(0.5, 0);
|
||||||
if (this.username === mar.client.username) {
|
if (this.username === mar.client.username) {
|
||||||
username.tint = config.selfUsernameColor;
|
username.tint = config.text.selfUsername;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.alpha = config.otherCubotAlpha;
|
this.alpha = config.cubot.otherCubotAlpha;
|
||||||
}
|
}
|
||||||
this.addChild(username);
|
this.addChild(username);
|
||||||
};
|
};
|
||||||
@ -1167,7 +1189,7 @@ var HarvesterNPC = (function (_super) {
|
|||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
HarvesterNPC.prototype.getTint = function () {
|
HarvesterNPC.prototype.getTint = function () {
|
||||||
return config.cubotTint;
|
return config.cubot.tint;
|
||||||
};
|
};
|
||||||
HarvesterNPC.prototype.updateDirection = function () {
|
HarvesterNPC.prototype.updateDirection = function () {
|
||||||
switch (this.direction) {
|
switch (this.direction) {
|
||||||
@ -1215,7 +1237,7 @@ var BiomassBlob = (function (_super) {
|
|||||||
_this.id = json.i;
|
_this.id = json.i;
|
||||||
_this.tileX = json.x;
|
_this.tileX = json.x;
|
||||||
_this.tileY = json.y;
|
_this.tileY = json.y;
|
||||||
_this.tint = config.biomassTint;
|
_this.tint = config.biomass.tint;
|
||||||
_this.animations.add("idle", mar.animationFrames.biomassIdle);
|
_this.animations.add("idle", mar.animationFrames.biomassIdle);
|
||||||
_this.animations.play("idle", 45, true);
|
_this.animations.play("idle", 45, true);
|
||||||
_this.setText("Biomass");
|
_this.setText("Biomass");
|
||||||
@ -1225,7 +1247,7 @@ var BiomassBlob = (function (_super) {
|
|||||||
BiomassBlob.prototype.onTileHover = function () {
|
BiomassBlob.prototype.onTileHover = function () {
|
||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 45 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({ isoZ: 45 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
this.tint = config.biomassHoverTint;
|
this.tint = config.biomass.tintHover;
|
||||||
mar.game.add.tween(this.scale).to({ x: 1.2, y: 1.2 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1.2, y: 1.2 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
};
|
};
|
||||||
@ -1233,7 +1255,7 @@ var BiomassBlob = (function (_super) {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.biomassTint;
|
this.tint = config.biomass.tintHover;
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
};
|
};
|
||||||
BiomassBlob.prototype.updateObject = function (json) {
|
BiomassBlob.prototype.updateObject = function (json) {
|
||||||
@ -1259,14 +1281,14 @@ var Factory = (function (_super) {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 25 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({ isoZ: 25 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
};
|
};
|
||||||
Factory.prototype.onTileExit = function () {
|
Factory.prototype.onTileExit = function () {
|
||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotTint;
|
this.tint = config.cubot.tint;
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
};
|
};
|
||||||
Factory.prototype.updateObject = function (json) {
|
Factory.prototype.updateObject = function (json) {
|
||||||
@ -1293,14 +1315,14 @@ var RadioTower = (function (_super) {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 25 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({ isoZ: 25 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
};
|
};
|
||||||
RadioTower.prototype.onTileExit = function () {
|
RadioTower.prototype.onTileExit = function () {
|
||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotTint;
|
this.tint = config.cubot.tint;
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
};
|
};
|
||||||
RadioTower.prototype.updateObject = function (json) {
|
RadioTower.prototype.updateObject = function (json) {
|
||||||
@ -1333,7 +1355,7 @@ var VaultDoor = (function (_super) {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 15 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({ isoZ: 15 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
document.body.style.cursor = 'pointer';
|
document.body.style.cursor = 'pointer';
|
||||||
document.body.setAttribute("title", "Click to visit Vault");
|
document.body.setAttribute("title", "Click to visit Vault");
|
||||||
@ -1342,7 +1364,7 @@ var VaultDoor = (function (_super) {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 0 }, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({ isoZ: 0 }, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotTint;
|
this.tint = config.cubot.tint;
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
document.body.style.cursor = 'default';
|
document.body.style.cursor = 'default';
|
||||||
document.body.setAttribute("title", "");
|
document.body.setAttribute("title", "");
|
||||||
@ -1374,14 +1396,14 @@ var ElectricBox = (function (_super) {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 25 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({ isoZ: 25 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
};
|
};
|
||||||
ElectricBox.prototype.onTileExit = function () {
|
ElectricBox.prototype.onTileExit = function () {
|
||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotTint;
|
this.tint = config.cubot.tint;
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
};
|
};
|
||||||
ElectricBox.prototype.makeSparks = function (self) {
|
ElectricBox.prototype.makeSparks = function (self) {
|
||||||
@ -1397,7 +1419,7 @@ var Portal = (function (_super) {
|
|||||||
function Portal(json) {
|
function Portal(json) {
|
||||||
var _this = _super.call(this, Util.getIsoX(json.x), Util.getIsoY(json.y), 15, "sheet", "objects/Portal") || this;
|
var _this = _super.call(this, Util.getIsoX(json.x), Util.getIsoY(json.y), 15, "sheet", "objects/Portal") || this;
|
||||||
_this.anchor.set(0.5, 0.3);
|
_this.anchor.set(0.5, 0.3);
|
||||||
_this.tint = config.portalTint;
|
_this.tint = config.portal.tint;
|
||||||
_this.setText("Portal");
|
_this.setText("Portal");
|
||||||
_this.text.visible = false;
|
_this.text.visible = false;
|
||||||
_this.id = json.i;
|
_this.id = json.i;
|
||||||
@ -1409,14 +1431,14 @@ var Portal = (function (_super) {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 25 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({ isoZ: 25 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1.06, y: 1.06 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
};
|
};
|
||||||
Portal.prototype.onTileExit = function () {
|
Portal.prototype.onTileExit = function () {
|
||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({ isoZ: 15 }, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({ x: 1, y: 1 }, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.portalTint;
|
this.tint = config.portal.tint;
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
};
|
};
|
||||||
Portal.prototype.updateObject = function (json) {
|
Portal.prototype.updateObject = function (json) {
|
||||||
@ -1475,7 +1497,7 @@ var Tile = (function (_super) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Tile.prototype.onHover = function () {
|
Tile.prototype.onHover = function () {
|
||||||
this.tint = config.tileHoverTint;
|
this.tint = config.tile.hover;
|
||||||
mar.game.add.tween(this).to({ isoZ: this.baseZ + 8 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({ isoZ: this.baseZ + 8 }, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.tileIndicator.tileX = this.tileX;
|
mar.tileIndicator.tileX = this.tileX;
|
||||||
mar.tileIndicator.tileY = this.tileY;
|
mar.tileIndicator.tileY = this.tileY;
|
||||||
@ -1505,8 +1527,8 @@ var Tile = (function (_super) {
|
|||||||
var PlainTile = (function (_super) {
|
var PlainTile = (function (_super) {
|
||||||
__extends(PlainTile, _super);
|
__extends(PlainTile, _super);
|
||||||
function PlainTile(x, y) {
|
function PlainTile(x, y) {
|
||||||
var _this = _super.call(this, x, y, config.plainSprite, 0) || this;
|
var _this = _super.call(this, x, y, config.tile.plainSprite, 0) || this;
|
||||||
_this.baseTint = config.tileTint;
|
_this.baseTint = config.tile.plain;
|
||||||
_this.tint = _this.baseTint;
|
_this.tint = _this.baseTint;
|
||||||
_this.tileType = "plain";
|
_this.tileType = "plain";
|
||||||
return _this;
|
return _this;
|
||||||
@ -1516,8 +1538,8 @@ var PlainTile = (function (_super) {
|
|||||||
var WallTile = (function (_super) {
|
var WallTile = (function (_super) {
|
||||||
__extends(WallTile, _super);
|
__extends(WallTile, _super);
|
||||||
function WallTile(x, y) {
|
function WallTile(x, y) {
|
||||||
var _this = _super.call(this, x, y, config.wallSprite, 0.2) || this;
|
var _this = _super.call(this, x, y, config.tile.wallSprite, 0.2) || this;
|
||||||
_this.baseTint = config.wallTint;
|
_this.baseTint = config.tile.wall;
|
||||||
_this.tint = _this.baseTint;
|
_this.tint = _this.baseTint;
|
||||||
_this.tileType = "wall";
|
_this.tileType = "wall";
|
||||||
return _this;
|
return _this;
|
||||||
@ -1527,8 +1549,8 @@ var WallTile = (function (_super) {
|
|||||||
var VaultWallTile = (function (_super) {
|
var VaultWallTile = (function (_super) {
|
||||||
__extends(VaultWallTile, _super);
|
__extends(VaultWallTile, _super);
|
||||||
function VaultWallTile(x, y) {
|
function VaultWallTile(x, y) {
|
||||||
var _this = _super.call(this, x, y, config.wallSprite2, 0.29) || this;
|
var _this = _super.call(this, x, y, config.tile.wallSprite2, 0.29) || this;
|
||||||
_this.baseTint = config.vaultWallTint;
|
_this.baseTint = config.tile.vaultWall;
|
||||||
_this.tint = _this.baseTint;
|
_this.tint = _this.baseTint;
|
||||||
_this.tileType = "vault wall";
|
_this.tileType = "vault wall";
|
||||||
return _this;
|
return _this;
|
||||||
@ -1538,8 +1560,8 @@ var VaultWallTile = (function (_super) {
|
|||||||
var VaultFloorTile = (function (_super) {
|
var VaultFloorTile = (function (_super) {
|
||||||
__extends(VaultFloorTile, _super);
|
__extends(VaultFloorTile, _super);
|
||||||
function VaultFloorTile(x, y) {
|
function VaultFloorTile(x, y) {
|
||||||
var _this = _super.call(this, x, y, config.plainSprite, 0) || this;
|
var _this = _super.call(this, x, y, config.tile.plainSprite, 0) || this;
|
||||||
_this.baseTint = config.vaultFloorTint;
|
_this.baseTint = config.tile.vaultFloor;
|
||||||
_this.tint = _this.baseTint;
|
_this.tint = _this.baseTint;
|
||||||
_this.tileType = "vault floor";
|
_this.tileType = "vault floor";
|
||||||
return _this;
|
return _this;
|
||||||
@ -1549,8 +1571,8 @@ var VaultFloorTile = (function (_super) {
|
|||||||
var VoidTile = (function (_super) {
|
var VoidTile = (function (_super) {
|
||||||
__extends(VoidTile, _super);
|
__extends(VoidTile, _super);
|
||||||
function VoidTile(x, y) {
|
function VoidTile(x, y) {
|
||||||
var _this = _super.call(this, x, y, config.plainSprite, 0) || this;
|
var _this = _super.call(this, x, y, config.tile.plainSprite, 0) || this;
|
||||||
_this.baseTint = config.vaultFloorTint;
|
_this.baseTint = config.tile.vaultFloor;
|
||||||
_this.tileType = "void";
|
_this.tileType = "void";
|
||||||
_this.alpha = 0;
|
_this.alpha = 0;
|
||||||
return _this;
|
return _this;
|
||||||
@ -1567,8 +1589,8 @@ var VoidTile = (function (_super) {
|
|||||||
var FluidTile = (function (_super) {
|
var FluidTile = (function (_super) {
|
||||||
__extends(FluidTile, _super);
|
__extends(FluidTile, _super);
|
||||||
function FluidTile(x, y) {
|
function FluidTile(x, y) {
|
||||||
var _this = _super.call(this, x, y, config.plainSprite, 0) || this;
|
var _this = _super.call(this, x, y, config.tile.plainSprite, 0) || this;
|
||||||
_this.baseTint = config.fluidTint;
|
_this.baseTint = config.tile.fluid;
|
||||||
_this.tint = _this.baseTint;
|
_this.tint = _this.baseTint;
|
||||||
_this.alpha = 0.6;
|
_this.alpha = 0.6;
|
||||||
_this.baseZ = -15;
|
_this.baseZ = -15;
|
||||||
@ -1581,10 +1603,10 @@ var FluidTile = (function (_super) {
|
|||||||
var MagneticTile = (function (_super) {
|
var MagneticTile = (function (_super) {
|
||||||
__extends(MagneticTile, _super);
|
__extends(MagneticTile, _super);
|
||||||
function MagneticTile(x, y) {
|
function MagneticTile(x, y) {
|
||||||
var _this = _super.call(this, x, y, config.magneticSprite, 0) || this;
|
var _this = _super.call(this, x, y, config.tile.magneticSprite, 0) || this;
|
||||||
_this.baseTint = 0xFFFFFF;
|
_this.baseTint = 0xFFFFFF;
|
||||||
_this.tint = _this.baseTint;
|
_this.tint = _this.baseTint;
|
||||||
_this.setText("Magnetic", config.textIron);
|
_this.setText("Magnetic", config.text.textIron);
|
||||||
_this.tileType = "Magnetic tile";
|
_this.tileType = "Magnetic tile";
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
@ -1599,10 +1621,10 @@ var MagneticTile = (function (_super) {
|
|||||||
var IronTile = (function (_super) {
|
var IronTile = (function (_super) {
|
||||||
__extends(IronTile, _super);
|
__extends(IronTile, _super);
|
||||||
function IronTile(x, y) {
|
function IronTile(x, y) {
|
||||||
var _this = _super.call(this, x, y, config.plainSprite, 0) || this;
|
var _this = _super.call(this, x, y, config.tile.plainSprite, 0) || this;
|
||||||
_this.baseTint = config.oreTint;
|
_this.baseTint = config.tile.ore;
|
||||||
_this.tint = _this.baseTint;
|
_this.tint = _this.baseTint;
|
||||||
_this.setText("Iron", config.textIron);
|
_this.setText("Iron", config.text.textIron);
|
||||||
_this.tileType = "iron";
|
_this.tileType = "iron";
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
@ -1611,10 +1633,10 @@ var IronTile = (function (_super) {
|
|||||||
var CopperTile = (function (_super) {
|
var CopperTile = (function (_super) {
|
||||||
__extends(CopperTile, _super);
|
__extends(CopperTile, _super);
|
||||||
function CopperTile(x, y) {
|
function CopperTile(x, y) {
|
||||||
var _this = _super.call(this, x, y, config.plainSprite, 0) || this;
|
var _this = _super.call(this, x, y, config.tile.plainSprite, 0) || this;
|
||||||
_this.baseTint = config.oreTint;
|
_this.baseTint = config.tile.ore;
|
||||||
_this.tint = _this.baseTint;
|
_this.tint = _this.baseTint;
|
||||||
_this.setText("Copper", config.textCopper);
|
_this.setText("Copper", config.text.textCopper);
|
||||||
_this.tileType = "copper";
|
_this.tileType = "copper";
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
@ -1659,8 +1681,8 @@ var World = (function () {
|
|||||||
World.prototype.setBigMessage = function (msg) {
|
World.prototype.setBigMessage = function (msg) {
|
||||||
this.bigMessage = mar.game.add.text(908, 450, msg, {
|
this.bigMessage = mar.game.add.text(908, 450, msg, {
|
||||||
fontSize: 46,
|
fontSize: 46,
|
||||||
fill: config.bigMessageFill,
|
fill: config.text.bigMessageFill,
|
||||||
stroke: config.textStroke,
|
stroke: config.text.textStroke,
|
||||||
strokeThickness: 2,
|
strokeThickness: 2,
|
||||||
font: "fixedsys"
|
font: "fixedsys"
|
||||||
}, mar.textGroup);
|
}, mar.textGroup);
|
||||||
@ -1752,12 +1774,12 @@ var WorldArrow = (function (_super) {
|
|||||||
mar.client.requestTerrain();
|
mar.client.requestTerrain();
|
||||||
});
|
});
|
||||||
_this.events.onInputOver.add(function () {
|
_this.events.onInputOver.add(function () {
|
||||||
self.tint = config.arrowHoverTint;
|
self.tint = config.arrow.tintHover;
|
||||||
self.hoverText.visible = true;
|
self.hoverText.visible = true;
|
||||||
document.body.style.cursor = "pointer";
|
document.body.style.cursor = "pointer";
|
||||||
});
|
});
|
||||||
_this.events.onInputOut.add(function () {
|
_this.events.onInputOut.add(function () {
|
||||||
self.tint = config.arrowTint;
|
self.tint = config.arrow.tint;
|
||||||
self.hoverText.visible = false;
|
self.hoverText.visible = false;
|
||||||
document.body.style.cursor = "default";
|
document.body.style.cursor = "default";
|
||||||
});
|
});
|
||||||
|
@ -108,6 +108,7 @@ class UserInfoListener implements MessageListener {
|
|||||||
mar.client.worldX = message.worldX;
|
mar.client.worldX = message.worldX;
|
||||||
mar.client.worldY = message.worldY;
|
mar.client.worldY = message.worldY;
|
||||||
mar.client.dimension = message.dimension;
|
mar.client.dimension = message.dimension;
|
||||||
|
Debug.SELF_ID = message.id;
|
||||||
|
|
||||||
//Maximum Universe width
|
//Maximum Universe width
|
||||||
mar.client.maxWidth = message.maxWidth;
|
mar.client.maxWidth = message.maxWidth;
|
||||||
@ -163,7 +164,7 @@ class TerrainListener implements MessageListener {
|
|||||||
|
|
||||||
let worldSize = message.size;
|
let worldSize = message.size;
|
||||||
if (worldSize == undefined) {
|
if (worldSize == undefined) {
|
||||||
worldSize = config.defaultWorldSize;
|
worldSize = config.world.defaultSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ class TerrainListener implements MessageListener {
|
|||||||
console.log("[MAR] Updating World terrain");
|
console.log("[MAR] Updating World terrain");
|
||||||
}
|
}
|
||||||
|
|
||||||
mar.world.updateTerrain([], config.defaultWorldSize);
|
mar.world.updateTerrain([], config.world.defaultSize);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -209,7 +210,7 @@ class TerrainListener implements MessageListener {
|
|||||||
console.log("[MAR] Creating new World");
|
console.log("[MAR] Creating new World");
|
||||||
}
|
}
|
||||||
|
|
||||||
mar.world = new World([], config.defaultWorldSize);
|
mar.world = new World([], config.world.defaultSize);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (mar.world) {
|
if (mar.world) {
|
||||||
@ -455,7 +456,7 @@ class GameClient {
|
|||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
this.keyboardBuffer = new KeyboardBuffer(config.kbBufferX, config.kbBufferY);
|
this.keyboardBuffer = new KeyboardBuffer(config.kbBuffer.x, config.kbBuffer.y);
|
||||||
mar.addDebugMessage(this.keyboardBuffer);
|
mar.addDebugMessage(this.keyboardBuffer);
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,8 +88,8 @@ abstract class GameObject extends Phaser.Plugin.Isometric.IsoSprite {
|
|||||||
protected setText(text: string): void {
|
protected setText(text: string): void {
|
||||||
this.text = mar.game.make.text(0, 0, text, {
|
this.text = mar.game.make.text(0, 0, text, {
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fill: config.textFill,
|
fill: config.text.textFill,
|
||||||
stroke: config.textStroke,
|
stroke: config.text.textStroke,
|
||||||
strokeThickness: 2,
|
strokeThickness: 2,
|
||||||
font: "fixedsys"
|
font: "fixedsys"
|
||||||
});
|
});
|
||||||
@ -207,7 +207,7 @@ class Cubot extends GameObject {
|
|||||||
mar.game.add.tween(this).to({isoZ: 45}, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({isoZ: 45}, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1.2, y: 1.2}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1.2, y: 1.2}, 200, Phaser.Easing.Linear.None, true);
|
||||||
|
|
||||||
this.cubotSprite.tint = config.cubotHoverTint;
|
this.cubotSprite.tint = config.cubot.hoverTint;
|
||||||
|
|
||||||
if (this.text !== undefined) {
|
if (this.text !== undefined) {
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
@ -260,13 +260,13 @@ class Cubot extends GameObject {
|
|||||||
|
|
||||||
public getTint(): number {
|
public getTint(): number {
|
||||||
if (!this.hovered) {
|
if (!this.hovered) {
|
||||||
if (this.energy <= config.lowEnergy) {
|
if (this.energy <= config.cubot.lowEnergy) {
|
||||||
return config.lowEnergyTint;
|
return config.cubot.lowEnergyTint;
|
||||||
} else {
|
} else {
|
||||||
return config.cubotTint;
|
return config.cubot.tint;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return config.cubotHoverTint;
|
return config.cubot.hoverTint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,9 +343,9 @@ class Cubot extends GameObject {
|
|||||||
this.hologram = mar.game.make.text(0, 32, "");
|
this.hologram = mar.game.make.text(0, 32, "");
|
||||||
this.hologram.anchor.set(0.5, 0);
|
this.hologram.anchor.set(0.5, 0);
|
||||||
this.addChild(this.hologram);
|
this.addChild(this.hologram);
|
||||||
this.hologram.setStyle(config.holoStyle(fillColor));
|
this.hologram.setStyle(config.text.holoStyle(fillColor));
|
||||||
} else {
|
} else {
|
||||||
this.hologram.setStyle(config.holoStyle(fillColor));
|
this.hologram.setStyle(config.text.holoStyle(fillColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (holoMode) {
|
switch (holoMode) {
|
||||||
@ -430,7 +430,7 @@ class Cubot extends GameObject {
|
|||||||
|
|
||||||
//Execute all the queued walk animations at a faster pace
|
//Execute all the queued walk animations at a faster pace
|
||||||
for (let i = 0; i < self.queuedAnimations.length; i++) {
|
for (let i = 0; i < self.queuedAnimations.length; i++) {
|
||||||
self.queuedAnimations[i](config.walkDuration / 2);
|
self.queuedAnimations[i](config.cubot.walkDuration / 2);
|
||||||
self.queuedAnimations.splice(i, 1)
|
self.queuedAnimations.splice(i, 1)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -442,7 +442,7 @@ class Cubot extends GameObject {
|
|||||||
this.queuedAnimations.push(walkAnimation);
|
this.queuedAnimations.push(walkAnimation);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
walkAnimation(config.walkDuration);
|
walkAnimation(config.cubot.walkDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -456,8 +456,8 @@ class Cubot extends GameObject {
|
|||||||
public createUsername() {
|
public createUsername() {
|
||||||
let username = mar.game.make.text(0, -24, this.username, {
|
let username = mar.game.make.text(0, -24, this.username, {
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fill: config.textFill,
|
fill: config.text.textFill,
|
||||||
stroke: config.textStroke,
|
stroke: config.text.textStroke,
|
||||||
strokeThickness: 2,
|
strokeThickness: 2,
|
||||||
font: "fixedsys"
|
font: "fixedsys"
|
||||||
});
|
});
|
||||||
@ -466,9 +466,9 @@ class Cubot extends GameObject {
|
|||||||
|
|
||||||
//Color own username
|
//Color own username
|
||||||
if (this.username === mar.client.username) {
|
if (this.username === mar.client.username) {
|
||||||
username.tint = config.selfUsernameColor;
|
username.tint = config.text.selfUsername;
|
||||||
} else {
|
} else {
|
||||||
this.alpha = config.otherCubotAlpha;
|
this.alpha = config.cubot.otherCubotAlpha;
|
||||||
}
|
}
|
||||||
this.addChild(username);
|
this.addChild(username);
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ class HarvesterNPC extends Cubot {
|
|||||||
* Needs to be overridden because Cubot() calls getTint() when initialised
|
* Needs to be overridden because Cubot() calls getTint() when initialised
|
||||||
*/
|
*/
|
||||||
public getTint() {
|
public getTint() {
|
||||||
return config.cubotTint;
|
return config.cubot.tint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateDirection() {
|
public updateDirection() {
|
||||||
@ -585,7 +585,7 @@ class BiomassBlob extends GameObject {
|
|||||||
onTileHover() {
|
onTileHover() {
|
||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 45}, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({isoZ: 45}, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
this.tint = config.biomassHoverTint;
|
this.tint = config.biomass.tintHover;
|
||||||
mar.game.add.tween(this.scale).to({x: 1.2, y: 1.2}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1.2, y: 1.2}, 200, Phaser.Easing.Linear.None, true);
|
||||||
|
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
@ -595,7 +595,7 @@ class BiomassBlob extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.biomassTint;
|
this.tint = config.biomass.tintHover;
|
||||||
|
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
}
|
}
|
||||||
@ -618,7 +618,7 @@ class BiomassBlob extends GameObject {
|
|||||||
this.tileX = json.x;
|
this.tileX = json.x;
|
||||||
this.tileY = json.y;
|
this.tileY = json.y;
|
||||||
|
|
||||||
this.tint = config.biomassTint;
|
this.tint = config.biomass.tint;
|
||||||
|
|
||||||
this.animations.add("idle", mar.animationFrames.biomassIdle);
|
this.animations.add("idle", mar.animationFrames.biomassIdle);
|
||||||
this.animations.play("idle", 45, true);
|
this.animations.play("idle", 45, true);
|
||||||
@ -635,7 +635,7 @@ class Factory extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 25}, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({isoZ: 25}, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
|
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
}
|
}
|
||||||
@ -644,7 +644,7 @@ class Factory extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotTint;
|
this.tint = config.cubot.tint;
|
||||||
|
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
}
|
}
|
||||||
@ -678,7 +678,7 @@ class RadioTower extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 25}, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({isoZ: 25}, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
|
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
}
|
}
|
||||||
@ -687,7 +687,7 @@ class RadioTower extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotTint;
|
this.tint = config.cubot.tint;
|
||||||
|
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
}
|
}
|
||||||
@ -715,7 +715,7 @@ class VaultDoor extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 15}, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({isoZ: 15}, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
|
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
|
|
||||||
@ -727,7 +727,7 @@ class VaultDoor extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 0}, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({isoZ: 0}, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotTint;
|
this.tint = config.cubot.tint;
|
||||||
|
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
document.body.style.cursor = 'default';
|
document.body.style.cursor = 'default';
|
||||||
@ -773,7 +773,7 @@ class ElectricBox extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 25}, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({isoZ: 25}, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
|
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
}
|
}
|
||||||
@ -782,7 +782,7 @@ class ElectricBox extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotTint;
|
this.tint = config.cubot.tint;
|
||||||
|
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
}
|
}
|
||||||
@ -827,7 +827,7 @@ class Portal extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 25}, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({isoZ: 25}, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1.06, y: 1.06}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.cubotHoverTint;
|
this.tint = config.cubot.hoverTint;
|
||||||
|
|
||||||
this.text.visible = true;
|
this.text.visible = true;
|
||||||
}
|
}
|
||||||
@ -836,7 +836,7 @@ class Portal extends GameObject {
|
|||||||
mar.game.tweens.removeFrom(this);
|
mar.game.tweens.removeFrom(this);
|
||||||
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
mar.game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
|
||||||
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
mar.game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
|
||||||
this.tint = config.portalTint;
|
this.tint = config.portal.tint;
|
||||||
|
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
}
|
}
|
||||||
@ -848,7 +848,7 @@ class Portal extends GameObject {
|
|||||||
constructor(json) {
|
constructor(json) {
|
||||||
super(Util.getIsoX(json.x), Util.getIsoY(json.y), 15, "sheet", "objects/Portal");
|
super(Util.getIsoX(json.x), Util.getIsoY(json.y), 15, "sheet", "objects/Portal");
|
||||||
this.anchor.set(0.5, 0.3);
|
this.anchor.set(0.5, 0.3);
|
||||||
this.tint = config.portalTint;
|
this.tint = config.portal.tint;
|
||||||
|
|
||||||
this.setText("Portal");
|
this.setText("Portal");
|
||||||
this.text.visible = false;
|
this.text.visible = false;
|
||||||
|
@ -84,7 +84,7 @@ class Tile extends Phaser.Plugin.Isometric.IsoSprite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onHover() {
|
public onHover() {
|
||||||
this.tint = config.tileHoverTint;
|
this.tint = config.tile.hover;
|
||||||
mar.game.add.tween(this).to({isoZ: this.baseZ + 8}, 200, Phaser.Easing.Quadratic.InOut, true);
|
mar.game.add.tween(this).to({isoZ: this.baseZ + 8}, 200, Phaser.Easing.Quadratic.InOut, true);
|
||||||
|
|
||||||
mar.tileIndicator.tileX = this.tileX;
|
mar.tileIndicator.tileX = this.tileX;
|
||||||
@ -121,9 +121,9 @@ class Tile extends Phaser.Plugin.Isometric.IsoSprite {
|
|||||||
class PlainTile extends Tile {
|
class PlainTile extends Tile {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super(x, y, config.plainSprite, 0);
|
super(x, y, config.tile.plainSprite, 0);
|
||||||
|
|
||||||
this.baseTint = config.tileTint;
|
this.baseTint = config.tile.plain;
|
||||||
this.tint = this.baseTint;
|
this.tint = this.baseTint;
|
||||||
this.tileType = "plain";
|
this.tileType = "plain";
|
||||||
}
|
}
|
||||||
@ -132,9 +132,9 @@ class PlainTile extends Tile {
|
|||||||
class WallTile extends Tile {
|
class WallTile extends Tile {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super(x, y, config.wallSprite, 0.2);
|
super(x, y, config.tile.wallSprite, 0.2);
|
||||||
|
|
||||||
this.baseTint = config.wallTint;
|
this.baseTint = config.tile.wall;
|
||||||
this.tint = this.baseTint;
|
this.tint = this.baseTint;
|
||||||
this.tileType = "wall";
|
this.tileType = "wall";
|
||||||
|
|
||||||
@ -144,9 +144,9 @@ class WallTile extends Tile {
|
|||||||
class VaultWallTile extends Tile {
|
class VaultWallTile extends Tile {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super(x, y, config.wallSprite2, 0.29);
|
super(x, y, config.tile.wallSprite2, 0.29);
|
||||||
|
|
||||||
this.baseTint = config.vaultWallTint;
|
this.baseTint = config.tile.vaultWall;
|
||||||
this.tint = this.baseTint;
|
this.tint = this.baseTint;
|
||||||
this.tileType = "vault wall";
|
this.tileType = "vault wall";
|
||||||
|
|
||||||
@ -156,9 +156,9 @@ class VaultWallTile extends Tile {
|
|||||||
class VaultFloorTile extends Tile {
|
class VaultFloorTile extends Tile {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super(x, y, config.plainSprite, 0);
|
super(x, y, config.tile.plainSprite, 0);
|
||||||
|
|
||||||
this.baseTint = config.vaultFloorTint;
|
this.baseTint = config.tile.vaultFloor;
|
||||||
this.tint = this.baseTint;
|
this.tint = this.baseTint;
|
||||||
this.tileType = "vault floor";
|
this.tileType = "vault floor";
|
||||||
}
|
}
|
||||||
@ -177,9 +177,9 @@ class VoidTile extends Tile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super(x, y, config.plainSprite, 0);
|
super(x, y, config.tile.plainSprite, 0);
|
||||||
|
|
||||||
this.baseTint = config.vaultFloorTint;
|
this.baseTint = config.tile.vaultFloor;
|
||||||
this.tileType = "void";
|
this.tileType = "void";
|
||||||
this.alpha = 0;
|
this.alpha = 0;
|
||||||
}
|
}
|
||||||
@ -187,9 +187,9 @@ class VoidTile extends Tile {
|
|||||||
|
|
||||||
class FluidTile extends Tile {
|
class FluidTile extends Tile {
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super(x, y, config.plainSprite, 0);
|
super(x, y, config.tile.plainSprite, 0);
|
||||||
|
|
||||||
this.baseTint = config.fluidTint;
|
this.baseTint = config.tile.fluid;
|
||||||
this.tint = this.baseTint;
|
this.tint = this.baseTint;
|
||||||
this.alpha = 0.6;
|
this.alpha = 0.6;
|
||||||
this.baseZ = -15;
|
this.baseZ = -15;
|
||||||
@ -210,12 +210,12 @@ class MagneticTile extends Tile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super(x, y, config.magneticSprite, 0);
|
super(x, y, config.tile.magneticSprite, 0);
|
||||||
|
|
||||||
this.baseTint = 0xFFFFFF;
|
this.baseTint = 0xFFFFFF;
|
||||||
this.tint = this.baseTint;
|
this.tint = this.baseTint;
|
||||||
|
|
||||||
this.setText("Magnetic", config.textIron);
|
this.setText("Magnetic", config.text.textIron);
|
||||||
this.tileType = "Magnetic tile";
|
this.tileType = "Magnetic tile";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,12 +223,12 @@ class MagneticTile extends Tile {
|
|||||||
class IronTile extends Tile {
|
class IronTile extends Tile {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super(x, y, config.plainSprite, 0);
|
super(x, y, config.tile.plainSprite, 0);
|
||||||
|
|
||||||
this.baseTint = config.oreTint;
|
this.baseTint = config.tile.ore;
|
||||||
this.tint = this.baseTint;
|
this.tint = this.baseTint;
|
||||||
|
|
||||||
this.setText("Iron", config.textIron);
|
this.setText("Iron", config.text.textIron);
|
||||||
this.tileType = "iron";
|
this.tileType = "iron";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,12 +237,12 @@ class IronTile extends Tile {
|
|||||||
class CopperTile extends Tile {
|
class CopperTile extends Tile {
|
||||||
|
|
||||||
constructor(x: number, y: number) {
|
constructor(x: number, y: number) {
|
||||||
super(x, y, config.plainSprite, 0);
|
super(x, y, config.tile.plainSprite, 0);
|
||||||
|
|
||||||
this.baseTint = config.oreTint;
|
this.baseTint = config.tile.ore;
|
||||||
this.tint = this.baseTint;
|
this.tint = this.baseTint;
|
||||||
|
|
||||||
this.setText("Copper", config.textCopper);
|
this.setText("Copper", config.text.textCopper);
|
||||||
this.tileType = "copper";
|
this.tileType = "copper";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,8 +321,8 @@ class World {
|
|||||||
public setBigMessage(msg: string) {
|
public setBigMessage(msg: string) {
|
||||||
this.bigMessage = mar.game.add.text(908, 450, msg, {
|
this.bigMessage = mar.game.add.text(908, 450, msg, {
|
||||||
fontSize: 46,
|
fontSize: 46,
|
||||||
fill: config.bigMessageFill,
|
fill: config.text.bigMessageFill,
|
||||||
stroke: config.textStroke,
|
stroke: config.text.textStroke,
|
||||||
strokeThickness: 2,
|
strokeThickness: 2,
|
||||||
font: "fixedsys"
|
font: "fixedsys"
|
||||||
}, mar.textGroup);
|
}, mar.textGroup);
|
||||||
@ -465,13 +465,13 @@ class WorldArrow extends Phaser.Plugin.Isometric.IsoSprite {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.events.onInputOver.add(function () {
|
this.events.onInputOver.add(function () {
|
||||||
self.tint = config.arrowHoverTint;
|
self.tint = config.arrow.tintHover;
|
||||||
self.hoverText.visible = true;
|
self.hoverText.visible = true;
|
||||||
document.body.style.cursor = "pointer";
|
document.body.style.cursor = "pointer";
|
||||||
});
|
});
|
||||||
|
|
||||||
this.events.onInputOut.add(function () {
|
this.events.onInputOut.add(function () {
|
||||||
self.tint = config.arrowTint;
|
self.tint = config.arrow.tint;
|
||||||
self.hoverText.visible = false;
|
self.hoverText.visible = false;
|
||||||
document.body.style.cursor = "default";
|
document.body.style.cursor = "default";
|
||||||
});
|
});
|
||||||
|
@ -6,43 +6,66 @@ let RENDERER_HEIGHT = (window.innerHeight / 1.40) * window.devicePixelRatio;
|
|||||||
let DEBUG: boolean = true;
|
let DEBUG: boolean = true;
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
portalTint: 0xff43c8,
|
kbBuffer: {
|
||||||
tileTint: 0xFFFFFF,
|
x: 350, ///Position of the keyboard buffer fill on screen
|
||||||
wallTint: 0xDDDDDD,
|
y: 35,
|
||||||
vaultWallTint: 0x3F2D2A,
|
},
|
||||||
vaultFloorTint: 0x2B1E1C,
|
cubot: {
|
||||||
fluidTint: 0x0ACED6,
|
tint: 0xFFFFFF,
|
||||||
oreTint: 0xF3F3F3,
|
hoverTint: 0x00FF00,
|
||||||
cubotHoverTint: 0x00FF00,
|
lowEnergyTint: 0xCC0000,
|
||||||
cubotTint: 0xFFFFFF,
|
walkDuration: 800, //walk animation duration in ms
|
||||||
textFill: "#FFFFFF",
|
lowEnergy: 100, //Low energy threshold to change color
|
||||||
textStroke: "#9298a8",
|
otherCubotAlpha: 0.6,
|
||||||
biomassTint: 0x63B85F,
|
},
|
||||||
biomassHoverTint: 0x00FF00,
|
biomass: {
|
||||||
tileHoverTint: 0x00FF00,
|
tint: 0x63B85F,
|
||||||
itemIron: 0x434341,
|
tintHover: 0x00FF00,
|
||||||
textIron: "#434341",
|
},
|
||||||
itemCopper: 0xC87D38,
|
tile: {
|
||||||
textCopper: "#C87D38",
|
hover: 0x00FF00,
|
||||||
hologramFill: "#0aced6",
|
vaultWall: 0x3F2D2A,
|
||||||
hologramStroke: "#12FFB0",
|
vaultFloor: 0x2B1E1C,
|
||||||
copperFill: "#C87D38",
|
fluid: 0x0ACED6,
|
||||||
plainSprite: "tiles/tile",
|
ore: 0xF3F3F3,
|
||||||
magneticSprite: "tiles/magneticTile",
|
plain: 0xFFFFFF,
|
||||||
wallSprite: "tiles/bigTile",
|
wall: 0xDDDDDD,
|
||||||
wallSprite2: "tiles/bigTile2",
|
plainSprite: "tiles/tile",
|
||||||
walkDuration: 800, //walk animation duration in ms
|
magneticSprite: "tiles/magneticTile",
|
||||||
holoStyle: (fill: string) => {
|
wallSprite: "tiles/bigTile",
|
||||||
return {
|
wallSprite2: "tiles/bigTile2",
|
||||||
fontSize: 32,
|
},
|
||||||
fill: fill ? fill : config.hologramFill,
|
item: {
|
||||||
stroke: config.hologramStroke,
|
ironColor: 0x434341,
|
||||||
strokeThickness: 1,
|
copperColor: 0xC87D38,
|
||||||
font: "fixedsys"
|
blueprintColor: 0xaced6,
|
||||||
}
|
},
|
||||||
|
portal: {
|
||||||
|
tint: 0xff43c8,
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
textFill: "#FFFFFF",
|
||||||
|
textStroke: "#9298a8",
|
||||||
|
textIron: "#434341",
|
||||||
|
textCopper: "#C87D38",
|
||||||
|
hologramFill: "#0aced6",
|
||||||
|
hologramStroke: "#12FFB0",
|
||||||
|
selfUsername: 0xFB4D0A, //Color of own Cubot's username.
|
||||||
|
bigMessageFill: "#ff803d",
|
||||||
|
holoStyle: (fill: string) => {
|
||||||
|
return {
|
||||||
|
fontSize: 32,
|
||||||
|
fill: fill ? fill : config.text.hologramFill,
|
||||||
|
stroke: config.text.hologramStroke,
|
||||||
|
strokeThickness: 1,
|
||||||
|
font: "fixedsys"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
arrow: {
|
||||||
|
tint: 0xFFFFFF,
|
||||||
|
tintHover: 0x00FF00,
|
||||||
},
|
},
|
||||||
kbBufferX: 350, ///Position of the keyboard buffer fill on screen
|
|
||||||
kbBufferY: 35,
|
|
||||||
arrowTextStyle: {
|
arrowTextStyle: {
|
||||||
fontSize: 32,
|
fontSize: 32,
|
||||||
fill: "#ffffff",
|
fill: "#ffffff",
|
||||||
@ -50,15 +73,9 @@ let config = {
|
|||||||
strokeThickness: 1,
|
strokeThickness: 1,
|
||||||
font: "fixedsys"
|
font: "fixedsys"
|
||||||
},
|
},
|
||||||
lowEnergy: 100, //Low energy threshold to change color
|
world: {
|
||||||
lowEnergyTint: 0xCC0000,
|
defaultSize: 16 //Will fallback to this when server does not provide world width
|
||||||
bigMessageFill: "#ff803d",
|
}
|
||||||
arrowTint: 0xFFFFFF,
|
|
||||||
arrowHoverTint: 0x00FF00,
|
|
||||||
selfUsernameColor: 0xFB4D0A, //Color of own Cubot's username.
|
|
||||||
otherCubotAlpha: 0.6,
|
|
||||||
defaultWorldSize: 16 //Will fallback to this when server does not provide world width
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -102,18 +119,21 @@ class Util {
|
|||||||
|
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case 1:
|
case 1:
|
||||||
return config.biomassTint;
|
return config.biomass.tint;
|
||||||
case 3:
|
case 3:
|
||||||
return config.itemIron;
|
return config.item.ironColor;
|
||||||
case 4:
|
case 4:
|
||||||
return config.itemCopper;
|
return config.item.copperColor;
|
||||||
|
case 5:
|
||||||
|
return config.item.blueprintColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Debug {
|
class Debug {
|
||||||
|
|
||||||
|
public static SELF_ID = "";
|
||||||
|
|
||||||
public static setTileAt(x, y, newTile) {
|
public static setTileAt(x, y, newTile) {
|
||||||
mar.client.sendDebugCommand({
|
mar.client.sendDebugCommand({
|
||||||
t: "debug", command: "setTileAt", x: x, y: y, newTile: newTile,
|
t: "debug", command: "setTileAt", x: x, y: y, newTile: newTile,
|
||||||
|
@ -0,0 +1,111 @@
|
|||||||
|
package net.simon987.constructionplugin;
|
||||||
|
|
||||||
|
import net.simon987.server.game.item.Item;
|
||||||
|
import net.simon987.server.game.objects.GameObject;
|
||||||
|
import net.simon987.server.game.objects.InventoryHolder;
|
||||||
|
import net.simon987.server.io.JSONSerializable;
|
||||||
|
import net.simon987.server.io.MongoSerializable;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public abstract class BluePrint implements InventoryHolder, JSONSerializable, MongoSerializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of items id and required amount
|
||||||
|
* <br>The amount is decremented as the items are added
|
||||||
|
*/
|
||||||
|
protected Map<Integer, Integer> requiredItems;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This object will be instantiated when completed
|
||||||
|
*/
|
||||||
|
protected Class<? extends GameObject> targetObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true when all the requirements are met
|
||||||
|
*/
|
||||||
|
private boolean completed;
|
||||||
|
|
||||||
|
public BluePrint() {
|
||||||
|
requiredItems = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BluePrint(Document document) {
|
||||||
|
requiredItems = (Map<Integer, Integer>) document.get("required_items");
|
||||||
|
completed = document.getBoolean("completed");
|
||||||
|
try {
|
||||||
|
targetObject = Class.forName(document.getString("target")).asSubclass(GameObject.class);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkCompleted() {
|
||||||
|
|
||||||
|
for (Integer remaining : requiredItems.values()) {
|
||||||
|
if (remaining > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
completed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean placeItem(Item item) {
|
||||||
|
|
||||||
|
if (requiredItems.containsKey(item.getId()) && requiredItems.get(item.getId()) > 0) {
|
||||||
|
requiredItems.put(item.getId(), requiredItems.get(item.getId()) - 1);
|
||||||
|
checkCompleted();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void takeItem(int itemId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTakeItem(int itemId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCompleted() {
|
||||||
|
return completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends GameObject> getTargetObject() {
|
||||||
|
return targetObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject debugJsonSerialise() {
|
||||||
|
return jsonSerialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject jsonSerialise() {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
|
||||||
|
json.put("target", targetObject);
|
||||||
|
json.put("required_items", requiredItems);
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document mongoSerialise() {
|
||||||
|
Document document = new Document();
|
||||||
|
|
||||||
|
document.put("completed", completed);
|
||||||
|
document.put("target", targetObject);
|
||||||
|
document.put("required_items", requiredItems);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
}
|
61
plugin-contruction/src/main/java/net/simon987/constructionplugin/BluePrintRegistry.java
Normal file
61
plugin-contruction/src/main/java/net/simon987/constructionplugin/BluePrintRegistry.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package net.simon987.constructionplugin;
|
||||||
|
|
||||||
|
import net.simon987.server.logging.LogManager;
|
||||||
|
import org.bson.Document;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class BluePrintRegistry {
|
||||||
|
|
||||||
|
public static final BluePrintRegistry INSTANCE = new BluePrintRegistry();
|
||||||
|
|
||||||
|
private Map<String, Class<? extends BluePrint>> blueprints;
|
||||||
|
private Map<String, String> digitizedBlueprints;
|
||||||
|
|
||||||
|
private BluePrintRegistry() {
|
||||||
|
blueprints = new HashMap<>();
|
||||||
|
digitizedBlueprints = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerBluePrint(Class<? extends BluePrint> clazz) {
|
||||||
|
blueprints.put(clazz.getCanonicalName(), clazz);
|
||||||
|
String bpData = new String(BluePrintUtil.bluePrintData(clazz));
|
||||||
|
digitizedBlueprints.put(bpData, clazz.getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public BluePrint deserializeBlueprint(Document document) {
|
||||||
|
|
||||||
|
String type = document.getString("type");
|
||||||
|
|
||||||
|
if (blueprints.containsKey(type)) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return blueprints.get(type).getConstructor(Document.class).newInstance(document);
|
||||||
|
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
LogManager.LOGGER.severe("(Construction Plugin) Error while trying to deserialize object of type " + type + ": " + e.getTargetException().getMessage());
|
||||||
|
LogManager.LOGGER.severe(document.toJson());
|
||||||
|
e.getTargetException().printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogManager.LOGGER.severe("(Construction Plugin) Trying to deserialize unknown BluePrint type: " + type);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BluePrint deserializeBluePrint(char[] chars) {
|
||||||
|
|
||||||
|
String bpData = new String(chars);
|
||||||
|
|
||||||
|
if (digitizedBlueprints.containsKey(bpData)) {
|
||||||
|
return deserializeBlueprint(new Document("type", digitizedBlueprints.get(bpData)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package net.simon987.constructionplugin;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
class BluePrintUtil {
|
||||||
|
|
||||||
|
private static byte[] secretKey;
|
||||||
|
private static final String SHA512 = "SHA-512";
|
||||||
|
|
||||||
|
//We need 1024 chars = 2048 bytes = 32 values
|
||||||
|
private static final char[] ARBITRARY_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456".toCharArray();
|
||||||
|
|
||||||
|
static void setSecretKey(String secretKey) {
|
||||||
|
BluePrintUtil.secretKey = secretKey.getBytes(StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash a message using SHA512 with the server secret key as the sal
|
||||||
|
*
|
||||||
|
* @return 128-bit char array
|
||||||
|
*/
|
||||||
|
private static char[] hashMessage(String message) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
MessageDigest md = MessageDigest.getInstance(SHA512);
|
||||||
|
md.update(secretKey);
|
||||||
|
md.update(message.getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
byte[] digest = md.digest();
|
||||||
|
char[] chars = new char[digest.length / 2];
|
||||||
|
ByteBuffer.wrap(digest).order(ByteOrder.BIG_ENDIAN).asCharBuffer().get(chars);
|
||||||
|
|
||||||
|
return chars;
|
||||||
|
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a char array representation of a blueprint. It is obtained by hashing the blueprint
|
||||||
|
* properties with the server secret key. Some arbitrary values are added to make a 1024-char
|
||||||
|
* array. The same blueprint and secret key always gives the same result.
|
||||||
|
*/
|
||||||
|
static char[] bluePrintData(Class<? extends BluePrint> blueprint) {
|
||||||
|
|
||||||
|
char[] result = new char[ARBITRARY_STRING.length * 32];
|
||||||
|
|
||||||
|
for (int i = ARBITRARY_STRING.length - 1; i > 0; --i) {
|
||||||
|
char[] hashedBlueprint = hashMessage(ARBITRARY_STRING[i] + blueprint.getName());
|
||||||
|
if (hashedBlueprint != null) {
|
||||||
|
System.arraycopy(hashedBlueprint, 0, result,
|
||||||
|
i * hashedBlueprint.length, hashedBlueprint.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,24 @@
|
|||||||
package net.simon987.constructionplugin;
|
package net.simon987.constructionplugin;
|
||||||
|
|
||||||
import net.simon987.server.ServerConfiguration;
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.game.objects.GameRegistry;
|
import net.simon987.server.game.objects.GameRegistry;
|
||||||
|
import net.simon987.server.logging.LogManager;
|
||||||
import net.simon987.server.plugin.ServerPlugin;
|
import net.simon987.server.plugin.ServerPlugin;
|
||||||
|
|
||||||
public class ConstructionPlugin extends ServerPlugin {
|
public class ConstructionPlugin extends ServerPlugin {
|
||||||
@Override
|
|
||||||
public void init(ServerConfiguration config, GameRegistry gameRegistry) {
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(GameServer gameServer) {
|
||||||
|
|
||||||
|
BluePrintUtil.setSecretKey(gameServer.getSecretKey());
|
||||||
|
GameRegistry gameRegistry = gameServer.getRegistry();
|
||||||
|
|
||||||
|
gameRegistry.registerItem(ItemBluePrint.ID, ItemBluePrint.class);
|
||||||
|
gameRegistry.registerGameObject(Obstacle.class);
|
||||||
|
gameRegistry.registerGameObject(ConstructionSite.class);
|
||||||
|
|
||||||
|
BluePrintRegistry.INSTANCE.registerBluePrint(ObstacleBlueprint.class);
|
||||||
|
|
||||||
|
LogManager.LOGGER.info("(Construction Plugin) Initialized construction plugin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,33 @@ package net.simon987.constructionplugin;
|
|||||||
|
|
||||||
import net.simon987.server.GameServer;
|
import net.simon987.server.GameServer;
|
||||||
import net.simon987.server.game.item.Item;
|
import net.simon987.server.game.item.Item;
|
||||||
import net.simon987.server.game.objects.GameObject;
|
|
||||||
import net.simon987.server.game.objects.InventoryHolder;
|
import net.simon987.server.game.objects.InventoryHolder;
|
||||||
|
import net.simon987.server.game.objects.Structure;
|
||||||
import net.simon987.server.game.objects.Updatable;
|
import net.simon987.server.game.objects.Updatable;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
public class ConstructionSite extends GameObject implements Updatable, InventoryHolder {
|
public class ConstructionSite extends Structure implements Updatable, InventoryHolder {
|
||||||
|
|
||||||
public static final int MAP_INFO = 0xFFFF; //TODO: determine
|
public static final int MAP_INFO = 0xFFFF; //TODO: determine
|
||||||
public static final int LIFETIME = GameServer.INSTANCE.getConfig().getInt("construction_site_ttl");
|
public static final int LIFETIME = GameServer.INSTANCE.getConfig().getInt("construction_site_ttl");
|
||||||
|
|
||||||
private int age;
|
private int age;
|
||||||
|
private BluePrint bluePrint;
|
||||||
|
|
||||||
|
public ConstructionSite(BluePrint bluePrint) {
|
||||||
|
super(1, 1);
|
||||||
|
|
||||||
|
this.bluePrint = bluePrint;
|
||||||
|
this.age = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConstructionSite(Document document) {
|
||||||
|
super(document, 1, 1);
|
||||||
|
|
||||||
|
age = document.getInteger("age");
|
||||||
|
bluePrint = BluePrintRegistry.INSTANCE.deserializeBlueprint((Document) document.get("blueprint"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char getMapInfo() {
|
public char getMapInfo() {
|
||||||
@ -30,11 +47,7 @@ public class ConstructionSite extends GameObject implements Updatable, Inventory
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeItem(Item item) {
|
public boolean placeItem(Item item) {
|
||||||
|
return bluePrint.placeItem(item);
|
||||||
//todo: add mats here
|
|
||||||
//todo: inv digitize
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,4 +59,24 @@ public class ConstructionSite extends GameObject implements Updatable, Inventory
|
|||||||
public boolean canTakeItem(int itemId) {
|
public boolean canTakeItem(int itemId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject jsonSerialise() {
|
||||||
|
JSONObject json = super.jsonSerialise();
|
||||||
|
|
||||||
|
json.put("blueprint", bluePrint.jsonSerialise());
|
||||||
|
json.put("age", age);
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document mongoSerialise() {
|
||||||
|
Document document = super.mongoSerialise();
|
||||||
|
|
||||||
|
document.put("blueprint", bluePrint.mongoSerialise());
|
||||||
|
document.put("age", age);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package net.simon987.constructionplugin;
|
||||||
|
|
||||||
|
import net.simon987.server.assembly.Memory;
|
||||||
|
import net.simon987.server.game.item.Item;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
public class ItemBluePrint extends Item {
|
||||||
|
|
||||||
|
public static final int ID = 0x0005;
|
||||||
|
private Class<? extends BluePrint> bluePrint;
|
||||||
|
|
||||||
|
public ItemBluePrint() {
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemBluePrint(Document document) {
|
||||||
|
super(document);
|
||||||
|
try {
|
||||||
|
bluePrint = Class.forName(document.getString("blueprint")).asSubclass(BluePrint.class);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void digitize(Memory memory, int offset) {
|
||||||
|
char[] data = BluePrintUtil.bluePrintData(bluePrint);
|
||||||
|
memory.write(offset, data, 0, data.length);
|
||||||
|
|
||||||
|
System.out.println("DEBUG: blueprint digitize " + data.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char poll() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject debugJsonSerialise() {
|
||||||
|
JSONObject json = super.debugJsonSerialise();
|
||||||
|
json.put("blueprint", bluePrint.getCanonicalName());
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document mongoSerialise() {
|
||||||
|
Document document = super.mongoSerialise();
|
||||||
|
|
||||||
|
document.put("blueprint", bluePrint.getCanonicalName());
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
package net.simon987.constructionplugin;
|
||||||
|
|
||||||
|
import net.simon987.server.GameServer;
|
||||||
|
import net.simon987.server.game.objects.Attackable;
|
||||||
|
import net.simon987.server.game.objects.Structure;
|
||||||
|
import net.simon987.server.game.objects.Updatable;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
public class Obstacle extends Structure implements Attackable, Updatable {
|
||||||
|
|
||||||
|
public static final int MAP_INFO = 0x0601;
|
||||||
|
private static final int HEAL_RATE = GameServer.INSTANCE.getConfig().getInt("obstacle_regen");
|
||||||
|
private static final int MAX_HP = GameServer.INSTANCE.getConfig().getInt("obstacle_hp");
|
||||||
|
|
||||||
|
private int hp;
|
||||||
|
private int color;
|
||||||
|
|
||||||
|
public Obstacle() {
|
||||||
|
super(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Obstacle(Document document) {
|
||||||
|
super(document, 1, 1);
|
||||||
|
|
||||||
|
hp = document.getInteger(hp);
|
||||||
|
color = document.getInteger(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update() {
|
||||||
|
heal(HEAL_RATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHealRate(int hp) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHp() {
|
||||||
|
return hp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHp(int hp) {
|
||||||
|
this.hp = hp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHp() {
|
||||||
|
return MAX_HP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMaxHp(int hp) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void heal(int amount) {
|
||||||
|
hp = Math.min(getMaxHp(), hp + amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void damage(int amount) {
|
||||||
|
hp -= amount;
|
||||||
|
|
||||||
|
if (hp < 0) {
|
||||||
|
setDead(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char getMapInfo() {
|
||||||
|
return MAP_INFO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document mongoSerialise() {
|
||||||
|
Document document = super.mongoSerialise();
|
||||||
|
|
||||||
|
document.put("hp", hp);
|
||||||
|
document.put("color", hp);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject debugJsonSerialise() {
|
||||||
|
return jsonSerialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject jsonSerialise() {
|
||||||
|
JSONObject json = super.jsonSerialise();
|
||||||
|
|
||||||
|
json.put("hp", hp);
|
||||||
|
json.put("color", hp);
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
}
|
19
plugin-contruction/src/main/java/net/simon987/constructionplugin/ObstacleBlueprint.java
Normal file
19
plugin-contruction/src/main/java/net/simon987/constructionplugin/ObstacleBlueprint.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package net.simon987.constructionplugin;
|
||||||
|
|
||||||
|
import net.simon987.server.game.item.ItemIron;
|
||||||
|
import org.bson.Document;
|
||||||
|
|
||||||
|
public class ObstacleBlueprint extends BluePrint {
|
||||||
|
|
||||||
|
public ObstacleBlueprint() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.requiredItems.put(ItemIron.ID, 2); //TODO: load from config?
|
||||||
|
this.targetObject = Obstacle.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObstacleBlueprint(Document document) {
|
||||||
|
this.requiredItems.put(ItemIron.ID, 2); //TODO: load from config?
|
||||||
|
this.targetObject = Obstacle.class;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user