Code edit (11 edits merged)
Please save this source code
User prompt
allow diagonal movements for units
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: newCell is not defined' in or related to this line: 'self.cellX = Math.floor(newCell.cellX / tileSize);' Line Number: 805
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '8')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '7')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '6')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'unit')' in or related to this line: 'gameMap.cells[self.cellX][self.cellY].unit = self;' Line Number: 747
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '9.366666666666676')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'spice')' in or related to this line: 'if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {' Line Number: 833
===================================================================
--- original.js
+++ change.js
@@ -462,8 +462,20 @@
y: -1
}, {
x: 0,
y: 1
+ }, {
+ x: -1,
+ y: -1
+ }, {
+ x: -1,
+ y: 1
+ }, {
+ x: 1,
+ y: -1
+ }, {
+ x: 1,
+ y: 1
}];
directions.forEach(function (dir) {
var newX = node.x + dir.x;
var newY = node.y + dir.y;
@@ -712,12 +724,32 @@
updateActionBoard();
});
self.onArrivedCallback = null;
self.handleDrag = function () {
+ // OK
var newCoord = worldCellToScreenCoord(self.cellX, self.cellY);
self.x = newCoord.x + tileSize / 2;
self.y = newCoord.y + tileSize / 2;
+ // KO
+ //var deltaX = self.x-Math.floor(self.x/tileSize)*tileSize;
+ //var deltaY = self.y-Math.floor(self.y/tileSize)*tileSize;
+ //var newCoord = worldCellToScreenCell(self.cellX, self.cellY);
+ //self.x = newCoord.cellX + deltaX;
+ //self.y = newCoord.cellY + deltaY;
+ // KO
+ //var deltaX = self.x-Math.floor(self.x/tileSize)*tileSize;
+ //var deltaY = self.y-Math.floor(self.y/tileSize)*tileSize;
+ //var newCoord = worldCellToScreenCoord(self.cellX, self.cellY);
+ //self.x = newCoord.x + deltaX;
+ //self.y = newCoord.y + deltaY;
+ // KO
+ //var newCoord = worldCoordToScreenCoord(self.x, self.y);
+ //self.x = newCoord.x;
+ //self.y = newCoord.y;
};
+ self.stopOtherActions = function () {
+ console.log("Unit stopOtherActions :");
+ };
return self;
});
var UnitHarvester = Unit.expand(function (x, y, playerId) {
var self = Unit.call(this, x, y, playerId, 'unitHarvester');
@@ -800,8 +832,12 @@
self.startHarvesting(); // Start a new harvesting cycle
}
}
};
+ self.stopOtherActions = function () {
+ console.log("UnitHarvester stopOtherActions :");
+ self.harvestingMode = 0; // Reset harvesting mode
+ };
// Additional properties and methods for UnitHarvester can be added here
return self;
});
//{15.1}
@@ -923,8 +959,9 @@
}
function moveActionLogic(targetUnit, destinationX, destinationY) {
console.log("MoveActionLogic...", destinationX, ',', destinationY);
if (targetUnit && targetUnit.isUnit) {
+ targetUnit.stopOtherActions();
var path = gameMap.findPath({
x: targetUnit.cellX,
y: targetUnit.cellY
}, {
@@ -1237,12 +1274,13 @@
x: Math.round(-deltaX / tileSize),
y: Math.round(-deltaY / tileSize)
};
var allUnits = player1.units.concat(player2.units);
- gameMap.handleDrag(inputPosition);
allUnits.forEach(function (unit) {
- unit.handleDrag(inputPosition);
+ //unit.handleDrag(inputPosition);
+ unit.visible = false;
});
+ gameMap.handleDrag(inputPosition);
dragDelta = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
selectionMarker.setOnElement(currentSelection);
}
}
@@ -1302,8 +1340,13 @@
var clickCell = screenCoordToWorldCell(input.x, input.y);
var cellX = clickCell.wCellX;
var cellY = clickCell.wCellY;
console.log("Click at cell " + cellX + ',' + cellY);
+ var allUnits = player1.units.concat(player2.units);
+ allUnits.forEach(function (unit) {
+ unit.handleDrag(input);
+ unit.visible = true;
+ });
var deltaToSelection = 99;
if (currentSelection && currentSelection.isUnit) {
var selCell = getCellForUnit(currentSelection);
deltaToSelection = Math.sqrt(Math.pow(Math.abs(selCell.cellX - cellX), 2) + Math.pow(Math.abs(selCell.cellY - cellY), 2));
a tileable sand terrain tile.
A square tileable rock terrain tile WITHOUT BBORDER. Single Game Texture. In-Game asset. 2d. No shadows. No Border
Zenith view of Dune's Wind Trap power facility square fence. Ressembles a bit to Sydney's Opera. Zenith view Directly from above.
grey cancel icon. UI
thin white circle empty.
0x5e86ff
Zenith view of a white rectangular Harvester shape of a garbage truck with a triangular head. Harvesting on sand, with flowing spice in the back. inside a square fence. Zenith view. Directly overhead. Plumb view.
Minimal Ui icon of an right sign aside with an icon of a target. sand background
Minimal icon of a home with direction icon pointing to the home. sand background
3 white flat isometric concentric circles like a target.
Remove background
Gray background
Minimal Ui icon of target sign on a fire icon.. sand background
top view of an explosion effect.
Simple heavy army tank factory buiding a tank with a crane. Square fence... Zenith view Directly overhead. Plumb view.
an empty black popup UI. UI