咸鱼的反击
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.
 
 
 

448 lines
17 KiB

import DaDianScript from "../../../../FrameWork/Base/DaDianScript";
import WordGameBaseComponent from "../../../../FrameWork/Base/WordGameBaseComptent";
import { ryw_Event } from "../../../../FrameWork/Event/EventEnum";
import EventMgr from "../../../../FrameWork/Event/EventMgr";
import Common from "../../../../FrameWork/Util/Common";
import Common5 from "../../../../Platform/th/Common5";
import Game from "../../../../Scripts/WenZiRes/ui/Game";
import CccGame from "../../../WordGame/gameComScript/CccGame/CccGame";
import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript";
const { ccclass, property } = cc._decorator;
@ccclass
export default class PoWuNvHai2 extends WordGameBaseComponent {
@property(cc.Node)
layerNode: cc.Node[] = [];
@property(cc.Node)
operateNodeList: cc.Node[] = [];
//当前层级下标
curLayerIndex = 0;
//当前进度
curSchedule: number = 0;
//文本配置
titleArrayConfig: string[] = [];
duihuaArrayConfig: any[] = [];
chadianArrayConfig: any[] = [];
wrongAnswerConfig: string[] = [];
answersIndexConfig: number[] = [];
start() {
super.start();
DaDianScript.userEnterDaDian();
//this.openTouchEvent(this.node.getChildByName('bg'));
Common5.stopMusic();
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle, 'script/PoWuNvHai2Config', (assest) => {
this.jsonData = assest.json;
this.initParameters();
this.initComponent();
})
}
//初始化参数
initParameters() {
this.curLayerIndex = 0;
this.curSchedule = 0;
this.titleArrayConfig = this.jsonData.titleArray;
this.duihuaArrayConfig = this.jsonData.duihuaArray;
this.chadianArrayConfig = this.jsonData.chadianArray;
this.wrongAnswerConfig = this.jsonData.wrongAnswer;
this.answersIndexConfig = this.jsonData.answersIndex;
Common.Type = 0
Common.subLevel = this.curLayerIndex;
Common.GameSubTipConfigs = this.jsonData.tipsArray;
Common.GameSubAnswerConfigs = this.jsonData.answersArray;
EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => {
this.normalTouchCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => {
this.normalTouchCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.DirectTouchMoveCheck, (data_) => {
this.normalTouchCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => {
this.endGameView(0);
}, this);
}
//初始化组件
initComponent() {
for (const node of this.layerNode) {
node.active = false;
}
let node = this.layerNode[this.curLayerIndex];
node.active = true;
Game.ins.setGameTitle(this.titleArrayConfig[0]);
//Common5.playMusicCustom(Common5.selectGameInfo.bundle, 'sound/背景音');
this.refreshLayer();
}
refreshLayer() {
let node = this.layerNode[this.curLayerIndex];
node.active = true;
if (this.curLayerIndex == 1) {
for (const iterator of this.getLayerChild('money1').children) {
let callbacks = CccGame.onNodeTouchMoreCheckEvent(iterator, this.getLayerChild('chadianNodeList1').children);
callbacks.setSuccessListener((data_) => {
this.nodeCheckSuccessCallback1(data_.targetNode);
});
}
for (const iterator of this.getLayerChild('money2').children) {
let callbacks = CccGame.onNodeTouchMoreCheckEvent(iterator, this.getLayerChild('chadianNodeList2').children);
callbacks.setSuccessListener((data_) => {
this.nodeCheckSuccessCallback2(data_.targetNode);
});
}
for (const iterator of this.getLayerChild('money3').children) {
let callbacks = CccGame.onNodeTouchMoreCheckEvent(iterator, this.getLayerChild('chadianNodeList3').children);
callbacks.setSuccessListener((data_) => {
this.nodeCheckSuccessCallback3(data_.targetNode);
});
}
this.node.getChildByName("inputBlock").active = true;
this.showDuiHua(this.duihuaArrayConfig[1], () => {
this.node.getChildByName("inputBlock").active = false;
});
} else if (this.curLayerIndex == 2) {
this.showDuiHua(this.duihuaArrayConfig[16], () => {
this.showDuiHua(this.duihuaArrayConfig[17], () => {
this.endGameView(1);
});
});
}
}
nodeCheckSuccessCallback1(targetNode: cc.Node) {
let checkLogic = {
: () => {
this.getLayerChild('左边场景1', '家财万贯').active = true;
this.getLayerChild('chadianNodeList1', '丝绸大衣').active = true;
this.showDuiHua(this.duihuaArrayConfig[2]);
},
: () => {
this.getLayerChild('左边场景1', '女', '衣服').active = true;
this.getLayerChild('chadianNodeList1', '翡翠珍珠首饰').active = true;
this.node.getChildByName("inputBlock").active = true;
this.showDuiHua(this.duihuaArrayConfig[3], () => {
this.node.getChildByName("inputBlock").active = false;
this.showDuiHua(this.duihuaArrayConfig[4]);
});
},
: () => {
this.getLayerChild('左边场景1', '女', '首饰').active = true;
this.getLayerChild('chadianNodeList1', '全部交出来').active = true;
this.showDuiHua(this.duihuaArrayConfig[5]);
},
: () => {
this.getLayerChild('chadianNodeList1', '家产').active = true;
this.showDuiHua(this.duihuaArrayConfig[6]);
},
: () => {
this.showDuiHua(this.duihuaArrayConfig[7], () => {
cc.tween(this.getLayerChild("左边场景2"))
.set({ active: true, opacity: 0 })
.to(0.5, { opacity: 255 })
.call(() => {
this.getLayerChild('左边场景1').active = false;
})
.start();
});
},
}
console.log("[GameReport]++++++++++++++++++++++>" + targetNode['checkNode'].name);
checkLogic[targetNode['checkNode'].name]?.();
}
nodeCheckSuccessCallback2(targetNode: cc.Node) {
let checkLogic = {
: () => {
this.getLayerChild('右边场景1', '女儿').active = false;
this.getLayerChild('右边场景1', '女儿2').active = true;
this.showDuiHua(this.duihuaArrayConfig[8], () => {
cc.tween(this.getLayerChild('右边场景1', '女儿2'))
.to(0.5, { opacity: 0 })
.set({ active: false })
.start();
this.getLayerChild('chadianNodeList2', '怀里的宝宝').active = true;
});
},
怀: () => {
this.getLayerChild('右边场景1', '女主1').active = false;
this.getLayerChild('右边场景1', '女主2').active = true;
this.getLayerChild('右边场景1', '儿子1').active = true;
this.getLayerChild('chadianNodeList2', '长大的孩子').active = true;
this.showDuiHua(this.duihuaArrayConfig[9]);
},
: () => {
this.getLayerChild('右边场景1', '儿子1').active = false;
this.getLayerChild('右边场景1', '儿子2').active = true;
this.showDuiHua(this.duihuaArrayConfig[10], () => {
cc.tween(this.getLayerChild('右边场景1', '儿子2'))
.to(0.5, { opacity: 0 })
.set({ active: false })
.start();
this.getLayerChild('右边场景1', '日历', '现在').active = true;
});
}
}
console.log("[GameReport]++++++++++++++++++++++>" + targetNode['checkNode'].name);
checkLogic[targetNode['checkNode'].name]?.();
}
nodeCheckSuccessCallback3(targetNode: cc.Node) {
let checkLogic = {
: () => {
this.getLayerChild('右边场景1', '右边场景2').active = true;
this.showDuiHua(this.duihuaArrayConfig[13]);
this.getLayerChild('chadianNodeList3', '妈妈穿着华丽').active = true;
},
穿: () => {
this.getLayerChild('右边场景1', '女主3').active = false;
this.getLayerChild('右边场景1', '女主4').active = true;
this.showDuiHua(this.duihuaArrayConfig[14]);
this.getLayerChild('chadianNodeList3', '妈妈身上带着珠宝').active = true;
},
: () => {
this.getLayerChild('右边场景1', '女主4', '首饰-老人').active = true;
this.showDuiHua(this.duihuaArrayConfig[15], () => {
this.getLayerChild('chadianNodeList4').active = true;
});
}
}
console.log("[GameReport]++++++++++++++++++++++>" + targetNode['checkNode'].name);
checkLogic[targetNode['checkNode'].name]?.();
}
//触摸回调
normalTouchCallback(targetNode: cc.Node) {
const itemLogic = {
: () => {
this.showDuiHua(this.duihuaArrayConfig[0], () => {
let index = 0;
const money = this.getLayerChild('money').children;
this.schedule(() => {
let curIndex = index, startPosi = money[index].getPosition();
cc.tween(money[curIndex])
.set({ active: true, position: cc.v3(0, 750, 0) })
.to(0.5, { position: cc.v3(startPosi.x, startPosi.y, 0) })
.call(() => {
if (curIndex >= money.length - 1) {
this.nextLayer();
}
})
.start();
index++;
}, 0.2, money.length - 1, 0);
});
},
: () => {
this.getLayerChild('右边场景1', '女主2').active = false;
this.getLayerChild('右边场景1', '女主3').active = true;
const callback_money = () => {
let index = 5;
const money = this.getLayerChild('money3').children;
this.schedule(() => {
let curIndex = index, startPosi = money[index].getPosition();
cc.tween(money[curIndex])
.set({ active: true, position: cc.v3(250, 600, 0) })
.to(0.5, { position: cc.v3(startPosi.x, startPosi.y, 0) })
.call(() => {
if (curIndex >= 9) {
this.showDuiHua(this.duihuaArrayConfig[12], () => {
this.getLayerChild('chadianNodeList3', '变成豪宅').active = true;
});
}
})
.start();
index++;
}, 0.2, 4, 0);
}
const callback_role = () => {
cc.tween(this.getLayerChild('右边场景1', '儿子3'))
.set({ active: true, position: cc.v3(500, -600, 0) })
.to(1, { position: cc.v3(265, -600, 0) })
.call(callback_money)
.start();
};
cc.tween(this.getLayerChild('右边场景1', '女儿3'))
.set({ active: true, position: cc.v3(500, -540, 0) })
.to(1, { position: cc.v3(-110, -540, 0) })
.call(() => {
let index = 0;
const money = this.getLayerChild('money3').children;
this.schedule(() => {
let curIndex = index, startPosi = money[index].getPosition();
cc.tween(money[curIndex])
.set({ active: true, position: cc.v3(-50, 500, 0) })
.to(0.5, { position: cc.v3(startPosi.x, startPosi.y, 0) })
.call(() => {
if (curIndex >= 4) {
this.showDuiHua(this.duihuaArrayConfig[11], callback_role);
}
})
.start();
index++;
}, 0.2, 4, 0);
})
.start();
},
: () => {
this.nextLayer();
},
}
console.log("+++++++++++++++++++++>" + targetNode.name);
itemLogic[targetNode.name]?.();
}
//显示对话
showDuiHua(curLog, func?) {
console.log("curLog==", curLog);
if (curLog.effectUrl) {
Common5.playEffectCustom(Common5.selectGameInfo.bundle, curLog.effectUrl);
}
let string_ = curLog.str;
let qiPaoPos_ = curLog.qiPaoPos;
let delayTime_ = curLog.delayTime || 3;
let node = this.layerNode[this.curLayerIndex];
if (qiPaoPos_ != -1) {
let qiPao = node.getChildByName("qiPao").getChildByName("qiPao_" + qiPaoPos_);
qiPao.stopAllActions()
qiPao.getChildByName("str").getComponent(cc.Label).string = string_
cc.tween(qiPao)
.set({ active: true, scale: 0 })
.to(0.2, { scale: 1 })
.delay(delayTime_)
.set({ active: false })
.start();
}
else {
let logPrefab = this.node.getChildByName('logPrefab');
let script_: logPrefabScript = logPrefab.getComponent('logPrefabScript');
script_.setDailogShow(string_, delayTime_);
}
this.scheduleOnce(() => {
if (func) {
func();
}
}, delayTime_);
}
//获取当前场景下的节点
getLayerChild(...path: string[]) {
let child = this.layerNode[this.curLayerIndex];
if (path.length > 1) {
for (const name of path) {
child = child.getChildByName(name);
}
return child;
}
return child.getChildByName(path[0]);
}
//跳转场景
nextLayer() {
this.curLayerIndex++;
for (let i = 0; i < this.layerNode.length; i++) {
if (this.layerNode[i].active) {
cc.tween(this.layerNode[i])
.delay(1.0)
.to(1, { opacity: 0 })
.call(() => {
this.layerNode[i].active = false;
this.refreshLayer();
})
.start();
} else {
this.layerNode[i].active = false;
}
};
}
//结束弹窗
endGameView(touchIndex) {
this.node.getChildByName("inputBlock").active = true;
Game.ins.stopTime();
if (touchIndex == 0) {
Game.ins.showFail();
} else {
Game.ins.showSuccess();
}
}
//解锁提示
unlockLevel(sublevel) {
Game.ins.tipUnlock(sublevel)
}
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) {
let target = event.target;
console.log('touchStartNode');
}
touchMoveNode(event) {
}
touchEndNode(event) {
let target = event.target;
let logPrefab = this.node.getChildByName('logPrefab');
logPrefab.getChildByName('duihua').active = false;
}
onClick(event) {
let target = event.target as cc.Node;
console.log("+++++++++++++++++++++>" + target.name);
Common5.playEffect("点击音效");
switch (target.name) {
case "BtnAddTimes":
default:
break;
}
}
//update(dt) { }
}