消消方块阵换皮表情
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.

307 lines
12 KiB

1 week ago
import { _decorator, Component, Enum, Node } from 'cc';
import { GEvent } from 'db://assets/mx/module/event/GEvent';
import { Dot } from './RedDot';
import { OtherDataType, StatisticsType } from 'db://assets/script/game/GameData';
import { sdkConfig } from 'db://assets/script/sdk/sdkConfig';
import { NewFunType } from 'db://assets/script/newFun/NewFun';
import { UIID } from 'db://assets/script/game/ConfigRes';
import { ChapterDifficulty } from 'db://assets/script/manager/ChapterDataManager';
const { ccclass, property } = _decorator;
/** 红点类型(预留) */
export enum DotType {
= 1,
}
/** 红点ID */
export enum RedDotID {
= 0,
//主界面红点
_挂机 = 101,
_任务 = 102,
_签到 = 103,
_关卡 = 104,
_排名 = 105,
_商店 = 106,
_角色 = 107,
_武器 = 108,
_超值赠礼 = 109,
_基金收益 = 110,
_月卡充值 = 111,
_首充礼包 = 113,
_邀请有礼 = 114,
_每日礼包 = 115,
_左章节红点 = 116,
_右章节红点 = 117,
_离线收益 = 118,
//挂机页面红点
_扫荡 = 201,
_领取 = 202,
//商店红点
_免费钻石 = 301,
_稀有宝箱 = 302,
_免费金币 = 303,
}
/**
*
*/
export const DotConfig: Array<Dot> = [//根据游戏修改此处配置
//主界面红点
{ id: RedDotID.主界面_挂机, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_任务, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_签到, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_关卡, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_排名, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_商店, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_角色, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_武器, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_离线收益, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_超值赠礼, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_基金收益, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_月卡充值, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_首充礼包, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_邀请有礼, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_每日礼包, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_左章节红点, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.主界面_右章节红点, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
//挂机页面红点
// 注意:这两个红点用于挂机页内部,不应反向影响主界面按钮红点(避免出现“主界面判断为0但仍亮”的冲突)
{ id: RedDotID.挂机页_扫荡, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
{ id: RedDotID.挂机页_领取, type: DotType., parentId: RedDotID.无, parent: null, status: 0, children: [] },
//商店红点
{ id: RedDotID.商店_免费钻石, type: DotType., parentId: RedDotID.主界面_商店, parent: null, status: 0, children: [] },
{ id: RedDotID.商店_稀有宝箱, type: DotType., parentId: RedDotID.主界面_商店, parent: null, status: 0, children: [] },
{ id: RedDotID.商店_免费金币, type: DotType., parentId: RedDotID.主界面_商店, parent: null, status: 0, children: [] },
]
/** 检查是否需要显示红点 */
export const checkRedDotShow = (id: RedDotID) => {
let status = 0;
if (id == RedDotID.) return status;
if (id == RedDotID._扫荡) {
let normalCount = gg.data.getStatistics(StatisticsType.saodangNormalCount)
status = normalCount < gg.game.getMaxFreeSweepTimes() ? 1 : 0;
}
if (id == RedDotID._任务) {
let newFunData = gg.newFun.getNewFunData(NewFunType.MainPageBtn, 5);
let isUnlocked = newFunData ? newFunData.chapter < gg.data.doc.chapter : false;
return (isUnlocked && gg.data.checkTaskRewardGetData()) ? 1 : 0;
}
if (id == RedDotID._签到) {
let signData = gg.data.getStringData(OtherDataType.SignData)
let curSignStatus = Number(signData.split('&')[1])
return curSignStatus == 0 ? 1 : 0;
}
if (id == RedDotID._武器) {
let isUnLock = gg.newFun.isUnLockMainPageTab(UIID.Weapon)
let isCanUpgradeWeapon = gg.data.getIsCanUpgradeWeapon();
return (isCanUpgradeWeapon && isUnLock) ? 1 : 0;
}
if (id == RedDotID._角色) {
let can = gg.data.getIsCanUpgradeWeaponByMoney();
let isUnlocked = gg.newFun.isUnLockMainPageTab(UIID.Role);
return (can && isUnlocked) ? 1 : 0;
}
if (id == RedDotID._关卡) {
let isCanGetBox = gg.data.project.isCanGetLevelBox();
return isCanGetBox ? 1 : 0;
}
if (id == RedDotID._离线收益) {
let normalCount = gg.data.getStatistics(StatisticsType.saodangNormalCount);
if(normalCount >= gg.game.getMaxFreeSweepTimes()){
//没有扫荡次数 判断是否超过1小时可以领取奖励
let lastAddTime = gg.data.getStatistics(StatisticsType.AfkRewards);
let curTime = gg.data.getCurentTime();
let time = Math.floor((curTime - lastAddTime) / 1000);
return time >= 3600 ? 1 : 0;
}else{
//有扫荡次数
return normalCount < gg.game.getMaxFreeSweepTimes() ? 1 : 0;
}
}
if (id == RedDotID._超值赠礼) {
let greatGiftStatus = gg.data.getStatistics(StatisticsType.GreatGiftStatus)
let greatGiftGetDay = gg.data.getStatistics(StatisticsType.GreatGiftGetDay)
if(greatGiftStatus == 0 && greatGiftGetDay <= 2){
return 1
}
return 0
}
if (id == RedDotID._基金收益) {
}
if (id == RedDotID._月卡充值) {
}
if (id == RedDotID._邀请有礼) {
}
if (id == RedDotID._每日礼包) {
}
if (id == RedDotID._首充礼包) {
}
if (id == RedDotID._左章节红点) {
let have = gg.data.project.isCanGetBoxBeforeOrAfter(gg.game.CurentSelectChapterId, gg.game.CurentSelectBattleDifficulty, true);
return have ? 1 : 0;
}
if (id == RedDotID._右章节红点) {
let have = gg.data.project.isCanGetBoxBeforeOrAfter(gg.game.CurentSelectChapterId, gg.game.CurentSelectBattleDifficulty, false);
return have ? 1 : 0;
}
if (id == RedDotID._免费钻石) {
let isUnLock = gg.newFun.isUnLockMainPageTab(UIID.Shop)
let count = gg.data.getStatistics(StatisticsType.ShopBuyItemAdCount)
status = (count == 6 && isUnLock) ? 1 : 0;
}
if (id == RedDotID._稀有宝箱) {
let isUnLock = gg.newFun.isUnLockMainPageTab(UIID.Shop)
let xiyouBoxSpendNum = sdkConfig.isIAPVersion ? 3000 : 200;
status = (gg.data.getDiamond() >= xiyouBoxSpendNum && isUnLock) ? 1 : 0;
}
if (id == RedDotID._免费金币) {
let isUnLock = gg.newFun.isUnLockMainPageTab(UIID.Shop)
let freeSpendNum = gg.data.getStatistics(StatisticsType.ShopBuyGoldAdCount)
status = (freeSpendNum == 6 && isUnLock) ? 1 : 0;
}
if(id == RedDotID._挂机){
//挂机收益 免费收益3次 累积收益
//农场
let curTime = gg.data.getCurentTime()
let farmSaodangNormalCount = gg.data.getStatistics(StatisticsType.farmSaodangNormalCount)
if(farmSaodangNormalCount < 3){
status = 1
return status;
}else{
status = 0
}
let lastAddTime = gg.data.getStatistics(StatisticsType.framAfkRewards);
let time = Math.floor((curTime - lastAddTime) / 1000) //time大于一个小时
if(time >= 3600){
status = 1
return status;
}else{
status = 0
}
//工厂
let isUnLockHard = gg.newFun.isUnLockDifficult(ChapterDifficulty.Hard);
if(isUnLockHard){
let factorySaodangNormalCount = gg.data.getStatistics(StatisticsType.factorySaodangNormalCount)
if(factorySaodangNormalCount < 3){
status = 1
return status;
}else{
status = 0
}
let lastAddTime = gg.data.getStatistics(StatisticsType.factoryAfkRewards);
let time = Math.floor((curTime - lastAddTime) / 1000) //time大于一个小时
if(time >= 3600){
status = 1
return status;
}else{
status = 0
}
}
//矿场
let isUnLockHell = gg.newFun.isUnLockDifficult(ChapterDifficulty.Hell);
if(isUnLockHell){
let mineSaodangNormalCount = gg.data.getStatistics(StatisticsType.mineSaodangNormalCount)
if(mineSaodangNormalCount < 3){
status = 1
return status;
}else{
status = 0
}
let lastAddTime = gg.data.getStatistics(StatisticsType.mineAfkRewards);
let time = Math.floor((curTime - lastAddTime) / 1000) //time大于一个小时
if(time >= 3600){
status = 1
return status;
}else{
status = 0
}
}
}
return status;
}
/**
* 使
* 1.ID
* 2.DotConfig数组中新增红点配置
* 3.checkRedDotShow函数中新增红点判断逻辑
* 4.first/prefab/dot.prefab UI按钮上
* 5.RedDotComp组件中设置id属性为新增的红点ID
*
*
* 1.
* 2.id配置根据UI实际显示逻辑配置
* 3.type字段目前没有用
* 4.checkRedDotShow函数中只需要实现末端红点是否要显示
*/
@ccclass('RedDotComp')
export class RedDotComp extends Component {
@property({ type: Enum(RedDotID) })
id: RedDotID = RedDotID.;
dotIcon: Node = null;
protected onLoad(): void {
this.dotIcon = this.node.find("icon");
this.dotIcon.active = false;
}
protected onEnable(): void {
GEvent.Ins.on(GEvent.UpdateRedDotEvent, this.onUpdateDot, this);
GEvent.Ins.on(GEvent.UpdateItemNum, this.checkRedDotShow, this);
this.checkRedDotShow();
}
protected onDisable(): void {
GEvent.Ins.off(GEvent.UpdateRedDotEvent, this.onUpdateDot, this);
GEvent.Ins.off(GEvent.UpdateItemNum, this.checkRedDotShow, this);
}
/** 更新红点显示 */
onUpdateDot() {
let dot = gg.dot.getDotData(this.id);
if (!dot || !this.dotIcon) return;
this.dotIcon.active = dot.status > 0;
}
/** 检查红点显示 */
checkRedDotShow() {
let status = checkRedDotShow(this.id);
this.dotIcon.active = status > 0;
}
}