提交项目
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using System.Text;
|
||||
using FutureCore;
|
||||
using ZooMatch;
|
||||
|
||||
public class Base64Kit
|
||||
{
|
||||
public static string Encode(string data)
|
||||
{
|
||||
var key = NetworkManager.DomainRelease;
|
||||
var keyMD5 = MD5Kit.MD5String1(key);
|
||||
var str = Base64EncodeUtil.Base64Encode(data + keyMD5);
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(str);
|
||||
for (int i = 0, j = bytes.Length - 1; i < j; i += 1, j -= 1)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
(bytes[i], bytes[j]) = (bytes[j], bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var loginData = Encoding.UTF8.GetString(bytes);
|
||||
return loginData;
|
||||
}
|
||||
|
||||
public static string Encode(string data, bool is_google_pay = false)
|
||||
{
|
||||
var key = NetworkManager.DomainRelease;
|
||||
if (is_google_pay) key = NetworkManager.identifier;
|
||||
|
||||
var keyMD5 = MD5Kit.MD5String1(key);
|
||||
var str = Base64EncodeUtil.Base64Encode(data + keyMD5);
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(str);
|
||||
for (int i = 0, j = bytes.Length - 1; i < j; i += 1, j -= 1)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
(bytes[i], bytes[j]) = (bytes[j], bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var loginData = Encoding.UTF8.GetString(bytes);
|
||||
return loginData;
|
||||
}
|
||||
|
||||
public static string Decode(string data)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(data);
|
||||
for (int i = 0, j = bytes.Length - 1; i < j; i += 1, j -= 1)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
(bytes[i], bytes[j]) = (bytes[j], bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var str = Encoding.UTF8.GetString(bytes);
|
||||
var str1 = Base64EncodeUtil.Base64Decode(str);
|
||||
var key = NetworkManager.DomainRelease;
|
||||
var keyMD5 = MD5Kit.MD5String1(key);
|
||||
var result = str1.Replace(keyMD5, string.Empty);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string Decode(string data, string key)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(data);
|
||||
for (int i = 0, j = bytes.Length - 1; i < j; i += 1, j -= 1)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
(bytes[i], bytes[j]) = (bytes[j], bytes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var str = Encoding.UTF8.GetString(bytes);
|
||||
var str1 = Base64EncodeUtil.Base64Decode(str);
|
||||
// var key = NetworkManager.DomainRelease;
|
||||
var keyMD5 = MD5Kit.MD5String1(key);
|
||||
var result = str1.Replace(keyMD5, string.Empty);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ddfec3608bd54db781f2ad54f0c14a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class CameraAdaptive : MonoBehaviour
|
||||
{
|
||||
private bool isOrthographic;
|
||||
private float orthographicSize;
|
||||
|
||||
private Camera cameraCom;
|
||||
|
||||
public void DoAdaptive(bool isOrthographic, float orthographicSize)
|
||||
{
|
||||
this.isOrthographic = isOrthographic;
|
||||
this.orthographicSize = orthographicSize;
|
||||
this.cameraCom = GetComponent<Camera>();
|
||||
|
||||
Adaptive();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private float currScreenHeight;
|
||||
private float currScreenWidth;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (currScreenHeight != Screen.height || currScreenWidth != Screen.width)
|
||||
{
|
||||
currScreenHeight = Screen.height;
|
||||
currScreenWidth = Screen.width;
|
||||
ScreenConst.CurrAspectRatio = (float)Screen.height / Screen.width;
|
||||
Adaptive();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private void Adaptive()
|
||||
{
|
||||
if (cameraCom == null) return;
|
||||
|
||||
cameraCom.orthographic = isOrthographic;
|
||||
if (isOrthographic)
|
||||
{
|
||||
if (ScreenConst.CurrAspectRatio > ScreenConst.StandardAspectRatio)
|
||||
{
|
||||
float computeHeight = Screen.width * ScreenConst.StandardAspectRatio;
|
||||
float heightRatio = Screen.height / computeHeight;
|
||||
cameraCom.orthographicSize = orthographicSize * heightRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraCom.orthographicSize = orthographicSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float fov = Get3DFOV();
|
||||
cameraCom.fieldOfView = fov;
|
||||
}
|
||||
}
|
||||
|
||||
private float Get3DFOV()
|
||||
{
|
||||
float defaultFOV = 60;
|
||||
float standardWidth = ScreenConst.StandardWidth;
|
||||
float standardHeight = ScreenConst.StandardHeight;
|
||||
float currWidth = Screen.width;
|
||||
float currHeight = Screen.height;
|
||||
float nowHeight;
|
||||
|
||||
if (ScreenConst.CurrAspectRatio > ScreenConst.StandardAspectRatio)
|
||||
{
|
||||
nowHeight = Mathf.RoundToInt(standardWidth / currWidth * currHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
nowHeight = standardHeight;
|
||||
}
|
||||
|
||||
float heightScale = nowHeight / standardHeight;
|
||||
float fov = defaultFOV * heightScale;
|
||||
return fov;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c34ee27814511ae4e9278c1978c55d11
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class EngineEventSystem : MonoBehaviour
|
||||
{
|
||||
public static EngineEventSystem Instance { get; private set; }
|
||||
|
||||
[HideInInspector] public GameObject eventObj;
|
||||
[HideInInspector] public EventSystem eventSystem;
|
||||
[HideInInspector] public StandaloneInputModule inputModule;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
LoadKit.Instance.LoadGameObjectAndClone("Prefab", "EngineEventSystem", eventObj1 =>
|
||||
{
|
||||
eventObj = eventObj1;
|
||||
eventObj.transform.SetParent(transform, false);
|
||||
eventSystem = eventObj.GetComponent<EventSystem>();
|
||||
inputModule = eventObj.GetComponent<StandaloneInputModule>();
|
||||
AppObjConst.EngineEventSystemGo = Instance.eventObj.transform.parent.gameObject;
|
||||
AppObjConst.EngineEventSystemGo.name = AppObjConst.EngineEventSystemGoName;
|
||||
UIManager.Instance.SetEventSystemGo(eventObj);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 441822cef8fef8d439736a08304713e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public static class EventKit
|
||||
{
|
||||
public static void Set2DRaycasterEnabled(Physics2DRaycaster com, bool enabled)
|
||||
{
|
||||
if (com.enabled != enabled)
|
||||
{
|
||||
com.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Set3DRaycasterEnabled(PhysicsRaycaster com, bool enabled)
|
||||
{
|
||||
if (com.enabled != enabled)
|
||||
{
|
||||
com.enabled = enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f8abc2dbceeabe47a4ad3b9e9748f89
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using UObject = UnityEngine.Object;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public static class GeneralKit
|
||||
{
|
||||
#region Engine
|
||||
|
||||
public static T Instantiate<T>(T original) where T : UObject
|
||||
{
|
||||
T obj = UObject.Instantiate(original);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static void Destroy(UObject obj)
|
||||
{
|
||||
if (obj)
|
||||
{
|
||||
UObject.Destroy(obj);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18cfc4767ce56ed429bc8ac74bbd0a72
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93c4fa506ccad6b4db60f2d5b9e55ffd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public static class SerializeUtil
|
||||
{
|
||||
static SerializeUtil()
|
||||
{
|
||||
JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => { return DefaultUseJsonSettings; });
|
||||
}
|
||||
|
||||
private static JsonSerializerSettings DefaultUseJsonSettings = new JsonSerializerSettings
|
||||
{
|
||||
Formatting = Formatting.None,
|
||||
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat,
|
||||
DateFormatString = "yyyy/MM/dd hh:mm:ss",
|
||||
};
|
||||
|
||||
private static JsonSerializerSettings JsonIndentedSettings = new JsonSerializerSettings
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat,
|
||||
DateFormatString = "yyyy/MM/dd hh:mm:ss",
|
||||
};
|
||||
|
||||
public static string ToJson(object obj)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj, DefaultUseJsonSettings);
|
||||
}
|
||||
|
||||
public static string ToJsonIndented(object obj)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj, JsonIndentedSettings);
|
||||
}
|
||||
|
||||
public static string ToJson(object obj, Type type)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj, type, DefaultUseJsonSettings);
|
||||
}
|
||||
|
||||
public static string ToJson<T>(object obj)
|
||||
{
|
||||
return ToJson(obj, typeof(T));
|
||||
}
|
||||
|
||||
public static T ToObject<T>(string json)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(json);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 094e748a04f77844d960e9e2d87e6559
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class TaskSequence
|
||||
{
|
||||
public Action onFinish;
|
||||
private List<TaskProcedure> taskList;
|
||||
private bool isCancel = false;
|
||||
|
||||
public int Count => taskList.Count;
|
||||
|
||||
public TaskSequence Add(Action<TaskProcedure> taskFunc)
|
||||
{
|
||||
TaskProcedure task = new TaskProcedure();
|
||||
task.taskSequence = this;
|
||||
task.onTaskFunc = taskFunc;
|
||||
taskList.Add(task);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskSequence Add(bool result, Action<TaskProcedure> trueTaskFunc)
|
||||
{
|
||||
if (!result) return this;
|
||||
return Add(trueTaskFunc);
|
||||
}
|
||||
|
||||
public TaskSequence Run()
|
||||
{
|
||||
if (isCancel)
|
||||
return null;
|
||||
for (int i = 0; i < taskList.Count - 1; i++)
|
||||
{
|
||||
int index = i;
|
||||
int nextIndex = index + 1;
|
||||
taskList[index].onComplete = () => taskList[nextIndex].onTaskFunc(taskList[nextIndex]);
|
||||
}
|
||||
|
||||
if (taskList.Count > 0)
|
||||
{
|
||||
taskList[taskList.Count - 1].onComplete = onFinish;
|
||||
taskList[0].onTaskFunc(taskList[0]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public TaskSequence Clear()
|
||||
{
|
||||
onFinish = null;
|
||||
if (taskList != null)
|
||||
{
|
||||
foreach (TaskProcedure task in taskList)
|
||||
{
|
||||
task?.Dispose();
|
||||
}
|
||||
|
||||
taskList.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
taskList = new List<TaskProcedure>();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class TaskProcedure
|
||||
{
|
||||
public TaskSequence taskSequence;
|
||||
public Action<TaskProcedure> onTaskFunc;
|
||||
public Action onComplete;
|
||||
|
||||
public void InvokeComplete()
|
||||
{
|
||||
if (onComplete != null)
|
||||
{
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
taskSequence = null;
|
||||
onTaskFunc = null;
|
||||
onComplete = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa7436b18ddf94d44b141a67425a0759
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f071f4f98482cb4ea09fbf4ed3bbfe4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class EasyTimer : MonoBehaviour
|
||||
{
|
||||
private Dictionary<Action, float> mIntervalDic = new();
|
||||
private List<Action> triggers = new();
|
||||
|
||||
[SerializeField] private string timerName;
|
||||
private TimerTimeType type = TimerTimeType.Null;
|
||||
|
||||
public void SetTimer(string name, TimerTimeType type)
|
||||
{
|
||||
this.timerName = name + "_" + type;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private float GetTime()
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
TimerTimeType.Time => Time.time,
|
||||
TimerTimeType.UnscaledTime => Time.unscaledTime,
|
||||
TimerTimeType.RealtimeSinceStartup => Time.realtimeSinceStartup,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (mIntervalDic.Count > 0)
|
||||
{
|
||||
triggers.Clear();
|
||||
foreach (var keyValue in mIntervalDic.Where(keyValue => keyValue.Value <= GetTime()))
|
||||
{
|
||||
triggers.Add(keyValue.Key);
|
||||
}
|
||||
|
||||
foreach (var func in triggers)
|
||||
{
|
||||
mIntervalDic.Remove(func);
|
||||
func();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTimer(float interval, Action func)
|
||||
{
|
||||
if (null != func)
|
||||
{
|
||||
if (interval <= 0)
|
||||
{
|
||||
func();
|
||||
return;
|
||||
}
|
||||
|
||||
mIntervalDic[func] = GetTime() + interval;
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
mIntervalDic.Clear();
|
||||
triggers.Clear();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearAll();
|
||||
mIntervalDic = null;
|
||||
triggers = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cccc8c2ef81a9c04c99cc97fdf07a8a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class NormalTimer : MonoBehaviour
|
||||
{
|
||||
private class TimerTask
|
||||
{
|
||||
private NormalTimer mNormalTimer;
|
||||
|
||||
private string name;
|
||||
private TimerMode mode;
|
||||
private float startTime;
|
||||
private float duration;
|
||||
|
||||
private bool isBreak = false;
|
||||
private float breakStart;
|
||||
private float breakDuration = 0;
|
||||
|
||||
private Action timerEvent;
|
||||
private Action<object[]> timerArgsEvent;
|
||||
private object[] args = null;
|
||||
|
||||
public float TimeLeft => Mathf.Max(0f, duration - (mNormalTimer.GetTime() - startTime) + breakDuration);
|
||||
|
||||
public void Run()
|
||||
{
|
||||
if (isBreak)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (TimeLeft > 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == TimerMode.Normal)
|
||||
{
|
||||
mNormalTimer.RemoveTimer(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = mNormalTimer.GetTime();
|
||||
breakDuration = 0;
|
||||
}
|
||||
|
||||
timerEvent?.Invoke();
|
||||
timerArgsEvent?.Invoke(args);
|
||||
}
|
||||
|
||||
public static implicit operator bool(TimerTask timerTask)
|
||||
{
|
||||
return null != timerTask;
|
||||
}
|
||||
}
|
||||
|
||||
private enum TimerMode
|
||||
{
|
||||
Normal,
|
||||
Repeat,
|
||||
}
|
||||
|
||||
private Dictionary<string, TimerTask> addTimerList = new();
|
||||
private Dictionary<string, TimerTask> timerList = new();
|
||||
private List<string> destroyTimerList = new();
|
||||
|
||||
[SerializeField] private string timerName;
|
||||
private TimerTimeType type = TimerTimeType.Null;
|
||||
|
||||
public void SetTimer(string name, TimerTimeType type)
|
||||
{
|
||||
timerName = name + "_" + type;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private float GetTime()
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
TimerTimeType.Time => Time.time,
|
||||
TimerTimeType.UnscaledTime => Time.unscaledTime,
|
||||
TimerTimeType.RealtimeSinceStartup => Time.realtimeSinceStartup,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (destroyTimerList.Count > 0)
|
||||
{
|
||||
foreach (var i in destroyTimerList)
|
||||
{
|
||||
timerList.Remove(i);
|
||||
}
|
||||
|
||||
destroyTimerList.Clear();
|
||||
}
|
||||
|
||||
if (addTimerList.Count > 0)
|
||||
{
|
||||
foreach (var i in addTimerList.Where(i => i.Value != null))
|
||||
{
|
||||
timerList[i.Key] = i.Value;
|
||||
}
|
||||
|
||||
addTimerList.Clear();
|
||||
}
|
||||
|
||||
if (timerList.Count > 0)
|
||||
{
|
||||
foreach (var timer in timerList.Values)
|
||||
{
|
||||
if (timer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
timer.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool RemoveTimer(string key)
|
||||
{
|
||||
if (!timerList.ContainsKey(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!destroyTimerList.Contains(key))
|
||||
{
|
||||
destroyTimerList.Add(key);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
addTimerList.Clear();
|
||||
timerList.Clear();
|
||||
destroyTimerList.Clear();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearAll();
|
||||
addTimerList = null;
|
||||
timerList = null;
|
||||
destroyTimerList = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fefb9ed2ef0fffd409b6ea3e113cb153
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class TimerTask
|
||||
{
|
||||
private Timer timer;
|
||||
|
||||
public int repeatCount;
|
||||
public float interval;
|
||||
private Action<TimerTask> onCallBack;
|
||||
public object[] args;
|
||||
public float time;
|
||||
public bool isActive = true;
|
||||
public bool isFrameUpdate = false;
|
||||
|
||||
public TimerTask(Timer timer, float interval, Action<TimerTask> onCallBack, params object[] args)
|
||||
{
|
||||
this.timer = timer;
|
||||
|
||||
repeatCount = 1;
|
||||
this.interval = interval;
|
||||
this.onCallBack = onCallBack;
|
||||
this.args = args;
|
||||
time = timer.GetTriggerTime(interval);
|
||||
}
|
||||
|
||||
public TimerTask(Timer timer, int repeatCount, float interval, Action<TimerTask> onCallBack,
|
||||
params object[] args)
|
||||
{
|
||||
this.timer = timer;
|
||||
|
||||
this.repeatCount = repeatCount;
|
||||
this.interval = interval;
|
||||
this.onCallBack = onCallBack;
|
||||
this.args = args;
|
||||
time = timer.GetTriggerTime(interval);
|
||||
}
|
||||
|
||||
public TimerTask(Timer timer, Action<TimerTask> onCallBack, params object[] args)
|
||||
{
|
||||
this.timer = timer;
|
||||
|
||||
this.onCallBack = onCallBack;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public void CallFunc()
|
||||
{
|
||||
onCallBack?.Invoke(this);
|
||||
}
|
||||
|
||||
public static implicit operator bool(TimerTask timerTask)
|
||||
{
|
||||
return null != timerTask;
|
||||
}
|
||||
}
|
||||
|
||||
public class Timer : MonoBehaviour
|
||||
{
|
||||
public const int INFINITE_LOOP = -1;
|
||||
|
||||
private List<TimerTask> timerTaskList = new();
|
||||
private List<TimerTask> timerTaskTriggers = new();
|
||||
|
||||
[SerializeField] private string timerName;
|
||||
private TimerTimeType type = TimerTimeType.Null;
|
||||
|
||||
public void SetTimer(string name, TimerTimeType type)
|
||||
{
|
||||
this.timerName = name + "_" + type;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private float GetTime()
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
TimerTimeType.Time => Time.time,
|
||||
TimerTimeType.UnscaledTime => Time.unscaledTime,
|
||||
TimerTimeType.RealtimeSinceStartup => Time.realtimeSinceStartup,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (timerTaskList.Count > 0)
|
||||
{
|
||||
timerTaskTriggers.Clear();
|
||||
foreach (var timerTask in timerTaskList.Where(timerTask => timerTask.isActive))
|
||||
{
|
||||
if (timerTask.isFrameUpdate)
|
||||
{
|
||||
timerTaskTriggers.Add(timerTask);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (timerTask.time <= GetTime())
|
||||
{
|
||||
timerTaskTriggers.Add(timerTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var triggerTimerTask in timerTaskTriggers)
|
||||
{
|
||||
if (triggerTimerTask.repeatCount != INFINITE_LOOP)
|
||||
{
|
||||
triggerTimerTask.repeatCount--;
|
||||
}
|
||||
|
||||
if (triggerTimerTask.repeatCount == 0)
|
||||
{
|
||||
timerTaskList.Remove(triggerTimerTask);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!triggerTimerTask.isFrameUpdate)
|
||||
{
|
||||
triggerTimerTask.time = GetTriggerTime(triggerTimerTask.interval);
|
||||
}
|
||||
}
|
||||
|
||||
triggerTimerTask.CallFunc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TimerTask AddLoopTimer(float interval, Action<TimerTask> onCallBack, params object[] args)
|
||||
{
|
||||
var timeTask = new TimerTask(this, INFINITE_LOOP, interval, onCallBack, args);
|
||||
AddTimer(timeTask);
|
||||
return timeTask;
|
||||
}
|
||||
|
||||
public void AddTimer(TimerTask timerTask)
|
||||
{
|
||||
if (null != timerTask)
|
||||
{
|
||||
if (!timerTask.isFrameUpdate)
|
||||
{
|
||||
if (timerTask.interval <= 0)
|
||||
{
|
||||
timerTask.CallFunc();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
timerTaskList.Add(timerTask);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
timerTaskList.Clear();
|
||||
timerTaskTriggers.Clear();
|
||||
}
|
||||
|
||||
public float GetTriggerTime(float interval)
|
||||
{
|
||||
return GetTime() + interval;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearAll();
|
||||
timerTaskList = null;
|
||||
timerTaskTriggers = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1af09b65e6897dd4e8adcb89203638d1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
namespace ZooMatch
|
||||
{
|
||||
public static class TimerHelper
|
||||
{
|
||||
private static string name = "TimerHelper";
|
||||
|
||||
#region Time
|
||||
|
||||
private static EasyTimer sEasyTimer;
|
||||
private static Timer _Timer;
|
||||
private static NormalTimer sNormalTimer;
|
||||
|
||||
public static EasyTimer mEasy
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sEasyTimer == null)
|
||||
{
|
||||
sEasyTimer = TimerIManager.Instance.CreateSimpleTimer(name, TimerTimeType.Time);
|
||||
}
|
||||
|
||||
return sEasyTimer;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UnscaledTime
|
||||
|
||||
private static EasyTimer sUnscaledEasyTimer;
|
||||
private static Timer _UnscaledTimer;
|
||||
private static NormalTimer sUnscaledNormalTimer;
|
||||
|
||||
public static Timer UnscaleGeneral
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_UnscaledTimer == null)
|
||||
{
|
||||
_UnscaledTimer = TimerIManager.Instance.CreateTimer(name, TimerTimeType.UnscaledTime);
|
||||
}
|
||||
|
||||
return _UnscaledTimer;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RealtimeSinceStartup
|
||||
|
||||
private static EasyTimer sRealEasyTimer;
|
||||
private static Timer _RealTimer;
|
||||
private static NormalTimer sRealNormalTimer;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 889a363446c9d38489732b45d60696c6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,102 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class UnitConvertUtil
|
||||
{
|
||||
public static string[] UnitSuffixs =
|
||||
{
|
||||
"", "K", "M", "B", "T", "aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj ", "ak", "al", "am", "an",
|
||||
"ao", "ap", "aq", "ar", "as", "at", "au", "av", "aw", "ax", "ay", "az", "ba", "bb", "bc", "bd", "be", "bf",
|
||||
"bg", "bh", "bi", "bj", "bk", "bl", "bm", "bn", "bo", "bp", "bq", "br", "bs", "bt", "bu", "bv", "bw", "bx",
|
||||
"by", "bz", "ca", "cb", "cc", "cd", "ce", "cf", "cg", "ch", "ci", "cj", "ck", "cl", "cm", "cn", "co", "cp",
|
||||
"cq", "cr", "cs", "ct", "cu", "cv", "cw", "cx", "cy", "da", "db", "dc", "dd", "de", "df", "dg", "dh", "di",
|
||||
"dj", "dk", "dl", "dm", "dn", "do", "dp", "dq", "dr", "ds", "dt", "du", "dv", "dw", "dx", "dy"
|
||||
};
|
||||
|
||||
|
||||
public static string ConvertIntUnitStr(double value)
|
||||
{
|
||||
int count = GetDigitNumber(value);
|
||||
int unitNum = 0;
|
||||
while (count > 3)
|
||||
{
|
||||
count -= 3;
|
||||
value /= 1000;
|
||||
unitNum++;
|
||||
}
|
||||
|
||||
return (int)value + UnitSuffixs[unitNum];
|
||||
}
|
||||
|
||||
public static int GetDigitNumber(double value)
|
||||
{
|
||||
int count = 0;
|
||||
while (value > 1)
|
||||
{
|
||||
count++;
|
||||
value = value / 10;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
public static string ConvertUnit(int value)
|
||||
{
|
||||
int unit = GetDigitNumber(value);
|
||||
if (unit > 0)
|
||||
{
|
||||
unit--;
|
||||
}
|
||||
|
||||
int unitIdx = 0;
|
||||
if (unit >= 6)
|
||||
{
|
||||
unitIdx = (int)Mathf.Ceil(unit / 3) - 1;
|
||||
}
|
||||
|
||||
unitIdx = Mathf.Min(unitIdx, UnitSuffixs.Length - 1);
|
||||
|
||||
float baseNum = Mathf.Pow(10, unitIdx * 3);
|
||||
string numToShow = Mathf.Ceil(value / baseNum).ToString();
|
||||
string numToShowString = string.Empty;
|
||||
int j = 0;
|
||||
for (int i = numToShow.Length - 1; i >= 0; i--)
|
||||
{
|
||||
j++;
|
||||
numToShowString = numToShow[i] + numToShowString;
|
||||
if (i != 0 && j % 3 == 0)
|
||||
{
|
||||
numToShowString = "," + numToShowString;
|
||||
}
|
||||
}
|
||||
|
||||
return numToShowString + UnitSuffixs[unitIdx];
|
||||
}
|
||||
|
||||
public static string ConvertNoDecimalUnit(double value, string symbol = ".")
|
||||
{
|
||||
int count = GetDigitNumber(value);
|
||||
int unitNum = 0;
|
||||
while (count > 7)
|
||||
{
|
||||
count -= 3;
|
||||
value /= 1000;
|
||||
unitNum++;
|
||||
}
|
||||
|
||||
string valueStr = value.ToString("f0");
|
||||
string unitStr = UnitSuffixs[unitNum];
|
||||
for (int i = 0; i < (valueStr.Length - 1) / 3; i++)
|
||||
{
|
||||
int index = valueStr.Length % 3 + i * ((valueStr.Length - 1) / 3) + i;
|
||||
valueStr = valueStr.Insert(index, symbol);
|
||||
}
|
||||
|
||||
if (valueStr.StartsWith(symbol))
|
||||
valueStr = valueStr.Remove(0, 1);
|
||||
return valueStr + unitStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d812f124e53f2548bc7aba6bf278bc7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54a881205c54bff4d850da7972e5cb09
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using DG.Tweening;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public static class DOTweenHelper
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var doTweenInit = DOTween.Init();
|
||||
doTweenInit?.SetCapacity(1024, 1024);
|
||||
|
||||
DOTween.SetTweensCapacity(1024, 1024);
|
||||
|
||||
DOTween.defaultEaseType = Ease.Linear;
|
||||
|
||||
DOTween.defaultEaseOvershootOrAmplitude = 1.70158f;
|
||||
|
||||
DOTween.defaultEasePeriod = 0f;
|
||||
|
||||
DOTween.logBehaviour = LogBehaviour.Verbose;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0519ac96dec7c074eb2ab4191049c0e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using FairyGUI;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public static class FGUIHelper
|
||||
{
|
||||
public static void AddFguiTimer(float interval, int repeat, TimerCallback callback, object callbackParam)
|
||||
{
|
||||
Timers.inst.Add(interval, repeat, callback, callbackParam);
|
||||
}
|
||||
|
||||
public static string SetGLoaderUrl(GLoader gLoader, string pkgName, string resName)
|
||||
{
|
||||
var url = UIPackage.GetItemURL(pkgName, resName);
|
||||
if (url != null)
|
||||
{
|
||||
gLoader.url = url;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
public static void PlayClickSound()
|
||||
{
|
||||
if (UIConfig.buttonSound != null && UIConfig.buttonSound.nativeClip != null)
|
||||
{
|
||||
Stage.inst.PlayOneShotSound(UIConfig.buttonSound.nativeClip, UIConfig.buttonSoundVolumeScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed9a746e29efffb49a34ccaa28fad0bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class ParticleUnscaledTime : MonoBehaviour
|
||||
{
|
||||
private float lastTime;
|
||||
private ParticleSystem particle;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitData();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
OnUpdateParticleTime();
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
particle = GetComponent<ParticleSystem>();
|
||||
lastTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
|
||||
private void OnUpdateParticleTime()
|
||||
{
|
||||
var realtimeSinceStartup = Time.realtimeSinceStartup;
|
||||
var deltaTime = realtimeSinceStartup - lastTime;
|
||||
particle.Simulate(deltaTime, true, false);
|
||||
lastTime = realtimeSinceStartup;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3aea4fd60c51439408f557406144c842
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public static class PlayerPrefsKit
|
||||
{
|
||||
public static void WriteInt(string key, int data)
|
||||
{
|
||||
PlayerPrefs.SetInt(key, data);
|
||||
}
|
||||
|
||||
public static void WriteBool(string key, bool data)
|
||||
{
|
||||
PlayerPrefs.SetInt(key, data ? PrefsConst.IntTrue : PrefsConst.IntFalse);
|
||||
}
|
||||
|
||||
public static void WriteString(string key, string data)
|
||||
{
|
||||
PlayerPrefs.SetString(key, data);
|
||||
}
|
||||
|
||||
public static void WriteObject(string key, object data)
|
||||
{
|
||||
string dataStr = SerializeUtil.ToJson(data);
|
||||
PlayerPrefs.SetString(key, dataStr);
|
||||
}
|
||||
|
||||
public static bool ReadBool(string key, bool defalutValue = PrefsConst.BoolDefault)
|
||||
{
|
||||
if (!HasKey(key))
|
||||
{
|
||||
return defalutValue;
|
||||
}
|
||||
|
||||
bool data = PlayerPrefs.GetInt(key) == PrefsConst.IntTrue ? true : false;
|
||||
return data;
|
||||
}
|
||||
|
||||
public static string ReadString(string key)
|
||||
{
|
||||
string data = PlayerPrefs.GetString(key, string.Empty);
|
||||
return data;
|
||||
}
|
||||
|
||||
public static bool HasKey(string key)
|
||||
{
|
||||
return PlayerPrefs.HasKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76dcbe5a9e849b04792146811da649cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da918a8bb74e48a39f4b2bf158d7a90d
|
||||
timeCreated: 1703490994
|
||||
@@ -0,0 +1,397 @@
|
||||
//
|
||||
//
|
||||
// using System.Collections;
|
||||
// using UnityEngine;
|
||||
// using AppsFlyerSDK;
|
||||
// using System.Collections.Generic;
|
||||
// using ZooMatch;
|
||||
// using Unity.Advertisement.IosSupport;
|
||||
// using System;
|
||||
// using DG.Tweening;
|
||||
//
|
||||
// namespace IgnoreOPS
|
||||
// {
|
||||
//
|
||||
//
|
||||
// internal class AppsFlyerObjectScript1 : MonoBehaviour, IAppsFlyerConversionData
|
||||
// {
|
||||
// public string appID = null;
|
||||
// public bool is_init = false;
|
||||
//
|
||||
// public Coroutine m_Coroutine;
|
||||
// void Start()
|
||||
// {
|
||||
// AddListener();
|
||||
// AppsFlyer.setIsDebug(true);
|
||||
// #if UNITY_IOS && !UNITY_EDITOR
|
||||
// appID = "6745081004";
|
||||
// m_Coroutine = CrazyAsyKit.StartCoroutine(loopWaitInitAf());
|
||||
//
|
||||
// #endif
|
||||
//
|
||||
//
|
||||
// #if UNITY_EDITOR
|
||||
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// #endif
|
||||
// }
|
||||
// private void AddListener()
|
||||
// {
|
||||
// NetworkDispatcher.Instance.AddListener(NetworkMsg.NotNetwork, RequestLogin);
|
||||
// }
|
||||
//
|
||||
// private void RemoveListener()
|
||||
// {
|
||||
// NetworkDispatcher.Instance.RemoveListener(NetworkMsg.NotNetwork, RequestLogin);
|
||||
// }
|
||||
// void RequestLogin(object obj = null)
|
||||
// {
|
||||
// if (GameHelper.IsConnect())
|
||||
// {
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Network_reconnection);
|
||||
// }
|
||||
//
|
||||
// CrazyAsyKit.StopCoroutine(m_Coroutine);
|
||||
//
|
||||
// m_Coroutine = CrazyAsyKit.StartCoroutine(loopWaitInitAf());
|
||||
// }
|
||||
//
|
||||
// void OnDestroy() {
|
||||
// RemoveListener();
|
||||
// }
|
||||
//
|
||||
// public IEnumerator loopWaitInitAf()
|
||||
// {
|
||||
// // Debug.Log($"barry !GameHelper.IsConnect()==== {!GameHelper.IsConnect()}");
|
||||
//
|
||||
// #if !FlowerPowerRelease
|
||||
// GameHelper.ShowTips($"is link network:{GameHelper.IsConnect()}");
|
||||
// #endif
|
||||
// if (!GameHelper.IsConnect())
|
||||
// {
|
||||
// Action action = () =>
|
||||
// {
|
||||
// DOVirtual.DelayedCall(0.5f, ()=>
|
||||
// {
|
||||
// // NetworkDispatcher.Instance.Dispatch(NetworkMsg.NotNetwork);
|
||||
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// });
|
||||
// };
|
||||
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.TipsViewUI_Open,action);
|
||||
// yield return null;
|
||||
// }
|
||||
//
|
||||
// var reqData = new RespLoginFunnelData
|
||||
// {
|
||||
// type = "afSend",
|
||||
// payload = ""
|
||||
// };
|
||||
// NetworkKit.PostFunnelLogin(reqData);
|
||||
//
|
||||
// float a = 0;
|
||||
// if (ATTrackingStatusBinding.GetAuthorizationTrackingStatus() ==
|
||||
// ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED)
|
||||
// {
|
||||
// ATTrackingStatusBinding.RequestAuthorizationTracking();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// while ((ATTrackingStatusBinding.GetAuthorizationTrackingStatus() ==
|
||||
// ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED) && (a < 5.0f))
|
||||
// {
|
||||
// a += 0.5f;
|
||||
// yield return new WaitForSeconds(0.5f);
|
||||
// }
|
||||
//
|
||||
// AppsFlyer.initSDK("MoPyHQ7ZLXpqouczgQkNdU", appID, this);
|
||||
// AppsFlyer.startSDK();
|
||||
// AppsFlyer.AFLog("8888888888888888888", ATTrackingStatusBinding.GetAuthorizationTrackingStatus().ToString());
|
||||
// //yield return new WaitForSeconds(0.5f);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void onConversionDataSuccess(string conversionData)
|
||||
// {
|
||||
// if (is_init) return;
|
||||
// is_init = true;
|
||||
// AppsFlyer.AFLog("onConversionDataSuccess", conversionData);
|
||||
// Debug.Log("hunxiao0000000000000000000000-1");
|
||||
// var conversionDataDictionary = AppsFlyer.CallbackStringToDictionary(conversionData);
|
||||
// var json = SerializeUtil.ToJsonIndented(conversionDataDictionary);
|
||||
// // Debug.Log("hunxiao0000000000000000000000-2");
|
||||
// SuperApplication.Instance.attribution =
|
||||
// conversionDataDictionary.TryGetValue("af_status", out var afStatus)
|
||||
// ? afStatus.ToString().ToLower()
|
||||
// : "organic";
|
||||
//
|
||||
// // Debug.Log("hunxiao0000000000000000000000");
|
||||
// // if (GameHelper.IsConnect())
|
||||
// // {
|
||||
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// // }
|
||||
//
|
||||
// var reqData = new RespLoginFunnelData
|
||||
// {
|
||||
// type = "afRecv",
|
||||
// payload = "success"
|
||||
// };
|
||||
// NetworkKit.PostFunnelLogin(reqData);
|
||||
// }
|
||||
//
|
||||
// public void onConversionDataFail(string error)
|
||||
// {
|
||||
// if (is_init) return;
|
||||
// is_init = true;
|
||||
// AppsFlyer.AFLog("onConversionDataFail", error);
|
||||
// Debug.Log("hunxiao0000000000000000000000-2");
|
||||
// // if (GameHelper.IsConnect())
|
||||
// // {
|
||||
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// // }
|
||||
//
|
||||
// var reqData = new RespLoginFunnelData
|
||||
// {
|
||||
// type = "afRecv",
|
||||
// payload = "fail"
|
||||
// };
|
||||
// NetworkKit.PostFunnelLogin(reqData);
|
||||
// }
|
||||
//
|
||||
// public void onAppOpenAttribution(string attributionData)
|
||||
// {
|
||||
// AppsFlyer.AFLog("onAppOpenAttribution", attributionData);
|
||||
// Dictionary<string, object> attributionDataDictionary =
|
||||
// AppsFlyer.CallbackStringToDictionary(attributionData);
|
||||
// }
|
||||
//
|
||||
// public void onAppOpenAttributionFailure(string error)
|
||||
// {
|
||||
// AppsFlyer.AFLog("onAppOpenAttributionFailure", error);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // using System.Collections;
|
||||
// // using UnityEngine;
|
||||
// // using System.Collections.Generic;
|
||||
// // using Unity.Advertisement.IosSupport;
|
||||
// // using ZooMatch;
|
||||
// // using System;
|
||||
// // using DG.Tweening;
|
||||
// // using Unity.VisualScripting;
|
||||
// // namespace IgnoreOPS
|
||||
// // {
|
||||
// //
|
||||
// // public class AppsFlyerObjectScript1 : MonoBehaviour
|
||||
// // {
|
||||
// // public string appID = null;
|
||||
// // public bool is_init = false;
|
||||
// //
|
||||
// // public Coroutine m_Coroutine;
|
||||
// // void Start()
|
||||
// // {
|
||||
// //
|
||||
// // AddListener();
|
||||
// //
|
||||
// // // AppsFlyer.setIsDebug(true);
|
||||
// // #if UNITY_IOS && !UNITY_EDITOR
|
||||
// // appID = "6739028047";
|
||||
// // m_Coroutine = CrazyAsyKit.StartCoroutine(loopWaitInitAf());
|
||||
// // CrazyAsyKit.StartCoroutine(loopCheckAdjustState());
|
||||
// // // NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// //
|
||||
// // #endif
|
||||
// //
|
||||
// // #if UNITY_EDITOR || UNITY_ANDROID
|
||||
// // NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// // #endif
|
||||
// //
|
||||
// // }
|
||||
// // private void AddListener()
|
||||
// // {
|
||||
// // NetworkDispatcher.Instance.AddListener(NetworkMsg.NotNetwork, RequestLogin);
|
||||
// // }
|
||||
// //
|
||||
// // private void RemoveListener()
|
||||
// // {
|
||||
// // NetworkDispatcher.Instance.RemoveListener(NetworkMsg.NotNetwork, RequestLogin);
|
||||
// // }
|
||||
// // void RequestLogin(object obj = null)
|
||||
// // {
|
||||
// // if (GameHelper.IsConnect())
|
||||
// // {
|
||||
// // GameDispatcher.Instance.Dispatch(GameMsg.Network_reconnection);
|
||||
// // }
|
||||
// //
|
||||
// // CrazyAsyKit.StopCoroutine(m_Coroutine);
|
||||
// //
|
||||
// // m_Coroutine = CrazyAsyKit.StartCoroutine(loopWaitInitAf());
|
||||
// // }
|
||||
// // void OnDestroy()
|
||||
// // {
|
||||
// // RemoveListener();
|
||||
// // }
|
||||
// //
|
||||
// // IEnumerator loopWaitInitAf()
|
||||
// // {
|
||||
// // if (!GameHelper.IsConnect())
|
||||
// // {
|
||||
// // Action action = () =>
|
||||
// // {
|
||||
// // DOVirtual.DelayedCall(0.5f, () =>
|
||||
// // {
|
||||
// // NetworkDispatcher.Instance.Dispatch(NetworkMsg.NotNetwork);
|
||||
// // });
|
||||
// // };
|
||||
// // UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.TipsViewUI_Open, action);
|
||||
// // yield return null;
|
||||
// // }
|
||||
// //
|
||||
// //
|
||||
// // sendEventToServer("afSend");
|
||||
// // float a = 0;
|
||||
// // #if !UNITY_EDITOR && UNITY_IOS
|
||||
// //
|
||||
// // if (ATTrackingStatusBinding.GetAuthorizationTrackingStatus() ==
|
||||
// // ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED)
|
||||
// // {
|
||||
// // ATTrackingStatusBinding.RequestAuthorizationTracking();
|
||||
// // }
|
||||
// //
|
||||
// //
|
||||
// // while ((ATTrackingStatusBinding.GetAuthorizationTrackingStatus() ==
|
||||
// // ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED)&& (a < 5.0f))
|
||||
// // {
|
||||
// // a += 0.5f;
|
||||
// // yield return new WaitForSeconds(0.5f);
|
||||
// // }
|
||||
// //
|
||||
// // #endif
|
||||
// //
|
||||
// // AdjustConfig adjustConfig = new AdjustConfig(
|
||||
// // "g1s03vcg43y8",
|
||||
// // AdjustEnvironment.Production,
|
||||
// // (AdjustLogLevel.Verbose == AdjustLogLevel.Suppress));
|
||||
// // adjustConfig.LogLevel = AdjustLogLevel.Verbose;
|
||||
// // adjustConfig.IsSendingInBackgroundEnabled = false;
|
||||
// // adjustConfig.IsDeferredDeeplinkOpeningEnabled = true;
|
||||
// // adjustConfig.DefaultTracker = "Default";
|
||||
// // // TODO: URL strategy
|
||||
// // adjustConfig.IsCoppaComplianceEnabled = false;
|
||||
// // adjustConfig.IsCostDataInAttributionEnabled = true;
|
||||
// // adjustConfig.IsPreinstallTrackingEnabled = false;
|
||||
// // adjustConfig.PreinstallFilePath = "";
|
||||
// // adjustConfig.IsAdServicesEnabled = true;
|
||||
// // adjustConfig.IsIdfaReadingEnabled = true;
|
||||
// // adjustConfig.IsLinkMeEnabled = false;
|
||||
// // adjustConfig.IsSkanAttributionEnabled = true;
|
||||
// // adjustConfig.SessionSuccessDelegate += SuccessDelegate;
|
||||
// // adjustConfig.SessionFailureDelegate += (a) =>
|
||||
// // {
|
||||
// // ///sendEventToServer("afRecv", "fail");
|
||||
// // };
|
||||
// // //adjustConfig.AttributionChangedDelegate += SuccessDelegate;
|
||||
// // a = 0;
|
||||
// // Adjust.InitSdk(adjustConfig);
|
||||
// // while (SaveData.GetSaveobject().attribution == "null" && (a < 5.0f))
|
||||
// // {
|
||||
// // a += 0.5f;
|
||||
// // yield return new WaitForSeconds(0.5f);
|
||||
// // }
|
||||
// // NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// // sendEventToServer("afRecv", "success");
|
||||
// // // AppsFlyer.initSDK("eVgvrvwfbFeuRrC69EpX6j", appID, this);
|
||||
// // // AppsFlyer.startSDK();
|
||||
// // //AppsFlyer.AFLog("8888888888888888888", ATTrackingStatusBinding.GetAuthorizationTrackingStatus().ToString());
|
||||
// // //yield return new WaitForSeconds(0.5f);
|
||||
// //
|
||||
// // }
|
||||
// // void SuccessDelegate(AdjustSessionSuccess AdjustSessionSuccess)
|
||||
// // {//adjust成功回调,每个设备只会触发第一次
|
||||
// // Debug.Log("[Adjust]----" + "成功回调");
|
||||
// // Adjust.GetAttribution(attribution =>
|
||||
// // {
|
||||
// // SuperApplication.Instance.attribution = attribution.Network;
|
||||
// // SaveData.GetSaveobject().attribution = attribution.Network;
|
||||
// // SaveData.saveDataFunc();
|
||||
// //
|
||||
// // });
|
||||
// // Adjust.GetAdid((adid) =>
|
||||
// // {
|
||||
// // Debug.Log(adid + "+++++++++++++++++++++++++++++");
|
||||
// // PlayerPrefs.SetString("adjust_adid", adid);
|
||||
// //
|
||||
// // });
|
||||
// //
|
||||
// // }
|
||||
// //
|
||||
// // IEnumerator loopCheckAdjustState()
|
||||
// // {
|
||||
// //
|
||||
// //
|
||||
// //
|
||||
// // #if !UNITY_EDITOR && UNITY_IOS
|
||||
// //
|
||||
// //
|
||||
// // Adjust.IsEnabled(isEnabled =>
|
||||
// // {
|
||||
// // Debug.Log("[Adjust]----启用" + isEnabled);
|
||||
// //
|
||||
// // });
|
||||
// //
|
||||
// // yield return new WaitForSeconds(0.1f);
|
||||
// //
|
||||
// //
|
||||
// // #else
|
||||
// // yield return null;
|
||||
// // #endif
|
||||
// //
|
||||
// //
|
||||
// // }
|
||||
// // // public void onConversionDataSuccess(string conversionData)
|
||||
// // // {
|
||||
// // // if (is_init) return;
|
||||
// // // is_init = true;
|
||||
// // // AppsFlyer.AFLog("onConversionDataSuccess", conversionData);
|
||||
// // // var conversionDataDictionary = AppsFlyer.CallbackStringToDictionary(conversionData);
|
||||
// // // var json = SerializeUtil.ToJsonIndented(conversionDataDictionary);
|
||||
// //
|
||||
// // // SuperApplication.Instance.attribution =
|
||||
// // // conversionDataDictionary.TryGetValue("af_status", out var afStatus)
|
||||
// // // ? afStatus.ToString().ToLower()
|
||||
// // // : "organic";
|
||||
// // // NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// // // sendEventToServer("afRecv","success");
|
||||
// // // }
|
||||
// //
|
||||
// // // public void onConversionDataFail(string error)
|
||||
// // // {
|
||||
// // // if (is_init) return;
|
||||
// // // is_init = true;
|
||||
// // // AppsFlyer.AFLog("onConversionDataFail", error);
|
||||
// // // NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
// // // sendEventToServer("afRecv","fail");
|
||||
// // // }
|
||||
// //
|
||||
// // private void sendEventToServer(string _type, string _payload = "")
|
||||
// // {
|
||||
// // var reqData = new RespLoginFunnelData
|
||||
// // {
|
||||
// // type = _type,
|
||||
// // payload = _payload
|
||||
// // };
|
||||
// // NetworkKit.PostFunnelLogin(reqData);
|
||||
// // }
|
||||
// //
|
||||
// // // public void onAppOpenAttribution(string attributionData)
|
||||
// // // {
|
||||
// // // AppsFlyer.AFLog("onAppOpenAttribution", attributionData);
|
||||
// // // Dictionary<string, object> attributionDataDictionary =
|
||||
// // // AppsFlyer.CallbackStringToDictionary(attributionData);
|
||||
// // // }
|
||||
// //
|
||||
// // // public void onAppOpenAttributionFailure(string error)
|
||||
// // // {
|
||||
// // // AppsFlyer.AFLog("onAppOpenAttributionFailure", error);
|
||||
// // // }
|
||||
// // }
|
||||
// // }
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7069d4622d7c4f4bbc84bcdfd341f10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,462 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using RGKT2NIYSDK;
|
||||
|
||||
// using AppsFlyerSDK;
|
||||
|
||||
// using AppsFlyerSDK;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
|
||||
namespace ZooMatch
|
||||
{
|
||||
public class MaxADKit
|
||||
{
|
||||
public static string SDKKey =
|
||||
"N79bseJJqX7mlVAcld9x4vkF6mm8a6pZaJhzMauN934y1f5KIDr2QVDrRhuJFgtL9POreELZVuwUTs9dAdZiSp";
|
||||
|
||||
public static string interstitialADUnitID = "83d1339b89e7e791";
|
||||
|
||||
|
||||
public static string rewardedADUnitID = "f7fbcf0b6c8d02b2";
|
||||
|
||||
|
||||
private const float RevenueThreshold = 0f;
|
||||
|
||||
public static Dictionary<string, string> adCallbackInfo;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
//注册 ab事件,0或1,0为自然量版本,1为激励版本
|
||||
RGKT2NIYSDKUtility.Instance.RegistIosParam(i =>
|
||||
{
|
||||
SuperApplication.Instance.attribution = i == 0 ? "organic" : "non-organic";
|
||||
// SuperApplication.Instance.attribution = "non-organic";
|
||||
Debug.Log($"ios ab param: {i} attribution: {SuperApplication.Instance.attribution}");
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
||||
|
||||
});
|
||||
|
||||
void GameConfig(bool result, string config)
|
||||
{
|
||||
Debug.Log($"************** game config result: {config}, result: {result}");
|
||||
}
|
||||
|
||||
RGKT2NIYSDKUtility.Instance.Init(null,null,GameConfig);
|
||||
#endif
|
||||
|
||||
|
||||
// MaxSdkCallbacks.OnSdkInitializedEvent += sdkConfiguration =>
|
||||
// {
|
||||
// InitializeRewardedAds();
|
||||
// InitializeInterstitialAds();
|
||||
// };
|
||||
//
|
||||
//
|
||||
// MaxSdk.SetSdkKey(SDKKey);
|
||||
//
|
||||
// // var loginModel = GameHelper.GetLoginModel();
|
||||
// // user_id = loginModel.uid.ToString();
|
||||
// // MaxSdk.SetUserId(loginModel.uid.ToString());
|
||||
// // MaxSdk.SetIsAgeRestrictedUser(false);
|
||||
// MaxSdk.SetHasUserConsent(true);
|
||||
// MaxSdk.SetDoNotSell(false);
|
||||
//
|
||||
// MaxSdk.InitializeSdk();
|
||||
//
|
||||
// // MaxSdk.ShowMediationDebugger();
|
||||
// #if !UNITY_EDITOR
|
||||
// MBridgeSDKManager.initialize("368295", "fc0155e8f6e8bda23b06d22414379609");
|
||||
// #endif
|
||||
adCallbackInfo = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public static void SetUserID(string userID)
|
||||
{
|
||||
user_id = userID;
|
||||
MaxSdk.SetUserId(user_id);
|
||||
}
|
||||
|
||||
#region 插屏广告相关
|
||||
|
||||
public static bool CheckInter()
|
||||
{
|
||||
var isReady = RGKT2NIYSDKUtility.Instance.IsInterReady();
|
||||
return isReady;
|
||||
}
|
||||
|
||||
public static UnityAction<bool> onInterstitialAdCompleted = null;
|
||||
public static void ShowInterstitial(string placement = "DefaultInterstitial",
|
||||
UnityAction<bool> onCompleted = null)
|
||||
{
|
||||
if (CheckInter())
|
||||
{
|
||||
Debug.Log($"插屏广告已经准备好,播放");
|
||||
RGKT2NIYSDKUtility.Instance.ShowInter(placement, (() =>
|
||||
{
|
||||
onCompleted?.Invoke(true);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"插屏广告未准备好");
|
||||
onCompleted?.Invoke(false);
|
||||
}
|
||||
// if (MaxSdk.IsInterstitialReady(interstitialADUnitID))
|
||||
// {
|
||||
// Debug.Log($"广告已经准备好,播放");
|
||||
// MaxSdk.ShowInterstitial(interstitialADUnitID, placement);
|
||||
// onInterstitialAdCompleted = onCompleted;
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log($"广告未准备好,不播放");
|
||||
//
|
||||
// onCompleted?.Invoke(false);
|
||||
// }
|
||||
}
|
||||
|
||||
static int retryAttemptInterstitial;
|
||||
|
||||
public static void InitializeInterstitialAds()
|
||||
{
|
||||
|
||||
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterstitialLoadedEvent;
|
||||
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnInterstitialLoadFailedEvent;
|
||||
MaxSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnInterstitialDisplayedEvent;
|
||||
MaxSdkCallbacks.Interstitial.OnAdClickedEvent += OnInterstitialClickedEvent;
|
||||
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialHiddenEvent;
|
||||
MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent += OnInterstitialAdFailedToDisplayEvent;
|
||||
MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnInterstitialAdRevenueEvent;
|
||||
|
||||
|
||||
LoadInterstitial();
|
||||
}
|
||||
|
||||
private static void LoadInterstitial()
|
||||
{
|
||||
MaxSdk.LoadInterstitial(interstitialADUnitID);
|
||||
}
|
||||
|
||||
private static void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
retryAttemptInterstitial = 0;
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.video_type, BuriedPointEvent.Interstitial_videos_fill_number, 1);
|
||||
}
|
||||
|
||||
private static void OnInterstitialLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||
{
|
||||
retryAttemptInterstitial++;
|
||||
double retryDelay = Math.Pow(2, Math.Min(6, retryAttemptInterstitial));
|
||||
|
||||
CrazyAsyKit.StartAction("LoadInterstitial", LoadInterstitial, (float)retryDelay);
|
||||
}
|
||||
|
||||
private static void OnInterstitialDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
}
|
||||
|
||||
private static void OnInterstitialAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
|
||||
MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
LoadInterstitial();
|
||||
}
|
||||
|
||||
private static void OnInterstitialClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
}
|
||||
|
||||
private static void OnInterstitialHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
LoadInterstitial();
|
||||
onInterstitialAdCompleted?.Invoke(true);
|
||||
onInterstitialAdCompleted = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 激励视频广告相关
|
||||
|
||||
private static bool CheckReward()
|
||||
{
|
||||
var isReady = RGKT2NIYSDKUtility.Instance.IsVideoReady();
|
||||
return isReady;
|
||||
}
|
||||
|
||||
private static UnityAction<bool> onVideoAdCompleted = null;
|
||||
private static string _placement = "";
|
||||
private static Coroutine _waitForVideoAd = null;
|
||||
public static void ShowVideo(string placement = "DefaultVideo", UnityAction<bool> onCompleted = null)
|
||||
{
|
||||
|
||||
// onVideoAdCompleted = onCompleted;
|
||||
// _placement = placement;
|
||||
#if UNITY_EDITOR
|
||||
onVideoAdCompleted?.Invoke(true);
|
||||
#else
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.video_behavior,BuriedPointEvent.watch_ad_people,1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.video_type,BuriedPointEvent.Rewarded_videos_trigger_number,1);
|
||||
|
||||
if (CheckReward())
|
||||
{
|
||||
Debug.Log($"激励广告已经准备好, 播放");
|
||||
|
||||
RGKT2NIYSDKUtility.Instance.ShowRewardVideo(placement, b =>
|
||||
{
|
||||
Debug.Log($"reward video result: {b}");
|
||||
onCompleted?.Invoke(b);
|
||||
}, () =>
|
||||
{
|
||||
Debug.Log("激励广告关闭");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"广告未准备好");
|
||||
onCompleted?.Invoke(false);
|
||||
}
|
||||
// if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
|
||||
// {
|
||||
// MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (_waitForVideoAd != null)
|
||||
// {
|
||||
// CrazyAsyKit.StopCoroutine(_waitForVideoAd);
|
||||
// }
|
||||
// _waitForVideoAd = CrazyAsyKit.StartCoroutine(WaitForVideoAd());
|
||||
// }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
private static IEnumerator WaitForVideoAd()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Open);
|
||||
var count = 0;
|
||||
var result = false;
|
||||
while (count < 6)
|
||||
{
|
||||
if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
|
||||
{
|
||||
result = true;
|
||||
MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
|
||||
break;
|
||||
}
|
||||
|
||||
count++;
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(result);
|
||||
}
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
_waitForVideoAd = null;
|
||||
}
|
||||
|
||||
static int retryAttempt;
|
||||
|
||||
public static void InitializeRewardedAds()
|
||||
{
|
||||
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
|
||||
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardedAdLoadFailedEvent;
|
||||
MaxSdkCallbacks.Rewarded.OnAdDisplayedEvent += OnRewardedAdDisplayedEvent;
|
||||
MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
|
||||
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenuePaidEvent;
|
||||
MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdHiddenEvent;
|
||||
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardedAdFailedToDisplayEvent;
|
||||
MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
|
||||
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenueEvent;
|
||||
|
||||
|
||||
LoadRewardedAd();
|
||||
}
|
||||
|
||||
private static void LoadRewardedAd()
|
||||
{
|
||||
MaxSdk.LoadRewardedAd(rewardedADUnitID);
|
||||
}
|
||||
|
||||
private static void OnInterstitialAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
// #if !ZooMatchRelease
|
||||
// Debug.Log("OnInterstitialAdRevenueEvent: " + adInfo.Revenue);
|
||||
// GameHelper.AdOverRevenueEvent(2, 0.1f);
|
||||
// #endif
|
||||
OnAdRevenuePaidEvent(adUnitId, adInfo, 2);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
// #if !ZooMatchRelease
|
||||
// Debug.Log("OnInterstitialAdRevenueEvent: " + adInfo.Revenue);
|
||||
// GameHelper.AdOverRevenueEvent(1, 0.1f);
|
||||
// #endif
|
||||
OnAdRevenuePaidEvent(adUnitId, adInfo, 1);
|
||||
}
|
||||
|
||||
public static string user_id = "";
|
||||
private static void OnAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo, int adType)
|
||||
{
|
||||
//string countryCode = MaxSdk.GetSdkConfiguration().CountryCode; // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD"
|
||||
// //string networkName = adInfo.NetworkName; // Display name of the network that showed the ad
|
||||
// // string adUnitIdentifier = adInfo.AdUnitIdentifier; // The MAX Ad Unit ID
|
||||
// //string placement = adInfo.Placement; // The placement this ad's postbacks are tied to
|
||||
|
||||
if (adInfo.Revenue > 0)
|
||||
{
|
||||
GameHelper.AdOverRevenueEvent(adType,(float)adInfo.Revenue);
|
||||
|
||||
var revenue = adInfo.Revenue;
|
||||
//adjust上传广告收益时,不判断是否大于0.1,只要大于0都上传
|
||||
// AdjustEvent adjustEvent = new AdjustEvent("nytwjm");
|
||||
// adjustEvent.SetRevenue(revenue, "USD");
|
||||
// Adjust.TrackEvent(adjustEvent);
|
||||
}
|
||||
|
||||
|
||||
SaveData.GetSaveobject().watchRewardAD_value += adInfo.Revenue;
|
||||
SaveData.GetSaveobject().watchRewardADnumbers++;
|
||||
SaveData.saveDataFunc();
|
||||
// if (SaveData.GetSaveobject().watchRewardADnumbers == 1)
|
||||
// {
|
||||
// AdjustEvent adjustEvent = new AdjustEvent("96ny5o");
|
||||
// adjustEvent.SetRevenue(SaveData.GetSaveobject().watchRewardAD_value, "USD");
|
||||
// Adjust.TrackEvent(adjustEvent);
|
||||
// }
|
||||
// else if (SaveData.GetSaveobject().watchRewardADnumbers == 5)
|
||||
// {
|
||||
// AdjustEvent adjustEvent = new AdjustEvent("5zai0n");
|
||||
// adjustEvent.SetRevenue(SaveData.GetSaveobject().watchRewardAD_value, "USD");
|
||||
// Adjust.TrackEvent(adjustEvent);
|
||||
// }
|
||||
// else if (SaveData.GetSaveobject().watchRewardADnumbers == 10)
|
||||
// {
|
||||
// AdjustEvent adjustEvent = new AdjustEvent("9510hf");
|
||||
// adjustEvent.SetRevenue(SaveData.GetSaveobject().watchRewardAD_value, "USD");
|
||||
// Adjust.TrackEvent(adjustEvent);
|
||||
// }
|
||||
// int highSend;
|
||||
// if (!PlayerPrefs.HasKey($"sendHighRevenue_{user_id}"))
|
||||
// {
|
||||
// highSend = 0; // 如果不存在,则初始化为 0
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// highSend = PlayerPrefs.GetInt($"sendHighRevenue_{user_id}", 0); // 从 PlayerPrefs 中获取
|
||||
// }
|
||||
// // 判断是否需要发送高收入事件
|
||||
// // Debug.Log($"highSend=====: {highSend}");
|
||||
// if (highSend == 0)
|
||||
// {
|
||||
// float limitNum = GameHelper.GetCommonModel().afSendLimit;
|
||||
// var totalNum = Convert.ToDouble(PlayerPrefs.GetString($"adRevenueTotal_{user_id}", "0"));
|
||||
// totalNum += adInfo.Revenue;
|
||||
// // Debug.Log($"totalNum=====: {totalNum} {limitNum}");
|
||||
// if (totalNum >= limitNum)
|
||||
// {
|
||||
// GameHelper.sendHighRevenueToAF(); // 发送高收入事件
|
||||
// PlayerPrefs.SetInt($"sendHighRevenue_{user_id}", 1); // 标记已发送
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// PlayerPrefs.SetString($"adRevenueTotal_{user_id}", totalNum.ToString());
|
||||
// }
|
||||
// }
|
||||
|
||||
/*
|
||||
ATTRIBUTION_PLATFORM_APPSFLYER = "AppsFlyer";
|
||||
ATTRIBUTION_PLATFORM_ADJUST = "Adjust";
|
||||
ATTRIBUTION_PLATFORM_TENJIN = "Tenjin";
|
||||
ATTRIBUTION_PLATFORM_SINGULAR = "Singular";
|
||||
ATTRIBUTION_PLATFORM_KOCHAVA = "Kochava";
|
||||
ATTRIBUTION_PLATFORM_BRANCH = "Branch";
|
||||
ATTRIBUTION_PLATFORM_REYUN = "Reyun";
|
||||
ATTRIBUTION_PLATFORM_SOLAR_ENGINE = "SolarEngine";
|
||||
...
|
||||
...
|
||||
*/
|
||||
|
||||
//这里需要改成自己的归因平台名称,这里以Adjust为例,"userid"替换为归因平台UID
|
||||
MBridgeRevenueParamsEntity mBridgeRevenueParamsEntity = new MBridgeRevenueParamsEntity(MBridgeRevenueParamsEntity.ATTRIBUTION_PLATFORM_ADJUST, PlayerPrefs.GetString("adjust_adid", "default"));
|
||||
|
||||
///MaxSdkBase.AdInfo类型的adInfo
|
||||
mBridgeRevenueParamsEntity.SetMaxAdInfo(adInfo);
|
||||
MBridgeRevenueManager.Track(mBridgeRevenueParamsEntity);
|
||||
|
||||
}
|
||||
private static void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
retryAttempt = 0;
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.AD_event, $"{BuriedPointEvent.AdLoadCode}Succeed", 1, false);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||
{
|
||||
retryAttempt++;
|
||||
double retryDelay = Math.Pow(2, Math.Min(3, retryAttempt));
|
||||
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.AD_event, $"{BuriedPointEvent.AdLoadCode}{errorInfo.Code}", 1, false);
|
||||
CrazyAsyKit.StartAction("LoadRewardedAd", LoadRewardedAd, (float)retryDelay);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.AD_event, $"{BuriedPointEvent.ADShowCode}Succeed", 1, false);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
|
||||
MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.AD_event, $"{BuriedPointEvent.ADShowCode}{errorInfo.Code}", 1, false);
|
||||
LoadRewardedAd();
|
||||
}
|
||||
|
||||
private static void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
}
|
||||
|
||||
private static void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
Debug.Log("RewardedAdHiddenEvent---0");
|
||||
LoadRewardedAd();
|
||||
if (_hasReceivedReward && onVideoAdCompleted != null)
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(true);
|
||||
}
|
||||
onVideoAdCompleted = null;
|
||||
_hasReceivedReward = false;
|
||||
|
||||
Debug.Log("RewardedAdHiddenEvent---1-" + GameHelper.IsGiftSwitch() + " remove:" + SaveData.GetSaveobject().is_get_removead + " rewardinsertion:" +GameHelper.GetCommonModel().rewardinsertion );
|
||||
if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveobject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
|
||||
{
|
||||
Debug.Log("RewardedAdHiddenEvent---2-");
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.afterRewardAdShow, 1);
|
||||
|
||||
GameHelper.ShowInterstitial("AfterReward");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool _hasReceivedReward = false;
|
||||
private static void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward,
|
||||
MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
_hasReceivedReward = true;
|
||||
}
|
||||
|
||||
private static void OnRewardedAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3991d0dfc5a46ddbb4a020f0c5e0abf
|
||||
timeCreated: 1704883729
|
||||
Reference in New Issue
Block a user