Commit e82d9ac0 authored by 李维's avatar 李维

Update package

parent d73963a7
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
# dependencies # dependencies
/node_modules /node_modules
/publish
# profiling files # profiling files
chrome-profiler-events*.json chrome-profiler-events*.json
......
...@@ -114,20 +114,30 @@ export class Cartoon { ...@@ -114,20 +114,30 @@ export class Cartoon {
const audio = this.audio.get(key); const audio = this.audio.get(key);
audio.volume = volume audio.volume = volume
} }
stopAllAudio(){ stopAllAudio(audioAll?){
this._playingNow.forEach(audio=>{ if(!audioAll){
try{ audioAll = this._playingNow
if(audio){ }
audio.onended && audio.onended() audioAll.forEach(audio_URL=>{
audio.pause(); if(audio_URL){
audio.currentTime = 0; const audio = this.audio.get(audio_URL);
}else{ try{
if(audio.src && this.audioCallback[audio.src] && this.audioCallback[audio.src]["onended"]){ if(audio){
this.audioCallback[audio.src]["onended"]() audio.onended && audio.onended()
audio.pause && audio.pause();
audio.currentTime = 0;
}else{
if(this.audioCallback[audio_URL] && this.audioCallback[audio_URL]["onended"]){
this.audioCallback[audio_URL]["onended"]()
}
} }
}catch(err){
console.log(err)
} }
}catch(err){ }
console.log(err) else if(this._currentPlayAudio){
this._currentPlayAudio.pause();
this._currentPlayAudio.currentTime = 0;
} }
}) })
this._playingNow = [] this._playingNow = []
......
...@@ -170,7 +170,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -170,7 +170,8 @@ export class PlayComponent implements OnInit, OnDestroy {
{x: 450} {x: 450}
] ]
} }
m_canStopAudio = []
m_tipsSetinterval_1 = null;
// ------------------------------------ // ------------------------------------
...@@ -217,9 +218,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -217,9 +218,11 @@ export class PlayComponent implements OnInit, OnDestroy {
let array = [] let array = []
contentObj.dataArray.forEach(item => { contentObj.dataArray.forEach(item => {
array.push(item.audio_url) array.push(item.audio_url)
this.m_canStopAudio.push(item.audio_url)
item.options.forEach(card=>{ item.options.forEach(card=>{
if(card.audio_url){ if(card.audio_url){
array.push(card.audio_url) array.push(card.audio_url)
this.m_canStopAudio.push(card.audio_url)
} }
}) })
}) })
...@@ -254,11 +257,15 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -254,11 +257,15 @@ export class PlayComponent implements OnInit, OnDestroy {
cleanGameVar(){ cleanGameVar(){
this.stopEndPatal() this.stopEndPatal()
this.m_currentQuestion = 0; this.m_currentQuestion = 0;
if(this.m_tipsSetinterval_1){
clearInterval(this.m_tipsSetinterval_1)
}
// this.g_cartoon.getCartoonElement(`play-audio`).firstClick = true;
} }
startGame(){ startGame(){
this.loadQuestion() this.loadQuestion()
this.playTips() this.playTips(1)
this.g_cartoon.playAudio("skier", false ,null, true, (audio)=>{ this.g_cartoon.playAudio("skier", false ,null, true, (audio)=>{
this.m_bgMusic = audio this.m_bgMusic = audio
audio.volume = 0.5 audio.volume = 0.5
...@@ -266,7 +273,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -266,7 +273,6 @@ export class PlayComponent implements OnInit, OnDestroy {
this.g_cartoon.getCartoonElement(`question-index-board`).resetIndex() this.g_cartoon.getCartoonElement(`question-index-board`).resetIndex()
this.g_cartoon.getCartoonElement("play-audio").in() this.g_cartoon.getCartoonElement("play-audio").in()
this.g_cartoon.getCartoonElement("skier").ready(()=>{ this.g_cartoon.getCartoonElement("skier").ready(()=>{
// this.g_cartoon.getCartoonElement("play-audio").play()
}) })
} }
...@@ -404,31 +410,75 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -404,31 +410,75 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref, 999) this.render(element.ref, 999)
} }
playTips(){ playTips(type?){
let loopFunc
let header = this.g_cartoon.getCartoonElement(`header`) let header = this.g_cartoon.getCartoonElement(`header`)
let audio = this.g_cartoon.getCartoonElement(`play-audio`) let audio = this.g_cartoon.getCartoonElement(`play-audio`)
let skier = this.g_cartoon.getCartoonElement(`skier`) let skier = this.g_cartoon.getCartoonElement(`skier`)
setTimeout(()=>{
if(!type){
type = 3
}
if(type == 1){
if(this.m_tipsSetinterval_1){
clearInterval(this.m_tipsSetinterval_1)
}
loopFunc = ()=>{
header.ref.visible = true;
header.ref.scaleX = header.ref.scaleX * 1.5
header.ref.scaleY = header.ref.scaleY * 1.5
header.ref.x = audio.ref.x + this.g_canvasWidth
header.ref.y = audio.ref.y + this.g_canvasHeight
tweenChange(header.ref, {x: audio.ref.x+50*this.g_mapScale , y:audio.ref.y+50*this.g_mapScale, scaleX: header.initScaleX, scaleY: header.initScaleY}, 2)
return loopFunc
}
this.m_tipsSetinterval_1 = setInterval(loopFunc(), 3000)
this.m_setIntervalIDs.push(this.m_tipsSetinterval_1)
return
}
if(type == 2){
header.ref.scaleX = header.initScaleX
header.ref.scaleY = header.initScaleY
header.ref.x = audio.ref.x+50*this.g_mapScale
header.ref.y = audio.ref.y+50*this.g_mapScale
header.ref.visible = true; header.ref.visible = true;
header.ref.scaleX = header.ref.scaleX * 1.3 tweenChange(header.ref, {scaleX: header.ref.scaleX * 1.2, scaleY:header.ref.scaleY * 1.2}, 0.2)
header.ref.scaleY = header.ref.scaleY * 1.3
header.ref.x = audio.ref.x + this.g_canvasWidth
header.ref.y = audio.ref.y + this.g_canvasHeight
setTimeout(() => { setTimeout(() => {
tweenChange(header.ref, {x: audio.ref.x+50*this.g_mapScale , y:audio.ref.y+50*this.g_mapScale, scaleX: header.initScaleX, scaleY: header.initScaleY}, 0.5, ()=>{ tweenChange(header.ref, {scaleX: header.initScaleX, scaleY: header.initScaleY}, 0.2)
setTimeout(() => { }, 300);
tweenChange(header.ref, {scaleX: header.ref.scaleX * 1.2, scaleY:header.ref.scaleY * 1.2}, 0.2) tweenChange(header.ref, {x: skier.ref.x+50*this.g_mapScale , y:skier.ref.y-50*this.g_mapScale}, 0.5, ()=>{
header.ref.visible = false;
this.g_cartoon.getCartoonElement("skier").cruise()
})
return
}
if(type == 3){
setTimeout(()=>{
header.ref.visible = true;
header.ref.scaleX = header.ref.scaleX * 1.3
header.ref.scaleY = header.ref.scaleY * 1.3
header.ref.x = audio.ref.x + this.g_canvasWidth
header.ref.y = audio.ref.y + this.g_canvasHeight
setTimeout(() => {
tweenChange(header.ref, {x: audio.ref.x+50*this.g_mapScale , y:audio.ref.y+50*this.g_mapScale, scaleX: header.initScaleX, scaleY: header.initScaleY}, 0.5, ()=>{
setTimeout(() => { setTimeout(() => {
tweenChange(header.ref, {scaleX: header.initScaleX, scaleY: header.initScaleY}, 0.2) tweenChange(header.ref, {scaleX: header.ref.scaleX * 1.2, scaleY:header.ref.scaleY * 1.2}, 0.2)
}, 300); setTimeout(() => {
tweenChange(header.ref, {x: skier.ref.x+50*this.g_mapScale , y:skier.ref.y-50*this.g_mapScale}, 0.5, ()=>{ tweenChange(header.ref, {scaleX: header.initScaleX, scaleY: header.initScaleY}, 0.2)
header.ref.visible = false; }, 300);
this.g_cartoon.getCartoonElement("skier").cruise() tweenChange(header.ref, {x: skier.ref.x+50*this.g_mapScale , y:skier.ref.y-50*this.g_mapScale}, 0.5, ()=>{
}) header.ref.visible = false;
}, 1000); this.g_cartoon.getCartoonElement("skier").cruise()
}) })
}, 1000); }, 1000);
}, 500) })
}, 1000);
}, 500)
return
}
} }
initBaseLine(){ initBaseLine(){
...@@ -550,12 +600,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -550,12 +600,13 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
}, (w,h)=>{ }, (w,h)=>{
return{ return{
x: 1157*this.g_mapScale + (96/2)*this.g_mapScale, x: this.g_canvasWidth - (190/2)*this.g_mapScale,
y: 80*this.g_mapScale + (96/2)*this.g_mapScale, y: 80*this.g_mapScale + (96/2)*this.g_mapScale,
} }
}) })
element.ref.setScaleXY(0) element.ref.setScaleXY(0)
element.firstClick = true;
let audio0 = new MySprite() let audio0 = new MySprite()
audio0.init(this.g_cartoon.images.get("play_audio_0")) audio0.init(this.g_cartoon.images.get("play_audio_0"))
...@@ -586,7 +637,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -586,7 +637,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if(!this.g_formData.dataArray[this.m_currentQuestion].audio_url){ if(!this.g_formData.dataArray[this.m_currentQuestion].audio_url){
return return
} }
this.g_cartoon.stopAllAudio() this.g_cartoon.stopAllAudio(this.m_canStopAudio)
this.g_cartoon.playAudio(this.g_formData.dataArray[this.m_currentQuestion].audio_url, false, ()=>{ this.g_cartoon.playAudio(this.g_formData.dataArray[this.m_currentQuestion].audio_url, false, ()=>{
element.stop(); element.stop();
this.muteBgMusic(false) this.muteBgMusic(false)
...@@ -614,8 +665,17 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -614,8 +665,17 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
this.subscribeMapDownEvent(`play-audio`, ()=>{ this.subscribeMapDownEvent(`play-audio`, ()=>{
clearInterval(this.m_tipsSetinterval_1)
if(element.firstClick){
element.firstClick = false;
this.playTips(2)
}else{
this.g_cartoon.getCartoonElement(`header`).ref.visible = false;
}
this.g_cartoon.getCartoonElement("skier").enbaleClick = true;
if(this.g_formData.dataArray[this.m_currentQuestion].audio_url){ if(this.g_formData.dataArray[this.m_currentQuestion].audio_url){
this.g_cartoon.stopAllAudio() this.g_cartoon.stopAllAudio(this.m_canStopAudio)
element.play() element.play()
} }
tweenChange(element.ref, {scaleX: element.ref.initScaleX*0.9, scaleY: element.ref.initScaleY*0.9}, 0.1, ()=>{ tweenChange(element.ref, {scaleX: element.ref.initScaleX*0.9, scaleY: element.ref.initScaleY*0.9}, 0.1, ()=>{
...@@ -870,6 +930,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -870,6 +930,7 @@ export class PlayComponent implements OnInit, OnDestroy {
element.ref.y = this.g_canvasHeight + 500*this.g_mapScale element.ref.y = this.g_canvasHeight + 500*this.g_mapScale
element.ref.scaleX = element.initScaleX * 1.2 element.ref.scaleX = element.initScaleX * 1.2
element.ref.scaleY = element.initScaleY * 1.2 element.ref.scaleY = element.initScaleY * 1.2
element.enbaleClick = false;
let header = this.g_cartoon.createCartoonElementImageFunc(`header-inside`, "header", (w,h)=>{ let header = this.g_cartoon.createCartoonElementImageFunc(`header-inside`, "header", (w,h)=>{
return { return {
...@@ -940,17 +1001,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -940,17 +1001,11 @@ export class PlayComponent implements OnInit, OnDestroy {
element.firstReady = true; element.firstReady = true;
element.ready =(callback?)=>{ element.ready =(callback?)=>{
this.g_cartoon.playAudio("skier", false, ()=>{
this.muteBgMusic(false)
})
tweenChange(element.ref, {x: element.initX, y: element.initY, scaleX: element.initScaleX, scaleY: element.initScaleY}, 0.2, ()=>{ tweenChange(element.ref, {x: element.initX, y: element.initY, scaleX: element.initScaleX, scaleY: element.initScaleY}, 0.2, ()=>{
this.g_enableMapDown = true this.g_enableMapDown = true
// if(element.firstReady){
// element.firstReady = false;
// element.cruise(()=>{
// callback && callback()
// })
// }else{
// callback && callback()
// }
}) })
} }
...@@ -972,7 +1027,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -972,7 +1027,7 @@ export class PlayComponent implements OnInit, OnDestroy {
element.enableDrag = false; element.enableDrag = false;
this.subscribeMapDownEvent(element.id, ()=>{ this.subscribeMapDownEvent(element.id, ()=>{
if(!this.g_cartoon.getCartoonElementRef("mask-layer").visible && !element.enableDrag){ if(!this.g_cartoon.getCartoonElementRef("mask-layer").visible && !element.enableDrag && element.enbaleClick){
element.enableDrag = true element.enableDrag = true
element.stopCruise() element.stopCruise()
let disX = element.ref.x - this.g_clickX let disX = element.ref.x - this.g_clickX
...@@ -984,6 +1039,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -984,6 +1039,10 @@ export class PlayComponent implements OnInit, OnDestroy {
element.ref.y = this.g_clickY + disY; element.ref.y = this.g_clickY + disY;
this.highlightRunWay(this.calcRunWayIndex(element.ref.x, element.ref.y)) this.highlightRunWay(this.calcRunWayIndex(element.ref.x, element.ref.y))
}) })
}else{
if(!element.enbaleClick){
this.g_enableMapDown = true;
}
} }
}) })
...@@ -991,7 +1050,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -991,7 +1050,6 @@ export class PlayComponent implements OnInit, OnDestroy {
if(element.enableDrag){ if(element.enableDrag){
element.enableDrag = false; element.enableDrag = false;
element.targetRunWay = this.calcRunWayIndex(element.ref.x, element.ref.y) element.targetRunWay = this.calcRunWayIndex(element.ref.x, element.ref.y)
// this.g_cartoon.playAudio("move")
this.muteBgMusic(false) this.muteBgMusic(false)
element.go(element.targetRunWay, ()=>{ element.go(element.targetRunWay, ()=>{
if(this.gameControl(element.targetRunWay)){ if(this.gameControl(element.targetRunWay)){
...@@ -1001,7 +1059,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1001,7 +1059,8 @@ export class PlayComponent implements OnInit, OnDestroy {
element.goAhead(()=>{ element.goAhead(()=>{
this.nextQuestion(()=>{ this.nextQuestion(()=>{
this.loadQuestion() this.loadQuestion()
element.ready() element.ready();
this.g_cartoon.playAudio("move")
}) })
}) })
}else{ }else{
...@@ -1090,6 +1149,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1090,6 +1149,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.showEndPatal() this.showEndPatal()
this.m_setTimeoutIDs.push(setTimeout(() => { this.m_setTimeoutIDs.push(setTimeout(() => {
this.stopEndPatal() this.stopEndPatal()
this.playTips(1)
this.g_cartoon.getCartoonElement("skier").enbaleClick = false
callback && callback() callback && callback()
}, 3000)) }, 3000))
...@@ -1098,7 +1159,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1098,7 +1159,6 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
controlCardAndHotZoo(num){ controlCardAndHotZoo(num){
console.log(num)
let allQuestionCards = [] let allQuestionCards = []
let hotZooArrows = [] let hotZooArrows = []
for(let index=0; index<4; index++){ for(let index=0; index<4; index++){
......
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