174 lines
5.7 KiB
Plaintext
174 lines
5.7 KiB
Plaintext
import { _decorator, Component, instantiate, isValid, Label, Material, Node, Prefab, Sprite, tween, UIOpacity, v3 } from 'cc';
|
|
import Utils from '../../Main/Common/Utils';
|
|
import HXZ_ScrollViewList from '../../Main/Common/ScrollViewList';
|
|
import GameManager from '../../Main/Manager/GameManager';
|
|
import { I_HuiyiInfo } from '../../Main/Config/CommonConfig';
|
|
import ResManager from '../../Main/Manager/ResManager';
|
|
import { GButton } from '../../Main/Common/GButton';
|
|
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
|
import SubManager from '../SubManager';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/**图鉴 - 心动回忆 */
|
|
@ccclass('tj_huiyi')
|
|
export class tj_huiyi extends Component {
|
|
|
|
private itemClone!: any;
|
|
@property(HXZ_ScrollViewList)
|
|
Item_List: HXZ_ScrollViewList = null!; // 回忆列表
|
|
@property(Prefab)
|
|
Item_Temp: Prefab = null!;//被克隆的模板
|
|
|
|
private _nodeTab:any = {}
|
|
private huiyiDataList: I_HuiyiInfo[] = []
|
|
|
|
protected onLoad(): void {
|
|
Utils.parseNode(this.node, this._nodeTab)
|
|
|
|
this.itemClone = instantiate(this.Item_Temp);
|
|
this.Item_List.setTemplateItem(this.itemClone);
|
|
|
|
}
|
|
start() {
|
|
|
|
this.huiyiDataList = []
|
|
let lvlist = GameManager.getLevelCfgList()
|
|
let isunlock = false
|
|
for (let i = 0; i < lvlist.length; i++) {
|
|
let data = lvlist[i]
|
|
if (data.id) {
|
|
for (let j=0; j<4; j++) {
|
|
isunlock = false
|
|
if (data.is_unlock && data.star >= j) {
|
|
isunlock = true
|
|
}
|
|
let item: I_HuiyiInfo = {
|
|
lvId: data.id,
|
|
star: j,
|
|
unlock: isunlock,
|
|
}
|
|
this.huiyiDataList.push(item)
|
|
}
|
|
}
|
|
}
|
|
|
|
let cellnum = Math.ceil(this.huiyiDataList.length / 2)
|
|
this.Item_List.numItems = cellnum
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
|
|
|
|
//region 列表渲染
|
|
onRenderItemList(node: any, idx: number) {
|
|
if(!isValid(node)) {return}
|
|
if (!node.inited) {
|
|
node.inited = true;
|
|
Utils.parseNode(node);
|
|
|
|
let opa1:UIOpacity = node.hyItem1.getComponent(UIOpacity)
|
|
let opa2:UIOpacity = node.hyItem2.getComponent(UIOpacity)
|
|
|
|
opa1.opacity = 0
|
|
tween(opa1)
|
|
.delay(0.1)
|
|
.to(0.2, {opacity: 255})
|
|
.start()
|
|
|
|
opa2.opacity = 0
|
|
tween(opa2)
|
|
.delay(0.15)
|
|
.to(0.2, {opacity: 255})
|
|
.start()
|
|
}
|
|
|
|
let startIdx = idx * 2
|
|
let data1 = this.huiyiDataList[idx * 2]
|
|
let data2 = this.huiyiDataList[idx * 2 + 1]
|
|
this.refreshHuiyiCell(node.hyItem1, startIdx)
|
|
this.refreshHuiyiCell(node.hyItem2, startIdx+1)
|
|
}
|
|
//刷新单个节点
|
|
private refreshHuiyiCell(hyItem:any, idx:number) {
|
|
let data = this.huiyiDataList[idx]
|
|
if (!data) {
|
|
hyItem.active = false
|
|
return
|
|
}
|
|
hyItem.active = true
|
|
if (!hyItem.inited) {
|
|
hyItem.inited = true;
|
|
Utils.parseNode(hyItem);
|
|
}
|
|
|
|
let lvCfg = GameManager.getLevelCfg(data.lvId)
|
|
//名字
|
|
Utils.setString(hyItem.npcName, lvCfg.name)
|
|
|
|
let picPath = "" //表情图
|
|
let talkStr = "" //对话
|
|
let lockStr = "" //解锁提示
|
|
if (data.star == 3) {
|
|
picPath = `cg3/${lvCfg.threeStarCG}`
|
|
talkStr = lvCfg.threeStarSummary
|
|
lockStr = "3星成功结婚解锁"
|
|
} else if (data.star == 2) {
|
|
picPath = `cg2/${lvCfg.twoStarCG}`
|
|
talkStr = lvCfg.twoStarSummary
|
|
lockStr = "2星成为恋人解锁"
|
|
} else if (data.star == 1) {
|
|
picPath = `cg1/${lvCfg.oneStarCG}`
|
|
talkStr = lvCfg.oneStarSummary
|
|
lockStr = "1星通过相亲解锁"
|
|
} else {
|
|
picPath = `cg0/${lvCfg.failureCG}`
|
|
talkStr = lvCfg.failureSummary
|
|
lockStr = "0星通关失败解锁"
|
|
}
|
|
let cgPic: Sprite = hyItem.npcPic.getComponent(Sprite)
|
|
ResManager.I.changeBundleSpriteFrame(cgPic, picPath, "Raw")
|
|
|
|
if (data.unlock) {
|
|
//已解锁
|
|
hyItem.LockNode.active = false
|
|
Utils.setString(hyItem.labTalk, talkStr)
|
|
ResManager.I.SetBlur(cgPic, false)
|
|
} else {
|
|
//未解锁
|
|
hyItem.LockNode.active = true
|
|
Utils.setString(hyItem.labTalk, lockStr)
|
|
ResManager.I.SetBlur(cgPic, true)
|
|
}
|
|
//星级
|
|
for (let i = 1; i <= 3; i++) {
|
|
let starSpt = hyItem["star" + i].getComponent(Sprite)
|
|
let starPath = ""
|
|
if(data.star == 3) {
|
|
starPath = "lv_23"
|
|
} else if (data.star < i) {
|
|
starPath = "lv_21"
|
|
} else {
|
|
starPath = "lv_22"
|
|
}
|
|
ResManager.I.changeBundleSpriteFrame(starSpt, starPath, "Zhujiemian")
|
|
}
|
|
|
|
GButton.RemoveAndBandClick(hyItem, ()=>{
|
|
if (data.unlock) {
|
|
Utils.sendInnerMsg(InnerMsgCode.UI_Tj_huiyi_Pic, {hyItem:hyItem, talk:talkStr})
|
|
} else {
|
|
SubManager.ShowConfirm({
|
|
content: "该奖励尚未解锁,是否跳转至对应关卡进行攻略?",
|
|
strYes: "前往攻略",
|
|
yesCallback: () => {
|
|
Utils.sendInnerMsg(InnerMsgCode.UI_Tj_huiyi_Lv, {lvId:data.lvId})
|
|
}
|
|
})
|
|
}
|
|
}, this, 0, null, null, false);
|
|
}
|
|
|
|
}
|