Add proper title screen and logo
This commit is contained in:
parent
7189258095
commit
cf959c6e1b
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -54,7 +54,6 @@ import CharSprite from './ui/char-sprite';
|
|||
import DamageNumberHandler from './field/damage-number-handler';
|
||||
import PokemonInfoContainer from './ui/pokemon-info-container';
|
||||
import { biomeDepths } from './data/biomes';
|
||||
import { DailyRunScoreboard } from './ui/daily-run-scoreboard';
|
||||
|
||||
export const bypassLogin = false;
|
||||
|
||||
|
@ -124,8 +123,8 @@ export default class BattleScene extends Phaser.Scene {
|
|||
public pbTrayEnemy: PokeballTray;
|
||||
public abilityBar: AbilityBar;
|
||||
public partyExpBar: PartyExpBar;
|
||||
public arenaBg: Phaser.GameObjects.Sprite;
|
||||
public arenaBgTransition: Phaser.GameObjects.Sprite;
|
||||
public arenaBg: Phaser.GameObjects.NineSlice;
|
||||
public arenaBgTransition: Phaser.GameObjects.NineSlice;
|
||||
public arenaPlayer: ArenaBase;
|
||||
public arenaPlayerTransition: ArenaBase;
|
||||
public arenaEnemy: ArenaBase;
|
||||
|
@ -139,7 +138,6 @@ export default class BattleScene extends Phaser.Scene {
|
|||
public pokeballCounts: PokeballCounts;
|
||||
public money: integer;
|
||||
public pokemonInfoContainer: PokemonInfoContainer;
|
||||
public dailyRunScoreboard: DailyRunScoreboard;
|
||||
private party: PlayerPokemon[];
|
||||
private waveCountText: Phaser.GameObjects.Text;
|
||||
private moneyText: Phaser.GameObjects.Text;
|
||||
|
@ -316,6 +314,8 @@ export default class BattleScene extends Phaser.Scene {
|
|||
|
||||
this.loadImage('default_bg', 'arenas');
|
||||
|
||||
this.loadImage('logo', '');
|
||||
|
||||
// Load arena images
|
||||
Utils.getEnumValues(Biome).map(bt => {
|
||||
const btKey = Biome[bt].toLowerCase();
|
||||
|
@ -480,12 +480,14 @@ export default class BattleScene extends Phaser.Scene {
|
|||
}
|
||||
|
||||
launchBattle() {
|
||||
this.arenaBg = this.addFieldSprite(0, 0, 'plains_bg', null, 0);
|
||||
this.arenaBgTransition = this.addFieldSprite(0, 0, `plains_bg`, null, 1);
|
||||
this.arenaBg = this.add.nineslice(0, 0, 'plains_bg', null, 320, 180, 0, 0, 132, 0);
|
||||
this.arenaBgTransition = this.add.nineslice(0, 0, 'plains_bg', null, 320, 180, 0, 0, 132, 0);
|
||||
|
||||
[ this.arenaBgTransition, this.arenaBg ].forEach(a => {
|
||||
a.setPipeline(this.fieldSpritePipeline);
|
||||
a.setScale(6);
|
||||
a.setOrigin(0);
|
||||
a.setSize(320, 240);
|
||||
});
|
||||
|
||||
const field = this.add.container(0, 0);
|
||||
|
@ -569,11 +571,6 @@ export default class BattleScene extends Phaser.Scene {
|
|||
|
||||
this.fieldUI.add(this.pokemonInfoContainer);
|
||||
|
||||
this.dailyRunScoreboard = new DailyRunScoreboard(this, 1, -(this.game.canvas.height / 6) + 1);
|
||||
this.dailyRunScoreboard.setup();
|
||||
|
||||
this.fieldUI.add(this.dailyRunScoreboard);
|
||||
|
||||
this.party = [];
|
||||
|
||||
let loadPokemonAssets = [];
|
||||
|
|
|
@ -43,7 +43,7 @@ import { EggHatchPhase } from "./egg-hatch-phase";
|
|||
import { Egg } from "./data/egg";
|
||||
import { vouchers } from "./system/voucher";
|
||||
import { loggedInUser, updateUserInfo } from "./account";
|
||||
import { GameDataType, PlayerGender } from "./system/game-data";
|
||||
import { GameDataType, PlayerGender, SessionSaveData } from "./system/game-data";
|
||||
import { addPokeballCaptureStars, addPokeballOpenParticles } from "./field/anims";
|
||||
import { SpeciesFormChangeActiveTrigger, SpeciesFormChangeManualTrigger, SpeciesFormChangeMoveLearnedTrigger, SpeciesFormChangeMoveUsedTrigger } from "./data/pokemon-forms";
|
||||
import { battleSpecDialogue, getCharVariantFromDialogue } from "./data/dialogue";
|
||||
|
@ -127,6 +127,7 @@ export class LoginPhase extends Phase {
|
|||
|
||||
export class TitlePhase extends Phase {
|
||||
private loaded: boolean;
|
||||
private lastSessionData: SessionSaveData;
|
||||
|
||||
constructor(scene: BattleScene) {
|
||||
super(scene);
|
||||
|
@ -142,7 +143,13 @@ export class TitlePhase extends Phase {
|
|||
|
||||
this.scene.fadeOutBgm(0, false);
|
||||
|
||||
this.scene.gameData.getSession(loggedInUser.lastSessionSlot).then(sessionData => {
|
||||
this.lastSessionData = sessionData;
|
||||
const biomeKey = getBiomeKey(sessionData.arena.biome);
|
||||
const bgTexture = `${biomeKey}_bg`;
|
||||
this.scene.arenaBg.setTexture(bgTexture);
|
||||
this.showOptions();
|
||||
});
|
||||
}
|
||||
|
||||
showOptions(): void {
|
||||
|
@ -150,7 +157,7 @@ export class TitlePhase extends Phase {
|
|||
if (loggedInUser?.lastSessionSlot > -1) {
|
||||
options.push({
|
||||
label: 'Continue',
|
||||
handler: () => this.loadSaveSlot(loggedInUser.lastSessionSlot)
|
||||
handler: () => this.loadSaveSlot(-1)
|
||||
});
|
||||
}
|
||||
options.push({
|
||||
|
@ -178,18 +185,16 @@ export class TitlePhase extends Phase {
|
|||
});
|
||||
const config: OptionSelectConfig = {
|
||||
options: options,
|
||||
noCancel: true
|
||||
noCancel: true,
|
||||
yOffset: 47
|
||||
};
|
||||
this.scene.ui.setMode(Mode.OPTION_SELECT, config);
|
||||
|
||||
this.scene.dailyRunScoreboard.showAndUpdate();
|
||||
this.scene.ui.setMode(Mode.TITLE, config);
|
||||
}
|
||||
|
||||
loadSaveSlot(slotId: integer): void {
|
||||
this.scene.sessionSlotId = slotId;
|
||||
this.scene.sessionSlotId = slotId > -1 ? slotId : loggedInUser.lastSessionSlot;
|
||||
this.scene.ui.setMode(Mode.MESSAGE);
|
||||
this.scene.dailyRunScoreboard.hide();
|
||||
this.scene.gameData.loadSession(this.scene, slotId).then((success: boolean) => {
|
||||
this.scene.gameData.loadSession(this.scene, slotId, slotId === -1 ? this.lastSessionData : null).then((success: boolean) => {
|
||||
if (success) {
|
||||
this.loaded = true;
|
||||
this.scene.ui.showText('Session loaded successfully.', null, () => this.end());
|
||||
|
@ -256,8 +261,6 @@ export class TitlePhase extends Phase {
|
|||
}
|
||||
|
||||
end(): void {
|
||||
this.scene.dailyRunScoreboard.hide();
|
||||
|
||||
if (!this.loaded && !this.scene.gameMode.isDaily) {
|
||||
this.scene.arena.preloadBgm();
|
||||
this.scene.pushPhase(new SelectStarterPhase(this.scene));
|
||||
|
|
|
@ -109,7 +109,7 @@ vec3 hsl2rgb(vec3 hsl) {
|
|||
|
||||
rgb.r = hue2rgb(f1, f2, hsl.x + (1.0/3.0));
|
||||
rgb.g = hue2rgb(f1, f2, hsl.x);
|
||||
rgb.b= hue2rgb(f1, f2, hsl.x - (1.0/3.0));
|
||||
rgb.b = hue2rgb(f1, f2, hsl.x - (1.0/3.0));
|
||||
}
|
||||
|
||||
return rgb;
|
||||
|
|
|
@ -537,10 +537,10 @@ export class GameData {
|
|||
});
|
||||
}
|
||||
|
||||
loadSession(scene: BattleScene, slotId: integer): Promise<boolean> {
|
||||
loadSession(scene: BattleScene, slotId: integer, sessionData?: SessionSaveData): Promise<boolean> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
this.getSession(slotId).then(async sessionData => {
|
||||
const initSessionFromData = async sessionData => {
|
||||
console.debug(sessionData);
|
||||
|
||||
scene.setSeed(sessionData.seed || scene.game.config.seed[0]);
|
||||
|
@ -614,10 +614,17 @@ export class GameData {
|
|||
scene.updateModifiers(false);
|
||||
|
||||
Promise.all(loadPokemonAssets).then(() => resolve(true));
|
||||
}).catch(err => {
|
||||
};
|
||||
if (sessionData)
|
||||
initSessionFromData(sessionData);
|
||||
else {
|
||||
this.getSession(slotId)
|
||||
.then(data => initSessionFromData(data))
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
return;
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
return;
|
||||
|
|
|
@ -40,8 +40,6 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container {
|
|||
this.loadingLabel.setVisible(false);
|
||||
|
||||
this.add(this.loadingLabel);
|
||||
|
||||
this.setVisible(false);
|
||||
}
|
||||
|
||||
updateRankings(rankings: RankingEntry[]) {
|
||||
|
@ -72,7 +70,7 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container {
|
|||
});
|
||||
}
|
||||
|
||||
showAndUpdate() {
|
||||
update() {
|
||||
this.rankingsContainer.removeAll(true);
|
||||
|
||||
this.loadingLabel.setText('Loading…');
|
||||
|
@ -87,12 +85,6 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container {
|
|||
} else
|
||||
this.loadingLabel.setText('No Rankings');
|
||||
});
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ class SessionSlot extends Phaser.GameObjects.Container {
|
|||
this.hasData = true;
|
||||
await this.setupWithData(sessionData);
|
||||
resolve(true);
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
import BattleScene from "../battle-scene";
|
||||
import { DailyRunScoreboard } from "./daily-run-scoreboard";
|
||||
import OptionSelectUiHandler from "./option-select-ui-handler";
|
||||
import { Mode } from "./ui";
|
||||
import * as Utils from "../utils";
|
||||
|
||||
export default class TitleUiHandler extends OptionSelectUiHandler {
|
||||
private titleContainer: Phaser.GameObjects.Container;
|
||||
private dailyRunScoreboard: DailyRunScoreboard;
|
||||
|
||||
constructor(scene: BattleScene, mode: Mode = Mode.TITLE) {
|
||||
super(scene, mode);
|
||||
}
|
||||
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
const ui = this.getUi();
|
||||
|
||||
this.titleContainer = this.scene.add.container(0, -(this.scene.game.canvas.height / 6));
|
||||
this.titleContainer.setAlpha(0);
|
||||
ui.add(this.titleContainer);
|
||||
|
||||
const logo = this.scene.add.image((this.scene.game.canvas.width / 6) / 2, 8, 'logo');
|
||||
logo.setOrigin(0.5, 0);
|
||||
this.titleContainer.add(logo);
|
||||
|
||||
this.dailyRunScoreboard = new DailyRunScoreboard(this.scene, 1, 49);
|
||||
this.dailyRunScoreboard.setup();
|
||||
|
||||
this.titleContainer.add(this.dailyRunScoreboard);
|
||||
}
|
||||
|
||||
show(args: any[]): boolean {
|
||||
const ret = super.show(args);
|
||||
|
||||
if (ret) {
|
||||
const ui = this.getUi();
|
||||
|
||||
this.dailyRunScoreboard.update();
|
||||
|
||||
this.scene.tweens.add({
|
||||
targets: [ this.titleContainer, ui.getMessageHandler().bg ],
|
||||
duration: Utils.fixedInt(325),
|
||||
alpha: (target: any) => target === this.titleContainer ? 1 : 0,
|
||||
ease: 'Sine.easeInOut'
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
super.clear();
|
||||
|
||||
const ui = this.getUi();
|
||||
|
||||
this.scene.tweens.add({
|
||||
targets: [ this.titleContainer, ui.getMessageHandler().bg ],
|
||||
duration: Utils.fixedInt(325),
|
||||
alpha: (target: any) => target === this.titleContainer ? 0 : 1,
|
||||
ease: 'Sine.easeInOut'
|
||||
});
|
||||
}
|
||||
}
|
|
@ -31,9 +31,11 @@ import * as Utils from "../utils";
|
|||
import GameStatsUiHandler from './game-stats-ui-handler';
|
||||
import AwaitableUiHandler from './awaitable-ui-handler';
|
||||
import SaveSlotSelectUiHandler from './save-slot-select-ui-handler';
|
||||
import TitleUiHandler from './title-ui-handler';
|
||||
|
||||
export enum Mode {
|
||||
MESSAGE,
|
||||
TITLE,
|
||||
COMMAND,
|
||||
FIGHT,
|
||||
BALL,
|
||||
|
@ -73,6 +75,7 @@ const transitionModes = [
|
|||
];
|
||||
|
||||
const noTransitionModes = [
|
||||
Mode.TITLE,
|
||||
Mode.CONFIRM,
|
||||
Mode.OPTION_SELECT,
|
||||
Mode.MENU,
|
||||
|
@ -107,6 +110,7 @@ export default class UI extends Phaser.GameObjects.Container {
|
|||
this.modeChain = [];
|
||||
this.handlers = [
|
||||
new BattleMessageUiHandler(scene),
|
||||
new TitleUiHandler(scene),
|
||||
new CommandUiHandler(scene),
|
||||
new FightUiHandler(scene),
|
||||
new BallUiHandler(scene),
|
||||
|
|
Loading…
Reference in New Issue