Visual improvements, Added Radio Tower, String literals

This commit is contained in:
simon 2017-12-30 09:35:12 -05:00
parent 2b96a2c77e
commit 59dae76be9
9 changed files with 389 additions and 105 deletions

View File

@ -91,6 +91,10 @@ if (isset($user)) {
background: #A386CA;
}
#gameBtns {
display: inline;
}
</style>
@ -126,6 +130,10 @@ if (isset($user)) {
</button>
</div>
<div id="gameBtns">
<a class="button editorBtn" onclick="findMyRobot()">Find My Robot</a>
</div>
<!-- Docs link -->
<a class="button alt" id="btnDocs"
href="https://github.com/simon987/Much-Assembly-Required/wiki" target="_blank">
@ -139,7 +147,7 @@ if (isset($user)) {
<!-- Game -->
<div id="game" tabindex="1">
<div id="game" tabindex="0">
<script src="./mar/phaser/phaser.min.js"></script>
<script src="./mar/phaser/phaser-plugin-isometric.min.js"></script>
<script src="./mar/phaser/mar.js"></script>
@ -157,8 +165,6 @@ if (isset($user)) {
editor.setFontSize(16);
editor.setDisplayIndentGuides(false);
document.getElementById('editor').style.fontFamily="fixedsys";
reloadCode();
</script>
</div>
@ -206,7 +212,7 @@ if (isset($user)) {
</div>
</div>
</div>
<?php include "footer.inc.html" ?>
<?php //include "footer.inc.html" ?>
</div>

View File

@ -74,7 +74,6 @@ define("ace/mode/mar_rules", ["require", "exports", "module", "ace/lib/oop", "ac
regex: '\\b0x[A-F0-9]+\\b',
caseInsensitive: true
},
{token: 'string.assembly', regex: /'([^\\']|\\.)*'/},
{token: 'string.assembly', regex: /"([^\\"]|\\.)*"/},
{token: 'comment.assembly', regex: ';.*$'},
{token: 'support.function.directive.assembly', regex: /^\.text|\.data/},

View File

@ -1,4 +1,4 @@
define("ace/mode/mar_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(a,d,b){b=a("../lib/oop");a=a("./text_highlight_rules").TextHighlightRules;var c=function(){this.$rules={start:[{token:"keyword.function.assembly",regex:"\\b(?:mov|add|sub|and|or|test|cmp|shl|shr|mul|push|pop|div|xor|dw|nop|equ|neg|hwq|not|ror|rol|sal|sar)\\b",caseInsensitive:!0},{token:"keyword.operator.assembly",regex:"\\b(?:call|ret|jmp|jnz|jg|jl|jge|jle|hwi|jz|js|jns|jc|jnc)\\b",caseInsensitive:!0},
{token:"variable.predefined.ahk",regex:"\\b(?:brk|dup)\\b",caseInsensitive:!0},{token:"variable.parameter.register.assembly",regex:"\\b(?:A|B|C|D|X|Y|bp|sp)\\b",caseInsensitive:!0},{token:"constant.character.decimal.assembly",regex:"\\b[0-9]+\\b"},{token:"constant.character.hexadecimal.assembly",regex:"\\b0x[A-F0-9]+\\b",caseInsensitive:!0},{token:"string.assembly",regex:/'([^\\']|\\.)*'/},{token:"string.assembly",regex:/"([^\\"]|\\.)*"/},{token:"comment.assembly",regex:";.*$"},{token:"support.function.directive.assembly",
regex:/^\.text|\.data/},{token:"entity.name.function.assembly",regex:/\w*:/}]};this.normalizeRules()};c.metaData={fileTypes:["asm"],name:"Much Assembly Required",scopeName:"source.assembly"};b.inherits(c,a);d.MarHighlightRules=c});
{token:"variable.predefined.ahk",regex:"\\b(?:brk|dup)\\b",caseInsensitive:!0},{token:"variable.parameter.register.assembly",regex:"\\b(?:A|B|C|D|X|Y|bp|sp)\\b",caseInsensitive:!0},{token:"constant.character.decimal.assembly",regex:"\\b[0-9]+\\b"},{token:"constant.character.hexadecimal.assembly",regex:"\\b0x[A-F0-9]+\\b",caseInsensitive:!0},{token:"string.assembly",regex:/"([^\\"]|\\.)*"/},{token:"comment.assembly",regex:";.*$"},{token:"support.function.directive.assembly",regex:/^\.text|\.data/},
{token:"entity.name.function.assembly",regex:/\w*:/}]};this.normalizeRules()};c.metaData={fileTypes:["asm"],name:"Much Assembly Required",scopeName:"source.assembly"};b.inherits(c,a);d.MarHighlightRules=c});
define("ace/mode/mar","require exports module ace/lib/oop ace/mode/text ace/mode/mar_rules".split(" "),function(a,d,b){b=a("../lib/oop");var c=a("./text").Mode,e=a("./mar_rules").MarHighlightRules;a=function(){this.HighlightRules=e;this.$behaviour=this.$defaultBehaviour};b.inherits(a,c);a.prototype.lineCommentStart=";";a.prototype.$id="ace/mode/mar";d.Mode=a});

View File

