123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- const DWTool = require("../utils/DWTool");
- const ArtistManager = require("../utils/ArtistManager");
- const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
- cc.Class({
- extends: cc.Component,
- properties: {
- starDarkNode: cc.Node,
- starHeadNode: cc.Node,
- countNode: cc.Node,
- countLabel: cc.Label,
- isUnlocked: {
- get: function() {
- return this._isUnlocked;
- },
- set: function(value) {
- this._isUnlocked = value;
- if (this._isUnlocked) {
- this.starHeadNode.active = true;
- this.countNode.active = true;
- this.starDarkNode.active = false;
- } else {
- this.starHeadNode.active = false;
- this.countNode.active = false;
- this.starDarkNode.active = true;
- }
- }
- },
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.node.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
- this.showStarDesc();
- }, 1000, true), this);
- GameEvent.on(GameNotificationKey.StarEnterRoom, this, (starId) => {
- this.starEnterRoom(starId);
- });
- GameEvent.on(GameNotificationKey.StarLeaveRoom, this, (starId) => {
- this.starLeaveRoom(starId);
- });
- GameEvent.on(GameNotificationKey.AllStarLeaveRoom, this, this.allStarLeaveRoom);
- },
- onDestroy() {
- GameEvent.off(GameNotificationKey.StarEnterRoom, this);
- GameEvent.off(GameNotificationKey.StarLeaveRoom, this);
- GameEvent.off(GameNotificationKey.AllStarLeaveRoom, this);
- },
- start () {
- },
- configData(starInfo) {
- this.starInfo = starInfo;
- if (starInfo.starCount > 0 ) {
- this.isUnlocked = true;
- this.countLabel.string = `${starInfo.starRoomCount}/${starInfo.starCount}`;
- } else {
- this.isUnlocked = false;
- }
- let imageId = 50000 + starInfo.starId;
- ArtistManager.loadStarBlackAvatarSpriteFrame(imageId, this.starDarkNode.getComponent('cc.Sprite'));
- ArtistManager.loadStarAvatarSpriteFrame(imageId, this.starHeadNode.getComponent('cc.Sprite'));
- },
- showStarDesc() {
- // if (this.isUnlocked) {
- GameEvent.fire('show_star_desc', this.starInfo);
- // }
- },
- starEnterRoom(starId) {
- if (this.starInfo.starId == starId) {
- this.countLabel.string = `${this.starInfo.starRoomCount}/${this.starInfo.starCount}`;
- }
- },
- starLeaveRoom(starId) {
- if (this.starInfo.starId == starId) {
- this.countLabel.string = `${this.starInfo.starRoomCount}/${this.starInfo.starCount}`;
- }
- },
- allStarLeaveRoom() {
- // if (this.starInfo.starCount > 0 ) {
- // this.isUnlocked = true;
- // this.countLabel.string = `0/${this.starInfo.starCount}`;
- // } else {
- // this.isUnlocked = false;
- // }
- this.countLabel.string = `0/${this.starInfo.starCount}`;
- }
- // update (dt) {},
- });
|