Commit 3f66e0db authored by 李维's avatar 李维

dev commit

parent c22de964
...@@ -181,9 +181,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -181,9 +181,10 @@ export class PlayComponent implements OnInit, OnDestroy {
this.stopAllInterval(); this.stopAllInterval();
this.stopAllTimeout() this.stopAllTimeout()
this.g_cartoon.stopAllAudio() this.g_cartoon.stopAllAudio()
this.m_allCardIds = [] this.m_allCardIds = []
this.cardRunControl(false) this.cardRunControl(false)
clearInterval(this.m_runIntervalId)
this.m_rightBuffer = [] this.m_rightBuffer = []
this.m_requestAfterCard = false; this.m_requestAfterCard = false;
this.m_requestID = null; this.m_requestID = null;
...@@ -194,6 +195,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -194,6 +195,8 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
// 背景
initBackground(){ initBackground(){
let element = this.g_cartoon.createCartoonElementImage('my-background', "bg-background", this.g_canvasWidth, this.g_canvasHeight, this.g_canvasWidth/2, this.g_canvasHeight/2,) let element = this.g_cartoon.createCartoonElementImage('my-background', "bg-background", this.g_canvasWidth, this.g_canvasHeight, this.g_canvasWidth/2, this.g_canvasHeight/2,)
this.subscribeMapMoveEvent('my-background', ()=>{ this.subscribeMapMoveEvent('my-background', ()=>{
...@@ -206,6 +209,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -206,6 +209,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref) this.render(element.ref)
} }
// 标题
initTitle(){ initTitle(){
let titleText = "Drag and drop games" let titleText = "Drag and drop games"
let element = this.g_cartoon.createCartoonElementImage('title', "bg_title", 576*this.g_mapScale, 66*this.g_mapScale, this.g_canvasWidth/2, this.g_cartoon.getOrigin().y+48*this.g_mapScale) let element = this.g_cartoon.createCartoonElementImage('title', "bg_title", 576*this.g_mapScale, 66*this.g_mapScale, this.g_canvasWidth/2, this.g_cartoon.getOrigin().y+48*this.g_mapScale)
...@@ -219,6 +224,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -219,6 +224,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref) this.render(element.ref)
} }
// 跑道
initCardRunway(){ initCardRunway(){
let element = this.g_cartoon.createCartoonElementImageFunc('card-runway', "bg_card_runway", (w,h)=>{ let element = this.g_cartoon.createCartoonElementImageFunc('card-runway', "bg_card_runway", (w,h)=>{
return { return {
...@@ -244,6 +251,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -244,6 +251,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref) this.render(element.ref)
} }
// 桌子
initTable(){ initTable(){
let element = this.g_cartoon.createCartoonElementImageFunc('desk', "desk", (w,h)=>{ let element = this.g_cartoon.createCartoonElementImageFunc('desk', "desk", (w,h)=>{
return { return {
...@@ -259,6 +268,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -259,6 +268,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref) this.render(element.ref)
} }
// 卡片容器(盘子 桌布)
initCardContainer(){ initCardContainer(){
let element = this.g_cartoon.createCartoonElementImageFunc('card-container', "dish", (w,h)=>{ let element = this.g_cartoon.createCartoonElementImageFunc('card-container', "dish", (w,h)=>{
return { return {
...@@ -274,11 +284,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -274,11 +284,13 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref) this.render(element.ref)
} }
// 选择卡片
initCards(){ initCards(){
let boundingBox = this.g_cartoon.getCartoonElement('card-runway').ref.getBoundingBox() let boundingBox = this.g_cartoon.getCartoonElement('card-runway').ref.getBoundingBox()
let cardWidth = 251*this.g_mapScale let cardWidth = 251*this.g_mapScale
let cardNumber = Math.ceil(this.g_canvasWidth/cardWidth); let cardNumber = Math.ceil(this.g_canvasWidth/cardWidth);
for(let index=0; index<6; index++){ for(let index=0; index<8; index++){
let newCard = this.createCard(index,index*cardWidth,boundingBox.y); let newCard = this.createCard(index,index*cardWidth,boundingBox.y);
if(index>=cardNumber){ if(index>=cardNumber){
newCard.ref.x = -999 newCard.ref.x = -999
...@@ -290,6 +302,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -290,6 +302,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
this.render(newCard.ref) this.render(newCard.ref)
} }
console.log(this.m_rightBuffer)
} }
createCard(index,x,y){ createCard(index,x,y){
...@@ -328,16 +341,19 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -328,16 +341,19 @@ export class PlayComponent implements OnInit, OnDestroy {
return element; return element;
} }
// 跑道启停控制
cardRunControl(status){ cardRunControl(status){
if(!this.m_enableRunway){ if(!this.m_enableRunway){
return; return;
} }
let step = 1*this.g_mapScale; let step = 1*this.g_mapScale;
let cardElement = null; let cardElement = null;
let max_x = 0; this.m_runStatus = status
if(status){ if(!this.m_runIntervalId){
this.m_runIntervalId = setInterval(()=>{ this.m_runIntervalId = setInterval(()=>{
max_x = 0; if(!this.m_runStatus){
return
}
this.m_allCardIds.forEach((id)=>{ this.m_allCardIds.forEach((id)=>{
cardElement = this.g_cartoon.getCartoonElement(id) cardElement = this.g_cartoon.getCartoonElement(id)
if(!cardElement.waiting){ if(!cardElement.waiting){
...@@ -347,12 +363,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -347,12 +363,11 @@ export class PlayComponent implements OnInit, OnDestroy {
}) })
this.m_runStatus = true; this.m_runStatus = true;
},10) },10)
}else{
clearInterval(this.m_runIntervalId)
this.m_runStatus = false;;
} }
} }
// 灯光
initLights(){ initLights(){
this.g_cartoon.getCartoonElement('card-runway').ref.addChild(this.createLights(0,0).ref) this.g_cartoon.getCartoonElement('card-runway').ref.addChild(this.createLights(0,0).ref)
this.g_cartoon.getCartoonElement('card-runway').ref.addChild(this.createLights(1,0).ref) this.g_cartoon.getCartoonElement('card-runway').ref.addChild(this.createLights(1,0).ref)
...@@ -366,14 +381,17 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -366,14 +381,17 @@ export class PlayComponent implements OnInit, OnDestroy {
return element; return element;
} }
// 卡片回收与准备控制
cardRecyclingAndPreparation(id){ cardRecyclingAndPreparation(id){
let ele = this.g_cartoon.getCartoonElement(id) let ele = this.g_cartoon.getCartoonElement(id)
let x = ele.ref.x; let x = ele.ref.x;
let width = 230*this.g_mapScale; let width = 230*this.g_mapScale;
if( (x + width*0.5) < this.g_canvasWidth && ( (x+ width*0.5) > this.g_canvasWidth-21*this.g_mapScale) && !this.m_requestAfterCard ){ if( (x + width*0.5) < this.g_canvasWidth && ( (x+ width*0.5) > this.g_canvasWidth-21*this.g_mapScale) && !this.m_requestAfterCard ){
if(this.m_requestID != id){
this.m_requestAfterCard = true; this.m_requestAfterCard = true;
this.m_requestID = id this.m_requestID = id
} }
}
if(this.m_rightBuffer[0] && this.m_requestAfterCard){ if(this.m_rightBuffer[0] && this.m_requestAfterCard){
this.m_requestAfterCard = false; this.m_requestAfterCard = false;
...@@ -388,6 +406,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -388,6 +406,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.g_cartoon.getCartoonElement(id).waiting = true; this.g_cartoon.getCartoonElement(id).waiting = true;
this.m_rightBuffer.push(id) this.m_rightBuffer.push(id)
} }
} }
......
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