Add late campaign character portraits
This commit is contained in:
@@ -7,7 +7,21 @@ import { palette } from '../ui/palette';
|
||||
const portraitKeys: Record<PortraitKey, string> = {
|
||||
liuBei: 'portrait-liu-bei',
|
||||
guanYu: 'portrait-guan-yu',
|
||||
zhangFei: 'portrait-zhang-fei'
|
||||
zhangFei: 'portrait-zhang-fei',
|
||||
zhugeLiang: 'portrait-zhuge-liang',
|
||||
zhaoYun: 'portrait-zhao-yun',
|
||||
jiangWei: 'portrait-jiang-wei',
|
||||
simaYi: 'portrait-sima-yi'
|
||||
};
|
||||
|
||||
const portraitBySpeaker: Record<string, PortraitKey> = {
|
||||
유비: 'liuBei',
|
||||
관우: 'guanYu',
|
||||
장비: 'zhangFei',
|
||||
제갈량: 'zhugeLiang',
|
||||
조운: 'zhaoYun',
|
||||
강유: 'jiangWei',
|
||||
사마의: 'simaYi'
|
||||
};
|
||||
|
||||
type AlphaObject = Phaser.GameObjects.Image | Phaser.GameObjects.Rectangle | Phaser.GameObjects.Text;
|
||||
@@ -57,7 +71,9 @@ export class StoryScene extends Phaser.Scene {
|
||||
currentPageId: page?.id,
|
||||
background: page?.background,
|
||||
backgroundReady: page ? this.textures.exists(page.background) : false,
|
||||
activeTexture: this.background?.texture.key ?? null
|
||||
activeTexture: this.background?.texture.key ?? null,
|
||||
portraitKey: page ? this.pagePortraitKey(page) ?? null : null,
|
||||
portraitTextureKey: this.portrait?.visible ? this.portrait.texture.key : null
|
||||
};
|
||||
}
|
||||
|
||||
@@ -239,11 +255,13 @@ export class StoryScene extends Phaser.Scene {
|
||||
this.applyBackground(page.background);
|
||||
this.chapterText?.setText(page.chapter);
|
||||
|
||||
if (page.portrait) {
|
||||
const portraitKey = this.pagePortraitKey(page);
|
||||
|
||||
if (portraitKey) {
|
||||
this.portraitFrame?.setVisible(true);
|
||||
this.portrait?.setVisible(true);
|
||||
this.portraitDivider?.setVisible(true);
|
||||
this.portrait?.setTexture(portraitKeys[page.portrait]);
|
||||
this.portrait?.setTexture(portraitKeys[portraitKey]);
|
||||
this.portrait?.setDisplaySize(128, 128);
|
||||
this.nameText?.setPosition(270, this.scale.height - 210);
|
||||
this.bodyText?.setPosition(270, this.scale.height - 160);
|
||||
@@ -262,6 +280,10 @@ export class StoryScene extends Phaser.Scene {
|
||||
this.progressText?.setText(`${this.pageIndex + 1} / ${this.pages.length} SPACE / ENTER`);
|
||||
}
|
||||
|
||||
private pagePortraitKey(page: StoryPage) {
|
||||
return page.portrait ?? (page.speaker ? portraitBySpeaker[page.speaker] : undefined);
|
||||
}
|
||||
|
||||
private applyBackground(textureKey: string) {
|
||||
if (!this.background) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user