UEBattleRole.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { FightTeam } from "../../common/Xys";
  2. import { FightType } from "../../data/const/TypeConst";
  3. import ResSpine from "../../frameWork/compment/ResSpine";
  4. import UERole from "../ui/UERole";
  5. const { ccclass, property } = cc._decorator;
  6. @ccclass
  7. export default class UEBattleRole extends UERole {
  8. public m_ResSpine: ResSpine;
  9. m_IsLoadComplete: boolean;
  10. team: FightTeam;
  11. type: FightType;
  12. posX: number;
  13. onLoad() {
  14. this.m_ResSpine = this.node.getChildByName("spine").getComponent(ResSpine);
  15. }
  16. start() {
  17. }
  18. setRole(posX: number, team: FightTeam, type: FightType) {
  19. this.team = team;
  20. this.type = type;
  21. this.node.x = posX;
  22. this.posX = posX;
  23. this.LoadRoleRes();
  24. }
  25. GetSpinePath() {
  26. let spinePath = "role/nv";
  27. if (this.team?.fid == "1022") {
  28. spinePath = "mon/10001";
  29. }
  30. return spinePath;
  31. }
  32. public LoadRoleRes(cb?: Function): void {
  33. let spinePath = this.GetSpinePath();
  34. let that = this;
  35. this.m_IsLoadComplete = false;
  36. this.m_ResSpine.spSkeleton.skeletonData = null;
  37. this.m_ResSpine.setSpineData("spine", spinePath, (asset: sp.SkeletonData) => {
  38. if (asset) {
  39. }
  40. if (that.m_ResSpine && that.m_ResSpine.isValid) {
  41. that.m_ResSpine.addEventListener(that.OnEventListener.bind(that));
  42. that.m_ResSpine.AddSpineCompleteListener(that.OnCompleteListener.bind(that));
  43. }
  44. this.m_IsLoadComplete = true;
  45. cb && cb();
  46. }, false, "stand", true, 1);
  47. }
  48. playAni(aniName: string, loop: boolean, showLast?: boolean) {
  49. this.m_ResSpine.playAnimation(aniName, loop, showLast);
  50. }
  51. /** 监听事件帧 */
  52. OnEventListener(name: string) {
  53. // console.log("角色事件帧", name);
  54. if (name === "skill" || name === "atk") {
  55. }
  56. }
  57. OnCompleteListener(name: string) {
  58. }
  59. }