mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-30 09:31:29 +08:00
feat(SS) 故事场景控制场景备份
This commit is contained in:
1 parent
062d950583
commit
5644f9c1eb
13 files changed
+108
-1072
No files matched your search
@@ -52,10 +52,8 @@ export default class BreatheLife extends WorldLand {
|
||||
}
|
||||
initSceneTransition() {
|
||||
// 初始化角色计数器,用于跟踪创建的角色数量
|
||||
this.spriteCount = 0
|
||||
this.spriteTextureCount = 0
|
||||
this.spriteAnimCount = 0
|
||||
this.targetCount = 3 // 目标角色数量
|
||||
this.NPCObjects = [] // 维护角色集合
|
||||
this.smallGrassObjects = [] // 维护小草集合
|
||||
}
|
||||
initInput() {
|
||||
@@ -91,22 +89,31 @@ export default class BreatheLife extends WorldLand {
|
||||
const clickedSprite = this.getClickedSprite(x, y)
|
||||
console.log("点击到的精灵:", clickedSprite)
|
||||
// 如果满足条件则切换到下一场景
|
||||
if (clickedSprite) { // 如果点击到了精灵
|
||||
if (clickedSprite && this.NPCObjects.includes(clickedSprite)) { // 如果点击到了角色
|
||||
this.handleSpriteClick(clickedSprite)
|
||||
}else if (this.spriteCount >= this.targetCount && this.spriteTextureCount >= this.targetCount && this.spriteAnimCount >= this.targetCount) {
|
||||
this.scene.start(this.nextScene)
|
||||
}else if (this.spriteCount < 3) {
|
||||
}else if (this.NPCObjects.length >= this.targetCount) {
|
||||
// 如果角色列表中角色数量超过目标数量,且动态效果的数量也超过目标数量
|
||||
let moveCount = 0
|
||||
for (const sprite of this.NPCObjects) {
|
||||
// 如果角色当前的纹理在player-move的动画帧中,计数加一
|
||||
const moveAnimationFrames = ['player1-1', 'player1-2']
|
||||
if (moveAnimationFrames.includes(sprite.texture.key)) {
|
||||
moveCount++
|
||||
}
|
||||
}
|
||||
if (moveCount >= this.targetCount) {
|
||||
this.scene.start(this.nextScene)
|
||||
}
|
||||
}else if (this.NPCObjects.length < this.targetCount) {
|
||||
// 如果角色数量不足目标数量
|
||||
// 创建一个新的角色 sprite,缩放为1倍,并设置原点为中心底部
|
||||
const sprite = this.physics.add.sprite(x, y, 'player').setScale(1).setOrigin(0.5, 1)
|
||||
sprite.setDepth(this.SpriteDepth) // 设置角色层级
|
||||
|
||||
this.NPCObjects.push(sprite) // 加入角色集合
|
||||
|
||||
// 设置角色碰撞世界边界
|
||||
sprite.setCollideWorldBounds(true)
|
||||
|
||||
// 增加角色计数器
|
||||
this.spriteCount++
|
||||
console.log("已设置纹理的角色数量:", this.spriteTextureCount)
|
||||
console.log("已创建的角色数量:", this.spriteCount)
|
||||
// // 设置角色碰撞世界边界
|
||||
// sprite.setCollideWorldBounds(true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,8 +242,8 @@ export default class BreatheLife extends WorldLand {
|
||||
targets: clickedSprite, // 角色精灵
|
||||
x: nearestGrass.x, // 目标小草位置x
|
||||
y: nearestGrass.y, // 目标小草位置y
|
||||
duration: 1000, // 移动时间1秒
|
||||
ease: 'Power2', // 移动缓动效果
|
||||
duration: minDistance * 10, // 移动时间根据距离计算
|
||||
ease: 'Linear', // 匀速移动
|
||||
onComplete: () => {
|
||||
// 从数组中移除已收集的小草
|
||||
this.smallGrassObjects = this.smallGrassObjects.filter(
|
||||
@@ -244,7 +251,11 @@ export default class BreatheLife extends WorldLand {
|
||||
)
|
||||
nearestGrass.destroy() // 移动完成后销毁小草
|
||||
this.sound.play('coin-a') // 播放收集小草音效
|
||||
this.searchAndAddSmallGrass(clickedSprite) // 递归调用,继续搜索下一个小草
|
||||
// 等待随机时间后,继续搜索下一个小草
|
||||
const delay = Phaser.Math.Between(500, 1000)
|
||||
this.time.delayedCall(delay, () => {
|
||||
this.searchAndAddSmallGrass(clickedSprite) // 递归调用,继续搜索下一个小草
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user