init
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 127 KiB |
@@ -0,0 +1,327 @@
|
||||
import { _decorator, instantiate, Node, PageView, Prefab, Sprite, tween, UIOpacity, UITransform, Vec3, view } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import GameManager from '../../Main/Manager/GameManager';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import GameRootUI from '../../Main/Common/GameRootUI';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
import { ViewManager } from '../../Main/Manager/ViewManager';
|
||||
import { E_AD_TARGET } from './TalkAdDialog';
|
||||
import { SDKManager } from '../../Main/Channel/SDKManager';
|
||||
import SubManager from '../SubManager';
|
||||
import { I_ZhengCangConfig } from '../../Main/Config/CommonConfig';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//图鉴奖励界面
|
||||
@ccclass('TujianReward_UI')
|
||||
export class TujianReward_UI extends li_BaseView {
|
||||
|
||||
@property(Prefab)
|
||||
private rewardPageItem: Prefab = null //角色页签节点
|
||||
private npcPageView: PageView = null //可领取角色页签容器
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
private rewardList: any[] = []; //可领取的奖励列表
|
||||
private targetPicId:number|null = null; //目标图片Id
|
||||
private isShowBigPic: boolean = false; //是否显示大图
|
||||
private autoClose: boolean = false; //是否自动关闭
|
||||
|
||||
/**缩放图片信息 */
|
||||
private bigPicInfo = {
|
||||
pageItem: null, //翻页item
|
||||
npcPic: null, //npc图片
|
||||
origScale: Vec3.ZERO, //原始缩放
|
||||
}
|
||||
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
this._nodeTab.BPMask1.active = false;
|
||||
this._nodeTab.labBPTalk.active = false;
|
||||
this.npcPageView = this._nodeTab.npcPageView.getComponent(PageView)
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
Utils.addInnerEL(InnerMsgCode.Data_ZhencangUp, this, this.resiveZhencangUp)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
GButton.BandClick(this._nodeTab.mask, ()=>{
|
||||
this.onClose();
|
||||
}, this, 0, null, null, false);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnCancel, ()=>{
|
||||
this.onClose();
|
||||
}, this);
|
||||
GButton.BandClick(this._nodeTab.btnAD, ()=>{
|
||||
ViewManager.I.openBundlesView("UI/StartUI/TalkAdDialog", {
|
||||
type: E_AD_TARGET.shoucangJiangli, //收藏奖励
|
||||
content: "每日可以免费领取 1 次奖励,更多奖励需要“观看广告”领取",
|
||||
adCallback: (isfree:any)=>{
|
||||
if (isfree){
|
||||
this.doGetReward()
|
||||
} else {
|
||||
SDKManager.show_reward_video_ad(this.node.uuid, 1)
|
||||
}
|
||||
},
|
||||
shareCallback: ()=>{
|
||||
SDKManager.show_reward_share(this.node.uuid, 1)
|
||||
}
|
||||
})
|
||||
}, this);
|
||||
GButton.BandClick(this._nodeTab.btnFree, ()=>{
|
||||
this.doGetReward();
|
||||
}, this);
|
||||
|
||||
|
||||
SDKManager.register_video_reward(this.node.uuid, (tag:number)=>{
|
||||
console.log("视频广告回调", tag)
|
||||
if (tag == 1) {
|
||||
// 加次数
|
||||
SubManager.ShowPrompt("观看视频成功")
|
||||
this.doGetReward()
|
||||
}
|
||||
})
|
||||
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
|
||||
console.log("分享回调", tag)
|
||||
if (tag == 1) {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
this.scheduleOnce(()=>{
|
||||
this.refreshPageList()
|
||||
}, 0.1)
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
/**私家珍藏数据变化消息 */
|
||||
resiveZhencangUp(data:any) {
|
||||
this.refreshPageList()
|
||||
}
|
||||
|
||||
|
||||
/**刷新翻页容器 */
|
||||
refreshPageList() {
|
||||
let list = GameManager.zhencangCanget
|
||||
this._doRefreshWithData(list)
|
||||
}
|
||||
private _doRefreshWithData(data: any[]) {
|
||||
this.rewardList = []
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let item = data[i]
|
||||
let rcell = GameManager.getZhencangCfg(item.img)
|
||||
if (rcell) {
|
||||
this.rewardList.push(item)
|
||||
}
|
||||
}
|
||||
if (this.rewardList.length == 0) {
|
||||
if (this.isShowBigPic) {
|
||||
this.autoClose = true
|
||||
return
|
||||
}
|
||||
this.onClose();
|
||||
return;
|
||||
}
|
||||
|
||||
let wsize = view.getVisibleSize()
|
||||
let tempNode = instantiate(this.rewardPageItem)
|
||||
let tntf = tempNode.getComponent(UITransform)
|
||||
tntf.setContentSize(wsize.width, tntf.height)
|
||||
|
||||
let targetPageIdx = -1
|
||||
this.npcPageView.removeAllPages()
|
||||
for (let i=0; i<this.rewardList.length; i++) {
|
||||
let pnode: any = instantiate(tempNode)
|
||||
this.npcPageView.addPage(pnode)
|
||||
Utils.parseNode(pnode)
|
||||
let rewarddata = this.rewardList[i]
|
||||
let zhencangCfg: I_ZhengCangConfig = GameManager.getZhencangCfg(rewarddata.img)
|
||||
let lvcfg = GameManager.getLevelCfg(zhencangCfg.levelId)
|
||||
|
||||
//名字
|
||||
Utils.setString(pnode.labName, lvcfg.name)
|
||||
//简介
|
||||
Utils.setString(pnode.labDesc, zhencangCfg.giftSummary)
|
||||
|
||||
let cgPic: Sprite = pnode.npcPic.getComponent(Sprite)
|
||||
//图片
|
||||
let picUrl = `${HttpUnit.ZhenCangUrl}${zhencangCfg.giftImgName}.jpg`
|
||||
ResManager.I.changeRemoteSpriteFrame(cgPic, picUrl, "jpg")
|
||||
|
||||
//图片模糊
|
||||
ResManager.I.SetBlur(cgPic, true)
|
||||
|
||||
if (this.targetPicId && this.targetPicId == rewarddata.id) {
|
||||
targetPageIdx = i
|
||||
}
|
||||
|
||||
// GButton.RemoveAndBandClick(pnode.npcPic, ()=>{
|
||||
// this.changePicScale(pnode);
|
||||
// }, this, 0, null, null, false);
|
||||
}
|
||||
|
||||
//按钮状态
|
||||
let freecount = HttpUnit.GetZhencangFreeCount()
|
||||
let havefree = freecount > 0
|
||||
this._nodeTab.btnFree.active = havefree
|
||||
this._nodeTab.btnAD.active = !havefree
|
||||
|
||||
if (targetPageIdx >= 0) {
|
||||
this.scheduleOnce(()=>{
|
||||
this.npcPageView.scrollToPage(targetPageIdx, 0.5)
|
||||
}, 0)
|
||||
}
|
||||
this.targetPicId = null
|
||||
}
|
||||
// //翻页容器事件回调
|
||||
// guidePageViewEvent(param1, param2) {
|
||||
// let pageIdx = this.npcPageView.curPageIdx
|
||||
// this.changeLevel(pageIdx+1)
|
||||
// }
|
||||
|
||||
/**获取当前页奖励 */
|
||||
doGetReward() {
|
||||
let pageIdx = this.npcPageView.curPageIdx
|
||||
let data = this.rewardList[pageIdx]
|
||||
console.log("当前页奖励:", pageIdx, data)
|
||||
HttpUnit.ins.getZhencangReward({id: data.id}, (_data) => {
|
||||
if (_data) {
|
||||
let targetdata = this.rewardList[pageIdx+1]
|
||||
if (targetdata) {
|
||||
this.targetPicId = targetdata.id
|
||||
} else {
|
||||
targetdata = this.rewardList[pageIdx-1]
|
||||
if (targetdata) {
|
||||
this.targetPicId = targetdata.id
|
||||
}
|
||||
}
|
||||
|
||||
//region放大图片
|
||||
this.isShowBigPic = true
|
||||
let pnode:any = this.npcPageView.getPages()[pageIdx]
|
||||
let npcPic = pnode.npcPic
|
||||
let wpos = new Vec3(0,0,0);
|
||||
npcPic.getWorldPosition(wpos);
|
||||
let BigPicRoot:Node = this._nodeTab.BigPicRoot;
|
||||
let npos = BigPicRoot.getComponent(UITransform).convertToNodeSpaceAR(wpos);
|
||||
let npcPicClone = instantiate(npcPic);
|
||||
npcPicClone.setParent(BigPicRoot);
|
||||
npcPicClone.setPosition(npos);
|
||||
ResManager.I.SetBlur(npcPicClone.getComponent(Sprite), false)
|
||||
|
||||
let ttime = 0.2;
|
||||
GameRootUI.DisableOper(ttime+0.1)
|
||||
let s = 1
|
||||
let windowSize = view.getVisibleSize(); // 获取窗口大小
|
||||
let picTf:UITransform = npcPicClone.getComponent(UITransform);
|
||||
if (picTf.height < windowSize.height) {
|
||||
s = windowSize.height / picTf.height;
|
||||
}
|
||||
tween((npcPicClone))
|
||||
.to(ttime, { scale: new Vec3(s, s, s), position: new Vec3(0, 0, 0) }, { easing: 'quadOut' })
|
||||
.call(() => {
|
||||
//刷新数据
|
||||
GameManager.refreshZhencangCanget()
|
||||
})
|
||||
.start();
|
||||
|
||||
//介绍背景
|
||||
this._nodeTab.BPMask1.active = true;
|
||||
this._nodeTab.BPMask1.setSiblingIndex(10)
|
||||
let opaMask = this._nodeTab.BPMask1.getComponent(UIOpacity);
|
||||
opaMask.opacity = 0;
|
||||
tween(opaMask)
|
||||
.to(ttime, { opacity: 255 }, { easing: 'quadOut' })
|
||||
.start();
|
||||
//介绍文本
|
||||
this._nodeTab.labBPTalk.active = true;
|
||||
this._nodeTab.labBPTalk.setSiblingIndex(11)
|
||||
let zhencangCfg: I_ZhengCangConfig = GameManager.getZhencangCfg(data.img)
|
||||
Utils.setString(this._nodeTab.labBPTalk, zhencangCfg.giftSummary)
|
||||
let opaTalk = this._nodeTab.labBPTalk.getComponent(UIOpacity);
|
||||
opaTalk.opacity = 0;
|
||||
tween(opaTalk)
|
||||
.to(ttime, { opacity: 255 }, { easing: 'quadOut' })
|
||||
.start();
|
||||
|
||||
GButton.RemoveAndBandClick(npcPicClone, ()=>{
|
||||
npcPicClone.destroy();
|
||||
this._nodeTab.BPMask1.active = false;
|
||||
this._nodeTab.labBPTalk.active = false
|
||||
this.isShowBigPic = false;
|
||||
if (this.autoClose) {
|
||||
this.onClose();
|
||||
}
|
||||
}, this, 0, null, null, false);
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//图片缩放逻辑
|
||||
changePicScale(item: any) {
|
||||
if (this.bigPicInfo.pageItem) {
|
||||
//缩小
|
||||
let npcPic = this.bigPicInfo.npcPic
|
||||
let wpos = new Vec3(0,0,0);
|
||||
this.bigPicInfo.pageItem.picRoot.getWorldPosition(wpos);
|
||||
let npos = this._nodeTab.BigPicRoot.getComponent(UITransform).convertToNodeSpaceAR(wpos);
|
||||
|
||||
let ttime = 0.3;
|
||||
GameRootUI.DisableOper(ttime+0.1)
|
||||
tween((npcPic))
|
||||
.to(ttime, { scale: this.bigPicInfo.origScale, position: npos }, { easing: 'quadOut' })
|
||||
.call(() => {
|
||||
npcPic.setParent(this.bigPicInfo.pageItem.picRoot);
|
||||
npcPic.setPosition(new Vec3(0,0,0));
|
||||
this.bigPicInfo.pageItem = null;
|
||||
this.bigPicInfo.npcPic = null;
|
||||
})
|
||||
.start();
|
||||
|
||||
} else {
|
||||
//放大
|
||||
let npcPic:Node = item.npcPic;
|
||||
this.bigPicInfo.pageItem = item;
|
||||
this.bigPicInfo.npcPic = npcPic;
|
||||
this.bigPicInfo.origScale = npcPic.scale.clone();
|
||||
|
||||
let wpos = new Vec3(0,0,0);
|
||||
npcPic.getWorldPosition(wpos);
|
||||
let BigPicRoot:Node = this._nodeTab.BigPicRoot;
|
||||
let npos = BigPicRoot.getComponent(UITransform).convertToNodeSpaceAR(wpos);
|
||||
npcPic.setParent(BigPicRoot);
|
||||
npcPic.setPosition(npos);
|
||||
|
||||
let ttime = 0.3;
|
||||
GameRootUI.DisableOper(ttime+0.1)
|
||||
//放大图片
|
||||
let s = 1
|
||||
let windowSize = view.getVisibleSize(); // 获取窗口大小
|
||||
let picTf:UITransform = npcPic.getComponent(UITransform);
|
||||
if (picTf.height < windowSize.height) {
|
||||
s = windowSize.height / picTf.height;
|
||||
}
|
||||
tween((npcPic))
|
||||
.to(ttime, { scale: new Vec3(s, s, s), position: new Vec3(0, 0, 0) }, { easing: 'quadOut' })
|
||||
.start();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "cccc5fab-681f-424a-8410-1d418257aaf9",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 461 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 422 KiB |
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "bf5ed416-3ce4-44bd-8efc-f40cb27ce29a",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "bf5ed416-3ce4-44bd-8efc-f40cb27ce29a@6c48a",
|
||||
"displayName": "youmiaoxiang_avatar",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "bf5ed416-3ce4-44bd-8efc-f40cb27ce29a",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "bf5ed416-3ce4-44bd-8efc-f40cb27ce29a@f9941",
|
||||
"displayName": "youmiaoxiang_avatar",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 80,
|
||||
"height": 80,
|
||||
"rawWidth": 80,
|
||||
"rawHeight": 80,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-40,
|
||||
-40,
|
||||
0,
|
||||
40,
|
||||
-40,
|
||||
0,
|
||||
-40,
|
||||
40,
|
||||
0,
|
||||
40,
|
||||
40,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
80,
|
||||
80,
|
||||
80,
|
||||
0,
|
||||
0,
|
||||
80,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-40,
|
||||
-40,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
40,
|
||||
40,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "bf5ed416-3ce4-44bd-8efc-f40cb27ce29a@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "bf5ed416-3ce4-44bd-8efc-f40cb27ce29a@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import { _decorator, Component, Node, Sprite } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//通用广告弹窗
|
||||
@ccclass('CommAdDialog')
|
||||
export class CommAdDialog extends Component {
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
private inited: boolean = false;
|
||||
|
||||
onLoad() {
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
}
|
||||
|
||||
start() {
|
||||
// GButton.BandClick(this._nodeTab.mask, ()=>{
|
||||
|
||||
// }, this, 0, null, null, false);
|
||||
//关闭
|
||||
GButton.BandClick(this._nodeTab.btnClose, ()=>{
|
||||
if (this._data && this._data.closeCallback) {
|
||||
this._data.closeCallback();
|
||||
}
|
||||
this.node.removeFromParent()
|
||||
}, this);
|
||||
//左 取消
|
||||
GButton.BandClick(this._nodeTab.btnLeft, ()=>{
|
||||
if (this._data && this._data.leftCallback) {
|
||||
this._data.leftCallback();
|
||||
}
|
||||
this.node.removeFromParent()
|
||||
}, this);
|
||||
//右 看广告
|
||||
GButton.BandClick(this._nodeTab.btnAD, ()=>{
|
||||
if (this._data && this._data.adCallback) {
|
||||
this._data.adCallback();
|
||||
}
|
||||
this.node.removeFromParent()
|
||||
}, this);
|
||||
|
||||
this.inited = true;
|
||||
this.refreshUI();
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
/**设置显示参数 */
|
||||
setParam(data: any) {
|
||||
this._data = data;
|
||||
this.refreshUI();
|
||||
}
|
||||
|
||||
|
||||
private refreshUI() {
|
||||
if (!this.inited || !this._data) return;
|
||||
//内容
|
||||
Utils.setString(this._nodeTab.labContent, this._data.content);
|
||||
//确认按钮文本
|
||||
if (this._data.strAd) {
|
||||
Utils.setString(this._nodeTab.labAd, this._data.strAd);
|
||||
}
|
||||
//取消按钮文本
|
||||
if (this._data.strLeft) {
|
||||
Utils.setString(this._nodeTab.labLeft, this._data.strLeft);
|
||||
}
|
||||
//隐藏取消按钮
|
||||
if (this._data.hideLeft == true) {
|
||||
this._nodeTab.btnLeft.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user