2023-04-20 15:46:05 -04:00
|
|
|
import BattleScene from "../battle-scene";
|
2024-04-21 12:18:09 +02:00
|
|
|
import i18next from '../plugins/i18n';
|
2023-03-28 14:54:52 -04:00
|
|
|
|
|
|
|
export enum PokeballType {
|
|
|
|
POKEBALL,
|
|
|
|
GREAT_BALL,
|
|
|
|
ULTRA_BALL,
|
2024-02-28 23:13:05 -05:00
|
|
|
ROGUE_BALL,
|
2023-03-29 22:56:43 -04:00
|
|
|
MASTER_BALL,
|
|
|
|
LUXURY_BALL
|
2023-03-28 14:54:52 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
export function getPokeballAtlasKey(type: PokeballType): string {
|
|
|
|
switch (type) {
|
|
|
|
case PokeballType.POKEBALL:
|
|
|
|
return 'pb';
|
|
|
|
case PokeballType.GREAT_BALL:
|
|
|
|
return 'gb';
|
|
|
|
case PokeballType.ULTRA_BALL:
|
|
|
|
return 'ub';
|
2024-02-28 23:13:05 -05:00
|
|
|
case PokeballType.ROGUE_BALL:
|
|
|
|
return 'rb';
|
2023-03-28 14:54:52 -04:00
|
|
|
case PokeballType.MASTER_BALL:
|
|
|
|
return 'mb';
|
2023-03-29 22:56:43 -04:00
|
|
|
case PokeballType.LUXURY_BALL:
|
|
|
|
return 'lb';
|
2023-03-28 14:54:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getPokeballName(type: PokeballType): string {
|
|
|
|
let ret: string;
|
|
|
|
switch (type) {
|
|
|
|
case PokeballType.POKEBALL:
|
2024-04-21 12:18:09 +02:00
|
|
|
ret = i18next.t('pokeball:pokeBall');
|
2023-03-28 14:54:52 -04:00
|
|
|
break;
|
|
|
|
case PokeballType.GREAT_BALL:
|
2024-04-21 12:18:09 +02:00
|
|
|
ret = i18next.t('pokeball:greatBall');
|
2023-03-28 14:54:52 -04:00
|
|
|
break;
|
|
|
|
case PokeballType.ULTRA_BALL:
|
2024-04-21 12:18:09 +02:00
|
|
|
ret = i18next.t('pokeball:ultraBall');
|
2023-03-28 14:54:52 -04:00
|
|
|
break;
|
2024-02-28 23:13:05 -05:00
|
|
|
case PokeballType.ROGUE_BALL:
|
2024-04-21 12:18:09 +02:00
|
|
|
ret = i18next.t('pokeball:rogueBall');
|
2024-02-28 23:13:05 -05:00
|
|
|
break;
|
2023-03-28 14:54:52 -04:00
|
|
|
case PokeballType.MASTER_BALL:
|
2024-04-21 12:18:09 +02:00
|
|
|
ret = i18next.t('pokeball:masterBall');
|
2023-03-28 14:54:52 -04:00
|
|
|
break;
|
2023-03-29 22:56:43 -04:00
|
|
|
case PokeballType.LUXURY_BALL:
|
2024-04-21 12:18:09 +02:00
|
|
|
ret = i18next.t('pokeball:luxuryBall');
|
2023-03-29 22:56:43 -04:00
|
|
|
break;
|
2023-03-28 14:54:52 -04:00
|
|
|
}
|
2023-10-18 18:01:15 -04:00
|
|
|
return ret;
|
2023-03-28 14:54:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getPokeballCatchMultiplier(type: PokeballType): number {
|
|
|
|
switch (type) {
|
|
|
|
case PokeballType.POKEBALL:
|
|
|
|
return 1;
|
|
|
|
case PokeballType.GREAT_BALL:
|
|
|
|
return 1.5;
|
|
|
|
case PokeballType.ULTRA_BALL:
|
|
|
|
return 2;
|
2024-02-28 23:13:05 -05:00
|
|
|
case PokeballType.ROGUE_BALL:
|
|
|
|
return 3;
|
2023-03-28 14:54:52 -04:00
|
|
|
case PokeballType.MASTER_BALL:
|
2023-04-23 12:35:16 -04:00
|
|
|
return -1;
|
2023-03-29 22:56:43 -04:00
|
|
|
case PokeballType.LUXURY_BALL:
|
|
|
|
return 1;
|
2023-03-28 14:54:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-30 00:13:56 -04:00
|
|
|
export function getPokeballTintColor(type: PokeballType): number {
|
2023-03-28 14:54:52 -04:00
|
|
|
switch (type) {
|
|
|
|
case PokeballType.POKEBALL:
|
|
|
|
return 0xd52929;
|
|
|
|
case PokeballType.GREAT_BALL:
|
|
|
|
return 0x94b4de;
|
|
|
|
case PokeballType.ULTRA_BALL:
|
|
|
|
return 0xe6cd31;
|
2024-02-28 23:13:05 -05:00
|
|
|
case PokeballType.ROGUE_BALL:
|
|
|
|
return 0xd52929;
|
2023-03-28 14:54:52 -04:00
|
|
|
case PokeballType.MASTER_BALL:
|
|
|
|
return 0xa441bd;
|
2023-03-29 22:56:43 -04:00
|
|
|
case PokeballType.LUXURY_BALL:
|
|
|
|
return 0xffde6a;
|
2023-03-28 14:54:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function doPokeballBounceAnim(scene: BattleScene, pokeball: Phaser.GameObjects.Sprite, y1: number, y2: number, baseBounceDuration: integer, callback: Function) {
|
|
|
|
let bouncePower = 1;
|
|
|
|
let bounceYOffset = y1;
|
|
|
|
let bounceY = y2;
|
|
|
|
let yd = y2 - y1;
|
|
|
|
|
|
|
|
const doBounce = () => {
|
|
|
|
scene.tweens.add({
|
|
|
|
targets: pokeball,
|
|
|
|
y: y2,
|
|
|
|
duration: bouncePower * baseBounceDuration,
|
|
|
|
ease: 'Cubic.easeIn',
|
|
|
|
onComplete: () => {
|
2023-10-21 08:58:39 -04:00
|
|
|
scene.playSound('pb_bounce_1', { volume: bouncePower });
|
2023-03-28 14:54:52 -04:00
|
|
|
|
|
|
|
bouncePower = bouncePower > 0.01 ? bouncePower * 0.5 : 0;
|
|
|
|
|
|
|
|
if (bouncePower) {
|
|
|
|
bounceYOffset = yd * bouncePower;
|
|
|
|
bounceY = y2 - bounceYOffset;
|
|
|
|
|
|
|
|
scene.tweens.add({
|
|
|
|
targets: pokeball,
|
|
|
|
y: bounceY,
|
|
|
|
duration: bouncePower * baseBounceDuration,
|
|
|
|
ease: 'Cubic.easeOut',
|
|
|
|
onComplete: () => doBounce()
|
|
|
|
});
|
|
|
|
} else if (callback)
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
doBounce();
|
|
|
|
}
|