SkillBase.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { __SkillData } from "../../../data/sdata/SManage";
  2. import AIBase from "../AI/AIBase";
  3. import FSprite from "../FSprite";
  4. /**
  5. * 技能基础属性
  6. */
  7. const {ccclass, property} = cc._decorator;
  8. @ccclass
  9. export default class SkillBase extends cc.Component {
  10. /**
  11. * 技能CD时间
  12. */
  13. @property({
  14. displayName: '技能编号'
  15. })
  16. public ID:number = 0;
  17. /**
  18. * 技能CD时间
  19. */
  20. @property({
  21. displayName: '技能CD时间(毫秒)'
  22. })
  23. public CD:number = 3000;
  24. /**
  25. * 技能CD时间
  26. */
  27. @property({
  28. displayName: '有效射程'
  29. })
  30. public range:number = 1000;
  31. /**
  32. * 技能CD时间
  33. */
  34. @property({
  35. displayName: '子弹速度'
  36. })
  37. public speed:number = 500;
  38. /**
  39. * 开始计时
  40. */
  41. public time:number = 0;
  42. public sprite:FSprite;
  43. public AI:AIBase;
  44. /**
  45. * 技能数据
  46. */
  47. public _skillData:__SkillData
  48. onLoad(){
  49. this.sprite = this.node.getComponent(FSprite);
  50. this.AI = this.node.getComponent(AIBase);
  51. }
  52. /**
  53. * 技能是否准备好
  54. */
  55. public ready():boolean{
  56. let dx = new Date().getTime();
  57. if(this.time == 0){
  58. this.time = dx;
  59. return false
  60. }
  61. if(dx - this.time > this.CD){
  62. return true;
  63. }
  64. return false;
  65. }
  66. /**
  67. * 释放技能
  68. * @target 攻击目标
  69. * @callback 技能结束回调
  70. */
  71. public exe(target:FSprite,callback:()=>void){
  72. }
  73. }