pictorial.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @author uu
  3. */
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. container: cc.Node,
  8. avatar: cc.Node,
  9. prefab: cc.Prefab,
  10. },
  11. init(c) {
  12. this._controller = c
  13. // if (c.social.node.active) {
  14. // let highLevel = c.social.getHighestLevel()
  15. // if (highLevel) {
  16. // this.showAvatar(highLevel)
  17. // this.loadContainer(+highLevel)
  18. // } else {
  19. // this.avatar.active = false
  20. // this.loadContainer(1)
  21. // }
  22. // } else {
  23. this.avatar.active = false
  24. // }
  25. },
  26. showAvatar(level) {
  27. this.avatar.active = true
  28. let data = this._controller.gameData.json.levelData[+level - 1]
  29. // let heightScore = this._controller.social.getHighestScore()
  30. this.avatar.getChildByName('name').getComponent(cc.Label).string = '历史最高:' + data.name
  31. // this.avatar.getChildByName('score').getComponent(cc.Label).string = '分数' + heightScore
  32. setTimeout(() => {
  33. this._controller.scoreMgr.characterMgr.showCharacter(+level, this.avatar.getChildByName('db'), false)
  34. }, 1000)
  35. },
  36. loadContainer(level) {
  37. let data = this._controller.gameData.json.levelData
  38. this.clearContainer()
  39. setTimeout(() => {
  40. for (let i = 0; i < data.length; i++) {
  41. let card = cc.instantiate(this.prefab)
  42. card.parent = this.container
  43. this.initCard(card, data[i], i, level)
  44. }
  45. }, 1000)
  46. },
  47. clearContainer() {
  48. this.container.children.map(item => {
  49. item.destroy()
  50. })
  51. },
  52. initCard(card, info, level, selfLevel) {
  53. if (level < selfLevel) {
  54. card.getChildByName('name').getComponent(cc.Label).string = info.name
  55. //card.getChildByName('score').getComponent(cc.Label).string = "得分:" + info.score
  56. card.getChildByName('db').color = cc.Color.WHITE
  57. card.getChildByName('giftStep').getComponent(cc.Label).string = "开局奖励" + info.giftStep + "步"
  58. } else {
  59. card.getChildByName('name').getComponent(cc.Label).string = '???'
  60. card.getChildByName('giftStep').getComponent(cc.Label).string = "开局奖励???步"
  61. card.getChildByName('db').color = cc.Color.BLACK
  62. }
  63. this._controller.scoreMgr.characterMgr.showCharacter(level + 1, card.getChildByName('db'), 0)
  64. }
  65. });