329 lines
11 KiB
329 lines
11 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 ChooseBtnLayer from "../../../WordGame/gameComScript/ChooseBtnLayer";
|
|
import DaDianScript from "../../../FrameWork/Base/DaDianScript";
|
|
import Game from "../../../Scripts/Game";
|
|
import DuiHuaScript from "../../../WordGame/guizeGame/comScript/DuiHuaScript";
|
|
import GZTipBtnScript from "../../../WordGame/guizeGame/comScript/GZTipBtnScript";
|
|
import GuiZeLayer from "../../../WordGame/guizeGame/comScript/GuiZeLayer";
|
|
import MeiRenYuConfig from "./MeiRenYuConfig";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class QiPaWaWaScript extends WordGameBaseComponent {
|
|
|
|
@property(cc.Node)
|
|
layerArray: cc.Node[] = [];
|
|
|
|
@property(cc.Node)
|
|
resultLayer: cc.Node[] = [];
|
|
|
|
@property(cc.Node)
|
|
resultNpc: cc.Node[] = [];
|
|
|
|
@property(cc.Node)
|
|
GZTipBtn: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
GuiZeLayer: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
DuiHuaPrefab: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
xiaoyugang: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
yuGangShui: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
yuGangNode: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
xiaoGuo: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
qingJiCancelTouchList: cc.Node[] = [];
|
|
|
|
@property(cc.Node)
|
|
qingJiCancelTouchList2: cc.Node[] = [];
|
|
|
|
@property(cc.Node)
|
|
chuanglianList: cc.Node[] = [];
|
|
|
|
|
|
//当前层级
|
|
curLayerIndex = 0;
|
|
//当前进度
|
|
isReadGuize = 0;
|
|
chooseArrayName: string = "";
|
|
scheduleList: Map<string, boolean> = null;
|
|
|
|
//文件配置
|
|
titleArrayConfig: string[] = null;
|
|
duihuaArrayConfig: [] = null;
|
|
resultDuihuaArrayConfig: [] = null;
|
|
failArrayConfig: any[] = null;
|
|
|
|
|
|
bundle = null
|
|
start() {
|
|
this.bundle = Common5.gameConfig.zmGameConfig[Common5.selectGameNum].bundle
|
|
super.start();
|
|
DaDianScript.userEnterDaDian();
|
|
this.initParameters();
|
|
this.initComponent();
|
|
Common5.playMusicCustom(this.bundle,'sound/背景音乐');
|
|
}
|
|
|
|
//初始化参数
|
|
initParameters() {
|
|
this.isReadGuize = 0;
|
|
this.scheduleList = new Map();
|
|
|
|
this.titleArrayConfig = MeiRenYuConfig.getInstance().getGameConfig('titleArray');
|
|
this.duihuaArrayConfig = MeiRenYuConfig.getInstance().getGameConfig('duihuaArray');
|
|
this.resultDuihuaArrayConfig = MeiRenYuConfig.getInstance().getGameConfig('resultDuihuaArray');
|
|
this.failArrayConfig = MeiRenYuConfig.getInstance().getGameConfig('failArray');
|
|
Common.GameSubTipConfigs = MeiRenYuConfig.getInstance().getGameConfig('tipsArray');
|
|
Common.Type = 0
|
|
Common.GameSubChooseArray = MeiRenYuConfig.getInstance().getGameConfig('chooseArray');
|
|
Common.GameguizeArray = MeiRenYuConfig.getInstance().getGameConfig('GameguizeArray');
|
|
Common.GameSubAnswerConfigs = MeiRenYuConfig.getInstance().getGameConfig('answersArray');
|
|
EventMgr.onEvent_custom(ryw_Event.openGuizeLayerEvent, (data) => {
|
|
this.guizeBtnCallback();
|
|
}, this);
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.GuiZeGameBtnClick, (data) => {
|
|
this.guizePaperCallback(data.touchIndex);
|
|
}, this);
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => {
|
|
this.touchMoveCallback(data_.targetNode);
|
|
}, this);
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => {
|
|
this.touchMoveCallback(data_.targetNode);
|
|
}, this);
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.DirectTouchMoveCheck, (data_) => {
|
|
this.touchMoveCallback(data_.targetNode);
|
|
}, this);
|
|
|
|
}
|
|
|
|
//初始化组件
|
|
initComponent() {
|
|
for (const node of this.layerArray) {
|
|
node.active = false;
|
|
}
|
|
this.refreshLayer();
|
|
}
|
|
|
|
//更新层级
|
|
refreshLayer() {
|
|
this.layerArray[this.curLayerIndex].active = true;
|
|
|
|
// let title = this.titleArrayConfig[this.curLayerIndex];
|
|
// let titleLab = this.node.getChildByName('标题').getChildByName('lab').getComponent(cc.Label);
|
|
// if (titleLab.string) {
|
|
// titleLab.string = title;
|
|
// }
|
|
Game.ins.setGameTitle(this.titleArrayConfig[0])
|
|
|
|
this.refreshTipBtn();
|
|
this.theStartStep();
|
|
}
|
|
|
|
//更新规则
|
|
refreshTipBtn() {
|
|
Common.subLevel = 0//this.curLayerIndex * 2 + this.isReadGuize;
|
|
let tipScr: GZTipBtnScript = this.GZTipBtn.getComponent('GZTipBtnScript');
|
|
tipScr.refreshTipsCurView();
|
|
}
|
|
|
|
//开头语言
|
|
theStartStep() {
|
|
const startSteps = [0, -1, -1];
|
|
let stepIndex = startSteps[this.curLayerIndex];
|
|
const callBacks = [null, null, null];
|
|
let onComplete = callBacks[this.curLayerIndex];
|
|
this.showDuihua(stepIndex, onComplete);
|
|
}
|
|
|
|
//显示对话
|
|
showDuihua(stepIndex: number, func?: Function) {
|
|
this.DuiHuaPrefab.active = true;
|
|
let script_: DuiHuaScript = this.DuiHuaPrefab.getComponent('DuiHuaScript');
|
|
let duihua = this.duihuaArrayConfig[stepIndex];
|
|
script_.setDuihuaArray(this.bundle,duihua, func);
|
|
}
|
|
|
|
//显示结果对话
|
|
showDuihuaResult(duihuaIndex, func?: Function) {
|
|
this.DuiHuaPrefab.active = true;
|
|
let script_: DuiHuaScript = this.DuiHuaPrefab.getComponent('DuiHuaScript');
|
|
let duihuaArray = this.resultDuihuaArrayConfig[duihuaIndex];
|
|
script_.setDuihuaArray(this.bundle,duihuaArray, func);
|
|
}
|
|
|
|
//显示选项
|
|
showChooseLayer(chooseArrayName: string) {
|
|
let ChooseLayer = this.node.getChildByName('GZChooseLayer2');
|
|
ChooseLayer.active = true;
|
|
|
|
this.chooseArrayName = chooseArrayName;
|
|
Common.GameSubChooseArray = MeiRenYuConfig.getInstance().getGameConfig(chooseArrayName);
|
|
let script_: ChooseBtnLayer = ChooseLayer.getComponent('ChooseBtnLayer');
|
|
script_.setChooseBtnView();
|
|
}
|
|
|
|
//规则按键回调
|
|
guizeBtnCallback() {
|
|
this.GuiZeLayer.active = true;
|
|
let script_: GuiZeLayer = this.GuiZeLayer.getComponent('GuiZeLayer');
|
|
script_.refreshView();
|
|
}
|
|
|
|
//规则纸回调
|
|
guizePaperCallback(touchIndex: number) {
|
|
if (this.isReadGuize == 1) return;
|
|
this.isReadGuize = 1;
|
|
|
|
this.refreshTipBtn();
|
|
|
|
this.GuiZeLayer.active = true;
|
|
let script_: GuiZeLayer = this.GuiZeLayer.getComponent('GuiZeLayer')
|
|
script_.setGuizeArray(this.curLayerIndex);
|
|
|
|
console.log("+++++++++++++++++++++++++++++++++++>" + touchIndex);
|
|
if (touchIndex == 1) {
|
|
let layer = this.layerArray[this.curLayerIndex];
|
|
layer.getChildByName("shoubi").active = false;
|
|
this.xiaoyugang.active = true;
|
|
}
|
|
}
|
|
|
|
//触摸移动回调
|
|
touchMoveCallback(targetNode) {
|
|
|
|
console.log("+++++++++++++++++++++++++++++++++++>" + targetNode.name);
|
|
this.scheduleList.set(targetNode.name, true);
|
|
|
|
switch (targetNode.name) {
|
|
case "shuilongtou":
|
|
cc.tween(this.yuGangShui)
|
|
.to(4, { height: 250 })
|
|
.start();
|
|
this.yuGangNode.active = true;
|
|
for (const iterator of this.qingJiCancelTouchList) {
|
|
if ((<any>iterator).scr) {
|
|
(<any>iterator).scr.cancelTouchEvent();
|
|
}
|
|
}
|
|
break;
|
|
case "chuanglian1":
|
|
for (const iterator of this.qingJiCancelTouchList2) {
|
|
if ((<any>iterator).scr) {
|
|
(<any>iterator).scr.cancelTouchEvent();
|
|
}
|
|
}
|
|
break;
|
|
case "chuixianghailuo":
|
|
this.xiaoGuo.active = true;
|
|
this.scheduleOnce(() => {
|
|
this.chuanglianList[0].active = false;
|
|
this.chuanglianList[1].active = true;
|
|
this.chuanglianList[2].active = true;
|
|
this.xiaoGuo.active = false;
|
|
}, 2);
|
|
break;
|
|
case "chuanglian3":
|
|
if (this.scheduleList.has("tuoba") && this.scheduleList.has("qingjieji") && this.scheduleList.has("mabu")) {
|
|
if (this.scheduleList.has("yan")) {
|
|
if (this.scheduleList.has("yifu")) {
|
|
this.resultNpc[3].active = true;
|
|
this.resultLayer[3].active = true;
|
|
this.showDuihuaResult(3, () => {
|
|
Game.ins.showSuccess();
|
|
});
|
|
} else {
|
|
this.failShow(2);
|
|
}
|
|
} else {
|
|
this.failShow(1);
|
|
}
|
|
} else {
|
|
this.failShow(0);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
//跳转场景
|
|
openNextLayer(event?: any) {
|
|
if (event) {
|
|
if (!event.target.active) return;
|
|
event.target.active = false;
|
|
}
|
|
let node = this.layerArray[this.curLayerIndex];
|
|
cc.tween(node)
|
|
.to(3.0, { opacity: 0 })
|
|
.delay(1.0)
|
|
.call(() => {
|
|
node.active = false;
|
|
this.curLayerIndex++;
|
|
this.isReadGuize = 0;
|
|
this.refreshLayer();
|
|
})
|
|
.start();
|
|
}
|
|
|
|
//失败展示
|
|
failShow(curResultIndex, isshowDuihua = true, callFunc?: Function) {
|
|
Common5.playEffect("人物跳脸");
|
|
|
|
this.resultNpc[curResultIndex].active = true;
|
|
|
|
let failInfo = this.failArrayConfig[curResultIndex];
|
|
let node = this.resultLayer[curResultIndex]
|
|
// let renwuNode = node.getChildByName('renwuNode')
|
|
// renwuNode.scale = 0.01
|
|
// let zhuahengBg = node.getChildByName('zhuahengBg')
|
|
node.active = true
|
|
|
|
if (isshowDuihua) {
|
|
this.showDuihuaResult(curResultIndex, () => {
|
|
// Game.ins.showFail2(failInfo.img, failInfo.tips);
|
|
Game.ins.showFail()
|
|
});
|
|
}
|
|
|
|
// cc.tween(renwuNode)
|
|
// .to(0.3, { scale: 1 }, { easing: 'elasticOut' })
|
|
// .delay(1.0)
|
|
// .call(() => {
|
|
// if (zhuahengBg) {
|
|
// Common5.playEffect("跳脸抓痕");
|
|
// zhuahengBg.active = true
|
|
// let zhuhen = zhuahengBg.getChildByName('抓痕')
|
|
// zhuhen.getComponent(sp.Skeleton).setAnimation(0, 'animation', false)
|
|
// }
|
|
// if (callFunc) {
|
|
// callFunc()
|
|
// }
|
|
// this.scheduleOnce(() => {
|
|
|
|
// }, 2)
|
|
// })
|
|
// .start();
|
|
}
|
|
|
|
}
|
|
|