Commit 1d000050 authored by 李维's avatar 李维

dev commit

parent 209e23c0
......@@ -112,6 +112,8 @@ export class PlayComponent implements OnInit, OnDestroy {
m_requestAfterCard = false;
m_requestID = null;
m_enableRunway = false;
m_pickupCard = false;
m_currentPickupCardID = null;
// ------------------------------------
......@@ -190,6 +192,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_requestAfterCard = false;
this.m_requestID = null;
this.m_enableRunway = false;
this.m_pickupCard = false;
this.m_currentPickupCardID = null;
}
endGame(){
......@@ -282,6 +286,16 @@ export class PlayComponent implements OnInit, OnDestroy {
y: this.g_cartoon.getOrigin().y+ (h/2)*this.g_mapScale + 481*this.g_mapScale
}
})
this.subscribeMapUpEvent('card-container', ()=>{
if(this.m_currentPickupCardID){
let card = this.g_cartoon.getCartoonElement(this.m_currentPickupCardID)
if(card.parentID){
this.g_cartoon.getCartoonElement(card.parentID).content = null
card.parentID = null;
}
}
})
this.render(element.ref)
}
......@@ -318,11 +332,69 @@ export class PlayComponent implements OnInit, OnDestroy {
y: y + 150*this.g_mapScale
}
})
element.content = null;
// let imageContainer= new MySprite()
// imageContainer.init(this.g_cartoon.images.get("card"))
// imageContainer.setScaleXY(180/imageContainer.width)
// element.ref.addChild(imageContainer)
// 可移动卡片
let cardContent = this.g_cartoon.createCartoonElementImageFunc(`card-content-${index}`, "card", (w,h)=>{
return {
sx: (180*this.g_mapScale)/w,
sy: (180*this.g_mapScale)/h
}
}, (w,h)=>{
return {
x: element.ref.x,
y: element.ref.y
}
})
cardContent.parentID = `card-bckground-${index}`
cardContent.canMove = false;
this.subscribeMapDownEvent(`card-content-${index}`, ()=>{
this.g_cartoon.playAudio("sm-click")
cardContent.canMove = true;
if(cardContent.parentID){
this.g_cartoon.getCartoonElement(cardContent.parentID).content = null
}
this.m_pickupCard = true;
this.m_currentPickupCardID = `card-content-${index}`
this.topOfRenderArray(cardContent.ref)
this.g_enableMapDown = true;
})
this.subscribeMapMoveEvent(`card-content-${index}`, ()=>{
if(cardContent.canMove){
cardContent.ref.x = this.g_clickX
cardContent.ref.y = this.g_clickY
}
this.g_enableMapMove = true;
})
this.subscribeMapUpEvent(`card-content-${index}`, ()=>{
let card = cardContent
if(card.canMove){
card.canMove = false;
card.backToParent()
this.m_pickupCard = false;
}
this.g_enableMapUp = true;
})
element.content = cardContent
let imageContainer= new MySprite()
imageContainer.init(this.g_cartoon.images.get("card"))
imageContainer.setScaleXY(180/imageContainer.width)
element.ref.addChild(imageContainer)
cardContent.backToParent = ()=>{
cardContent.canMove = false;
this.m_pickupCard = false;
if(cardContent.parentID){
this.g_cartoon.getCartoonElement(cardContent.parentID).setContent(cardContent)
}
}
this.render(cardContent.ref,999)
//
let textContainer= new MySprite()
textContainer.init(this.g_cartoon.images.get("text_container"))
......@@ -336,8 +408,46 @@ export class PlayComponent implements OnInit, OnDestroy {
textContent.fontSize = 50
textContainer.addChild(textContent)
textContainer.x = -textContainer.width/4
element.ref.addChild(textContainer)
cardContent.ref.addChild(textContainer)
element.moveLeft = (distance)=>{
element.ref.x -= distance
if(element.content){
element.content.ref.x -= distance;
}
}
element.readyGoOut = (x)=>{
element.ref.x = x
if(element.content){
element.content.ref.x = x;
}
}
element.setContent = (content)=>{
content.ref.x = element.ref.x
content.ref.y = element.ref.y
element.content = content
content.parentID = element.id
}
element.cleanContent = ()=>{
element.content = null
}
this.subscribeMapUpEvent(`card-bckground-${index}`, ()=>{
if(!element.content){
if(this.m_currentPickupCardID){
let card = this.g_cartoon.getCartoonElement(this.m_currentPickupCardID)
if(card.parentID){
this.g_cartoon.getCartoonElement(card.parentID).content = null;
}
element.setContent(this.g_cartoon.getCartoonElement(this.m_currentPickupCardID))
this.m_currentPickupCardID = null;
}
}
this.g_enableMapUp = true;
})
return element;
}
......@@ -357,7 +467,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_allCardIds.forEach((id)=>{
cardElement = this.g_cartoon.getCartoonElement(id)
if(!cardElement.waiting){
cardElement.ref.x -= step
cardElement.moveLeft(step)
}
this.cardRecyclingAndPreparation(id)
})
......@@ -469,7 +579,8 @@ export class PlayComponent implements OnInit, OnDestroy {
if(this.m_rightBuffer[0] && this.m_requestAfterCard){
this.m_requestAfterCard = false;
this.g_cartoon.getCartoonElementRef(this.m_rightBuffer[0]).alpha = 0;
this.g_cartoon.getCartoonElementRef(this.m_rightBuffer[0]).x = this.g_cartoon.getCartoonElementRef(this.m_requestID).x + width + 14*this.g_mapScale
// this.g_cartoon.getCartoonElementRef(this.m_rightBuffer[0]).x = this.g_cartoon.getCartoonElementRef(this.m_requestID).x + width + 14*this.g_mapScale
this.g_cartoon.getCartoonElement(this.m_rightBuffer[0]).readyGoOut(this.g_cartoon.getCartoonElementRef(this.m_requestID).x + width + 14*this.g_mapScale)
tweenChange(this.g_cartoon.getCartoonElementRef(this.m_rightBuffer[0]), {alpha: 1}, 0.2)
this.g_cartoon.getCartoonElement(this.m_rightBuffer[0]).waiting = false;
this.m_rightBuffer.splice(0,1)
......@@ -677,7 +788,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
this.m_mapMoveArray.forEach((item)=>{
if(!myStopPropagation){
if(!myStopPropagation || this.m_pickupCard){
if (this.checkClickTarget(this.g_cartoon.getCartoonElementRef(item.id))) {
this.g_enableMapMove = false;
if(item.callback()){
......@@ -1015,6 +1126,13 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_setIntervalIDs = []
}
topOfRenderArray(element){
let index = this.m_renderArr.indexOf(element)
if(index !=-1){
this.m_renderArr.splice(index, 1)
this.m_renderArr.push(element)
}
}
......
......@@ -39,7 +39,7 @@ const localImages = {
'bg_title': 'assets/play/bg_title.png',
'bg_card': 'assets/play/bg_card.png',
'bg_card_runway': 'assets/play/bg_card_runway.png',
'text_container': 'assets/play/text_container-1.png'
'text_container': 'assets/play/text_container.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