123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- import FqLogin from "../../../login/FqLogin";
- import { AudioMgr } from "../../../main/ViewManage";
- import FPanelIcon from "../object/FPanelIcon";
- import BaseEvent from "./base/BaseEvent";
- /**
- * 宝箱
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class FTreasureBox extends BaseEvent {
- @property({
- displayName: '地图元素id'
- })
- boxId: string = '28';
- @property([cc.String])
- text: Array<string> = [];
- @property(sp.Skeleton)
- spine: sp.Skeleton = null;
- @property({
- displayName: '提示图标',
- type: cc.SpriteFrame
- })
- mTipsIcon: cc.SpriteFrame = null;
- @property(cc.Node)
- guides: Array<cc.Node> = [];//引导标识
- @property({
- displayName: '是否需要引导穿装备'
- })
- isGuide: boolean = false
- @property({
- displayName: '指引步骤'
- })
- guideStep: number = 0;
- /**
- * 控制的栅栏机关
- */
- @property({
- displayName: '控制的机关',
- type: [cc.Node],
- })
- mFenceTrigger: Array<cc.Node> = [];
- @property({
- displayName: '消失的提示',
- type: cc.Node
- })
- mCancelNode: cc.Node = null;
- private isOpen = false;
- onLoad() {
- super.onLoad()
- let stage = this.ff.main.player.stage;
- if (stage.element.indexOf(this.boxId) >= 0) {
- this.node.destroy();
- for (let i = 0; i < this.mFenceTrigger.length; i++) {
- const element = this.mFenceTrigger[i];
- element.destroy()
- }
- }
- }
- /**
- * 主角进入碰撞区域
- */
- public onBegin(tag: number) {
- if (this.isOpen) {
- return
- }
- if (tag == 1) {
- this.showOpt(this.mTipsIcon, () => {
- if (this.mCancelNode) {
- this.mCancelNode.destroy()
- }
- this.openBox();
- })
- }
- }
- /**
- * 主角离开碰撞区域
- */
- public onEnd(tag: number) {
- if (tag == 1) {
- this.closeOpt()
- }
- }
- private openBox() {
- this.closeOpt()
- this.isOpen = true;
- this.pause()
- for (let i = 0; i < this.guides.length; i++) {
- const element = this.guides[i];
- element.destroy();
- }
- this.guides = [];
- this.spine.setCompleteListener(() => {
- FqLogin.commitEvent(this.node.name, '', '');
- this.spine.setCompleteListener(null);
- //与服务器通讯
- this.getMapObject(this.boxId, () => {
- this.showDialog1()
- })
- });
- this.spine.setAnimation(0, 'open', false);
- this.ff.main.playerEffectByPath(AudioMgr.box);
- }
- private showDialog1() {
- if (this.text.length <= 0) {
- this.resume()
- return
- }
- this.showDialog(this.ff.mainSprite.node, this.text, () => {
- this.resume()
- if (this.isGuide) {
- if (this.guideStep == 0) {
- this.guide()
- } else if (this.guideStep == 1) {
- this.guide_1()
- }
- }
- })
- }
- /**
- * 开始引导穿装备
- */
- private guide() {
- for (let i = 0; i < this.mFenceTrigger.length; i++) {
- const element = this.mFenceTrigger[i];
- element.destroy()
- }
- let main = this.ff.main
- let guideMask = main.mGuideMask
- let res = this.ff.fres;
- let hudNode = res.mHudNode.children[0]
- guideMask.setTargetNode(hudNode)
- guideMask.show()
- let panelIcon = hudNode.getComponent(FPanelIcon)
- panelIcon.inGuide = true
- panelIcon.setGuideCallback(() => {
- panelIcon.setGuideCallback(null)
- guideMask.close();
- this.ff.firstGetSkillTips();
- })
- }
- /**
- * 开始引导强化装备
- */
- private guide_1() {
- for (let i = 0; i < this.mFenceTrigger.length; i++) {
- const element = this.mFenceTrigger[i];
- element.destroy()
- }
- let main = this.ff.main
- let guideMask = main.mGuideMask
- let res = this.ff.fres;
- let hudNode = res.mHudNode.children[0];
- guideMask.setTargetNode(hudNode);
- guideMask.show();
- let panelIcon = hudNode.getComponent(FPanelIcon);
- panelIcon.inGuide = true;
- panelIcon.guideStep = this.guideStep;
- panelIcon.setGuideCallback(() => {
- guideMask.close();
- })
- }
- }
|