123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- import FqLogin from "../../../login/FqLogin";
- import { AudioMgr } from "../../../main/ViewManage";
- import BaseEvent from "../../fight/evnet/base/BaseEvent";
- import { SpriteActionType } from "../../fight/object/FSprite";
- /**
- * 多组按钮控制开门-解救宠物剧情
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class JG0111_1 extends BaseEvent {
- @property({
- displayName: '替换的图片',
- type: cc.Sprite,
- })
- mIcon: cc.Sprite = null;
- @property({
- displayName: '未踩上图片',
- type: cc.SpriteFrame,
- })
- mIcon0: cc.SpriteFrame = null;
- @property({
- displayName: '踩上后的图片',
- type: cc.SpriteFrame,
- })
- mIcon1: cc.SpriteFrame = null;
- /**
- * 控制的地刺
- */
- @property({
- displayName: '控制的地刺',
- type: [cc.Node],
- })
- mFenceTrigger: Array<cc.Node> = [];
- @property({
- displayName: '困住的宠物',
- type: cc.Node,
- })
- mPet: cc.Node = null;
- @property({
- displayName: '对话用NPC',
- type: cc.Node,
- })
- mNpc: cc.Node = null;
- /**
- * 控制的地刺
- */
- @property({
- displayName: '控制的机关',
- type: [cc.Node],
- })
- mFenceTrigger1: Array<cc.Node> = [];
- /**
- * 机关是否已经结束
- */
- public isOver = false;
- private count = 0;
- onLoad() {
- super.onLoad();
- this.node.zIndex = -9999;
- this.mNpc.active = false;
- }
- onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider) {
- if (other.node.group != 'bullet') {
- this.count++
- this.onBegin(self.tag)
- }
- }
- onEndContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider) {
- if (other.node.group != 'bullet') {
- this.count--
- if (this.count <= 0) {
- this.count = 0;
- this.onEnd(self.tag)
- }
- }
- }
- onBegin(tag: number) {
- this.mIcon.spriteFrame = this.mIcon1;
- this.checkOpen();
- }
- onEnd(tag: number) {
- }
- private checkOpen() {
- if (this.isOver) {
- return
- }
- this.isOver = true;
- this.pause();
- this.moveCamera(this.mFenceTrigger[0].getPosition(), 1, () => {
- cc.tween(this.node).sequence(
- cc.callFunc(() => {
- this.showFence(this.mFenceTrigger[0], 'down');
- let nodes = this.mFenceTrigger[1].children
- for (let i = 0; i < nodes.length; i++) {
- const element = nodes[i];
- this.showFence(element, 'down');
- }
- this.ff.main.playerEffectByPath(AudioMgr.openDoor);
- }),
- cc.delayTime(1),
- cc.callFunc(() => {
- this.mFenceTrigger[0].getComponent(cc.PhysicsBoxCollider).enabled = false;
- this.startPlot()
- })
- ).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);
- }
- }
- }
- /**
- * 开始剧情
- * 1.NPC从左边移动出现
- */
- private startPlot() {
- this.mNpc.active = true;
- cc.tween(this.mNpc).sequence(
- cc.moveTo(1, cc.v2(3180, 5870)),
- cc.callFunc(() => {
- this.dialog1()
- })
- ).start()
- let mainSprite = this.ff.mainSprite
- mainSprite.setLR(-1)
- mainSprite.playAction(SpriteActionType.run, true)
- cc.tween(mainSprite.node).sequence(
- cc.moveTo(1, cc.v2(3388, 5813)),
- cc.callFunc(() => {
- mainSprite.playAction(SpriteActionType.stand, true)
- })
- ).start()
- }
- /**
- * 落单的精灵:太好了太好了!!(落单的精灵鼓掌)
- 落单的精灵:你成功救出了这头小鹿,我之前尝试了很多次都无法成功。
- 落单的精灵:不得不承认,你出乎了我的意料。
- */
- private dialog1() {
- let text = [
- '太好了太好了!!',
- '你成功救出了这头小鹿,我之前尝试了很多次都无法成功。',
- '不得不承认,你出乎了我的意料。'
- ]
- this.showDialog(this.mNpc, text, () => {
- this.escape()
- })
- }
- /**
- * 小鹿逃跑
- */
- private escape() {
- for (let i = 0; i < this.mFenceTrigger1.length; i++) {
- const element = this.mFenceTrigger1[i];
- element.active = false
- }
- let spine = this.mPet.getComponent(sp.Skeleton)
- spine.setAnimation(0, SpriteActionType.run, true);
- cc.tween(this.mPet).sequence(
- cc.moveBy(1,cc.v2(0,-500)),
- cc.callFunc(()=>{
- this.dialog2()
- }),
- cc.destroySelf()
- ).start()
- }
- private dialog2() {
- let text = [
- '逃跑了……',
- ]
- let mainSprite = this.ff.mainSprite
- this.showDialog(mainSprite.node, text, () => {
- this.dialog3()
- })
- }
- private dialog3() {
- let text = [
- '快追!!',
- ]
- this.showDialog(this.mNpc, text, () => {
- cc.tween(this.mNpc).sequence(
- cc.moveTo(1, cc.v2(3294, 5085)),
- cc.callFunc(() => {
- this.resume()
- }),
- cc.destroySelf()
- ).start()
- })
- }
- }
|