Commit f4f1e030 authored by 李维's avatar 李维

dev commit

parent 56d69ff6
...@@ -38,7 +38,21 @@ import * as _ from "lodash"; ...@@ -38,7 +38,21 @@ import * as _ from "lodash";
import TWEEN from "@tweenjs/tween.js"; import TWEEN from "@tweenjs/tween.js";
const defauleFormData = { const defauleFormData = {
sex:"male" bgMusic:"FC-Sonw",
dataArray:[
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"},
{type:"Image", image_url:"bee-demo", audio_url:"bee-demo"},
{type:"Text", text:"Apple", audio_url:"apple-demo"}
]
} }
const zIndexMap = { const zIndexMap = {
...@@ -114,7 +128,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -114,7 +128,8 @@ export class PlayComponent implements OnInit, OnDestroy {
m_enableRunway = false; m_enableRunway = false;
m_pickupCard = false; m_pickupCard = false;
m_currentPickupCardID = null; m_currentPickupCardID = null;
m_allSelectedHotZone = [] m_allSelectedHotZone = [];
m_moveAsstantIntervalId = null
// ------------------------------------ // ------------------------------------
...@@ -180,6 +195,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -180,6 +195,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.cardRunControl(true) this.cardRunControl(true)
this.initSelectedCardArea() this.initSelectedCardArea()
this.initStartButton() this.initStartButton()
this.initBackgroundMusic()
} }
cleanGameVar(){ cleanGameVar(){
...@@ -198,12 +214,22 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -198,12 +214,22 @@ export class PlayComponent implements OnInit, OnDestroy {
this.m_pickupCard = false; this.m_pickupCard = false;
this.m_currentPickupCardID = null; this.m_currentPickupCardID = null;
this.m_allSelectedHotZone = [] this.m_allSelectedHotZone = []
this.disableMoveAsstant()
} }
endGame(){ endGame(){
} }
// 播放背景音乐
initBackgroundMusic(){
let play = ()=>{
this.g_cartoon.playAudio(this.g_formData.bgMusic, false, ()=>{
play()
})
}
play()
}
// 背景 // 背景
initBackground(){ initBackground(){
...@@ -299,8 +325,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -299,8 +325,9 @@ export class PlayComponent implements OnInit, OnDestroy {
let boundingBox = this.g_cartoon.getCartoonElement('card-runway').ref.getBoundingBox() let boundingBox = this.g_cartoon.getCartoonElement('card-runway').ref.getBoundingBox()
let cardWidth = 244*this.g_mapScale let cardWidth = 244*this.g_mapScale
let cardNumber = Math.ceil(this.g_canvasWidth/cardWidth); let cardNumber = Math.ceil(this.g_canvasWidth/cardWidth);
for(let index=0; index<10; index++){ let cardDetailArray = this.g_formData.dataArray
let newCard = this.createCard(index,index*cardWidth,boundingBox.y); for(let index=0; index<cardDetailArray.length; index++){
let newCard = this.createCard(index,index*cardWidth,boundingBox.y,cardDetailArray[index]);
if(index>=cardNumber){ if(index>=cardNumber){
newCard.ref.x = -999 newCard.ref.x = -999
newCard.waiting = true; newCard.waiting = true;
...@@ -313,7 +340,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -313,7 +340,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
} }
createCard(index,x,y){ createCard(index,x,y,data){
this.m_allCardIds.push(`card-bckground-${index}`) this.m_allCardIds.push(`card-bckground-${index}`)
let element = this.g_cartoon.createCartoonElementImageFunc(`card-bckground-${index}`, "bg_card", (w,h)=>{ let element = this.g_cartoon.createCartoonElementImageFunc(`card-bckground-${index}`, "bg_card", (w,h)=>{
return { return {
...@@ -342,49 +369,73 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -342,49 +369,73 @@ export class PlayComponent implements OnInit, OnDestroy {
}) })
cardContent.parentID = `card-bckground-${index}` cardContent.parentID = `card-bckground-${index}`
cardContent.canMove = false; cardContent.canMove = false;
this.subscribeMapDownEvent(`card-content-${index}`, ()=>{ cardContent.clickTime = null
cardContent.handleClick = ()=>{
this.g_cartoon.playAudio("sm-click") this.g_cartoon.playAudio("sm-click")
cardContent.canMove = true; cardContent.canMove = true;
if(cardContent.parentID){ if(cardContent.parentID){
this.g_cartoon.getCartoonElement(cardContent.parentID).content = null this.g_cartoon.getCartoonElement(cardContent.parentID).content = null
} }
this.enableMoveAsstant(cardContent)
this.m_pickupCard = true; this.m_pickupCard = true;
this.m_currentPickupCardID = `card-content-${index}` this.m_currentPickupCardID = `card-content-${index}`
this.g_cartoon.getCartoonElement(`selected-card-hotzone`).show() this.g_cartoon.getCartoonElement(`selected-card-hotzone`).show()
this.topOfRenderArray(cardContent.ref) this.topOfRenderArray(cardContent.ref)
element.baseClick_x = this.g_clickX
element.baseClick_y = this.g_clickY
}
this.subscribeMapDownEvent(`card-content-${index}`, ()=>{
if( cardContent.parentID.indexOf("hot") != -1 ){
this.g_cartoon.playAudio(data.audio_url)
cardContent.clickTime = new Date().getTime()
}else{
cardContent.handleClick()
}
this.g_enableMapDown = true; this.g_enableMapDown = true;
}) })
this.subscribeMapMoveEvent(`card-content-${index}`, ()=>{ this.subscribeMapMoveEvent(`card-content-${index}`, ()=>{
if(cardContent.canMove){ if( cardContent.clickTime ){
let a = cardContent.clickTime - new Date().getTime()
if(Math.abs(a)>50){
cardContent.handleClick()
cardContent.clickTime = null
}
}
if( cardContent.canMove ){
cardContent.ref.x = this.g_clickX cardContent.ref.x = this.g_clickX
cardContent.ref.y = this.g_clickY cardContent.ref.y = this.g_clickY
} }
// else{
// if(dis>(50*this.g_mapScale)){
// cardContent.canMove = true;
// }
// }
this.g_enableMapMove = true; this.g_enableMapMove = true;
}) })
this.subscribeMapUpEvent(`card-content-${index}`, ()=>{ this.subscribeMapUpEvent(`card-content-${index}`, ()=>{
cardContent.clickTime = null
if(cardContent.canMove){ if(cardContent.canMove){
setTimeout(()=>{ setTimeout(()=>{
cardContent.canMove = false; cardContent.canMove = false;
cardContent.backToParent() cardContent.backToParent()
this.g_cartoon.getCartoonElement(`selected-card-hotzone`).hide() this.g_cartoon.getCartoonElement(`selected-card-hotzone`).hide()
this.m_pickupCard = false; this.m_pickupCard = false;
},100) },100)
}else{ }else{
if(cardContent.parentID && this.m_currentPickupCardID){
if(cardContent.parentID && this.m_currentPickupCardID){ let pickupCard = this.g_cartoon.getCartoonElement(this.m_currentPickupCardID)
let pickupCard = this.g_cartoon.getCartoonElement(this.m_currentPickupCardID) if( cardContent.parentID.indexOf("hotzone") != -1 && pickupCard.parentID.indexOf("hotzone") != -1 ){
if( cardContent.parentID.indexOf("hotzone") != -1 && pickupCard.parentID.indexOf("hotzone") != -1 ){ let temp = pickupCard.parentID
let temp = pickupCard.parentID pickupCard.parentID = cardContent.parentID
pickupCard.parentID = cardContent.parentID cardContent.parentID =temp
cardContent.parentID =temp cardContent.backToParent()
cardContent.backToParent()
}
} }
}
} }
this.disableMoveAsstant()
this.g_enableMapUp = true; this.g_enableMapUp = true;
}) })
element.content = cardContent element.content = cardContent
...@@ -400,19 +451,26 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -400,19 +451,26 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(cardContent.ref,999) this.render(cardContent.ref,999)
// //
let textContainer= new MySprite() if(data.type == "Text"){
textContainer.init(this.g_cartoon.images.get("text_container")) let textContent = new Label()
textContainer.setScaleXY(150/textContainer.width) textContent.text = data.text?data.text:"Demo"
let textContent = new Label() textContent.fontColor = "#e05e14";
textContent.text = "T:" + index textContent.fontName = "BerlinSansFBDemi-Bold";
textContent.fontColor = "#e05e14"; textContent.textAlign = "center";
textContent.fontName = "BerlinSansFBDemi-Bold"; textContent.x = textContent.width/2
textContent.maxSingalLineWidth = 170*this.g_mapScale let textSize = 180*this.g_mapScale / textContent.text.length
textContent.x = textContent.width/2 if(textSize>50){
textContent.fontSize = 50 textSize = 50
textContainer.addChild(textContent) }
textContainer.x = -textContainer.width/4 textContent.fontSize = textSize
cardContent.ref.addChild(textContainer) cardContent.ref.addChild(textContent)
}else{
let imageContent = new MySprite()
imageContent.init(this.g_cartoon.images.get(data.image_url?data.image_url:"apple-demp"))
imageContent.setScaleXY(Math.min( 120/imageContent.width, 120/imageContent.height ))
cardContent.ref.addChild(imageContent)
}
element.moveLeft = (distance)=>{ element.moveLeft = (distance)=>{
element.ref.x -= distance element.ref.x -= distance
...@@ -687,6 +745,19 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -687,6 +745,19 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref) this.render(element.ref)
} }
enableMoveAsstant(element){
if(this.m_moveAsstantIntervalId){
clearInterval(this.m_moveAsstantIntervalId)
}
this.m_moveAsstantIntervalId = setInterval(()=>{
element.ref.x = this.g_clickX;
element.ref.y = this.g_clickY;
},50)
}
disableMoveAsstant(){
clearInterval(this.m_moveAsstantIntervalId)
}
......
...@@ -39,9 +39,10 @@ const localImages = { ...@@ -39,9 +39,10 @@ const localImages = {
'bg_title': 'assets/play/bg_title.png', 'bg_title': 'assets/play/bg_title.png',
'bg_card': 'assets/play/bg_card.png', 'bg_card': 'assets/play/bg_card.png',
'bg_card_runway': 'assets/play/bg_card_runway.png', 'bg_card_runway': 'assets/play/bg_card_runway.png',
'text_container': 'assets/play/text_container.png', 'text_container': 'assets/play/text_container-1.png',
'bg_selected_card': 'assets/play/bg_selected_card.png', 'bg_selected_card': 'assets/play/bg_selected_card.png',
'bg_1280_180': 'assets/play/bg_1280_180_1.png' 'bg_1280_180': 'assets/play/bg_1280_180_1.png',
'bee-demo': 'assets/play/bee-demo.jpg'
}; };
...@@ -68,6 +69,9 @@ const localAudios = { ...@@ -68,6 +69,9 @@ const localAudios = {
'change': 'assets/audio/change.mp3', 'change': 'assets/audio/change.mp3',
'selected': 'assets/audio/selected.mp3', 'selected': 'assets/audio/selected.mp3',
'FC-Sonw': 'assets/audio/FC-Sonw.mp3',
'apple-demo': 'assets/audio/apple-demo.mp3',
'bee-demo': 'assets/audio/bee-demo.mp3'
}; };
export {localImages, localAudios}; export {localImages, localAudios};
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