Commit a82fae5d authored by Tt's avatar Tt

feat(游戏逻辑): 添加倒计时音效并重构游戏初始化流程

parent 379207ec
...@@ -297,9 +297,12 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -297,9 +297,12 @@ export class PlayComponent implements OnInit, OnDestroy {
// 依次显示3、2、1的倒计时动画 // 依次显示3、2、1的倒计时动画
// 先显示3 // 先显示3
this.g_cartoon.playAudio('time_3');
this.showCountdownNumber('dao_ji_shi_3', config, () => { this.showCountdownNumber('dao_ji_shi_3', config, () => {
this.g_cartoon.playAudio('time_2');
// 显示完3后显示2 // 显示完3后显示2
this.showCountdownNumber('dao_ji_shi_2', config, () => { this.showCountdownNumber('dao_ji_shi_2', config, () => {
this.g_cartoon.playAudio('time_1');
// 显示完2后显示1 // 显示完2后显示1
this.showCountdownNumber('dao_ji_shi_1', config, () => { this.showCountdownNumber('dao_ji_shi_1', config, () => {
// 倒计时结束后的操作,等待一段时间后显示VS动画 // 倒计时结束后的操作,等待一段时间后显示VS动画
...@@ -307,6 +310,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -307,6 +310,8 @@ export class PlayComponent implements OnInit, OnDestroy {
// this.showVsAni(type); // this.showVsAni(type);
this.hideVsElements(); this.hideVsElements();
this.hide321Elements(); this.hide321Elements();
this.startBattle();
}, config.time.afterComplete * 1000); }, config.time.afterComplete * 1000);
}); });
}); });
...@@ -440,32 +445,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -440,32 +445,6 @@ export class PlayComponent implements OnInit, OnDestroy {
this.initBackground() this.initBackground()
this.initListPage(); this.initListPage();
// 显示321倒计时动画,传递'left'参数表示左侧猫开始玩
// this.show321('left');
// 注释掉直接显示VS动画的代码,因为现在由show321函数在倒计时结束后调用
// this.showVsAni('right');
this.initFishGame();
// 初始化发音按钮
this.initFaYinBtn();
// 初始化退出按钮
// this.initBtnBack();
// // 初始化标题
// this.initTitle();
// const partXList = this.g_formData.type == 0 ? [300 * this.g_mapScale, 700 * this.g_mapScale, 1100 * this.g_mapScale] : [700 * this.g_mapScale, 300 * this.g_mapScale, 1100 * this.g_mapScale];
// // 初始化第一部分内容(字母块)
// this.initPart1(partXList[0]);
// // 初始化第二部分内容(字母块)
// this.initPart2(partXList[1]);
// // 初始化第三部分内容(字母块)
// this.initPart3(partXList[2]);
// // 初始化文字
// this.initWords();
// // 初始化连接线
// this.drawConnectionLines();
} }
/** /**
...@@ -492,10 +471,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -492,10 +471,10 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_gameOver = true; this.m_gameOver = true;
// 延迟500毫秒后执行结束动画 // 延迟500毫秒后执行结束动画
setTimeout(() => { setTimeout(() => {
// 显示花瓣效果 // // 显示花瓣效果
this.showCorrectPatal("card", 5000) // this.showCorrectPatal("card", 5000)
// 播放结束音效 // // 播放结束音效
this.g_cartoon.playAudio("success") // this.g_cartoon.playAudio("success")
}, 500) }, 500)
} }
...@@ -580,6 +559,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -580,6 +559,8 @@ export class PlayComponent implements OnInit, OnDestroy {
toggleItemSelection(itemNode, dataIndex) { toggleItemSelection(itemNode, dataIndex) {
if (!this.layoutPage.ref.visible) return; if (!this.layoutPage.ref.visible) return;
this.g_cartoon.playAudio('click_pic')
const isSelected = itemNode.ref.isSelected || false; const isSelected = itemNode.ref.isSelected || false;
const selectMark = itemNode.ref.selectMark; const selectMark = itemNode.ref.selectMark;
...@@ -678,8 +659,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -678,8 +659,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.layoutPage.ref.visible = false; this.layoutPage.ref.visible = false;
this.checkBtnElement.ref.visible = false; this.checkBtnElement.ref.visible = false;
this.listItem.ref.visible = false; this.listItem.ref.visible = false;
this.initFishGame(); this.initBattle();
// 这里可以添加开始游戏的具体逻辑
} else { } else {
// 提示需要选择更多单词 // 提示需要选择更多单词
console.log('请至少选择2个单词'); console.log('请至少选择2个单词');
...@@ -883,6 +863,22 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -883,6 +863,22 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
initBattle() {
this.g_enableMapDown = true;
if (this.g_formData.doubleModal) {
this.showVsAni('left');
// this.showVsAni('right');
} else {
this.startBattle();
}
}
startBattle() {
// 初始化鱼游戏
this.initFishGame();
// 初始化发音按钮
this.initFaYinBtn();
}
/** /**
* 初始化鱼游戏 * 初始化鱼游戏
*/ */
...@@ -890,7 +886,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -890,7 +886,8 @@ export class PlayComponent implements OnInit, OnDestroy {
private cat_right: any; private cat_right: any;
private cat_center: any; private cat_center: any;
initFishGame() { initFishGame() {
const targetList = [0, 1, 2, 3, 4, 5, 6]; console.log("this.selectList", this.selectList);
const targetList = this.selectList.concat();
const questions = this.g_formData.questions; const questions = this.g_formData.questions;
// 1. 梳理出选中的数据数组 // 1. 梳理出选中的数据数组
...@@ -1223,6 +1220,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1223,6 +1220,7 @@ export class PlayComponent implements OnInit, OnDestroy {
moveItem(s_element, this.g_canvasWidth / 2 + config.vs.s.offsetX * this.g_mapScale, s_element.y, config.vs.s.moveTime, () => { moveItem(s_element, this.g_canvasWidth / 2 + config.vs.s.offsetX * this.g_mapScale, s_element.y, config.vs.s.moveTime, () => {
// VS元素移动完成后,调用showVsShadow函数创建阴影效果 // VS元素移动完成后,调用showVsShadow函数创建阴影效果
this.showVsShadow(); this.showVsShadow();
this.g_cartoon.playAudio('vs');
}); });
setTimeout(() => { setTimeout(() => {
// 隐藏VS元素 // 隐藏VS元素
...@@ -1661,6 +1659,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1661,6 +1659,7 @@ export class PlayComponent implements OnInit, OnDestroy {
return fish; return fish;
} }
brokePaopaoAni(fish) { brokePaopaoAni(fish) {
// this.g_cartoon.playAudio('pop_bomb');
// 对于正确的鱼,显示泡泡破裂动画 // 对于正确的鱼,显示泡泡破裂动画
// 按顺序切换序列帧 pao_pao_xu_lie_zhen_1 到 pao_pao_xu_lie_zhen_9 // 按顺序切换序列帧 pao_pao_xu_lie_zhen_1 到 pao_pao_xu_lie_zhen_9
let currentFrame = 1; let currentFrame = 1;
...@@ -1690,6 +1689,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1690,6 +1689,7 @@ export class PlayComponent implements OnInit, OnDestroy {
* @param shuiHuaElement 水花元素 * @param shuiHuaElement 水花元素
*/ */
playShuiHuaAnimation(shuiHuaElement) { playShuiHuaAnimation(shuiHuaElement) {
this.g_cartoon.playAudio('fish_down');
// 显示水花元素 // 显示水花元素
shuiHuaElement.ref.visible = true; shuiHuaElement.ref.visible = true;
......
...@@ -100,14 +100,14 @@ const localAudios = { ...@@ -100,14 +100,14 @@ const localAudios = {
'bg_sometime': 'assets/audio/bg_sometime.mp3', 'bg_sometime': 'assets/audio/bg_sometime.mp3',
'click_pic': 'assets/audio/click_pic.mp3', 'click_pic': 'assets/audio/click_pic.mp3',
'click_wrong': 'assets/audio/click_wrong.mp3', 'click_wrong': 'assets/audio/click_wrong.mp3',
'fish_down': 'assets/audio/fish_down.mp3',
'fish_many_down': 'assets/audio/fish_many_down.mp3',
'pop_bomb': 'assets/audio/pop_bomb.mp3', 'pop_bomb': 'assets/audio/pop_bomb.mp3',
'fish_down': 'assets/audio/fish_down.mp3',
'time_1': 'assets/audio/time_1.mp3', 'time_1': 'assets/audio/time_1.mp3',
'time_2': 'assets/audio/time_2.mp3', 'time_2': 'assets/audio/time_2.mp3',
'time_3': 'assets/audio/time_3.mp3', 'time_3': 'assets/audio/time_3.mp3',
'vs': 'assets/audio/vs.mp3', 'vs': 'assets/audio/vs.mp3',
'vs2': 'assets/audio/vs2.mp3', 'vs2': 'assets/audio/vs2.mp3',
'fish_many_down': 'assets/audio/fish_many_down.mp3',
// Default audio files // Default audio files
'sm-back': 'assets/default/audio/sm-back.mp3', 'sm-back': 'assets/default/audio/sm-back.mp3',
......
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