Added Build Rotation
This commit is contained in:
parent
e94eb2dd3d
commit
b7636f71e3
|
|
@ -145,14 +145,19 @@ function render() {
|
||||||
if (mode == "build") {
|
if (mode == "build") {
|
||||||
ctx.globalAlpha = 0.6
|
ctx.globalAlpha = 0.6
|
||||||
var tile = new toBuild()
|
var tile = new toBuild()
|
||||||
|
tile.direction = buildRotation
|
||||||
var img = tile.getImage(fulltime, 0)
|
var img = tile.getImage(fulltime, 0)
|
||||||
if (img != "0") {
|
if (img != "0") {
|
||||||
drawRotatedImage(img, cursorScreenX * 48 + 24, cursorScreenY * 48 + 24, 0)
|
drawRotatedImage(img, cursorScreenX * 48 + 24, cursorScreenY * 48 + 24, directions[tile.direction].degree)
|
||||||
}
|
}
|
||||||
img = tile.getImage(fulltime, 1)
|
img = tile.getImage(fulltime, 1)
|
||||||
if (img != "0") {
|
if (img != "0") {
|
||||||
drawRotatedImage(img, cursorScreenX * 48 + 24, cursorScreenY * 48 + 24, 0)
|
drawRotatedImage(img, cursorScreenX * 48 + 24, cursorScreenY * 48 + 24, directions[tile.direction].degree)
|
||||||
}
|
}
|
||||||
|
var img2 = new Image
|
||||||
|
img2.src = "images/ui/rotationOverlay.png"
|
||||||
|
ctx.globalAlpha = 0.4
|
||||||
|
drawRotatedImage(img2, cursorScreenX * 48 + 24, cursorScreenY * 48 + 24, directions[tile.direction].degree)
|
||||||
ctx.globalAlpha = 1
|
ctx.globalAlpha = 1
|
||||||
} else {
|
} else {
|
||||||
ctx.globalAlpha = 0.4
|
ctx.globalAlpha = 0.4
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ var isCursorInInfo = true
|
||||||
var mousedown = false
|
var mousedown = false
|
||||||
|
|
||||||
var tooltip = ""
|
var tooltip = ""
|
||||||
|
var buildRotation = "right"
|
||||||
|
|
||||||
function onDocumentMouseMove(event) {
|
function onDocumentMouseMove(event) {
|
||||||
//Tooltip POS
|
//Tooltip POS
|
||||||
|
|
@ -139,8 +140,10 @@ function onDocumentMouseMove(event) {
|
||||||
}
|
}
|
||||||
if (mousedown && mode == "build" && isCursorInScreen) {
|
if (mousedown && mode == "build" && isCursorInScreen) {
|
||||||
if (factorys[currentFactory].tiles[cursorScreenX][cursorScreenY] == 0) {
|
if (factorys[currentFactory].tiles[cursorScreenX][cursorScreenY] == 0) {
|
||||||
if (new toBuild().pay())
|
if (new toBuild().pay()) {
|
||||||
factorys[currentFactory].tiles[cursorScreenX][cursorScreenY] = new toBuild(cursorScreenX, cursorScreenY, factorys[currentFactory])
|
factorys[currentFactory].tiles[cursorScreenX][cursorScreenY] = new toBuild(cursorScreenX, cursorScreenY, factorys[currentFactory])
|
||||||
|
factorys[currentFactory].tiles[cursorScreenX][cursorScreenY].direction = buildRotation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -265,11 +268,48 @@ function options() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildEvents() {
|
function buildEvents() {
|
||||||
|
$(window).bind('mousewheel DOMMouseScroll', function(event) {
|
||||||
|
if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {
|
||||||
|
// scroll up
|
||||||
|
switch (buildRotation) {
|
||||||
|
case "right":
|
||||||
|
buildRotation = "up"
|
||||||
|
break;
|
||||||
|
case "down":
|
||||||
|
buildRotation = "right"
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
buildRotation = "down"
|
||||||
|
break;
|
||||||
|
case "up":
|
||||||
|
buildRotation = "left"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// scroll down
|
||||||
|
switch (buildRotation) {
|
||||||
|
case "right":
|
||||||
|
buildRotation = "down"
|
||||||
|
break;
|
||||||
|
case "down":
|
||||||
|
buildRotation = "left"
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
buildRotation = "up"
|
||||||
|
break;
|
||||||
|
case "up":
|
||||||
|
buildRotation = "right"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
$('img').click(function() {
|
$('img').click(function() {
|
||||||
var id = $(this).attr("id");
|
var id = $(this).attr("id");
|
||||||
if (id.startsWith("build_")) {
|
if (id.startsWith("build_")) {
|
||||||
id = parseInt(id.substr(6))
|
id = parseInt(id.substr(6))
|
||||||
toBuild = tileClasses[id]
|
toBuild = tileClasses[id]
|
||||||
|
buildRotation = "right"
|
||||||
mode = "build"
|
mode = "build"
|
||||||
$('#buildselect').fadeOut(200)
|
$('#buildselect').fadeOut(200)
|
||||||
}
|
}
|
||||||
|
|
@ -304,8 +344,10 @@ function buildEvents() {
|
||||||
}
|
}
|
||||||
if (mode == "build" && isCursorInScreen) {
|
if (mode == "build" && isCursorInScreen) {
|
||||||
if (factorys[currentFactory].tiles[cursorScreenX][cursorScreenY] == 0) {
|
if (factorys[currentFactory].tiles[cursorScreenX][cursorScreenY] == 0) {
|
||||||
if (new toBuild().pay())
|
if (new toBuild().pay()) {
|
||||||
factorys[currentFactory].tiles[cursorScreenX][cursorScreenY] = new toBuild(cursorScreenX, cursorScreenY, factorys[currentFactory])
|
factorys[currentFactory].tiles[cursorScreenX][cursorScreenY] = new toBuild(cursorScreenX, cursorScreenY, factorys[currentFactory])
|
||||||
|
factorys[currentFactory].tiles[cursorScreenX][cursorScreenY].direction = buildRotation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((mode == "none") && isCursorInScreen) {
|
if ((mode == "none") && isCursorInScreen) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue