Code edit (1 edits merged)
Please save this source code
Code edit (17 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: screenCoordsToWorldCell is not defined' in or related to this line: 'var cellElt = screenCoordsToWorldCell(element.x, element.y);' Line Number: 645
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: getScreenToWorldCoord is not defined' in or related to this line: 'var wCoordCoords = getScreenToWorldCoord(x, y);' Line Number: 1657
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: getScreenToWorldCell is not defined' in or related to this line: 'var wCellCoords = getScreenToWorldCell(x, y);' Line Number: 1650
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
update the Map.render function to use the viewPort and world coordinates
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'setText')' in or related to this line: 'Map.viewCenterText.setText(Map.currentViewCenter.x + ', ' + Map.currentViewCenter.y);' Line Number: 1619
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: newCoords is not defined' in or related to this line: 'game.mouseCoordsText.setText("S:" + Math.floor(x) + ',' + Math.floor(y) + '\r\n' + newCoords.wCellX + ',' + newCoords.wCellY + '\r\nW:' + wCellCoords.wCellX + ',' + wCellCoords.wCellY + '\r\n' + wCoordCoords.wX + ',' + wCoordCoords.wY);' Line Number: 1615
Code edit (2 edits merged)
Please save this source code
User prompt
in findAvailablePositionAroundRefinery, return relative values, instead of aboslute cell coordinates
Code edit (1 edits merged)
Please save this source code
User prompt
For a move from [9,11 to 8,11 find Path returned a path [{8,11}], instead of [{-1,0}]. Fix that
User prompt
now that findPath returns relative values, update the instruction var targetCell = { cellX: targetPathStep.x, cellY: targetPathStep.y }; in Unit.updateMovement accordingly
User prompt
in Map.findPath(), instead of returning and array of targetCells, return an array of relative moves. ie: instead of : [{cellX: 5, cellY: 5}, {cellX: 6, cellY: 5}, {cellX: 6, cellY: 6}] return : [{cellX: +1, cellY: 0}, {cellX: 0, cellY: +1}]
Code edit (16 edits merged)
Please save this source code
User prompt
in UnitHarvester, in update function, implement the case of spice unloading (self.harvestingMode == 2) In this mode, harvestedSpiceOnTripCounter is decremented by self.unloadSpeed. during this decrement, unit blinks in green. Each spice decremented is added to the player spice counter. When harvestedSpiceOnTripCounter reaches 0, the units starts a new harvesting cycle (self.startHarvesting()).
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -414,8 +414,9 @@
var neighbor = neighbors[i];
if (closedSet.findIndex(function (node) {
return node.x === neighbor.x && node.y === neighbor.y;
}) !== -1 || self.cells[neighbor.x][neighbor.y].building && !ignoreSpecificBuilding) {
+ // TODO : Be more specific here ! ignore just 1 building
continue;
}
var gScore = currentNode.g + 1; // 1 is the distance from a node to a neighbor
var gScoreIsBest = false;
@@ -628,20 +629,23 @@
});
var Unit = Container.expand(function (x, y, playerId, type) {
var self = Container.call(this);
self.moveAlongPath = function (path, callback) {
- console.log("moveAlongPath", path);
+ console.log("moveAlongPath", path, callback);
self.path = path;
self.pathIndex = 0;
self.isMoving = true;
self.onArrivedCallback = callback;
};
self.updateMovement = function (delta) {
//console.log("updateMovement", delta);
if (!self.isMoving || !self.path || self.pathIndex >= self.path.length) {
+ console.log("updateMovement will stop ", self.path, self.pathIndex, self.onArrivedCallback);
self.isMoving = false;
if (self.onArrivedCallback) {
+ console.log("updateMovement call onArrivedCallback 1");
self.onArrivedCallback();
+ self.onArrivedCallback = null;
}
return;
}
var targetPathStep = self.path[self.pathIndex];
@@ -679,10 +683,11 @@
self.pathIndex++;
if (self.pathIndex >= self.path.length) {
self.isMoving = false;
if (self.onArrivedCallback) {
+ console.log("updateMovement call onArrivedCallback 2");
self.onArrivedCallback();
- //self.onArrivedCallback = null;
+ self.onArrivedCallback = null;
}
}
} else {
//console.log("advance by ", dx / distance * step);
@@ -730,11 +735,12 @@
var self = Unit.call(this, x, y, playerId, 'unitHarvester');
self.harvestedSpiceCapacity = 600;
self.harvestedSpiceOnTripCounter = 0;
self.harvestedSpiceOnCellCounter = 0;
- self.harvestingMode = false;
+ self.harvestingMode = 0; // 0 : Idle / 1 : harvesting / 2 : unload
self.harvestSpeed = 2; // TEMP DEBUG !!!TEMP DEBUG !!!TEMP DEBUG !!! 0.25; // Adjust this value to control the speed of harvesting
self.startHarvesting = function () {
+ console.log("startHarvesting...");
var closestSpiceSpot = findClosestSpiceSpot(self.cellX, self.cellY);
if (closestSpiceSpot) {
var path = gameMap.findPath({
x: self.cellX,
@@ -743,13 +749,17 @@
x: closestSpiceSpot.x,
y: closestSpiceSpot.y
});
self.moveAlongPath(path);
- self.harvestingMode = true;
+ self.harvestingMode = 1;
}
};
+ self.startUnloading = function () {
+ self.harvestingMode = 2;
+ console.log("Unloading spice...");
+ };
self.update = function () {
- if (self.harvestingMode && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {
+ if (self.harvestingMode == 1 && self.harvestedSpiceOnCellCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {
self.harvestedSpiceOnTripCounter += self.harvestSpeed;
self.harvestedSpiceOnCellCounter += self.harvestSpeed;
//console.log('Harvested Spice Counter:', self.harvestedSpiceOnCellCounter); //, ' cell ' + self.cellX + ',' + self.cellY, ' of map ', gameMap.cells[self.cellX][self.cellY]);
if (self.harvestedSpiceOnCellCounter >= 200) {
@@ -764,9 +774,14 @@
}, {
x: closestRefinery.cellX,
y: closestRefinery.cellY
}, closestRefinery);
- self.moveAlongPath(path);
+ if (path.length > 0) {
+ console.log("Returning to Refiniery...");
+ self.moveAlongPath(path, self.startUnloading);
+ } else {
+ console.warn("No path to Refinery !");
+ }
}
} else {
self.harvestedSpiceOnCellCounter = 0;
self.startHarvesting();
@@ -776,8 +791,10 @@
var blinkPhase = Math.sin(Date.now() * 0.01) * 0.5 + 0.5;
self.asset.tint = blinkPhase < 0.5 ? 0xFFA500 : 0xFFFFFF;
self.asset.rotation += 45 / 400 * (Math.PI / 180);
}
+ } else {
+ //console.log("update : not harvesting " + self.harvestingMode);
}
};
// Additional properties and methods for UnitHarvester can be added here
return self;
@@ -898,12 +915,8 @@
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
-// CONTINUER ICI : xxxActionLogic => change currentSelection to unit param !!!!
-// CONTINUER ICI : xxxActionLogic => change currentSelection to unit param !!!!
-// CONTINUER ICI : xxxActionLogic => change currentSelection to unit param !!!!
-// CONTINUER ICI : xxxActionLogic => change currentSelection to unit param !!!!
function moveActionLogic(targetUnit, destinationX, destinationY) {
console.log("MoveActionLogic...", destinationX, ',', destinationY);
if (targetUnit && targetUnit.isUnit) {
var path = gameMap.findPath({
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