Commit 7bd9d4b7 authored by Tt's avatar Tt

feat(play): 添加倒计时视图根据游戏类型调整位置的功能

parent f521198c
...@@ -229,10 +229,17 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -229,10 +229,17 @@ export class PlayComponent implements OnInit, OnDestroy {
* 初始化321倒计时视图 * 初始化321倒计时视图
* 创建并初始化倒计时数字元素 * 创建并初始化倒计时数字元素
*/ */
init321View() { /**
* 初始化321倒计时视图
* @param type 游戏类型,'left'表示左侧猫开始玩,'right'表示右侧猫开始玩
*/
init321View(type: string = 'left') {
// 创建倒计时数字元素 // 创建倒计时数字元素
const countdownElements = ['dao_ji_shi_3', 'dao_ji_shi_2', 'dao_ji_shi_1']; const countdownElements = ['dao_ji_shi_3', 'dao_ji_shi_2', 'dao_ji_shi_1'];
// 根据type计算x坐标的偏移量
const xOffset = type === 'left' ? 140 : -140;
countdownElements.forEach(elementName => { countdownElements.forEach(elementName => {
// 检查元素是否已存在 // 检查元素是否已存在
if (!this.g_cartoon.cartoonElementsBuffer[elementName]) { if (!this.g_cartoon.cartoonElementsBuffer[elementName]) {
...@@ -243,13 +250,18 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -243,13 +250,18 @@ export class PlayComponent implements OnInit, OnDestroy {
// 设置元素缩放 // 设置元素缩放
element.ref.scaleX = this.g_mapScale; element.ref.scaleX = this.g_mapScale;
element.ref.scaleY = this.g_mapScale; element.ref.scaleY = this.g_mapScale;
// 设置元素位置(画面中心) // 设置元素位置(根据type调整画面中心的x坐标)
element.ref.x = this.g_canvasWidth / 2; element.ref.x = this.g_canvasWidth / 2 + xOffset;
element.ref.y = this.g_canvasHeight / 2; element.ref.y = this.g_canvasHeight / 2 + 60 * this.g_mapScale;
// 默认隐藏 // 默认隐藏
element.ref.visible = false; element.ref.visible = false;
// 添加到渲染队列 // 添加到渲染队列
this.render(element.ref, zIndexMap.card + 3); this.render(element.ref, zIndexMap.card + 3);
} else {
// 如果元素已存在,更新其位置
const element = this.g_cartoon.cartoonElementsBuffer[elementName];
element.ref.x = this.g_canvasWidth / 2 + xOffset;
} }
}); });
} }
...@@ -257,8 +269,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -257,8 +269,9 @@ export class PlayComponent implements OnInit, OnDestroy {
/** /**
* 显示321倒计时动画 * 显示321倒计时动画
* 依次显示3、2、1的倒计时动画效果 * 依次显示3、2、1的倒计时动画效果
* @param type 游戏类型,'left'表示左侧猫开始玩,'right'表示右侧猫开始玩
*/ */
show321() { show321(type: string = 'left') {
// 动画配置参数 // 动画配置参数
const config = { const config = {
// 动画时间配置 // 动画时间配置
...@@ -275,8 +288,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -275,8 +288,8 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
}; };
// 初始化321倒计时视图 // 初始化321倒计时视图,传递type参数
this.init321View(); this.init321View(type);
// 隐藏所有倒计时元素(确保初始状态是隐藏的) // 隐藏所有倒计时元素(确保初始状态是隐藏的)
this.hide321Elements(); this.hide321Elements();
...@@ -290,7 +303,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -290,7 +303,9 @@ export class PlayComponent implements OnInit, OnDestroy {
this.showCountdownNumber('dao_ji_shi_1', config, () => { this.showCountdownNumber('dao_ji_shi_1', config, () => {
// 倒计时结束后的操作,等待一段时间后显示VS动画 // 倒计时结束后的操作,等待一段时间后显示VS动画
setTimeout(() => { setTimeout(() => {
this.showVsAni('left'); // this.showVsAni(type);
this.hideVsElements();
this.hide321Elements();
}, config.time.afterComplete * 1000); }, config.time.afterComplete * 1000);
}); });
}); });
...@@ -425,11 +440,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -425,11 +440,11 @@ export class PlayComponent implements OnInit, OnDestroy {
// this.initListPage(); // this.initListPage();
// 显示321倒计时动画 // 显示321倒计时动画,传递'left'参数表示左侧猫开始玩
this.show321(); // this.show321('left');
// 显示VS动画 // 注释掉直接显示VS动画的代码,因为现在由show321函数在倒计时结束后调用
// this.showVsAni('left'); this.showVsAni('left');
// this.initFishGame(); // this.initFishGame();
...@@ -1167,7 +1182,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1167,7 +1182,8 @@ export class PlayComponent implements OnInit, OnDestroy {
tweenChange(ju_mao_tou, { tweenChange(ju_mao_tou, {
scaleX: this.g_mapScale * config.cat.ju.shrinkRatio, scaleX: this.g_mapScale * config.cat.ju.shrinkRatio,
scaleY: this.g_mapScale * config.cat.ju.shrinkRatio, scaleY: this.g_mapScale * config.cat.ju.shrinkRatio,
x: ju_mao_tou.x - config.cat.ju.moveDistance * this.g_mapScale x: ju_mao_tou.x - config.cat.ju.moveDistance * this.g_mapScale,
y: ju_mao_tou.y + 95 * this.g_mapScale
}, config.cat.ju.animTime); }, config.cat.ju.animTime);
// 红色底板向左移动 // 红色底板向左移动
...@@ -1175,36 +1191,15 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1175,36 +1191,15 @@ export class PlayComponent implements OnInit, OnDestroy {
moveItem( moveItem(
hong_se_jian_bian_ref, hong_se_jian_bian_ref,
hong_se_jian_bian_ref.x - config.panel.hong.moveDistance * this.g_mapScale, hong_se_jian_bian_ref.x - config.panel.hong.moveDistance * this.g_mapScale,
hong_se_jian_bian_ref.y, hong_se_jian_bian_ref.y + 95 * this.g_mapScale,
config.panel.hong.moveTime config.panel.hong.moveTime
); );
} }
setTimeout(() => {
this.show321();
}, 1000);
}, config.vs.v.moveTime * 1000 + 500); }, config.vs.v.moveTime * 1000 + 500);
}, config.common.vsAnimDelay); }, config.common.vsAnimDelay);
// 隐藏所有VS相关元素
setTimeout(() => {
// 隐藏红色渐变面板
const hong_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['hong_se_jian_bian'];
if (hong_se_jian_bian && hong_se_jian_bian.ref) {
hong_se_jian_bian.ref.visible = false;
}
// 隐藏蓝色渐变面板
const lan_se_jian_bian = this.g_cartoon.cartoonElementsBuffer['lan_se_jian_bian'];
if (lan_se_jian_bian && lan_se_jian_bian.ref) {
lan_se_jian_bian.ref.visible = false;
}
// 隐藏其他VS元素
const vsElements = ['v', 's', 'ju_mao_tou', 'hui_mao_tou'];
vsElements.forEach(elementName => {
const element = this.g_cartoon.cartoonElementsBuffer[elementName];
if (element && element.ref) {
element.ref.visible = false;
}
});
}, config.common.hideDelay);
} }
createCat(type) { createCat(type) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment