Skip to content

Commit

Permalink
style: 樂不思蜀放在player身上顯示優化
Browse files Browse the repository at this point in the history
  • Loading branch information
Parsons committed Jan 25, 2025
1 parent d004f3d commit cf3589f
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/classes/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class Player {
cardIds: string[]
}
equipments: ThreeKingdomsCardIds[]
delayScrolls: string[]
delayScrolls: ThreeKingdomsCardIds[]
instance!: Phaser.GameObjects.Container
scene!: BattleScene
handleClickPlayer!: (player: Player) => void
Expand Down Expand Up @@ -56,7 +56,7 @@ export default class Player {
cardIds: string[]
}
equipments: ThreeKingdomsCardIds[]
delayScrolls: string[]
delayScrolls: ThreeKingdomsCardIds[]
handleClickPlayer: any
x: number
y: number
Expand Down Expand Up @@ -99,6 +99,9 @@ export default class Player {
})
const hpContainer = this.initHpInstance(this.hp, this.general.hp)
this.instanceMap.hp = hpContainer

const delayScrollsContainer = this.initDelayScrollsInstance()
this.instanceMap.delayScrolls = delayScrollsContainer
// const hpText = scene.add.text(0, -10, `血量: ${this.hp}`, {
// fontSize: '10px',
// color: '#000',
Expand Down Expand Up @@ -255,6 +258,14 @@ export default class Player {
}
this.equipments = data.equipments
}
// 延遲錦囊卡確認
if (data.delayScrolls.join() !== this.delayScrolls.join()) {
this.delayScrolls = data.delayScrolls
this.instanceMap.delayScrolls.destroy()
const delayScrollsContainer = this.initDelayScrollsInstance()
this.instanceMap.delayScrolls = delayScrollsContainer
this.instance.add(delayScrollsContainer)
}
}
setOutOfDistance(isOutofDistance: boolean) {
this.isOutofDistance = isOutofDistance
Expand Down Expand Up @@ -385,4 +396,23 @@ export default class Player {
healthContainer.setX(0 - 100 + 4)
return healthContainer
}
initDelayScrollsInstance() {
const delayScrollsContainer = this.scene.add.container(0, 0)
const delayScrolls = this.delayScrolls
for (let i = 0; i < delayScrolls.length; i++) {
const delayScroll = threeKingdomsCards[delayScrolls[i]]
const delayScrollText = this.scene.add.text(
-100 + 12, // 左邊界+位移
-100 + 12 + 22 * i, // 上邊界+位移
`${delayScroll.name[0]}`,
{
fontSize: '20px',
color: '#000',
},
)
delayScrollText.setOrigin(0.5)
delayScrollsContainer.add(delayScrollText)
}
return delayScrollsContainer
}
}

0 comments on commit cf3589f

Please sign in to comment.