From 139f500d9daad272f837ab93fff2959c55e1fed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ricardo=20Fleury=20Oliveira?= Date: Sat, 18 May 2024 12:43:49 -0300 Subject: [PATCH] added candy overlays and colors --- src/ui/starter-select-ui-handler.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 44c207e95a3..5e11734e829 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -186,6 +186,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { private hiddenAbilityIcons: Phaser.GameObjects.Image[]; private classicWinIcons: Phaser.GameObjects.Image[]; private candyUpgradeIcon: Phaser.GameObjects.Image[]; + private candyUpgradeOverlayIcon: Phaser.GameObjects.Image[]; private iconAnimHandler: PokemonIconAnimHandler; @@ -446,7 +447,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterSelectContainer.add(ret); return ret; }); - + this.classicWinIcons = new Array(81).fill(null).map((_, i) => { const x = (i % 9) * 18; const y = Math.floor(i / 9) * 18; @@ -468,6 +469,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterSelectContainer.add(ret); return ret; }); + + this.candyUpgradeOverlayIcon = new Array(81).fill(null).map((_, i) => { + const x = (i % 9) * 18; + const y = Math.floor(i / 9) * 18; + const ret = this.scene.add.image(x + 163, y + 21, 'candy_overlay'); + ret.setOrigin(0, 0); + ret.setScale(0.25); + ret.setVisible(false); + this.starterSelectContainer.add(ret); + return ret; + }); this.pokemonSprite = this.scene.add.sprite(53, 63, `pkmn__sub`); this.pokemonSprite.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true }); @@ -1289,6 +1301,15 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.hiddenAbilityIcons[s].setVisible(slotVisible && !!this.scene.gameData.dexData[speciesId].caughtAttr && !!(this.scene.gameData.starterData[speciesId].abilityAttr & 4)); this.classicWinIcons[s].setVisible(slotVisible && this.scene.gameData.starterData[speciesId].classicWinCount > 0); + if (!starterColors[speciesId]) { + starterColors[speciesId] = [ 'ffffff', 'ffffff' ]; // Default to white if no colors are found + } + + // Set the candy colors + this.candyUpgradeIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][0]))); + this.candyUpgradeOverlayIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][1]))); + + // Display the candy upgrade icon and its overlay if the species has a passive ability that can be unlocked or if its value can be reduced this.candyUpgradeIcon[s].setVisible( slotVisible && ( (this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) && @@ -1296,6 +1317,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler { (this.scene.gameData.starterData[speciesId].candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[this.scene.gameData.starterData[speciesId].valueReduction] && this.scene.gameData.starterData[speciesId].valueReduction < 2) ) + ); + this.candyUpgradeOverlayIcon[s].setVisible( + slotVisible && this.candyUpgradeIcon[s].visible ); } } else { @@ -1786,6 +1810,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.candyUpgradeIcon[cursor].setVisible( this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) || this.scene.gameData.starterData[speciesId].candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[this.scene.gameData.starterData[speciesId].valueReduction]); + this.candyUpgradeOverlayIcon[cursor].setVisible(this.candyUpgradeIcon[cursor].visible); } tryUpdateValue(add?: integer): boolean {