123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- import FqLogin from "../../../../login/FqLogin";
- import { AudioMgr } from "../../../../main/ViewManage";
- import FF from "../../FF";
- import FMap from "../../map/FMap";
- import { GroupType } from "../../object/FObject";
- import FSprite from "../../object/FSprite";
- import BaseEvent from "../base/BaseEvent";
- import FMapDialog from "../dialog/FMapDialog";
- import FAltar from "./FAltar";
- import FAltarGear from "./FAltarGear";
- const SpineName = {
- IDLE: "idle",
- IDLE2: "idle2",
- CLOSE: "close",
- OPEN: "open"
- }
- /**
- * 祭坛灯柱
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class FAltarLight extends BaseEvent {
- @property({
- displayName: '对应的地图物件'
- })
- public mapGoodId: string = '27';
- @property({
- displayName: '需要的物品id'
- })
- public goodId = 2002;
- @property({
- type: cc.Node,
- displayName: '点亮火焰动画'
- })
- public spine: cc.Node = null;
- @property({
- type: cc.Node,
- displayName: '完成后触发对象'
- })
- public altar: cc.Node = null;
- @property({
- displayName: '靠近的提示',
- type: cc.Sprite
- })
- mIcon: cc.Sprite = null;//靠近后的提示
- @property({
- type: [cc.SpriteFrame],
- displayName: '不同状态的图标'
- })
- mIconFrame: Array<cc.SpriteFrame> = [];
- @property(cc.Prefab)
- mMapDialog: cc.Prefab = null;
- @property({
- displayName: '提示图标',
- type: cc.SpriteFrame
- })
- mTipsIcon: cc.SpriteFrame = null;
- @property({
- displayName: '点亮后的对话',
- type: [cc.String]
- })
- text: Array<string> = [];
- onLoad() {
- super.onLoad()
- if (this.mIcon) {
- this.mIcon.node.active = false;
- }
- }
- start() {
- this.spine.active = false;
- }
- /**
- *
- * @param show 是否显示提示
- */
- private iconTips(show) {
- if (this.mIcon) {
- if (show) {
- this.mIcon.node.active = true;
- let head = this.ff.mFFheader;
- let count = head.getTmpCount(this.goodId);
- if (count > 0) {
- this.mIcon.spriteFrame = this.mIconFrame[0]
- } else {
- this.mIcon.spriteFrame = this.mIconFrame[1]
- }
- } else {
- this.mIcon.node.active = false;
- }
- }
- }
- onBegin(tag: number) {
- if (this.spine.active) {
- return;
- }
- if (tag == 1) {
- this.iconTips(true);
- this.showOpt(this.mTipsIcon, () => {
- this.submit()
- })
- }
- }
- onEnd(tag: number) {
- if (tag == 1) {
- this.closeButton();
- }
- }
- public closeButton() {
- this.iconTips(false);
- this.closeOpt()
- }
- public submit() {
- if (this.spine.active) {
- this.ff.main.showTips('祭火已经点亮');
- return;
- }
- this.closeButton();
- let head = this.ff.mFFheader;
- let count = head.getTmpCount(this.goodId);
- if (count > 0) {
- head.removeTmpGood(this.goodId, 1);
- this.spine.active = true;
- let fAltar = this.altar.getComponent(FAltar);
- let fAltarGear = this.altar.getComponent(FAltarGear);
- if (fAltar) {
- fAltar.check();
- } else if (fAltarGear) {
- let ok = fAltarGear.check();
- if (this.text.length > 0 && !ok) {
- this.d0()
- }
- if (ok) {
- FqLogin.commitEvent(this.node.name, '', '');
- }
- }
- } else {
- this.ff.main.showTips('需要祭火');
- }
- }
- private d0() {
- this.ff.pauseSprite(true);
- let dialogs = this.text;
- let mapDialog = new FMapDialog(this.ff, this.mMapDialog);
- let pos = cc.v2();
- let ga = this.ff.getGroupBy(GroupType.A);
- let spine = ga[0]
- pos.x = spine.node.x;
- pos.y = spine.node.y + spine.node.height;
- mapDialog.showDialog(dialogs,
- pos,
- spine.spine,
- () => {
- this.ff.pauseSprite(false);
- }
- );
- }
- // private checkOpen() {
- // //检查其它开关是否打开
- // this.pause();
- // this.moveCamera(this.mFenceTrigger[0].getPosition(), 1, () => {
- // cc.tween(this.node).sequence(
- // cc.callFunc(() => {
- // for (let i = 0; i < this.mFenceTrigger.length; i++) {
- // const element = this.mFenceTrigger[i];
- // this.showFence(element, SpineName.OPEN);
- // }
- // this.ff.main.playerEffectByPath(AudioMgr.openDoor);
- // }),
- // cc.delayTime(1),
- // cc.callFunc(() => {
- // this.resume()
- // for (let i = 0; i < this.mFenceTrigger.length; i++) {
- // const element = this.mFenceTrigger[i];
- // element.getComponent(cc.PhysicsBoxCollider).enabled = false;
- // }
- // })
- // ).start();
- // })
- // }
- // private showFence(element, action) {
- // let nodes = element.children;
- // for (let i = 0; i < nodes.length; i++) {
- // const element = nodes[i];
- // let spine: sp.Skeleton = element.getComponent(sp.Skeleton);
- // if (spine) {
- // spine.setAnimation(0, action, false);
- // }
- // }
- // }
- }
|