81 lines
2.1 KiB
C#
81 lines
2.1 KiB
C#
using System.Collections;
|
|
|
|
using UnityEngine;
|
|
using WZ;
|
|
|
|
public class AdjustNetwork : NormalSingleton<AdjustNetwork>
|
|
{
|
|
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();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 3分钟设置自然量
|
|
/// </summary>
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否是自然量用户
|
|
/// 默认买量用户
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
} |