Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: newunit is not defined' in or related to this line: 'harvestActionLogic(newunit, cellX, cellY);' Line Number: 1324
Code edit (2 edits merged)
Please save this source code
User prompt
in harvestActionLogic, remplace the use of currentSelection, by the of a parameter 'targetUnit' and update the existing function calls
User prompt
in moveActionLogic, remplace the use of currentSelection, by the of a parameter 'targetUnit' and update the existing function calls
Code edit (1 edits merged)
Please save this source code
User prompt
in clearCellSpice also update the spiceSpots array
Code edit (8 edits merged)
Please save this source code
User prompt
when the harvester took 200 from a cell, call clearCellSpice()
User prompt
add a new method clearCellSpice in the Map class
Code edit (1 edits merged)
Please save this source code
User prompt
no rotate only when harvestedSpiceCounter%100 ==0
User prompt
make the unit randomy rotate by 45° while harvesting
Code edit (1 edits merged)
Please save this source code
User prompt
make the blinking moresmooth
User prompt
in UnitHarvester, while harvesting, make the unit blink in orange
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: harvestSpeed is not defined' in or related to this line: 'self.harvestedSpiceCounter += harvestSpeed;' Line Number: 596
Code edit (10 edits merged)
Please save this source code
User prompt
in UnitHarvester add a property harvestSpeed to reduce the increase speed of the harvestedSpiceCounter
Code edit (2 edits merged)
Please save this source code
User prompt
set the currentSelection.selectedAction in ActionItemIcon down event
User prompt
in handleDragEnd, replace the following code that calls all the actions ``` currentSelection.actions.forEach(function (actionType) { var actionInfo = actionRepository.getActionInfo(actionType); if (actionInfo && actionInfo.handler) { console.log('Call action handler : ', actionInfo); actionInfo.handler(cellCoord.cellX, cellCoord.cellY); } }); ``` by a code that call only the action selected bu the user
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -104,8 +104,18 @@
// Initialize game elements
// Map class to represent the grid-based map system
var Map = Container.expand(function () {
var self = Container.call(this);
+ // Method to clear spice from a specified cell
+ self.clearCellSpice = function (x, y) {
+ if (self.cells[x] && self.cells[x][y]) {
+ self.cells[x][y].spice = false;
+ if (self.cells[x][y].spiceAsset) {
+ self.cells[x][y].spiceAsset.destroy();
+ self.cells[x][y].spiceAsset = null;
+ }
+ }
+ };
self.cells = [];
self.init = function (width, height) {
for (var x = 0; x < width; x++) {
self.cells[x] = [];
@@ -548,8 +558,9 @@
return self;
});
var UnitHarvester = Unit.expand(function (x, y, playerId) {
var self = Unit.call(this, x, y, playerId, 'unitHarvester');
+ self.harvestedSpiceCapacity = 600;
self.harvestedSpiceCounter = 0;
self.harvestingMode = false;
self.harvestSpeed = 0.25; // Adjust this value to control the speed of harvesting
self.startHarvesting = function () {
@@ -566,20 +577,22 @@
self.harvestingMode = true;
}
};
self.update = function () {
- if (self.harvestingMode && self.harvestedSpiceCounter < 200) {
+ if (self.harvestingMode && self.harvestedSpiceCounter < 200 && gameMap.cells[self.cellX][self.cellY].spice) {
self.harvestedSpiceCounter += self.harvestSpeed;
- console.log('Harvested Spice Counter:', self.harvestedSpiceCounter);
- // Make the unit blink in orange more smoothly
- var blinkPhase = Math.sin(Date.now() * 0.01) * 0.5 + 0.5;
- self.asset.tint = blinkPhase < 0.5 ? 0xFFA500 : 0xFFFFFF;
- // Randomly rotate by 45° only when harvestedSpiceCounter%100 == 0
- if (self.harvestedSpiceCounter % 100 == 0) {
- var randomRotation = Math.floor(Math.random() * 8) * 45 * (Math.PI / 180);
- self.asset.rotation += self.harvestedSpiceCounter * 45 / 200 * (Math.PI / 180);
+ console.log('Harvested Spice Counter:', self.harvestedSpiceCounter); //, ' cell ' + self.cellX + ',' + self.cellY, ' of map ', gameMap.cells[self.cellX][self.cellY]);
+ if (self.harvestedSpiceCounter >= 200) {
+ self.asset.tint = 0xFFFFFF;
+ // clear spice of cell
+ // if full return refinery
+ // else search closest
+ } else {
+ // Make the unit blink in orange more smoothly
+ 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);
}
- self.asset.rotation += randomRotation;
}
};
// Additional properties and methods for UnitHarvester can be added here
return self;
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