@ -26,11 +26,10 @@ function removeComment(line) {
function checkForLabel(line, result) {
line = removeComment(line);
if (line.indexOf(":") !== -1) {
var match;
if ((match = /\b\w*\b:/.exec(line)) !== null) {
line = line.substring(0, line.indexOf(":"));
result.labels.push(line.trim());
result.labels.push(match[0].substring(0, match[0].length - 1));
}
}
@ -81,11 +80,7 @@ function getTokens(line) {
}
function removeLabel(line) {
if (line.indexOf(':') !== -1) {
return line.substring(line.indexOf(':') + 1);
} else {
return line;
}
return line.replace(/\b\w*\b:/, "");
}
function checkForORGInstruction(line, result, currentLine) {
@ -127,7 +122,7 @@ function parseDWInstruction(line, result, currentLine) {
if (line.substr(0, 2).toLowerCase() === "dw") {
var values = line.substr(2, line.length).split(",");
var values = line.substr(2, line.length).split(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/, -1);
for (var i = 0; i < values.length; i++) {
@ -141,6 +136,9 @@ function parseDWInstruction(line, result, currentLine) {
// console.log("DUp");
} else if (values[i].startsWith("\"") && values[i].endsWith("\"")) {
//Handle string
} else if (getOperandType(values[i], result) === OPERAND_IMM) {
// console.log("is Imm " + values[i]);
@ -173,7 +171,8 @@ function getOperandType(text, result) {
}
//Check IMM
if (!isNaN(Number(text)) && Number(text) === Math.floor(Number(text))) {
if (!isNaN(Number(text)) && Number(text) === Math.floor(Number(text)) && text.indexOf("o") === -1
&& text.indexOf("e") === -1) {
return OPERAND_IMM;
}
@ -396,11 +395,13 @@ function parse() {
}
function gameClick() {
document.getElementById("editorBtns").setAttribute("style", "display: none")
document.getElementById("editorBtns").setAttribute("style", "display: none");
document.getElementById("gameBtns").setAttribute("style", "");
}
function editorClick() {
document.getElementById("editorBtns").setAttribute("style", "")
document.getElementById("editorBtns").setAttribute("style", "");
document.getElementById("gameBtns").setAttribute("style", "display: none");
}
editor.on("change", parse);

15
mar/editor.min.js vendored
View File

@ -3,14 +3,15 @@ $jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.definePrope
$jscomp.polyfill=function(a,c,b,d){if(c){b=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in b||(b[e]={});b=b[e]}a=a[a.length-1];d=b[a];c=c(d);c!=d&&null!=c&&$jscomp.defineProperty(b,a,{configurable:!0,writable:!0,value:c})}};
$jscomp.polyfill("String.prototype.startsWith",function(a){return a?a:function(a,b){var c=$jscomp.checkStringArgs(this,a,"startsWith");a+="";var e=c.length,f=a.length;b=Math.max(0,Math.min(b|0,c.length));for(var g=0;g<f&&b<e;)if(c[b++]!=a[g++])return!1;return g>=f}},"es6","es3");
$jscomp.polyfill("String.prototype.endsWith",function(a){return a?a:function(a,b){var c=$jscomp.checkStringArgs(this,a,"endsWith");a+="";void 0===b&&(b=c.length);b=Math.max(0,Math.min(b|0,c.length));for(var e=a.length;0<e&&0<b;)if(c[--b]!=a[--e])return!1;return 0>=e}},"es6","es3");OPERAND_INVALID=-1;OPERAND_REG=0;OPERAND_MEM_IMM=1;OPERAND_MEM_REG=2;OPERAND_IMM=3;editor=ace.edit("editor");editor.session.setOption("useWorker",!1);editor.$blockScrolling=Infinity;
function removeComment(a){return-1!==a.indexOf(";")?a.substring(0,a.indexOf(";")):a}function checkForLabel(a,c){a=removeComment(a);-1!==a.indexOf(":")&&(a=a.substring(0,a.indexOf(":")),c.labels.push(a.trim()))}function checkForSegmentDeclaration(a){a=getTokens(a);return void 0!==a[0]&&(".data"===a[0].toLowerCase()||".text"===a[0].toLowerCase())}
function checkForEQUInstruction(a,c,b){var d=getTokens(a);return-1!==a.toLowerCase().indexOf(" equ ")||void 0!==d[1]&&"equ"===d[1].toLowerCase()?(a=Number(d[2]),isNaN(a)||a!==Math.floor(a)?c.annotations.push({row:b,column:0,text:"Usage: constant_name EQU immediate_value",type:"error"}):c.labels.push(d[0]),!0):!1}function getTokens(a){a=a.split(/\s+/);for(var c=0;c<a.length;c++)""===a[c]&&a.splice(c,1);return a}function removeLabel(a){return-1!==a.indexOf(":")?a.substring(a.indexOf(":")+1):a}
function removeComment(a){return-1!==a.indexOf(";")?a.substring(0,a.indexOf(";")):a}function checkForLabel(a,c){a=removeComment(a);var b;null!==(b=/\b\w*\b:/.exec(a))&&c.labels.push(b[0].substring(0,b[0].length-1))}function checkForSegmentDeclaration(a){a=getTokens(a);return void 0!==a[0]&&(".data"===a[0].toLowerCase()||".text"===a[0].toLowerCase())}
function checkForEQUInstruction(a,c,b){var d=getTokens(a);return-1!==a.toLowerCase().indexOf(" equ ")||void 0!==d[1]&&"equ"===d[1].toLowerCase()?(a=Number(d[2]),isNaN(a)||a!==Math.floor(a)?c.annotations.push({row:b,column:0,text:"Usage: constant_name EQU immediate_value",type:"error"}):c.labels.push(d[0]),!0):!1}function getTokens(a){a=a.split(/\s+/);for(var c=0;c<a.length;c++)""===a[c]&&a.splice(c,1);return a}function removeLabel(a){return a.replace(/\b\w*\b:/,"")}
function checkForORGInstruction(a,c,b){a=removeComment(a);a=removeLabel(a);a=getTokens(a);var d=a[0];if(void 0!==d&&"org"===d.toLowerCase()){if(console.log(a),1<a.length)return d=Number(a[1]),(isNaN(d)||d!==Math.floor(d))&&c.annotations.push({row:b,column:0,text:"Invalid operand: "+a[1],type:"error"}),!0}else return!1}
function parseDWInstruction(a,c,b){a=a.trim();if("dw"===a.substr(0,2).toLowerCase()){a=a.substr(2,a.length).split(",");for(var d=0;d<a.length;d++){a[d]=a[d].trim();var e=getTokens(a[d]);if(!(2===e.length&&getOperandType(e[0],c)===OPERAND_IMM&&e[1].toLowerCase().startsWith("dup(")&&e[1].endsWith(")")&&getOperandType(e[1].substring(4,e[1].indexOf(")")),c)===OPERAND_IMM||getOperandType(a[d],c)===OPERAND_IMM)){c.annotations.push({row:b,column:0,text:"Usage: DW IMM, IMM ...",type:"error"});break}}return!0}return!1}
function getOperandType(a,c){a=a.trim();if(""===a)return OPERAND_INVALID;if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a)))return OPERAND_IMM;if(/^(a|b|c|d|x|y|bp|sp)$/.test(a.toLowerCase()))return OPERAND_REG;for(b=0;b<c.labels.length;b++)if(a===c.labels[b])return OPERAND_IMM;if(a.startsWith("[")&&a.endsWith("]")){a=a.replace("[","").replace("]","");if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a)))return OPERAND_MEM_IMM;for(var b=0;b<c.labels.length;b++)if(a===c.labels[b])return OPERAND_MEM_IMM;
if(/^(bp|sp)$/.test(a.toLowerCase().substring(0,2).toLowerCase()))a=a.substring(2);else if(/^(a|b|c|d|x|y)$/.test(a.toLowerCase().substring(0,1).toLowerCase()))a=a.substring(1);else return OPERAND_INVALID;if(""===a.replace(/\s+/g,""))return OPERAND_MEM_REG;a=a.replace(/\s+/g,"");for(b=0;b<c.labels.length;b++)if(a.substring(1)===c.labels[b])return OPERAND_MEM_REG;if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a)))return OPERAND_MEM_REG}return OPERAND_INVALID}
function parseDWInstruction(a,c,b){a=a.trim();if("dw"===a.substr(0,2).toLowerCase()){a=a.substr(2,a.length).split(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/,-1);for(var d=0;d<a.length;d++){a[d]=a[d].trim();var e=getTokens(a[d]);if(!(2===e.length&&getOperandType(e[0],c)===OPERAND_IMM&&e[1].toLowerCase().startsWith("dup(")&&e[1].endsWith(")")&&getOperandType(e[1].substring(4,e[1].indexOf(")")),c)===OPERAND_IMM||a[d].startsWith('"')&&a[d].endsWith('"')||getOperandType(a[d],c)===OPERAND_IMM)){c.annotations.push({row:b,
column:0,text:"Usage: DW IMM, IMM ...",type:"error"});break}}return!0}return!1}
function getOperandType(a,c){a=a.trim();if(""===a)return OPERAND_INVALID;if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a))&&-1===a.indexOf("o")&&-1===a.indexOf("e"))return OPERAND_IMM;if(/^(a|b|c|d|x|y|bp|sp)$/.test(a.toLowerCase()))return OPERAND_REG;for(b=0;b<c.labels.length;b++)if(a===c.labels[b])return OPERAND_IMM;if(a.startsWith("[")&&a.endsWith("]")){a=a.replace("[","").replace("]","");if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a)))return OPERAND_MEM_IMM;for(var b=0;b<c.labels.length;b++)if(a===
c.labels[b])return OPERAND_MEM_IMM;if(/^(bp|sp)$/.test(a.toLowerCase().substring(0,2).toLowerCase()))a=a.substring(2);else if(/^(a|b|c|d|x|y)$/.test(a.toLowerCase().substring(0,1).toLowerCase()))a=a.substring(1);else return OPERAND_INVALID;if(""===a.replace(/\s+/g,""))return OPERAND_MEM_REG;a=a.replace(/\s+/g,"");for(b=0;b<c.labels.length;b++)if(a.substring(1)===c.labels[b])return OPERAND_MEM_REG;if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a)))return OPERAND_MEM_REG}return OPERAND_INVALID}
function parseInstruction(a,c,b){a=removeComment(a);a=removeLabel(a);var d=getTokens(a),e=d[0];if(void 0!==e&&""!==e&&!parseDWInstruction(a,c,b))if(/\b(?:mov|add|sub|and|or|test|cmp|shl|shr|mul|push|pop|div|xor|hwi|hwq|nop|neg|call|ret|jmp|jnz|jg|jl|jge|jle|int|jz|js|jns|brk|not|jc|jnc|ror|rol|sal|sar)\b/.test(e.toLowerCase()))if(-1!==a.indexOf(","))if(d=a.substring(a.indexOf(e)+e.length,a.indexOf(",")),a=a.substring(a.indexOf(",")+1).trim(),/\b(?:mov|add|sub|and|or|test|cmp|shl|shr|xor|rol|ror|sal|sar)\b/.test(e.toLowerCase())){e=
getOperandType(d,c);var f=getOperandType(a,c);e===OPERAND_INVALID?c.annotations.push({row:b,column:0,text:"Invalid operand: "+d,type:"error"}):f===OPERAND_INVALID?c.annotations.push({row:b,column:0,text:"Invalid operand: "+a,type:"error"}):e===OPERAND_IMM&&c.annotations.push({row:b,column:0,text:"Destination operand can't be an immediate value",type:"error"})}else c.annotations.push({row:b,column:0,text:e+" instruction with 2 operands is illegal",type:"error"});else 1<d.length?(d=a.substring(a.indexOf(e)+
e.length).trim(),/\b(?:push|mul|pop|div|neg|call|jnz|jg|jl|jge|jle|hwi|hwq|jz|js|jns|ret|jmp|not|jc|jnc)\b/.test(e.toLowerCase())?getOperandType(d,c)===OPERAND_INVALID&&c.annotations.push({row:b,column:0,text:"Invalid operand: "+d,type:"error"}):c.annotations.push({row:b,column:0,text:e+" instruction with 1 operand is illegal",type:"error"})):/\b(?:ret|brk|nop)\b/.test(e.toLowerCase())||c.annotations.push({row:b,column:0,text:e+" instruction with no operand is illegal",type:"error"});else c.annotations.push({row:b,
column:0,text:"Unknown mnemonic: "+e,type:"error"})}function parse(){for(var a=ace.edit("editor").getValue().split("\n"),c={labels:[],annotations:[]},b=0;b<a.length;b++)checkForLabel(a[b],c);for(b=0;b<a.length;b++)checkForSegmentDeclaration(a[b])||checkForEQUInstruction(a[b],c,b)||checkForORGInstruction(a[b],c,b)||parseInstruction(a[b],c,b);editor.getSession().setAnnotations(c.annotations)}function gameClick(){document.getElementById("editorBtns").setAttribute("style","display: none")}
function editorClick(){document.getElementById("editorBtns").setAttribute("style","")}editor.on("change",parse);
column:0,text:"Unknown mnemonic: "+e,type:"error"})}function parse(){for(var a=ace.edit("editor").getValue().split("\n"),c={labels:[],annotations:[]},b=0;b<a.length;b++)checkForLabel(a[b],c);for(b=0;b<a.length;b++)checkForSegmentDeclaration(a[b])||checkForEQUInstruction(a[b],c,b)||checkForORGInstruction(a[b],c,b)||parseInstruction(a[b],c,b);editor.getSession().setAnnotations(c.annotations)}
function gameClick(){document.getElementById("editorBtns").setAttribute("style","display: none");document.getElementById("gameBtns").setAttribute("style","")}function editorClick(){document.getElementById("editorBtns").setAttribute("style","");document.getElementById("gameBtns").setAttribute("style","display: none")}editor.on("change",parse);

View File

