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.
953 lines
40 KiB
953 lines
40 KiB
|
|
import { ryw_Event } from "../../../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../../../FrameWork/Event/EventMgr";
|
|
import User from "../../../FrameWork/User/User";
|
|
import Common5 from "../../../Platform/th/Common5";
|
|
import UserManager from "../../Manager/UserManager";
|
|
import PrefabManage, { GameType } from "../../PrefabManager/PrefabManage";
|
|
import GameBase from "../../SCommon/GameBase";
|
|
import ZhongCanTingManager from "../ZhongCanTing/ZhongCanTingManager";
|
|
import BuyPropNode from "./BuyPropNode2";
|
|
import ExitTipCNXX from "./ExitTipCNXX";
|
|
import GameDataManage2 from "./GameDataManage2";
|
|
import GameDataManage, { DaoJuType, GamePropManage, GameSecondLevelManage } from "./GameDataManage2";
|
|
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class GameBase_CNXX extends GameBase {
|
|
@property(cc.Node)
|
|
singleQiE: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
niaoWoJieSuo: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
niaoWoNode: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
prop_niaoWo: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
prop_fuBing: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
prop_xiaoChu: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
prop_chongPai: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
xiaoChuBingKuai: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
jinDuProgress: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
incomePopUp: cc.Node = null;
|
|
|
|
// @property(cc.Node)
|
|
// progressTips: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
qiPao: cc.Node = null;
|
|
// @property(cc.Node)
|
|
// mapNode: cc.Node = null;
|
|
|
|
// 对象池
|
|
public qiEPool: cc.NodePool = new cc.NodePool();
|
|
|
|
curSelectLineIndex: number = -1//已经选中的行
|
|
lastSelectInfo: any = null//已经选中的企鹅数据
|
|
lineZIndex: number = 100;//zIndex
|
|
|
|
niaoWoSingleQiE: cc.Node = null//鸟窝的企鹅
|
|
isSelectNiaoWoSingle: boolean = false//是否选中了鸟窝企鹅
|
|
|
|
isMoving: boolean = false//是否正在进行中
|
|
isUsingXiaoChuProp: boolean = false//是否正在使用消除道具
|
|
_dt: number = 0
|
|
recordStartSeconds: number = 0//记录开始游戏的时间
|
|
lingQuStatus = [false,false,false,false,false]//领取奖励状态
|
|
onLoad() {
|
|
// super.onLoad()
|
|
}
|
|
public onDestroy(): void {
|
|
super.onDestroy();
|
|
}
|
|
|
|
|
|
start() {
|
|
Common5.playMusic("sound/兔子舞背景")
|
|
this.initTouchEvent()
|
|
this.initStartMainContent()
|
|
this.initBuWeiContent()
|
|
this.freshProgress()
|
|
EventMgr.onEvent_custom(ryw_Event.nextQie, () => {
|
|
|
|
GameSecondLevelManage.initStartData(User.getQieLevel())
|
|
this.prop_niaoWo.active = true
|
|
this.niaoWoJieSuo.active = false
|
|
this.lingQuStatus = [false,false,false,false,false]
|
|
this.initStartMainContent()
|
|
this.initBuWeiContent()
|
|
this.freshProgress()
|
|
|
|
GamePropManage.initDaoJuJieSuoStatus()
|
|
this.prop_fuBing.getComponent(cc.Button).interactable = true
|
|
this.node.getChildByName("mainNode").getChildByName("fuBing_12").active = false
|
|
this.node.getChildByName("mainNode").getChildByName("fuBing_13").active = false
|
|
this.prop_chongPai.getComponent(cc.Button).interactable = true
|
|
}, this)
|
|
// this.nanDuTiShenAni()
|
|
}
|
|
protected update(dt: number): void {
|
|
this._dt += dt
|
|
if (this._dt >= 12) {
|
|
this._dt = 0
|
|
this.showQiPao()
|
|
}
|
|
}
|
|
|
|
showQiPao() {
|
|
if (!this.qiPao) {
|
|
return
|
|
}
|
|
// this.successResult()//测试代码xxxx
|
|
if (this.niaoWoSingleQiE) {
|
|
this.qiPao.active = false
|
|
} else {
|
|
this.qiPao.active = true
|
|
this.qiPao.scale = 0
|
|
this.qiPao.stopAllActions()
|
|
cc.tween(this.qiPao)
|
|
.to(0.3, { scale: 1 })
|
|
.delay(3)
|
|
.call(() => {
|
|
this.qiPao.active = false
|
|
})
|
|
.start()
|
|
}
|
|
}
|
|
//难度提升
|
|
nanDuTiShenAni() {
|
|
|
|
}
|
|
initTouchEvent() {
|
|
let fuBingNum = GameDataManage.getMaxFuBingNum()//this.node.getChildByName("mainNode").childrenCount
|
|
for (var i = 0; i < fuBingNum; i++) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + i).getChildByName("bingKuaiTouchNode")
|
|
bingKuaiTouchNode.attr({ lineIndex: i, typeName: "Line" })
|
|
this.openTouchEvent(bingKuaiTouchNode)
|
|
}
|
|
}
|
|
//初始化主区
|
|
initStartMainContent() {
|
|
let dataTab = GameDataManage.getCurContentData()
|
|
|
|
let fuBingNum = GameDataManage.getMaxFuBingNum()//this.node.getChildByName("mainNode").childrenCount
|
|
for (var i = 0; i < fuBingNum; i++) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + i).getChildByName("bingKuaiTouchNode")
|
|
for (var j = 0; j < 4; j++) {
|
|
let posNode = bingKuaiTouchNode.getChildByName("pos_" + j)
|
|
if (dataTab[i][j]) {
|
|
this.cloneSingleQiE(dataTab[i][j], posNode, true, GameDataManage.getQiEDirection(i))
|
|
}
|
|
}
|
|
}
|
|
let unLockFuBingArr = GameDataManage2.getUnLockFuBingArr()
|
|
for(let i = 0;i<unLockFuBingArr.length;i++){
|
|
if(unLockFuBingArr[i] > 0){
|
|
this.node.getChildByName("mainNode").getChildByName("fuBing_" + i).active = true
|
|
}else{
|
|
this.node.getChildByName("mainNode").getChildByName("fuBing_" + i).active = false
|
|
}
|
|
}
|
|
}
|
|
//初始化补位区
|
|
initBuWeiContent() {
|
|
let dataTab = GameDataManage.getCurBuWeiContentData()
|
|
|
|
let fuBingNum = GameDataManage.getMaxFuBingNum()//this.node.getChildByName("mainNode").childrenCount
|
|
for (var i = 0; i < fuBingNum; i++) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + i).getChildByName("bingKuaiTouchNode")
|
|
for (var j = 0; j < 4; j++) {
|
|
let posNode = bingKuaiTouchNode.getChildByName("buWeiPos_" + j)
|
|
if (dataTab[i][j]) {
|
|
this.cloneSingleQiE(dataTab[i][j], posNode, false, GameDataManage.getQiEDirection(i),j)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//初始化道具
|
|
initDaoJu() {
|
|
GamePropManage.initDaoJuJieSuoStatus()
|
|
this.xiaoChuBingKuai.attr({ typeName: "BingKuai", startPos: this.xiaoChuBingKuai.getPosition() })
|
|
this.openTouchEvent(this.xiaoChuBingKuai)
|
|
}
|
|
// //初始化进度提示
|
|
// initProgressTips() {
|
|
// let allNum = GameDataManage.getAllAmount();
|
|
// for (let index = 0; index < GameDataManage.NaoLiNumArray.length; index++) {
|
|
// const amount = GameDataManage.NaoLiNumArray[index];
|
|
// let element = cc.instantiate(this.progressTips.getChildByName("六边形黑"));
|
|
// element.active = true;
|
|
// element.x = this.progressTips.width * amount / allNum;
|
|
// element.getChildByName('lab').getComponent(cc.Label).string = index + 1 + "";
|
|
// this.progressTips.addChild(element);
|
|
// }
|
|
// }
|
|
|
|
//发放奖励
|
|
sendAward(index,times){
|
|
if(!this.lingQuStatus[index]){
|
|
this.lingQuStatus[index] = true
|
|
let money = ZhongCanTingManager.getPerSecondShouYi()
|
|
UserManager.addMoney(money*times)
|
|
PrefabManage.showTextTips(`获得收益${Common5.getNumberChangeHanzi(money*times, '1')}`)
|
|
|
|
Common5.setNodeToTargetPos(this.incomePopUp,this.jinDuProgress.getChildByName('baoXiang_'+index))
|
|
this.incomePopUp.getComponent(cc.Label).string = `+${Common5.getNumberChangeHanzi(money*times, '1')}`
|
|
cc.tween(this.incomePopUp)
|
|
.set({active:true,opacity:255,scale:0})
|
|
.to(0.2,{scale:1})
|
|
.delay(0.8)
|
|
.to(1, { y:this.incomePopUp.y+50,opacity:0 })
|
|
.to(0.5,{opacity:0})
|
|
.set({active:false})
|
|
.start()
|
|
}
|
|
}
|
|
//刷新进度
|
|
freshProgress() {
|
|
if (!this.jinDuProgress) {
|
|
return
|
|
}
|
|
let allNum = GameDataManage.getAllAmount()
|
|
let curXiaoChuAmount = GameDataManage.getCurXiaoChuAmount()
|
|
this.jinDuProgress.getComponent(cc.ProgressBar).progress = curXiaoChuAmount / allNum;
|
|
let rate = Math.floor(curXiaoChuAmount / allNum * 1000) / 10
|
|
this.jinDuProgress.getChildByName('progressStr').getComponent(cc.Label).string = `${rate}%`
|
|
|
|
let jieSuoNum = 0
|
|
if(rate >= 100){
|
|
jieSuoNum = 5
|
|
this.sendAward(4,21)
|
|
}else if(rate >= 80){
|
|
jieSuoNum = 4
|
|
this.sendAward(3,15)
|
|
}else if(rate >= 60){
|
|
jieSuoNum = 3
|
|
this.sendAward(2,10)
|
|
}else if(rate >= 40){
|
|
jieSuoNum = 2
|
|
this.sendAward(1,6)
|
|
}else if(rate >= 20){
|
|
jieSuoNum = 1
|
|
this.sendAward(0,3)
|
|
}
|
|
for(let i=0;i<5;i++){
|
|
if(jieSuoNum > i){
|
|
this.jinDuProgress.getChildByName('baoXiang_'+i).getChildByName('灰色宝箱').active = true
|
|
this.jinDuProgress.getChildByName('baoXiang_'+i).getChildByName('有色宝箱').active = false
|
|
}else{
|
|
this.jinDuProgress.getChildByName('baoXiang_'+i).getChildByName('灰色宝箱').active = false
|
|
this.jinDuProgress.getChildByName('baoXiang_'+i).getChildByName('有色宝箱').active = true
|
|
}
|
|
}
|
|
// console.log(curXiaoChuAmount, allNum);
|
|
let curShouYi = ZhongCanTingManager.getPerSecondShouYi()
|
|
let tiShengShouYi = ZhongCanTingManager.getPerSecondShouYi(0,1)
|
|
|
|
let str1 = `过关后每秒收益: ${Common5.getNumberChangeHanzi(curShouYi, '1', 1)}/秒 →`
|
|
let str2 = `${Common5.getNumberChangeHanzi(tiShengShouYi, '1', 1)}/秒`
|
|
this.jinDuProgress.getChildByName('curShouYi').getComponent(cc.Label).string = str1
|
|
this.jinDuProgress.getChildByName('nextShouYi').getComponent(cc.Label).string = str2
|
|
|
|
let curLevel = User.getQieLevel()
|
|
this.jinDuProgress.getChildByName('gameName').getComponent(cc.Label).string = `冰川企鹅(${curLevel})`
|
|
if(curLevel == 1){
|
|
this.jinDuProgress.getChildByName('taskTip1').active = true
|
|
this.jinDuProgress.getChildByName('taskTip2').active = false
|
|
this.jinDuProgress.getChildByName('taskTip3').active = false
|
|
}else if(curLevel == 2){
|
|
this.jinDuProgress.getChildByName('taskTip1').active = false
|
|
this.jinDuProgress.getChildByName('taskTip2').active = true
|
|
this.jinDuProgress.getChildByName('taskTip3').active = false
|
|
}else{
|
|
this.jinDuProgress.getChildByName('taskTip1').active = false
|
|
this.jinDuProgress.getChildByName('taskTip2').active = false
|
|
this.jinDuProgress.getChildByName('taskTip3').active = true
|
|
|
|
let money = ZhongCanTingManager.getPerSecondShouYi()
|
|
let times = 21
|
|
let str = Common5.getNumberChangeHanzi(money*times, '1') + ''
|
|
this.jinDuProgress.getChildByName('taskTip3').getChildByName('moneyStr').getComponent(cc.Label).string = str
|
|
}
|
|
|
|
|
|
}
|
|
//刷新进度提示
|
|
freshProgressTips() {
|
|
// if (!this.progressTips) {
|
|
// return;
|
|
// }
|
|
// let allNum = GameDataManage.getAllAmount();
|
|
// let curXiaoChuAmount = GameDataManage.getCurXiaoChuAmount();
|
|
// let NaoLiNum = GameDataManage.NaoLiNumArray[GameDataManage.addNaoLiNum];
|
|
// if (NaoLiNum && curXiaoChuAmount > NaoLiNum) {
|
|
// const element = this.progressTips.children[GameDataManage.addNaoLiNum + 2];
|
|
// element.getChildByName('icon').active = true;
|
|
// }
|
|
// if (curXiaoChuAmount >= allNum) {
|
|
// this.progressTips.children[0].getChildByName('icon').active = true;
|
|
// }
|
|
//GameDataManage.addNaoLiValue();
|
|
}
|
|
|
|
cloneSingleQiE(number, parentNode, isMainContent, direction,j?) {
|
|
let singleQiE = cc.instantiate(this.singleQiE)
|
|
// let singleQiE = Common5.getPoolNode(this.qiEPool, this.singleQiE);
|
|
singleQiE.active = true
|
|
singleQiE.scaleX = 0.5 * direction
|
|
if (!isMainContent) {
|
|
if(j > 0){
|
|
singleQiE.active = false
|
|
}else{
|
|
singleQiE.color = cc.color(100, 100, 100);
|
|
}
|
|
}
|
|
// singleQiE.getComponent(cc.Sprite).spriteFrame = this.qiESpFrameTab[number-1]
|
|
singleQiE.getComponent(sp.Skeleton).defaultSkin = number + "" //.setSkin()
|
|
singleQiE.getComponent(sp.Skeleton).defaultAnimation = "zhayanbudong"//.setAnimation(0,"daiji",true)
|
|
parentNode.addChild(singleQiE)
|
|
return singleQiE
|
|
}
|
|
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_END, this.touchEndNode, this)
|
|
}
|
|
offTouchEvent(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_END, this.touchEndNode, this)
|
|
}
|
|
|
|
touchStartNode(event) {
|
|
if (this.isMoving || this.isUsingXiaoChuProp) {
|
|
return
|
|
}
|
|
//Common5.playEffectCustom("cainiaoxiaoxiao", "sound/选中")
|
|
//列
|
|
if (event.target.typeName == "Line") {
|
|
//已选择过单只
|
|
if (this.isSelectNiaoWoSingle) {
|
|
this.isSelectNiaoWoSingle = false
|
|
// this.niaoWoSingleQiE.removeAllChildren()
|
|
this.niaoWoSingleQiE.getComponent(sp.Skeleton).setAnimation(0, "zhayanbudong", true)
|
|
let curSelectInfo = GameDataManage.getSelectQiEData(event.target.lineIndex)
|
|
if (curSelectInfo.selectDataTab.length > 0) {
|
|
//该列已满
|
|
if (curSelectInfo.selectLineLength >= 4) {
|
|
return
|
|
}
|
|
//相同企鹅可以移动
|
|
if (curSelectInfo.selectDataTab[0] == this.niaoWoSingleQiE['niaoData']) {
|
|
this.niaoWoQiEFlyToMain(event.target.lineIndex, curSelectInfo.selectLineLength, this.niaoWoSingleQiE)
|
|
//不同企鹅不能移动
|
|
} else {
|
|
return
|
|
}
|
|
//该列没有数据
|
|
} else {
|
|
this.niaoWoQiEFlyToMain(event.target.lineIndex, curSelectInfo.selectLineLength, this.niaoWoSingleQiE)
|
|
}
|
|
return
|
|
}
|
|
//重复点击
|
|
if (this.curSelectLineIndex == event.target.lineIndex) {
|
|
this.clearSelectEffect(this.lastSelectInfo)
|
|
this.initSelectData()
|
|
} else {
|
|
//已经选了
|
|
if (this.curSelectLineIndex > -1) {
|
|
let curSelectInfo = GameDataManage.getSelectQiEData(event.target.lineIndex)
|
|
if (curSelectInfo.selectDataTab.length > 0) {
|
|
//相同企鹅可以移动
|
|
if (curSelectInfo.selectDataTab[0] == this.lastSelectInfo.selectDataTab[0]) {
|
|
//最多可移动数量
|
|
let maxCanMoveNum = Math.min(this.lastSelectInfo.selectDataTab.length, 4 - curSelectInfo.selectLineLength)
|
|
|
|
this.clearSelectEffect(this.lastSelectInfo)
|
|
this.qiEMoveAction(maxCanMoveNum, this.lastSelectInfo, curSelectInfo, event.target.lineIndex)
|
|
//不同企鹅不能移动
|
|
} else {
|
|
this.clearSelectEffect(this.lastSelectInfo)
|
|
this.initSelectData()
|
|
}
|
|
//该列没有数据
|
|
} else {
|
|
//最多可移动数量
|
|
let maxCanMoveNum = Math.min(this.lastSelectInfo.selectDataTab.length, 4 - curSelectInfo.selectLineLength)
|
|
|
|
this.clearSelectEffect(this.lastSelectInfo)
|
|
this.qiEMoveAction(maxCanMoveNum, this.lastSelectInfo, curSelectInfo, event.target.lineIndex)
|
|
}
|
|
//选中
|
|
} else {
|
|
this.lastSelectInfo = GameDataManage.getSelectQiEData(event.target.lineIndex)
|
|
console.log('event.target.lineIndex==',event.target.lineIndex)
|
|
console.log('this.lastSelectInfo==',this.lastSelectInfo)
|
|
if (this.lastSelectInfo.selectDataTab.length > 0) {
|
|
this.node.getChildByName("mainNode").getChildByName("fuBing_" + event.target.lineIndex).zIndex = this.lineZIndex++
|
|
this.curSelectLineIndex = event.target.lineIndex
|
|
this.setSelectEffect(this.lastSelectInfo)
|
|
//该列没有数据
|
|
} else {
|
|
this.initSelectData()
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
//单只
|
|
} else if (event.target.typeName == "Single") {
|
|
//清除列的选中效果
|
|
this.clearSelectEffect(this.lastSelectInfo)
|
|
this.initSelectData()
|
|
|
|
//取消选中
|
|
if (this.isSelectNiaoWoSingle) {
|
|
this.isSelectNiaoWoSingle = false
|
|
// this.niaoWoSingleQiE.removeAllChildren()
|
|
this.niaoWoSingleQiE.getComponent(sp.Skeleton).setAnimation(0, "zhayanbudong", true)
|
|
//选中
|
|
} else {
|
|
|
|
|
|
|
|
|
|
this.isSelectNiaoWoSingle = true
|
|
// let selectIcon = cc.instantiate(this.selectIcon)
|
|
// selectIcon.active = true
|
|
// this.niaoWoSingleQiE.addChild(selectIcon)
|
|
this.niaoWoSingleQiE.getComponent(sp.Skeleton).setAnimation(0, "dianji", false)
|
|
}
|
|
}
|
|
|
|
}
|
|
touchMoveNode(event) {
|
|
if (event.target.typeName == "BingKuai") {
|
|
let nodeLoc = event.getLocation()
|
|
let nodePos = event.target.parent.convertToNodeSpaceAR(nodeLoc)
|
|
event.target.setPosition(nodePos)
|
|
}
|
|
}
|
|
touchEndNode(event) {
|
|
if (event.target.typeName == "BingKuai") {
|
|
|
|
let fuBingNum = GameDataManage.getMaxFuBingNum()//this.node.getChildByName("mainNode").childrenCount
|
|
for (var i = 0; i < fuBingNum; i++) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + i).getChildByName("bingKuaiTouchNode")
|
|
for (var j = 0; j < 4; j++) {
|
|
let qiE = bingKuaiTouchNode.getChildByName("pos_" + j).getChildByName("singleQiE")
|
|
if (qiE && Common5.checkContainsNode(event.target, qiE)) {
|
|
this.xiaoChuSingleQiE(i, j, qiE)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//消除结冰冰块
|
|
xiaoChuSingleQiE(xPos, yPos, qiE) {
|
|
this.xiaoChuBingKuai.active = false
|
|
//如果删除的鸟加入等待区,需要ui处理
|
|
let callFunc = (data) => {
|
|
if (data.isJoinBuWeiQu) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + data.joinXPos).getChildByName("bingKuaiTouchNode")
|
|
let posNode = bingKuaiTouchNode.getChildByName("buWeiPos_" + data.joinYPos)
|
|
this.cloneSingleQiE(data.deleteData, posNode, false, GameDataManage.getQiEDirection(data.joinXPos))
|
|
}
|
|
}
|
|
GameDataManage.deleteSingleCardData(xPos, yPos, callFunc)
|
|
qiE.getComponent(sp.Skeleton).setAnimation(0, "jiebing", false)
|
|
cc.tween(this.node)
|
|
.delay(2)
|
|
.call(() => {
|
|
//其他企鹅移动位置
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + xPos).getChildByName("bingKuaiTouchNode")
|
|
for (let j = 0; j < 4; j++) {
|
|
let qiE = bingKuaiTouchNode.getChildByName("pos_" + j).getChildByName("singleQiE")
|
|
if (qiE) {
|
|
if (j > yPos) {
|
|
cc.tween(qiE)
|
|
.by(0.3, { x: -68 * GameDataManage.getQiEDirection(xPos) })
|
|
.call(() => {
|
|
qiE.setPosition(cc.v2(0, 0))
|
|
qiE.parent = bingKuaiTouchNode.getChildByName("pos_" + (j - 1))
|
|
})
|
|
.start()
|
|
} else if (j == yPos) {
|
|
qiE.removeFromParent()
|
|
// Common5.putPoolNode(qiE, this.qiEPool);
|
|
}
|
|
}
|
|
}
|
|
})
|
|
.delay(0.4)
|
|
.call(() => {
|
|
this.isUsingXiaoChuProp = false
|
|
})
|
|
.start()
|
|
}
|
|
//初始化选中数据(选了个空气)
|
|
initSelectData() {
|
|
this.curSelectLineIndex = -1
|
|
this.lastSelectInfo = null
|
|
}
|
|
//选中效果
|
|
setSelectEffect(selectInfo) {
|
|
if (!selectInfo) {
|
|
return
|
|
}
|
|
let selectPosTab = selectInfo.selectPosTab
|
|
for (var i = 0; i < selectPosTab.length; i++) {
|
|
let xPos = selectPosTab[i].xPos
|
|
let yPos = selectPosTab[i].yPos
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + xPos).getChildByName("bingKuaiTouchNode")
|
|
let qiE = bingKuaiTouchNode.getChildByName("pos_" + yPos).getChildByName("singleQiE")
|
|
if (qiE) {
|
|
// let selectIcon = cc.instantiate(this.selectIcon)
|
|
// selectIcon.active = true
|
|
// qiE.addChild(selectIcon)
|
|
qiE.getComponent(sp.Skeleton).setAnimation(0, "dianji", false)
|
|
}
|
|
}
|
|
}
|
|
//清除选中效果
|
|
clearSelectEffect(selectInfo) {
|
|
if (!selectInfo) {
|
|
return
|
|
}
|
|
let selectPosTab = selectInfo.selectPosTab
|
|
for (var i = 0; i < selectPosTab.length; i++) {
|
|
let xPos = selectPosTab[i].xPos
|
|
let yPos = selectPosTab[i].yPos
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + xPos).getChildByName("bingKuaiTouchNode")
|
|
let qiE = bingKuaiTouchNode.getChildByName("pos_" + yPos).getChildByName("singleQiE")
|
|
if (qiE) {
|
|
// qiE.removeAllChildren()
|
|
qiE.getComponent(sp.Skeleton).setAnimation(0, "zhayanbudong", true)
|
|
}
|
|
}
|
|
}
|
|
//鸟窝企鹅飞向主区
|
|
niaoWoQiEFlyToMain(targetXPos, targetYPos, qiE) {
|
|
this.isMoving = true
|
|
let targetBingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + targetXPos).getChildByName("bingKuaiTouchNode")
|
|
let targetNode = targetBingKuaiTouchNode.getChildByName("pos_" + targetYPos)
|
|
|
|
let localPos = Common5.getNodeToTargetPos(qiE, targetNode)
|
|
let data = qiE['niaoData']
|
|
qiE.getComponent(sp.Skeleton).setAnimation(0, "fei", true)
|
|
cc.tween(qiE)
|
|
.to(0.5, { x: localPos.x, y: localPos.y })
|
|
.call(() => {
|
|
qiE.setPosition(cc.v2(0, 0))
|
|
qiE.parent = targetNode
|
|
qiE.scaleX = 0.5 * GameDataManage.getQiEDirection(targetXPos)
|
|
qiE.getComponent(sp.Skeleton).setAnimation(0, "zhayanbudong", true)
|
|
GameDataManage.niaoWoFlyToMain(targetXPos, data)
|
|
this.offTouchEvent(qiE)
|
|
this.niaoWoSingleQiE = null
|
|
// this.showQiPao()
|
|
this.isMoving = false
|
|
let callFunc = ()=>{
|
|
this.onBtnClickNiaoWo()
|
|
}
|
|
this.checkIsXiaoChu(callFunc)
|
|
})
|
|
.start()
|
|
}
|
|
//企鹅移动
|
|
qiEMoveAction(num, lastSelectInfo, curSelectInfo, targetLine) {
|
|
if (!lastSelectInfo) {
|
|
return
|
|
}
|
|
this.isMoving = true
|
|
//将选中的企鹅移动至目标列
|
|
let lastSelectPosTab = lastSelectInfo.selectPosTab
|
|
let curSelectPosTab = curSelectInfo.selectPosTab
|
|
|
|
// console.log("num=", num)
|
|
// console.log("lastSelectPosTab=", lastSelectPosTab)
|
|
// console.log("curSelectPosTab=", curSelectPosTab)
|
|
|
|
|
|
//确定目标位置的起始值
|
|
let targetStartYPos = -1
|
|
let targetXPos = targetLine
|
|
let selectNumber = lastSelectInfo.selectDataTab[0]
|
|
|
|
//目标列为空
|
|
if (curSelectPosTab.length <= 0) {
|
|
|
|
} else {
|
|
// targetXPos = curSelectPosTab[0].xPos
|
|
for (var i = 0; i < curSelectPosTab.length; i++) {
|
|
if (curSelectPosTab[i].yPos > targetStartYPos) {
|
|
targetStartYPos = curSelectPosTab[i].yPos
|
|
}
|
|
}
|
|
}
|
|
|
|
let curData = []
|
|
let targetData = []
|
|
for (let i = 0; i < num; i++) {
|
|
let xPos = lastSelectPosTab[i].xPos
|
|
let yPos = lastSelectPosTab[i].yPos
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + xPos).getChildByName("bingKuaiTouchNode")
|
|
let qiE = bingKuaiTouchNode.getChildByName("pos_" + yPos).getChildByName("singleQiE")
|
|
|
|
|
|
|
|
let targetYPos = targetStartYPos + num - i
|
|
let targetBingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + targetXPos).getChildByName("bingKuaiTouchNode")
|
|
let targetNode = targetBingKuaiTouchNode.getChildByName("pos_" + targetYPos)
|
|
|
|
let localPos = Common5.getNodeToTargetPos(qiE, targetNode)
|
|
curData[i] = { xPos: xPos, yPos: yPos, data: selectNumber }
|
|
targetData[i] = { xPos: targetXPos, yPos: targetYPos, data: selectNumber }
|
|
|
|
qiE.getComponent(sp.Skeleton).setAnimation(0, "fei", true)
|
|
cc.tween(qiE)
|
|
.to(0.35, { x: localPos.x, y: localPos.y })
|
|
.call(() => {
|
|
qiE.scaleX = 0.5 * GameDataManage.getQiEDirection(targetLine)
|
|
qiE.setPosition(cc.v2(0, 0))
|
|
qiE.parent = targetNode
|
|
qiE.getComponent(sp.Skeleton).setAnimation(0, "zhayanbudong", true)
|
|
})
|
|
.start()
|
|
}
|
|
this.scheduleOnce(() => {
|
|
GameDataManage.moveRefreshContentQiEData(curData, targetData)
|
|
this.checkIsXiaoChu()
|
|
this.initSelectData()
|
|
|
|
}, 0.36)
|
|
}
|
|
//检测消除
|
|
checkIsXiaoChu(autoChuNiao?) {
|
|
this.isMoving = true
|
|
let xiaoChuLineTab = GameDataManage.checkIsContentXiaoChu()
|
|
//消除整列
|
|
if (xiaoChuLineTab.length > 0) {
|
|
for (var i = 0; i < xiaoChuLineTab.length; i++) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + xiaoChuLineTab[i]).getChildByName("bingKuaiTouchNode")
|
|
for (var j = 0; j < 4; j++) {
|
|
let qiE = bingKuaiTouchNode.getChildByName("pos_" + j).getChildByName("singleQiE")
|
|
if (qiE) {
|
|
qiE.getComponent(sp.Skeleton).setAnimation(0, "tiaoshuikuai", false)
|
|
// qiE.stopAllActions()
|
|
cc.tween(qiE)
|
|
.delay(0.5)
|
|
.call(() => {
|
|
if (j == 4) {
|
|
Common5.playEffectCustom("cainiaoxiaoxiao", "sound/企鹅入水1")
|
|
}
|
|
})
|
|
.delay(0.5)
|
|
.call(() => {
|
|
qiE.removeFromParent()
|
|
// Common5.putPoolNode(qiE, this.qiEPool);
|
|
})
|
|
.start()
|
|
}
|
|
}
|
|
}
|
|
cc.tween(this.node)
|
|
.delay(0.35)
|
|
.call(() => {
|
|
GameDataManage.clearCurLineData(xiaoChuLineTab)
|
|
this.buWeiEnterMainContent(xiaoChuLineTab)
|
|
})
|
|
.delay(0.22)
|
|
.call(() => {
|
|
// this.isMoving = false
|
|
this.freshProgress()
|
|
autoChuNiao && autoChuNiao()
|
|
// this.freshProgressTips();
|
|
if (GameDataManage.isQiEAllOver()) {
|
|
this.successResult()
|
|
}
|
|
})
|
|
.start()
|
|
} else {
|
|
this.isMoving = false
|
|
autoChuNiao && autoChuNiao()
|
|
}
|
|
}
|
|
//补位区进入主区
|
|
buWeiEnterMainContent(xiaoChuLineTab) {
|
|
console.log("补位区进入主区123==", xiaoChuLineTab)
|
|
let buWeiQuData = GameDataManage.getCurBuWeiContentData()
|
|
for (let i = 0; i < xiaoChuLineTab.length; i++) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + xiaoChuLineTab[i]).getChildByName("bingKuaiTouchNode")
|
|
let buWeiLineLength = buWeiQuData[xiaoChuLineTab[i]].length
|
|
for (let j = 0; j < 4; j++) {
|
|
let qiE = bingKuaiTouchNode.getChildByName("buWeiPos_" + j).getChildByName("singleQiE")
|
|
let posNode = bingKuaiTouchNode.getChildByName("pos_" + (buWeiLineLength - 1 - j))
|
|
if (qiE) {
|
|
// qiE.stopAllActions()
|
|
qiE.color = cc.color(255, 255, 255)
|
|
qiE.active = true
|
|
cc.tween(qiE)
|
|
.by(0.2, { x: 75 * buWeiLineLength * GameDataManage.getQiEDirection(xiaoChuLineTab[i]) })
|
|
.call(() => {
|
|
qiE.setPosition(cc.v2(0, 0))
|
|
qiE.parent = posNode
|
|
})
|
|
.start()
|
|
}
|
|
}
|
|
}
|
|
this.scheduleOnce(() => {
|
|
//主区,补位区,剩余数据刷新
|
|
GameDataManage.buWeiQuEnterMain(xiaoChuLineTab)
|
|
this.buWeiQuJoinQiE(xiaoChuLineTab)
|
|
this.scheduleOnce(() => {
|
|
this.checkIsXiaoChu()
|
|
}, 0.45)
|
|
// this.checkIsXiaoChu()
|
|
}, 0.21)
|
|
}
|
|
//补位区加入企鹅
|
|
buWeiQuJoinQiE(xiaoChuLineTab) {
|
|
let buWeiQuData = GameDataManage.getCurBuWeiContentData()
|
|
for (var i = 0; i < xiaoChuLineTab.length; i++) {
|
|
let buWeiLineData = buWeiQuData[xiaoChuLineTab[i]]
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + xiaoChuLineTab[i]).getChildByName("bingKuaiTouchNode")
|
|
for (var j = 0; j < 4; j++) {
|
|
let posNode = bingKuaiTouchNode.getChildByName("buWeiPos_" + j)
|
|
if (buWeiLineData[j]) {
|
|
this.cloneSingleQiE(buWeiLineData[j], posNode, false, GameDataManage.getQiEDirection(xiaoChuLineTab[i]),j)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//点击道具
|
|
onDaoJuClick(event, customData) {
|
|
Common5.playEffectCustom("cainiaoxiaoxiao", "sound/UI按钮")
|
|
if (this.isMoving || this.isUsingXiaoChuProp) {
|
|
return
|
|
}
|
|
let callFunc = null
|
|
//解锁鸟窝
|
|
if (customData == DaoJuType.NiaoWo) {
|
|
callFunc = () => {
|
|
this.prop_niaoWo.active = false
|
|
this.niaoWoJieSuo.active = true
|
|
|
|
this.onBtnClickNiaoWo()
|
|
}
|
|
//浮冰道具
|
|
} else if (customData == DaoJuType.FuBing) {
|
|
callFunc = () => {
|
|
// GamePropManage.setDaoJuJieSuoStatus(customData,true)
|
|
GameDataManage.addFuBingNum()
|
|
this.refreshDaoJuStatus(customData)
|
|
}
|
|
//消除道具
|
|
} else if (customData == DaoJuType.XiaoChu) {
|
|
callFunc = () => {
|
|
this.refreshDaoJuStatus(customData)
|
|
}
|
|
//重新排序
|
|
} else if (customData == DaoJuType.ChongXinPaiXu) {
|
|
callFunc = () => {
|
|
this.refreshDaoJuStatus(customData)
|
|
}
|
|
}
|
|
PrefabManage.loadPrefabByType(GameType.CNXX_BuyProp, null, (prefabNode) => {
|
|
prefabNode.getComponent(BuyPropNode).initView(customData, callFunc)
|
|
})
|
|
}
|
|
//刷新道具状态
|
|
refreshDaoJuStatus(id) {
|
|
if (id == DaoJuType.FuBing) {
|
|
//使用次数
|
|
let leftTimes = GamePropManage.getDaoJuLeftUseTimes(id)
|
|
if (leftTimes == 2) {
|
|
GamePropManage.useDaoJuLeftUseTimes(DaoJuType.FuBing)
|
|
this.node.getChildByName("mainNode").getChildByName("fuBing_12").active = true
|
|
} else if (leftTimes == 1) {
|
|
GamePropManage.useDaoJuLeftUseTimes(DaoJuType.FuBing)
|
|
this.node.getChildByName("mainNode").getChildByName("fuBing_13").active = true
|
|
this.prop_fuBing.getComponent(cc.Button).interactable = false
|
|
this.prop_fuBing.getChildByName("icon").active = false
|
|
}
|
|
} else if (id == DaoJuType.XiaoChu) {
|
|
//使用次数
|
|
let leftTimes = GamePropManage.getDaoJuLeftUseTimes(id)
|
|
if (leftTimes == 2) {
|
|
GamePropManage.useDaoJuLeftUseTimes(DaoJuType.XiaoChu)
|
|
|
|
this.xiaoChuBingKuai.setPosition(this.xiaoChuBingKuai["startPos"])
|
|
this.xiaoChuBingKuai.active = true
|
|
this.isUsingXiaoChuProp = true
|
|
} else if (leftTimes == 1) {
|
|
GamePropManage.useDaoJuLeftUseTimes(DaoJuType.XiaoChu)
|
|
this.xiaoChuBingKuai.setPosition(this.xiaoChuBingKuai["startPos"])
|
|
this.xiaoChuBingKuai.active = true
|
|
this.isUsingXiaoChuProp = true
|
|
this.prop_xiaoChu.getComponent(cc.Button).interactable = false
|
|
this.prop_xiaoChu.getChildByName("icon").active = false
|
|
}
|
|
} else if (id == DaoJuType.ChongXinPaiXu) {
|
|
//使用次数
|
|
let leftTimes = GamePropManage.getDaoJuLeftUseTimes(id)
|
|
if (leftTimes == 2) {
|
|
GamePropManage.useDaoJuLeftUseTimes(DaoJuType.ChongXinPaiXu)
|
|
this.reSortAllQiEAction()
|
|
} else if (leftTimes == 1) {
|
|
GamePropManage.useDaoJuLeftUseTimes(DaoJuType.ChongXinPaiXu)
|
|
this.reSortAllQiEAction()
|
|
this.prop_chongPai.getComponent(cc.Button).interactable = false
|
|
this.prop_chongPai.getChildByName("icon").active = false
|
|
}
|
|
}
|
|
}
|
|
//点击鸟窝
|
|
onBtnClickNiaoWo() {
|
|
if (this.isMoving || this.isUsingXiaoChuProp || this.niaoWoSingleQiE) {
|
|
return
|
|
}
|
|
// Common5.playEffectCustom("cainiaoxiaoxiao", "sound/UI按钮")
|
|
let niaoData = GameDataManage.getNiaoWoData()
|
|
if (niaoData.niaoId < 0) {
|
|
PrefabManage.showTextTips("冰屋已经没企鹅啦~")
|
|
return
|
|
}
|
|
//取的是等待区的鸟,需要ui上删除
|
|
if (niaoData.isDengDaiQu) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + niaoData.xPos).getChildByName("bingKuaiTouchNode")
|
|
let qiE = bingKuaiTouchNode.getChildByName("buWeiPos_" + niaoData.yPos).getChildByName("singleQiE")
|
|
if (qiE) {
|
|
qiE.removeFromParent()
|
|
// Common5.putPoolNode(qiE, this.qiEPool);
|
|
}
|
|
}
|
|
//鸟窝出鸟
|
|
this.niaoWoSingleQiE = this.cloneSingleQiE(niaoData.niaoId, this.niaoWoNode, true, 1)
|
|
this.niaoWoSingleQiE.scale = 0.1
|
|
cc.tween(this.niaoWoSingleQiE)
|
|
.to(0.3, { x: 20, y: -20, scale: 0.5 })
|
|
.delay(0.1)
|
|
.call(() => {
|
|
this.niaoWoSingleQiE.attr({ typeName: "Single", niaoData: niaoData.niaoId })
|
|
this.openTouchEvent(this.niaoWoSingleQiE)
|
|
})
|
|
.start()
|
|
this.showQiPao()
|
|
}
|
|
//重新排序
|
|
reSortAllQiEAction() {
|
|
this.isMoving = true
|
|
//所有企鹅飞向屏幕中心点
|
|
let allQiEFlyToCenter = () => {
|
|
let fuBingNum = GameDataManage.getMaxFuBingNum()
|
|
for (var i = 0; i < fuBingNum; i++) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + i).getChildByName("bingKuaiTouchNode")
|
|
for (var j = 0; j < 4; j++) {
|
|
let qiE = bingKuaiTouchNode.getChildByName("pos_" + j).getChildByName("singleQiE")
|
|
if (qiE) {
|
|
let localPos = Common5.getNodeToTargetPos(qiE, this.node.getChildByName("mainNode"))
|
|
cc.tween(qiE)
|
|
.to(0.6, { x: localPos.x, y: localPos.y })
|
|
.start()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//屏幕中心点释放所有企鹅
|
|
let centerFlyToAllQiE = () => {
|
|
let fuBingNum = GameDataManage.getMaxFuBingNum()
|
|
for (var i = 0; i < fuBingNum; i++) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + i).getChildByName("bingKuaiTouchNode")
|
|
for (var j = 0; j < 4; j++) {
|
|
let qiE = bingKuaiTouchNode.getChildByName("pos_" + j).getChildByName("singleQiE")
|
|
if (qiE) {
|
|
cc.tween(qiE)
|
|
.to(0.6, { x: 0, y: 0 })
|
|
.start()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cc.tween(this.node)
|
|
.call(() => {
|
|
this.resortMainContent()
|
|
})
|
|
.delay(0.05)
|
|
.call(() => {
|
|
allQiEFlyToCenter()
|
|
})
|
|
.delay(0.8)
|
|
.call(() => {
|
|
centerFlyToAllQiE()
|
|
})
|
|
.delay(0.7)
|
|
.call(() => {
|
|
this.checkIsXiaoChu()
|
|
})
|
|
.start()
|
|
|
|
}
|
|
//重新排序刷新主区ui
|
|
resortMainContent() {
|
|
//重新排列企鹅数据
|
|
GameDataManage.reSortAllContentData()
|
|
let dataTab = GameDataManage.getCurContentData()
|
|
|
|
let fuBingNum = GameDataManage.getMaxFuBingNum()//this.node.getChildByName("mainNode").childrenCount
|
|
for (var i = 0; i < fuBingNum; i++) {
|
|
let bingKuaiTouchNode = this.node.getChildByName("mainNode").getChildByName("fuBing_" + i).getChildByName("bingKuaiTouchNode")
|
|
for (var j = 0; j < 4; j++) {
|
|
let qiE = bingKuaiTouchNode.getChildByName("pos_" + j).getChildByName("singleQiE")
|
|
if (qiE) {
|
|
qiE.getComponent(sp.Skeleton).setSkin(dataTab[i][j])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
failResult() {
|
|
|
|
}
|
|
successResult() {
|
|
|
|
}
|
|
onBtnClickBack() {
|
|
Common5.playEffectCustom("cainiaoxiaoxiao", "sound/UI按钮")
|
|
// let closeGameFunc = () => {
|
|
// this.node.removeFromParent();
|
|
// this.node.destroy();
|
|
// //EventMgr.emitEvent_custom(ryw_Event.exitToLobby)
|
|
// // EventMgr.emitEvent_custom(ryw_Event.updateUserProvince,``)
|
|
// }
|
|
// PrefabManage.loadPrefabByType(GameType.Setting, null, (prefabNode) => {
|
|
// prefabNode.getComponent(Setting).initView(true,closeGameFunc)
|
|
// })
|
|
let exitCall = ()=>{
|
|
this.node.removeFromParent();
|
|
this.node.destroy();
|
|
}
|
|
PrefabManage.loadPrefabByType(GameType.CNXX_exitTip, null, (prefabNode: cc.Node) => {
|
|
prefabNode.getComponent(ExitTipCNXX).initView(exitCall)
|
|
});
|
|
}
|
|
}
|
|
|