Add day/night cycle
This commit is contained in:
parent
b04c7c8c3b
commit
5ef6f2da88
109
src/arena.ts
109
src/arena.ts
|
@ -15,6 +15,13 @@ import { BattlerIndex } from "./battle";
|
|||
|
||||
const WEATHER_OVERRIDE = WeatherType.NONE;
|
||||
|
||||
export enum TimeOfDay {
|
||||
DAWN,
|
||||
DAY,
|
||||
DUSK,
|
||||
NIGHT
|
||||
}
|
||||
|
||||
export class Arena {
|
||||
public scene: BattleScene;
|
||||
public biomeType: Biome;
|
||||
|
@ -136,14 +143,15 @@ export class Arena {
|
|||
case Species.VIVILLON:
|
||||
return 0;
|
||||
case Species.LYCANROC:
|
||||
switch (this.biomeType) {
|
||||
case Biome.CAVE:
|
||||
case Biome.ICE_CAVE:
|
||||
case Biome.FAIRY_CAVE:
|
||||
const timeOfDay = this.getTimeOfDay();
|
||||
switch (timeOfDay) {
|
||||
case TimeOfDay.DAY:
|
||||
case TimeOfDay.DAWN:
|
||||
return 0;
|
||||
case TimeOfDay.DUSK:
|
||||
return 2;
|
||||
default:
|
||||
if (!this.isDaytime())
|
||||
return 1;
|
||||
case TimeOfDay.NIGHT:
|
||||
return 1;
|
||||
}
|
||||
case Species.CALYREX:
|
||||
switch (this.biomeType) {
|
||||
|
@ -297,27 +305,80 @@ export class Arena {
|
|||
}
|
||||
}
|
||||
|
||||
isDaytime(): boolean {
|
||||
getTimeOfDay(): TimeOfDay {
|
||||
switch (this.biomeType) {
|
||||
case Biome.TOWN:
|
||||
case Biome.PLAINS:
|
||||
case Biome.GRASS:
|
||||
case Biome.METROPOLIS:
|
||||
case Biome.SEA:
|
||||
case Biome.BEACH:
|
||||
case Biome.LAKE:
|
||||
case Biome.MOUNTAIN:
|
||||
case Biome.BADLANDS:
|
||||
case Biome.DESERT:
|
||||
case Biome.MEADOW:
|
||||
case Biome.ABYSS:
|
||||
return TimeOfDay.NIGHT;
|
||||
}
|
||||
|
||||
const waveCycle = ((this.scene.currentBattle?.waveIndex || 0) + this.scene.getWaveCycleOffset()) % 40;
|
||||
|
||||
if (waveCycle < 15)
|
||||
return TimeOfDay.DAY;
|
||||
|
||||
if (waveCycle < 20)
|
||||
return TimeOfDay.DAWN;
|
||||
|
||||
if (waveCycle < 35)
|
||||
return TimeOfDay.NIGHT;
|
||||
|
||||
return TimeOfDay.DUSK;
|
||||
}
|
||||
|
||||
isOutside(): boolean {
|
||||
switch (this.biomeType) {
|
||||
case Biome.SEABED:
|
||||
case Biome.CAVE:
|
||||
case Biome.ICE_CAVE:
|
||||
case Biome.POWER_PLANT:
|
||||
case Biome.DOJO:
|
||||
case Biome.CONSTRUCTION_SITE:
|
||||
case Biome.ISLAND:
|
||||
case Biome.SNOWY_FOREST:
|
||||
case Biome.FACTORY:
|
||||
case Biome.ABYSS:
|
||||
case Biome.FAIRY_CAVE:
|
||||
case Biome.TEMPLE:
|
||||
case Biome.LABORATORY:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
getDayTint(): [integer, integer, integer] {
|
||||
switch (this.biomeType) {
|
||||
case Biome.ABYSS:
|
||||
return [ 64, 64, 64 ];
|
||||
default:
|
||||
return [ 128, 128, 128 ];
|
||||
}
|
||||
}
|
||||
|
||||
getDuskTint(): [integer, integer, integer] {
|
||||
if (!this.isOutside())
|
||||
return [ 0, 0, 0 ];
|
||||
|
||||
switch (this.biomeType) {
|
||||
default:
|
||||
return [ 98, 48, 73 ].map(c => Math.round((c + 128) / 2)) as [integer, integer, integer];
|
||||
}
|
||||
}
|
||||
|
||||
getNightTint(): [integer, integer, integer] {
|
||||
switch (this.biomeType) {
|
||||
case Biome.ABYSS:
|
||||
case Biome.SPACE:
|
||||
case Biome.END:
|
||||
return this.getDayTint();
|
||||
}
|
||||
|
||||
if (!this.isOutside())
|
||||
return [ 64, 64, 64 ];
|
||||
|
||||
switch (this.biomeType) {
|
||||
default:
|
||||
return [ 48, 48, 98 ];
|
||||
}
|
||||
}
|
||||
|
||||
applyTags(tagType: ArenaTagType | { new(...args: any[]): ArenaTag }, ...args: any[]): void {
|
||||
const tags = typeof tagType === 'number'
|
||||
? this.tags.filter(t => t.tagType === tagType)
|
||||
|
@ -492,12 +553,12 @@ export class ArenaBase extends Phaser.GameObjects.Container {
|
|||
|
||||
this.player = player;
|
||||
|
||||
this.base = scene.add.sprite(0, 0, 'plains_a');
|
||||
this.base = scene.addFieldSprite(0, 0, 'plains_a');
|
||||
this.base.setOrigin(0, 0);
|
||||
|
||||
this.props = !player ?
|
||||
new Array(3).fill(null).map(() => {
|
||||
const ret = scene.add.sprite(0, 0, 'plains_b');
|
||||
const ret = scene.addFieldSprite(0, 0, 'plains_b');
|
||||
ret.setOrigin(0, 0);
|
||||
ret.setVisible(false);
|
||||
return ret;
|
||||
|
|
|
@ -135,6 +135,7 @@ export class SelectStarterPhase extends BattlePhase {
|
|||
this.scene.ui.setMode(Mode.MESSAGE).then(() => {
|
||||
SoundFade.fadeOut(this.scene, this.scene.sound.get('menu'), 500, true);
|
||||
this.scene.time.delayedCall(500, () => this.scene.playBgm());
|
||||
this.scene.newBattle();
|
||||
this.end();
|
||||
});
|
||||
});
|
||||
|
@ -335,7 +336,7 @@ export class EncounterPhase extends BattlePhase {
|
|||
pokemon.resetBattleData();
|
||||
}
|
||||
|
||||
this.scene.arena.trySetWeather(getRandomWeatherType(this.scene.arena.biomeType), false);
|
||||
this.scene.arena.trySetWeather(getRandomWeatherType(this.scene.arena), false);
|
||||
|
||||
const enemyField = this.scene.getEnemyField();
|
||||
this.scene.tweens.add({
|
||||
|
@ -489,7 +490,7 @@ export class NewBiomeEncounterPhase extends NextEncounterPhase {
|
|||
pokemon.resetBattleData();
|
||||
}
|
||||
|
||||
this.scene.arena.trySetWeather(getRandomWeatherType(this.scene.arena.biomeType), false);
|
||||
this.scene.arena.trySetWeather(getRandomWeatherType(this.scene.arena), false);
|
||||
|
||||
const enemyField = this.scene.getEnemyField();
|
||||
this.scene.tweens.add({
|
||||
|
@ -685,7 +686,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
|||
}
|
||||
|
||||
summon(): void {
|
||||
const pokeball = this.scene.add.sprite(this.player ? 36 : 248, this.player ? 80 : 44, 'pb', 'pb');
|
||||
const pokeball = this.scene.addFieldSprite(this.player ? 36 : 248, this.player ? 80 : 44, 'pb', 'pb');
|
||||
pokeball.setVisible(false);
|
||||
pokeball.setOrigin(0.5, 0.625);
|
||||
this.scene.field.add(pokeball);
|
||||
|
@ -1953,6 +1954,7 @@ export class StatChangePhase extends PokemonPhase {
|
|||
const pokemonMaskSprite = pokemon.maskSprite;
|
||||
|
||||
const statSprite = this.scene.add.tileSprite((this.player ? 106 : 236) * 6, ((this.player ? 148 : 84) + (levels.value >= 1 ? 160 : 0)) * 6, 156, 316, 'battle_stats', filteredStats.length > 1 ? 'mix' : BattleStat[filteredStats[0]].toLowerCase());
|
||||
statSprite.setPipeline(this.scene.fieldSpritePipeline);
|
||||
statSprite.setAlpha(0);
|
||||
statSprite.setScale(6);
|
||||
statSprite.setOrigin(0.5, 1);
|
||||
|
@ -2877,7 +2879,7 @@ export class AttemptCapturePhase extends PokemonPhase {
|
|||
const fpOffset = pokemon.getFieldPositionOffset();
|
||||
|
||||
const pokeballAtlasKey = getPokeballAtlasKey(this.pokeballType);
|
||||
this.pokeball = this.scene.add.sprite(16, 80, 'pb', pokeballAtlasKey);
|
||||
this.pokeball = this.scene.addFieldSprite(16, 80, 'pb', pokeballAtlasKey);
|
||||
this.pokeball.setOrigin(0.5, 0.625);
|
||||
this.scene.field.add(this.pokeball);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import AbilityBar from './ui/ability-bar';
|
|||
import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, applyAbAttrs, initAbilities } from './data/ability';
|
||||
import Battle, { BattleType, FixedBattleConfig, fixedBattles } from './battle';
|
||||
import { GameMode } from './game-mode';
|
||||
import FieldSpritePipeline from './pipelines/field-sprite';
|
||||
import SpritePipeline from './pipelines/sprite';
|
||||
import PartyExpBar from './ui/party-exp-bar';
|
||||
import { TrainerType, trainerConfigs } from './data/trainer-type';
|
||||
|
@ -122,6 +123,7 @@ export default class BattleScene extends Phaser.Scene {
|
|||
public seed: string;
|
||||
public waveSeed: string;
|
||||
|
||||
public fieldSpritePipeline: FieldSpritePipeline;
|
||||
public spritePipeline: SpritePipeline;
|
||||
|
||||
private bgm: AnySound;
|
||||
|
@ -389,6 +391,9 @@ export default class BattleScene extends Phaser.Scene {
|
|||
this.spritePipeline = new SpritePipeline(this.game);
|
||||
(this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.add('Sprite', this.spritePipeline);
|
||||
|
||||
this.fieldSpritePipeline = new FieldSpritePipeline(this.game);
|
||||
(this.renderer as Phaser.Renderer.WebGL.WebGLRenderer).pipelines.add('FieldSprite', this.fieldSpritePipeline);
|
||||
|
||||
this.time.delayedCall(20, () => this.launchBattle());
|
||||
}
|
||||
|
||||
|
@ -466,8 +471,8 @@ export default class BattleScene extends Phaser.Scene {
|
|||
|
||||
this.quickStart = this.quickStart || this.isButtonPressed(Button.QUICK_START);
|
||||
|
||||
this.arenaBg = this.add.sprite(0, 0, 'plains_bg');
|
||||
this.arenaBgTransition = this.add.sprite(0, 0, `plains_bg`);
|
||||
this.arenaBg = this.addFieldSprite(0, 0, 'plains_bg');
|
||||
this.arenaBgTransition = this.addFieldSprite(0, 0, `plains_bg`);
|
||||
this.arenaPlayer = new ArenaBase(this, true);
|
||||
this.arenaPlayerTransition = new ArenaBase(this, true);
|
||||
this.arenaEnemy = new ArenaBase(this, false);
|
||||
|
@ -489,7 +494,7 @@ export default class BattleScene extends Phaser.Scene {
|
|||
frameRate: 16
|
||||
});
|
||||
|
||||
const trainer = this.add.sprite(0, 0, 'trainer_m');
|
||||
const trainer = this.addFieldSprite(0, 0, 'trainer_m');
|
||||
trainer.setOrigin(0.5, 1);
|
||||
|
||||
field.add(trainer);
|
||||
|
@ -532,7 +537,10 @@ export default class BattleScene extends Phaser.Scene {
|
|||
if (enableAuto)
|
||||
initAutoPlay.apply(this);
|
||||
|
||||
this.newBattle();
|
||||
if (!this.quickStart)
|
||||
this.pushPhase(new CheckLoadPhase(this));
|
||||
else
|
||||
this.pushPhase(new EncounterPhase(this));
|
||||
|
||||
this.shiftPhase();
|
||||
});
|
||||
|
@ -733,35 +741,30 @@ export default class BattleScene extends Phaser.Scene {
|
|||
|
||||
//this.pushPhase(new TrainerMessageTestPhase(this));
|
||||
|
||||
if (!waveIndex) {
|
||||
const isNewBiome = !lastBattle || !(lastBattle.waveIndex % 10);
|
||||
if (!waveIndex && lastBattle) {
|
||||
const isNewBiome = !(lastBattle.waveIndex % 10);
|
||||
const resetArenaState = isNewBiome || this.currentBattle.battleType === BattleType.TRAINER;
|
||||
if (lastBattle) {
|
||||
this.getEnemyParty().forEach(enemyPokemon => enemyPokemon.destroy());
|
||||
this.trySpreadPokerus();
|
||||
if (resetArenaState) {
|
||||
this.arena.removeAllTags();
|
||||
playerField.forEach((_, p) => this.unshiftPhase(new ReturnPhase(this, p)));
|
||||
this.unshiftPhase(new ShowTrainerPhase(this));
|
||||
for (let pokemon of this.getParty()) {
|
||||
if (pokemon)
|
||||
pokemon.resetBattleData();
|
||||
}
|
||||
this.getEnemyParty().forEach(enemyPokemon => enemyPokemon.destroy());
|
||||
this.trySpreadPokerus();
|
||||
if (resetArenaState) {
|
||||
this.arena.removeAllTags();
|
||||
playerField.forEach((_, p) => this.unshiftPhase(new ReturnPhase(this, p)));
|
||||
this.unshiftPhase(new ShowTrainerPhase(this));
|
||||
for (let pokemon of this.getParty()) {
|
||||
if (pokemon)
|
||||
pokemon.resetBattleData();
|
||||
}
|
||||
if (this.gameMode === GameMode.CLASSIC && !isNewBiome)
|
||||
this.pushPhase(new NextEncounterPhase(this));
|
||||
else {
|
||||
this.pushPhase(new SelectBiomePhase(this));
|
||||
this.pushPhase(new NewBiomeEncounterPhase(this));
|
||||
}
|
||||
if (this.gameMode === GameMode.CLASSIC && !isNewBiome)
|
||||
this.pushPhase(new NextEncounterPhase(this));
|
||||
else {
|
||||
this.pushPhase(new SelectBiomePhase(this));
|
||||
this.pushPhase(new NewBiomeEncounterPhase(this));
|
||||
|
||||
const newMaxExpLevel = this.getMaxExpLevel();
|
||||
if (newMaxExpLevel > maxExpLevel)
|
||||
this.pushPhase(new LevelCapPhase(this));
|
||||
}
|
||||
} else if (!this.quickStart)
|
||||
this.pushPhase(new CheckLoadPhase(this));
|
||||
else
|
||||
this.pushPhase(new EncounterPhase(this));
|
||||
const newMaxExpLevel = this.getMaxExpLevel();
|
||||
if (newMaxExpLevel > maxExpLevel)
|
||||
this.pushPhase(new LevelCapPhase(this));
|
||||
}
|
||||
}
|
||||
|
||||
return this.currentBattle;
|
||||
|
@ -813,6 +816,14 @@ export default class BattleScene extends Phaser.Scene {
|
|||
return this.arena.getSpeciesFormIndex(species);
|
||||
}
|
||||
|
||||
getWaveCycleOffset(): integer {
|
||||
let ret = 0;
|
||||
this.executeWithSeedOffset(() => {
|
||||
ret = Utils.randSeedInt(8) * 5;
|
||||
}, 0, this.seed.toString());
|
||||
return ret;
|
||||
}
|
||||
|
||||
trySpreadPokerus(): void {
|
||||
const party = this.getParty();
|
||||
const infectedIndexes: integer[] = [];
|
||||
|
@ -841,7 +852,7 @@ export default class BattleScene extends Phaser.Scene {
|
|||
}
|
||||
|
||||
resetSeed(waveIndex?: integer): void {
|
||||
this.waveSeed = Utils.shiftCharCodes(this.seed, waveIndex || this.currentBattle.waveIndex);
|
||||
this.waveSeed = Utils.shiftCharCodes(this.seed, waveIndex || this.currentBattle?.waveIndex || 0);
|
||||
Phaser.Math.RND.sow([ this.waveSeed ]);
|
||||
}
|
||||
|
||||
|
@ -854,6 +865,13 @@ export default class BattleScene extends Phaser.Scene {
|
|||
Phaser.Math.RND.state(state);
|
||||
}
|
||||
|
||||
addFieldSprite(x: number, y: number, texture: string | Phaser.Textures.Texture, frame?: string | number): Phaser.GameObjects.Sprite {
|
||||
const ret = this.add.sprite(x, y, texture, frame);
|
||||
ret.setPipeline(this.fieldSpritePipeline);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
showFieldOverlay(duration: integer): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
this.tweens.add({
|
||||
|
|
|
@ -762,7 +762,7 @@ export abstract class BattleAnim {
|
|||
if ((isUser ? u : t) === sprites.length) {
|
||||
const spriteSource = isUser ? userSprite : targetSprite;
|
||||
let sprite: Phaser.GameObjects.Sprite;
|
||||
sprite = scene.add.sprite(0, 0, spriteSource.texture, spriteSource.frame.name);
|
||||
sprite = scene.addFieldSprite(0, 0, spriteSource.texture, spriteSource.frame.name);
|
||||
sprite.setPipeline(scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: true });
|
||||
[ 'spriteColors', 'fusionSpriteColors' ].map(k => sprite.pipelineData[k] = (isUser ? user : target).getSprite().pipelineData[k]);
|
||||
spriteSource.on('animationupdate', (_anim, frame) => sprite.setFrame(frame.textureFrame));
|
||||
|
@ -787,7 +787,7 @@ export abstract class BattleAnim {
|
|||
} else {
|
||||
const sprites = spriteCache[AnimFrameTarget.GRAPHIC];
|
||||
if (g === sprites.length) {
|
||||
let newSprite: Phaser.GameObjects.Sprite = scene.add.sprite(0, 0, anim.graphic, 1);
|
||||
let newSprite: Phaser.GameObjects.Sprite = scene.addFieldSprite(0, 0, anim.graphic, 1);
|
||||
sprites.push(newSprite);
|
||||
scene.field.add(newSprite);
|
||||
spritePriorities.push(1);
|
||||
|
|
|
@ -11,6 +11,7 @@ import * as Utils from "../utils";
|
|||
import { SpeciesFormKey } from "./pokemon-species";
|
||||
import { WeatherType } from "./weather";
|
||||
import { Biome } from "./biome";
|
||||
import { TimeOfDay } from "../arena";
|
||||
|
||||
export enum SpeciesWildEvolutionDelay {
|
||||
NONE,
|
||||
|
@ -893,10 +894,10 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.CLAWITZER, 37, null, null)
|
||||
],
|
||||
[Species.TYRUNT]: [
|
||||
new SpeciesEvolution(Species.TYRANTRUM, 39, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
new SpeciesEvolution(Species.TYRANTRUM, 39, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.DAY), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
],
|
||||
[Species.AMAURA]: [
|
||||
new SpeciesEvolution(Species.AURORUS, 39, null, new SpeciesEvolutionCondition((p: Pokemon) => !p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
new SpeciesEvolution(Species.AURORUS, 39, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
],
|
||||
[Species.GOOMY]: [
|
||||
new SpeciesEvolution(Species.HISUI_SLIGGOO, 40, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.biomeType === Biome.RUINS), SpeciesWildEvolutionDelay.NEVER),
|
||||
|
@ -939,7 +940,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.TOUCANNON, 36, null, null)
|
||||
],
|
||||
[Species.YUNGOOS]: [
|
||||
new SpeciesEvolution(Species.GUMSHOOS, 20, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.SHORT)
|
||||
new SpeciesEvolution(Species.GUMSHOOS, 20, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.DAY), SpeciesWildEvolutionDelay.SHORT)
|
||||
],
|
||||
[Species.GRUBBIN]: [
|
||||
new SpeciesEvolution(Species.CHARJABUG, 20, null, null)
|
||||
|
@ -957,7 +958,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.ARAQUANID, 22, null, null)
|
||||
],
|
||||
[Species.FOMANTIS]: [
|
||||
new SpeciesEvolution(Species.LURANTIS, 34, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.SHORT)
|
||||
new SpeciesEvolution(Species.LURANTIS, 34, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.DAY), SpeciesWildEvolutionDelay.SHORT)
|
||||
],
|
||||
[Species.MORELULL]: [
|
||||
new SpeciesEvolution(Species.SHIINOTIC, 24, null, null)
|
||||
|
@ -987,14 +988,14 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.COSMOEM, 43, null, null)
|
||||
],
|
||||
[Species.COSMOEM]: [
|
||||
new SpeciesEvolution(Species.SOLGALEO, 53, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.biomeType !== Biome.SPACE && p.scene.arena.isDaytime()), null),
|
||||
new SpeciesEvolution(Species.LUNALA, 53, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.biomeType !== Biome.SPACE && !p.scene.arena.isDaytime()), null)
|
||||
new SpeciesEvolution(Species.SOLGALEO, 53, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.biomeType !== Biome.SPACE && p.scene.arena.getTimeOfDay() === TimeOfDay.DAY), null),
|
||||
new SpeciesEvolution(Species.LUNALA, 53, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.biomeType !== Biome.SPACE && p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), null)
|
||||
],
|
||||
[Species.MELTAN]: [
|
||||
new SpeciesEvolution(Species.MELMETAL, 48, null, null)
|
||||
],
|
||||
[Species.ALOLA_RATTATA]: [
|
||||
new SpeciesEvolution(Species.ALOLA_RATICATE, 20, null, new SpeciesEvolutionCondition((p: Pokemon) => !p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.SHORT)
|
||||
new SpeciesEvolution(Species.ALOLA_RATICATE, 20, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.SHORT)
|
||||
],
|
||||
[Species.ALOLA_DIGLETT]: [
|
||||
new SpeciesEvolution(Species.ALOLA_DUGTRIO, 26, null, null)
|
||||
|
@ -1115,7 +1116,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.GALAR_LINOONE, 20, null, null)
|
||||
],
|
||||
[Species.GALAR_LINOONE]: [
|
||||
new SpeciesEvolution(Species.OBSTAGOON, 35, null, new SpeciesEvolutionCondition((p: Pokemon) => !p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.OBSTAGOON, 35, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.GALAR_YAMASK]: [
|
||||
new SpeciesEvolution(Species.RUNERIGUS, 34, null, null)
|
||||
|
@ -1215,7 +1216,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.GLIMMORA, 35, null, null)
|
||||
],
|
||||
[Species.GREAVARD]: [
|
||||
new SpeciesEvolution(Species.HOUNDSTONE, 30, null, new SpeciesEvolutionCondition((p: Pokemon) => !p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.HOUNDSTONE, 30, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.FRIGIBAX]: [
|
||||
new SpeciesEvolution(Species.ARCTIBAX, 35, null, null)
|
||||
|
@ -1280,8 +1281,8 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
],
|
||||
[Species.EEVEE]: [
|
||||
new SpeciesEvolution(Species.SYLVEON, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && !!p.getMoveset().find(m => m.getMove().type === Type.FAIRY)), SpeciesWildEvolutionDelay.MEDIUM),
|
||||
new SpeciesEvolution(Species.ESPEON, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.MEDIUM),
|
||||
new SpeciesEvolution(Species.UMBREON, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && !p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.MEDIUM),
|
||||
new SpeciesEvolution(Species.ESPEON, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && p.scene.arena.getTimeOfDay() === TimeOfDay.DAY), SpeciesWildEvolutionDelay.MEDIUM),
|
||||
new SpeciesEvolution(Species.UMBREON, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.MEDIUM),
|
||||
new SpeciesEvolution(Species.VAPOREON, 1, EvolutionItem.WATER_STONE, null, SpeciesWildEvolutionDelay.MEDIUM),
|
||||
new SpeciesEvolution(Species.JOLTEON, 1, EvolutionItem.THUNDER_STONE, null, SpeciesWildEvolutionDelay.MEDIUM),
|
||||
new SpeciesEvolution(Species.FLAREON, 1, EvolutionItem.FIRE_STONE, null, SpeciesWildEvolutionDelay.MEDIUM),
|
||||
|
@ -1319,13 +1320,13 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.DUDUNSPARCE, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.moveset.filter(m => m.moveId === Moves.HYPER_DRILL).length > 0), SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
],
|
||||
[Species.GLIGAR]: [
|
||||
new SpeciesEvolution(Species.GLISCOR, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => !p.scene.arena.isDaytime() /* Razor fang at night*/), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.GLISCOR, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT /* Razor fang at night*/), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.SNEASEL]: [
|
||||
new SpeciesEvolution(Species.WEAVILE, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => !p.scene.arena.isDaytime() /* Razor claw at night*/), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.WEAVILE, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT /* Razor claw at night*/), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.URSARING]: [
|
||||
new SpeciesEvolution(Species.URSALUNA, 1, EvolutionItem.MOON_STONE, new SpeciesEvolutionCondition((p: Pokemon) => !p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.VERY_LONG) //Ursaring does not evolve into Bloodmoon Ursaluna
|
||||
new SpeciesEvolution(Species.URSALUNA, 1, EvolutionItem.MOON_STONE, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.VERY_LONG) //Ursaring does not evolve into Bloodmoon Ursaluna
|
||||
],
|
||||
[Species.PILOSWINE]: [
|
||||
new SpeciesEvolution(Species.MAMOSWINE, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.moveset.filter(m => m.moveId === Moves.ANCIENT_POWER).length > 0), SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
|
@ -1406,9 +1407,9 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.CRABOMINABLE, 1, EvolutionItem.ICE_STONE, null)
|
||||
],
|
||||
[Species.ROCKRUFF]: [
|
||||
new SpeciesFormEvolution(Species.LYCANROC, '', 'midday', 25, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.isDaytime()), null),
|
||||
new SpeciesFormEvolution(Species.LYCANROC, '', 'midday', 25, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.DAY), null),
|
||||
new SpeciesFormEvolution(Species.LYCANROC, '', 'dusk', 25, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.getSpeciesFormIndex(p.species) === 2), null),
|
||||
new SpeciesFormEvolution(Species.LYCANROC, '', 'midnight', 25, null, new SpeciesEvolutionCondition((p: Pokemon) => !p.scene.arena.isDaytime()), null)
|
||||
new SpeciesFormEvolution(Species.LYCANROC, '', 'midnight', 25, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), null)
|
||||
],
|
||||
[Species.STEENEE]: [
|
||||
new SpeciesEvolution(Species.TSAREENA, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.moveset.filter(m => m.moveId === Moves.STOMP).length > 0), SpeciesWildEvolutionDelay.LONG)
|
||||
|
@ -1424,8 +1425,8 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
],
|
||||
[Species.APPLIN]: [
|
||||
new SpeciesEvolution(Species.DIPPLIN, 1, EvolutionItem.LEAF_STONE, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.biomeType === Biome.ISLAND), SpeciesWildEvolutionDelay.LONG),
|
||||
new SpeciesEvolution(Species.FLAPPLE, 1, EvolutionItem.LEAF_STONE, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.LONG),
|
||||
new SpeciesEvolution(Species.APPLETUN, 1, EvolutionItem.LEAF_STONE, new SpeciesEvolutionCondition((p: Pokemon) => !p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.FLAPPLE, 1, EvolutionItem.LEAF_STONE, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.DAY), SpeciesWildEvolutionDelay.LONG),
|
||||
new SpeciesEvolution(Species.APPLETUN, 1, EvolutionItem.LEAF_STONE, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.CLOBBOPUS]: [
|
||||
new SpeciesEvolution(Species.GRAPPLOCT, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.moveset.filter(m => m.moveId === Moves.TAUNT).length > 0), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
|
@ -1455,7 +1456,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.OVERQWIL, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.moveset.filter(m => m.moveId === Moves.BARB_BARRAGE).length > 0), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.HISUI_SNEASEL]: [
|
||||
new SpeciesEvolution(Species.SNEASLER, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.isDaytime() /* Razor claw at day*/), SpeciesWildEvolutionDelay.LONG)
|
||||
new SpeciesEvolution(Species.SNEASLER, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.scene.arena.getTimeOfDay() === TimeOfDay.DAY /* Razor claw at day*/), SpeciesWildEvolutionDelay.LONG)
|
||||
],
|
||||
[Species.CHARCADET]: [
|
||||
new SpeciesEvolution(Species.ARMAROUGE, 1, EvolutionItem.FIRE_STONE, null, SpeciesWildEvolutionDelay.LONG),
|
||||
|
@ -1582,10 +1583,10 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.MARILL, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160), SpeciesWildEvolutionDelay.SHORT)
|
||||
],
|
||||
[Species.BUDEW]: [
|
||||
new SpeciesEvolution(Species.ROSELIA, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.SHORT)
|
||||
new SpeciesEvolution(Species.ROSELIA, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && p.scene.arena.getTimeOfDay() === TimeOfDay.DAY), SpeciesWildEvolutionDelay.SHORT)
|
||||
],
|
||||
[Species.CHINGLING]: [
|
||||
new SpeciesEvolution(Species.CHIMECHO, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && !p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
new SpeciesEvolution(Species.CHIMECHO, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
],
|
||||
[Species.BUNEARY]: [
|
||||
new SpeciesEvolution(Species.LOPUNNY, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
|
@ -1594,7 +1595,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.CHANSEY, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160), SpeciesWildEvolutionDelay.SHORT)
|
||||
],
|
||||
[Species.RIOLU]: [
|
||||
new SpeciesEvolution(Species.LUCARIO, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
new SpeciesEvolution(Species.LUCARIO, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && p.scene.arena.getTimeOfDay() === TimeOfDay.DAY), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
],
|
||||
[Species.WOOBAT]: [
|
||||
new SpeciesEvolution(Species.SWOOBAT, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
|
@ -1612,7 +1613,7 @@ export const pokemonEvolutions: PokemonEvolutions = {
|
|||
new SpeciesEvolution(Species.ALCREMIE, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
],
|
||||
[Species.SNOM]: [
|
||||
new SpeciesEvolution(Species.FROSMOTH, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && !p.scene.arena.isDaytime()), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
new SpeciesEvolution(Species.FROSMOTH, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160 && p.scene.arena.getTimeOfDay() === TimeOfDay.NIGHT), SpeciesWildEvolutionDelay.MEDIUM)
|
||||
],
|
||||
[Species.GIMMIGHOUL]: [
|
||||
new SpeciesEvolution(Species.GHOLDENGO, 1, null, new SpeciesEvolutionCondition((p: Pokemon) => p.friendship >= 160), SpeciesWildEvolutionDelay.VERY_LONG)
|
||||
|
|
|
@ -197,21 +197,24 @@ interface WeatherPoolEntry {
|
|||
weight: integer;
|
||||
}
|
||||
|
||||
export function getRandomWeatherType(biome: Biome): WeatherType {
|
||||
export function getRandomWeatherType(arena: any /* Importing from arena causes a circular dependency */): WeatherType {
|
||||
let weatherPool: WeatherPoolEntry[] = [];
|
||||
switch (biome) {
|
||||
const hasSun = arena.getTimeOfDay() < 2;
|
||||
switch (arena.biomeType) {
|
||||
case Biome.GRASS:
|
||||
weatherPool = [
|
||||
{ weatherType: WeatherType.NONE, weight: 7 },
|
||||
{ weatherType: WeatherType.SUNNY, weight: 3 }
|
||||
{ weatherType: WeatherType.NONE, weight: 7 }
|
||||
];
|
||||
if (hasSun)
|
||||
weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 3 });
|
||||
break;
|
||||
case Biome.TALL_GRASS:
|
||||
weatherPool = [
|
||||
{ weatherType: WeatherType.SUNNY, weight: 8 },
|
||||
{ weatherType: WeatherType.RAIN, weight: 5 },
|
||||
{ weatherType: WeatherType.FOG, weight: 2 }
|
||||
];
|
||||
if (hasSun)
|
||||
weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 8 });
|
||||
break;
|
||||
case Biome.FOREST:
|
||||
weatherPool = [
|
||||
|
@ -235,9 +238,10 @@ export function getRandomWeatherType(biome: Biome): WeatherType {
|
|||
case Biome.BEACH:
|
||||
weatherPool = [
|
||||
{ weatherType: WeatherType.NONE, weight: 8 },
|
||||
{ weatherType: WeatherType.SUNNY, weight: 5 },
|
||||
{ weatherType: WeatherType.RAIN, weight: 3 }
|
||||
];
|
||||
if (hasSun)
|
||||
weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 5 });
|
||||
break;
|
||||
case Biome.LAKE:
|
||||
weatherPool = [
|
||||
|
@ -259,15 +263,17 @@ export function getRandomWeatherType(biome: Biome): WeatherType {
|
|||
case Biome.BADLANDS:
|
||||
weatherPool = [
|
||||
{ weatherType: WeatherType.NONE, weight: 8 },
|
||||
{ weatherType: WeatherType.SUNNY, weight: 5 },
|
||||
{ weatherType: WeatherType.SANDSTORM, weight: 2 }
|
||||
];
|
||||
if (hasSun)
|
||||
weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 5 });
|
||||
break;
|
||||
case Biome.DESERT:
|
||||
weatherPool = [
|
||||
{ weatherType: WeatherType.SANDSTORM, weight: 2 },
|
||||
{ weatherType: WeatherType.SUNNY, weight: 1 }
|
||||
{ weatherType: WeatherType.SANDSTORM, weight: 2 }
|
||||
];
|
||||
if (hasSun)
|
||||
weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 2 });
|
||||
break;
|
||||
case Biome.ICE_CAVE:
|
||||
weatherPool = [
|
||||
|
@ -276,11 +282,13 @@ export function getRandomWeatherType(biome: Biome): WeatherType {
|
|||
break;
|
||||
case Biome.MEADOW:
|
||||
weatherPool = [
|
||||
{ weatherType: WeatherType.SUNNY, weight: 1 }
|
||||
{ weatherType: WeatherType.NONE, weight: 2 }
|
||||
];
|
||||
if (hasSun)
|
||||
weatherPool.push({ weatherType: WeatherType.SUNNY, weight: 2 });
|
||||
case Biome.VOLCANO:
|
||||
weatherPool = [
|
||||
{ weatherType: WeatherType.SUNNY, weight: 1 }
|
||||
{ weatherType: hasSun ? WeatherType.SUNNY : WeatherType.NONE, weight: 1 }
|
||||
];
|
||||
break;
|
||||
case Biome.GRAVEYARD:
|
||||
|
|
|
@ -61,7 +61,7 @@ export class EvolutionPhase extends BattlePhase {
|
|||
this.evolutionBgOverlay.setAlpha(0);
|
||||
this.evolutionContainer.add(this.evolutionBgOverlay);
|
||||
|
||||
const getPokemonSprite = () => this.scene.add.sprite(this.evolutionBaseBg.displayWidth / 2, this.evolutionBaseBg.displayHeight / 2, `pkmn__sub`);
|
||||
const getPokemonSprite = () => this.scene.addFieldSprite(this.evolutionBaseBg.displayWidth / 2, this.evolutionBaseBg.displayHeight / 2, `pkmn__sub`);
|
||||
|
||||
this.evolutionContainer.add((this.pokemonSprite = getPokemonSprite()));
|
||||
this.evolutionContainer.add((this.pokemonTintSprite = getPokemonSprite()));
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
import BattleScene from "../battle-scene";
|
||||
import * as Utils from "../utils";
|
||||
|
||||
const spriteFragShader = `
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D uMainSampler[%count%];
|
||||
|
||||
varying vec2 outTexCoord;
|
||||
varying float outTexId;
|
||||
varying float outTintEffect;
|
||||
varying vec4 outTint;
|
||||
|
||||
uniform float time;
|
||||
uniform int isOutside;
|
||||
uniform vec3 dayTint;
|
||||
uniform vec3 duskTint;
|
||||
uniform vec3 nightTint;
|
||||
|
||||
float blendOverlay(float base, float blend) {
|
||||
return base<0.5?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend));
|
||||
}
|
||||
|
||||
vec3 blendOverlay(vec3 base, vec3 blend) {
|
||||
return vec3(blendOverlay(base.r,blend.r),blendOverlay(base.g,blend.g),blendOverlay(base.b,blend.b));
|
||||
}
|
||||
|
||||
vec3 blendHardLight(vec3 base, vec3 blend) {
|
||||
return blendOverlay(blend, base);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texture;
|
||||
|
||||
%forloop%
|
||||
|
||||
vec4 texel = vec4(outTint.bgr * outTint.a, outTint.a);
|
||||
|
||||
// Multiply texture tint
|
||||
vec4 color = texture * texel;
|
||||
|
||||
if (outTintEffect == 1.0) {
|
||||
// Solid color + texture alpha
|
||||
color.rgb = mix(texture.rgb, outTint.bgr * outTint.a, texture.a);
|
||||
} else if (outTintEffect == 2.0) {
|
||||
// Solid color, no texture
|
||||
color = texel;
|
||||
}
|
||||
|
||||
/* Apply day/night tint */
|
||||
if (color.a > 0.0) {
|
||||
vec3 dayNightTint;
|
||||
|
||||
if (time < 0.25) {
|
||||
dayNightTint = dayTint;
|
||||
} else if (isOutside == 0 && time < 0.5) {
|
||||
dayNightTint = mix(dayTint, nightTint, (time - 0.25) / 0.25);
|
||||
} else if (time < 0.375) {
|
||||
dayNightTint = mix(dayTint, duskTint, (time - 0.25) / 0.125);
|
||||
} else if (time < 0.5) {
|
||||
dayNightTint = mix(duskTint, nightTint, (time - 0.375) / 0.125);
|
||||
} else if (time < 0.75) {
|
||||
dayNightTint = nightTint;
|
||||
} else if (isOutside == 0) {
|
||||
dayNightTint = mix(nightTint, dayTint, (time - 0.75) / 0.25);
|
||||
} else if (time < 0.875) {
|
||||
dayNightTint = mix(nightTint, duskTint, (time - 0.75) / 0.125);
|
||||
} else {
|
||||
dayNightTint = mix(duskTint, dayTint, (time - 0.875) / 0.125);
|
||||
}
|
||||
|
||||
color = vec4(blendHardLight(color.rgb, dayNightTint), color.a);
|
||||
}
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
`;
|
||||
|
||||
const spriteVertShader = `
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform mat4 uProjectionMatrix;
|
||||
|
||||
attribute vec2 inPosition;
|
||||
attribute vec2 inTexCoord;
|
||||
attribute float inTexId;
|
||||
attribute float inTintEffect;
|
||||
attribute vec4 inTint;
|
||||
|
||||
varying vec2 outTexCoord;
|
||||
varying float outTexId;
|
||||
varying float outTintEffect;
|
||||
varying vec4 outTint;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);
|
||||
|
||||
outTexCoord = inTexCoord;
|
||||
outTexId = inTexId;
|
||||
outTint = inTint;
|
||||
outTintEffect = inTintEffect;
|
||||
}
|
||||
`;
|
||||
|
||||
export default class FieldSpritePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline {
|
||||
constructor(game: Phaser.Game, config?: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig) {
|
||||
super(config || {
|
||||
game: game,
|
||||
name: 'field-sprite',
|
||||
fragShader: spriteFragShader,
|
||||
vertShader: spriteVertShader
|
||||
});
|
||||
}
|
||||
|
||||
onPreRender(): void {
|
||||
this.set1f('time', 0);
|
||||
}
|
||||
|
||||
onBind(gameObject: Phaser.GameObjects.GameObject): void {
|
||||
super.onBind();
|
||||
|
||||
const sprite = (gameObject as Phaser.GameObjects.Sprite);
|
||||
const scene = sprite.scene as BattleScene;
|
||||
|
||||
let time = scene.currentBattle?.waveIndex
|
||||
? ((scene.currentBattle.waveIndex + scene.getWaveCycleOffset()) % 40) / 40 // ((new Date().getSeconds() * 1000 + new Date().getMilliseconds()) % 10000) / 10000
|
||||
: Utils.getCurrentTime();
|
||||
this.set1f('time', time);
|
||||
this.set1i('isOutside', scene.arena.isOutside() ? 1 : 0);
|
||||
this.set3fv('dayTint', scene.arena.getDayTint().map(c => c / 255));
|
||||
this.set3fv('duskTint', scene.arena.getDuskTint().map(c => c / 255));
|
||||
this.set3fv('nightTint', scene.arena.getNightTint().map(c => c / 255));
|
||||
}
|
||||
|
||||
onBatch(gameObject: Phaser.GameObjects.GameObject): void {
|
||||
if (gameObject)
|
||||
this.flush();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import Pokemon from "../pokemon";
|
||||
import Trainer from "../trainer";
|
||||
import FieldSpritePipeline from "./field-sprite";
|
||||
|
||||
const spriteFragShader = `
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
|
@ -16,6 +17,11 @@ varying vec2 outPosition;
|
|||
varying float outTintEffect;
|
||||
varying vec4 outTint;
|
||||
|
||||
uniform float time;
|
||||
uniform int isOutside;
|
||||
uniform vec3 dayTint;
|
||||
uniform vec3 duskTint;
|
||||
uniform vec3 nightTint;
|
||||
uniform int hasShadow;
|
||||
uniform int yCenter;
|
||||
uniform float vCutoff;
|
||||
|
@ -28,6 +34,18 @@ uniform ivec4 fusionSpriteColors[32];
|
|||
|
||||
const vec3 lumaF = vec3(.299, .587, .114);
|
||||
|
||||
float blendOverlay(float base, float blend) {
|
||||
return base<0.5?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend));
|
||||
}
|
||||
|
||||
vec3 blendOverlay(vec3 base, vec3 blend) {
|
||||
return vec3(blendOverlay(base.r,blend.r),blendOverlay(base.g,blend.g),blendOverlay(base.b,blend.b));
|
||||
}
|
||||
|
||||
vec3 blendHardLight(vec3 base, vec3 blend) {
|
||||
return blendOverlay(blend, base);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texture;
|
||||
|
@ -68,6 +86,31 @@ void main()
|
|||
/* Apply tone */
|
||||
color.rgb += tone.rgb * (color.a / 255.0);
|
||||
|
||||
/* Apply day/night tint */
|
||||
if (color.a > 0.0) {
|
||||
vec3 dayNightTint;
|
||||
|
||||
if (time < 0.25) {
|
||||
dayNightTint = dayTint;
|
||||
} else if (isOutside == 0 && time < 0.5) {
|
||||
dayNightTint = mix(dayTint, nightTint, (time - 0.25) / 0.25);
|
||||
} else if (time < 0.375) {
|
||||
dayNightTint = mix(dayTint, duskTint, (time - 0.25) / 0.125);
|
||||
} else if (time < 0.5) {
|
||||
dayNightTint = mix(duskTint, nightTint, (time - 0.375) / 0.125);
|
||||
} else if (time < 0.75) {
|
||||
dayNightTint = nightTint;
|
||||
} else if (isOutside == 0) {
|
||||
dayNightTint = mix(nightTint, dayTint, (time - 0.75) / 0.25);
|
||||
} else if (time < 0.875) {
|
||||
dayNightTint = mix(nightTint, duskTint, (time - 0.75) / 0.125);
|
||||
} else {
|
||||
dayNightTint = mix(duskTint, dayTint, (time - 0.875) / 0.125);
|
||||
}
|
||||
|
||||
color = vec4(blendHardLight(color.rgb, dayNightTint), color.a);
|
||||
}
|
||||
|
||||
if (hasShadow == 1) {
|
||||
float width = size.x - (yOffset / 2.0);
|
||||
|
||||
|
@ -131,11 +174,11 @@ void main()
|
|||
}
|
||||
`;
|
||||
|
||||
export default class SpritePipeline extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline {
|
||||
export default class SpritePipeline extends FieldSpritePipeline {
|
||||
private _tone: number[];
|
||||
|
||||
constructor(game: Phaser.Game) {
|
||||
super({
|
||||
super(game, {
|
||||
game: game,
|
||||
name: 'sprite',
|
||||
fragShader: spriteFragShader,
|
||||
|
@ -146,6 +189,8 @@ export default class SpritePipeline extends Phaser.Renderer.WebGL.Pipelines.Mult
|
|||
}
|
||||
|
||||
onPreRender(): void {
|
||||
super.onPreRender();
|
||||
|
||||
this.set1i('hasShadow', 0);
|
||||
this.set1i('yCenter', 0);
|
||||
this.set2f('relPosition', 0, 0);
|
||||
|
@ -155,7 +200,7 @@ export default class SpritePipeline extends Phaser.Renderer.WebGL.Pipelines.Mult
|
|||
}
|
||||
|
||||
onBind(gameObject: Phaser.GameObjects.GameObject): void {
|
||||
super.onBind();
|
||||
super.onBind(gameObject);
|
||||
|
||||
const sprite = (gameObject as Phaser.GameObjects.Sprite);
|
||||
|
||||
|
@ -188,11 +233,6 @@ export default class SpritePipeline extends Phaser.Renderer.WebGL.Pipelines.Mult
|
|||
this.set4iv(`fusionSpriteColors`, flatFusionSpriteColors.flat());
|
||||
}
|
||||
|
||||
onBatch(gameObject: Phaser.GameObjects.GameObject): void {
|
||||
if (gameObject)
|
||||
this.flush();
|
||||
}
|
||||
|
||||
batchQuad(gameObject: Phaser.GameObjects.GameObject, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number,
|
||||
u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean,
|
||||
texture?: WebGLTexture, unit?: number): boolean {
|
||||
|
|
|
@ -183,7 +183,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
this.battleInfo.initInfo(this);
|
||||
|
||||
const getSprite = (hasShadow?: boolean) => {
|
||||
const ret = this.scene.add.sprite(0, 0, `pkmn__${this.isPlayer() ? 'back__' : ''}sub`);
|
||||
const ret = this.scene.addFieldSprite(0, 0, `pkmn__${this.isPlayer() ? 'back__' : ''}sub`);
|
||||
ret.setOrigin(0.5, 1);
|
||||
ret.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: !!hasShadow });
|
||||
return ret;
|
||||
|
@ -375,7 +375,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
}
|
||||
|
||||
initShinySparkle(): void {
|
||||
const shinySparkle = this.scene.add.sprite(0, 0, 'shiny');
|
||||
const shinySparkle = this.scene.addFieldSprite(0, 0, 'shiny');
|
||||
shinySparkle.setVisible(false);
|
||||
shinySparkle.setOrigin(0.5, 1);
|
||||
const frameNames = this.scene.anims.generateFrameNames('shiny', { suffix: '.png', end: 34 });
|
||||
|
@ -721,10 +721,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
|
||||
let shinyThreshold = new Utils.IntegerHolder(32);
|
||||
if (thresholdOverride === undefined) {
|
||||
if (!this.hasTrainer()) {
|
||||
if (!this.hasTrainer())
|
||||
this.scene.applyModifiers(ShinyRateBoosterModifier, true, shinyThreshold);
|
||||
console.log(shinyThreshold.value, 'SHINY THRESHOLD');
|
||||
}
|
||||
} else
|
||||
shinyThreshold.value = thresholdOverride;
|
||||
|
||||
|
|
|
@ -427,7 +427,6 @@ export class GameData {
|
|||
public exportData(dataType: GameDataType): void {
|
||||
const dataKey: string = getDataTypeKey(dataType);
|
||||
const dataStr = atob(localStorage.getItem(dataKey));
|
||||
console.log(dataStr);
|
||||
const encryptedData = AES.encrypt(dataStr, saveKey);
|
||||
const blob = new Blob([ encryptedData.toString() ], {type: 'text/json'});
|
||||
const link = document.createElement('a');
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class Trainer extends Phaser.GameObjects.Container {
|
|||
console.log(Object.keys(trainerPartyTemplates)[Object.values(trainerPartyTemplates).indexOf(this.getPartyTemplate())]);
|
||||
|
||||
const getSprite = (hasShadow?: boolean) => {
|
||||
const ret = this.scene.add.sprite(0, 0, this.getKey());
|
||||
const ret = this.scene.addFieldSprite(0, 0, this.getKey());
|
||||
ret.setOrigin(0.5, 1);
|
||||
ret.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: !!hasShadow });
|
||||
return ret;
|
||||
|
|
|
@ -87,6 +87,11 @@ export function getFrameMs(frameCount: integer): integer {
|
|||
return Math.floor((1 / 60) * 1000 * frameCount);
|
||||
}
|
||||
|
||||
export function getCurrentTime(): number {
|
||||
const date = new Date();
|
||||
return (((date.getHours() * 60 + date.getMinutes()) / 1440) + 0.675) % 1;
|
||||
}
|
||||
|
||||
export function binToDec(input: string): integer {
|
||||
let place: integer[] = [];
|
||||
let binary: string[] = [];
|
||||
|
|
Loading…
Reference in New Issue