init
This commit is contained in:
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,399 @@
|
||||
import { randomRange, view } from "cc";
|
||||
import GlobalValue from "../Common/GlobalValue";
|
||||
import SubManager from "../../Sub/SubManager";
|
||||
import { I_SDK_UserInfo_Callback } from "./SDKManager";
|
||||
|
||||
//广告ID
|
||||
const wx_banner_ad_unit_id = 'test'
|
||||
const wx_splash_ad_unit_id = 'test'
|
||||
const wx_video_ad_unit_id = 'test'
|
||||
|
||||
export class KSSDK{
|
||||
|
||||
static g_InGameScene = null; //游戏场景值
|
||||
|
||||
private wx_video:any = null;
|
||||
private wx_splash:any = null;
|
||||
private wx_banner:any = null;
|
||||
private wx_video_callback:Function = null;
|
||||
private wx_video_tag:number = null;
|
||||
private wx_gameClub:any = null; //游戏圈按钮
|
||||
|
||||
private ShareSTime: any;
|
||||
private ShareCb: any; //分享回调
|
||||
private shareTxt = ["分享失败", "请分享到一个群", "请分享给一位好友", "分享过于频繁"]
|
||||
|
||||
//初始化
|
||||
init(cb: Function = null) {
|
||||
// 保持屏幕常亮
|
||||
// window['ks'].setKeepScreenOn({ keepScreenOn: true });
|
||||
|
||||
//获取小游戏冷启动时的参数 热启动参数通过 ks.onShow 接口获取。
|
||||
let launchOption = window['ks'].getLaunchOptionsSync();
|
||||
KSSDK.g_InGameScene = launchOption.from;
|
||||
console.log('init 快手 - 进入游戏的场景值', launchOption);
|
||||
|
||||
// //显示分享按钮
|
||||
// window['ks'].showShareMenu({
|
||||
// withShareTicket: true,
|
||||
// menus: ["shareAppMessage", "shareTimeline"],
|
||||
// });
|
||||
// window['ks'].onShareAppMessage(() => {
|
||||
// return this.shareInfo();
|
||||
// });
|
||||
// window['ks'].onShareTimeline(() => {
|
||||
// return this.shareInfo();
|
||||
// })
|
||||
|
||||
//小游戏回到前台
|
||||
window['ks'].onShow(this.onWxShow.bind(this));
|
||||
//小游戏被隐藏 记个时间
|
||||
window['ks'].onHide(() => {
|
||||
console.log("快手 onHide回调:")
|
||||
if (this.ShareCb) {
|
||||
this.ShareSTime = new Date().getTime();
|
||||
console.log("分享时间差 记录:", this.ShareSTime);
|
||||
}
|
||||
});
|
||||
|
||||
this.init_video(); //初始化视频广告
|
||||
this.init_splash(); //初始化插屏广告
|
||||
this.init_banner(); //初始化Banner广告 弹窗广告
|
||||
cb && cb();
|
||||
}
|
||||
|
||||
|
||||
//小游戏回到前台
|
||||
onWxShow(data: any) {
|
||||
console.log("快手 onShow回调:", data)
|
||||
if (data) {
|
||||
//启动小游戏时传入的参数 object
|
||||
if (data.query) {
|
||||
GlobalValue.ShareTocusid = data.query.ShareCode
|
||||
}
|
||||
//游戏启动场景 string
|
||||
if (data.from) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ShareCb) {
|
||||
if (this.ShareSTime) {
|
||||
let nT = new Date().getTime();
|
||||
console.log("分享时间差 计算:",nT, this.ShareSTime, nT - this.ShareSTime);
|
||||
if (nT - this.ShareSTime > 1) { //快手的onHide有问题,离onShow很近
|
||||
let cb = this.ShareCb.succ
|
||||
cb && cb()
|
||||
} else {
|
||||
this.tostErr()
|
||||
}
|
||||
}
|
||||
this.ShareCb = null;
|
||||
}
|
||||
}
|
||||
//分享失败
|
||||
tostErr() {
|
||||
let rint = Math.floor( randomRange(0, this.shareTxt.length - 1) )
|
||||
SubManager.ShowPrompt(this.shareTxt[rint])
|
||||
if (this.ShareCb) {
|
||||
let cb = this.ShareCb.fail
|
||||
cb && cb()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**获取用户授权状态
|
||||
* @param autoKey string 授权类型 userInfo=用户信息,对应接口wx.getUserInfo
|
||||
*/
|
||||
checkAutoSetting(autoKey:string, cb:Function = null) {
|
||||
window['ks'].getSetting({
|
||||
success(res:any) {
|
||||
console.log("快手 - 检测权限状态 succ:", res)
|
||||
if (autoKey == "userInfo" && res.authSetting['scope.userInfo']) {
|
||||
cb && cb(true)
|
||||
} else {
|
||||
cb && cb(false)
|
||||
}
|
||||
},
|
||||
fail(res:any) {
|
||||
console.log("快手 - 检测权限状态 fail:", res)
|
||||
cb && cb(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人信息
|
||||
*/
|
||||
getUserInfo(cb:I_SDK_UserInfo_Callback = null) {
|
||||
var self = this;
|
||||
window['ks'].getSetting({
|
||||
success(res:any) {
|
||||
console.log("快手 - 获取授权信息成功:", res);
|
||||
let isScope = res.authSetting['scope.userInfo']
|
||||
if (isScope) {
|
||||
window['ks'].getUserInfo({
|
||||
success: (res2) => {
|
||||
console.log("快手 - 获取用户信息成功:", res2);
|
||||
cb && cb({avatarUrl:res2.userInfo.avatarUrl, nickName:res2.userInfo.nickName})
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log("快手 - 获取用户信息失败:", error);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
//向用户发起授权请求
|
||||
window['ks'].authorize({
|
||||
scope: 'scope.userInfo',
|
||||
success: (res) => {
|
||||
console.log("快手 - 发起授权请求成功:", res);
|
||||
self.getUserInfo(cb)
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log("快手 - 发起授权请求失败: ", error);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log("快手 - 获取授权信息失败: ", error);
|
||||
// cb && cb({avatarUrl:"", nickName:""})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//微信登录
|
||||
login(cb: Function = null) {
|
||||
window['ks'].login({
|
||||
success: (res) => {
|
||||
console.log('快手 - 登录成功', res.code);
|
||||
cb && cb({ platform:1, code: res.code });
|
||||
},
|
||||
fail(res: any) {
|
||||
console.log(`快手 login 调用失败`, res);
|
||||
cb && cb({ platform:1, code: null });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
//初始化视频广告
|
||||
private init_video() {
|
||||
this.wx_video = window['ks'].createRewardedVideoAd({
|
||||
adUnitId: wx_video_ad_unit_id
|
||||
});
|
||||
this.wx_video.onError((err) => {
|
||||
console.log('onError event emit', err);
|
||||
});
|
||||
this.wx_video.onClose(res => {
|
||||
console.log('onClose event emit',res);
|
||||
// 用户点击了【关闭广告】按钮
|
||||
// 小于 2.1.0 的基础库版本,res 是一个 undefined
|
||||
if ((res && res.isEnded) || res === undefined) {
|
||||
// 正常播放结束,可以下发游戏奖励
|
||||
if (this.wx_video_callback) {
|
||||
this.wx_video_callback(this.wx_video_tag);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 播放中途退出,不下发游戏奖励
|
||||
//wx_video_callback(-1);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//初始化插屏广告
|
||||
private init_splash() {
|
||||
// 创建插屏广告实例,提前初始化
|
||||
if (window['ks'].createInterstitialAd){
|
||||
this.wx_splash = window['ks'].createInterstitialAd({
|
||||
adUnitId: wx_splash_ad_unit_id
|
||||
});
|
||||
this.wx_splash.onError((err) => {
|
||||
console.log('splash onError event emit', err);
|
||||
});
|
||||
this.wx_splash.onClose(res => {
|
||||
console.log('splash onClose event emit', res);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//初始化Banner
|
||||
private init_banner() {
|
||||
|
||||
}
|
||||
|
||||
//显示视频广告
|
||||
show_video(callback:Function, tag:number) {
|
||||
if (wx_video_ad_unit_id == 'test') {
|
||||
console.log('未接入广告ID,视频广告请求直接返回');
|
||||
callback && callback();
|
||||
return;
|
||||
}
|
||||
if (this.wx_video) {
|
||||
this.wx_video_callback = callback;
|
||||
this.wx_video_tag = tag;
|
||||
let p = this.wx_video.show()
|
||||
p.then(function(result){
|
||||
// 激励视频展示成功
|
||||
console.log(`快手 show rewarded video ad success, result is ${result}`)
|
||||
}).catch(function(error){
|
||||
// 激励视频展示失败
|
||||
console.log(`快手 show rewarded video ad failed, error is ${error}`)
|
||||
})
|
||||
|
||||
// this.wx_video.load()
|
||||
// .then(() => {
|
||||
// this.wx_video.show()
|
||||
// .catch(err => {
|
||||
// this.wx_video.load()
|
||||
// .then(() => this.wx_video.show())
|
||||
// })
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
||||
//显示插屏
|
||||
show_splash() {
|
||||
|
||||
if (this.wx_splash) {
|
||||
let p = this.wx_splash.show()
|
||||
p.then(function(result){
|
||||
// 插屏广告展示成功
|
||||
console.log(`快手 show interstitial ad success, result is ${result}`)
|
||||
}).catch(function(error){
|
||||
// 插屏广告展示失败
|
||||
console.log(`快手 show interstitial ad failed, error is ${error}`)
|
||||
if (error.code === -10005) {
|
||||
// 表明当前app版本不支持插屏广告,可以提醒用户升级app版本
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//显示Banner
|
||||
show_banner() {
|
||||
if (this.wx_banner) {
|
||||
this.wx_banner.show(); //banner 默认隐藏(hide) 要打开
|
||||
}
|
||||
}
|
||||
|
||||
//隐藏Banner
|
||||
hide_banner() {
|
||||
if (this.wx_banner) {
|
||||
this.wx_banner.hide(); //banner 默认隐藏(hide) 要打开
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//分享信息
|
||||
shareInfo() {
|
||||
return {
|
||||
templateId: undefined, //分享模版id,不传走默认分享文案
|
||||
//查询字符串,从这条转发消息进入后,可通过 ks.getLaunchOptionsSync() 或 ks.onShow() 获取启动参数中的 query。必须是 key1=val1&key2=val2 的格式。
|
||||
query: "ShareCode=" + "user_default", //ModelPlayer.I.getPlayerId(),
|
||||
}
|
||||
}
|
||||
//主动拉起分享
|
||||
show_share(rewardCB?:Function) {
|
||||
console.log("主动拉起分享");
|
||||
let info:any = this.shareInfo();
|
||||
info.succ = rewardCB;
|
||||
info.success = null;
|
||||
info.fail = null;
|
||||
this.ShareCb = info;
|
||||
window['ks'].shareAppMessage(info);
|
||||
}
|
||||
|
||||
//获取设备分辨率
|
||||
getWindowSize() {
|
||||
let windowinfo = window['ks'].getSystemInfoSync();
|
||||
return {width:windowinfo.screenWidth, height: windowinfo.screenHeight};
|
||||
}
|
||||
|
||||
//显示游戏圈
|
||||
show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) {
|
||||
if (true) {
|
||||
console.log("显示游戏圈,快手暂不支持");
|
||||
return
|
||||
}
|
||||
}
|
||||
//隐藏游戏圈
|
||||
hide_gameClub() {
|
||||
console.log("隐藏游戏圈");
|
||||
if (this.wx_gameClub) {
|
||||
this.wx_gameClub.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//检查是否支持base64音频播放
|
||||
checkSupportBase64Audio() {
|
||||
return true;
|
||||
}
|
||||
//播放base64音频
|
||||
private _innerAudioContext: any = null;
|
||||
private _iacIdx = 0 //音频播放索引
|
||||
playBase64Audio(base64, loop) {
|
||||
if (!this.checkSupportBase64Audio()) {
|
||||
console.log("当前平台不支持base64音频播放");
|
||||
return;
|
||||
}
|
||||
|
||||
let substring = base64;
|
||||
let qianzhui = "data:audio/x-wav;base64,"
|
||||
if(base64.startsWith(qianzhui)) {
|
||||
substring = base64.substring(qianzhui.length, base64.length)
|
||||
}
|
||||
|
||||
let self = this;
|
||||
const fs = window['ks'].getFileSystemManager();
|
||||
//1.删除上一个音频
|
||||
const lastPath = window['ks'].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`
|
||||
console.log("快手 正在删除上一个音频 ->", lastPath);
|
||||
fs.removeSavedFile({
|
||||
filePath: lastPath,
|
||||
success(res) {
|
||||
console.log("快手 删除上一个音频成功", res);
|
||||
},
|
||||
fail(err) {
|
||||
console.log("快手 删除上一个音频失败", err);
|
||||
},
|
||||
complete(res) {
|
||||
console.log("快手 删除上一个音频完成", res);
|
||||
|
||||
//2.保存当前音频
|
||||
//这里需要每次保存时换一下名字的原因是:innerAudioContext设置路径时如果路径相同,会认为还是同一个音频,不会重新加载,所以需要每次保存时换一下名字
|
||||
self._iacIdx++;
|
||||
const audioPath = window['ks'].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`
|
||||
console.log("快手 正在保存本次音频 ->", audioPath);
|
||||
fs.writeFile({
|
||||
filePath: audioPath,
|
||||
data: substring,
|
||||
encoding: 'base64',
|
||||
success(res) {
|
||||
if (self._innerAudioContext == null){
|
||||
self._innerAudioContext = window['ks'].createInnerAudioContext();
|
||||
// 添加播放结束的回调
|
||||
self._innerAudioContext.onEnded(() => {
|
||||
console.log("快手 AI语音播放结束")
|
||||
self._innerAudioContext.stop(); // 使用 stop 方法停止音频并重置播放状态
|
||||
self._innerAudioContext.destroy(); // 销毁音频实例
|
||||
self._innerAudioContext = null;
|
||||
});
|
||||
}
|
||||
console.log("快手 播放base64音频", audioPath)
|
||||
self._innerAudioContext.src = audioPath;
|
||||
self._innerAudioContext.play(); // 开始播放音频
|
||||
},
|
||||
fail(err) {
|
||||
console.log("快手 保存本次音频失败", err);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"__version__": "1.0.1"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 870 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 690 KiB |
@@ -0,0 +1,305 @@
|
||||
import { _decorator, instantiate, Node, PageView, Prefab, Sprite, tween, 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.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
|
||||
}
|
||||
}
|
||||
|
||||
//放大图片
|
||||
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();
|
||||
|
||||
GButton.RemoveAndBandClick(npcPicClone, ()=>{
|
||||
npcPicClone.destroy();
|
||||
this.isShowBigPic = false;
|
||||
if (this.autoClose) {
|
||||
this.onClose();
|
||||
}
|
||||
}, this, 0, null, null, false);
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//region 图片缩放逻辑
|
||||
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,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "2cd057c0-225a-4c7a-96c3-24c7f384a842",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "2cd057c0-225a-4c7a-96c3-24c7f384a842@6c48a",
|
||||
"displayName": "yuka_portrait",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "2cd057c0-225a-4c7a-96c3-24c7f384a842",
|
||||
"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": "2cd057c0-225a-4c7a-96c3-24c7f384a842@f9941",
|
||||
"displayName": "yuka_portrait",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": -1.5,
|
||||
"offsetY": -12,
|
||||
"trimX": 0,
|
||||
"trimY": 24,
|
||||
"width": 273,
|
||||
"height": 340,
|
||||
"rawWidth": 276,
|
||||
"rawHeight": 364,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-136.5,
|
||||
-170,
|
||||
0,
|
||||
136.5,
|
||||
-170,
|
||||
0,
|
||||
-136.5,
|
||||
170,
|
||||
0,
|
||||
136.5,
|
||||
170,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
340,
|
||||
273,
|
||||
340,
|
||||
0,
|
||||
0,
|
||||
273,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
0.9891304347826086,
|
||||
0,
|
||||
0,
|
||||
0.9340659340659341,
|
||||
0.9891304347826086,
|
||||
0.9340659340659341
|
||||
],
|
||||
"minPos": [
|
||||
-136.5,
|
||||
-170,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
136.5,
|
||||
170,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "2cd057c0-225a-4c7a-96c3-24c7f384a842@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "2cd057c0-225a-4c7a-96c3-24c7f384a842@6c48a"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "2b91c8f7-e736-4d0b-94d8-87970bc80998",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "2b91c8f7-e736-4d0b-94d8-87970bc80998@6c48a",
|
||||
"displayName": "shuqing_shy",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "2b91c8f7-e736-4d0b-94d8-87970bc80998",
|
||||
"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": "2b91c8f7-e736-4d0b-94d8-87970bc80998@f9941",
|
||||
"displayName": "shuqing_shy",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": -55.5,
|
||||
"offsetY": -1.5,
|
||||
"trimX": 21,
|
||||
"trimY": 3,
|
||||
"width": 772,
|
||||
"height": 1186,
|
||||
"rawWidth": 925,
|
||||
"rawHeight": 1189,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-386,
|
||||
-593,
|
||||
0,
|
||||
386,
|
||||
-593,
|
||||
0,
|
||||
-386,
|
||||
593,
|
||||
0,
|
||||
386,
|
||||
593,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
21,
|
||||
1186,
|
||||
793,
|
||||
1186,
|
||||
21,
|
||||
0,
|
||||
793,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0.022702702702702703,
|
||||
0,
|
||||
0.8572972972972973,
|
||||
0,
|
||||
0.022702702702702703,
|
||||
0.9974768713204374,
|
||||
0.8572972972972973,
|
||||
0.9974768713204374
|
||||
],
|
||||
"minPos": [
|
||||
-386,
|
||||
-593,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
386,
|
||||
593,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "2b91c8f7-e736-4d0b-94d8-87970bc80998@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "2b91c8f7-e736-4d0b-94d8-87970bc80998@6c48a"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 393 KiB |
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "21980d70-759b-4666-ad69-a282aaf62d62",
|
||||
"files": [
|
||||
".jpg",
|
||||
".json"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "21980d70-759b-4666-ad69-a282aaf62d62@6c48a",
|
||||
"displayName": "rose_1_cg",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "21980d70-759b-4666-ad69-a282aaf62d62",
|
||||
"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": "21980d70-759b-4666-ad69-a282aaf62d62@f9941",
|
||||
"displayName": "rose_1_cg",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 996,
|
||||
"height": 1280,
|
||||
"rawWidth": 996,
|
||||
"rawHeight": 1280,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-498,
|
||||
-640,
|
||||
0,
|
||||
498,
|
||||
-640,
|
||||
0,
|
||||
-498,
|
||||
640,
|
||||
0,
|
||||
498,
|
||||
640,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
1280,
|
||||
996,
|
||||
1280,
|
||||
0,
|
||||
0,
|
||||
996,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-498,
|
||||
-640,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
498,
|
||||
640,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "21980d70-759b-4666-ad69-a282aaf62d62@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": false,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "21980d70-759b-4666-ad69-a282aaf62d62@6c48a"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 838 KiB |
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "126e5446-c191-4a84-8f92-86aa21ea67e2",
|
||||
"files": [
|
||||
".jpg",
|
||||
".json"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "126e5446-c191-4a84-8f92-86aa21ea67e2@6c48a",
|
||||
"displayName": "tiannin_2_cg",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "126e5446-c191-4a84-8f92-86aa21ea67e2",
|
||||
"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": "126e5446-c191-4a84-8f92-86aa21ea67e2@f9941",
|
||||
"displayName": "tiannin_2_cg",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 996,
|
||||
"height": 1280,
|
||||
"rawWidth": 996,
|
||||
"rawHeight": 1280,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-498,
|
||||
-640,
|
||||
0,
|
||||
498,
|
||||
-640,
|
||||
0,
|
||||
-498,
|
||||
640,
|
||||
0,
|
||||
498,
|
||||
640,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
1280,
|
||||
996,
|
||||
1280,
|
||||
0,
|
||||
0,
|
||||
996,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-498,
|
||||
-640,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
498,
|
||||
640,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "126e5446-c191-4a84-8f92-86aa21ea67e2@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": false,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "126e5446-c191-4a84-8f92-86aa21ea67e2@6c48a"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 511 KiB |
Reference in New Issue
Block a user