|
|
|
@ -5,7 +5,10 @@ |
|
|
|
|
// 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 Common5 from "../../Platform/th/Common5"; |
|
|
|
|
import ZaoCanManager from "../Manager/ZaoCanManager"; |
|
|
|
|
import ZaoCanDianNpc from "./ZaoCanDianNpc"; |
|
|
|
|
|
|
|
|
|
const { ccclass, property } = cc._decorator; |
|
|
|
@ -36,13 +39,7 @@ export default class ZaoCanDian extends cc.Component { |
|
|
|
|
|
|
|
|
|
npc_Position_States: Npc_Position_State[] = [{ isHaveNpc: false }, { isHaveNpc: false }, { isHaveNpc: false }] |
|
|
|
|
|
|
|
|
|
ZaoCanArr = [ |
|
|
|
|
['馒头', '肉包', '烧卖', '红薯'], |
|
|
|
|
['鸡蛋', '茶叶蛋', '玉米', '西兰花'], |
|
|
|
|
['饺子', '韭菜盒子', '鸡蛋饼', '牛排'], |
|
|
|
|
['油条', '麻球', '油饼', '鸡腿'], |
|
|
|
|
['豆浆', '小米粥', '燕麦', '咖啡机'], |
|
|
|
|
] |
|
|
|
|
ZaoCanArr = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
@ -53,6 +50,28 @@ export default class ZaoCanDian extends cc.Component { |
|
|
|
|
//NPC,头上带气泡
|
|
|
|
|
|
|
|
|
|
//点击,点击完自动上架早餐
|
|
|
|
|
|
|
|
|
|
//刷新早餐种类
|
|
|
|
|
this.refreshZaoCan() |
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.levelUpChange, () => { |
|
|
|
|
//人物升级会变更早餐
|
|
|
|
|
this.refreshZaoCan() |
|
|
|
|
}, this) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refreshZaoCan() { |
|
|
|
|
let config = ZaoCanManager.getManagerConfigDate() |
|
|
|
|
for (let i = 0; i < config.length; i++) { |
|
|
|
|
let name = ZaoCanManager.getCurNameById(config[i]) |
|
|
|
|
this.ZaoCanArr[i] = name |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 = [] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
runNpc() { |
|
|
|
@ -61,7 +80,7 @@ export default class ZaoCanDian extends cc.Component { |
|
|
|
|
let position = this.getNpcEndPosition() |
|
|
|
|
let curDirect = this.lastDirect == Npc_Direct.LEFT ? Npc_Direct.RIGHT : Npc_Direct.LEFT |
|
|
|
|
let index = Common5.getRandomNumber(0, this.ZaoCanArr.length - 1) |
|
|
|
|
npc.getComponent(ZaoCanDianNpc).init(curDirect, position, this.ZaoCanArr[index][0], index, 1) |
|
|
|
|
npc.getComponent(ZaoCanDianNpc).init(curDirect, position, this.ZaoCanArr[index], index, 1) |
|
|
|
|
this.lastDirect = curDirect |
|
|
|
|
this.npcNodes.push(npc) |
|
|
|
|
} |
|
|
|
@ -87,27 +106,37 @@ export default class ZaoCanDian extends cc.Component { |
|
|
|
|
} |
|
|
|
|
let _child |
|
|
|
|
let _position |
|
|
|
|
if (custom == "油条") { |
|
|
|
|
let tanwei = this.node.getChildByName("油条摊位") |
|
|
|
|
let children = tanwei.children |
|
|
|
|
for (const child of children) { |
|
|
|
|
if (child.active) { |
|
|
|
|
_child = child |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
_position = tanwei.convertToNodeSpaceAR(_npc.parent.convertToWorldSpaceAR(_npc.getPosition())) |
|
|
|
|
} else if (custom == "包子") { |
|
|
|
|
let tanwei = this.node.getChildByName("包子摊位") |
|
|
|
|
let children = tanwei.children |
|
|
|
|
for (const child of children) { |
|
|
|
|
if (child.active) { |
|
|
|
|
_child = child |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
// if (custom == "馒头") {
|
|
|
|
|
// let tanwei = this.node.getChildByName("馒头摊位")
|
|
|
|
|
// let children = tanwei.children
|
|
|
|
|
// for (const child of children) {
|
|
|
|
|
// if (child.active) {
|
|
|
|
|
// _child = child
|
|
|
|
|
// break
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// _position = tanwei.convertToNodeSpaceAR(_npc.parent.convertToWorldSpaceAR(_npc.getPosition()))
|
|
|
|
|
// } else if (custom == "鸡蛋") {
|
|
|
|
|
// let tanwei = this.node.getChildByName("鸡蛋摊位")
|
|
|
|
|
// let children = tanwei.children
|
|
|
|
|
// for (const child of children) {
|
|
|
|
|
// if (child.active) {
|
|
|
|
|
// _child = child
|
|
|
|
|
// break
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// _position = tanwei.convertToNodeSpaceAR(_npc.parent.convertToWorldSpaceAR(_npc.getPosition()))
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
let tanwei = this.node.getChildByName(custom + "摊位") |
|
|
|
|
let children = tanwei.children |
|
|
|
|
for (const child of children) { |
|
|
|
|
if (child.active) { |
|
|
|
|
_child = child |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
_position = tanwei.convertToNodeSpaceAR(_npc.parent.convertToWorldSpaceAR(_npc.getPosition())) |
|
|
|
|
} |
|
|
|
|
_position = tanwei.convertToNodeSpaceAR(_npc.parent.convertToWorldSpaceAR(_npc.getPosition())) |
|
|
|
|
|
|
|
|
|
if (_child) { |
|
|
|
|
cc.tween(_child) |
|
|
|
|