using System.Collections; using Script.Utils; using UnityEngine; public class AdjustNetwork : NormalSingleton { private const string KEY_USER_NETWORK = "KEY_USER_NETWORK"; public void SetNetwork(string network) { if (string.IsNullOrEmpty(network)) { return; } if (network.ToLower().Replace(" ", "") == "Organic".ToLower().Replace(" ", "")) { return; } string curNetwork = PlayerPrefs.GetString(KEY_USER_NETWORK, ""); if (string.IsNullOrEmpty(curNetwork)) { PlayerPrefs.SetString(KEY_USER_NETWORK, network); PlayerPrefs.Save(); } } /// /// 3分钟设置自然量 /// public IEnumerator SetOrganic3Min() { string curNetwork = PlayerPrefs.GetString(KEY_USER_NETWORK, ""); if (!string.IsNullOrEmpty(curNetwork)) { yield break; } //写死3分钟 yield return new WaitForSeconds(3 * 60); //重新获取 curNetwork = PlayerPrefs.GetString(KEY_USER_NETWORK, ""); if (!string.IsNullOrEmpty(curNetwork)) { yield break; } PlayerPrefs.SetString(KEY_USER_NETWORK, "Organic"); PlayerPrefs.Save(); } /// /// 是否是自然量用户 /// 默认买量用户 /// /// public bool InOrganic() { string network = PlayerPrefs.GetString(KEY_USER_NETWORK, ""); if (string.IsNullOrEmpty(network)) { return true; } if (network.ToLower().Replace(" ", "") == "Organic".ToLower().Replace(" ", "")) { return true; } //去除大小写和空格之后再对比 if (network.ToLower().Replace(" ", "") == "Untrusted Devices".ToLower().Replace(" ", "") || network.ToLower().Replace(" ", "") == "Google Organic Search".ToLower().Replace(" ", "")) { return true; } return false; } }