Battle animation improvements
This commit is contained in:
parent
791bf3cc49
commit
1b8c8b5a3f
|
@ -7168,7 +7168,7 @@
|
|||
"3": [
|
||||
{
|
||||
"frameIndex": 3,
|
||||
"resourceName": "PRSFX- Baton Pass.wav",
|
||||
"resourceName": "PRSFX- Baton Pass1.wav",
|
||||
"volume": 100,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -7177,7 +7177,7 @@
|
|||
"17": [
|
||||
{
|
||||
"frameIndex": 17,
|
||||
"resourceName": "PRSFX- Baton Pass1.wav",
|
||||
"resourceName": "PRSFX- Baton Pass2.wav",
|
||||
"volume": 100,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2382,7 +2382,7 @@
|
|||
},
|
||||
{
|
||||
"frameIndex": 15,
|
||||
"resourceName": "PRSFX- Sunny",
|
||||
"resourceName": "PRSFX- Sunny.wav",
|
||||
"volume": 100,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
|
@ -13913,7 +13913,7 @@
|
|||
"0": [
|
||||
{
|
||||
"frameIndex": 0,
|
||||
"resourceName": "PRSFX- Rain",
|
||||
"resourceName": "PRSFX- Rain.wav",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -13922,7 +13922,7 @@
|
|||
"17": [
|
||||
{
|
||||
"frameIndex": 17,
|
||||
"resourceName": "PRSFX- Rain",
|
||||
"resourceName": "PRSFX- Rain.wav",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
|
@ -1637,7 +1637,7 @@
|
|||
"0": [
|
||||
{
|
||||
"frameIndex": 0,
|
||||
"resourceName": "PRSFX- Protect",
|
||||
"resourceName": "PRSFX- Protect.wav",
|
||||
"volume": 70,
|
||||
"pitch": 120,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
|
@ -1057,7 +1057,7 @@
|
|||
"2": [
|
||||
{
|
||||
"frameIndex": 2,
|
||||
"resourceName": "PRSFX- Doom Desire1",
|
||||
"resourceName": "PRSFX- Doom Desire1.wav",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
|
@ -5699,7 +5699,7 @@
|
|||
"5": [
|
||||
{
|
||||
"frameIndex": 5,
|
||||
"resourceName": "PRSFX- Psychic Terrain2",
|
||||
"resourceName": "PRSFX- Psychic Terrain2.wav",
|
||||
"volume": 80,
|
||||
"pitch": 140,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5708,7 +5708,7 @@
|
|||
"9": [
|
||||
{
|
||||
"frameIndex": 9,
|
||||
"resourceName": "PRSFX- Psychic Terrain2",
|
||||
"resourceName": "PRSFX- Psychic Terrain2.wav",
|
||||
"volume": 80,
|
||||
"pitch": 130,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5717,7 +5717,7 @@
|
|||
"15": [
|
||||
{
|
||||
"frameIndex": 15,
|
||||
"resourceName": "PRSFX- Psychic Terrain2",
|
||||
"resourceName": "PRSFX- Psychic Terrain2.wav",
|
||||
"volume": 80,
|
||||
"pitch": 140,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5726,7 +5726,7 @@
|
|||
"19": [
|
||||
{
|
||||
"frameIndex": 19,
|
||||
"resourceName": "PRSFX- Psychic Terrain2",
|
||||
"resourceName": "PRSFX- Psychic Terrain2.wav",
|
||||
"volume": 80,
|
||||
"pitch": 130,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5735,7 +5735,7 @@
|
|||
"25": [
|
||||
{
|
||||
"frameIndex": 25,
|
||||
"resourceName": "PRSFX- Psychic Terrain2",
|
||||
"resourceName": "PRSFX- Psychic Terrain2.wav",
|
||||
"volume": 80,
|
||||
"pitch": 140,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5744,7 +5744,7 @@
|
|||
"29": [
|
||||
{
|
||||
"frameIndex": 29,
|
||||
"resourceName": "PRSFX- Psychic Terrain2",
|
||||
"resourceName": "PRSFX- Psychic Terrain2.wav",
|
||||
"volume": 80,
|
||||
"pitch": 130,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5753,7 +5753,7 @@
|
|||
"36": [
|
||||
{
|
||||
"frameIndex": 36,
|
||||
"resourceName": "PRSFX- Psychic Terrain2",
|
||||
"resourceName": "PRSFX- Psychic Terrain2.wav",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3397,7 +3397,7 @@
|
|||
"4": [
|
||||
{
|
||||
"frameIndex": 4,
|
||||
"resourceName": "PRSFX- Freeze Shock1",
|
||||
"resourceName": "PRSFX- Freeze Shock1.wav",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
|
@ -3005,7 +3005,7 @@
|
|||
},
|
||||
{
|
||||
"frameIndex": 0,
|
||||
"resourceName": "PRSFX- Fusion Bolt1",
|
||||
"resourceName": "PRSFX- Fusion Bolt1.wav",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -3014,7 +3014,7 @@
|
|||
"19": [
|
||||
{
|
||||
"frameIndex": 19,
|
||||
"resourceName": "PRSFX- Fusion Bolt2",
|
||||
"resourceName": "PRSFX- Fusion Bolt2.wav",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6030,7 +6030,7 @@
|
|||
},
|
||||
{
|
||||
"frameIndex": 0,
|
||||
"resourceName": "PRSFX- Fusion Bolt1",
|
||||
"resourceName": "PRSFX- Fusion Bolt1.wav",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6039,7 +6039,7 @@
|
|||
"19": [
|
||||
{
|
||||
"frameIndex": 19,
|
||||
"resourceName": "PRSFX- Fusion Bolt2",
|
||||
"resourceName": "PRSFX- Fusion Bolt2.wav",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
|
@ -1400,7 +1400,7 @@
|
|||
"0": [
|
||||
{
|
||||
"frameIndex": 0,
|
||||
"resourceName": "throw",
|
||||
"resourceName": "throw.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -1409,7 +1409,7 @@
|
|||
"9": [
|
||||
{
|
||||
"frameIndex": 9,
|
||||
"resourceName": "Blow4",
|
||||
"resourceName": "Blow4.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -2820,7 +2820,7 @@
|
|||
"0": [
|
||||
{
|
||||
"frameIndex": 0,
|
||||
"resourceName": "throw",
|
||||
"resourceName": "throw.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -2829,7 +2829,7 @@
|
|||
"9": [
|
||||
{
|
||||
"frameIndex": 9,
|
||||
"resourceName": "Blow3",
|
||||
"resourceName": "Blow3.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
|
@ -7213,7 +7213,7 @@
|
|||
"0": [
|
||||
{
|
||||
"frameIndex": 0,
|
||||
"resourceName": "Wind8",
|
||||
"resourceName": "Wind8.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -7222,7 +7222,7 @@
|
|||
"5": [
|
||||
{
|
||||
"frameIndex": 5,
|
||||
"resourceName": "Wind7",
|
||||
"resourceName": "Wind7.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -7231,7 +7231,7 @@
|
|||
"8": [
|
||||
{
|
||||
"frameIndex": 8,
|
||||
"resourceName": "Wind7",
|
||||
"resourceName": "Wind7.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -7240,7 +7240,7 @@
|
|||
"11": [
|
||||
{
|
||||
"frameIndex": 11,
|
||||
"resourceName": "Wind8",
|
||||
"resourceName": "Wind8.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -7249,7 +7249,7 @@
|
|||
"16": [
|
||||
{
|
||||
"frameIndex": 16,
|
||||
"resourceName": "Wind7",
|
||||
"resourceName": "Wind7.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -7258,7 +7258,7 @@
|
|||
"19": [
|
||||
{
|
||||
"frameIndex": 19,
|
||||
"resourceName": "Wind7",
|
||||
"resourceName": "Wind7.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -7267,7 +7267,7 @@
|
|||
"22": [
|
||||
{
|
||||
"frameIndex": 22,
|
||||
"resourceName": "Wind8",
|
||||
"resourceName": "Wind8.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -7276,7 +7276,7 @@
|
|||
"27": [
|
||||
{
|
||||
"frameIndex": 27,
|
||||
"resourceName": "Wind7",
|
||||
"resourceName": "Wind7.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -7285,7 +7285,7 @@
|
|||
"30": [
|
||||
{
|
||||
"frameIndex": 30,
|
||||
"resourceName": "Wind7",
|
||||
"resourceName": "Wind7.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
|
@ -5944,7 +5944,7 @@
|
|||
"15": [
|
||||
{
|
||||
"frameIndex": 15,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5953,7 +5953,7 @@
|
|||
"17": [
|
||||
{
|
||||
"frameIndex": 17,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5962,7 +5962,7 @@
|
|||
"19": [
|
||||
{
|
||||
"frameIndex": 19,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5971,7 +5971,7 @@
|
|||
"21": [
|
||||
{
|
||||
"frameIndex": 21,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5980,7 +5980,7 @@
|
|||
"23": [
|
||||
{
|
||||
"frameIndex": 23,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5989,7 +5989,7 @@
|
|||
"25": [
|
||||
{
|
||||
"frameIndex": 25,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -5998,7 +5998,7 @@
|
|||
"27": [
|
||||
{
|
||||
"frameIndex": 27,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6007,7 +6007,7 @@
|
|||
"29": [
|
||||
{
|
||||
"frameIndex": 29,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6016,7 +6016,7 @@
|
|||
"31": [
|
||||
{
|
||||
"frameIndex": 31,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6025,7 +6025,7 @@
|
|||
"33": [
|
||||
{
|
||||
"frameIndex": 33,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6034,7 +6034,7 @@
|
|||
"35": [
|
||||
{
|
||||
"frameIndex": 35,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6043,7 +6043,7 @@
|
|||
"37": [
|
||||
{
|
||||
"frameIndex": 37,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6052,7 +6052,7 @@
|
|||
"39": [
|
||||
{
|
||||
"frameIndex": 39,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6061,7 +6061,7 @@
|
|||
"41": [
|
||||
{
|
||||
"frameIndex": 41,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6070,7 +6070,7 @@
|
|||
"43": [
|
||||
{
|
||||
"frameIndex": 43,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6079,7 +6079,7 @@
|
|||
"45": [
|
||||
{
|
||||
"frameIndex": 45,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6088,7 +6088,7 @@
|
|||
"47": [
|
||||
{
|
||||
"frameIndex": 47,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6097,7 +6097,7 @@
|
|||
"49": [
|
||||
{
|
||||
"frameIndex": 49,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
@ -6119,7 +6119,7 @@
|
|||
},
|
||||
{
|
||||
"frameIndex": 51,
|
||||
"resourceName": "Blow1",
|
||||
"resourceName": "Blow1.ogg",
|
||||
"volume": 80,
|
||||
"pitch": 100,
|
||||
"eventType": "AnimTimedSoundEvent"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -18,6 +18,12 @@ enum AnimFocus {
|
|||
SCREEN
|
||||
}
|
||||
|
||||
enum AnimBlendType {
|
||||
NORMAL,
|
||||
ADD,
|
||||
SUBTRACT
|
||||
}
|
||||
|
||||
export enum ChargeAnim {
|
||||
FLY_CHARGING = 1000,
|
||||
BOUNCE_CHARGING,
|
||||
|
@ -151,7 +157,7 @@ class AnimFrame {
|
|||
public angle: number;
|
||||
public mirror: boolean;
|
||||
public visible: boolean;
|
||||
public blendType: integer;
|
||||
public blendType: AnimBlendType;
|
||||
public target: AnimFrameTarget;
|
||||
public graphicFrame: integer;
|
||||
public opacity: integer;
|
||||
|
@ -162,7 +168,7 @@ class AnimFrame {
|
|||
public priority: integer;
|
||||
public focus: AnimFocus;
|
||||
|
||||
constructor(x: number, y: number, zoomX: number, zoomY: number, angle: number, mirror: boolean, visible: boolean, blendType: integer, pattern: integer,
|
||||
constructor(x: number, y: number, zoomX: number, zoomY: number, angle: number, mirror: boolean, visible: boolean, blendType: AnimBlendType, pattern: integer,
|
||||
opacity: integer, colorR: integer, colorG: integer, colorB: integer, colorA: integer, toneR: integer, toneG: integer, toneB: integer, toneA: integer,
|
||||
flashR: integer, flashG: integer, flashB: integer, flashA: integer, locked: boolean, priority: integer, focus: AnimFocus) {
|
||||
this.x = x;
|
||||
|
@ -220,7 +226,7 @@ class AnimTimedSoundEvent extends AnimTimedEvent {
|
|||
public pitch: number;
|
||||
|
||||
constructor(frameIndex: integer, resourceName: string, source?: any) {
|
||||
super(frameIndex, resourceName);
|
||||
super(frameIndex, resourceName + (resourceName && resourceName.indexOf('.') === -1 ? '.ogg' : ''));
|
||||
|
||||
if (source) {
|
||||
this.volume = source.volume;
|
||||
|
@ -232,7 +238,11 @@ class AnimTimedSoundEvent extends AnimTimedEvent {
|
|||
execute(scene: BattleScene, battleAnim: BattleAnim): integer {
|
||||
const soundConfig = { rate: (this.pitch * 0.01), volume: (this.volume * 0.01) };
|
||||
if (this.resourceName) {
|
||||
scene.sound.play(this.resourceName, soundConfig);
|
||||
try {
|
||||
scene.sound.play(this.resourceName, soundConfig);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
return Math.ceil((scene.sound.get(this.resourceName).totalDuration * 1000) / 33.33);
|
||||
} else
|
||||
return Math.ceil(battleAnim.user.cry(soundConfig) / 33.33);
|
||||
|
@ -289,7 +299,7 @@ class AnimTimedUpdateBgEvent extends AnimTimedBgEvent {
|
|||
execute(scene: BattleScene, moveAnim: MoveAnim): integer {
|
||||
const tweenProps = {};
|
||||
if (this.bgX !== undefined)
|
||||
tweenProps['x'] = (this.bgX * 0.5) - 256;
|
||||
tweenProps['x'] = (this.bgX * 0.5);
|
||||
if (this.bgY !== undefined)
|
||||
tweenProps['y'] = (this.bgY * 0.5) - 284;
|
||||
if (this.opacity !== undefined)
|
||||
|
@ -297,7 +307,7 @@ class AnimTimedUpdateBgEvent extends AnimTimedBgEvent {
|
|||
if (Object.keys(tweenProps).length) {
|
||||
scene.tweens.add(Object.assign({
|
||||
targets: moveAnim.bgSprite,
|
||||
duration: this.duration * 2,
|
||||
duration: this.duration * 3,
|
||||
useFrames: true
|
||||
}, tweenProps))
|
||||
}
|
||||
|
@ -315,17 +325,19 @@ class AnimTimedAddBgEvent extends AnimTimedBgEvent {
|
|||
}
|
||||
|
||||
execute(scene: BattleScene, moveAnim: MoveAnim): integer {
|
||||
moveAnim.bgSprite = scene.add.tileSprite(this.bgX - 256, this.bgY - 284, 768, 576, this.resourceName);
|
||||
if (moveAnim.bgSprite)
|
||||
moveAnim.bgSprite.destroy();
|
||||
moveAnim.bgSprite = scene.add.tileSprite(this.bgX, this.bgY - 284, 768, 576, this.resourceName);
|
||||
moveAnim.bgSprite.setOrigin(0, 0);
|
||||
moveAnim.bgSprite.setScale(1.25);
|
||||
moveAnim.bgSprite.setAlpha(0);
|
||||
scene.field.add(moveAnim.bgSprite);
|
||||
scene.field.moveBelow(moveAnim.bgSprite, scene.getEnemyPokemon());
|
||||
scene.field.moveAbove(moveAnim.bgSprite, scene.arenaEnemy);
|
||||
|
||||
scene.tweens.add({
|
||||
targets: moveAnim.bgSprite,
|
||||
alpha: 1,
|
||||
duration: this.duration * 2,
|
||||
duration: this.duration * 3,
|
||||
useFrames: true
|
||||
});
|
||||
|
||||
|
@ -444,17 +456,14 @@ export function loadCommonAnimAssets(scene: BattleScene, startLoad?: boolean): P
|
|||
|
||||
export function loadMoveAnimAssets(scene: BattleScene, moveIds: Moves[], startLoad?: boolean): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
const moveAnimations = moveIds.map(m => {
|
||||
const anims = moveAnims.get(m);
|
||||
if (anims instanceof Anim)
|
||||
return anims;
|
||||
return anims[0];
|
||||
});
|
||||
const moveAnimations = moveIds.map(m => moveAnims.get(m)).flat();
|
||||
for (let moveId of moveIds) {
|
||||
const chargeAttr = allMoves[moveId - 1].getAttrs(ChargeAttr) as ChargeAttr[];
|
||||
if (chargeAttr.length) {
|
||||
const moveChargeAnims = chargeAnims.get(chargeAttr[0].chargeAnim);
|
||||
moveAnimations.push(moveChargeAnims instanceof Anim ? moveChargeAnims : moveChargeAnims[0]);
|
||||
if (Array.isArray(moveChargeAnims))
|
||||
moveAnimations.push(moveChargeAnims[1]);
|
||||
}
|
||||
}
|
||||
loadAnimAssets(scene, moveAnimations, startLoad).then(() => resolve());
|
||||
|
@ -488,6 +497,12 @@ function loadAnimAssets(scene: BattleScene, anims: Anim[], startLoad?: boolean):
|
|||
});
|
||||
}
|
||||
|
||||
interface GraphicFrameData {
|
||||
x: number,
|
||||
y: number,
|
||||
angle: number
|
||||
}
|
||||
|
||||
export abstract class BattleAnim {
|
||||
public user: Pokemon;
|
||||
public target: Pokemon;
|
||||
|
@ -506,6 +521,52 @@ export abstract class BattleAnim {
|
|||
|
||||
abstract isReverseCoords(): boolean;
|
||||
|
||||
getGraphicScale(): number {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private getGraphicFrameData(scene: BattleScene, frames: AnimFrame[]): Map<integer, GraphicFrameData> {
|
||||
const ret = new Map<integer, GraphicFrameData>();
|
||||
|
||||
const isOppAnim = this.isOppAnim();
|
||||
const user = !isOppAnim ? this.user : this.target;
|
||||
const target = !isOppAnim ? this.target : this.user;
|
||||
const isReverseCoords = this.isReverseCoords();
|
||||
const graphicScale = this.getGraphicScale();
|
||||
|
||||
const userInitialX = user.x;
|
||||
const userInitialY = user.y;
|
||||
const userHalfHeight = user.getSprite().displayHeight / 2;
|
||||
const targetInitialX = target.x;
|
||||
const targetInitialY = target.y;
|
||||
const targetHalfHeight = target.getSprite().displayHeight / 2;
|
||||
|
||||
let g = 0;
|
||||
|
||||
for (let frame of frames) {
|
||||
if (frame.target !== AnimFrameTarget.GRAPHIC)
|
||||
continue;
|
||||
|
||||
const xProgress = frame.focus !== AnimFocus.SCREEN ? Math.min(Math.max(frame.x, 0) / 128, 1) : 0;
|
||||
const initialX = targetInitialX;
|
||||
const initialY = targetInitialY;
|
||||
let xOffset = (!isReverseCoords ? (userInitialX - targetInitialX) : (targetInitialX - userInitialX));
|
||||
let yOffset = (!isReverseCoords ? (userInitialY - targetInitialY) : (targetInitialY - userInitialY));
|
||||
const ySpriteOffset = ((userHalfHeight * (1 - xProgress)) + (targetHalfHeight * xProgress)) * -1;
|
||||
if (graphicScale > 1) {
|
||||
xOffset -= ((scene.game.canvas.width / 6) * (graphicScale - 1)) / 2;
|
||||
yOffset -= ((scene.game.canvas.height / 6) * (graphicScale - 1)) / 2;
|
||||
}
|
||||
const x = initialX + xOffset * (!isReverseCoords ? 1 : -1) + (frame.x * graphicScale) * (!isReverseCoords ? 1 : -1);
|
||||
const y = ((initialY + yOffset * (!isReverseCoords || frame.focus === AnimFocus.USER || frame.focus === AnimFocus.SCREEN ? 1 : -1)
|
||||
+ (frame.y * graphicScale) * (!isReverseCoords || (frame.focus !== AnimFocus.USER_TARGET) ? 1 : -1) + ySpriteOffset));
|
||||
const angle = -frame.angle * (!isReverseCoords ? 1 : -1);
|
||||
ret.set(g++, { x: x, y: y, angle: angle });
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
play(scene: BattleScene, callback?: Function) {
|
||||
const isOppAnim = this.isOppAnim();
|
||||
const user = !isOppAnim ? this.user : this.target;
|
||||
|
@ -515,52 +576,110 @@ export abstract class BattleAnim {
|
|||
|
||||
const userInitialX = user.x;
|
||||
const userInitialY = user.y;
|
||||
const userHalfHeight = user.getSprite().displayHeight / 2;
|
||||
const targetInitialX = target.x;
|
||||
const targetInitialY = target.y;
|
||||
const targetHalfHeight = target.getSprite().displayHeight / 2;
|
||||
|
||||
const coordMultiplier = this.isReverseCoords() ? -1 : 1;
|
||||
const isReverseCoords = this.isReverseCoords();
|
||||
|
||||
let r = anim.frames.length;
|
||||
let f = 0;
|
||||
|
||||
const sprites: Phaser.GameObjects.Sprite[] = [];
|
||||
const spritePriorities: integer[] = [];
|
||||
|
||||
scene.tweens.addCounter({
|
||||
useFrames: true,
|
||||
duration: 2,
|
||||
duration: 3,
|
||||
repeat: anim.frames.length,
|
||||
onRepeat: () => {
|
||||
const spriteFrames = anim.frames[f];
|
||||
const frameData = this.getGraphicFrameData(scene, anim.frames[f]);
|
||||
let g = 0;
|
||||
for (let frame of spriteFrames) {
|
||||
switch (frame.target) {
|
||||
case AnimFrameTarget.USER:
|
||||
user.setPosition(userInitialX + frame.x * coordMultiplier, userInitialY + frame.y * coordMultiplier);
|
||||
user.setPosition(userInitialX + frame.x / (!isReverseCoords ? 2 : -2), userInitialY + frame.y / (!isOppAnim ? 2 : -2));
|
||||
break;
|
||||
case AnimFrameTarget.TARGET:
|
||||
target.setPosition(targetInitialX + frame.x * coordMultiplier, targetInitialY + frame.y * coordMultiplier);
|
||||
target.setPosition(targetInitialX + frame.x / (!isReverseCoords ? 2 : -2), targetInitialY + frame.y / (!isOppAnim ? 2 : -2));
|
||||
break;
|
||||
case AnimFrameTarget.GRAPHIC:
|
||||
let isNewSprite = false;
|
||||
|
||||
if (g === sprites.length) {
|
||||
const newSprite = scene.add.sprite(0, 0, anim.graphic, 1);
|
||||
scene.field.add(newSprite);
|
||||
sprites.push(newSprite);
|
||||
scene.field.add(newSprite);
|
||||
spritePriorities.push(1);
|
||||
isNewSprite = true;
|
||||
}
|
||||
|
||||
const graphicIndex = g++;
|
||||
const moveSprite = sprites[graphicIndex];
|
||||
if (spritePriorities[graphicIndex] !== frame.priority) {
|
||||
spritePriorities[graphicIndex] = frame.priority;
|
||||
const setSpritePriority = (priority: integer) => {
|
||||
switch (priority) {
|
||||
case 0:
|
||||
scene.field.moveBelow(moveSprite, scene.getEnemyPokemon());
|
||||
break;
|
||||
case 1:
|
||||
scene.field.moveTo(moveSprite, scene.field.getAll().length - 1);
|
||||
break;
|
||||
case 2:
|
||||
switch (frame.focus) {
|
||||
case AnimFocus.USER:
|
||||
if (this.bgSprite)
|
||||
scene.field.moveAbove(moveSprite, this.bgSprite);
|
||||
else
|
||||
scene.field.moveBelow(moveSprite, this.user);
|
||||
break;
|
||||
case AnimFocus.TARGET:
|
||||
scene.field.moveBelow(moveSprite, this.target);
|
||||
break;
|
||||
default:
|
||||
setSpritePriority(1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch (frame.focus) {
|
||||
case AnimFocus.USER:
|
||||
scene.field.moveAbove(moveSprite, this.user);
|
||||
break;
|
||||
case AnimFocus.TARGET:
|
||||
scene.field.moveAbove(moveSprite, this.target);
|
||||
break;
|
||||
default:
|
||||
setSpritePriority(1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
setSpritePriority(1);
|
||||
}
|
||||
};
|
||||
setSpritePriority(frame.priority);
|
||||
}
|
||||
const moveSprite = sprites[g++];
|
||||
moveSprite.setFrame(frame.graphicFrame);
|
||||
const xProgress = Math.min(Math.max(frame.x, 0) / 128, 1);
|
||||
const yOffset = ((userHalfHeight * (1 - xProgress)) + (targetHalfHeight * xProgress)) * -1;
|
||||
moveSprite.setPosition((!isOppAnim ? userInitialX : targetInitialX) + frame.x * coordMultiplier, (!isOppAnim ? userInitialY : targetInitialY) + yOffset + frame.y * coordMultiplier);
|
||||
moveSprite.setAlpha(frame.opacity);
|
||||
moveSprite.setAngle(-frame.angle * coordMultiplier);
|
||||
//console.log(AnimFocus[frame.focus]);
|
||||
const graphicScale = this.getGraphicScale();
|
||||
|
||||
moveSprite.setPosition(frameData.get(graphicIndex).x, frameData.get(graphicIndex).y);
|
||||
moveSprite.setAngle(frameData.get(graphicIndex).angle);
|
||||
const scaleX = graphicScale * (isReverseCoords === frame.mirror ? 1 : -1);
|
||||
const scaleY = graphicScale;
|
||||
moveSprite.setScale(scaleX, scaleY);
|
||||
|
||||
moveSprite.setAlpha(frame.opacity / 255);
|
||||
moveSprite.setBlendMode(frame.blendType === AnimBlendType.NORMAL ? Phaser.BlendModes.NORMAL : frame.blendType === AnimBlendType.ADD ? Phaser.BlendModes.ADD : Phaser.BlendModes.DIFFERENCE);
|
||||
break;
|
||||
}
|
||||
if (frame.target !== AnimFrameTarget.GRAPHIC) {
|
||||
const pokemon = frame.target === AnimFrameTarget.USER ? user : target;
|
||||
pokemon.setAlpha(frame.opacity);
|
||||
pokemon.setAngle(-frame.angle * coordMultiplier);
|
||||
pokemon.setScale(!frame.mirror ? 1 : -1)
|
||||
pokemon.setAlpha(frame.opacity / 255);
|
||||
pokemon.setAngle(-frame.angle * (!isReverseCoords ? 1 : -1));
|
||||
const zoomScaleX = frame.zoomX / 100;
|
||||
const zoomScaleY = frame.zoomY / 100;
|
||||
const zoomSprite = pokemon.getZoomSprite();
|
||||
|
@ -574,6 +693,7 @@ export abstract class BattleAnim {
|
|||
}
|
||||
if (g < sprites.length) {
|
||||
const removedSprites = sprites.splice(g, sprites.length - g);
|
||||
spritePriorities.splice(g, sprites.length - g);
|
||||
for (let rs of removedSprites)
|
||||
rs.destroy();
|
||||
}
|
||||
|
@ -583,16 +703,22 @@ export abstract class BattleAnim {
|
|||
onComplete: () => {
|
||||
const cleanUpAndComplete = () => {
|
||||
user.setPosition(userInitialX, userInitialY);
|
||||
user.setScale(1);
|
||||
user.setAlpha(1);
|
||||
user.setAngle(0);
|
||||
target.setPosition(targetInitialX, targetInitialY);
|
||||
target.setScale(1);
|
||||
target.setAlpha(1);
|
||||
target.setAngle(0);
|
||||
if (this.bgSprite)
|
||||
this.bgSprite.destroy();
|
||||
if (callback)
|
||||
callback();
|
||||
};
|
||||
for (let ms of sprites)
|
||||
ms.destroy();
|
||||
for (let ms of sprites) {
|
||||
if (ms)
|
||||
ms.destroy();
|
||||
}
|
||||
if (r) {
|
||||
scene.tweens.addCounter({
|
||||
duration: r,
|
||||
|
@ -650,6 +776,15 @@ export class MoveAnim extends BattleAnim {
|
|||
isReverseCoords(): boolean {
|
||||
return this.user instanceof EnemyPokemon && !this.isOppAnim();
|
||||
}
|
||||
|
||||
getGraphicScale(): number {
|
||||
switch (this.move) {
|
||||
case Moves.FISSURE:
|
||||
return 1.25;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
export class MoveChargeAnim extends MoveAnim {
|
||||
|
|
|
@ -437,6 +437,10 @@ export class CommandPhase extends BattlePhase {
|
|||
this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, cursor, true));
|
||||
success = true;
|
||||
break;
|
||||
case Command.RUN:
|
||||
//this.scene.unshiftPhase(new MoveAnimTestPhase(this.scene, [ Moves.SING, Moves.FISSURE, Moves.GROWL, Moves.AROMATHERAPY, Moves.PERISH_SONG ]));
|
||||
//success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
|
@ -545,7 +549,7 @@ abstract class MovePhase extends BattlePhase {
|
|||
console.log(this.pokemon.moveset);
|
||||
if (this.pokemon.summonData.moveQueue.length && !this.pokemon.summonData.moveQueue.shift().ignorePP)
|
||||
this.move.ppUsed++;
|
||||
this.scene.unshiftPhase(new MessagePhase(this.scene, `${this.pokemon.name} used\n${this.move.getName()}!`, 500));
|
||||
this.scene.unshiftPhase(new MessagePhase(this.scene, `${this.pokemon instanceof EnemyPokemon ? 'Foe ' : ''}${this.pokemon.name} used\n${this.move.getName()}!`, 500));
|
||||
this.scene.unshiftPhase(this.getEffectPhase());
|
||||
this.end();
|
||||
};
|
||||
|
@ -632,6 +636,8 @@ abstract class MoveEffectPhase extends PokemonPhase {
|
|||
|
||||
const overridden = new Utils.BooleanHolder(false);
|
||||
|
||||
console.log(this.move.getName());
|
||||
|
||||
applyMoveAttrs(OverrideMoveEffectAttr, this.scene, user, target, this.move.getMove(), overridden).then(() => {
|
||||
|
||||
if (overridden.value) {
|
||||
|
@ -682,7 +688,7 @@ abstract class MoveEffectPhase extends PokemonPhase {
|
|||
|
||||
end() {
|
||||
const user = this.getUserPokemon();
|
||||
if (--user.turnData.hitsLeft && this.getTargetPokemon().hp)
|
||||
if (--user.turnData.hitsLeft >= 1 && this.getTargetPokemon().hp)
|
||||
this.scene.unshiftPhase(this.getNewHitPhase());
|
||||
else {
|
||||
if (user.turnData.hitsTotal > 1)
|
||||
|
@ -763,6 +769,42 @@ export class EnemyMoveEffectPhase extends MoveEffectPhase {
|
|||
}
|
||||
}
|
||||
|
||||
export class MoveAnimTestPhase extends BattlePhase {
|
||||
private moveQueue: Moves[];
|
||||
|
||||
constructor(scene: BattleScene, moveQueue?: Moves[]) {
|
||||
super(scene);
|
||||
|
||||
this.moveQueue = moveQueue || Utils.getEnumValues(Moves);
|
||||
}
|
||||
|
||||
start() {
|
||||
const moveQueue = this.moveQueue.slice(0);
|
||||
this.playMoveAnim(moveQueue, true);
|
||||
}
|
||||
|
||||
playMoveAnim(moveQueue: Moves[], player: boolean) {
|
||||
const moveId = player ? moveQueue[0] : moveQueue.shift();
|
||||
if (moveId === undefined) {
|
||||
this.playMoveAnim(this.moveQueue.slice(0), true);
|
||||
return;
|
||||
}
|
||||
|
||||
initMoveAnim(moveId).then(() => {
|
||||
loadMoveAnimAssets(this.scene, [ moveId ], true)
|
||||
.then(() => {
|
||||
new MoveAnim(moveId, player ? this.scene.getPlayerPokemon() : this.scene.getEnemyPokemon(),
|
||||
player ? this.scene.getEnemyPokemon() : this.scene.getPlayerPokemon()).play(this.scene, () => {
|
||||
if (player)
|
||||
this.playMoveAnim(moveQueue, false);
|
||||
else
|
||||
this.playMoveAnim(moveQueue, true);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class StatChangePhase extends PokemonPhase {
|
||||
private stats: BattleStat[];
|
||||
private levels: integer;
|
||||
|
@ -940,7 +982,7 @@ export class FaintPhase extends PokemonPhase {
|
|||
}
|
||||
|
||||
const pokemon = this.getPokemon();
|
||||
|
||||
|
||||
pokemon.lapseTags(BattleTagLapseType.FAINT);
|
||||
|
||||
pokemon.faintCry(() => {
|
||||
|
|
1153
src/move.ts
1153
src/move.ts
File diff suppressed because it is too large
Load Diff
|
@ -928,10 +928,10 @@ export class PokemonMove {
|
|||
public ppUp: integer;
|
||||
public disableTurns: integer;
|
||||
|
||||
constructor(moveId: Moves, ppUsed: integer, ppUp: integer) {
|
||||
constructor(moveId: Moves, ppUsed?: integer, ppUp?: integer) {
|
||||
this.moveId = moveId;
|
||||
this.ppUsed = ppUsed;
|
||||
this.ppUp = ppUp;
|
||||
this.ppUsed = ppUsed || 0;
|
||||
this.ppUp = ppUp || 0;
|
||||
this.disableTurns = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { CommandPhase } from "../battle-phases";
|
||||
import BattleScene, { Button } from "../battle-scene";
|
||||
import { addTextObject, TextStyle } from "../text";
|
||||
import { toPokemonUpperCase } from "../utils";
|
||||
|
@ -67,6 +68,10 @@ export default class CommandUiHandler extends UiHandler {
|
|||
ui.setMode(Mode.PARTY, PartyUiMode.SWITCH);
|
||||
success = true;
|
||||
break;
|
||||
case 3:
|
||||
(this.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.RUN, 0);
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue