Skip to content

Commit d2129b4

Browse files
committed
add zombie picker
1 parent f09b20f commit d2129b4

File tree

7 files changed

+289
-17
lines changed

7 files changed

+289
-17
lines changed

game/Custom.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,3 +1345,16 @@ body.game-paused #cover {
13451345
user-select: none;
13461346
pointer-events: none;
13471347
}
1348+
1349+
#dSelectCard.zombies {
1350+
background: url("images/interface/ZombieChooser_Background.png") no-repeat;
1351+
}
1352+
#dSelectCard.zombies #btnOK,
1353+
#dSelectCard.zombies #btnReset {
1354+
color: #00f500 !important;
1355+
background-color: #5a5d78;
1356+
border-left: 3px solid #6c6c85;
1357+
border-right: 3px solid #595674;
1358+
border-top: 3px solid #6c6c85;
1359+
border-bottom: 3px solid #54546b;
1360+
}
34.4 KB
Loading

game/js/Cfunction.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,17 +2051,17 @@ var ViewProduceZombie = function (zombieClass) {
20512051
$("pZombieBack").style.background = "url('images/interface/Almanac_Ground" + proto.BookHandBack + ".jpg')";
20522052
};
20532053

2054-
var ViewCardTitle = function (plantClass, e) {
2054+
var ViewCardTitle = function (plantClass, e, showCooldown = true, showProduce = true) {
20552055
e = e || window.event;
20562056
var zoom = parseFloat(document.body.style.zoom) || 1;
20572057
const titleDiv = $("dTitle");
20582058
const proto = plantClass.prototype;
2059-
let html = proto.CName + "<br>cooldown: " + proto.coolTime + "s<br>";
2059+
let html = proto.CName + "<br>" + (showCooldown ? "cooldown: " + proto.coolTime + "s<br>" : "");
20602060

20612061
if (oS.DKind && proto.night) {
20622062
html += '<span style="color:#F00">Nocturnal - sleeps during the day</span><br>' + proto.Tooltip;
20632063
} else {
2064-
html += proto.Tooltip || '<span style="text-align:left">' + proto.Produce + "</span>";
2064+
html += proto.Tooltip || (showProduce ? '<span style="text-align:left">' + proto.Produce + "</span>" : "");
20652065
}
20662066

20672067
titleDiv.innerHTML = html;

game/js/IZombie.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,33 @@ const TINYIFIER_MAP = {
1919
eleTop: 13,
2020
eleWidth: 14,
2121
eleHeight: 15,
22+
// zombies
23+
selectedZombies: 16,
2224
};
2325

26+
const iZombies = [
27+
oIImp,
28+
oIConeheadZombie,
29+
oIPoleVaultingZombie,
30+
oIBucketheadZombie,
31+
oIFootballZombie,
32+
oIJackinTheBoxZombie,
33+
oIScreenDoorZombie,
34+
oIZombie,
35+
oIDuckyTubeZombie1,
36+
oIDuckyTubeZombie2,
37+
oIDuckyTubeZombie3,
38+
oIBalloonZombie,
39+
];
40+
2441
const REVERSE_TINYIFIER_MAP = Object.fromEntries(Object.entries(TINYIFIER_MAP).map(([key, value]) => [value, key]));
2542

2643
const IZL3_HEADER = new Uint8Array([0x49, 0x5a, 0x4c, 0x33]); // "IZL3"
2744

2845
// for level loading, not used in this script
2946
let levelDataToLoad = null;
3047
let pNameValue = [];
48+
let zNameValue = [];
3149

3250
// ============================================================================
3351
// VERSION DETECTION
@@ -135,6 +153,11 @@ function tinyifyClone(obj) {
135153
} else if (key === "plantName" && typeof value === "string") {
136154
const plantIndex = izombiePlantsMap.indexOf(value);
137155
result[newKey] = plantIndex !== -1 ? plantIndex : value;
156+
} else if (key === "selectedZombies" && Array.isArray(value)) {
157+
result[newKey] = value.map((zombieName) => {
158+
const index = iZombies.findIndex((z) => z.prototype.EName === zombieName);
159+
return index !== -1 ? index : zombieName;
160+
});
138161
} else {
139162
result[newKey] = tinyifyClone(value);
140163
}
@@ -157,6 +180,13 @@ function untinyifyClone(obj) {
157180

158181
if (newKey === "plantName" && typeof value === "number") {
159182
result[newKey] = izombiePlantsMap[value] || value;
183+
} else if (newKey === "selectedZombies" && Array.isArray(value)) {
184+
result[newKey] = value.map((zombieIndex) => {
185+
if (typeof zombieIndex === "number" && iZombies[zombieIndex]) {
186+
return iZombies[zombieIndex].prototype.EName;
187+
}
188+
return zombieIndex;
189+
});
160190
} else {
161191
result[newKey] = untinyifyClone(value);
162192
}
@@ -387,6 +417,13 @@ function cloneFromPlants(name, sun, includeXY, screenshot) {
387417

388418
let levelData = {
389419
plants: plantArray,
420+
selectedZombies: (() => {
421+
let zombies = [];
422+
for (let i = 0; i < oS.ChosenZombies.length; i++) {
423+
zombies.push(oS.ChosenZombies[i].prototype.EName);
424+
}
425+
return zombies;
426+
})(),
390427
music: oS.LoadMusic,
391428
sun,
392429
name,

game/level/izombiecustomlevelnormal.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pNameValue = [];
2+
zNameValue = [];
13
// make sure everything in levelDataToLoad is defined
24
if (typeof levelDataToLoad === "undefined") {
35
alert("Invalid level data!");
@@ -143,14 +145,25 @@ for (let i = 0; i < levelDataToLoad.plants.length; i++) {
143145
pNameValue.push(window[plant.plantName]);
144146
}
145147
}
148+
if (levelDataToLoad.selectedZombies) {
149+
for (let i = 0; i < levelDataToLoad.selectedZombies.length; i++) {
150+
let zombie = levelDataToLoad.selectedZombies[i];
151+
if (!zNameValue.includes(window[zombie])) {
152+
zNameValue.push(window[zombie]);
153+
}
154+
}
155+
}
146156
// if lfValue is [0, 1, 1, 2, 2, 1, 1], then we use background4, otherwise background2
147157
backgroundImage = levelDataToLoad.lfValue[3] === 2 ? "images/interface/background4.jpg" : "images/interface/background2.jpg";
148158
// if its [0, 1, 1, 2, 2, 1, 1], then we use 6 brains, otherwise 5
149159
brainsNum = levelDataToLoad.lfValue[3] === 2 ? 6 : 5;
150160

151161
oS.Init({
152162
PName: pNameValue,
153-
ZName: [oIImp, oIConeheadZombie, oIPoleVaultingZombie, oIBucketheadZombie, oIFootballZombie, oIJackinTheBoxZombie, oIScreenDoorZombie],
163+
ZName:
164+
zNameValue.length === 0
165+
? [oIImp, oIConeheadZombie, oIPoleVaultingZombie, oIBucketheadZombie, oIFootballZombie, oIJackinTheBoxZombie, oIScreenDoorZombie]
166+
: zNameValue,
154167
PicArr: [backgroundImage, "images/interface/trophy.png", "images/interface/Stripe.png"],
155168
LF: levelDataToLoad.lfValue,
156169
backgroundImage,

game/level/izombiecustomlevelwater.js

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pNameValue = [];
2+
zNameValue = [];
13
// make sure everything in levelDataToLoad is defined
24
if (typeof levelDataToLoad === "undefined") {
35
alert("Invalid level data!");
@@ -197,24 +199,35 @@ for (let i = 0; i < levelDataToLoad.plants.length; i++) {
197199
pNameValue.push(window[plant.plantName]);
198200
}
199201
}
202+
if (levelDataToLoad.selectedZombies) {
203+
for (let i = 0; i < levelDataToLoad.selectedZombies.length; i++) {
204+
let zombie = levelDataToLoad.selectedZombies[i];
205+
if (!zNameValue.includes(window[zombie])) {
206+
zNameValue.push(window[zombie]);
207+
}
208+
}
209+
}
200210
// if lfValue is [0, 1, 1, 2, 2, 1, 1], then we use background4, otherwise background2
201211
backgroundImage = levelDataToLoad.lfValue[3] === 2 ? "images/interface/background4.jpg" : "images/interface/background2.jpg";
202212
// if its [0, 1, 1, 2, 2, 1, 1], then we use 6 brains, otherwise 5
203213
brainsNum = levelDataToLoad.lfValue[3] === 2 ? 6 : 5;
204214

205215
oS.Init({
206216
PName: pNameValue,
207-
ZName: [
208-
oIZombie,
209-
oIConeheadZombie,
210-
oIBucketheadZombie,
211-
oIDuckyTubeZombie1,
212-
oIDuckyTubeZombie2,
213-
oIDuckyTubeZombie3,
214-
oIScreenDoorZombie,
215-
oIPoleVaultingZombie,
216-
oIBalloonZombie,
217-
],
217+
ZName:
218+
zNameValue.length === 0
219+
? [
220+
oIZombie,
221+
oIConeheadZombie,
222+
oIBucketheadZombie,
223+
oIDuckyTubeZombie1,
224+
oIDuckyTubeZombie2,
225+
oIDuckyTubeZombie3,
226+
oIScreenDoorZombie,
227+
oIPoleVaultingZombie,
228+
oIBalloonZombie,
229+
]
230+
: zNameValue,
218231
PicArr: [backgroundImage, "images/interface/trophy.png", "images/interface/Stripe.png"],
219232
backgroundImage,
220233
Coord: 2,

0 commit comments

Comments
 (0)