1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import { AudioMgr } from "../../../../main/ViewManage";
- import { SpriteActionType } from "../../object/FSprite";
- import BaseEvent from ".././base/BaseEvent";
- /**
- * 能被打碎的箱子
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class FHitBox extends BaseEvent {
- @property(sp.Skeleton)
- spine: sp.Skeleton = null;
- @property({
- displayName: '靠近的提示',
- type: cc.Node
- })
- icon: cc.Node = null;
- @property({
- displayName: '打碎后显示',
- type: cc.Node
- })
- hide: cc.Node = null;
- @property({
- displayName: '提示图标',
- type: cc.SpriteFrame
- })
- mTipsIcon: cc.SpriteFrame = null;
- private isOver = false;
- onLoad() {
- super.onLoad()
- if (this.icon) {
- this.icon.active = false;
- }
- if (this.hide && this.hide.isValid) {
- this.hide.active = false;
- }
- }
- start() {
- if (this.hide) {
- if (this.ff.mMap.checkIn(this.hide.name)) {
- this.node.destroy()
- }
- }
- }
- onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider) {
- if (other.node.group == 'bullet') {
- this.onBegin(self.tag)
- }
- }
- onBegin(tag: number) {
- if (this.isOver) {
- return
- }
- this.isOver = true
- this.hitBox()
- }
- public hitBox() {
- // this.onEnd(1)
- // this.ff.pauseSprite(true)
- this.node.removeComponent(cc.PhysicsBoxCollider)
- this.node.removeComponent(cc.PhysicsBoxCollider)
- // element.useHammer()
- // element.playAction2(SpriteActionType.chuizi, false, () => {
- // this.ff.pauseSprite(false)
- // element.playAction2(SpriteActionType.stand, true);
- // element.updateSkin()
- // })
- if (this.spine) {
- this.spine.setCompleteListener(() => {
- this.node.destroy();
- })
- if (this.hide && this.hide.isValid) {
- this.hide.active = true;
- }
- this.spine.setAnimation(0, 'boom', false);
- }
- this.ff.main.playerEffectByPath(AudioMgr.wooden);
- }
- }
|