Commit eb1bd05c authored by 李维's avatar 李维

dev commit

parent 6231e9ec
......@@ -98,7 +98,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------ 调试变量 ------------
g_EnableStageRuler = true; // 使能舞台背景格尺
g_EnableStageRuler = false; // 使能舞台背景格尺
g_ForceChangeDefaultRole = false // 强制当前角色为默认角色
g_EnableTestSendEvent = false // 发送模拟Web数据
// ------------------------------------
......@@ -106,7 +106,9 @@ export class PlayComponent implements OnInit, OnDestroy {
// 当数据加载完毕后,执行
systemReady(){
this.initGame()
this.switchAnswerSheetButton("start")
}
// 屏幕尺寸变化后执行
......@@ -159,17 +161,27 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------------------------------------------------------------------------
initGame(){
this.initBackground()
this.initAnswerSheet()
this.initSpeaker()
this.initStartButton()
this.initRestartButton()
this.showAnswer()
this.initPuzzles()
setTimeout(()=>{
this.startGame()
}, 1000)
this.switchAnswerSheetButton("speaker")
}
startGame(){
this.g_cartoon.playAudio("sm-start")
this.g_cartoon.getCartoonElement("AnswerSheet").moveLeft(()=>{
this.showPuzzleCards();
this.switchAnswerSheetButton("speaker")
if(this.g_formData.hotZoneItemArr[this.m_currentQuestionIndex].media && this.g_formData.hotZoneItemArr[this.m_currentQuestionIndex].media.audio_url){
this.g_cartoon.getCartoonElement("speaker").setAudio(this.g_formData.hotZoneItemArr[this.m_currentQuestionIndex].media.audio_url)
}
setTimeout(()=>{
this.g_cartoon.getCartoonElement("speaker").playAudio()
},100)
})
}
......@@ -177,11 +189,36 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_currentQuestionIndex++;
if(this.m_currentQuestionIndex==this.m_totalQusetion){
this.finisedAll()
}else{
if(this.g_formData.hotZoneItemArr[this.m_currentQuestionIndex].media && this.g_formData.hotZoneItemArr[this.m_currentQuestionIndex].media.audio_url){
this.g_cartoon.getCartoonElement("speaker").setAudio(this.g_formData.hotZoneItemArr[this.m_currentQuestionIndex].media.audio_url)
}else{
this.g_cartoon.getCartoonElement("speaker").setAudio("")
}
setTimeout(()=>{
this.g_cartoon.getCartoonElement("speaker").playAudio()
},2500)
}
}
finisedAll(){
this.switchAnswerSheetButton("restart")
this.g_cartoon.getCartoonElement("AnswerSheet").moveMiddle()
this.g_cartoon.playAudio("sm-win")
this.showEndPatal()
setTimeout(()=>{
this.stopEndPatal()
},3000)
}
initBackground(){
let element = this.g_cartoon.createCartoonElement("background", "MySprite");
element.ref.init(this.g_cartoon.images.get("background"));
element.ref.scaleX = this.g_canvasWidth / element.ref.width
element.ref.scaleY = this.g_canvasHeight / element.ref.height
element.ref.x = (element.ref.width*element.ref.scaleX)/2;
element.ref.y = (element.ref.height*element.ref.scaleY)/2;
this.render(element.ref)
}
initAnswerSheet(){
......@@ -219,6 +256,152 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref)
}
switchAnswerSheetButton(type){
switch(type){
case "speaker":
this.g_cartoon.getCartoonElement("speaker").show()
this.g_cartoon.getCartoonElement("start-button").hide();
this.g_cartoon.getCartoonElement("restart-button").hide();
break;
case "start":
this.g_cartoon.getCartoonElement("speaker").hide();
this.g_cartoon.getCartoonElement("start-button").show()
this.g_cartoon.getCartoonElement("restart-button").hide();
break;
case "restart":
this.g_cartoon.getCartoonElement("start-button").hide()
this.g_cartoon.getCartoonElement("speaker").hide();
this.g_cartoon.getCartoonElement("restart-button").show();
break;
}
}
initSpeaker(){
let element = this.g_cartoon.createCartoonElement("speaker", "MySprite");
element.ref.init(this.g_cartoon.images.get("laba"));
let sx = 87 / element.ref.width;
let sy= 93 / element.ref.height;
element.ref.scaleX = sx;
element.ref.scaleY = sy;
element.ref.x = -5;
element.ref.y = 228;
element.ref.visible = false;
element.audio = ""
element.setAudio = (audio_url)=>{
element.audio = audio_url
}
element.playAudio = ()=>{
this.g_cartoon.playAudio(element.audio)
}
element.show = ()=>{
tweenChange(element.ref, {scaleX:sx, scaleY:sy}, 0, ()=>{
element.ref.visible = true
})
}
element.hide = ()=>{
element.ref.visible = false;
tweenChange(element.ref, {scaleX:0, scaleY:0}, 0)
}
element.click = ()=>{
element.playAudio()
tweenChange(element.ref, {scaleX:sx*0.8, scaleY:sy*0.8}, 0.1, ()=>{
tweenChange(element.ref, {scaleX:sx, scaleY:sy}, 0.1)
})
}
this.subscribeMapDownEvent("speaker", ()=>{
element.click()
this.g_enableMapDown = true;
})
this.g_cartoon.getCartoonElement("AnswerSheet").ref.addChild(element.ref)
}
initStartButton(){
let element = this.g_cartoon.createCartoonElement("start-button", "MySprite");
element.ref.init(this.g_cartoon.images.get("start"));
let sx = 87 / element.ref.width;
let sy= 93 / element.ref.height;
element.ref.scaleX = sx;
element.ref.scaleY = sy;
element.ref.x = -5;
element.ref.y = 228;
element.ref.visible = false;
element.show = ()=>{
tweenChange(element.ref, {scaleX:sx, scaleY:sy}, 0, ()=>{
element.ref.visible = true
})
}
element.hide = ()=>{
element.ref.visible = false;
tweenChange(element.ref, {scaleX:0, scaleY:0}, 0)
}
element.click = (callback)=>{
tweenChange(element.ref, {scaleX:sx*0.8, scaleY:sy*0.8}, 0.1, ()=>{
tweenChange(element.ref, {scaleX:sx, scaleY:sy}, 0.1, ()=>{
callback && callback()
})
})
}
this.subscribeMapDownEvent("start-button", ()=>{
element.click(()=>{
this.startGame()
})
this.g_enableMapDown = true;
})
this.g_cartoon.getCartoonElement("AnswerSheet").ref.addChild(element.ref)
}
initRestartButton(){
let element = this.g_cartoon.createCartoonElement("restart-button", "MySprite");
element.ref.init(this.g_cartoon.images.get("restart"));
let sx = 87 / element.ref.width;
let sy= 93 / element.ref.height;
element.ref.scaleX = sx;
element.ref.scaleY = sy;
element.ref.x = -5;
element.ref.y = 228;
element.ref.visible = false;
element.show = ()=>{
tweenChange(element.ref, {scaleX:sx, scaleY:sy}, 0, ()=>{
element.ref.visible = true
})
}
element.hide = ()=>{
element.ref.visible = false;
tweenChange(element.ref, {scaleX:0, scaleY:0}, 0)
}
element.click = (callback)=>{
tweenChange(element.ref, {scaleX:sx*0.8, scaleY:sy*0.8}, 0.1, ()=>{
tweenChange(element.ref, {scaleX:sx, scaleY:sy}, 0.1, ()=>{
callback && callback()
})
})
}
this.subscribeMapDownEvent("restart-button", ()=>{
element.click(()=>{
this.restartGame()
this.startGame();
})
this.g_enableMapDown = true;
})
this.g_cartoon.getCartoonElement("AnswerSheet").ref.addChild(element.ref)
}
showAnswer(){
let hotZoneItemArr = this.g_formData.hotZoneItemArr
......@@ -245,13 +428,21 @@ export class PlayComponent implements OnInit, OnDestroy {
if(this.checkSelectedZone(index)){
let rect = element.ref.getBoundingBox()
element.show()
this.g_cartoon.stopAllAudio()
this.g_cartoon.playAudio("sm-choice-correct")
this.showCorrectPatal("AnswerSheet",1500)
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).enableMove = false;
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).isPlaced = true;
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).moveTo(rect.x + rect.width/2, rect.y + rect.height/2)
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).hide()
this.nextQusetion()
this.g_enableMapUp = true;
}else{
this.g_cartoon.getCartoonElement(`puzzle-card-${this.m_currentMovedCardIndex}-container`).back()
this.g_cartoon.playAudio("sm-choice-incorrect")
let index = this.m_currentMovedCardIndex
setTimeout(()=>{
this.g_cartoon.getCartoonElement(`puzzle-card-${index}-container`).back()
},300)
}
})
});
......@@ -356,9 +547,18 @@ export class PlayComponent implements OnInit, OnDestroy {
tweenChange(container.ref, { x:x, y:y } , 0.1)
}
container.activite = ( )=>{
container.ref.init(this.g_cartoon.images.get("lvquan"))
}
container.incativite = ( )=>{
container.ref.init(this.g_cartoon.images.get("baiquan"))
}
this.subscribeMapDownEvent(`puzzle-card-${index}-container`, ()=>{
this.m_currentMovedCardIndex = container.cardIndex
this.g_cartoon.playAudio("sm-click")
container.enableMove= true;
container.activite()
this.g_enableMapDown = true;
})
this.subscribeMapMoveEvent(`puzzle-card-${index}-container`, ()=>{
......@@ -372,8 +572,13 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_currentMovedCardIndex = -1;
container.enableMove= false;
this.g_enableMapUp = true;
container.incativite()
if(!container.isPlaced){
container.back();
this.g_cartoon.stopAllAudio()
this.g_cartoon.playAudio("sm-choice-incorrect")
setTimeout(()=>{
container.back();
},300)
}
})
......@@ -384,7 +589,6 @@ export class PlayComponent implements OnInit, OnDestroy {
// console.log("currentQuestionIndex:" + this.m_currentQuestionIndex + " zoneIndex:" + zoneIndex + " currentMovedCardIndex: " + this.m_currentMovedCardIndex)
if(this.m_currentQuestionIndex == zoneIndex){
if(zoneIndex == this.m_currentMovedCardIndex){
this.nextQusetion()
return true;
}
}
......@@ -412,6 +616,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.cleanCardList()
this.m_totalQusetion = 0;
this.m_currentQuestionIndex = 0;
this.g_cartoon.getCartoonElement("speaker").audio_url = "";
}
......@@ -1114,5 +1319,4 @@ export class PlayComponent implements OnInit, OnDestroy {
}
return (radian * Math.PI) / 180;
}
}
......@@ -4,9 +4,20 @@ const localImages = {
'bg-453-251': 'assets/play/bg-453-251.png',
'bg_500_600': "assets/play/bg_500_600.png",
'bg_1280_222': "assets/play/bg_1280_222.png",
'petal_1': "assets/play/scrap-pic-1.png",
'petal_2': "assets/play/scrap-pic-2.png",
'petal_3': "assets/play/scrap-pic-3.png",
'answer-sheet': "assets/play/AnswerSheet.png",
'baiquan': "assets/play/baiquan.png"
'baiquan': "assets/play/baiquan.png",
'background': "assets/play/background.png",
'laba': "assets/play/laba.png",
'laba_down': "assets/play/laba_down.png",
'start': "assets/play/start.png",
'start_down': "assets/play/start_down.png",
'restart': "assets/play/restart.png",
'lvquan': "assets/play/lvquan.png"
};
......
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