@ -17,13 +17,16 @@ var colorScheme = {
tileHoverTint: 0x00FF00,
itemIron: 0x434341,
itemCopper: 0xC87D38,
hologramFill: "#FFFFFF",
hologramStroke: "#9298a8",
hologramFill: "#0aced6",
hologramStroke: "#12FFB0",
hologramAlpha: 0.9
};
var mar = {};
mar.kbBuffer = [];
mar.kbBufferText = "";
mar.animationFrames = {};
mar.controlledUnitVisible = false;
CUBOT_WALK_FRAMES = {
south: 240,
@ -39,6 +42,7 @@ HARVESTER_WALK_FRAMES = {
east: 287
};
LOW_ENERGY = 100;
if (fullscreen) {
@ -216,7 +220,6 @@ function Word(terrain) {
//Update/Create the object
var existingObject = self.getObject(response[i].i);
if (existingObject !== null) {
//Object already exists
existingObject.updated = true;
@ -236,9 +239,19 @@ function Word(terrain) {
//Delete not updated objects (see above comments)
for (var i = 0; i < self.objects.length; i++) {
if (!self.objects[i].updated) {
// console.log("DEBUG: removed " + self.objects[i].id);
//Check if the object we are removing is our controlledUnit, if so, follow it
if (mar.client.username !== "guest") {
if (self.objects[i].type === 1 && self.objects[i].username === mar.client.username) {
findMyRobot();
console.log("Following Cubot " + mar.client.username)
}
}
self.objects[i].destroy();
dispatchTileLeave(self.objects[i].tileX, self.objects[i].tileY);
self.objects.splice(i, 1);
}
}
@ -254,6 +267,7 @@ function updateGameObject(object, responseObj) {
if (object.type === 1) {
object.action = responseObj.action;
object.energy = responseObj.energy;
//Update location
if ((object.tileX !== responseObj.x || object.tileY !== responseObj.y)) {
@ -278,6 +292,13 @@ function updateGameObject(object, responseObj) {
}
//Battery indication
if (object.energy <= LOW_ENERGY) {
object.tint = 0xFF0000;
} else {
object.tint = 0xFFFFFF;
}
//Update direction
switch (object.direction) {
case DIR_NORTH:
@ -299,7 +320,9 @@ function updateGameObject(object, responseObj) {
object.hologram.destroy();
}
if (responseObj.holo !== 0) {
if (responseObj.holoMode === 1) {
//Hex
object.hologram = game.make.text(0, 32, "0x" + ("0000" + Number(responseObj.holo).toString(16).toUpperCase()).slice(-4), {
fontSize: 32,
fill: colorScheme.hologramFill,
@ -307,9 +330,29 @@ function updateGameObject(object, responseObj) {
strokeThickness: 1,
font: "fixedsys"
});
object.hologram.alpha = colorScheme.hologramAlpha;
object.hologram.anchor.set(0.5, 0);
object.addChild(object.hologram);
game.add.tween(object.hologram).to({tint: 0xFFFFF0, alpha: colorScheme.hologramAlpha - 0.1},
mar.client.tickLength, Phaser.Easing.Bounce.In, true);
} else if (responseObj.holoMode === 2) {
//String
object.hologram = game.make.text(0, 32, responseObj.holoStr, {
fontSize: 27,
fill: colorScheme.hologramFill,
stroke: colorScheme.hologramStroke,
strokeThickness: 1,
font: "fixedsys"
});
object.hologram.alpha = colorScheme.hologramAlpha;
object.hologram.anchor.set(0.5, 0);
object.addChild(object.hologram);
game.add.tween(object.hologram).to({tint: 0xFFFFF0, alpha: colorScheme.hologramAlpha - 0.1},
mar.client.tickLength, Phaser.Easing.Bounce.In, true);
}
@ -423,6 +466,7 @@ function createGameObject(objData) {
cubot.heldItem = objData.heldItem;
cubot.direction = objData.direction;
cubot.action = objData.action;
cubot.energy = objData.energy;
cubot.inventory = createInventory([cubot.heldItem]);
cubot.addChild(cubot.inventory);
@ -436,17 +480,29 @@ function createGameObject(objData) {
cubot.onTileHover = function () {
game.add.tween(this).to({isoZ: 45}, 200, Phaser.Easing.Quadratic.InOut, true);
game.add.tween(this.scale).to({x: 1.2, y: 1.2}, 200, Phaser.Easing.Linear.None, true);
this.tint = colorScheme.cubotHoverTint;
if (this.tint !== 0xFF0000) {
this.tint = colorScheme.cubotHoverTint;
}
};
cubot.onTileOut = function () {
document.body.style.cursor = 'default';
game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
this.tint = colorScheme.cubotTint;
if (this.tint !== 0xFF0000) {
this.tint = colorScheme.cubotTint;
}
};
//Battery indication
if (cubot.energy <= LOW_ENERGY) {
cubot.tint = 0xFF0000;
}
cubot.animations.add("walk_w", mar.animationFrames.walk_w, true);
cubot.animations.add("walk_s", mar.animationFrames.walk_s, true);
cubot.animations.add("walk_e", mar.animationFrames.walk_e, true);
@ -475,6 +531,7 @@ function createGameObject(objData) {
var username = game.make.text(0, -24, cubot.username, {
fontSize: 22,
fill: colorScheme.textFill,
@ -484,6 +541,11 @@ function createGameObject(objData) {
});
username.alpha = 0.85;
username.anchor.set(0.5, 0);
if (cubot.username === mar.client.username) {
username.tint = 0xFB4D0A;
} else {
cubot.alpha = 0.6;
}
cubot.addChild(username);
if (objData.holo !== 0) {
@ -657,6 +719,52 @@ function createGameObject(objData) {
};
return factory;
} else if (objData.t === 4) {
//Radio tower
var radioTower = game.add.isoSprite(getIsoX(objData.x), getIsoY(objData.y), 15, "sheet", "objects/RadioTower", isoGroup);
radioTower.anchor.set(0.5, 0.64);
radioTower.id = objData.i;
radioTower.type = 4;
radioTower.tileX = objData.x;
radioTower.tileY = objData.y;
radioTower.hoverText = game.make.text(0, 0, "Radio Tower", {
fontSize: 22,
fill: colorScheme.textFill,
stroke: colorScheme.textStroke,
strokeThickness: 2,
font: "fixedsys"
});
radioTower.hoverText.alpha = 0;
radioTower.hoverText.anchor.set(0.5, 0);
radioTower.addChild(radioTower.hoverText);
radioTower.isAt = function (x, y) {
return this.tileX === x && this.tileY === y;
};
radioTower.onTileHover = function () {
game.tweens.removeFrom(this);
game.add.tween(this).to({isoZ: 45}, 200, Phaser.Easing.Quadratic.InOut, true);
game.add.tween(this.scale).to({x: 1.15, y: 1.15}, 200, Phaser.Easing.Linear.None, true);
this.tint = colorScheme.cubotHoverTint;
game.add.tween(this.hoverText).to({alpha: 0.9}, 200, Phaser.Easing.Quadratic.In, true);
radioTower.hoverText.visible = true;
};
radioTower.onTileOut = function () {
game.tweens.removeFrom(this);
game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true);
game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true);
this.tint = colorScheme.cubotTint;
game.add.tween(this.hoverText).to({alpha: 0}, 200, Phaser.Easing.Quadratic.Out, true);
};
return radioTower;
}
}
@ -703,8 +811,11 @@ function codeResponseListener(message) {
* Listens for user info responses from the server
*/
function userInfoListener(message) {
if (message.t === "userInfo") {
//Create new world / Find my robot
console.log(message);
mar.worldX = message.worldX;
@ -726,9 +837,31 @@ function terrainListener(message) {
} else {
mar.world = new Word(message.terrain);
console.log("Gameloop started");
//Handle keypresses
game.input.keyboard.onDownCallback = function (event) {
//If the game has focus
if (document.activeElement === document.getElementById("game")) {
if ((event.keyCode >= 37 && event.keyCode <= 40) || event.keyCode === 116 || event.keyCode === 32) {
event.preventDefault();
}
if (mar.client.username !== "guest" && mar.kbBuffer.length <= 16) {
mar.client.sendKeypress(event.keyCode);
//Locally update the buffer
mar.kbBuffer.push(event.keyCode);
mar.kbBufferText = formattedKeyBuffer(mar.kbBuffer);
}
}
};
//Grab focus when clicked (For chrome, Opera)
game.input.onDown.add(function () {
document.getElementById("game").focus();
})
}
}
}
@ -752,14 +885,10 @@ function tickListener(message) {
mar.client.socket.send(JSON.stringify({t: "object", x: mar.worldX, y: mar.worldY}));
//Update key buffer display
// if(game.textLayer){
// if(message.keys !== undefined){
// console.log(message.keys);
//
// game.kbBuffer = message.keys;
// game.keyboardBuffer.text = formattedKeyBuffer(game.kbBuffer);
// }
// }
if (message.keys !== undefined) {
mar.kbBuffer = message.keys;
mar.kbBufferText = formattedKeyBuffer(mar.kbBuffer);
}
}
}
@ -870,12 +999,6 @@ var GameClient = function (callback) {
}
};
this.request = function (key) {
if (key !== 0) {
this.socket.send(JSON.stringify({t: "k", k: key}));
}
};
this.requestFloppy = function () {
document.getElementById("floppyDown").innerHTML = "<i class=\"fa fa-cog fa-spin fa-fw\"></i>";
this.socket.send(JSON.stringify({t: "floppyDown"}));
@ -1035,6 +1158,10 @@ BasicGame.Boot.prototype = {
if (debugTile) {
game.debug.text(debugTile, 10, 40);
}
if (mar.client.username !== "guest") {
game.debug.text(mar.kbBufferText, 210, 20);
}
// game.debug.text(debugObj, 32, 190);
// game.debug.text(game.time.fps || '--', 2, 14, "#a7aebe");
@ -1398,6 +1525,38 @@ function getIsoY(tileY) {
return (tileY * 71.5)
}
function findMyRobot() {
if (mar.client.username === "guest") {
alert("You are not logged in!");
} else {
mar.client.requestUserInfo()
}
}
function formattedKeyBuffer(kbBuffer) {
var str = "KB: ";
for (var i = 0; i < 16; i++) {
if (kbBuffer[i] !== undefined) {
str += kbBuffer[i].toString(16) + " ";
} else {
str += "__ ";
}
}
return str;
}
game.state.add('Boot', BasicGame.Boot);
game.state.start('Boot');

76
mar/phaser/mar.min.js vendored
View File

@ -1,50 +1,56 @@
DIR_NORTH=0;DIR_EAST=1;DIR_SOUTH=2;DIR_WEST=3;WORLD_HEIGHT=WORLD_WIDTH=16;var colorScheme={tileTint:16777215,wallTint:14540253,cubotHoverTint:65280,cubotTint:16777215,textFill:"#FFFFFF",textStroke:"#9298a8",biomassTint:6535263,biomassHoverTint:65280,tileHoverTint:65280,itemIron:4408129,itemCopper:13139256,hologramFill:"#FFFFFF",hologramStroke:"#9298a8",hologramAlpha:.9},mar={animationFrames:{}};CUBOT_WALK_FRAMES={south:240,north:194,west:254,east:164};
HARVESTER_WALK_FRAMES={south:347,north:317,west:377,east:287};fullscreen?(RENDERER_WIDTH=window.innerWidth-4,RENDERER_HEIGHT=window.innerHeight-4):(RENDERER_WIDTH=document.getElementById("game").clientWidth,RENDERER_HEIGHT=window.innerHeight/1.25);var game=new Phaser.Game(RENDERER_WIDTH,RENDERER_HEIGHT,Phaser.AUTO,"game",null,!0,!1);
function dispatchTileLeave(a,b){for(var c=0;c<mar.world.tiles.length;c++){var d=mar.world.tiles[c].tileX,e=mar.world.tiles[c].tileY;mar.world.tiles[c].isWall&&(d===a&&e-1===b||d-1===a&&e-1===b||d-1===a&&e===b)&&1!==mar.world.tiles[c].alpha&&game.add.tween(mar.world.tiles[c]).to({alpha:1},175,Phaser.Easing.Quadratic.In,!0)}}
function dispatchTileEnter(a,b){for(var c=0;c<mar.world.tiles.length;c++){var d=mar.world.tiles[c].tileX,e=mar.world.tiles[c].tileY;mar.world.tiles[c].isWall&&(d===a&&e-1===b||d-1===a&&e-1===b||d-1===a&&e===b)&&game.add.tween(mar.world.tiles[c]).to({alpha:.6},300,Phaser.Easing.Quadratic.In,!0)}}
function Word(a){var b=this;b.tiles=[];b.objects=[];setupWorldArrows();this.setTerrain=function(a){for(var d=0;d<WORLD_HEIGHT;d++)for(var c=0;c<WORLD_HEIGHT;c++){var f=a[c*WORLD_WIDTH+d];if(1===f)f=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/bigTile",isoGroup),f.baseZ=0,f.baseTint=colorScheme.wallTint,f.anchor.set(.5,.2),f.isWall=!0;else{if(2===f)f=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/tile",isoGroup),g=game.make.text(0,16,"Iron",{fontSize:22,fill:"#434341",stroke:"#FFFFFF",
strokeThickness:1,font:"fixedsys"}),g.alpha=.6,g.anchor.set(.5,0),f.addChild(g),f.baseZ=0,f.baseTint=15987699;else if(3===f){f=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/tile",isoGroup);var g=game.make.text(0,16,"Copper",{fontSize:22,fill:"#C87D38",stroke:"#FFFFFF",strokeThickness:1,font:"fixedsys"});g.alpha=.6;g.anchor.set(.5,0);f.addChild(g);f.baseZ=0;f.baseTint=15987699}else f=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/tile",isoGroup),f.baseZ=0,f.baseTint=colorScheme.tileTint;
f.anchor.set(.5,0)}f.isTile=!0;f.tileX=d;f.tileY=c;f.tint=f.baseTint;b.tiles.push(f)}};this.setTerrain(a);this.update=function(a){for(var b=0;b<mar.world.objects.length;b++)mar.world.objects[b].destroy();for(b=0;b<mar.world.tiles.length;b++)mar.world.tiles[b].destroy();mar.world.objects=[];mar.world.tiles=[];this.setTerrain(a);game.iso.topologicalSort(isoGroup)};this.getObject=function(a){for(var c=0;c<b.objects.length;c++)if(b.objects[c].id===a)return b.objects[c];return null};this.updateObjects=
function(a){for(c=0;c<b.objects.length;c++)b.objects[c].updated=!1;for(var c=0;c<a.length;c++){var e=b.getObject(a[c].i);null!==e?(e.updated=!0,updateGameObject(e,a[c])):(e=createGameObject(a[c]),e.updated=!0,b.objects.push(e))}for(c=0;c<b.objects.length;c++)b.objects[c].updated||(b.objects[c].destroy(),b.objects.splice(c,1))}}
function updateGameObject(a,b){a.direction=b.direction;if(1===a.type){a.action=b.action;if(a.tileX!==b.x||a.tileY!==b.y)dispatchTileLeave(a.tileX,a.tileY),a.tileX=b.x,a.tileY=b.y,cubotWalk(a,a.direction,void 0,CUBOT_WALK_FRAMES);a.heldItem!==b.heldItem&&(void 0!==a.inventory&&a.inventory.destroy(),a.inventory=createInventory([b.heldItem]),a.addChild(a.inventory),a.heldItem=b.heldItem);switch(a.direction){case DIR_NORTH:a.animations.frame=194;break;case DIR_EAST:a.animations.frame=164;break;case DIR_SOUTH:a.animations.frame=
240;break;case DIR_WEST:a.animations.frame=254}void 0!==a.hologram&&a.hologram.destroy();0!==b.holo&&(a.hologram=game.make.text(0,32,"0x"+("0000"+Number(b.holo).toString(16).toUpperCase()).slice(-4),{fontSize:32,fill:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}),a.hologram.alpha=colorScheme.hologramAlpha,a.hologram.anchor.set(.5,0),a.addChild(a.hologram));1===a.action&&cubotDig(a,a.direction)}else if(10===a.type){a.action=b.action;if(a.tileX!==b.x||
a.tileY!==b.y)dispatchTileLeave(a.tileX,a.tileY),a.tileX=b.x,a.tileY=b.y,cubotWalk(a,a.direction,void 0,HARVESTER_WALK_FRAMES);switch(a.direction){case DIR_NORTH:a.animations.frame=HARVESTER_WALK_FRAMES.north;break;case DIR_EAST:a.animations.frame=HARVESTER_WALK_FRAMES.east;break;case DIR_SOUTH:a.animations.frame=HARVESTER_WALK_FRAMES.south;break;case DIR_WEST:a.animations.frame=HARVESTER_WALK_FRAMES.west}}}
DIR_NORTH=0;DIR_EAST=1;DIR_SOUTH=2;DIR_WEST=3;WORLD_HEIGHT=WORLD_WIDTH=16;var colorScheme={tileTint:16777215,wallTint:14540253,cubotHoverTint:65280,cubotTint:16777215,textFill:"#FFFFFF",textStroke:"#9298a8",biomassTint:6535263,biomassHoverTint:65280,tileHoverTint:65280,itemIron:4408129,itemCopper:13139256,hologramFill:"#0aced6",hologramStroke:"#12FFB0",hologramAlpha:.9},mar={kbBuffer:[],kbBufferText:"",animationFrames:{},controlledUnitVisible:!1};CUBOT_WALK_FRAMES={south:240,north:194,west:254,east:164};
HARVESTER_WALK_FRAMES={south:347,north:317,west:377,east:287};LOW_ENERGY=100;fullscreen?(RENDERER_WIDTH=window.innerWidth-4,RENDERER_HEIGHT=window.innerHeight-4):(RENDERER_WIDTH=document.getElementById("game").clientWidth,RENDERER_HEIGHT=window.innerHeight/1.25);var game=new Phaser.Game(RENDERER_WIDTH,RENDERER_HEIGHT,Phaser.AUTO,"game",null,!0,!1);
function dispatchTileLeave(a,b){for(var c=0;c<mar.world.tiles.length;c++){var d=mar.world.tiles[c].tileX,f=mar.world.tiles[c].tileY;mar.world.tiles[c].isWall&&(d===a&&f-1===b||d-1===a&&f-1===b||d-1===a&&f===b)&&1!==mar.world.tiles[c].alpha&&game.add.tween(mar.world.tiles[c]).to({alpha:1},175,Phaser.Easing.Quadratic.In,!0)}}
function dispatchTileEnter(a,b){for(var c=0;c<mar.world.tiles.length;c++){var d=mar.world.tiles[c].tileX,f=mar.world.tiles[c].tileY;mar.world.tiles[c].isWall&&(d===a&&f-1===b||d-1===a&&f-1===b||d-1===a&&f===b)&&game.add.tween(mar.world.tiles[c]).to({alpha:.6},300,Phaser.Easing.Quadratic.In,!0)}}
function Word(a){var b=this;b.tiles=[];b.objects=[];setupWorldArrows();this.setTerrain=function(a){for(var d=0;d<WORLD_HEIGHT;d++)for(var c=0;c<WORLD_HEIGHT;c++){var e=a[c*WORLD_WIDTH+d];if(1===e)e=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/bigTile",isoGroup),e.baseZ=0,e.baseTint=colorScheme.wallTint,e.anchor.set(.5,.2),e.isWall=!0;else{if(2===e)e=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/tile",isoGroup),g=game.make.text(0,16,"Iron",{fontSize:22,fill:"#434341",stroke:"#FFFFFF",
strokeThickness:1,font:"fixedsys"}),g.alpha=.6,g.anchor.set(.5,0),e.addChild(g),e.baseZ=0,e.baseTint=15987699;else if(3===e){e=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/tile",isoGroup);var g=game.make.text(0,16,"Copper",{fontSize:22,fill:"#C87D38",stroke:"#FFFFFF",strokeThickness:1,font:"fixedsys"});g.alpha=.6;g.anchor.set(.5,0);e.addChild(g);e.baseZ=0;e.baseTint=15987699}else e=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/tile",isoGroup),e.baseZ=0,e.baseTint=colorScheme.tileTint;
e.anchor.set(.5,0)}e.isTile=!0;e.tileX=d;e.tileY=c;e.tint=e.baseTint;b.tiles.push(e)}};this.setTerrain(a);this.update=function(a){for(var b=0;b<mar.world.objects.length;b++)mar.world.objects[b].destroy();for(b=0;b<mar.world.tiles.length;b++)mar.world.tiles[b].destroy();mar.world.objects=[];mar.world.tiles=[];this.setTerrain(a);game.iso.topologicalSort(isoGroup)};this.getObject=function(a){for(var c=0;c<b.objects.length;c++)if(b.objects[c].id===a)return b.objects[c];return null};this.updateObjects=
function(a){for(c=0;c<b.objects.length;c++)b.objects[c].updated=!1;for(var c=0;c<a.length;c++){var f=b.getObject(a[c].i);null!==f?(f.updated=!0,updateGameObject(f,a[c])):(f=createGameObject(a[c]),f.updated=!0,b.objects.push(f))}for(c=0;c<b.objects.length;c++)b.objects[c].updated||("guest"!==mar.client.username&&1===b.objects[c].type&&b.objects[c].username===mar.client.username&&(findMyRobot(),console.log("Following Cubot "+mar.client.username)),b.objects[c].destroy(),dispatchTileLeave(b.objects[c].tileX,
b.objects[c].tileY),b.objects.splice(c,1))}}
function updateGameObject(a,b){a.direction=b.direction;if(1===a.type){a.action=b.action;a.energy=b.energy;if(a.tileX!==b.x||a.tileY!==b.y)dispatchTileLeave(a.tileX,a.tileY),a.tileX=b.x,a.tileY=b.y,cubotWalk(a,a.direction,void 0,CUBOT_WALK_FRAMES);a.heldItem!==b.heldItem&&(void 0!==a.inventory&&a.inventory.destroy(),a.inventory=createInventory([b.heldItem]),a.addChild(a.inventory),a.heldItem=b.heldItem);a.tint=a.energy<=LOW_ENERGY?16711680:16777215;switch(a.direction){case DIR_NORTH:a.animations.frame=194;
break;case DIR_EAST:a.animations.frame=164;break;case DIR_SOUTH:a.animations.frame=240;break;case DIR_WEST:a.animations.frame=254}void 0!==a.hologram&&a.hologram.destroy();1===b.holoMode?(a.hologram=game.make.text(0,32,"0x"+("0000"+Number(b.holo).toString(16).toUpperCase()).slice(-4),{fontSize:32,fill:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}),a.hologram.alpha=colorScheme.hologramAlpha,a.hologram.anchor.set(.5,0),a.addChild(a.hologram),game.add.tween(a.hologram).to({tint:16777200,
alpha:colorScheme.hologramAlpha-.1},mar.client.tickLength,Phaser.Easing.Bounce.In,!0)):2===b.holoMode&&(a.hologram=game.make.text(0,32,b.holoStr,{fontSize:27,fill:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}),a.hologram.alpha=colorScheme.hologramAlpha,a.hologram.anchor.set(.5,0),a.addChild(a.hologram),game.add.tween(a.hologram).to({tint:16777200,alpha:colorScheme.hologramAlpha-.1},mar.client.tickLength,Phaser.Easing.Bounce.In,!0));1===a.action&&cubotDig(a,
a.direction)}else if(10===a.type){a.action=b.action;if(a.tileX!==b.x||a.tileY!==b.y)dispatchTileLeave(a.tileX,a.tileY),a.tileX=b.x,a.tileY=b.y,cubotWalk(a,a.direction,void 0,HARVESTER_WALK_FRAMES);switch(a.direction){case DIR_NORTH:a.animations.frame=HARVESTER_WALK_FRAMES.north;break;case DIR_EAST:a.animations.frame=HARVESTER_WALK_FRAMES.east;break;case DIR_SOUTH:a.animations.frame=HARVESTER_WALK_FRAMES.south;break;case DIR_WEST:a.animations.frame=HARVESTER_WALK_FRAMES.west}}}
function itemColor(a){switch(a){case 1:return colorScheme.biomassTint;case 3:return colorScheme.itemIron;case 4:return colorScheme.itemCopper}}function createInventory(a){var b=game.make.group();switch(a.length){case 0:return b;case 1:if(0!==a[0]){var c=game.make.sprite(0,0,"sheet","inventory/inv1x1");c.anchor.set(.5,.1);c.alpha=.5;var d=game.make.sprite(0,0,"sheet","inventory/item");d.anchor.set(.5,.1);d.tint=itemColor(a[0]);b.addChild(c);b.addChild(d)}return b}for(b=0;b<a.length;b++);}
function createGameObject(a){if(1===a.t){var b=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet",null,isoGroup);b.anchor.set(.5,0);b.inputEnabled=!0;b.events.onInputDown.add(function(){debugObj="Cubot: "+b.tileX+", "+b.tileY});b.events.onInputOver.add(function(){document.body.style.cursor="pointer"});b.events.onInputOut.add(function(){document.body.style.cursor="default"});b.id=a.i;b.type=1;b.tileX=a.x;b.tileY=a.y;b.username=a.parent;b.heldItem=a.heldItem;b.direction=a.direction;b.action=a.action;
b.inventory=createInventory([b.heldItem]);b.addChild(b.inventory);dispatchTileEnter(a.x,a.y);b.isAt=function(a,b){return this.tileX===a&&this.tileY===b};b.onTileHover=function(){game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint};b.onTileOut=function(){document.body.style.cursor="default";game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,
y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint};b.animations.add("walk_w",mar.animationFrames.walk_w,!0);b.animations.add("walk_s",mar.animationFrames.walk_s,!0);b.animations.add("walk_e",mar.animationFrames.walk_e,!0);b.animations.add("walk_n",mar.animationFrames.walk_n,!0);b.animations.add("dig_w",mar.animationFrames.dig_w,!1);b.animations.add("dig_s",mar.animationFrames.dig_s,!1);b.animations.add("dig_e",mar.animationFrames.dig_e,!1);b.animations.add("dig_n",mar.animationFrames.dig_n,
!1);b.queuedAnims=[];switch(b.direction){case DIR_NORTH:b.animations.frame=194;break;case DIR_EAST:b.animations.frame=164;break;case DIR_SOUTH:b.animations.frame=240;break;case DIR_WEST:b.animations.frame=254}var c=game.make.text(0,-24,b.username,{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});c.alpha=.85;c.anchor.set(.5,0);b.addChild(c);0!==a.holo&&(b.hologram=game.make.text(0,32,"0x"+("0000"+Number(a.holo).toString(16).toUpperCase()).slice(-4),
{fontSize:32,fill:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}),b.hologram.alpha=colorScheme.hologramAlpha,b.hologram.anchor.set(.5,0),b.addChild(b.hologram));return b}if(2===a.t){var d=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),10,"sheet",1,isoGroup);d.animations.add("idle",mar.animationFrames.biomassIdle,!0);d.anchor.set(.5,0);d.type=2;d.tileX=a.x;d.tileY=a.y;d.id=a.i;d.tint=colorScheme.biomassTint;d.hoverText=game.make.text(0,0,"Biomass",{fontSize:22,
fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});d.hoverText.alpha=0;d.hoverText.anchor.set(.5,0);d.addChild(d.hoverText);d.isAt=function(a,b){return this.tileX===a&&this.tileY===b};d.isAt=function(a,b){return this.tileX===a&&this.tileY===b};d.onTileHover=function(){game.tweens.removeFrom(this);document.body.style.cursor="pointer";game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);this.tint=colorScheme.biomassHoverTint;game.add.tween(this.scale).to({x:1.2,
y:1.2},200,Phaser.Easing.Linear.None,!0);game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);d.hoverText.visible=!0};d.onTileOut=function(){game.tweens.removeFrom(this);document.body.style.cursor="default";game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.biomassTint;game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,!0)};d.animations.play("idle",
45,!0);return d}if(10===a.t){c=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet",null,isoGroup);c.anchor.set(.5,0);c.id=a.i;c.type=10;c.tileX=a.x;c.tileY=a.y;c.direction=a.direction;c.action=a.action;dispatchTileEnter(a.x,a.y);c.isAt=function(a,b){return this.tileX===a&&this.tileY===b};c.onTileHover=function(){game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint};
c.onTileOut=function(){game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint};c.animations.add("walk_w",mar.animationFrames.harvester_walk_w,!0);c.animations.add("walk_s",mar.animationFrames.harvester_walk_s,!0);c.animations.add("walk_e",mar.animationFrames.harvester_walk_e,!0);c.animations.add("walk_n",mar.animationFrames.harvester_walk_n,!0);c.queuedAnims=[];switch(c.direction){case DIR_NORTH:c.animations.frame=
HARVESTER_WALK_FRAMES.north;break;case DIR_EAST:c.animations.frame=HARVESTER_WALK_FRAMES.east;break;case DIR_SOUTH:c.animations.frame=HARVESTER_WALK_FRAMES.south;break;case DIR_WEST:c.animations.frame=HARVESTER_WALK_FRAMES.west}return c}if(3===a.t){var e=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet","objects/factory",isoGroup);e.anchor.set(.5,.25);e.id=a.i;e.type=3;e.tileX=a.x;e.tileY=a.y;e.hoverText=game.make.text(0,0,"Factory",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,
strokeThickness:2,font:"fixedsys"});e.hoverText.alpha=0;e.hoverText.anchor.set(.5,0);e.addChild(e.hoverText);e.isAt=function(a,b){return(this.tileX===a||this.tileX+1===a)&&(this.tileY+1===b||this.tileY===b)};e.onTileHover=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:25},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.06,y:1.06},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint;game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,
!0);e.hoverText.visible=!0};e.onTileOut=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint;game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,!0)};return e}}function manhanttanDistance(a,b,c,d){return Math.abs(a-c)+Math.abs(b-d)}function codeListener(a){"code"===a.t&&ace.edit("editor").setValue(a.code)}
function authListener(a){"auth"===a.t&&("ok"===a.m?(console.log("Auth successful"),mar.client.requestUserInfo()):alert("Authentication failed. Please make sure you are logged in and reload the page."))}function codeResponseListener(a){"codeResponse"===a.t&&alert("Uploaded and assembled "+a.bytes+" bytes")}function userInfoListener(a){"userInfo"===a.t&&(console.log(a),mar.worldX=a.worldX,mar.worldY=a.worldY,mar.maxWidth=a.maxWidth,mar.client.requestTerrain())}
function terrainListener(a){"terrain"===a.t&&(void 0!==mar.world?(mar.client.socket.send(JSON.stringify({t:"object",x:mar.worldX,y:mar.worldY})),mar.world.update(a.terrain)):(mar.world=new Word(a.terrain),console.log("Gameloop started")))}function objectListener(a){"object"===a.t&&mar.world.updateObjects(a.objects)}
function floppyListener(a){document.getElementById("floppyDown").innerHTML='<i class="fa fa-long-arrow-down" aria-hidden="true"></i> <i class="fa fa-floppy-o" aria-hidden="true"></i>';a=new Blob([a.data],{type:"application/octet-stream"});saveAs(a,"floppy.bin")}function tickListener(a){"tick"===a.t&&mar.client.socket.send(JSON.stringify({t:"object",x:mar.worldX,y:mar.worldY}))}
var GameClient=function(a){var b=this,c=[],d=new XMLHttpRequest;d.open("GET","./getServerInfo.php",!0);d.onreadystatechange=function(){4===d.readyState&&200===d.status&&(console.log("Received server info "+d.responseText),setTimeout(function(){var e=JSON.parse(d.responseText);console.log(e.address);b.socket=new WebSocket(e.address);b.username=e.username;b.tickLength=e.tickLength;b.serverName=e.serverName;mar.client.socket.binaryType="arraybuffer";b.socket.onopen=function(){b.socket.send(e.token);
c.push(authListener);c.push(userInfoListener);c.push(terrainListener);c.push(tickListener);c.push(objectListener);c.push(codeListener);c.push(codeResponseListener);mar.client.socket.onmessage=function(a){try{var b=JSON.parse(a.data)}catch(h){console.log(h),floppyListener(a)}for(a=0;a<c.length;a++)c[a](b)};b.reloadCode();void 0!==a&&a()};b.socket.onerror=function(a){alert("Can't connect to game server at address "+e.address);console.log(a)};b.socket.onclose=function(a){alert("Disconnected from server");
b.energy=a.energy;b.inventory=createInventory([b.heldItem]);b.addChild(b.inventory);dispatchTileEnter(a.x,a.y);b.isAt=function(a,b){return this.tileX===a&&this.tileY===b};b.onTileHover=function(){game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);16711680!==this.tint&&(this.tint=colorScheme.cubotHoverTint)};b.onTileOut=function(){document.body.style.cursor="default";game.add.tween(this).to({isoZ:15},
400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);16711680!==this.tint&&(this.tint=colorScheme.cubotTint)};b.energy<=LOW_ENERGY&&(b.tint=16711680);b.animations.add("walk_w",mar.animationFrames.walk_w,!0);b.animations.add("walk_s",mar.animationFrames.walk_s,!0);b.animations.add("walk_e",mar.animationFrames.walk_e,!0);b.animations.add("walk_n",mar.animationFrames.walk_n,!0);b.animations.add("dig_w",mar.animationFrames.dig_w,!1);b.animations.add("dig_s",
mar.animationFrames.dig_s,!1);b.animations.add("dig_e",mar.animationFrames.dig_e,!1);b.animations.add("dig_n",mar.animationFrames.dig_n,!1);b.queuedAnims=[];switch(b.direction){case DIR_NORTH:b.animations.frame=194;break;case DIR_EAST:b.animations.frame=164;break;case DIR_SOUTH:b.animations.frame=240;break;case DIR_WEST:b.animations.frame=254}var c=game.make.text(0,-24,b.username,{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});c.alpha=.85;c.anchor.set(.5,
0);b.username===mar.client.username?c.tint=16469258:b.alpha=.6;b.addChild(c);0!==a.holo&&(b.hologram=game.make.text(0,32,"0x"+("0000"+Number(a.holo).toString(16).toUpperCase()).slice(-4),{fontSize:32,fill:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}),b.hologram.alpha=colorScheme.hologramAlpha,b.hologram.anchor.set(.5,0),b.addChild(b.hologram));return b}if(2===a.t){var d=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),10,"sheet",1,isoGroup);d.animations.add("idle",
mar.animationFrames.biomassIdle,!0);d.anchor.set(.5,0);d.type=2;d.tileX=a.x;d.tileY=a.y;d.id=a.i;d.tint=colorScheme.biomassTint;d.hoverText=game.make.text(0,0,"Biomass",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});d.hoverText.alpha=0;d.hoverText.anchor.set(.5,0);d.addChild(d.hoverText);d.isAt=function(a,b){return this.tileX===a&&this.tileY===b};d.isAt=function(a,b){return this.tileX===a&&this.tileY===b};d.onTileHover=function(){game.tweens.removeFrom(this);
document.body.style.cursor="pointer";game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);this.tint=colorScheme.biomassHoverTint;game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);d.hoverText.visible=!0};d.onTileOut=function(){game.tweens.removeFrom(this);document.body.style.cursor="default";game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,
y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.biomassTint;game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,!0)};d.animations.play("idle",45,!0);return d}if(10===a.t){c=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet",null,isoGroup);c.anchor.set(.5,0);c.id=a.i;c.type=10;c.tileX=a.x;c.tileY=a.y;c.direction=a.direction;c.action=a.action;dispatchTileEnter(a.x,a.y);c.isAt=function(a,b){return this.tileX===a&&this.tileY===b};c.onTileHover=function(){game.add.tween(this).to({isoZ:45},
200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint};c.onTileOut=function(){game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint};c.animations.add("walk_w",mar.animationFrames.harvester_walk_w,!0);c.animations.add("walk_s",mar.animationFrames.harvester_walk_s,!0);c.animations.add("walk_e",
mar.animationFrames.harvester_walk_e,!0);c.animations.add("walk_n",mar.animationFrames.harvester_walk_n,!0);c.queuedAnims=[];switch(c.direction){case DIR_NORTH:c.animations.frame=HARVESTER_WALK_FRAMES.north;break;case DIR_EAST:c.animations.frame=HARVESTER_WALK_FRAMES.east;break;case DIR_SOUTH:c.animations.frame=HARVESTER_WALK_FRAMES.south;break;case DIR_WEST:c.animations.frame=HARVESTER_WALK_FRAMES.west}return c}if(3===a.t){var f=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet","objects/factory",
isoGroup);f.anchor.set(.5,.25);f.id=a.i;f.type=3;f.tileX=a.x;f.tileY=a.y;f.hoverText=game.make.text(0,0,"Factory",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});f.hoverText.alpha=0;f.hoverText.anchor.set(.5,0);f.addChild(f.hoverText);f.isAt=function(a,b){return(this.tileX===a||this.tileX+1===a)&&(this.tileY+1===b||this.tileY===b)};f.onTileHover=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:25},200,Phaser.Easing.Quadratic.InOut,
!0);game.add.tween(this.scale).to({x:1.06,y:1.06},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint;game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);f.hoverText.visible=!0};f.onTileOut=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint;game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,
!0)};return f}if(4===a.t){var e=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet","objects/RadioTower",isoGroup);e.anchor.set(.5,.64);e.id=a.i;e.type=4;e.tileX=a.x;e.tileY=a.y;e.hoverText=game.make.text(0,0,"Radio Tower",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});e.hoverText.alpha=0;e.hoverText.anchor.set(.5,0);e.addChild(e.hoverText);e.isAt=function(a,b){return this.tileX===a&&this.tileY===b};e.onTileHover=function(){game.tweens.removeFrom(this);
game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.15,y:1.15},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint;game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);e.hoverText.visible=!0};e.onTileOut=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint;
game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,!0)};return e}}function manhanttanDistance(a,b,c,d){return Math.abs(a-c)+Math.abs(b-d)}function codeListener(a){"code"===a.t&&ace.edit("editor").setValue(a.code)}function authListener(a){"auth"===a.t&&("ok"===a.m?(console.log("Auth successful"),mar.client.requestUserInfo()):alert("Authentication failed. Please make sure you are logged in and reload the page."))}
function codeResponseListener(a){"codeResponse"===a.t&&alert("Uploaded and assembled "+a.bytes+" bytes")}function userInfoListener(a){"userInfo"===a.t&&(console.log(a),mar.worldX=a.worldX,mar.worldY=a.worldY,mar.maxWidth=a.maxWidth,mar.client.requestTerrain())}
function terrainListener(a){"terrain"===a.t&&(void 0!==mar.world?(mar.client.socket.send(JSON.stringify({t:"object",x:mar.worldX,y:mar.worldY})),mar.world.update(a.terrain)):(mar.world=new Word(a.terrain),console.log("Gameloop started"),game.input.keyboard.onDownCallback=function(a){document.activeElement===document.getElementById("game")&&((37<=a.keyCode&&40>=a.keyCode||116===a.keyCode||32===a.keyCode)&&a.preventDefault(),"guest"!==mar.client.username&&16>=mar.kbBuffer.length&&(mar.client.sendKeypress(a.keyCode),
mar.kbBuffer.push(a.keyCode),mar.kbBufferText=formattedKeyBuffer(mar.kbBuffer)))},game.input.onDown.add(function(){document.getElementById("game").focus()})))}function objectListener(a){"object"===a.t&&mar.world.updateObjects(a.objects)}function floppyListener(a){document.getElementById("floppyDown").innerHTML='<i class="fa fa-long-arrow-down" aria-hidden="true"></i> <i class="fa fa-floppy-o" aria-hidden="true"></i>';a=new Blob([a.data],{type:"application/octet-stream"});saveAs(a,"floppy.bin")}
function tickListener(a){"tick"===a.t&&(mar.client.socket.send(JSON.stringify({t:"object",x:mar.worldX,y:mar.worldY})),void 0!==a.keys&&(mar.kbBuffer=a.keys,mar.kbBufferText=formattedKeyBuffer(mar.kbBuffer)))}
var GameClient=function(a){var b=this,c=[],d=new XMLHttpRequest;d.open("GET","./getServerInfo.php",!0);d.onreadystatechange=function(){4===d.readyState&&200===d.status&&(console.log("Received server info "+d.responseText),setTimeout(function(){var f=JSON.parse(d.responseText);console.log(f.address);b.socket=new WebSocket(f.address);b.username=f.username;b.tickLength=f.tickLength;b.serverName=f.serverName;mar.client.socket.binaryType="arraybuffer";b.socket.onopen=function(){b.socket.send(f.token);
c.push(authListener);c.push(userInfoListener);c.push(terrainListener);c.push(tickListener);c.push(objectListener);c.push(codeListener);c.push(codeResponseListener);mar.client.socket.onmessage=function(a){try{var b=JSON.parse(a.data)}catch(h){console.log(h),floppyListener(a)}for(a=0;a<c.length;a++)c[a](b)};b.reloadCode();void 0!==a&&a()};b.socket.onerror=function(a){alert("Can't connect to game server at address "+f.address);console.log(a)};b.socket.onclose=function(a){alert("Disconnected from server");
console.log(a)}},100))};d.send(null);this.requestUserInfo=function(){this.socket.send(JSON.stringify({t:"userInfo"}))};this.requestTerrain=function(){this.socket.send(JSON.stringify({t:"terrain",x:mar.worldX,y:mar.worldY}))};this.uploadCode=function(a){console.log("Uploaded code");this.socket.send(JSON.stringify({t:"uploadCode",code:a}))};this.reloadCode=function(){this.socket.send(JSON.stringify({t:"codeRequest"}))};this.sendKeypress=function(a){0!==a&&this.socket.send(JSON.stringify({t:"k",k:a}))};
this.request=function(a){0!==a&&this.socket.send(JSON.stringify({t:"k",k:a}))};this.requestFloppy=function(){document.getElementById("floppyDown").innerHTML='<i class="fa fa-cog fa-spin fa-fw"></i>';this.socket.send(JSON.stringify({t:"floppyDown"}))};this.notifyFloppyUp=function(){this.socket.send(JSON.stringify({t:"floppyUp"}))}};function dispatchTileHover(a,b){for(var c in mar.world.objects){var d=mar.world.objects[c];if(d.isAt(a,b))d.onTileHover()}}
function dispatchTileOut(a,b){for(var c in mar.world.objects){var d=mar.world.objects[c];if(d.isAt(a,b))d.onTileOut()}}var count=0,BasicGame=function(a){};BasicGame.Boot=function(a){};var isoGroup,cursorPos,cursor,debugTile,debugObj,objectsGroup,cursors,tmpLine;
this.requestFloppy=function(){document.getElementById("floppyDown").innerHTML='<i class="fa fa-cog fa-spin fa-fw"></i>';this.socket.send(JSON.stringify({t:"floppyDown"}))};this.notifyFloppyUp=function(){this.socket.send(JSON.stringify({t:"floppyUp"}))}};function dispatchTileHover(a,b){for(var c in mar.world.objects){var d=mar.world.objects[c];if(d.isAt(a,b))d.onTileHover()}}function dispatchTileOut(a,b){for(var c in mar.world.objects){var d=mar.world.objects[c];if(d.isAt(a,b))d.onTileOut()}}
var count=0,BasicGame=function(a){};BasicGame.Boot=function(a){};var isoGroup,cursorPos,cursor,debugTile,debugObj,objectsGroup,cursors,tmpLine;
BasicGame.Boot.prototype={preload:function(){game.load.atlasJSONHash("sheet","./mar/sprites.png","./mar/sprites.json");game.time.advancedTiming=!0;game.plugins.add(new Phaser.Plugin.Isometric(game));game.iso.anchor.setTo(.5,0);game.world.setBounds(0,0,2200,1100);game.camera.x=280;game.camera.y=90;game.stage.disableVisibilityChange=!0},create:function(){isoGroup=game.add.group();objectsGroup=game.add.group();initialiseAnimations();this.spawnTiles();cursorPos=new Phaser.Plugin.Isometric.Point3;cursors=
game.input.keyboard.createCursorKeys()},update:function(){game.iso.unproject(game.input.activePointer.position,cursorPos);isoGroup.forEach(function(a){if(a.isTile){var b=a.isoBounds.containsXY(cursorPos.x,cursorPos.y);!a.selected&&b?(a.selected=!0,a.tint=colorScheme.tileHoverTint,debugTile=a.tileX+", "+a.tileY,dispatchTileHover(a.tileX,a.tileY),game.add.tween(a).to({isoZ:a.baseZ+8},200,Phaser.Easing.Quadratic.InOut,!0)):a.selected&&!b&&(dispatchTileOut(a.tileX,a.tileY),a.selected=!1,a.tint=a.baseTint,
game.add.tween(a).to({isoZ:a.baseZ},200,Phaser.Easing.Quadratic.InOut,!0))}});this.game.input.activePointer.isDown?(this.game.origDragPoint&&(this.game.camera.x+=this.game.origDragPoint.x-this.game.input.activePointer.position.x,this.game.camera.y+=this.game.origDragPoint.y-this.game.input.activePointer.position.y),this.game.origDragPoint=this.game.input.activePointer.position.clone()):this.game.origDragPoint=null;count++;0===count%10&&game.iso.topologicalSort(isoGroup)},render:function(){void 0!==
mar.worldX?game.debug.text("World: ("+Number(mar.worldX).toString(16)+", "+Number(mar.worldY).toString(16)+")",10,20):game.debug.text("World: (?,?)",10,20);debugTile&&game.debug.text(debugTile,10,40);void 0!==tmpLine&&(game.debug.geom(tmpLine),game.debug.lineInfo(tmpLine,32,32))},spawnTiles:function(){mar.client=new GameClient}};
mar.worldX?game.debug.text("World: ("+Number(mar.worldX).toString(16)+", "+Number(mar.worldY).toString(16)+")",10,20):game.debug.text("World: (?,?)",10,20);debugTile&&game.debug.text(debugTile,10,40);"guest"!==mar.client.username&&game.debug.text(mar.kbBufferText,210,20);void 0!==tmpLine&&(game.debug.geom(tmpLine),game.debug.lineInfo(tmpLine,32,32))},spawnTiles:function(){mar.client=new GameClient}};
function setupWorldArrows(){var a=game.make.isoSprite(528,-10,10,"sheet","ui/arrow_north",isoGroup);a.inputEnabled=!0;a.events.onInputDown.add(function(){0===mar.worldY?mar.worldY=mar.maxWidth:mar.worldY--;mar.client.requestTerrain()});a.events.onInputOver.add(function(){a.tint=65280;document.body.style.cursor="pointer"});a.events.onInputOut.add(function(){a.tint=16777215;document.body.style.cursor="default"});isoGroup.addChild(a);var b=game.make.isoSprite(1115,587,10,"sheet","ui/arrow_east",isoGroup);
b.inputEnabled=!0;b.events.onInputDown.add(function(){mar.worldX===mar.maxWidth?mar.worldX=0:mar.worldX++;mar.client.requestTerrain()});b.events.onInputOver.add(function(){b.tint=65280;document.body.style.cursor="pointer"});b.events.onInputOut.add(function(){b.tint=16777215;document.body.style.cursor="default"});isoGroup.addChild(b);var c=game.make.isoSprite(528,1170,10,"sheet","ui/arrow_south",isoGroup);c.inputEnabled=!0;c.events.onInputDown.add(function(){mar.worldY===mar.maxWidth?mar.worldY=0:
mar.worldY++;mar.client.requestTerrain()});c.events.onInputOver.add(function(){c.tint=65280;document.body.style.cursor="pointer"});c.events.onInputOut.add(function(){c.tint=16777215;document.body.style.cursor="default"});isoGroup.addChild(c);var d=game.make.isoSprite(-60,587,10,"sheet","ui/arrow_west",isoGroup);d.inputEnabled=!0;d.events.onInputDown.add(function(){0===mar.worldX?mar.worldX=mar.maxWidth:mar.worldX--;mar.client.requestTerrain()});d.events.onInputOver.add(function(){d.tint=65280;document.body.style.cursor=
"pointer"});d.events.onInputOut.add(function(){d.tint=16777215;document.body.style.cursor="default"});isoGroup.addChild(d)}function cubotDig(a,b,c){b===DIR_NORTH?a.animations.play("dig_n",45):b===DIR_EAST?a.animations.play("dig_e",45):b===DIR_SOUTH?a.animations.play("dig_s",45):b===DIR_WEST&&a.animations.play("dig_w",45)}
function cubotWalk(a,b,c,d){var e;if(b===DIR_SOUTH)var f=function(b){a.animations.play("walk_s",60,!0);e=game.add.tween(a).to({isoX:getIsoX(a.tileX),isoY:getIsoY(a.tileY)},b,Phaser.Easing.Linear.None,!0);dispatchTileEnter(a.tileX,a.tileY);e.onComplete.add(function(){a.animations.stop();a.animations.frame=d.south;a.onTileOut();a.isoX=getIsoX(a.tileX);a.isoY=getIsoY(a.tileY);void 0!==c&&c();for(var b=0;b<a.queuedAnims.length;b++)a.queuedAnims[b](500),a.queuedAnims.splice(b,1)})};else b===DIR_NORTH?
f=function(b){a.animations.play("walk_n",60,!0);e=game.add.tween(a).to({isoX:getIsoX(a.tileX),isoY:getIsoY(a.tileY)},b,Phaser.Easing.Linear.None,!0);dispatchTileEnter(a.tileX,a.tileY);e.onComplete.add(function(){a.animations.stop();a.animations.frame=d.north;a.onTileOut();a.isoX=getIsoX(a.tileX);a.isoY=getIsoY(a.tileY);void 0!==c&&c();for(var b=0;b<a.queuedAnims.length;b++)a.queuedAnims[b](500),a.queuedAnims.splice(b,1)})}:b===DIR_WEST?f=function(b){a.animations.play("walk_w",60,!0);e=game.add.tween(a).to({isoX:getIsoX(a.tileX),
isoY:getIsoY(a.tileY)},b,Phaser.Easing.Linear.None,!0);dispatchTileEnter(a.tileX,a.tileY);e.onComplete.add(function(){a.animations.stop();a.animations.frame=d.west;a.onTileOut();a.isoX=getIsoX(a.tileX);a.isoY=getIsoY(a.tileY);void 0!==c&&c();for(var b=0;b<a.queuedAnims.length;b++)a.queuedAnims[b](500),a.queuedAnims.splice(b,1)})}:b===DIR_EAST&&(f=function(b){a.animations.play("walk_e",60,!0);e=game.add.tween(a).to({isoX:getIsoX(a.tileX),isoY:getIsoY(a.tileY)},b,Phaser.Easing.Linear.None,!0);dispatchTileEnter(a.tileX,
a.tileY);e.onComplete.add(function(){a.animations.stop();a.animations.frame=d.east;a.onTileOut();a.isoX=getIsoX(a.tileX);a.isoY=getIsoY(a.tileY);void 0!==c&&c();for(var b=0;b<a.queuedAnims.length;b++)a.queuedAnims[b](500),a.queuedAnims.splice(b,1)})});a.animations.currentAnim.isPlaying?(a.queuedAnims.push(f),console.log("Queued Animation")):f(800)}
function cubotWalk(a,b,c,d){var f;if(b===DIR_SOUTH)var e=function(b){a.animations.play("walk_s",60,!0);f=game.add.tween(a).to({isoX:getIsoX(a.tileX),isoY:getIsoY(a.tileY)},b,Phaser.Easing.Linear.None,!0);dispatchTileEnter(a.tileX,a.tileY);f.onComplete.add(function(){a.animations.stop();a.animations.frame=d.south;a.onTileOut();a.isoX=getIsoX(a.tileX);a.isoY=getIsoY(a.tileY);void 0!==c&&c();for(var b=0;b<a.queuedAnims.length;b++)a.queuedAnims[b](500),a.queuedAnims.splice(b,1)})};else b===DIR_NORTH?
e=function(b){a.animations.play("walk_n",60,!0);f=game.add.tween(a).to({isoX:getIsoX(a.tileX),isoY:getIsoY(a.tileY)},b,Phaser.Easing.Linear.None,!0);dispatchTileEnter(a.tileX,a.tileY);f.onComplete.add(function(){a.animations.stop();a.animations.frame=d.north;a.onTileOut();a.isoX=getIsoX(a.tileX);a.isoY=getIsoY(a.tileY);void 0!==c&&c();for(var b=0;b<a.queuedAnims.length;b++)a.queuedAnims[b](500),a.queuedAnims.splice(b,1)})}:b===DIR_WEST?e=function(b){a.animations.play("walk_w",60,!0);f=game.add.tween(a).to({isoX:getIsoX(a.tileX),
isoY:getIsoY(a.tileY)},b,Phaser.Easing.Linear.None,!0);dispatchTileEnter(a.tileX,a.tileY);f.onComplete.add(function(){a.animations.stop();a.animations.frame=d.west;a.onTileOut();a.isoX=getIsoX(a.tileX);a.isoY=getIsoY(a.tileY);void 0!==c&&c();for(var b=0;b<a.queuedAnims.length;b++)a.queuedAnims[b](500),a.queuedAnims.splice(b,1)})}:b===DIR_EAST&&(e=function(b){a.animations.play("walk_e",60,!0);f=game.add.tween(a).to({isoX:getIsoX(a.tileX),isoY:getIsoY(a.tileY)},b,Phaser.Easing.Linear.None,!0);dispatchTileEnter(a.tileX,
a.tileY);f.onComplete.add(function(){a.animations.stop();a.animations.frame=d.east;a.onTileOut();a.isoX=getIsoX(a.tileX);a.isoY=getIsoY(a.tileY);void 0!==c&&c();for(var b=0;b<a.queuedAnims.length;b++)a.queuedAnims[b](500),a.queuedAnims.splice(b,1)})});a.animations.currentAnim.isPlaying?(a.queuedAnims.push(e),console.log("Queued Animation")):e(800)}
function initialiseAnimations(){mar.animationFrames.walk_e_start=[];for(var a=0;10>a;a++)mar.animationFrames.walk_e_start.push("cubot/walk_e/"+("0000"+a).slice(-4));mar.animationFrames.walk_e=[];for(a=10;30>a;a++)mar.animationFrames.walk_e.push("cubot/walk_e/"+("0000"+a).slice(-4));mar.animationFrames.harvester_walk_e_start=[];for(a=0;10>a;a++)mar.animationFrames.harvester_walk_e_start.push("harvester/walk_e/"+("0000"+a).slice(-4));mar.animationFrames.harvester_walk_e=[];for(a=10;30>a;a++)mar.animationFrames.harvester_walk_e.push("harvester/walk_e/"+
("0000"+a).slice(-4));mar.animationFrames.walk_n_start=[];for(a=0;10>a;a++)mar.animationFrames.walk_n_start.push("cubot/walk_n/"+("0000"+a).slice(-4));mar.animationFrames.walk_n=[];for(a=10;30>a;a++)mar.animationFrames.walk_n.push("cubot/walk_n/"+("0000"+a).slice(-4));mar.animationFrames.harvester_walk_n_start=[];for(a=0;10>a;a++)mar.animationFrames.harvester_walk_n_start.push("harvester/walk_n/"+("0000"+a).slice(-4));mar.animationFrames.harvester_walk_n=[];for(a=10;30>a;a++)mar.animationFrames.harvester_walk_n.push("harvester/walk_n/"+
("0000"+a).slice(-4));mar.animationFrames.walk_s_start=[];for(a=0;10>a;a++)mar.animationFrames.walk_s_start.push("cubot/walk_s/"+("0000"+a).slice(-4));mar.animationFrames.walk_s=[];for(a=10;30>a;a++)mar.animationFrames.walk_s.push("cubot/walk_s/"+("0000"+a).slice(-4));mar.animationFrames.harvester_walk_s_start=[];for(a=0;10>a;a++)mar.animationFrames.harvester_walk_s_start.push("harvester/walk_s/"+("0000"+a).slice(-4));mar.animationFrames.harvester_walk_s=[];for(a=10;30>a;a++)mar.animationFrames.harvester_walk_s.push("harvester/walk_s/"+
("0000"+a).slice(-4));mar.animationFrames.walk_w_start=[];for(a=0;10>a;a++)mar.animationFrames.walk_w_start.push("cubot/walk_w/"+("0000"+a).slice(-4));mar.animationFrames.walk_w=[];for(a=10;30>a;a++)mar.animationFrames.walk_w.push("cubot/walk_w/"+("0000"+a).slice(-4));mar.animationFrames.harvester_walk_w_start=[];for(a=0;10>a;a++)mar.animationFrames.harvester_walk_w_start.push("harvester/walk_w/"+("0000"+a).slice(-4));mar.animationFrames.harvester_walk_w=[];for(a=10;30>a;a++)mar.animationFrames.harvester_walk_w.push("harvester/walk_w/"+
("0000"+a).slice(-4));mar.animationFrames.dig_e=[];for(a=1;41>=a;a++)mar.animationFrames.dig_e.push("cubot/dig_e/"+("0000"+a).slice(-4));mar.animationFrames.dig_n=[];for(a=1;41>=a;a++)mar.animationFrames.dig_n.push("cubot/dig_n/"+("0000"+a).slice(-4));mar.animationFrames.dig_s=[];for(a=1;41>=a;a++)mar.animationFrames.dig_s.push("cubot/dig_s/"+("0000"+a).slice(-4));mar.animationFrames.dig_w=[];for(a=1;41>=a;a++)mar.animationFrames.dig_w.push("cubot/dig_w/"+("0000"+a).slice(-4));mar.animationFrames.biomassIdle=
[];for(a=1;60>a;a++)mar.animationFrames.biomassIdle.push("objects/biomass/idle/"+("0000"+a).slice(-4))}function getIsoX(a){return 71.5*a}function getIsoY(a){return 71.5*a}game.state.add("Boot",BasicGame.Boot);game.state.start("Boot");
[];for(a=1;60>a;a++)mar.animationFrames.biomassIdle.push("objects/biomass/idle/"+("0000"+a).slice(-4))}function getIsoX(a){return 71.5*a}function getIsoY(a){return 71.5*a}function findMyRobot(){"guest"===mar.client.username?alert("You are not logged in!"):mar.client.requestUserInfo()}function formattedKeyBuffer(a){for(var b="KB: ",c=0;16>c;c++)b=void 0!==a[c]?b+(a[c].toString(16)+" "):b+"__ ";return b}game.state.add("Boot",BasicGame.Boot);game.state.start("Boot");

