// 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 AudioManager from "../AudioManager"; import Character from "../Character/Character"; import EventName from "../EventName/EventName"; import LocalData from "../LocalData"; import MyMap from "../Map/MyMap"; import RewardMnr from "../Template/RewardMnr"; import Prop from "./Prop"; const { ccclass, property } = cc._decorator; @ccclass export default class GameProp1002 extends Prop { // onLoad () {} //触发几次获得奖励 triggerCount = 1 //完事之后自己是否消失 IsDeleteMe = true protected onEnable(): void { this.node.active = RewardMnr.getInstance().isEnable(this.Flag()) } onCollisionEnter(other: cc.CircleCollider, self: cc.BoxCollider) { if (this.triggerCount <= 0) { console.error('失效了'); this.getComponent(cc.BoxCollider).enabled = false return } //如果碰撞了玩家 if (other.node.getComponent(Character)) { this.triggerCount-- if (this.triggerCount <= 0 && this.IsDeleteMe) { this.Reaward() } } } //奖励的方法 Reaward() { let RoundState = this.getComponentInChildren(sp.Skeleton).setAnimation(0, '奖杯', false); this.scheduleOnce(() => { let NextLevel = cc.Canvas.instance.node.getChildByName('Map').getComponent(MyMap).MapjsonData.NextLevel if (!NextLevel) { console.log('通关'); if (LocalData.getInstance().getOverCount() == 0) {//首次通关 LocalData.getInstance().setOverCount(1) } else { LocalData.getInstance().setOverCount(LocalData.getInstance().getOverCount() + 1) } LocalData.getInstance().setMap(1) cc.systemEvent.emit(EventName.Over); this.scheduleOnce(() => { cc.director.loadScene("Hall") }, 3) return } LocalData.getInstance().setMap(NextLevel) if (NextLevel > 0) { cc.director.loadScene("Game") } else { cc.director.loadScene("Hall") } }, RoundState.animationEnd) } }