var {UserInformationType, UserInformationRelateOptType, GameNotificationKey, UserIntimacyType} = require('../utils/GameEnum');
const GameModule = require('../utils/GameModule');
cc.Class({
extends: cc.Component,
properties: {
titleNode: cc.Node,
titleRichText: cc.RichText,
homeButton: cc.Button,
//抢夺、赎身相关操作按钮
relationButtonNode: cc.Node,
relationRichText: cc.RichText,
//安抚按钮
interactionButtonNode: cc.Node,
//命令、反抗按钮
orderButtonNode: cc.Node,
//培养按钮
trainButtonNode: cc.Node,
//抢夺、赎身、签约成功提示
successNode: cc.Node,
successTipsNode: cc.Node,
//背包按钮节点
packButtonNode: cc.Node,
//亲密度显示
intimacyNode: cc.Node,
intimacyFullNode: cc.Node,
intimacyLeftNode: cc.Node,
intimacyRightNode: cc.Node,
intimacyLabel: cc.Label,
//插卡按钮节点
equipCardNode: cc.Node,
equipCardSprite1: cc.Sprite,
equipCardSprite2: cc.Sprite,
equipCardSprite3: cc.Sprite,
equipCardArray: [cc.SpriteFrame],
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.titleSprite = this.titleNode.getComponent(cc.Sprite);
this.successNode.on('touchstart',this.clossSuccessNode,this);
this.intimacyNode.on('touchend', this.showIntimacyStatus, this);
},
start () {
},
init() {
},
onDisable() {
this.hideAllFunctionNode();
this.refreshNoCards();
},
// update (dt) {},
changeTheme(infoRole, hasBoss, hasJob) {
this.infoRole = infoRole;
this.hasBoss = hasBoss;
this.hasJob = hasJob;
switch (this.infoRole) {
case UserInformationType.Mine:
this.refreshThemeOfMine();
break;
case UserInformationType.Boss:
this.refreshThemeOfBoss();
break;
case UserInformationType.MyArtist:
this.refreshThemeOfMyArtist();
break;
case UserInformationType.OtherArtist:
this.refreshThemeOfOtherArtist();
break;
case UserInformationType.ArtistFree:
this.refreshThemeOfArtistFree();
break;
}
},
//隐藏所有功能按钮和节点
hideAllFunctionNode() {
this.intimacyNode.active = false;
this.homeButton.node.active = false;
this.relationButtonNode.active = false;
this.interactionButtonNode.active = false;
this.orderButtonNode.active = false;
this.trainButtonNode.active = false;
this.packButtonNode.active = false;
this.equipCardNode.active = false;
},
refreshThemeOfMine () {
this.titleRichText.string = "我的信息";
this.hideAllFunctionNode();
this.packButtonNode.active = true;
},
refreshThemeOfBoss () {
this.titleRichText.string = "我的老板";
this.relationRichText.string = "赎身";
cc.loader.loadRes('userInformation/userinformation_play_button', cc.SpriteFrame, (err, spriteFrame) => {
this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
});
cc.loader.loadRes('userInformation/userinformation_revolt_button', cc.SpriteFrame, (err, spriteFrame) => {
this.orderButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
});
this.hideAllFunctionNode();
this.intimacyNode.active = true;
this.homeButton.node.active = true;
this.interactionButtonNode.active = true;
this.orderButtonNode.active = true;
},
refreshThemeOfMyArtist () {
this.titleRichText.string = "我的艺人";
this.relationRichText.string = "解雇";
cc.loader.loadRes('userInformation/userinformation_pacify_button', cc.SpriteFrame, (err, spriteFrame) => {
this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
});
cc.loader.loadRes('userInformation/userinformation_order_button', cc.SpriteFrame, (err, spriteFrame) => {
this.orderButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
});
this.hideAllFunctionNode();
this.intimacyNode.active = true;
this.homeButton.node.active = true;
this.interactionButtonNode.active = true;
this.orderButtonNode.active = true;
this.trainButtonNode.active = true;
},
refreshThemeOfOtherArtist () {
this.titleRichText.string = "他人艺人";
this.relationRichText.string = "抢夺";
cc.loader.loadRes('userInformation/userinformation_interact_button', cc.SpriteFrame, (err, spriteFrame) => {
this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
});
this.hideAllFunctionNode();
this.intimacyNode.active = true;
this.homeButton.node.active = true;
this.interactionButtonNode.active = true;
GameModule.homeGuide.getComponent('HomeGuide').handleState('state15');
},
refreshThemeOfArtistFree () {
this.titleRichText.string = "自由身";
this.relationRichText.string = "签约";
cc.loader.loadRes('userInformation/userinformation_interact_button', cc.SpriteFrame, (err, spriteFrame) => {
this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
});
this.hideAllFunctionNode();
this.intimacyNode.active = true;
this.homeButton.node.active = true;
this.interactionButtonNode.active = true;
GameModule.homeGuide.getComponent('HomeGuide').handleState('state15');
},
hideAllIntimacyNode() {
this.intimacyFullNode.active = false;
this.intimacyLeftNode.active = false;
this.intimacyRightNode.active = false;
},
configIntimacyData(interactionInfo) {
this.hideAllIntimacyNode();
switch (interactionInfo.heart) {
case UserIntimacyType.Empty:
break;
case UserIntimacyType.Full:
this.intimacyFullNode.active = true;
break;
case UserIntimacyType.Left:
this.intimacyLeftNode.active = true;
break;
case UserIntimacyType.Right:
this.intimacyRightNode.active = true;
break;
}
this.intimacyLabel.string = "亲密度:"+ interactionInfo.intimacy +"/100";
},
clossSuccessNode() {
this.successNode.active = false;
},
showChangeRelationSuccess(spriteFrameString) {
this.successNode.active = true;
GameEvent.fire(GameNotificationKey.PlaySuccessAnimation);
cc.loader.loadRes(spriteFrameString, cc.SpriteFrame, (err, spriteFrame) => {
this.successTipsNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
this.successTipsNode.active = true;
});
},
showIntimacyStatus() {
GameEvent.fire(GameNotificationKey.ShowInteraction);
},
//抢夺赎身操作按钮刷新
refreshRelationNode() {
switch (this.infoRole) {
case UserInformationType.Mine:
this.relationButtonNode.active = false;
break;
default:
this.relationButtonNode.active = true;
break;
}
},
//插卡节点数据显示
configCardsData(list, isRefresh) {
switch (this.infoRole) {
case UserInformationType.Mine:
if (this.hasBoss == false) {
this.equipCardNode.active = true;
} else {
this.equipCardNode.active = false;
return;
}
break;
case UserInformationType.MyArtist:
this.equipCardNode.active = true;
break;
default:
this.equipCardNode.active = false;
return;
}
this.list = list;
if (list != undefined && list.length > 0) {
this.refreshNoCards();
let count = list.length;
if (count == 1) {
this.equipCardSprite1.spriteFrame = this.equipCardArray[1];
this.equipCardSprite2.spriteFrame = this.equipCardArray[0];
this.equipCardSprite3.spriteFrame = this.equipCardArray[0];
} else if (count == 2) {
this.equipCardSprite1.spriteFrame = this.equipCardArray[1];
this.equipCardSprite2.spriteFrame = this.equipCardArray[1];
this.equipCardSprite3.spriteFrame = this.equipCardArray[0];
} else if (count >= 3) {
this.equipCardSprite1.spriteFrame = this.equipCardArray[1];
this.equipCardSprite2.spriteFrame = this.equipCardArray[1];
this.equipCardSprite3.spriteFrame = this.equipCardArray[1];
}
} else {
this.refreshNoCards();
}
},
refreshNoCards() {
this.equipCardSprite1.spriteFrame = this.equipCardArray[0];
this.equipCardSprite2.spriteFrame = this.equipCardArray[0];
this.equipCardSprite3.spriteFrame = this.equipCardArray[0];
},
});