buff_manager.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { _decorator, Component, Node } from 'cc';
  2. import { config } from '../../config';
  3. import { buff_dun_chong } from './buff_dun_chong';
  4. import { buff_dun } from './buff_dun';
  5. import { buff_xi } from './buff_xi';
  6. import { buff_xing } from './buff_xing';
  7. import { effect_node } from './effect_node';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('buff_manager')
  10. export class buff_manager extends Component {
  11. @property(Node) buff_dun:Node = null
  12. @property(Node) buff_xi:Node = null
  13. @property(Node) buff_xing:Node = null
  14. @property(Node) buff_dun_chong:Node = null
  15. @property(Node) effect_node:Node = null
  16. private curShowBuffType:number = -1;
  17. public init(){
  18. this.curShowBuffType = -1;
  19. this.buff_dun_chong.getComponent(buff_dun_chong).init()
  20. this.effect_node.getComponent(effect_node).init()
  21. this.hideAll()
  22. }
  23. hideAll(){
  24. this.buff_dun.active = false
  25. this.buff_dun_chong.active = false
  26. this.buff_xi.active = false
  27. this.buff_xing.active = false
  28. }
  29. updateStatus(type:number){
  30. if(type===this.curShowBuffType){
  31. return
  32. }
  33. this.curShowBuffType = type
  34. // console.log("this.curShowBuffType",this.curShowBuffType)
  35. // this.hideAll()
  36. this.effect_node.getComponent(effect_node).updateStatus(this.curShowBuffType)
  37. switch (type) {
  38. case config.SHOW_BUFF_STATUS.DUN:
  39. this.buff_dun.active = true
  40. this.buff_dun_chong.active = true
  41. this.buff_dun.getComponent(buff_dun).playAnimation()
  42. this.buff_dun_chong.getComponent(buff_dun_chong).playAnimation()
  43. break;
  44. case config.SHOW_BUFF_STATUS.XI:
  45. this.buff_xi.active = true
  46. this.buff_xi.getComponent(buff_xi).playAnimation()
  47. break;
  48. case config.SHOW_BUFF_STATUS.XING:
  49. this.buff_xing.active = true
  50. this.buff_xing.getComponent(buff_xing).playAnimation()
  51. break;
  52. }
  53. }
  54. public cancelStatus(type:number){
  55. if(type===this.curShowBuffType){
  56. this.curShowBuffType=-1;
  57. }
  58. this.effect_node.getComponent(effect_node).cancelStatus(type)
  59. switch (type) {
  60. case config.SHOW_BUFF_STATUS.DUN:
  61. this.buff_dun.active = false
  62. this.buff_dun_chong.active = false
  63. break;
  64. case config.SHOW_BUFF_STATUS.XI:
  65. this.buff_xi.active = false
  66. break;
  67. case config.SHOW_BUFF_STATUS.XING:
  68. this.buff_xing.active = false
  69. break;
  70. }
  71. }
  72. }