123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- /**
- * 获取职业技能
- */
- import ViewObject from "../../../../../main/ViewObject";
- import BaseEvent from "../../base/BaseEvent";
- import { AudioMgr, GameViewType } from "../../../../../main/ViewManage";
- import FSjpPanel from "./FSjpPanel";
- import FqLogin from "../../../../../login/FqLogin";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class FGetSkill extends BaseEvent {
- @property(cc.Prefab)
- mMapDialog: cc.Prefab = null;
- @property({
- displayName: '对话内容',
- type: [cc.String]
- })
- text: Array<string> = [];
- @property({
- displayName: '完成后的对话',
- type: [cc.String]
- })
- finish: Array<string> = [];//完成后的对话
- @property({
- displayName: '靠近的提示',
- type: cc.Node
- })
- icon: cc.Node = null;
- @property({
- displayName: '提示图标',
- type: cc.SpriteFrame
- })
- mTipsIcon: cc.SpriteFrame = null;
- @property({
- displayName: '需要的物品id'
- })
- public goodId = 2006;
- @property({
- displayName: '需要存储的ID'
- })
- public saveId: string = "";
- @property({
- displayName: '需要打开的门',
- type: cc.Node
- })
- mOpenDoor: cc.Node = null;
- private isEnd = false
- onLoad() {
- super.onLoad()
- let stage = this.ff.main.player.stage;
- if (stage.element.indexOf(this.saveId) > -1) {
- this.mOpenDoor.active = false;
- }
- }
- onBegin(tag: number) {
- if (this.isEnd) {
- return
- }
- if (tag == 1) {
- this.showOpt(this.mTipsIcon, () => {
- this.startDialog()
- })
- }
- }
- onEnd(tag: number) {
- if (tag == 1) {
- this.closeOpt()
- }
- }
- public startDialog() {
- this.closeOpt()
- let head = this.ff.mFFheader;
- let count = head.getTmpCount(this.goodId);
- if (count > 0) {
- head.removeTmpGood(this.goodId, 1);
- //已经打开了技能
- let role = this.ff.main.player.role
- if (role.openSkill) {
- this.pause()
- this.moveCamera(this.mOpenDoor.getPosition(), 1, () => {
- this.openGear()
- })
- } else {
- // this.showDialog2();
- this.showDialog(this.node, this.finish, ()=>{
- this.pause()
- this.moveCamera(this.mOpenDoor.getPosition(), 1, () => {
- this.openGear()
- })
- this.getMapObject(this.saveId, null);
- FqLogin.commitEvent(this.node.name,'','');
- })
- }
- } else {
- this.showDialog1(0);
- }
- }
- // private showDialog2() {
- // this.showDialog(this.node, this.finish, () => {
- // this.openSjpPanel()
- // });
- // }
- private showDialog1(index: number) {
- if (index >= this.text.length) {
- return;
- }
- let texts = this.text[index].split('|')
- let mid = parseInt(texts.shift());
- if (mid == -1) {//主角
- let my = this.ff.mainSprite.node;
- this.showDialog(my, texts, () => {
- index++;
- this.showDialog1(index);
- });
- } else {
- let my = this.node;
- this.showDialog(my, texts, () => {
- index++;
- this.showDialog1(index);
- });
- }
- }
- private openGear() {
- this.isEnd = true
- if (this.icon) {
- this.icon.active = false;
- }
- let nodes = this.mOpenDoor.children;
- nodes.forEach(element => {
- let spine = element.getComponent(sp.Skeleton);
- if (spine) {
- spine.setCompleteListener(() => {
- element.active = false;
- });
- spine.setAnimation(0, 'close', false);
- this.ff.main.playerEffectByPath(AudioMgr.openDoor);
- }
- });
- cc.tween(this.ff.mMap.node).sequence(
- cc.delayTime(1),
- cc.callFunc(() => {
- this.mOpenDoor.active = false;
- this.resume()
- })
- ).start()
- }
- /**
- * 打开水晶瓶界面
- */
- // private openSjpPanel() {
- // let main = this.ff.main
- // main.viewManage.loadFunc(GameViewType.fight_map_sjp_tips, (viewObject: ViewObject) => {
- // viewObject.show();
- // let sjp = viewObject as FSjpPanel;
- // sjp.setCallback(() => {
- // this.pause()
- // this.ff.control.showSkill2()
- // this.openGear()
- // // this.moveCamera(this.mOpenDoor.getPosition(), 1, () => {
- // // this.openGear()
- // // })
- // })
- // });
- // }
- }
|