1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- /**
- * @author heyuchang
- */
- cc.Class({
- extends: cc.Component,
- properties: {
- container: cc.Node,
- avatar: cc.Node,
- prefab: cc.Prefab,
- },
- init(c) {
- this._controller = c
- if (c.social.node.active) {
- let highLevel = c.social.getHighestLevel()
- if (highLevel) {
- this.showAvatar(highLevel)
- this.loadContainer(+highLevel)
- } else {
- this.avatar.active = false
- this.loadContainer(1)
- }
- } else {
- this.avatar.active = false
- }
- },
- showAvatar(level) {
- this.avatar.active = true
- let data = this._controller.gameData.json.levelData[+level - 1]
- let heightScore = this._controller.social.getHighestScore()
- this.avatar.getChildByName('name').getComponent(cc.Label).string = 'Historical highest:' + data.name
- this.avatar.getChildByName('score').getComponent(cc.Label).string = 'grade:' + heightScore
- setTimeout(() => {
- this._controller.scoreMgr.characterMgr.showAvatarCharacter(+level, this.avatar.getChildByName('db'))
- }, 1000)
- },
- loadContainer(level) {
- let data = this._controller.gameData.json.levelData
- this.clearContainer()
- setTimeout(() => {
- for (let i = 0; i < data.length; i++) {
- let card = cc.instantiate(this.prefab)
- card.parent = this.container
- this.initCard(card, data[i], i, level)
- }
- }, 1000)
- },
- clearContainer() {
- this.container.children.map(item => {
- item.destroy()
- })
- },
- initCard(card, info, level, selfLevel) {
- if (level < selfLevel) {
- card.getChildByName('name').getComponent(cc.Label).string = info.name
- //card.getChildByName('score').getComponent(cc.Label).string = "得分:" + info.score
- card.getChildByName('db').color = cc.Color.WHITE
- card.getChildByName('giftStep').getComponent(cc.Label).string = "Starting bonus" + info.giftStep + "step"
- this._controller.scoreMgr.characterMgr.showCharacter(level + 1, card.getChildByName('db'))
- } else {
- card.getChildByName('name').getComponent(cc.Label).string = '???'
- card.getChildByName('giftStep').getComponent(cc.Label).string = "Starting bonus???step"
- card.getChildByName('db').color = cc.Color.BLACK
- this._controller.scoreMgr.characterMgr.showCharacter(level + 1, card.getChildByName('db'), cc.Color.BLACK)
- }
- // this._controller.scoreMgr.characterMgr.showCharacter(level + 1, card.getChildByName('db'), 0)
- }
- });
|