大侠
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.
 
 
 

170 lines
8.7 KiB

//#region 文件引入
import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText } from "cc";
import BaseUIForm from "../../Mgr_UI/BaseUIForm";
import SceneDataMgr from "../../Mgr_LocalData/SceneDataMgr";
import StringUtils from "../../ExUtils/StringUtils";
import { IData } from "../../const/GameInterface";
import { EVideoType, FIGHTING_TYPE, GameTotalType, PropType } from "../../const/GameEnum";
import { MUTATE_PARAMS } from "../../const/GGameData";
import { EUIForms } from "../../const/UIFormCnf";
import UIMgr from "../../Mgr_UI/UIMgr";
import { Global } from "../../Global";
//#endregion 文件引入
const {ccclass, property,menu} = _decorator;
@ccclass("WantedNoticeUI_Proxy")
export default class WantedNoticeUI_Proxy extends BaseUIForm{
//#region 节点自动生成
@property(Node)
n_mutatebg: Node = null;
@property(Node)
n_mutatetitlebg: Node = null;
@property(RichText)
ric_name: RichText = null;
@property(Node)
n_mutatelab: Node = null;
@property(Label)
lab_title: Label = null;
@property(Sprite)
spr_headicon: Sprite = null;
@property(Node)
n_linenode: Node = null;
@property(Node)
n_mutatelinenode: Node = null;
@property(Label)
lab_des: Label = null;
@property(Label)
lab_hp: Label = null;
@property(Label)
lab_reduction_sword: Label = null;
@property(Label)
lab_reduction_stick: Label = null;
@property(Label)
lab_reduction_knife: Label = null;
@property(Button)
btn_reward_coin: Button = null;
@property(Label)
lab_coin: Label = null;
@property(Button)
btn_reward_exp: Button = null;
@property(Label)
lab_exp: Label = null;
@property(Button)
btn_reward_sl: Button = null;
@property(Label)
lab_sl: Label = null;
@property(Button)
btn_Arrest: Button = null;
@property(Button)
btn_fight: Button = null;
@property(Node)
n_ad: Node = null;
@property(RichText)
ric_notice: RichText = null;
//#endregion 节点自动生成
private isMutateBoss:boolean = false;
onButtonClick(button:Button){
/**点击事件触发*/
switch (button) {
case this.btn_Arrest:
this.CloseUI();
SceneDataMgr.Ins.onAttackBoss();
break;
case this.btn_fight:
const lefttimes = this.mDataMgr.Game.FreeChallengeTimes;
if(lefttimes > 0){
this.CloseUI();
SceneDataMgr.Ins.onAttackMutateBoss();
}else{
Global.showvideo({name: EVideoType.ADMutateBoss, gamelv: this.mDataMgr.Scene.getRealLevel()},()=>{
this.CloseUI();
SceneDataMgr.Ins.onAttackMutateBoss();
});
}
break;
case this.btn_reward_coin:
this.showItemInfo(GameTotalType.TOKEN, PropType.eGold);
break;
// case this.btn_reward_exp:
// this.showItemInfo(GameTotalType.EXP);
// break;
case this.btn_reward_sl:
this.showItemInfo(GameTotalType.TOKEN, PropType.eSLStone);
break;
default:
ConsoleEx.Log(button);
break;
}
}
showItemInfo(type: GameTotalType, id: number = 0) {
switch (type) {
case GameTotalType.TOKEN:
UIMgr.Ins.ShowUI(EUIForms.ShopInfoUI, { param: {tdata: {type: type, id: id}} });
break;
case GameTotalType.ITEM:
UIMgr.Ins.ShowUI(EUIForms.ShopInfoUI, { param: {id: id, style: "small"} });
}
}
protected start(): void {
this.isMutateBoss = (this.param && this.param.fighttype == FIGHTING_TYPE.MUTATEBOSS);
const bossConfig = this.isMutateBoss? this.mDataMgr.Mutate.getMutateBoss().config : SceneDataMgr.Ins.level.bossConfig;
let data:IData = {
type: GameTotalType.ENEMYICON,
id: bossConfig.id,
num:0
}
CNodeUtils.SwitchTextureByData(this.spr_headicon, data);
CNodeUtils.switchText(this.lab_des, bossConfig.desc);
CNodeUtils.switchText(this.lab_reduction_sword, bossConfig.defense_1 + "%");
CNodeUtils.switchText(this.lab_reduction_knife, bossConfig.defense_2 + "%");
CNodeUtils.switchText(this.lab_reduction_stick, bossConfig.defense_3 + "%");
if(this.isMutateBoss){
const bossData = this.mDataMgr.Mutate.getMutateBoss();
const displayname = bossData.tgbyboss? `${bossData.displayName}<outline color=white width=2><color=red>(精英)</color></outline>` : bossData.displayName;
CNodeUtils.switchRichText(this.ric_name, displayname);
CNodeUtils.setActive(this.n_mutatebg, true);
CNodeUtils.setActive(this.n_mutatetitlebg, true);
CNodeUtils.setActive(this.n_mutatelab, true);
CNodeUtils.setActive(this.n_mutatelinenode, true);
CNodeUtils.setActive(this.n_linenode, false);
CNodeUtils.setActive(this.btn_reward_sl, true);
CNodeUtils.setActive(this.btn_reward_exp, false);
CNodeUtils.setActive(this.btn_Arrest, false);
CNodeUtils.setActive(this.btn_fight, true);
CNodeUtils.switchText(this.lab_title, "异兽");
CNodeUtils.switchText(this.lab_hp, StringUtils.formatLargeNumber(bossData.totalHP));
CNodeUtils.switchText(this.lab_coin, StringUtils.formatLargeNumber(bossData.realCoin));
// CNodeUtils.switchText(this.lab_coin, StringUtils.GetFloat2ByString(Math.floor(bossData.coin),true,""));
CNodeUtils.switchText(this.lab_sl, StringUtils.GetFloat2ByString(bossData.realReward,true,""));
// const adtimes = this.mDataMgr.Game.TodayAdTimes % 5;
// const addtimes = Math.min(MUTATE_PARAMS.ADDREWARDMAXMUL, Math.floor(this.mDataMgr.Game.TodayAdTimes / 5));
// let rictext = "";
// if(addtimes == MUTATE_PARAMS.ADDREWARDMAXMUL){
// rictext = `每5次<color=#F05F3B>(5/5)</c>广告可以增加奖励加成\n当前已加成<color=#F05F3B>(${addtimes}/5)</c>次\n最高可以增加5次`;
// }else{
// rictext = `每5次<color=#6dff51>(${adtimes}/5)</c>广告可以增加奖励加成\n当前已加成<color=#6dff51>(${addtimes}/5)</c>次\n最高可以增加5次`;
// }
const lefttimes = this.mDataMgr.Game.FreeChallengeTimes;
CNodeUtils.setActive(this.n_ad, lefttimes <= 0);
const rictext = lefttimes > 0 ? `<color=#6dff51>${lefttimes}/${MUTATE_PARAMS.MAXFREETIMES}</color>`: `<color=red>(0/${MUTATE_PARAMS.MAXFREETIMES})</color>`;
CNodeUtils.switchRichText(this.ric_notice, "今日免费次数" + rictext);
}else{
CNodeUtils.switchRichText(this.ric_name, bossConfig.name);
CNodeUtils.setActive(this.n_mutatebg, false);
CNodeUtils.setActive(this.n_mutatetitlebg, false);
CNodeUtils.setActive(this.n_mutatelab, false);
CNodeUtils.setActive(this.btn_reward_sl, false);
CNodeUtils.setActive(this.n_mutatelinenode, false);
CNodeUtils.setActive(this.n_linenode, true);
CNodeUtils.setActive(this.btn_reward_exp, true);
CNodeUtils.setActive(this.btn_Arrest, true);
CNodeUtils.setActive(this.btn_fight, false);
CNodeUtils.switchText(this.lab_title, "悬赏令");
CNodeUtils.switchText(this.lab_hp, StringUtils.formatLargeNumber(bossConfig.hp));
CNodeUtils.switchText(this.lab_coin, StringUtils.formatLargeNumber(bossConfig.bounty));
// CNodeUtils.switchText(this.lab_coin, StringUtils.GetFloat2ByString(Math.floor(bossConfig.bounty),true,""));
CNodeUtils.switchText(this.lab_exp, StringUtils.GetFloat2ByString(Math.floor(bossConfig.reward),true,""));
}
}
}