Add late campaign character portraits

This commit is contained in:
2026-06-24 19:49:19 +09:00
parent 40078eabe3
commit cc70d1b665
10 changed files with 64 additions and 12 deletions

View File

@@ -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;