View File

@ -4221,7 +4221,7 @@
"sourceSize": {"w":128,"h":70},
"pivot": {"x":0.5,"y":0.5}
},
"objects/factory":
"objects/factory":
{
"frame": {"x":256,"y":1050,"w":256,"h":192},
"rotated": false,
@ -4275,9 +4275,38 @@
"sourceSize": {"w":64,"h":64},
"pivot": {"x":0.5,"y":0.5}
},
"objects/RadioTower": {
"frame": {
"x": 904,
"y": 1050,
"w": 128,
"h": 210
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 128,
"h": 210
},
"sourceSize": {
"w": 128,
"h": 210
},
"pivot": {
"x": 0.5,
"y": 0.5
}
},
"objects/rocket":
{
"frame": {"x":904,"y":1050,"w":135,"h":189},
"frame": {
"x": 1032,
"y": 1050,
"w": 135,
"h": 189
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":135,"h":189},
@ -4286,7 +4315,12 @@
},
"tiles/bigTile":
{
"frame": {"x":1039,"y":1050,"w":128,"h":140},
"frame": {
"x": 1167,
"y": 1050,
"w": 128,
"h": 140
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":140},
@ -4295,7 +4329,12 @@
},
"tiles/copper":
{
"frame": {"x":1167,"y":1050,"w":128,"h":64},
"frame": {
"x": 1295,
"y": 1050,
"w": 128,
"h": 64
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":64},
@ -4304,7 +4343,12 @@
},
"tiles/iron":
{
"frame": {"x":1295,"y":1050,"w":128,"h":64},
"frame": {
"x": 1423,
"y": 1050,
"w": 128,
"h": 64
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":64},
@ -4313,7 +4357,12 @@
},
"tiles/plain":
{
"frame": {"x":1423,"y":1050,"w":128,"h":64},
"frame": {
"x": 1551,
"y": 1050,
"w": 128,
"h": 64
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":64},
@ -4322,7 +4371,12 @@
},
"tiles/plain_s":
{
"frame": {"x":1551,"y":1050,"w":128,"h":64},
"frame": {
"x": 1679,
"y": 1050,
"w": 128,
"h": 64
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":64},
@ -4331,7 +4385,12 @@
},
"tiles/tile":
{
"frame": {"x":1679,"y":1050,"w":128,"h":114},
"frame": {
"x": 1807,
"y": 1050,
"w": 128,
"h": 114
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":114},
@ -4340,7 +4399,12 @@
},
"tiles/wall":
{
"frame": {"x":1807,"y":1050,"w":128,"h":103},
"frame": {
"x": 1935,
"y": 1050,
"w": 128,
"h": 103
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":103},
@ -4349,7 +4413,12 @@
},
"tiles/wall_s":
{
"frame": {"x":1935,"y":1050,"w":128,"h":103},
"frame": {
"x": 2063,
"y": 1050,
"w": 128,
"h": 103
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":103},
@ -4358,7 +4427,12 @@
},
"ui/arrow_east":
{
"frame": {"x":2063,"y":1050,"w":102,"h":51},
"frame": {
"x": 2191,
"y": 1050,
"w": 102,
"h": 51
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":102,"h":51},
@ -4367,7 +4441,12 @@
},
"ui/arrow_east_s":
{
"frame": {"x":2165,"y":1050,"w":102,"h":51},
"frame": {
"x": 2293,
"y": 1050,
"w": 102,
"h": 51
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":102,"h":51},
@ -4376,7 +4455,12 @@
},
"ui/arrow_north":
{
"frame": {"x":2267,"y":1050,"w":102,"h":51},
"frame": {
"x": 2395,
"y": 1050,
"w": 102,
"h": 51
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":102,"h":51},
@ -4385,7 +4469,12 @@
},
"ui/arrow_north_s":
{
"frame": {"x":2369,"y":1050,"w":102,"h":51},
"frame": {
"x": 2497,
"y": 1050,
"w": 102,
"h": 51
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":102,"h":51},
@ -4394,7 +4483,12 @@
},
"ui/arrow_south":
{
"frame": {"x":2471,"y":1050,"w":102,"h":51},
"frame": {
"x": 2599,
"y": 1050,
"w": 102,
"h": 51
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":102,"h":51},
@ -4403,7 +4497,12 @@
},
"ui/arrow_south_s":
{
"frame": {"x":2573,"y":1050,"w":102,"h":51},
"frame": {
"x": 2701,
"y": 1050,
"w": 102,
"h": 51
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":102,"h":51},
@ -4412,7 +4511,12 @@
},
"ui/arrow_west":
{
"frame": {"x":2675,"y":1050,"w":102,"h":51},
"frame": {
"x": 2803,
"y": 1050,
"w": 102,
"h": 51
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":102,"h":51},
@ -4421,7 +4525,12 @@
},
"ui/arrow_west_s":
{
"frame": {"x":2777,"y":1050,"w":102,"h":51},
"frame": {
"x": 2905,
"y": 1050,
"w": 102,
"h": 51
},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":102,"h":51},
@ -4433,8 +4542,11 @@
"version": "1.0",
"image": "sprites.png",
"format": "RGBA8888",
"size": {"w":3968,"h":1242},
"size": {
"w": 3968,
"h": 1260
},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:3e5e86b81265c9a25c883a4b788fcc48:d45ceb66196fa2f419192af0c660b105:1eabdf11f75e3a4fe3147baf7b5be24b$"
"smartupdate": "$TexturePacker:SmartUpdate:9033aea0c9a897c0ef813d508f6a34d4:37c604a593bacba7edbc1e4826db2c6e:1eabdf11f75e3a4fe3147baf7b5be24b$"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 KiB

After

Width:  |  Height:  |  Size: 589 KiB