123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using System;
- using UnityEngine;
- namespace GFGGame
- {
- public class AntiAddictionController
- {
- public static bool CheckAntiAddiction(int onlineTimeSecs, int onlineDurationSecs, int onlineDurationSecsDay) {
- if(!GameGlobal.antiAddiction) {
- return false;
- }
- Debug.LogFormat("init onlineTimeSecs {0} onlineDurationSecs {1} onlineDurationSecsDay{2}", onlineTimeSecs, onlineDurationSecs, onlineDurationSecsDay);
- if(GameGlobal.isVisitor) {
- int remainSecs = 60*60 - onlineDurationSecs;
- if(remainSecs < 0){
- string promptStr = "您当前为游客模式,已被纳入防沉迷系统,在此模式下不能充值和付费消费,共有60分钟体验时间,已全部体验完,需要使用有效的证件进行实名认证才能完整体验游戏内容。";
- Alert.Show(promptStr)
- .SetRightButton(true, "前往注册", (object data) => {
- GameController.QuitToLoginView(false);
- ViewManager.Show<RegisterView>();
- });
- return true;
- } else {
- int remainMins = (int)Math.Ceiling(remainSecs/60f);
- string promptStr = "您当前为游客模式,已被纳入防沉迷系统,在此模式下不能充值和付费消费,共有60分钟体验时间,还剩余{0}分钟";
- promptStr = string.Format(promptStr, remainMins);
- Alert.Show(promptStr)
- .SetRightButton(true);
- }
-
- }
- else {
- int age = GameGlobal.userAge;
- if(age < 18) {
- int remainSecs = 90*60 - onlineDurationSecsDay;
- if(remainSecs < 0){
- string promptStr = "您属于未成年人,已被纳入防沉迷系统。未成年账号每日累计游戏不得超过90分钟,目前已超出健康游戏体验时间,将强制游戏下线。";
- Alert.Show(promptStr)
- .SetRightButton(true, "知道啦", (object data) => {
- GameController.QuitToLoginView(false);
- });
- return true;
- } else {
- string ageRangeStr = null;
- int maxRechargeSingle = 0;
- int maxRechargeTotal = 0;
- GetAntiValue(out ageRangeStr, out maxRechargeSingle, out maxRechargeTotal);
- int remainMins = (int)Math.Ceiling(remainSecs/60f);
- string promptStr = "您属于{0}未成年人,已被纳入防沉迷系统。每日22:00-次日8:00不得进行游戏;每日在线时间上限为90分钟,目前游戏剩余{1}分钟。";
- promptStr = String.Format(promptStr, ageRangeStr, remainMins);
- if(age < 8) {
- promptStr += "本游戏不为未满8周岁的用户提供游戏充值服务。";
- } else {
- promptStr += "单次充值金额不得超过{0}元人民币,每月充值金额不得超过{1}元人民币。";
- promptStr = String.Format(promptStr, maxRechargeSingle, maxRechargeTotal);
- }
- Alert.Show(promptStr)
- .SetRightButton(true, "知道啦");
- }
- }
- }
- return false;
- }
- public static bool CheckOnlineTime(int onlineTimeSecs, int onlineDurationSecs, int onlineDurationSecsDay) {
- if(!GameGlobal.antiAddiction)
- {
- return false;
- }
- Debug.LogFormat("update onlineTimeSecs {0} onlineDurationSecs {1} onlineDurationSecsDay{2}", onlineTimeSecs, onlineDurationSecs, onlineDurationSecsDay);
- if(GameGlobal.isVisitor) {
- int remainSecs = 60*60 - onlineDurationSecs;
- if(remainSecs < 0) {
- string promptStr = "您当前为游客模式,已被纳入防沉迷系统,在此模式下不能充值和付费消费,共有60分钟体验时间,已全部体验完,需要使用有效的证件进行实名认证才能完整体验游戏内容。";
- Alert.Show(promptStr)
- .SetRightButton(true, "前往注册", (object data) => {
- GameController.QuitToLoginView(false);
- ViewManager.Show<RegisterView>();
- });
- return true;
- }
- }
- else {
- int age = GameGlobal.userAge;
- if(age < 18) {
- int remainSecs = 90*60 - onlineDurationSecsDay;
- if(remainSecs < 0) {
- string promptStr = "您属于未成年人,已被纳入防沉迷系统。未成年账号每日累计游戏不得超过90分钟,目前已超出健康游戏体验时间,将强制游戏下线。";
- Alert.Show(promptStr)
- .SetRightButton(true, "知道啦", (object data) => {
- GameController.QuitToLoginView(false);
- });
- return true;
- }
- }
- }
- return false;
- }
- public static bool CheckAntiAddictionRecharge(int value) {
- if(!GameGlobal.antiAddiction)
- {
- return false;
- }
- string promptStr = "";
- if(GameGlobal.isVisitor) {
- promptStr += "您当前为游客模式,已被纳入防沉迷系统,在此模式下不能充值和付费消费。";
- Alert.Show(promptStr)
- .SetRightButton(true, "知道啦");
- return true;
- }
- string ageRangeStr = null;
- int maxRechargeSingle = 0;
- int maxRechargeTotal = 0;
- GetAntiValue(out ageRangeStr, out maxRechargeSingle, out maxRechargeTotal);
- promptStr = "您属于{0}未成年人,已被纳入防沉迷系统。";
- promptStr = String.Format(promptStr, ageRangeStr);
- int age = GameGlobal.userAge;
- if(age < 8) {
- promptStr += "本游戏不为未满8周岁的用户提供游戏充值服务。";
- Alert.Show(promptStr)
- .SetRightButton(true, "知道啦");
- return true;
- } else if(age < 18) {
- int preTotalMon = RoleDataManager.rechargeTotalMon + value;
- if(value > maxRechargeSingle || preTotalMon > maxRechargeTotal) {
- promptStr += "单次充值金额不得超过{0}元人民币,每月充值金额不得超过{1}元人民币。";
- promptStr = String.Format(promptStr, maxRechargeSingle, maxRechargeTotal);
- Alert.Show(promptStr)
- .SetRightButton(true, "知道啦");
- return true;
- }
- }
- return false;
- }
- private static void GetAntiValue(out string ageRangeStr, out int maxRechargeSingle, out int maxRechargeTotal) {
- int age = GameGlobal.userAge;
- if(age < 8){
- ageRangeStr = "未满8周岁";
- maxRechargeSingle = 0;
- maxRechargeTotal = 0;
- } else if(age < 16){
- ageRangeStr = "8周岁以上未满16周岁";
- maxRechargeSingle = 50;
- maxRechargeTotal = 200;
- } else {
- ageRangeStr = "16周岁以上未满18周岁";
- maxRechargeSingle = 100;
- maxRechargeTotal = 400;
- }
- }
- }
- }
|