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

264 lines
8.5 KiB

3 months ago
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 ItemIconList from "../../../WordGame/gameComScript/ItemIconList/ItemIconList";
// import TaXiangChuQuChuangChuangConfigs from "./TaXiangChuQuChuangChuangConfigs";
const { ccclass, property } = cc._decorator;
@ccclass
export default class TaXiangChuQuChuangChuang extends WordGameBaseComponent {
@property(cc.Node)
ItemIconList: cc.Node = null;
@property(cc.Node)
checkNodeList: cc.Node = null;
@property(cc.Node)
targetNodeList: cc.Node[] = [];
@property(cc.Node)
xiaoyuanNode: cc.Node = null;
@property(cc.Node)
baocheck: cc.Node = null;
//当前层级下标
curLayerIndex = 0;
//当前进度
curSchedule: Set<number> = null;
//文本配置
duihuaArrayConfig: any[] = [];
unitListConfig: any = null;
chuanxiaofuState = false
nashuState = false
//计时
Timer = 0;
start() {
super.start();
Common5.playMusicCustom('TaXiangChuQuChuangChuang','sound/背景');
DaDianScript.userEnterDaDian();
Common5.stopMusic()
// this.initParameters();
// this.initComponent();
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/TaXiangChuQuChuangChuangConfigs',(assest)=>{
//this.jsonData = JSON.stringify(assest.json)
this.jsonData =assest.json
this.initParameters();
this.initComponent();
} )
}
onDestroy(): void {
}
//初始化参数
initParameters() {
this.curSchedule = new Set();
this.duihuaArrayConfig = this.jsonData.duihuaArray//TaXiangChuQuChuangChuangConfigs.getInstance().getGameConfig('duihuaArray');
this.unitListConfig = this.jsonData.unitList//TaXiangChuQuChuangChuangConfigs.getInstance().getGameConfig('unitList');
Common.Type = 0;
Common.subLevel = 0;
Common.GameSubTipConfigs = this.jsonData.tipsArray//TaXiangChuQuChuangChuangConfigs.getInstance().getGameConfig('tipsArray');
Common.GameSubAnswerConfigs = this.jsonData.answersArray//TaXiangChuQuChuangChuangConfigs.getInstance().getGameConfig('answersArray');
EventMgr.onEvent_custom(ryw_Event.itemIconTouchTrue, (data_) => {
this.itemIconTouchCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => {
this.endGameView(0);
}, this);
EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (tab) => {
Game.ins.stopTime();
let curLog = { str: '永远都怀念我的十五岁', qiPaoPos: 0, effectUrl: 'sound/永远都怀念我的十五岁'}
this.showDuiHua(curLog, ()=>{
this.endGameView(1);
})
}, this);
}
//初始化组件
initComponent() {
let lab = this.node.getChildByName("标题").getChildByName("lab");
lab.getComponent(cc.Label).string = this.jsonData.titleArray//TaXiangChuQuChuangChuangConfigs.getInstance().getGameConfig('titleArray');
let title = this.jsonData.titleArray//TaXiangChuQuChuangChuangConfigs.getInstance().getGameConfig('titleArray');
Game.ins.setGameTitle(title)
let scrZhuang: ItemIconList = this.ItemIconList.getComponent("ItemIconList");
scrZhuang.setIconListData(this.unitListConfig.unitIconList, this.checkNodeList.children, this.targetNodeList);
}
itemIconTouchCallback(targetNode: any) {
console.log("+++++++++++++++++++>" + targetNode.iconIndex);
this.curSchedule.add(targetNode.iconIndex);
if(targetNode.iconIndex == 0){
this.nashuState = true
}
if(targetNode.iconIndex == 10){
this.chuanxiaofuState = true
}
if(this.nashuState || this.chuanxiaofuState){
this.xiaoyuanNode.getChildByName('后手').active = false
}
if(targetNode.iconIndex == 0){
if(this.chuanxiaofuState){
this.xiaoyuanNode.getChildByName('校服').getChildByName('后袖子').active = false
this.xiaoyuanNode.getChildByName('书本').getChildByName('书').active = false
this.xiaoyuanNode.getChildByName('书本').getChildByName('前手').active = false
this.xiaoyuanNode.getChildByName('书本').getChildByName('校服书').active = true
}else{
this.xiaoyuanNode.getChildByName('书本').getChildByName('书').active = true
this.xiaoyuanNode.getChildByName('书本').getChildByName('前手').active = true
this.xiaoyuanNode.getChildByName('书本').getChildByName('校服书').active = false
}
}
if(this.chuanxiaofuState){
if(this.nashuState){
this.xiaoyuanNode.getChildByName('校服').getChildByName('后袖子').active = false
this.xiaoyuanNode.getChildByName('书本').getChildByName('书').active = false
this.xiaoyuanNode.getChildByName('书本').getChildByName('前手').active = false
this.xiaoyuanNode.getChildByName('书本').getChildByName('校服书').active = true
}else{
}
}
console.log("+++++++++++++++++++数目>" + this.curSchedule.size);
if(this.curSchedule.size == this.unitListConfig.unitIconList.length){
this.ItemIconList.active = false
let curLog = { str: '好想找回我流失的青春', qiPaoPos: 0, effectUrl: 'sound/好想找回我流失的青春'}
this.showDuiHua(curLog, ()=>{
this.baocheck.active = true
})
}
}
//对话
showDuiHua(curLog, func?) {
console.log("curLog==", curLog);
if (curLog.effectUrl) {
Common5.playEffectCustom("TaXiangChuQuChuangChuang", curLog.effectUrl);
}
let string_ = curLog.str
let qiPaoPos_ = curLog.qiPaoPos
let delayTime_ = curLog.delayTime || 3;
if (qiPaoPos_ != -1) {
let qiPaoList = this.node.getChildByName("qiPao");
let qiPao = qiPaoList.getChildByName("qiPao_" + qiPaoPos_);
qiPao.stopAllActions()
qiPao.getChildByName("str").getComponent(cc.Label).string = string_
qiPao.active = true
qiPao.scale = 0
cc.tween(qiPao)
.to(0.2, { scale: 1 })
.delay(delayTime_)
.call(() => {
qiPao.active = false
})
.start();
}
this.scheduleOnce(() => {
if (func) {
func();
}
}, delayTime_);
}
endGameView(touchIndex) {
this.node.getChildByName("mask").active = true;
Game.ins.stopTime();
this.scheduleOnce(() => {
// this.node.getChildByName("mask").active = true;
if (touchIndex == 0) {
Game.ins.showFail();;
} else {
Game.ins.showSuccess();;
}
}, 3)
}
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;
}
onClick(event) {
let target = event.target;
console.log("+++++++++++++++++++>" + target.name);
switch (target.name) {
case "button":
break;
default:
break;
}
}
//update(dt) { }
}