Commit 24356bfa authored by 李维's avatar 李维

dev commit

parent 767893a3
......@@ -120,6 +120,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// ------------ 游戏逻辑数据 ------------
m_currentSelectedCard = ""
m_allUpCards = []
// ------------------------------------
......@@ -133,7 +134,7 @@ export class PlayComponent implements OnInit, OnDestroy {
g_ForceChangeDefaultRole = false // 强制当前角色为默认角色
g_EnableTestSendEvent = false // 发送模拟Web数据
g_EnableLeftCornerTest= false // 测试左上角图标
g_enableConsoleLog = false;
g_enableConsoleLog = true;
// ------------------------------------
......@@ -197,7 +198,8 @@ export class PlayComponent implements OnInit, OnDestroy {
}
cleanGameVar(){
this.m_currentSelectedCard = ""
this.m_allUpCards = []
}
startGame(){
......@@ -474,7 +476,6 @@ export class PlayComponent implements OnInit, OnDestroy {
slider.enableSlider = false;
slider.release = ()=>{
console.log("Release Slider")
slider.enableSlider= false;
this.g_enableMapDown = true;
longAudio.refreshAudioProgress();
......@@ -630,7 +631,6 @@ export class PlayComponent implements OnInit, OnDestroy {
let totalWidth = 0
let totalNum = cardAll.length
cardAll.forEach((element, index) => {
console.log("Label width:" + element.width)
if(index==0 || index==(totalNum-1)){
totalWidth += (element.width/2) + spaceing
}else{
......@@ -642,10 +642,8 @@ export class PlayComponent implements OnInit, OnDestroy {
let fontSize = 50;
let adjustSX = 1
if(totalWidth > 1214){
// adjustSX = (1200 / totalWidth)
fontSize = baseFontsize * (1214 / (totalWidth * 1.65))
}
console.log(totalWidth, fontSize)
cardAll.forEach((card, index)=>{
card.fontSize = fontSize
card.refreshSize()
......@@ -709,7 +707,7 @@ export class PlayComponent implements OnInit, OnDestroy {
y: pos.y
}
})
this.m_allUpCards.push(`card-up-${index}`)
// 连接节点
let dot = this.g_cartoon.createImage("icon_dian1", (w, h)=>{
return {
......@@ -726,6 +724,24 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(dot, zIndexMap.dot);
card.ref.dot = dot;
// 链接关系
card.lineTo = this.g_formData.textUp[index].lineTo.split("-")
card.complete = false
card.checkLink = (id)=>{
this.log(id, card.lineTo)
let index = id.split("-")[2]
let z = card.lineTo.indexOf(index)
if(z==-1){
return false
}else{
card.lineTo.splice(index, 1)
if(card.lineTo.length==0){
card.complete = true;
}
return true
}
}
card.showHideDoc = (status)=>{
if(status){
this.showItemDot(card.ref)
......@@ -776,11 +792,22 @@ export class PlayComponent implements OnInit, OnDestroy {
card.showHideDoc(true)
if(this.m_currentSelectedCard){
if(this.m_currentSelectedCard.indexOf("down")!=-1){
this.lineTo(this.m_currentSelectedCard, card.id, true, ()=>{
card.showStart(()=>{
this.m_currentSelectedCard = null
this.g_enableMapDown = true;
})
let result = false
if( this.m_currentSelectedCard.indexOf("up")!= -1){
result = this.g_cartoon.getCartoonElement(this.m_currentSelectedCard).checkLink(card.id)
}else{
result = this.g_cartoon.getCartoonElement(card.id).checkLink(this.m_currentSelectedCard)
}
this.lineTo(this.m_currentSelectedCard, card.id, result, ()=>{
if(!result){
this.g_cartoon.getCartoonElement(this.m_currentSelectedCard).showHideDoc(false)
card.showHideDoc(false)
}
this.m_currentSelectedCard = null
this.g_enableMapDown = true;
if(this.checkEndGame()){
this.endGame()
}
})
}else{
this.g_cartoon.getCartoonElement(this.m_currentSelectedCard).showHideDoc(false)
......@@ -819,7 +846,6 @@ export class PlayComponent implements OnInit, OnDestroy {
let totalWidth = 0
let totalNum = cardAll.length
cardAll.forEach((element, index) => {
console.log("Label width:" + element.width)
if(index==0 || index==(totalNum-1)){
totalWidth += (element.width/2) + spaceing
}else{
......@@ -833,7 +859,6 @@ export class PlayComponent implements OnInit, OnDestroy {
if(totalWidth > 1700){
fontSize = baseFontsize * (1720 / (totalWidth * 2.2))
}
console.log(totalWidth, fontSize)
cardAll.forEach((card, index)=>{
card.fontSize = fontSize
card.refreshSize()
......@@ -960,11 +985,22 @@ export class PlayComponent implements OnInit, OnDestroy {
card.showHideDoc(true)
if(this.m_currentSelectedCard){
if(this.m_currentSelectedCard.indexOf("up")!=-1){
this.lineTo(this.m_currentSelectedCard, card.id, false, ()=>{
this.g_cartoon.getCartoonElement(this.m_currentSelectedCard).showHideDoc(false)
card.showHideDoc(false)
let result = false
if( this.m_currentSelectedCard.indexOf("up")!= -1){
result = this.g_cartoon.getCartoonElement(this.m_currentSelectedCard).checkLink(card.id)
}else{
result = this.g_cartoon.getCartoonElement(card.id).checkLink(this.m_currentSelectedCard)
}
this.lineTo(this.m_currentSelectedCard, card.id, result, ()=>{
if(!result){
this.g_cartoon.getCartoonElement(this.m_currentSelectedCard).showHideDoc(false)
card.showHideDoc(false)
}
this.m_currentSelectedCard = null
this.g_enableMapDown = true;
if(this.checkEndGame()){
this.endGame()
}
})
}else{
this.g_cartoon.getCartoonElement(this.m_currentSelectedCard).showHideDoc(false)
......@@ -1036,8 +1072,20 @@ export class PlayComponent implements OnInit, OnDestroy {
line_2.anchorY = 0;
line_2.id = UUID.UUID();
line_1.visible = false
line_2.visible = false
const line_3 = new MySprite();
line_3.init(this.g_cartoon.images.get(color));
line_3.setScaleXY(this.g_mapScale)
line_3.anchorX = (line_3.width - line_3.height / 2) / line_3.width;
line_3.anchorY = 0;
line_3.id = UUID.UUID();
let target_1 = this.g_cartoon.getCartoonElement(T1).ref.dot
let target_2 = this.g_cartoon.getCartoonElement(T2).ref.dot
let target_3 = this.g_cartoon.getCartoonElement(T1).ref.dot
if(isCorrect){
this.g_cartoon.getCartoonElement(T1).lined = true
this.g_cartoon.getCartoonElement(T2).lined = true
......@@ -1051,9 +1099,12 @@ export class PlayComponent implements OnInit, OnDestroy {
line_1.y = target_2.y;
line_2.x = target_1.x;
line_2.y = target_1.y;
line_3.x = target_2.x;
line_3.y = target_2.y;
this.render(line_1, zIndexMap.line);
this.render(line_2, zIndexMap.line);
this.render(line_3, zIndexMap.line);
if (middlePos.x < line_1.x) {
line_1.scaleX *= -1;
......@@ -1061,6 +1112,29 @@ export class PlayComponent implements OnInit, OnDestroy {
if (middlePos.x < line_2.x) {
line_2.scaleX *= -1;
}
if (target_3.x < line_3.x) {
line_3.scaleX *= -1;
}
const angle_3 = getAngleByPos(line_3.x, line_3.y, target_3.x, target_3.y);
line_3.rotation = angle_3 + 180;
const distance_3 = getPosDistance(line_3.x, line_3.y, target_3.x, target_3.y);
const targetS_3 = distance_3 / line_3.height;
tweenChange( line_3, { scaleY: targetS_3 }, 1.2, () => {
if(isCorrect){
line_1.visible = false
line_2.visible = false
callback && callback(line_1, line_2)
}else{
line_1.visible = true
line_2.visible = true
this.deleteElementInRender(line_3.id)
this.cutLine(line_1, line_2, ()=>{
callback && callback(line_1, line_2)
})
}
}, TWEEN.Easing.Sinusoidal.Out);
const angle_1 = getAngleByPos(line_1.x, line_1.y, middlePos.x, middlePos.y);
line_1.rotation = angle_1 + 180;
......@@ -1072,15 +1146,7 @@ export class PlayComponent implements OnInit, OnDestroy {
line_2.rotation = angle_2 + 180;
const distance_2 = getPosDistance(line_2.x, line_2.y, middlePos.x, middlePos.y);
const targetS_2 = distance_2 / line_2.height;
tweenChange( line_2, { scaleY: targetS_2 }, 1, () => {
if(isCorrect){
callback && callback(line_1, line_2)
}else{
this.cutLine(line_1, line_2, ()=>{
callback && callback(line_1, line_2)
})
}
}, TWEEN.Easing.Sinusoidal.Out);
tweenChange( line_2, { scaleY: targetS_2 }, 1, () => {}, TWEEN.Easing.Sinusoidal.Out);
}
// 生长连接点
......@@ -1145,7 +1211,6 @@ cutLine(line1, line2, callback?){
cutter.ref.visible = true
tweenChange(cutter.ref, middlePos, 1, ()=>{
console.log(line1.rotation, line2.rotation)
cutter.ref.visible = false
cutter.ref.x = cutter.initX
cutter.ref.y = cutter.initY
......@@ -1161,7 +1226,15 @@ cutLine(line1, line2, callback?){
},TWEEN.Easing.Cubic.Out)
}
checkEndGame(){
let result = true
this.m_allUpCards.forEach(id=>{
if(!this.g_cartoon.getCartoonElement(id).complete){
result = false
}
})
return result
}
......
......@@ -14,9 +14,9 @@ export default {
// {text:"make friends", lineTo:""}
// ],
textUp:[
{text:"ABCD", lineTo:""},{text:"ABCDEFG", lineTo:""},{text:"ABCDEF", lineTo:""},{text:"ABCD EFG", lineTo:""},
{text:"ABCD", lineTo:""},{text:"ABCD", lineTo:""},{text:"ABCD", lineTo:""},{text:"ABCD", lineTo:""},
{text:"ABCD", lineTo:""}
{text:"ABCD", lineTo:"1-2-4"},{text:"ABCDEFG", lineTo:"1"},{text:"ABCDEF", lineTo:"2-4"},{text:"ABCD EFG", lineTo:"1-2-3-4"},
{text:"ABCD", lineTo:"2-4"},{text:"ABCD", lineTo:"1-4"},{text:"ABCD", lineTo:"2-3-4"},{text:"ABCD", lineTo:"1-2-3-4"},
{text:"ABCD", lineTo:"2-3"}
],
// textDown:[
// {text:"it's so much fun", lineTo:""},{text:"lound", lineTo:""},{text:"very happy", lineTo:""},{text:"sun", lineTo:""},{text:"at the park", lineTo:""},
......
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