home_honor.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { _decorator, Component, Node, Sprite, SpriteFrame, Animation } from 'cc';
  2. import { tools } from '../../tools';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('home_honor')
  5. export class home_honor extends Component {
  6. @property(Node) img_text:Node = null
  7. @property(Node) img_light:Node = null
  8. @property(SpriteFrame) sf_country_text:SpriteFrame = null
  9. @property(SpriteFrame) sf_country_light:SpriteFrame = null
  10. @property(SpriteFrame) sf_province_text:SpriteFrame = null
  11. @property(SpriteFrame) sf_province_light:SpriteFrame = null
  12. @property(SpriteFrame) sf_city_text:SpriteFrame = null
  13. @property(SpriteFrame) sf_city_light:SpriteFrame = null
  14. private is_img_light_play_animation:boolean = false
  15. initView() {
  16. let rank_data = tools.mine_rank_data
  17. if(rank_data.nationwide_badge_status==undefined||rank_data.nationwide_badge_status==null) {
  18. rank_data.nationwide_badge_status = 0
  19. }
  20. if(rank_data.province_badge_status==undefined||rank_data.province_badge_status==null) {
  21. rank_data.province_badge_status = 0
  22. }
  23. if(rank_data.city_badge_status==undefined||rank_data.city_badge_status==null) {
  24. rank_data.city_badge_status = 0
  25. }
  26. if(rank_data.nationwide_badge_status==0&&rank_data.province_badge_status==0&&rank_data.city_badge_status==0) {
  27. this.node.active = false
  28. if(this.is_img_light_play_animation) {
  29. this.is_img_light_play_animation = false
  30. this.img_light.getComponent(Animation).stop()
  31. }
  32. return
  33. }
  34. this.node.active = true
  35. this.is_img_light_play_animation = true
  36. this.img_light.getComponent(Animation).play()
  37. if(rank_data.nationwide_badge_status==1) {
  38. this.img_text.getComponent(Sprite).spriteFrame = this.sf_country_text
  39. this.img_light.getComponent(Sprite).spriteFrame = this.sf_country_light
  40. return
  41. }
  42. if(rank_data.province_badge_status==1) {
  43. this.img_text.getComponent(Sprite).spriteFrame = this.sf_province_text
  44. this.img_light.getComponent(Sprite).spriteFrame = this.sf_province_light
  45. return
  46. }
  47. if(rank_data.city_badge_status==1) {
  48. this.img_text.getComponent(Sprite).spriteFrame = this.sf_city_text
  49. this.img_light.getComponent(Sprite).spriteFrame = this.sf_city_light
  50. return
  51. }
  52. }
  53. }