import { _decorator, Component, Node, Sprite, SpriteFrame, sp, Vec3, v3, tween } from 'cc'; import { DataSystem } from '../core/data/DataSystem'; import { ConfigData } from '../data/ConfigData'; import { PVPCardData } from './PVP'; const { ccclass, property } = _decorator; @ccclass('PVPBullet') export class PVPBullet extends Component { @property({ type: Sprite, tooltip: "子弹精灵" }) bulletSprite: Sprite; @property({ type: [SpriteFrame], tooltip: "子弹精灵合集" }) bulletSpriteList: Array = []; @property({ type: sp.Skeleton, tooltip: "spine组件" }) spine: sp.Skeleton; @property({ type: [sp.SkeletonData], tooltip: "受击特效合集" }) hitEffectList: Array = []; private spData: sp.SkeletonData; public setData(data: PVPCardData, dir: number, to: Vec3, cb: Function): void { this.spData = this.hitEffectList[DataSystem.getData(ConfigData)["general"][data.id]["hit_res"] - 1]; this.bulletSprite.spriteFrame = this.bulletSpriteList[DataSystem.getData(ConfigData)["general"][data.id]["atk_res"] - 1]; this.bulletSprite.node.setScale(v3(dir, 1, 1)); tween(this.node).to(0.3, { position: to }).call(async () => { if (cb) { cb(); } this.bulletSprite.node.active = false; this.spine.skeletonData = this.spData; this.spine.setAnimation(0, "animation", false); }).start(); } }