effect_node.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { _decorator, Component, Node } from 'cc';
  2. import { config } from '../../config';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('effect_node')
  5. export class effect_node extends Component {
  6. @property(Node) effect_dun:Node = null
  7. @property(Node) effect_xi:Node = null
  8. @property(Node) effect_xing:Node = null
  9. private curShowBuffType:number = -1;
  10. public init(){
  11. this.curShowBuffType = -1
  12. this.hideAllEffect()
  13. }
  14. public hideAllEffect(){
  15. this.effect_dun.active = false
  16. this.effect_xi.active = false
  17. this.effect_xing.active = false
  18. }
  19. updateStatus(type:number){
  20. if(type===this.curShowBuffType){
  21. return
  22. }
  23. this.curShowBuffType = type
  24. this.hideAllEffect()
  25. switch (type) {
  26. case config.SHOW_BUFF_STATUS.DUN:
  27. this.effect_dun.active = true
  28. break;
  29. case config.SHOW_BUFF_STATUS.XI:
  30. this.effect_xi.active = true
  31. break;
  32. case config.SHOW_BUFF_STATUS.XING:
  33. this.effect_xing.active = true
  34. break;
  35. }
  36. }
  37. public cancelStatus(type:number){
  38. if(type===this.curShowBuffType){
  39. this.curShowBuffType=-1;
  40. }
  41. switch (type) {
  42. case config.SHOW_BUFF_STATUS.DUN:
  43. this.effect_dun.active = false
  44. break;
  45. case config.SHOW_BUFF_STATUS.XI:
  46. this.effect_xi.active = false
  47. break;
  48. case config.SHOW_BUFF_STATUS.XING:
  49. this.effect_xing.active = false
  50. break;
  51. }
  52. }
  53. }