Code edit (18 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'units')' in or related to this line: 'var allUnits = player1.units.concat(player2.units);' Line Number: 2806
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -2220,16 +2220,16 @@
return tempNeededUnitList;
}
function getUnitNeedsPerWave(waveIndex) {
//console.log("getUnitNeedsPerWave...", waveIndex);
- /*
+ /*
Wave 1 : 1 Quad
Wave 2 : 2 Quad
Wave 3 : 2 Quad + 1 LightTank
Wave 4 : 2 Quad + 2 LightTank
Wave 5 : 2 Quad + 2 LightTank + 1 HeavyTank
Wave 6+ : 2 Quad + 2 LightTank + 2 HeavyTank
- */
+ */
var tempNbQuads = Math.min(2, waveIndex);
var tempNbLightTanks = Math.min(2, Math.max(0, waveIndex - 2));
var tempNbHeavyTanks = Math.min(2, Math.max(0, waveIndex - 4));
return {
@@ -2495,12 +2495,8 @@
var randomIndex = Math.floor(Math.random() * startingPositions.length);
rockIlot1Center = startingPositions[randomIndex];
// Remove selected position and choose next for rockIlot2Center
startingPositions.splice(randomIndex, 1);
- /*
- viewPort.wCellX = Math.max(0, Math.min(mapXSize - viewPort.cellW, rockIlot1Center.x - Math.floor(viewPort.cellW / 2)));
- viewPort.wCellY = Math.max(0, Math.min(mapYSize - viewPort.cellH, rockIlot1Center.y - Math.floor(viewPort.cellH / 2)));
- */
rockIlot2Center = startingPositions[Math.floor(Math.random() * startingPositions.length)];
//console.log("rockIlot1Center : ", rockIlot1Center);
var rockIlot1Radius = 4;
for (var x = rockIlot1Center.x - rockIlot1Radius; x <= rockIlot1Center.x + rockIlot1Radius; x++) {
@@ -2698,9 +2694,9 @@
var inputPosition = {
x: Math.round(-deltaX / tileSize),
y: Math.round(-deltaY / tileSize)
};
- var allUnits = (player1.units || []).concat(player2.units || []);
+ var allUnits = player1.units.concat(player2.units);
allUnits.forEach(function (unit) {
unit.handleDrag(inputPosition);
//unit.visible = false;
});
@@ -3256,8 +3252,12 @@
// Start the game with Player 1 construction yard preselected
initGame();
LK.setTimeout(function () {
gameIsRunning = true;
+ viewPort.wCellX = rockIlot1Center.x;
+ viewPort.wCellY = rockIlot1Center.y;
+ viewPort.wX = rockIlot1Center.x * tileSize - viewPort.wCellX * tileSize;
+ viewPort.wY = rockIlot1Center.y * tileSize - viewPort.wCellY * tileSize;
currentSelection = gameMap.cells[rockIlot1Center.x][rockIlot1Center.y].building;
selectionMarker.setOnElement(currentSelection);
updateActionBoard();
updateFogOfWar();
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