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

716 lines
29 KiB

// Learn TypeScript:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
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 TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import JieDaoManager from "../Manager/JieDaoManager";
import UserManager from "../Manager/UserManager";
import ZaoCanManager from "../Manager/ZaoCanManager";
import NewGuideScript from "../NewGuide/NewGuideScript";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
import ZaoCanDianNpc from "./ZaoCanDianNpc";
const { ccclass, property } = cc._decorator;
export enum Npc_Direct {
LEFT,
RIGHT,
}
type Npc_Position_State = {
isHaveNpc: boolean
}
@ccclass
export default class ZaoCanDian extends cc.Component {
@property([cc.Prefab])
npc_Prefabs: cc.Prefab[] = [];
@property([cc.Node])
npc_Positions: cc.Node[] = [];
@property(cc.Node)
npc_parent: cc.Node = null;
@property(cc.Node)
npc_free_parent: cc.Node = null;
@property(cc.Node)
fly_zaocan_parent: cc.Node = null;
@property(sp.Skeleton)
car: sp.Skeleton = null;
@property(sp.Skeleton)
tiehe: sp.Skeleton = null;
@property(cc.Sprite)
m_bg: cc.Sprite = null;
@property(cc.Label)
duihua: cc.Label = null;
npcNodes: cc.Node[] = [];
lastDirect: Npc_Direct = Npc_Direct.RIGHT;
npc_Position_States: Npc_Position_State[] = [{ isHaveNpc: false }, { isHaveNpc: false }, { isHaveNpc: false }]
ZaoCanArr = []
//摊位动画状态
TanWeiSpineState = [false, false, false, false, false]
SiblingIndex = 1000
m_NpcIndexs = []
m_NpcIndex = 0
m_NpcIndexValue
chatConfig = [
{ effectUrl: 'DH/MainHall/sound/老板你终于来了,顾客都在排队等着买早餐呢!', delayTime: 3.54, str: '老板你终于来了,顾客都在排队等着买早餐呢!', posi: '员工对话' },
{ effectUrl: 'DH/MainHall/sound/先把锅具摆上吧!', delayTime: 1.31, str: '先把锅具摆上吧!', posi: '员工对话' },
{ effectUrl: 'DH/MainHall/sound/客人都等着急了', delayTime: 1.32, str: '客人都等着急了', posi: '员工对话' },
{ effectUrl: 'DH/MainHall/sound/油条出锅了,快点击油条递给客人吧!', delayTime: 2.85, str: '油条出锅了,快点击油条递给客人吧!', posi: '员工对话' },
{ effectUrl: 'DH/MainHall/sound/接下来我们来升级摊位,能提升早餐售卖单价哦!', delayTime: 3.63, str: '接下来我们来升级摊位,能提升早餐售卖单价哦!', posi: '员工对话' },
{ effectUrl: 'DH/MainHall/sound/招聘员工可以增加摊位的秒赚收益哦!', delayTime: 2.8, str: '招聘员工可以增加摊位的秒赚收益哦!', posi: '员工对话' },
{ effectUrl: 'DH/MainHall/sound/好啦,老板你开始营业赚钱吧!', delayTime: 2.31, str: '好啦,老板你开始营业赚钱吧!', posi: '员工对话' },
]
isJoin: any;
clickTieHeNum: any = 0;
clickTimeOutEvent: number;
audioId;
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start() {
this.updateMainTask()
EventMgr.onEvent_custom(ryw_Event.updateMainTask, () => {
this.updateMainTask()
}, this)
//刷新早餐种类
this.refreshZaoCan()
EventMgr.onEvent_custom(ryw_Event.refreshZaoCan, () => {
//解锁会变更早餐
this.refreshZaoCan()
}, this)
//刷新街道
this.RefreshJieDao()
EventMgr.onEvent_custom(ryw_Event.RefreshJieDao, () => {
//解锁会变更早餐
this.RefreshJieDao()
}, this)
// 自动营业
EventMgr.onEvent_custom(ryw_Event.autoTimeEvent, () => {
this.autoTimeEvent()
}, this)
this.guideStep()
EventMgr.onEvent_custom(ryw_Event.swallowToucheFinishEvent, () => {
this.guideStep()
}, this)
EventMgr.onEvent_custom(ryw_Event.levelUpChange, () => {
//摊位节点名字
let names = ['馒头', '鸡蛋', '饺子', '油条', '豆浆']
//解锁了的摊位
let unlocks = ZaoCanManager.getUnlockTanWei()
for (let i = 0; i < 5; i++) {
let tanwei = this.node.getChildByName("桌子").getChildByName(names[i] + "摊位")
let name = ZaoCanManager.getCurNameByType(i)
if (unlocks.includes(names[i])) {
this.ZaoCanArr[i] = name
tanwei.active = true
} else {
this.ZaoCanArr[i] = ''
tanwei.active = false
}
}
}, this)
}
RefreshJieDao() {
Common5.getSpriteFrameFromBundle("ZaoCanDian", `res/图片${JieDaoManager.getJieDaoInUse() + 1}`, this.m_bg)
}
refreshZaoCan() {
//刷新当前摊位的早餐样式
//摊位节点名字
let names = ['馒头', '鸡蛋', '饺子', '油条', '豆浆']
//制作动画名
let animation_names1 = ['蒸', '煮', '', '', '']
//余几个的动画名
let animation_names2 = ['', '', '静止', '静止放', '']
//解锁了的摊位
let unlocks = ZaoCanManager.getUnlockTanWei()
for (let i = 0; i < 5; i++) {
let tanwei = this.node.getChildByName("桌子").getChildByName(names[i] + "摊位")
let name = ZaoCanManager.getCurNameByType(i)
if (unlocks.includes(names[i])) {
this.ZaoCanArr[i] = name
tanwei.active = true
} else {
this.ZaoCanArr[i] = ''
tanwei.active = false
}
let shengyuNum = 0
for (const child of this.fly_zaocan_parent.getChildByName(names[i] + "摊位").children) {
if (child.active) {
shengyuNum++
}
}
if (i <= 3) {
if (shengyuNum == 3) {
this.setTanWeiSpine(i, `${animation_names2[i]}${name}`, 3)
} else {
if (i == 2) {//饺子煎锅是直接补满,没有单独补的动画...
if (shengyuNum != 0) {
this.setTanWeiSpine(i, `${animation_names2[i]}${name}`, 3)
}
} else {
this.setTanWeiSpine(i, `${animation_names2[i]}${name}${shengyuNum}`, shengyuNum)
}
}
} else {
//豆浆特殊,只有1个
let tanweiSpine = tanwei.getComponent(sp.Skeleton)
tanweiSpine.setAnimation(0, name, false)
}
}
for (let i = this.npcNodes.length - 1; i >= 0; i--) {
this.npcNodes[i].removeFromParent()
this.npcNodes[i].destroy()
this.npc_Position_States[i].isHaveNpc = false
}
this.npcNodes = []
this.shuffle()
// this.runNpc()
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (User.getFirstStepIndex() != 3) {
this.unschedule(this.npcUpdate)
this.schedule(this.npcUpdate, 2)
}
}
shuffle() {
// 初始化随机npc序列
for (let i = 0; i < this.npc_Prefabs.length; i++) {
this.m_NpcIndexs[i] = i
}
this.m_NpcIndexs.sort(() => { return Math.random() - 0.5 })
this.m_NpcIndex = 0
if (this.m_NpcIndexs[this.m_NpcIndex] != this.m_NpcIndexValue) {
this.m_NpcIndexValue = this.m_NpcIndexs[this.m_NpcIndex]
} else {
this.m_NpcIndex = 1
this.m_NpcIndexValue = this.m_NpcIndexs[this.m_NpcIndex]
}
}
npcUpdate() {
this.runNpc()
}
runNpc() {
let stateIndex = this.getNpcEndIndex()
if (stateIndex != null && stateIndex != undefined) {
let npc = cc.instantiate(this.npc_Prefabs[this.m_NpcIndexValue])
this.m_NpcIndex++
if (this.m_NpcIndex > this.npc_Prefabs.length - 1) {
this.shuffle()
} else {
this.m_NpcIndexValue = this.m_NpcIndexs[this.m_NpcIndex]
}
// this.npc_parent.addChild(npc)
this.npc_parent.insertChild(npc, 0)
let curDirect = this.lastDirect == Npc_Direct.LEFT ? Npc_Direct.RIGHT : Npc_Direct.LEFT
let needNum = Common5.getRandomNumber(1, 3)
let index = Common5.getRandomNumber(0, this.ZaoCanArr.length - 1)
let haveIndexs = [] //在非空字符串里面去随机
for (let i = 0; i < this.ZaoCanArr.length; i++) {
if (this.ZaoCanArr[i] != '') {
haveIndexs.push(i)
}
}
index = haveIndexs[Common5.getRandomNumber(0, haveIndexs.length - 1)]
if (User.getFirstStepIndex() == 3) {
index = 3//油条
needNum = 1
}
npc.getComponent(ZaoCanDianNpc).init(curDirect, this.npc_Positions[stateIndex].getPosition(), this.ZaoCanArr[index], stateIndex, needNum)
// npc.getComponent(ZaoCanDianNpc).init(curDirect, this.npc_Positions[stateIndex].getPosition(), "油条", stateIndex, 1)
this.lastDirect = curDirect
this.npcNodes.push(npc)
} else {
// //逛街
// let npc = cc.instantiate(this.npc_Prefabs[Common5.getRandomNumber(0, this.npc_Prefabs.length - 1)])
// this.npc_free_parent.addChild(npc)
// let curDirect = this.lastDirect == Npc_Direct.LEFT ? Npc_Direct.RIGHT : Npc_Direct.LEFT
// npc.getComponent(ZaoCanDianNpc).init(curDirect, null, '', -1, 0)
// this.lastDirect = curDirect
}
}
getNpcEndIndex() {
// console.log(this.npc_Position_States)
let index
for (let i = 0; i < this.npc_Position_States.length; i++) {
let state = this.npc_Position_States[i]
if (!state.isHaveNpc) {
index = i
this.npc_Position_States[i].isHaveNpc = true
break
}
}
return index
}
onTouchZaoCan(event, custom) {
custom = Number(custom) //对应ZaoCanManager的zaocanConfig下标
//摊位动画正在运行直接返回
if (this.TanWeiSpineState[custom]) {
return
}
let zaoCanStr = ZaoCanManager.getCurNameByType(custom)
let _npc = this.getNpcByNeedStr(zaoCanStr)
//摊位节点名字
let names = ['馒头', '鸡蛋', '饺子', '油条', '豆浆']
//制作动画名
let animation_names1 = ['蒸', '煮', '', '', '']
//余几个的动画名
let animation_names2 = ['', '', '静止', '静止放', '']
let tanwei = this.node.getChildByName("桌子").getChildByName(names[custom] + "摊位")
let shengyuNum = 0
let _child
let children = this.fly_zaocan_parent.getChildByName(names[custom] + "摊位").children
for (let i = children.length - 1; i >= 0; i--) {
let child = children[i]
if (child.active) {
if (!_child) {
_child = child
}
shengyuNum++
}
}
if (!_npc) { //没有一个npc需要这个早餐
//补货,少几个补几个
if (custom <= 3) {//豆浆桶不需要补货
if (shengyuNum < 3) {
if (shengyuNum == 0) {
//手动补货,补全
this.setTanWeiSpine(custom, `${animation_names1[custom]}${zaoCanStr}`, 3)
} else {
if (custom == 2) {//饺子煎锅是直接补满,没有单独补的动画...
this.setTanWeiSpine(custom, `${animation_names1[custom]}${zaoCanStr}`, 3)
} else {
this.setTanWeiSpine(custom, `${animation_names1[custom]}${zaoCanStr}${shengyuNum}`, 3)
}
}
} else {
//所属物品摊位放大缩小
cc.tween(tanwei)
.sequence(
cc.tween().set({ scale: 1 }),
cc.tween().to(0.1, { scale: 1.1 }),
cc.tween().to(0.1, { scale: 1 })
)
.start()
}
}
return
}
Common5.playEffectCustom('ZaoCanDian', 'sound/通用/抛物线')
let com = _npc.getComponent(ZaoCanDianNpc)
let _position = this.fly_zaocan_parent.convertToNodeSpaceAR(com.getZaoCanWorldPosition())
if (custom <= 3) {
if (shengyuNum == 0) {
//手动补货,补全
this.setTanWeiSpine(custom, `${animation_names1[custom]}${zaoCanStr}`, 3)
return
} if (shengyuNum == 1) {
//自动补货,补全
this.setTanWeiSpine(custom, `${animation_names1[custom]}${zaoCanStr}`, 3)
} else {
this.setTanWeiSpine(custom, `${animation_names2[custom]}${zaoCanStr}${shengyuNum - 1}`, shengyuNum - 1)
}
//先减需要的量
let needNum = com.getNeedNum() - 1
com.setNeedNum(needNum)
if (_child) {
let child = cc.instantiate(_child)
child.setScale(1.3)
this.fly_zaocan_parent.addChild(child)
let startPosition = this.fly_zaocan_parent.convertToNodeSpaceAR(_child.parent.convertToWorldSpaceAR(_child.getPosition()))
child.setPosition(startPosition)
child.active = true
Common5.getSpriteFrameFromBundle("ZaoCanDian", "res/icon/" + zaoCanStr, child.getComponent(cc.Sprite))
let time = 0.5// _position.sub(startPosition).mag() / 1500
let middlePos = startPosition.add(_position).div(2)
let c1 = cc.v2(startPosition.x, middlePos.y)
let c2 = cc.v2(middlePos.x, _position.y)
cc.tween(child)
.sequence(
cc.tween().bezierTo(time, c1, c2, _position),
// cc.tween().to(time, { position: _position }),
cc.tween().call(() => {
UserManager.addMoney(ZaoCanManager.getDanJia(), child)
let com = _npc.getComponent(ZaoCanDianNpc)
com.setNeedNumLabel()
if (com.getNeedNum() == 0) {
this.npc_Position_States[com.getStateIndex()].isHaveNpc = false
com.getZaoCanAfter()
for (let j = this.npcNodes.length - 1; j >= 0; j--) {
if (this.npcNodes[j] === com.node) {
this.npcNodes.splice(j, 1)
}
}
com.setNeedNum(-1) //避免重复点击导致进多次这个判断..多次会一直重置isHaveNpc
}
child.removeFromParent()
child.destroy()
})
)
.start()
}
} else {
//先减需要的量
let com = _npc.getComponent(ZaoCanDianNpc)
let needNum = com.getNeedNum() - 1
com.setNeedNum(needNum)
//豆浆特殊
let tanweiSpine = tanwei.getComponent(sp.Skeleton)
this.TanWeiSpineState[custom] = true
tanweiSpine.setAnimation(0, `${zaoCanStr}`, false)
tanweiSpine.setCompleteListener(() => {
tanweiSpine.setCompleteListener(null)
this.TanWeiSpineState[custom] = false
let _child = this.fly_zaocan_parent.getChildByName(names[custom] + "摊位").children[0]
let child = cc.instantiate(_child)
child.setScale(1.3)
this.fly_zaocan_parent.addChild(child)
let startPosition = this.fly_zaocan_parent.convertToNodeSpaceAR(_child.parent.convertToWorldSpaceAR(_child.getPosition()))
child.setPosition(startPosition)
child.active = true
Common5.getSpriteFrameFromBundle("ZaoCanDian", "res/icon/" + zaoCanStr, child.getComponent(cc.Sprite))
let time = _position.sub(startPosition).mag() / 1500
let middlePos = startPosition.add(_position).div(2)
let c1 = cc.v2(startPosition.x, middlePos.y)
let c2 = cc.v2(middlePos.x, _position.y)
cc.tween(child)
.sequence(
cc.tween().bezierTo(time, c1, c2, _position),
// cc.tween().to(time, { position: _position }),
cc.tween().call(() => {
UserManager.addMoney(ZaoCanManager.getDanJia(), child)
let com = _npc.getComponent(ZaoCanDianNpc)
com.setNeedNumLabel()
if (com.getNeedNum() == 0) {
this.npc_Position_States[com.getStateIndex()].isHaveNpc = false
com.getZaoCanAfter()
for (let j = this.npcNodes.length - 1; j >= 0; j--) {
if (this.npcNodes[j] === com.node) {
this.npcNodes.splice(j, 1)
}
}
com.setNeedNum(-1) //避免重复点击导致进多次这个判断..多次会一直重置isHaveNpc
}
child.removeFromParent()
child.destroy()
})
)
.start()
})
}
}
getNpcByNeedStr(needStr) {
let _npc = null
for (const npc of this.npcNodes) {
if (npc.getComponent(ZaoCanDianNpc).getNeedStr() == needStr && npc.getComponent(ZaoCanDianNpc).getNeedNum() > 0) {
_npc = npc
break
}
}
return _npc
}
/**
*
* @param tanweiIndex 摊位下标
* @param animation 动画名
* @param showNum 需要显示几个早餐
* @param loop 循环播放
*/
setTanWeiSpine(tanweiIndex, animation, showNum, loop = false) {
if (!showNum) {
return
}
// 制作音效
if (showNum == 3) {
let effecturl = ZaoCanManager.getEffectUrlByType(tanweiIndex)
Common5.playEffectCustom('ZaoCanDian', effecturl)
}
let names = ['馒头', '鸡蛋', '饺子', '油条', '豆浆']
let tanwei = this.node.getChildByName("桌子").getChildByName(names[tanweiIndex] + "摊位")
let tanweiSpine = tanwei.getComponent(sp.Skeleton)
this.TanWeiSpineState[tanweiIndex] = true
tanweiSpine.setCompleteListener(() => {
tanweiSpine.setCompleteListener(null)
this.TanWeiSpineState[tanweiIndex] = false
if (showNum == 3) {
// if (tanweiIndex == 0) {
// Common5.playEffectCustom('ZaoCanDian', 'sound/蒸笼/出锅')
// }
this.scheduleOnce(() => {
// Common5.playEffectCustom('ZaoCanDian', 'sound/通用/制作完成')
let spine = tanwei.getChildByName("获取光效").getComponent(sp.Skeleton)
spine.node.active = true
spine.setAnimation(0, "animation", false)
})
}
for (let i = 3; i > 0; i--) {
if (showNum >= i) {
console.log("显示===", i)
this.fly_zaocan_parent.getChildByName(names[tanweiIndex] + "摊位").getChildByName(`${i}`).active = true
} else {
this.fly_zaocan_parent.getChildByName(names[tanweiIndex] + "摊位").getChildByName(`${i}`).active = false
}
}
if (User.getFirstStepIndex() == 3) {
this.showYuanGongChat(3, () => {
User.setFirstStepIndex(4)
let tanwei = this.node.getChildByName("桌子").getChildByName("油条摊位").getChildByName("touch")
this.guideView([tanwei, tanwei, tanwei])
})
}
})
tanweiSpine.setAnimation(0, animation, loop)
}
onTouchYeWu() {
}
onTouchShengJi() {
}
onTouchCar() {
this.car.setAnimation(0, "开走", false)
this.car.setCompleteListener(() => {
this.car.setCompleteListener(null)
cc.tween(this.car.node)
.by(0.2, { position: cc.v3(-100, 0, 0) })
.start()
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId == MainTaskIdEnum.MainTask_303 || mainId == MainTaskIdEnum.MainTask_401 || mainId == MainTaskIdEnum.MainTask_402) {
this.node.parent.parent.removeFromParent()
this.node.parent.parent.destroy()
PrefabManage.loadPrefabByType(GameType.Room2)
} else if (mainId == MainTaskIdEnum.MainTask_501) {
this.node.parent.parent.removeFromParent()
this.node.parent.parent.destroy()
PrefabManage.loadPrefabByType(GameType.DH_1)
} else if (mainId == MainTaskIdEnum.MainTask_503) {
this.node.parent.parent.removeFromParent()
this.node.parent.parent.destroy()
PrefabManage.loadPrefabByType(GameType.DH_5)
} else if (mainId == MainTaskIdEnum.MainTask_602) {
this.node.parent.parent.removeFromParent()
this.node.parent.parent.destroy()
PrefabManage.loadPrefabByType(GameType.GameStory4)
} else if (mainId == MainTaskIdEnum.MainTask_605 || mainId == MainTaskIdEnum.MainTask_606) {
this.node.parent.parent.removeFromParent()
this.node.parent.parent.destroy()
PrefabManage.loadPrefabByType(GameType.DH_3)
} else if (mainId == MainTaskIdEnum.MainTask_701 || mainId == MainTaskIdEnum.MainTask_702) {
this.node.parent.parent.removeFromParent()
this.node.parent.parent.destroy()
PrefabManage.loadPrefabByType(GameType.DH_4)
}
})
}
updateMainTask() {
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
let config = TaskManager.getTaskConfigById(mainId)
let index = User.getFirstStepIndex()
if (config && config.wanFaRuKouTip && config.wanFaRuKouTip.includes('rk_chuZuChe')) {
this.car.node.active = true
this.car.setAnimation(0, "空车", false)
this.car.node.setPosition(cc.v3(0, this.car.node.position.y, 0))
} else {
this.car.node.active = false
}
}
onTouchTieHe() {
clearTimeout(this.clickTimeOutEvent);
this.clickTieHeNum++
if (this.clickTieHeNum == 1) {
cc.audioEngine.stop(this.audioId)
Common5.playRemoteAudioEffect_id('effect/铁盒子点击音效', true, (id) => {
this.audioId = id
})
}
this.clickTimeOutEvent = setTimeout(() => {
this.clickTieHeNum = 0
cc.audioEngine.stop(this.audioId)
}, 500);
this.tiehe.setAnimation(0, "抖动", false)
let level = User.getMyLevel()
let money = Math.ceil(2 * Math.pow(1.025, (level - 1)))
UserManager.addMoneyOne(money, this.tiehe.node)
}
autoTimeEvent() {
let names = ['馒头', '鸡蛋', '饺子', '油条', '豆浆']
let autoClickTime = User.getAutoClickTime()
if (autoClickTime <= 0) {
} else {
for (let i = 0; i < 5; i++) {
let zaoCanStr = ZaoCanManager.getCurNameByType(i)
let _npc = this.getNpcByNeedStr(zaoCanStr)
if (_npc) {
this.onTouchZaoCan(this.node.getChildByName("桌子").getChildByName(names[i] + "摊位").getChildByName("touch"), i)
}
}
this.node.getChildByName("桌子").getChildByName("钱盒").getChildByName("手指箭头").active = true
}
}
showYuanGongChat(index, callback?, isNotHide?) {
this.node.getChildByName("员工对话框").active = true
let chat = this.chatConfig[index]
this.duihua.string = chat.str
if (chat.effectUrl && chat.effectUrl.length > 0) {
Common5.playRemoteAudioEffect(chat.effectUrl);
}
this.scheduleOnce(() => {
if (isNotHide) {
} else {
this.node.getChildByName("员工对话框").active = false
}
callback && callback()
}, chat.delayTime)
}
onTouchStartBaiTan() {
this.node.getChildByName("员工对话框").active = false
this.node.getChildByName("开始摆摊").active = false
let tanwei = this.node.getChildByName("桌子").getChildByName("油条摊位")
tanwei.active = true
let touch = tanwei.getChildByName("touch")
for (let i = 0; i < 3; i++) {
this.runNpc()
}
this.scheduleOnce(() => {
this.showYuanGongChat(2, () => {
this.guideView([touch], 150)
})
}, 2)
}
guideStep() {
let index = User.getFirstStepIndex()
if (index == 3 && !this.isJoin) { //早餐摊引导
this.isJoin = true
let names = ['馒头', '鸡蛋', '饺子', '油条', '豆浆']
for (let i = 0; i < names.length; i++) {
let tanwei = this.node.getChildByName("桌子").getChildByName(names[i] + "摊位")
tanwei.active = false
}
let othernames = ['碗1', '铁盆', '钱盒', '碗']
for (const element of othernames) {
this.node.getChildByName("桌子").getChildByName(element).active = false
}
this.showYuanGongChat(0, () => {
this.node.getChildByName("开始摆摊").active = true
this.guideView([this.node.getChildByName("开始摆摊")])
this.showYuanGongChat(1, null, true)
})
} else if (index == 4) {
this.scheduleOnce(() => {
User.setFirstStepIndex(5)
this.showYuanGongChat(4, () => {
EventMgr.emitEvent_custom(ryw_Event.swallowToucheFinishEvent)
})
}, 1)
} else if (index == 6) {
User.setFirstStepIndex(7)
this.showYuanGongChat(5, () => {
EventMgr.emitEvent_custom(ryw_Event.swallowToucheFinishEvent)
})
} else if (index == 8) {
this.showYuanGongChat(6, () => {
// let names = ['馒头', '鸡蛋', '饺子', '油条', '豆浆']
// for (let i = 0; i < names.length; i++) {
// let tanwei = this.node.getChildByName("桌子").getChildByName(names[i] + "摊位")
// tanwei.active = true
// }
let othernames = ['碗1', '铁盆', '钱盒', '碗']
for (const element of othernames) {
this.node.getChildByName("桌子").getChildByName(element).active = true
}
this.refreshZaoCan()
})
User.setFirstStepIndex(9)
}
}
guideView(nodeArray, opacity = -1) {
PrefabManage.loadPrefabByType(GameType.GuideMskNode, this.node, (prefab) => {
// prefab.zIndex = 199
let guideNodeArray = nodeArray
let firstNode = guideNodeArray.shift()
prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray)
if (opacity != -1) {
prefab.getComponent(NewGuideScript).setOpacityMaskNode(opacity)
}
})
}
// update (dt) {}
}