You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
777 lines
27 KiB
777 lines
27 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../../FrameWork/Event/EventMgr";
|
|
import User from "../../FrameWork/User/User";
|
|
import AppPlatform from "../../FrameWork/Util/AppPlatform";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import LevelUpManager from "../Manager/LevelUpManager";
|
|
import UserManager from "../Manager/UserManager";
|
|
// import buildManager from "../Manager/buildManager";
|
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
|
import ViewManageConfig from "../PrefabManager/ViewManageConfig";
|
|
import PinTuFinish from "./PinTuFinish";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class PinTuStart extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
areaMove: cc.Node = null;
|
|
@property(cc.Node)
|
|
areaFangzhi: cc.Node = null;
|
|
|
|
|
|
areaMoveArray: cc.Node[] = [] //因为会随着zindex的变化children会改变所以直接用数组存起来
|
|
|
|
pituNum = 0
|
|
pituMaxNum = 0
|
|
|
|
name = ''
|
|
nodeZindex = 1
|
|
isAutoPin = false
|
|
setPintuName(name) {
|
|
this.name = name
|
|
}
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
pintuArray = null
|
|
// onLoad () {}
|
|
|
|
checkMove = null
|
|
|
|
|
|
// manHanQuanXiFragmentMap = [
|
|
// [1,1709],
|
|
// [2,1713],
|
|
// [3,1712],
|
|
// [4,1710],
|
|
// [5,1714],
|
|
// [6,1716],
|
|
// [7,1715],
|
|
// [8,1711]
|
|
// ]
|
|
|
|
miaozhuanAllLab: cc.Label = null
|
|
|
|
findAreaFangzhiNode: cc.Node = null
|
|
start() {
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.ExitBtnEvent, () => {
|
|
if (User.getStatistics('smallgameptCurGoLevel') > 0) {
|
|
PrefabManage.loadPrefabByType(GameType.SuccessGetMoney, null, (prefab) => {
|
|
prefab.getComponent('SuccessGetMoney').setViewDate("", 1, 5)
|
|
})
|
|
}
|
|
}, this)
|
|
|
|
// let isEnterManhan = buildManager.getIsEnterManHan(this.name)
|
|
|
|
// let buildName = buildManager.getBuildNameByCaipuName(this.name)
|
|
let shouyi = 10//buildManager.getBuildIncome(buildName)
|
|
let lay = this.node.getChildByName('完成拼图').getChildByName('lay')
|
|
this.miaozhuanAllLab = lay.getChildByName('lab1').getComponent(cc.Label)
|
|
this.miaozhuanAllLab.string = Common5.getNumberChangeHanzi(shouyi * 15) + ''
|
|
|
|
|
|
this.checkMove = this.node.getChildByName('checkMove')
|
|
let pintuArray = []//User.getPintuArray()
|
|
// if( !pintuArray[ this.name ] ){
|
|
|
|
let temp = []
|
|
for (let i = 0; i < this.areaFangzhi.childrenCount; i++) {
|
|
let temp2 = []
|
|
if (i == 0 || i == this.areaFangzhi.childrenCount - 1) {
|
|
temp2 = [i, i]
|
|
|
|
} else {
|
|
temp2 = [i, -1]
|
|
|
|
}
|
|
|
|
temp.push(temp2)
|
|
}
|
|
|
|
pintuArray[this.name] = temp
|
|
// User.setPintuArray(pintuArray)
|
|
|
|
this.pintuArray = pintuArray[this.name]
|
|
// }else{
|
|
// this.pintuArray = pintuArray[ this.name ]
|
|
// }
|
|
console.log(this.pintuArray, 'pintuArray++++++++++===')
|
|
|
|
|
|
PrefabManage.preloadPrefabArray([ViewManageConfig.PinTuFinish])
|
|
this.pituMaxNum = this.areaMove.childrenCount
|
|
this.refreshBtn()
|
|
this.randFangzhiPosi()
|
|
|
|
|
|
// if(isEnterManhan){
|
|
// //拼图
|
|
// let btn = this.node.getChildByName('按钮自动拼图')
|
|
// btn.active = false
|
|
// this.node.getChildByName('完成拼图').active = false
|
|
// for(let i = 0; i<this.areaMove.childrenCount;i++){
|
|
// this.areaMove.children[i].active = false
|
|
// }
|
|
// for(let i = 0; i<this.areaFangzhi.childrenCount;i++){
|
|
// this.areaFangzhi.children[i].active = true
|
|
// }
|
|
// this.node.getChildByName('满汉全席碎片').active = true
|
|
// this.node.getChildByName('发光碎片').active = true
|
|
|
|
// //
|
|
// let index = buildManager.getIsEnterManHanSuiPianIndex(this.name)
|
|
|
|
// this.openTouchEvent2(this.node.getChildByName('发光碎片'))
|
|
|
|
// }else{
|
|
|
|
this.node.getChildByName('满汉全席碎片').active = false
|
|
this.node.getChildByName('发光碎片').active = false
|
|
|
|
for (let i = 0; i < this.areaFangzhi.childrenCount; i++) {
|
|
if (i == 0 || i == this.areaFangzhi.childrenCount - 1) {
|
|
this.areaFangzhi.children[i].active = true
|
|
} else {
|
|
this.areaFangzhi.children[i].active = false
|
|
}
|
|
// this.areaFangzhi.children[i].active = false
|
|
}
|
|
for (let i = 0; i < this.areaMove.childrenCount; i++) {
|
|
this.areaMove.children[i].active = true
|
|
}
|
|
|
|
//放置位置
|
|
for (let i = 0; i < this.pintuArray.length; i++) {
|
|
let array = this.pintuArray[i]
|
|
if (array[1] != -1) {
|
|
let endNode = this.areaFangzhi.children[array[0]]
|
|
let startNode = this.areaMove.children[array[1]]
|
|
startNode.scale = 1
|
|
startNode.angle = 0
|
|
startNode['moveStart'] = false
|
|
Common5.setNodeToTargetPos(startNode, endNode)
|
|
}
|
|
}
|
|
|
|
for (let i = 0; i < this.areaMove.childrenCount; i++) {
|
|
let node = this.areaMove.children[i]
|
|
this.areaMoveArray.push(node)
|
|
}
|
|
|
|
//计算中
|
|
this.countPintuNum()
|
|
// }
|
|
|
|
|
|
// for(let i = 0; i<this.areaFangzhi.childrenCount;i++){
|
|
// if(this.areaFangzhi.children[i].active){
|
|
// this.pituNum++ //每次都有两个已经出现的
|
|
// }
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
countPintuNum() {
|
|
let pituNum = 0
|
|
for (let i = 0; i < this.pintuArray.length; i++) {
|
|
let array = this.pintuArray[i]
|
|
if (array[0] == array[1]) {
|
|
pituNum++
|
|
}
|
|
}
|
|
|
|
this.pituNum = pituNum
|
|
|
|
// let pintuArray = User.getPintuArray()
|
|
// pintuArray[ this.name ] = this.pintuArray
|
|
|
|
// User.setPintuArray(pintuArray)
|
|
console.log(this.pituNum, '计算拼图数据')
|
|
//console.log(this.pintuArray , '计算拼图数据 pintuArray')
|
|
if (this.pituNum >= this.pituMaxNum) {
|
|
this.showResult()
|
|
}
|
|
}
|
|
|
|
randFangzhiPosi() {
|
|
|
|
for (let i = 0; i < this.areaMove.childrenCount; i++) {
|
|
if (this.areaMove.children[i].active = true) {
|
|
let randPosX = Common5.getRandomNum(-220, 220)
|
|
let randPosY = Common5.getRandomNum(-50, 50)
|
|
let node = this.areaMove.children[i]
|
|
// node.scale = 0.5
|
|
|
|
node.setPosition(cc.v2(randPosX, randPosY))
|
|
|
|
node.angle = Common5.getRandomNum(-20, 20)
|
|
node['recoveryPosi'] = node.getPosition()
|
|
node['recoveryAngle'] = node.angle
|
|
node['recoveryScale'] = node.scale
|
|
node['registerIndex'] = i
|
|
node['moveStart'] = true
|
|
//注册节点
|
|
// node['targetNode'] = this.areaFangzhi.children[i]
|
|
// this.areaFangzhi.children[i].active = false
|
|
// node.active = true
|
|
this.openTouchEvent(node)
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
openTouchEvent2(node) {
|
|
|
|
node.on(cc.Node.EventType.TOUCH_END, this.touchEndNode2, this)
|
|
}
|
|
closeTouchEvent2(node) {
|
|
|
|
node.on(cc.Node.EventType.TOUCH_END, this.touchEndNode2, this)
|
|
}
|
|
|
|
touchEndNode2(event) {
|
|
// //发现碎片
|
|
// let mabu = this.node.getChildByName('发光碎片').getChildByName('mabu')
|
|
// if(mabu){
|
|
// mabu.active = true
|
|
// mabu.getComponent(sp.Skeleton).setAnimation(0, 'ma', false)
|
|
// this.scheduleOnce(()=>{
|
|
// mabu.active = false
|
|
// this.node.getChildByName('满汉全席碎片').active = true
|
|
// this.node.getChildByName('发光碎片').active = false
|
|
// let index = buildManager.getIsEnterManHanSuiPianIndex(this.name)
|
|
// this.areaFangzhi.children[index].active = false
|
|
// PrefabManage.showTextTips('获得,满汉全席碎片'+(index-3))
|
|
// this.closeTouchEvent2(event.target)
|
|
// this.checkTaskFinsh()
|
|
// },1.5)
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openTouchEvent(node) {
|
|
node.on(cc.Node.EventType.TOUCH_START, this.touchStartNode, this)
|
|
node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMoveNode, this)
|
|
node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEndNode, this)
|
|
node.on(cc.Node.EventType.TOUCH_END, this.touchEndNode, this)
|
|
}
|
|
|
|
closeTouchEvent(node: cc.Node) {
|
|
node.off(cc.Node.EventType.TOUCH_START, this.touchStartNode, this)
|
|
node.off(cc.Node.EventType.TOUCH_MOVE, this.touchMoveNode, this)
|
|
node.off(cc.Node.EventType.TOUCH_CANCEL, this.touchEndNode, this)
|
|
node.off(cc.Node.EventType.TOUCH_END, this.touchEndNode, this)
|
|
}
|
|
|
|
touchStartNode(event) {
|
|
// event.target.scale = 1
|
|
// event.target.angle = 0
|
|
|
|
event.target.zIndex = this.nodeZindex++
|
|
cc.tween(event.target)
|
|
.to(0.1, { scale: 1, angle: 0 })
|
|
.start()
|
|
}
|
|
|
|
touchMoveNode(event) {
|
|
let target = event.target
|
|
|
|
let posi = event.getLocation()//世界坐标
|
|
posi = target.parent.convertToNodeSpaceAR(posi)
|
|
target.setPosition(posi)
|
|
}
|
|
|
|
getPosiNode(fromNode, toNode) {
|
|
return fromNode.parent.convertToNodeSpaceAR(cc.v2(toNode.convertToWorldSpaceAR(cc.v2(0, 0))))
|
|
}
|
|
|
|
|
|
touchEndNode(event) {
|
|
let target = event.target;
|
|
|
|
let registerIndex = target['registerIndex'];
|
|
if (Common5.checkIntersectsBox(target, this.checkMove)) {
|
|
for (let i = 0; i < this.pintuArray.length; i++) {
|
|
//找到那个图片
|
|
if (this.pintuArray[i][1] == registerIndex) {
|
|
this.pintuArray[i][1] = -1
|
|
break
|
|
}
|
|
}
|
|
this.countPintuNum()
|
|
|
|
this.nodeMoveToRecovery(target, target["recoveryPosi"], target["recoveryAngle"], target['recoveryScale'])
|
|
} else {
|
|
//可能有多个重合的拼图
|
|
//找出距离最近的拼图
|
|
|
|
let findMinLeng = 0
|
|
let findMinNode: cc.Node = null
|
|
let posi: cc.Vec2 = event.getLocation()
|
|
|
|
let findX = -1
|
|
for (let i = 0; i < this.areaFangzhi.childrenCount; i++) {
|
|
if (Common5.checkIntersectsBox(target, this.areaFangzhi.children[i])) {
|
|
let targetLocalPos = this.areaFangzhi.children[i].getPosition()
|
|
//目标节点的世界坐标
|
|
let targetWorldPos = this.areaFangzhi.children[i].parent.convertToWorldSpaceAR(targetLocalPos)
|
|
|
|
let targetLocalPos2 = target.getPosition()
|
|
//目标节点的世界坐标
|
|
let targetWorldPos2 = target.parent.convertToWorldSpaceAR(targetLocalPos2)
|
|
|
|
|
|
let dis = targetWorldPos2.sub(targetWorldPos).mag()
|
|
if (findMinLeng == 0) {
|
|
findMinLeng = dis
|
|
findMinNode = this.areaFangzhi.children[i]
|
|
findX = i
|
|
}
|
|
|
|
if (findMinLeng > dis) {
|
|
findMinLeng = dis
|
|
findMinNode = this.areaFangzhi.children[i]
|
|
findX = i
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (findMinNode) {
|
|
|
|
if (this.pintuArray[findX][1] == -1) {
|
|
//
|
|
console.log('直接进行位置转移')
|
|
let posi = Common5.getNodeToTargetPos(target, findMinNode)
|
|
|
|
cc.tween(target)
|
|
.to(0.2, { x: posi.x, y: posi.y })
|
|
.start()
|
|
|
|
if (target['moveStart']) {
|
|
//直接移动
|
|
console.log('直接进行位置转移2 直接移动')
|
|
} else {
|
|
//原来的地方也需要重新变为空
|
|
console.log('直接进行位置转移2 原来的地方也需要重新变为空')
|
|
for (let i = 0; i < this.pintuArray.length; i++) {
|
|
//找到那个图片
|
|
if (this.pintuArray[i][1] == registerIndex) {
|
|
this.pintuArray[i][1] = -1
|
|
break
|
|
}
|
|
}
|
|
}
|
|
this.pintuArray[findX][1] = registerIndex //当前拼图状态
|
|
this.countPintuNum()
|
|
target['moveStart'] = false
|
|
|
|
} else if (this.pintuArray[findX][1] != -1) {
|
|
|
|
if (target['moveStart']) {
|
|
//重叠的话上面的图片回到原位,当前图片移动到这上面
|
|
console.log('重叠的话上面的图片回到原位,当前图片移动到这上面')
|
|
let findChongdieIndex = this.pintuArray[findX][1]
|
|
let findChongdieNode = this.areaMoveArray[findChongdieIndex]
|
|
this.nodeMoveToRecovery(findChongdieNode, findChongdieNode["recoveryPosi"], findChongdieNode["recoveryAngle"], findChongdieNode['recoveryScale'])
|
|
|
|
this.pintuArray[findX][1] = registerIndex //当前拼图状态
|
|
this.countPintuNum()
|
|
let posi = Common5.getNodeToTargetPos(target, findMinNode)
|
|
target['moveStart'] = false
|
|
cc.tween(target)
|
|
.to(0.2, { x: posi.x, y: posi.y })
|
|
.start()
|
|
} else {
|
|
//交换图片
|
|
console.log('交换图片,交换位置')
|
|
|
|
target['moveStart'] = false
|
|
let findChongdieIndex = this.pintuArray[findX][1]
|
|
let findChongdieNode = this.areaMoveArray[findChongdieIndex]
|
|
|
|
let findTargetIndex = -1
|
|
for (let i = 0; i < this.pintuArray.length; i++) {
|
|
//找到那个图片
|
|
if (this.pintuArray[i][1] == registerIndex) {
|
|
findTargetIndex = i
|
|
break
|
|
}
|
|
}
|
|
|
|
//交换数据
|
|
this.pintuArray[findTargetIndex][1] = findChongdieIndex
|
|
this.pintuArray[findX][1] = registerIndex
|
|
|
|
//交换位置
|
|
this.countPintuNum()
|
|
|
|
|
|
let posi = Common5.getNodeToTargetPos(target, findMinNode)
|
|
cc.tween(target)
|
|
.to(0.2, { x: posi.x, y: posi.y })
|
|
.start()
|
|
|
|
let findMinNode2 = this.areaFangzhi.children[this.pintuArray[findTargetIndex][0]]
|
|
let posi2 = Common5.getNodeToTargetPos(findChongdieNode, findMinNode2)
|
|
cc.tween(findChongdieNode)
|
|
.to(0.2, { x: posi2.x, y: posi2.y })
|
|
.start()
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
autoPintu(target, findMinNode, findX) {
|
|
|
|
let registerIndex = target['registerIndex'];
|
|
if (findMinNode) {
|
|
|
|
if (this.pintuArray[findX][1] == -1) {
|
|
//
|
|
console.log('直接进行位置转移')
|
|
let posi = Common5.getNodeToTargetPos(target, findMinNode)
|
|
|
|
cc.tween(target)
|
|
.to(0.2, { x: posi.x, y: posi.y })
|
|
.start()
|
|
|
|
if (target['moveStart']) {
|
|
//直接移动
|
|
console.log('直接进行位置转移2 直接移动')
|
|
} else {
|
|
//原来的地方也需要重新变为空
|
|
console.log('直接进行位置转移2 原来的地方也需要重新变为空')
|
|
for (let i = 0; i < this.pintuArray.length; i++) {
|
|
//找到那个图片
|
|
if (this.pintuArray[i][1] == registerIndex) {
|
|
this.pintuArray[i][1] = -1
|
|
break
|
|
}
|
|
}
|
|
}
|
|
this.pintuArray[findX][1] = registerIndex //当前拼图状态
|
|
this.countPintuNum()
|
|
target['moveStart'] = false
|
|
|
|
} else if (this.pintuArray[findX][1] != -1) {
|
|
|
|
if (target['moveStart']) {
|
|
//重叠的话上面的图片回到原位,当前图片移动到这上面
|
|
console.log('重叠的话上面的图片回到原位,当前图片移动到这上面')
|
|
let findChongdieIndex = this.pintuArray[findX][1]
|
|
let findChongdieNode = this.areaMoveArray[findChongdieIndex]
|
|
this.nodeMoveToRecovery(findChongdieNode, findChongdieNode["recoveryPosi"], findChongdieNode["recoveryAngle"], findChongdieNode['recoveryScale'])
|
|
|
|
this.pintuArray[findX][1] = registerIndex //当前拼图状态
|
|
this.countPintuNum()
|
|
let posi = Common5.getNodeToTargetPos(target, findMinNode)
|
|
target['moveStart'] = false
|
|
cc.tween(target)
|
|
.to(0.2, { x: posi.x, y: posi.y })
|
|
.start()
|
|
} else {
|
|
//交换图片
|
|
console.log('交换图片,交换位置')
|
|
|
|
target['moveStart'] = false
|
|
let findChongdieIndex = this.pintuArray[findX][1]
|
|
let findChongdieNode = this.areaMoveArray[findChongdieIndex]
|
|
|
|
let findTargetIndex = -1
|
|
for (let i = 0; i < this.pintuArray.length; i++) {
|
|
//找到那个图片
|
|
if (this.pintuArray[i][1] == registerIndex) {
|
|
findTargetIndex = i
|
|
break
|
|
}
|
|
}
|
|
|
|
//交换数据
|
|
this.pintuArray[findTargetIndex][1] = findChongdieIndex
|
|
this.pintuArray[findX][1] = registerIndex
|
|
|
|
//交换位置
|
|
this.countPintuNum()
|
|
|
|
|
|
let posi = Common5.getNodeToTargetPos(target, findMinNode)
|
|
cc.tween(target)
|
|
.to(0.2, { x: posi.x, y: posi.y })
|
|
.start()
|
|
|
|
let findMinNode2 = this.areaFangzhi.children[this.pintuArray[findTargetIndex][0]]
|
|
let posi2 = Common5.getNodeToTargetPos(findChongdieNode, findMinNode2)
|
|
cc.tween(findChongdieNode)
|
|
.to(0.2, { x: posi2.x, y: posi2.y })
|
|
.start()
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
showResult() {
|
|
|
|
//取消注册
|
|
for (let i = 0; i < this.areaMoveArray.length; i++) {
|
|
this.closeTouchEvent(this.areaMoveArray[i])
|
|
}
|
|
|
|
// let pintuArray = User.getPintuArray()
|
|
|
|
// delete pintuArray[ this.name ]
|
|
// User.setPintuArray(pintuArray)
|
|
|
|
// let buildName = buildManager.getBuildNameByCaipuName(this.name)
|
|
// buildManager.setPintuFinish(buildName)
|
|
//任务的拼图菜谱和这个name
|
|
// let pinTuId = buildManager.getBuildIdByName(buildName)
|
|
// TaskManager.checkIsFinishPinTuTask(pinTuId)
|
|
// TaskManager.checkIsFinishPinTuTaskArray() //检测拼图多个
|
|
|
|
let faguang = this.node.getChildByName('发光')
|
|
let xingxing = this.node.getChildByName('星星')
|
|
faguang.zIndex = 9999
|
|
faguang.active = true
|
|
xingxing.active = true
|
|
faguang.getComponent(sp.Skeleton).setAnimation(0, 'animation', false)
|
|
|
|
this.scheduleOnce(() => {
|
|
PrefabManage.loadPrefabByType(GameType.PinTuFinish, null, (prefabNode) => {
|
|
prefabNode.getComponent(PinTuFinish).setPintuName(this.name);
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
})
|
|
}, 1.5)
|
|
|
|
}
|
|
|
|
|
|
nodeMoveToRecovery(node, oldPosi: cc.Vec2, angleNum: number, scaleNum: number) {
|
|
|
|
node['moveStart'] = true
|
|
cc.tween(node)
|
|
.to(0.1, { x: oldPosi.x, y: oldPosi.y, angle: angleNum, scale: scaleNum })
|
|
|
|
.start()
|
|
}
|
|
|
|
refreshBtn() {
|
|
let btn = this.node.getChildByName('按钮自动拼图')
|
|
let adIcon = btn.getChildByName('蓝色按钮视频')
|
|
let lab = btn.getChildByName('lab').getComponent(cc.Label)
|
|
// let buildName = buildManager.getBuildNameByCaipuName(this.name)
|
|
let num = 5//buildManager.getFreePintuNum(buildName)
|
|
if (num > 0) {
|
|
adIcon.active = false
|
|
lab.string = num + '/5'
|
|
} else {
|
|
adIcon.active = true
|
|
lab.string = '0/5'
|
|
}
|
|
}
|
|
|
|
|
|
addPintuTime() {
|
|
let btn = this.node.getChildByName('按钮自动拼图')
|
|
let adIcon = btn.getChildByName('蓝色按钮视频')
|
|
// let buildName = buildManager.getBuildNameByCaipuName(this.name)
|
|
if (adIcon.active) {
|
|
let tab = {
|
|
onClose: (finish) => {
|
|
if (finish) {
|
|
Common5.ReportDY("inLevel", "自动拼图-AD-增加次数");
|
|
// buildManager.setFreePintuNum(buildName,5)
|
|
this.refreshBtn()
|
|
} else {
|
|
Common5.showTips_custom("广告未观看完");
|
|
}
|
|
}, onFailed: () => {
|
|
|
|
}
|
|
}
|
|
AppPlatform.playVideo_custom(tab)
|
|
} else {
|
|
//自动拼图
|
|
if (this.isAutoPin) {
|
|
PrefabManage.showTextTips('不要操作太快哦!')
|
|
return
|
|
}
|
|
this.isAutoPin = true
|
|
|
|
// let num = buildManager.getFreePintuNum(buildName)
|
|
// num--
|
|
// buildManager.setFreePintuNum(buildName,num)
|
|
this.refreshBtn()
|
|
|
|
let findIndex = 0
|
|
for (let i = 0; i < this.pintuArray.length; i++) {
|
|
let array = this.pintuArray[i]
|
|
if (array[0] != array[1]) {
|
|
findIndex = i
|
|
break
|
|
}
|
|
}
|
|
|
|
let target = null
|
|
for (let i = 0; i < this.areaMoveArray.length; i++) {
|
|
if (this.areaMoveArray[i]['registerIndex'] == this.pintuArray[findIndex][0]) {
|
|
target = this.areaMoveArray[i]
|
|
break
|
|
}
|
|
}
|
|
//找出不对劲的图片给他摆正
|
|
this.scheduleOnce(() => {
|
|
this.isAutoPin = false
|
|
}, 0.2)
|
|
if (!target) {
|
|
|
|
return
|
|
}
|
|
|
|
let findMinNode = this.areaFangzhi.children[this.pintuArray[findIndex][0]] //找到移动的地方
|
|
cc.tween(target)
|
|
.to(0.1, { scale: 1, angle: 0 })
|
|
.start()
|
|
this.autoPintu(target, findMinNode, this.pintuArray[findIndex][0])
|
|
//fix me
|
|
// let findNode = null
|
|
// for(let i=0;i<this.areaMove.childrenCount;i++){
|
|
// if(this.areaMove.children[i].active){
|
|
// findNode = this.areaMove.children[i]
|
|
// break
|
|
// }
|
|
// }
|
|
// if(findNode){
|
|
// this.autoPintu(findNode)
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
}
|
|
// update (dt) {}
|
|
|
|
|
|
checkTaskFinsh() {
|
|
// let mainTaskInfo:any = TaskManager.getCurUnLockMainTaskInfo()
|
|
// let mainId = mainTaskInfo.Id
|
|
// let manHanQuanXiFragment = User.getManHanQuanXiFragment()
|
|
|
|
// let BuildNameByCaipuId = buildManager.getBuildNameByCaipuId(this.name)
|
|
// let Index= -1
|
|
// for(let i=0;i<buildManager.manHanQuanXiFragmentMap.length;i++){
|
|
// let data = buildManager.manHanQuanXiFragmentMap[i]
|
|
// if(data[1] == BuildNameByCaipuId){
|
|
// Index = i
|
|
// break
|
|
// }
|
|
// }
|
|
// if(mainId != MainTaskIdEnum.MainTask_None && mainId == MainTaskIdEnum.MainTask_1710){
|
|
// //进去
|
|
// let taskConfig = TaskManager.getTaskConfigById(mainId)
|
|
// let taskManhan = taskConfig.manHanQuanXiFragment
|
|
|
|
// if(manHanQuanXiFragment[Index] == 1){
|
|
// manHanQuanXiFragment[Index] = 2
|
|
// }
|
|
|
|
// let isHaveAll = this.checkTask(taskManhan)
|
|
|
|
// if(isHaveAll){
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1710);
|
|
// TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1711);
|
|
|
|
// }
|
|
|
|
// }else if(mainId != MainTaskIdEnum.MainTask_None && mainId == MainTaskIdEnum.MainTask_1711){
|
|
|
|
// }else if(mainId != MainTaskIdEnum.MainTask_None && mainId == MainTaskIdEnum.MainTask_1712){
|
|
// let taskConfig = TaskManager.getTaskConfigById(mainId)
|
|
// let taskManhan = taskConfig.manHanQuanXiFragment
|
|
|
|
// if(manHanQuanXiFragment[Index] == 1){
|
|
// manHanQuanXiFragment[Index] = 2
|
|
// }
|
|
|
|
// let isHaveAll = this.checkTask(taskManhan)
|
|
|
|
// if(isHaveAll){
|
|
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1712);
|
|
// TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1713);
|
|
|
|
// }
|
|
// }
|
|
}
|
|
|
|
//检测满汉全席
|
|
checkTask(taskManhan) {
|
|
// let manHanQuanXiFragment = User.getManHanQuanXiFragment()
|
|
|
|
// let isHaveAll = true
|
|
// for(let i = 0;i<taskManhan.length;i++){
|
|
// let id = taskManhan[i]
|
|
|
|
// let Index= -1
|
|
// for(let i=0;i<buildManager.manHanQuanXiFragmentMap.length;i++){
|
|
// let data = buildManager.manHanQuanXiFragmentMap[i]
|
|
// if(data[1] == id){
|
|
// Index = i
|
|
// break
|
|
// }
|
|
// }
|
|
|
|
// if(manHanQuanXiFragment[Index] < 2){
|
|
// isHaveAll = false
|
|
// break
|
|
// }
|
|
|
|
// }
|
|
|
|
// return isHaveAll
|
|
}
|
|
|
|
|
|
onTouchClose() {
|
|
if (User.getStatistics('smallgameptCurGoLevel') > 0) {
|
|
UserManager.addMoney(LevelUpManager.levelUpSpned(), this.node)
|
|
}
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
}
|
|
}
|
|
|