pictorial.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.loadContainer(15)
  24. this.avatar.active = false
  25. // }
  26. },
  27. showAvatar(level) {
  28. this.avatar.active = true
  29. let data = this._controller.gameData.json.levelData[+level - 1]
  30. // let heightScore = this._controller.social.getHighestScore()
  31. this.avatar.getChildByName('name').getComponent(cc.Label).string = '历史最高:' + data.name
  32. // this.avatar.getChildByName('score').getComponent(cc.Label).string = '分数' + heightScore
  33. setTimeout(() => {
  34. this._controller.scoreMgr.characterMgr.showCharacter(+level, this.avatar.getChildByName('db'), false)
  35. }, 1000)
  36. },
  37. loadContainer(level) {
  38. let data = this._controller.gameData.json.levelData
  39. console.log(data);
  40. this.clearContainer()
  41. setTimeout(() => {
  42. for (let i = 0; i < data.length; i++) {
  43. let card = cc.instantiate(this.prefab)
  44. card.parent = this.container
  45. this.initCard(card, data[i], i, level)
  46. }
  47. }, 1000)
  48. },
  49. clearContainer() {
  50. this.container.children.map(item => {
  51. item.destroy()
  52. })
  53. },
  54. initCard(card, info, level, selfLevel) {
  55. if (level < selfLevel) {
  56. card.getChildByName('name').getComponent(cc.Label).string = info.name
  57. //card.getChildByName('score').getComponent(cc.Label).string = "得分:" + info.score
  58. card.getChildByName('db').color = cc.Color.WHITE
  59. card.getChildByName('giftStep').getComponent(cc.Label).string = "开局奖励" + info.giftStep + "步"
  60. } else {
  61. card.getChildByName('name').getComponent(cc.Label).string = '???'
  62. card.getChildByName('giftStep').getComponent(cc.Label).string = "开局奖励???步"
  63. card.getChildByName('db').color = cc.Color.BLACK
  64. }
  65. this._controller.scoreMgr.characterMgr.showCharacter(level + 1, card.getChildByName('db'), 0)
  66. }
  67. });