You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
8.1 KiB
175 lines
8.1 KiB
//#region 文件引入
|
|
import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText, random } from "cc";
|
|
import BaseUIForm from "../../Mgr_UI/BaseUIForm";
|
|
import { TokenDataProxy } from "../../Mgr_LocalData/DataTypeProxy/TokenDataProxy";
|
|
import { EVideoType, GameTotalType, PropType, TXVideoMapping } from "../../const/GameEnum";
|
|
import UIMgr from "../../Mgr_UI/UIMgr";
|
|
import { Global } from "../../Global";
|
|
import { LocalDataMgr } from "../../Mgr_LocalData/LocalDataMgr";
|
|
import { AD_DOUBLE_CONFIG, AD_DOUBLE_TYPE, CONFIDANTE_TYPE, TALENT_TYPE } from "../../const/GGameData";
|
|
import { TXSDKMgr } from "../../Mgr_Ge/TXSDKMgr";
|
|
import MathUtils from "../../ExUtils/MathUtils";
|
|
import MesMgr from "../../MesEvent/MesMgr";
|
|
import { EGlobalEvent } from "../../MesEvent/EGlobalEvent";
|
|
import GDUtils from "../../ExCUtils/GDUtils";
|
|
import { ResUrlLoad } from "../../CComEx/ResUrlLoad";
|
|
import { Utils } from "../../ExUtils/Utils";
|
|
//#endregion 文件引入
|
|
const {ccclass, property,menu} = _decorator;
|
|
@ccclass("LookAdGetUI_Proxy")
|
|
export default class LookAdGetUIDoule_Proxy extends BaseUIForm{
|
|
//#region 节点自动生成
|
|
@property(Label)
|
|
lab_title: Label = null;
|
|
@property(Node)
|
|
n_coinInfo: Node = null;
|
|
@property(Node)
|
|
n_coin: Node = null;
|
|
@property(Label)
|
|
lab_coin: Label = null;
|
|
@property(Label)
|
|
lab_mul: Label = null;
|
|
@property(Node)
|
|
n_offlineInfo: Node = null;
|
|
@property(Label)
|
|
lab_offline_coin: Label = null;
|
|
@property(Label)
|
|
lab_shopNum: Label = null;
|
|
@property(Button)
|
|
btn_AdGetDoule: Button = null;
|
|
@property(Label)
|
|
lab_btnmul: Label = null;
|
|
@property(Button)
|
|
btn_AdGet: Button = null;
|
|
//#endregion 节点自动生成
|
|
|
|
@property(Button)
|
|
closeGetRewardBtn: Button = null;
|
|
private m_CoinType:PropType = PropType.eGold;
|
|
private m_AdGetNum:number = 100000;
|
|
private m_AdShopRefNum:number = 0;
|
|
private m_EventName:string = EVideoType.AddCoinDouble;
|
|
|
|
// 翻倍下限额外增加的值
|
|
private m_MinEx:number = 0;
|
|
onButtonClick(button: Button) {
|
|
|
|
/**点击事件触发*/
|
|
switch (button) {
|
|
case this.btn_AdGetDoule:
|
|
Global.showvideo({name: this.m_EventName, gamelv: this.mDataMgr.Scene.getRealLevel()},()=>{
|
|
let mul = 1;
|
|
const config = AD_DOUBLE_CONFIG.find(item=>item.type == this.param.type);
|
|
if(config){
|
|
if(config.min == config.max){
|
|
mul = config.min;
|
|
}else{
|
|
if(AD_DOUBLE_TYPE.AD_ADD_TJCOIN == this.param.type){
|
|
const rand = MathUtils.randomRangeInt(1, 100);
|
|
if(rand <= 25){
|
|
mul = 2;
|
|
}else if(rand <= 75){
|
|
mul = 3;
|
|
}else{
|
|
mul = 4;
|
|
}
|
|
}else{
|
|
mul = MathUtils.randomRangeInt(config.min + this.m_MinEx, config.max);
|
|
}
|
|
}
|
|
this.getReward(mul);
|
|
}
|
|
});
|
|
|
|
break;
|
|
case this.btn_AdGet:
|
|
this.getReward();
|
|
break
|
|
case this.closeGetRewardBtn:
|
|
this.getReward();
|
|
break
|
|
default:
|
|
ConsoleEx.Log(button);
|
|
break;
|
|
}
|
|
}
|
|
|
|
protected start(): void {
|
|
if(this.param){
|
|
this.m_AdShopRefNum = 0;
|
|
this.m_AdGetNum = this.param.coin;
|
|
this.m_CoinType = PropType.eGold;
|
|
CNodeUtils.setActive(this.n_coinInfo, true);
|
|
CNodeUtils.setActive(this.n_offlineInfo, false);
|
|
CNodeUtils.switchText(this.lab_title,"恭喜获得");
|
|
CNodeUtils.switchText(this.lab_btnmul,"随机翻倍");
|
|
const tokenicon = this.n_coin.getComponent(ResUrlLoad);
|
|
const labnum = Utils.StringUtils.formatLargeNumber(this.m_AdGetNum);
|
|
switch(this.param.type){
|
|
case AD_DOUBLE_TYPE.AD_ADD_COIN:
|
|
this.m_MinEx = Math.min(this.mDataMgr.Pass.passed_times, Global.CsvMgr.cnf_discretization_csv[9].num2);
|
|
this.m_EventName = EVideoType.AddCoinDouble;
|
|
tokenicon.showResInfo(GameTotalType.TOKEN, PropType.eGold);
|
|
CNodeUtils.switchText(this.lab_coin,`${GDUtils.getTokenName(PropType.eGold)}+${labnum}`);
|
|
TXSDKMgr.ins.AD_UI_SHOW(TXVideoMapping[EVideoType.AddCoinDouble]);
|
|
break;
|
|
case AD_DOUBLE_TYPE.AD_ADD_TJCOIN:
|
|
this.m_EventName = EVideoType.AddTjCoinDouble;
|
|
tokenicon.showResInfo(GameTotalType.TOKEN, PropType.eTaiJi);
|
|
CNodeUtils.switchText(this.lab_coin,`${GDUtils.getTokenName(PropType.eTaiJi)}+${this.m_AdGetNum}`);
|
|
this.m_CoinType = PropType.eTaiJi;
|
|
break;
|
|
case AD_DOUBLE_TYPE.AD_OFFLINE:
|
|
this.m_EventName = EVideoType.OffLineDouble;
|
|
this.m_AdShopRefNum = this.param.shopNum;
|
|
CNodeUtils.switchText(this.lab_title,"离线奖励");
|
|
CNodeUtils.switchText(this.lab_btnmul,"奖励 x2");
|
|
CNodeUtils.switchText(this.lab_offline_coin,`+${labnum}`);
|
|
CNodeUtils.switchText(this.lab_shopNum,`+${this.m_AdShopRefNum}次`);
|
|
CNodeUtils.setActive(this.n_offlineInfo, true);
|
|
CNodeUtils.setActive(this.n_coinInfo, false);
|
|
break;
|
|
}
|
|
const config = AD_DOUBLE_CONFIG.find(item=>item.type == this.param.type);
|
|
config && CNodeUtils.switchText(this.lab_mul,`随机${config.min + this.m_MinEx}~${config.max}倍`)
|
|
}
|
|
}
|
|
|
|
onClick_bgCloseBtn(btn?: Node): void {
|
|
this.getReward()
|
|
}
|
|
|
|
getReward(mul:number = 1): void {
|
|
this.m_AdGetNum *= mul;
|
|
this.m_AdShopRefNum *= mul;
|
|
mul > 1 && UIMgr.Ins.ShowTipsUI(`恭喜奖励 <color=#F05F3B>x${mul}倍</color>`);
|
|
if(this.m_CoinType == PropType.eGold){
|
|
let rewcoin = this.m_AdGetNum;
|
|
UIMgr.Ins.ShowTipsUI(`获得${GDUtils.getTokenName(PropType.eGold)} +${Utils.StringUtils.formatLargeNumber(this.m_AdGetNum)}`);
|
|
const talenttime = LocalDataMgr.Talent.getProp1(TALENT_TYPE.AD_ADD_COIN);
|
|
if(this.param.type == AD_DOUBLE_TYPE.AD_ADD_COIN){
|
|
if(talenttime > 0){
|
|
rewcoin = this.m_AdGetNum * talenttime;
|
|
const labnum = Utils.StringUtils.formatLargeNumber(rewcoin - this.m_AdGetNum)
|
|
UIMgr.Ins.ShowTipsUI(`天赋爆发,额外<color=#218026>+${labnum}</color>`);
|
|
}
|
|
const confcoin = this.m_AdGetNum * LocalDataMgr.Confidante.getProp(CONFIDANTE_TYPE.来财) * 0.01;
|
|
if(confcoin > 0){
|
|
rewcoin += confcoin;
|
|
UIMgr.Ins.ShowTipsUI(`经脉爆发,额外<color=#218026>+${Utils.StringUtils.formatLargeNumber(confcoin)}</color>`);
|
|
}
|
|
}
|
|
TokenDataProxy.Ins.addToken(PropType.eGold, rewcoin);
|
|
}else if(this.m_CoinType == PropType.eTaiJi){
|
|
TokenDataProxy.Ins.addToken(PropType.eTaiJi, this.m_AdGetNum);
|
|
UIMgr.Ins.ShowTipsUI(`${GDUtils.getTokenName(PropType.eTaiJi)} +${this.m_AdGetNum}`);
|
|
}
|
|
if(this.m_AdShopRefNum > 0){
|
|
this.mDataMgr.Shop.addTimes(this.m_AdShopRefNum);
|
|
UIMgr.Ins.ShowTipsUI(`离线奖励: 商店刷新次数+${this.m_AdShopRefNum}`);
|
|
MesMgr.event(EGlobalEvent.OUTLINE_UPDATE, false);
|
|
}
|
|
this.param.callback && this.param.callback();
|
|
this.CloseUI();
|
|
}
|
|
}
|