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

423 lines
16 KiB

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 WordGameBaseComponent from "../../../../FrameWork/Base/WordGameBaseComptent";
import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript";
import DaDianScript from "../../../../FrameWork/Base/DaDianScript";
import Game from "../../../../Scripts/WenZiRes/ui/Game";
import CccGame from "../../../WordGame/gameComScript/CccGame/CccGame";
import GameReport from "../../../../FrameWork/Report/ZyZyReport";
import XiWangZhiLuConfig from "./XiWangZhiLuConfig";
const { ccclass, property } = cc._decorator;
@ccclass
export default class XiWangZhiLuScript extends WordGameBaseComponent {
@property(cc.Node)
checkNodeList: cc.Node = null;
@property([cc.Node])
targetNodeList: cc.Node[] = [];
@property([cc.Node])
spineNodeList: cc.Node[] = [];
@property(cc.Node)
itemIconList: cc.Node = null;
@property(cc.Node)
itemIconContent: cc.Node = null;
@property(cc.Node)
itemIcon: cc.Node = null;
@property(cc.Node)
moveNode: cc.Node = null;
//当前层级下标
curLayerIndex = 0;
//当前进度
curSchedule: Set<number> = null;
roleUnitNum: number[] = [];
hiddenNode: cc.Node = null;
//文本配置
titleArrayConfig: string[] = [];
duihuaArrayConfig: any[] = [];
unitIconListConfig: any = null;
bundle = null
start() {
this.bundle = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].bundle
super.start();
DaDianScript.userEnterDaDian();
this.openTouchEvent(this.node.getChildByName('bg'));
this.initParameters();
this.initComponent();
Common5.playMusicCustom(this.bundle,'sound/场景一背景音');
}
//初始化参数
initParameters() {
this.curLayerIndex = 0;
this.curSchedule = new Set();
this.roleUnitNum = [6, 6, 5];
this.titleArrayConfig = XiWangZhiLuConfig.getInstance().getGameConfig('titleArray') as string[];
this.duihuaArrayConfig = XiWangZhiLuConfig.getInstance().getGameConfig('duihuaArray') as any[];
this.unitIconListConfig = XiWangZhiLuConfig.getInstance().getGameConfig('unitIconList');
Common.Type = 0;
Common.subLevel = this.curLayerIndex;
Common.GameSubTipConfigs = XiWangZhiLuConfig.getInstance().getGameConfig('tipsArray');
Common.GameSubAnswerConfigs = XiWangZhiLuConfig.getInstance().getGameConfig('answersArray');
EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => {
this.normalTouchCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => {
this.endGameView(0);
}, this);
}
//初始化组件
initComponent() {
// let title = this.titleArrayConfig[0];
// let lab = this.node.getChildByName("标题").getChildByName("lab");
// lab.getComponent(cc.Label).string = title;
Game.ins.setGameTitle(this.titleArrayConfig[0])
let layerNode = this.node.getChildByName("layerNode");
layerNode.active = false;
let startLayer = this.node.getChildByName("startLayer");
startLayer.active = true;
this.itemIconList.active = false;
CccGame.playAnimation(startLayer.getChildByName("xiaohai"), 'xiaohai');
cc.tween(startLayer)
.delay(1.5)
.call(() => {
Common5.playEffectCustom(this.bundle, "sound/女生掉下");
})
.delay(1.5)
.to(1, { opacity: 0 })
.set({ active: false })
.call(() => {
layerNode.active = true;
this.setIconListData();
})
.start();
this.scheduleOnce(this.setTimeNodePos, 0);
}
//设置计时位置
setTimeNodePos() {
// let timeNode = this.node.getChildByName("timeNode");
// let addtimeNode = this.node.getChildByName("tipsBtn").getChildByName("addtimeNode");
// let timeNodePos = timeNode.getPosition();
// let addtimeNodePos = addtimeNode.getPosition();
// Game.ins.setTimePos(timeNodePos.x, timeNodePos.y);
// Game.ins.setTimeScale(0.7);
// Game.ins.setTimeBtnPos(addtimeNodePos.x, addtimeNodePos.y);
}
//设置图标列表数据
setIconListData() {
Common5.playMusicCustom(this.bundle,'sound/场景二背景音');
this.itemIconList.active = true;
this.itemIcon.active = false;
for (const iterator of this.targetNodeList) {
iterator.active = false;
}
for (let index = 0; index < this.unitIconListConfig.length; index++) {
const element = this.unitIconListConfig[index];
let itemIconNode = cc.instantiate(this.itemIcon);
itemIconNode.active = true;
this.itemIconContent.addChild(itemIconNode);
let touchNode = itemIconNode.getChildByName('touchNode');
Common5.getSpriteFrameFromBundle(this.bundle, element.url, touchNode.getComponent(cc.Sprite));
if (element.name) {
itemIconNode.getChildByName('name').getComponent(cc.Label).string = element.name;
}
let checkNode = this.checkNodeList.children[index];
let func = CccGame.onNodeTouchCheckEvent(touchNode, checkNode, { touchIndex: index }, this.moveNode, checkNode);
func.setSuccessListener((data_) => {
this.itemIconTouchCallback(data_.targetNode);
func.closeTouchEvent();
});
func.setFailListener((data_) => {
this.itemIconTouchFalseCallback(data_.targetNode);
});
if (element.id == 11) {
itemIconNode.active = false;
this.hiddenNode = itemIconNode;
}
}
for (let index = 0; index < this.itemIconContent.children.length; index++) {
let aInt = Math.trunc(Math.random() * this.itemIconContent.children.length);
let random = this.itemIconContent.children[aInt];
this.itemIconContent.children[aInt] = this.itemIconContent.children[index];
this.itemIconContent.children[index] = random;
}
this.node.getChildByName("mask").active = true;
this.showDuiHua(this.duihuaArrayConfig[0], () => {
this.node.getChildByName("mask").active = false;
});
}
itemIconTouchCallback(targetNode) {
console.log("+++++++++++++++++++++>" + targetNode.checkNode.name, targetNode.touchIndex);
Common5.playEffect('放置成功');
const name = this.unitIconListConfig[targetNode.touchIndex].name;
GameReport.BtnsReport(name, Common5.selectGameInfo.titleUrl);
console.log("[GameReport]++++++++++++++++++++++>" + name);
this.curSchedule.add(targetNode.touchIndex);
targetNode.recoveparent.active = false;
if (targetNode.touchIndex == 1) {
Common5.playEffectCustom(this.bundle, "sound/挖土");
CccGame.playAnimation(this.spineNodeList[2], 'animation', true, 3, true, this.node.getChildByName("mask"));
this.scheduleOnce(() => {
this.targetNodeList[targetNode.touchIndex].active = true;
}, 3);
}
else if (targetNode.touchIndex == 2) {
this.checkNodeList.children[3].active = true;
this.checkNodeList.children[10].active = true;
this.checkNodeList.children[1].active = false;
this.targetNodeList[targetNode.touchIndex].active = true;
}
else if (targetNode.touchIndex == 11) {
this.targetNodeList[1].active = false;
this.targetNodeList[2].active = false;
this.targetNodeList[3].active = false;
this.checkNodeList.children[1].active = false;
this.checkNodeList.children[2].active = false;
this.checkNodeList.children[7].active = true;
this.checkNodeList.children[8].active = true;
this.targetNodeList[targetNode.touchIndex].active = true;
}
else if (targetNode.touchIndex == 3) {
Common5.playEffectCustom(this.bundle, "sound/电焊");
CccGame.playAnimation(this.spineNodeList[3], 'dianhan', false, 3, true, this.node.getChildByName("mask"));
this.scheduleOnce(() => {
if (!this.curSchedule.has(11)) {
this.targetNodeList[targetNode.touchIndex].active = true;
}
if (!this.curSchedule.has(7)) {
this['dianhan'] = true;
}
}, 3);
}
else if (targetNode.touchIndex == 7) {
this.checkNodeList.children[9].active = true;
this.targetNodeList[targetNode.touchIndex].active = true;
}
else if (targetNode.touchIndex == 8) {
Common5.playEffectCustom(this.bundle, "sound/洒水");
CccGame.playAnimation(this.spineNodeList[0], 'shuiguan', false, 3, true, this.node.getChildByName("mask"));
this.scheduleOnce(() => {
this.targetNodeList[targetNode.touchIndex].active = true;
}, 3);
}
else if (targetNode.touchIndex == 9) {
Common5.playEffectCustom(this.bundle, "sound/刷油漆");
CccGame.playAnimation(this.spineNodeList[0], 'shuazi', false, 3, true, this.node.getChildByName("mask"));
this.scheduleOnce(() => {
this.targetNodeList[targetNode.touchIndex].active = true;
}, 3);
}
else if (targetNode.touchIndex == 10) {
Common5.playEffectCustom(this.bundle, "sound/彩球");
this.targetNodeList[targetNode.touchIndex].active = true;
this.scheduleOnce(() => {
if (this.curSchedule.size == this.unitIconListConfig.length && this["dianhan"]) {
this.endGameView(1);
} else {
for (const iterator of this.targetNodeList) {
iterator.active = false;
}
this.targetNodeList[0].parent.active = false;
this.scheduleOnce(() => {
Common5.playEffectCustom(this.bundle, "sound/桥塌方");
}, 2);
CccGame.playAnimation(this.spineNodeList[0], 'diaoxiaqiao', false, 4, true, this.node.getChildByName("mask"));
this.scheduleOnce(() => {
this.endGameView(0);
}, 3);
}
}, 2);
}
else {
this.targetNodeList[targetNode.touchIndex].active = true;
}
if (!this['shuini'] && this.curSchedule.has(4) && this.curSchedule.has(5) && this.curSchedule.has(6)) {
this['shuini'] = true;
this.targetNodeList[4].active = false;
this.targetNodeList[5].active = false;
this.targetNodeList[6].active = false;
CccGame.playAnimation(this.spineNodeList[1], 'chanzi', true, 3, true, this.node.getChildByName("mask"));
this.scheduleOnce(() => {
let touchNode = this.hiddenNode.getChildByName('touchNode');
touchNode['recoveparent'] = touchNode.parent;
touchNode['recoveposi'] = touchNode.getPosition();
let pos = targetNode.checkNode.convertToWorldSpaceAR(cc.Vec3.ZERO);
cc.tween(touchNode)
.set({ parent: this.moveNode, position: this.moveNode.convertToNodeSpaceAR(pos) })
.delay(0.2)
.to(0.5, { position: cc.v3(0, 0) })
.set({ parent: touchNode['recoveparent'], position: touchNode['recoveposi'] })
.call(() => {
this.checkNodeList.children[11].active = true;
this.hiddenNode.active = true;
let index = this.itemIconContent.children.indexOf(this.hiddenNode) + 1;
let percent = index / this.itemIconContent.childrenCount;
this.itemIconContent.parent.getComponent(cc.ScrollView).scrollToPercentHorizontal(percent, 0.1)
cc.tween(this.hiddenNode)
.set({ color: cc.Color.YELLOW })
.delay(1)
.set({ color: cc.Color.WHITE })
.start();
})
.start();
}, 3);
}
// if (this.roleUnitNum[targetNode.roleIndex] == 0) {
// this.showDuiHua(this.duihuaArrayConfig[targetNode.roleIndex], () => {
// this.curSchedule++;
// if (this.curSchedule == this.roleUnitNum.length) {
// this.itemIconList.active = false;
// this.endGameView(1);
// return;
// }
// })
// }
}
itemIconTouchFalseCallback(targetNode) {
console.log("++++++++++++++++++++++++++++++++++++Fail!");
Common5.playEffect('放置错误');
}
//触摸回调
normalTouchCallback(targetNode) {
console.log("+++++++++++++++++++++>" + targetNode.name);
switch (targetNode.name) {
case "花瓶":
break;
default:
break;
}
}
//显示对话
showDuiHua(curLog, func?) {
console.log("curLog==", curLog);
if (curLog.effectUrl) {
Common5.playEffectCustom(this.bundle, curLog.effectUrl);
}
let string_ = curLog.str
let qiPaoPos_ = curLog.qiPaoPos
let delayTime_ = curLog.delayTime || 3;
let node = this.node.getChildByName('layerNode');
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_);
}
endGameView(touchIndex) {
this.node.getChildByName("mask").active = true;
Game.ins.stopTime();
if (touchIndex == 0) {
this.scheduleOnce(() => {
Game.ins.showFail();
}, 1.5);
} else {
this.scheduleOnce(() => {
Game.ins.showSuccess();
}, 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) {
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) { }
}