var { UserIntimacyType } = require('../utils/GameEnum');
cc.Class({
extends: cc.Component,
properties: {
titleRichText: cc.RichText,
intimacyFullNode: cc.Node,
intimacyLeftNode: cc.Node,
intimacyRightNode: cc.Node,
intimacyLabel: cc.Label,
userLeftNode: cc.Node,
leftNicknameRichText: cc.RichText,
interactionLeftIcon: cc.Sprite,
userRightNode: cc.Node,
rightNicknameRichText: cc.RichText,
interactionRightIcon: cc.Sprite,
//亲密度显示按钮
okButton: cc.Button,
remindButton: cc.Button,
//互动成功
intimacyRichText: cc.RichText,
inviteRichText: cc.RichText,
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
},
init() {
},
hideAllIntimacyNode() {
this.intimacyFullNode.active = false;
this.intimacyLeftNode.active = false;
this.intimacyRightNode.active = false;
if (this.intimacyLabel) {
this.intimacyLabel.node.active = false;
}
},
/**
* 亲密度信息显示
* @param {Object} interactionInfo 亲密度相关
* @param {Boolean} isInfo 是否亲密度显示
* @param {Boolean} isCommon 是否普通的互动
*/
configIntimacyInfo(interactionInfo, isInfo, isCommon) {
this.hideAllIntimacyNode();
this.interactionInfo = interactionInfo;
if (isInfo) {
this.configIntimacyInfoShow(isCommon);
} else {
this.configIntimacyInfoShare(isCommon);
}
let leftIcon = (err, spriteFrame) => {
this.interactionLeftIcon.spriteFrame = spriteFrame;
};
let rightIcon = (err, spriteFrame) => {
this.interactionRightIcon.spriteFrame = spriteFrame;
};
switch (interactionInfo.heart) {
case UserIntimacyType.Empty:
cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, leftIcon);
cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, rightIcon);
break;
case UserIntimacyType.Full:
this.intimacyFullNode.active = true;
cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, leftIcon);
cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, rightIcon);
break;
case UserIntimacyType.Left:
this.intimacyLeftNode.active = true;
cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, leftIcon);
cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, rightIcon);
break;
case UserIntimacyType.Right:
this.intimacyRightNode.active = true;
cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, leftIcon);
cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, rightIcon);
break;
}
if (interactionInfo.me) {
var genderIcon = 'intimacy_female';
if (interactionInfo.me.gender == 1) {
genderIcon = 'intimacy_male';
}
var nickString = " " + interactionInfo.me.nick.slice(0,5);
this.leftNicknameRichText.string = nickString;
}
if (interactionInfo.other) {
var genderIcon = 'intimacy_female';
if (interactionInfo.other.gender == 1) {
genderIcon = 'intimacy_male';
}
var nickString = " " + interactionInfo.other.nick.slice(0,5);
this.rightNicknameRichText.string = nickString;
}
},
configIntimacyInfoShow(isCommon) {
var titleString = "你们今天还没有进行互动~\n一起互动额外增加 5 >点亲密度~";
if (isCommon == true) {
titleString = "你们今天还没有进行互动~";
}
switch (this.interactionInfo.heart) {
case UserIntimacyType.Empty:
this.okButton.node.active = false;
this.remindButton.node.active = true;
break;
case UserIntimacyType.Full:
this.intimacyLabel.node.active = true;
titleString = "你和你的好友都完成了今天的互动\n获得额外的 5 >点亲密度~";
if (isCommon) {
titleString = "你和你的好友都完成了今天的互动";
}
this.okButton.node.active = true;
this.remindButton.node.active = false;
break;
case UserIntimacyType.Left:
titleString = "和你的好友一起互动\n额外增加 5 >点亲密度~";
if (isCommon) {
titleString = "和你的好友一起互动";
}
this.okButton.node.active = false;
this.remindButton.node.active = true;
break;
case UserIntimacyType.Right:
titleString = "和你的好友一起互动\n额外增加 5 >点亲密度~";
if (isCommon) {
titleString = "和你的好友一起互动";
}
this.okButton.node.active = true;
this.remindButton.node.active = false;
break;
}
this.titleRichText.string = titleString;
},
configIntimacyInfoShare(isCommon) {
// var textString = "邀请你的好友一起互动额外增加 5 >点亲密度~";
if (isCommon == true) {
this.intimacyRichText.node.active = false;
// textString = "邀请你的好友一起互动";
} else {
this.intimacyRichText.node.active = true;
}
// this.inviteRichText.string = textString;
},
// update (dt) {},
});