E - Split bots R - Eject mass" );
socket.on('spawn-count', function(data) {
document.getElementById('minionCount').innerHTML = data
});
var client_uuid = localStorage.getItem('client_uuid');
if (client_uuid == null) {
console.log("generating a uuid for this user");
client_uuid = ""; var ranStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var ii = 0; ii < 15; ii++) client_uuid += ranStr.charAt(Math.floor(Math.random() * ranStr.length));
localStorage.setItem('client_uuid', client_uuid)
}
socket.emit("login", client_uuid);
$(" #instructions").replaceWith('
UUID');
function isMe(cell) {
for (var i = 0; i < window.agar.myCells.length; i++) {
if (window.agar.myCells[i] == cell.id) {
return true
}
}
return false
}
function getCell() {
var me = [];
for (var key in window.agar.allCells) {
var cell = window.agar.allCells[key];
if (isMe(cell)) {
me.push(cell)
}
}
return me[0]
}
var skin_var = 0;
function emitPosition() {
socket.emit("pos", {
"x": window.__botclonsData.mx,
"y": window.__botclonsData.my,
"l": window.__botclonsData.ml,
"dimensions": [-7071, -7071, 7071, 7071]
})
}
function emitSplit() {
socket.emit("cmd", {
"name": "split"
})
}
function emitMassEject() {
socket.emit("cmd", {
"name": "eject"
})
}
function toggleMovement() {
canMove = !canMove;
switch (canMove) {
case true:
canvas.onmousemove = moveEvent[0];
moveEvent[0] = null;
canvas.onmousedown = moveEvent[1];
moveEvent[1] = null;
break;
case false:
canvas.onmousemove({
clientX: innerWidth / 2,
clientY: innerHeight / 2
});
moveEvent[0] = canvas.onmousemove;
canvas.onmousemove = null;
moveEvent[1] = canvas.onmousedown;
canvas.onmousedown = null;
break
}
}
interval_id = setInterval(function() {
emitPosition()
}, 100);
interval_id2 = setInterval(function() {
transmit_game_server_if_changed()
}, 5000);
document.addEventListener('keydown', function(e) {
var key = e.keyCode || e.which;
switch (key) {
case 65:
movetoMouse = !movetoMouse;
if(movetoMouse) { document.getElementById('ismoveToMouse').innerHTML = "On"; } else { document.getElementById('ismoveToMouse').innerHTML = "Off"; }
break;
case 68:
toggleMovement();
if(!canMove) { document.getElementById('isStopMove').innerHTML = "On"; } else { document.getElementById('isStopMove').innerHTML = "Off"; }
break;
case 69:
emitSplit();
break;
case 82:
emitMassEject();
break
}
});
function transmit_game_server_if_changed() {
if (last_transmited_game_server != window.__botclonsData.socketaddr) {
transmit_game_server()
}
}
function transmit_game_server() {
last_transmited_game_server = window.__botclonsData.socketaddr;
socket.emit("cmd", {
"name": "connect_server",
"ip": window.__botclonsData.socketaddr,
"origin": location.origin
})
}
var mouseX = 0;
var mouseY = 0;
$("body").mousemove(function(event) {
mouseX = event.clientX;
mouseY = event.clientY
});
}, 200)