提交项目

This commit is contained in:
2026-05-28 15:23:36 +08:00
commit 3cfc77d12b
5726 changed files with 554351 additions and 0 deletions
@@ -0,0 +1,322 @@
using FairyGUI;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine.Events;
namespace ZooMatch
{
public sealed class AudioManager : BaseUnityManager<AudioManager>
{
public const bool IsUnscaleTime = true;
private Dictionary<string, AudioClip> audioClipCacheDict = new Dictionary<string, AudioClip>();
private GameObject newEffectSourcesRoot;
private GameObject dynamicEffectSourcesRoot;
[HideInInspector] public AudioListener audioListener;
[HideInInspector] public AudioSource bgmSource;
[HideInInspector] public AudioSource effectSource;
[HideInInspector] public List<AudioSource> dynamicEffectSources = new List<AudioSource>();
[HideInInspector] public List<AudioSource> unscaleTimeSounds = new List<AudioSource>();
[HideInInspector] public float currUISoundVolume = 1;
private bool isOpenBGM;
public bool IsOpenBGM
{
get { return isOpenBGM; }
set
{
isOpenBGM = value;
PlayerPrefsKit.WriteBool(PrefsKeyConst.AudioMgr_isOpenBGM, isOpenBGM);
if (!bgmSource) return;
bgmSource.enabled = isOpenBGM;
if (isOpenBGM)
{
bgmSource.Play();
}
else
{
bgmSource.Pause();
}
}
}
private bool isOpenEffect;
public bool IsOpenEffect
{
get { return isOpenEffect; }
set
{
isOpenEffect = value;
PlayerPrefsKit.WriteBool(PrefsKeyConst.AudioMgr_isOpenEffect, isOpenEffect);
GRoot.inst.soundVolume = isOpenEffect ? currUISoundVolume : 0f;
if (isOpenEffect)
{
GRoot.inst.EnableSound();
}
else
{
GRoot.inst.DisableSound();
}
}
}
private void InitAudioMode()
{
isOpenBGM = PlayerPrefsKit.ReadBool(PrefsKeyConst.AudioMgr_isOpenBGM, true);
isOpenEffect = PlayerPrefsKit.ReadBool(PrefsKeyConst.AudioMgr_isOpenEffect, true);
GRoot.inst.soundVolume = 1;
currUISoundVolume = GRoot.inst.soundVolume;
GRoot.inst.soundVolume = isOpenEffect ? currUISoundVolume : 0f;
}
public override void Init()
{
base.Init();
AppDispatcher.Instance.AddListener(AppMsg.TimeScale_Change, OnTimeScaleChange);
audioListener = gameObject.AddComponent<AudioListener>();
bgmSource = gameObject.AddComponent<AudioSource>();
bgmSource.playOnAwake = false;
bgmSource.loop = true;
effectSource = gameObject.AddComponent<AudioSource>();
effectSource.playOnAwake = false;
effectSource.loop = false;
newEffectSourcesRoot = new GameObject("NewEffectSources");
newEffectSourcesRoot.transform.SetParent(gameObject.transform, false);
dynamicEffectSourcesRoot = new GameObject("DynamicEffectSources");
dynamicEffectSourcesRoot.transform.SetParent(gameObject.transform, false);
InitAudioMode();
}
public override void Dispose()
{
base.Dispose();
AppDispatcher.Instance.RemoveListener(AppMsg.TimeScale_Change, OnTimeScaleChange);
}
public void InitDefaultButtonClickSound(string btnSound)
{
string defaultSound = AudioConst.UIButtonDefault;
if (!string.IsNullOrEmpty(btnSound))
{
defaultSound = btnSound;
}
LoadKit.Instance.LoadAudio("Audio", defaultSound, audioClip =>
{
if (audioClip != null)
{
UIConfig.buttonSound = new NAudioClip(audioClip);
UIConfig.buttonSoundVolumeScale = 1;
}
});
}
private void OnTimeScaleChange(object value)
{
if (unscaleTimeSounds.Count != 0)
{
for (int i = 0; i < unscaleTimeSounds.Count; i++)
{
AudioSource audioSource = unscaleTimeSounds[i];
if (audioSource)
{
audioSource.pitch = 1;
}
}
}
}
public void StopBGM()
{
bgmSource.Stop();
}
public void PlayBGM(string audioName, bool isUnscaleTime = IsUnscaleTime)
{
if (string.IsNullOrEmpty(audioName)) return;
string curName = bgmSource.clip == null ? null : bgmSource.clip.name;
if (curName != audioName)
{
AudioClip currClip = null;
if (audioClipCacheDict.TryGetValue(audioName, out var value))
{
currClip = value;
}
else
{
try
{
currClip = LoadKit.Instance.LoadAsset<AudioClip>("Audio", audioName);
}
catch (System.Exception)
{
}
}
if (currClip != null)
{
bgmSource.clip = currClip;
if (!isOpenBGM)
{
return;
}
if (isUnscaleTime)
{
if (!unscaleTimeSounds.Contains(bgmSource))
{
unscaleTimeSounds.Add(bgmSource);
}
}
else
{
if (unscaleTimeSounds.Contains(bgmSource))
{
unscaleTimeSounds.Remove(bgmSource);
}
}
bgmSource.pitch = isUnscaleTime ? 1 : Time.timeScale;
bgmSource.Play();
}
}
}
public AudioSource PlayDynamicEffect(string audioName, float delay = 0, bool isLoop = false,
bool isUnscaleTime = IsUnscaleTime)
{
if (!isOpenEffect || string.IsNullOrEmpty(audioName)) return null;
AudioSource effectSourceCom = null;
for (int i = 0; i < dynamicEffectSources.Count; i++)
{
AudioSource sourceItem = dynamicEffectSources[i];
if (!sourceItem.isPlaying)
{
effectSourceCom = sourceItem;
break;
}
}
if (effectSourceCom == null)
{
effectSourceCom = dynamicEffectSourcesRoot.AddComponent<AudioSource>();
effectSourceCom.playOnAwake = false;
dynamicEffectSources.Add(effectSourceCom);
}
if (effectSourceCom.loop != isLoop)
{
effectSourceCom.loop = isLoop;
}
string curName;
AudioClip currClip = null;
if (effectSourceCom.clip == null)
{
curName = null;
}
else
{
currClip = effectSourceCom.clip;
curName = currClip.name;
}
var playAction = new UnityAction(delegate
{
if (currClip != null)
{
effectSourceCom.clip = currClip;
if (isUnscaleTime)
{
if (!unscaleTimeSounds.Contains(effectSourceCom))
{
unscaleTimeSounds.Add(effectSourceCom);
}
}
else
{
if (unscaleTimeSounds.Contains(effectSourceCom))
{
unscaleTimeSounds.Remove(effectSourceCom);
}
}
effectSourceCom.pitch =
isUnscaleTime ? 1 : Time.timeScale;
if (delay == 0)
{
effectSourceCom.Play();
}
else
{
effectSourceCom.PlayDelayed(delay);
}
}
});
if (curName != audioName)
{
if (audioClipCacheDict.ContainsKey(audioName))
{
currClip = audioClipCacheDict[audioName];
playAction();
}
else
{
var path = new StringBuilder("Audio");
var strs = audioName.Split('.');
var assetName = strs.Last();
if (strs.Length > 1)
{
var assetUrl = audioName.Replace($".{assetName}", string.Empty);
path.Append(".").Append(assetUrl);
}
LoadKit.Instance.LoadAudio(path.ToString(), assetName, (clip) =>
{
currClip = clip;
audioClipCacheDict[audioName] = clip;
playAction();
});
}
}
else
{
try
{
if (delay == 0)
{
effectSourceCom.Play();
}
else
{
effectSourceCom.PlayDelayed(delay);
}
}
catch (System.Exception)
{
}
}
return effectSourceCom;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 865f04198a097e941bd87d4c2716d517
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,53 @@
using System;
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
namespace ZooMatch
{
public sealed class SceneSwitchManager : BaseUnityManager<SceneSwitchManager>
{
private const bool IsUseUnityScene = false;
public delegate void LoadCallBack(object param);
public void SwitchInitialScene(int idx, LoadCallBack loadHandler, object param)
{
StartCoroutine(OnLoadInitialScene(idx, loadHandler, param));
}
public void SwitchScene(int idx, LoadCallBack loadHandler, object param)
{
StartCoroutine(OnLoadScene(idx, loadHandler, param));
}
private IEnumerator OnLoadInitialScene(int idx, LoadCallBack loadHandle, object param)
{
yield return YieldConst.Time10ms;
if (loadHandle != null)
{
loadHandle(param);
}
}
private IEnumerator OnLoadScene(int idx, LoadCallBack loadHandle, object param)
{
yield return YieldConst.WaitFor100ms;
GC.Collect();
GC.WaitForPendingFinalizers();
if (IsUseUnityScene)
{
AsyncOperation asyncUnityScene = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(idx, LoadSceneMode.Single);
yield return asyncUnityScene;
}
if (loadHandle != null)
{
loadHandle(param);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6503fa22efaefd542a68eccaa2f4e790
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,55 @@
using UnityEngine;
namespace ZooMatch
{
public enum TimerTimeType : int
{
Null = -1,
Time = 0,
UnscaledTime = 1,
RealtimeSinceStartup = 2,
}
public sealed class TimerIManager : BaseUnityManager<TimerIManager>
{
private GameObject simpleTimersRoot;
private GameObject timersRoot;
private GameObject heavyTimersRoot;
private void InitTimersRoot()
{
simpleTimersRoot = new GameObject("SimpleTimers");
simpleTimersRoot.SetParent(gameObject);
timersRoot = new GameObject("Timers");
timersRoot.SetParent(gameObject);
heavyTimersRoot = new GameObject("HeavyTimers");
heavyTimersRoot.SetParent(gameObject);
}
public EasyTimer CreateSimpleTimer(string name, TimerTimeType type)
{
EasyTimer easyTimer = simpleTimersRoot.AddComponent<EasyTimer>();
easyTimer.SetTimer(name, type);
return easyTimer;
}
public Timer CreateTimer(string name, TimerTimeType type)
{
Timer timer = timersRoot.AddComponent<Timer>();
timer.SetTimer(name, type);
return timer;
}
#region Mgr
public override void Init()
{
base.Init();
InitTimersRoot();
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f02ecdb607607114abbe6750658a9225
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,859 @@
using System;
using FairyGUI;
using System.IO;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using System.Collections.Generic;
using System.Linq;
namespace ZooMatch
{
public class UISequenceInfo
{
public BaseUI ui;
public object args;
public bool isLaunch;
}
public class UIParentInfo
{
public GComponent parent;
public int index;
}
public static class UIMgrConst
{
public static bool IsEnableOpenUIAnim = true;
public static bool IsEnableCloseUIAnim = true;
public static Vector2 OpenUIAnimEffectScale = new Vector2(0.8f, 0.8f);
public static float OpenUIAnimEffectTime = 0.3f;
public static float ClickDownAnimEffectScale = 0.9f;
}
public sealed class UIManager : BaseUnityManager<UIManager>
{
private const bool IsUseSafeAreaAdaptive = false;
private const bool IsSetButtonPivotCenter = false;
private GameObject eventSystemGo;
private EventSystem eventSystem;
private StandaloneInputModule inputModule;
private string uiDefaultFontName;
private List<string> commonPackageList = new List<string>();
private Queue<GGraph> uiMaskCacheQueue = new Queue<GGraph>();
private Dictionary<GObject, UIParentInfo> tempGObjectParentDict = new Dictionary<GObject, UIParentInfo>();
private Dictionary<int, FairyGUI.Window> uiLayerWindowDict = new Dictionary<int, FairyGUI.Window>();
private List<BaseUI> existDynamicUIs = new List<BaseUI>();
private List<BaseUI> tickUpdateUIs = new List<BaseUI>();
private List<BaseUI> normalUIRecord = new List<BaseUI>();
private List<UISequenceInfo> uiSequenceQueue = new List<UISequenceInfo>();
private ObjectPool<UISequenceInfo> uiSequencePool = new ObjectPool<UISequenceInfo>();
private Vector2 uiCenterPos;
private uint currUIOpenCumsumId;
private int closeWorldRaycastRefCount;
public void RegisterCommonPackage(string commonPackage)
{
if (!commonPackageList.Contains(commonPackage))
{
commonPackageList.Add(commonPackage);
}
}
public void RegisterCommonPackages(List<string> commonPackages)
{
#if UNITY_EDITOR
if (!UnityEngine.Application.isPlaying)
{
for (int i = 0; i < commonPackages.Count; i++)
{
string pakName = commonPackages[i];
if (UIPackage.GetByName(pakName) == null)
{
string packagePath = GetPackageUIPath(pakName);
UIPackage.AddPackage(packagePath);
}
}
return;
}
#endif
for (int i = 0; i < commonPackages.Count; i++)
{
RegisterCommonPackage(commonPackages[i]);
}
}
public void RegisterDefaultFont(string defaultFontName)
{
uiDefaultFontName = defaultFontName;
LoadKit.Instance.LoadAsset<Font>("Font", defaultFontName, (font) =>
{
if (font != null)
{
FontManager.RegisterFont(new DynamicFont(defaultFontName, font), defaultFontName);
InitFguiConfig();
}
});
}
public void RegisterFont(params string[] otherFontNames)
{
for (int i = 0; i < otherFontNames.Length; i++)
{
string fontName = otherFontNames[i];
LoadKit.Instance.LoadAsset<Font>("Font", fontName, (font) =>
{
if (font != null)
{
FontManager.RegisterFont(new DynamicFont(fontName, font), fontName);
}
});
}
}
public void DisposeAllUI()
{
while (existDynamicUIs != null && existDynamicUIs.Count != 0)
{
BaseUI ui = existDynamicUIs[existDynamicUIs.Count - 1];
Internal_CloseUI(ui, true);
}
UIPackage.RemoveAllPackages();
}
public void SwitchSceneCloseAllUI()
{
for (int i = existDynamicUIs.Count - 1; i >= 0; i--)
{
if (existDynamicUIs.Count == 0) return;
if (i >= existDynamicUIs.Count)
{
i = existDynamicUIs.Count;
}
BaseUI ui = existDynamicUIs[i];
if (ui.uiInfo.isSwitchSceneCloseUI)
{
Internal_CloseUI(ui);
}
}
}
public void Internal_OpenUI(BaseUI ui, object args = null)
{
if (!IsStartUp) return;
LoadUI(ui, args, OpenUIProcess);
}
private void OpenUIProcess(BaseUI ui, object args)
{
existDynamicUIs.Add(ui);
ui.Process_Bind();
ui.Process_OpenBefore(args);
ui.Process_Open(args);
AddNormalBaseUI(ui);
NotificationEvent(AppMsg.UIEvent_UIOpen, ui);
if (ui.uiInfo.isTickUpdate)
{
tickUpdateUIs.Add(ui);
}
if (ui.uiInfo.isClosetWorldRaycast)
{
SetWorldRaycasterEnabled(false);
}
if (UIMgrConst.IsEnableOpenUIAnim && ui.uiInfo.isNeedOpenAnim)
{
ui.KillOpenUIAnim();
OpenUIAnim(ui);
}
}
public void Internal_CloseUI(BaseUI ui, bool isImmediatelyDispose = false)
{
if (existDynamicUIs.Contains(ui))
{
existDynamicUIs.Remove(ui);
RemoveNormalBaseUI(ui);
if (ui.uiInfo.isTickUpdate)
{
tickUpdateUIs.Remove(ui);
}
ui.Process_Close();
if (UIMgrConst.IsEnableOpenUIAnim && ui.uiInfo.isNeedOpenAnim)
{
ui.KillOpenUIAnim();
}
if (UIMgrConst.IsEnableCloseUIAnim && ui.uiInfo.isNeedCloseAnim)
{
ui.KillCloseUIAnim();
CloseUIAnim(ui, () => DestroyUI(ui, isImmediatelyDispose));
}
else
{
DestroyUI(ui, isImmediatelyDispose);
}
}
}
public void Internal_HideUI(BaseUI ui)
{
ui.Process_Hide();
NotificationEvent(AppMsg.UIEvent_UIHide, ui);
}
public void Internal_DisplayUI(BaseUI ui, object args = null)
{
ui.Process_Display(args);
NotificationEvent(AppMsg.UIEvent_UIDisplay, ui);
}
private void Update()
{
if (tickUpdateUIs.Count <= 0) return;
for (int i = tickUpdateUIs.Count - 1; i >= 0; i--)
{
BaseUI ui = tickUpdateUIs[i];
if (ui == null) continue;
if (ui.isClose) continue;
if (!ui.uiInfo.isTickUpdate) continue;
ui.OnUpdate();
}
}
private void LoadUI(BaseUI ui, object args, Action<BaseUI, object> completeFunc)
{
AddUIPackage(ui.uiInfo.packageName, () => { CreateUI(ui, args, completeFunc); });
}
private void CreateUI(BaseUI ui, object args, Action<BaseUI, object> completeFunc)
{
if (string.IsNullOrEmpty(ui.uiName))
{
return;
}
GObject gObject = UIPackage.CreateObject(ui.uiInfo.packageName, ui.uiInfo.assetName);
string rawGoName = gObject.gameObjectName;
string uiGoName = string.Format("({0}){1}", ui.uiName, rawGoName);
gObject.gameObjectName = uiGoName;
gObject.displayObject.name = uiGoName;
ui.baseGObj = gObject;
ui.baseUI = ui.baseGObj.asCom;
ui.baseUI.fairyBatching = true;
ui.baseUI.name = rawGoName;
ui.rawGameObjectName = rawGoName;
ui.gameObjectName = uiGoName;
ui.baseUI.MakeFullScreen();
ui.baseUI.SetSize(GRoot.inst.width, GRoot.inst.height, false);
if (IsUseSafeAreaAdaptive)
{
Rect safeArea = Screen.safeArea;
ui.baseUI.SetPivot(0.5f, 0.5f, false);
ui.baseUI.SetSize(GRoot.inst.width, safeArea.height);
ui.baseUI.y = GRoot.inst.height - safeArea.height;
}
SetButtonClickDownEffect(ui.baseUI);
if (ui.uiInfo.gComType == UIGComType.Window)
{
FairyGUI.Window gWindowUI = new()
{
contentPane = ui.baseUI
};
ui.windowUI = gWindowUI;
ui.windowUI.fairyBatching = true;
ui.windowUI.Show();
}
if (ui.uiInfo.isNeedUIMask)
{
GGraph uiMask = CreateUIMask(ui.uiInfo.uiMaskCustomColor);
ui.uiMask = uiMask;
ui.baseUI.AddChildAt(ui.uiMask, 0);
if (ui.uiInfo.isNeedUIMaskCloseEvent)
{
ui.uiMask.onClick.Add(ui.CtrlCloseUI);
}
}
ui.uiOpenCumsumId = ++currUIOpenCumsumId;
ui.currLayer = (int)ui.uiInfo.layerType;
uiLayerWindowDict[ui.currLayer].AddChild(ui.baseUI);
completeFunc(ui, args);
}
private void AddUIPackage(string packageName, UnityAction onCompleted = null)
{
if (UIPackage.GetByName(packageName) == null)
{
if (packageName.Contains("PLoading") || packageName.Contains("A001_bigImg"))
{
var resUIPath = Path.Combine("FGUI", packageName);
UIPackage.AddPackage(resUIPath);
onCompleted?.Invoke();
}
else
{
LoadKit.Instance.LoadAsset<TextAsset>("FGUI", $"{packageName}_fui.bytes", textAsset =>
{
UIPackage.AddPackage(textAsset.bytes, packageName,
delegate (string s, string extension, Type type, out DestroyMethod destroyMethod)
{
destroyMethod = DestroyMethod.Unload;
return LoadKit.Instance.LoadAsset<UnityEngine.Object>("FGUI", $"{s}{extension}");
});
onCompleted?.Invoke();
});
}
}
else
{
onCompleted?.Invoke();
}
}
private string GetPackageUIPath(string packageName)
{
return string.Format("FGUI/{0}", packageName);
}
private void SetButtonClickDownEffect(GComponent gComponent)
{
GObject[] gObjects = gComponent.GetChildren();
for (int i = 0; i < gObjects.Length; i++)
{
GObject gObject = gObjects[i];
GButton gButton = gObject.asButton;
if (gButton != null && gButton.mode == ButtonMode.Common)
{
if (!gButton.name.StartsWith("obtn_"))
{
if (IsSetButtonPivotCenter)
{
gButton.SetPivot(0.5f, 0.5f, false);
}
gButton.SetClickDownEffect(UIMgrConst.ClickDownAnimEffectScale);
}
continue;
}
GComponent otherGComponent = gObject.asCom;
if (otherGComponent != null)
{
SetButtonClickDownEffect(otherGComponent);
continue;
}
}
}
private GGraph CreateUIMask(Color color)
{
GGraph uiMask = null;
if (uiMaskCacheQueue.Count > 0)
{
uiMask = GetUIMaskFormPool();
uiMask.color = color;
uiMask.visible = true;
}
else
{
uiMask = new GGraph();
uiMask.gameObjectName = "UIMask";
uiMask.name = uiMask.gameObjectName;
uiMask.SetPivot(0.5f, 0.5f, true);
uiMask.SetXY(uiCenterPos.x, uiCenterPos.y);
uiMask.DrawRect(5000, 5000, 0, Color.black, color);
}
return uiMask;
}
private GGraph GetUIMaskFormPool()
{
if (uiMaskCacheQueue.Count == 0) return null;
return uiMaskCacheQueue.Dequeue();
}
private void ReleaseUIMaskToPool(BaseUI ui)
{
if (ui.uiMask == null) return;
GGraph uiMask = ui.uiMask;
ui.baseUI.RemoveChild(uiMask);
ui.uiMask = null;
uiMask.onClick.Clear();
uiMask.visible = false;
uiMaskCacheQueue.Enqueue(uiMask);
}
private void DestroyUI(BaseUI ui, bool isImmediatelyDispose)
{
if (ui.uiInfo.isNeedUIMask)
{
ReleaseUIMaskToPool(ui);
}
if (ui.uiInfo.isClosetWorldRaycast)
{
SetWorldRaycasterEnabled(true);
}
CloseAllSubUI(ui);
DisposeUI(ui);
ui.Process_Destroy();
NotificationEvent(AppMsg.UIEvent_UIClose, ui);
QuitUISequence(ui);
UnloadAsset(ui.uiInfo.packageName, ui.uiInfo.assetName);
}
private void UnloadAsset(string packageName, string assetName)
{
if (UIPackage.GetByName(packageName) != null)
{
LoadKit.Instance.RecycleAsset(packageName);
}
}
private void DisposeUI(BaseUI ui)
{
uiLayerWindowDict[ui.currLayer].RemoveChild(ui.baseUI);
if (ui.uiInfo.gComType == UIGComType.Window)
{
if (ui.windowUI != null)
{
ui.windowUI.Dispose();
ui.windowUI = null;
}
}
ui.baseUI.Dispose();
ui.baseUI = null;
}
private void NotificationEvent(uint msgId, BaseUI ui)
{
AppDispatcher.Instance.Dispatch(msgId, ui);
}
private void OpenUIAnim(BaseUI ui)
{
GObject gObj = ui.baseUI;
gObj.pivot = VectorConst.Half;
gObj.SetScale(UIMgrConst.OpenUIAnimEffectScale.x, UIMgrConst.OpenUIAnimEffectScale.y);
ui.openUiGTweener = gObj.TweenScale(Vector3.one, UIMgrConst.OpenUIAnimEffectTime).OnComplete(() =>
{
ui.openUiGTweener = null;
ui.Process_OpenUIAnimEnd();
}).SetIgnoreEngineTimeScale(true).SetEase(EaseType.BackOut);
}
private void CloseUIAnim(BaseUI ui, Action animEndCB)
{
GObject gObj = ui.baseUI;
ui.closeUiGTweener = gObj.TweenScale(UIMgrConst.OpenUIAnimEffectScale, UIMgrConst.OpenUIAnimEffectTime)
.OnComplete(() =>
{
ui.Process_CloseUIAnimEnd();
animEndCB();
}).SetIgnoreEngineTimeScale(true).SetEase(EaseType.BackIn);
}
private void SetWorldRaycasterEnabled(bool enabled)
{
if (enabled)
{
closeWorldRaycastRefCount--;
}
else
{
closeWorldRaycastRefCount++;
}
if (closeWorldRaycastRefCount > 0)
{
CameraManager.Instance.SetWorldRaycasterEnabled(false);
}
else
{
CameraManager.Instance.SetWorldRaycasterEnabled(true);
}
}
public BaseUI GetDynamicUI(string uiName)
{
foreach (BaseUI ui in existDynamicUIs)
{
if (ui.uiName == uiName)
{
return ui;
}
}
return null;
}
public bool IsExistUI(string uiName)
{
foreach (BaseUI ui in existDynamicUIs)
{
if (ui.uiName == uiName)
{
return true;
}
}
return false;
}
public void SetGObjectUILayer(UILayerType toLayer, params GObject[] objs)
{
foreach (GObject item in objs)
{
if (item.parent != null)
{
GComponent defaultParent = item.parent;
int idx = defaultParent.GetChildIndex(item);
if (!tempGObjectParentDict.ContainsKey(item))
{
tempGObjectParentDict.Add(item, new UIParentInfo()
{
parent = defaultParent,
index = idx,
});
}
}
uiLayerWindowDict[(int)toLayer].AddChild(item);
Vector2 pos = item.LocalToRoot(Vector2.zero, GRoot.inst);
item.position = pos;
}
}
public void ResetGObjectUILayer(params GObject[] objs)
{
foreach (GObject item in objs)
{
if (tempGObjectParentDict.ContainsKey(item))
{
UIParentInfo parentInfo = tempGObjectParentDict[item];
int itemIndex = parentInfo.index;
int parentCount = parentInfo.parent.GetChildrenCount();
if (parentCount != 0 && parentCount >= itemIndex)
{
parentInfo.parent.AddChildAt(item, itemIndex);
}
else
{
parentInfo.parent.AddChild(item);
}
Vector2 pos = parentInfo.parent.RootToLocal(item.position, GRoot.inst);
item.position = pos;
tempGObjectParentDict.Remove(item);
}
}
}
public bool AddNormalBaseUI(BaseUI ui)
{
if (ui.uiInfo.layerType != UILayerType.Normal) return false;
BaseUI nowUI = GetNowBaseUI();
if (nowUI == null)
{
normalUIRecord.Add(ui);
return true;
}
if (ui.uiInfo.packageName == nowUI.uiInfo.packageName &&
ui.uiInfo.assetName == nowUI.uiInfo.assetName) return false;
normalUIRecord.Add(ui);
return true;
}
public bool RemoveNormalBaseUI(BaseUI ui)
{
if (ui.uiInfo.layerType != UILayerType.Normal) return false;
{
normalUIRecord.Remove(ui);
return true;
}
}
public BaseUI GetNowBaseUI()
{
if (normalUIRecord.Count > 0)
{
return normalUIRecord[normalUIRecord.Count - 1];
}
return null;
}
private void ExecuteOpenUISequence()
{
if (uiSequenceQueue.Count == 0) return;
UISequenceInfo sequenceInfo = uiSequenceQueue[0];
if (sequenceInfo.isLaunch) return;
sequenceInfo.isLaunch = true;
BaseUI ui = sequenceInfo.ui;
ui.Open(sequenceInfo.args);
}
private void QuitUISequence(BaseUI ui)
{
if (uiSequenceQueue.Count == 0) return;
UISequenceInfo sequenceInfo = uiSequenceQueue[0];
if (sequenceInfo.ui != ui) return;
uiSequenceQueue.Remove(sequenceInfo);
uiSequencePool.Release(sequenceInfo);
ExecuteOpenUISequence();
}
public void CloseSubUI(BaseUI mainUI, SubUI subUI)
{
mainUI.subUIs.Remove(subUI);
mainUI.baseUI.RemoveChild(subUI.baseGObj);
subUI.baseUI.Dispose();
subUI.baseUI = null;
}
public void CloseAllSubUI(BaseUI mainUI)
{
List<SubUI> subUIs = mainUI.subUIs;
if (subUIs == null) return;
for (int i = subUIs.Count - 1; i >= 0; i--)
{
CloseSubUI(mainUI, subUIs[i]);
}
mainUI.subUIs.Clear();
mainUI.subUIs = null;
}
private void InitUIMgr()
{
GameObject uiRootParent = new GameObject(AppObjConst.UIGoName);
uiRootParent.layer = LayerMaskConst.UI;
AppObjConst.UIGo = uiRootParent;
AppObjConst.UIGo.SetParent(AppObjConst.FrameGo);
AppObjConst.UIGo.transform.position = new Vector3(CameraConst.UICameraPos.x, CameraConst.UICameraPos.y, 0);
InitFguiConfig();
InitFguiSettings();
InitFguiLayers();
}
private void InitEventSystem()
{
GameObject engineEventSystemGo = new GameObject("[EngineEventSystem]");
engineEventSystemGo.AddComponent<EngineEventSystem>();
engineEventSystemGo.transform.SetParent(ZooMatchCore.Instance.transform, false);
}
private void InitFguiConfig()
{
UIPackage.branch = null;
AppObjConst.UIGo.AddComponent<UIConfig>();
UIConfig.defaultFont = uiDefaultFontName;
UIConfig.enhancedTextOutlineEffect = true;
UIConfig.bringWindowToFrontOnClick = false;
UIConfig.modalLayerColor = new Color(0f, 0f, 0f, (255f / 2f) / 255f);
UIConfig.buttonSoundVolumeScale = 1;
}
private void InitFguiSettings()
{
AppObjConst.UICacheGo = new GameObject(AppObjConst.UICacheGoName);
AppObjConst.UICacheGo.SetParent(AppObjConst.FrameGo);
DisplayObject.CreateUICacheRoot(AppObjConst.UICacheGo.transform);
Stage.Instantiate();
Stage.inst.gameObject.transform.SetParent(AppObjConst.UIGo.transform, false);
Vector2Int uiResolution = AppConst.UIResolution;
GRoot.inst.SetContentScaleFactor(uiResolution.x, uiResolution.y,
UIContentScaler.ScreenMatchMode.MatchWidthOrHeight);
uiCenterPos = new Vector2(GRoot.inst.width / 2f, GRoot.inst.height / 2f);
}
private void InitFguiLayers()
{
GRoot.inst.fairyBatching = false;
for (int i = 0; i < UILayerConst.AllUILayer.Length; i++)
{
Window uiLayerWindow = new Window();
string name = UILayerConst.AllUILayer[i];
uiLayerWindow.fairyBatching = false;
uiLayerWindow.name = name;
uiLayerWindow.displayObject.name = name;
uiLayerWindow.gameObjectName = uiLayerWindow.name;
uiLayerWindow.sortingOrder = i * 100;
uiLayerWindow.Show();
uiLayerWindow.fairyBatching = false;
uiLayerWindowDict.Add(i, uiLayerWindow);
}
}
private void InitFguiCommonPackages()
{
foreach (string commonPackage in commonPackageList)
{
Debug.Log($"Load Common Package: {commonPackage}");
LoadKit.Instance.LoadAsset<TextAsset>("FGUI", $"{commonPackage}_fui.bytes",
textAsset =>
{
UIPackage.AddPackage(textAsset.bytes, commonPackage,
delegate (string s, string extension, Type type, out DestroyMethod destroyMethod)
{
destroyMethod = DestroyMethod.Unload;
return LoadKit.Instance.LoadAsset<UnityEngine.Object>("FGUI", $"{s}{extension}");
});
});
}
}
private void InitFguiMultiLanguage()
{
if (AppConst.IsMultiLangue)
{
Stage.inst.currLang = AppConst.InternalLangue;
}
}
public override void Init()
{
base.Init();
AppDispatcher.Instance.AddListener(AppMsg.InitUIMgr, (obj) =>
{
// InitReporterGo();
InitEventSystem();
InitFguiCommonPackages();
InitFguiMultiLanguage();
});
InitUIMgr();
}
public override void DisposeBefore()
{
base.DisposeBefore();
DisposeAllUI();
}
protected override void OnDestroy()
{
base.OnDestroy();
GeneralKit.Destroy(AppObjConst.UIGo);
commonPackageList.Clear();
existDynamicUIs.Clear();
tickUpdateUIs.Clear();
commonPackageList = null;
existDynamicUIs = null;
tickUpdateUIs = null;
uiSequencePool.Dispose();
uiSequenceQueue.Clear();
uiSequencePool = null;
uiSequenceQueue = null;
}
public void SetEventSystemGo(GameObject go)
{
eventSystemGo = go;
eventSystem = eventSystemGo.GetComponent<EventSystem>();
inputModule = eventSystemGo.GetComponent<StandaloneInputModule>();
}
public void SetSwitchLanguage(string switchLang)
{
if (AppConst.IsMultiLangue)
{
var multiLangueConfig =
LoadKit.Instance.LoadAsset<TextAsset>("TextAsset.I18N", "#JarvisI18N");
if (!multiLangueConfig) return;
if (string.IsNullOrWhiteSpace(multiLangueConfig.text)) return;
var multiLangueConfigList = SerializeUtil.ToObject<List<string>>(multiLangueConfig.text);
if (multiLangueConfigList == null || multiLangueConfigList.Count == 0) return;
if (string.IsNullOrWhiteSpace(switchLang)) return;
if (switchLang == Stage.inst.currLang && switchLang == AppConst.InternalLangue) return;
if (!multiLangueConfigList.Contains(switchLang)) return;
var switchLangXML = LoadKit.Instance.LoadAsset<TextAsset>("TextAsset.I18N", switchLang);
if (!switchLangXML) return;
if (string.IsNullOrWhiteSpace(switchLangXML.text)) return;
var xml = new FairyGUI.Utils.XML(switchLangXML.text);
UIPackage.SetStringsSource(xml);
Stage.inst.currLang = switchLang;
AppConst.CurrMultiLangue = switchLang;
PlayerPrefsKit.WriteObject(PrefsKeyConst.UIMgr_switchLanguage, AppConst.CurrMultiLangue);
AppDispatcher.Instance.Dispatch(AppMsg.App_SwitchLanguage);
var uiPackageList = UIPackage.GetPackages();
foreach (var packageItem in uiPackageList.Select(uiPackage => uiPackage.GetItems()).SelectMany(
packageItemList => packageItemList.Where(packageItem => packageItem.translated)))
{
packageItem.translated = false;
}
for (var i = existDynamicUIs.Count - 1; i >= 0; i--)
{
var ui = existDynamicUIs[i];
if (ui == null) continue;
if (ui.isClose) continue;
ui.ProcessFunc_SwitchLanguage();
}
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46e1248ba381a29489bc7e8d2ed09cc4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,737 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FairyGUI;
using UnityEngine;
using UnityEngine.EventSystems;
using ZooMatch;
using DG.Tweening;
namespace IgnoreOPS
{
public class WebviewManager : BaseUnityManager<WebviewManager>
{
// Vector2 startPos;
// float lastTouchTime = 0f;
// float touchInterval = 0.3f;
// void Update()
// {
// #if UNITY_IOS && !UNITY_EDITOR
// if(Input.touchCount > 0)
// {
// Touch touch_ = Input.GetTouch(0);
//
// if(touch_.phase == TouchPhase.Began)
// {
// startPos = touch_.position;
// lastTouchTime = Time.time;
// }
// if(touch_.phase == TouchPhase.Ended)
// {
// if ((Time.time - lastTouchTime) < touchInterval){
// // if (WebViewMgr.Instance.WebUIType == WebUIType.H5 && EventSystem.current.currentSelectedGameObject == null){
// // BrigdeIOS.SetTouchWebview(true, true);
// // }else{
// // BrigdeIOS.SetTouchWebview(true);
// // }
// BrigdeIOS.SetClickView();
// }
// }
// // if(touch_.phase == TouchPhase.Moved){
// // Vector2 delta = touch_.position - startPos;
// // // Debug.Log("delta Y: " + delta.y);
// // BrigdeIOS.ScrollWebview(delta.x, delta.y);
// // startPos = touch_.position;
// // }
// }
// #endif
// }
public void OpenWebView(string url)
{
//Debug.Log("[WebviewManager] OpenWebView");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.OpenWebview(url);
#endif
}
public void showDarkWebview()
{
//Debug.Log("[WebviewManager] OpenWebView");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.showDarkWebview();
#endif
}
public void CloseWebview()
{
//Debug.Log("[WebviewManager] CloseWebview");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.CloseWebview();
#endif
}
public void SetPadding(float left, float top, float right, float bottom)
{
// Debug.Log("[WebviewManager] SetPadding");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.SetPadding(left, top, right, bottom);
#endif
}
public void SetOffset(int offset_y, int offset_y1)
{
// Debug.Log($"barry [WebviewManager] SetOffset:{offset_y}, {offset_y1}");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.SetOffset(offset_y, offset_y1);
#endif
}
public void SetDarkThough(bool though)
{
if (though)
{
if (UIManager.Instance.IsExistUI(UIConst.GameResultUI) || UIManager.Instance.IsExistUI(UIConst.MakeupConfirmUI) ||
UIManager.Instance.IsExistUI(UIConst.NewTaskUI) || UIManager.Instance.IsExistUI(UIConst.PackrewardUI)
|| UIManager.Instance.IsExistUI(UIConst.PassViewUI) || UIManager.Instance.IsExistUI(UIConst.SignInViewUI) ||
UIManager.Instance.IsExistUI(UIConst.MenuUI)|| UIManager.Instance.IsExistUI(UIConst.SaveingPotUI))
{
return;
}
}
// Debug.Log("[WebviewManager] SetPadding");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.SetDarkThough(though);
#endif
}
public void SetBtn(int left, int top, int right, int bottom)
{
// Debug.Log("[WebviewManager] SetBtn");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.SetBtn(left, top, right, bottom);
#endif
}
public void SetCTEnable(bool flag)
{
// Debug.Log("[WebviewManager] SetCTEnable");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.SetCTEnable(flag);
#endif
}
public void SetFullScreen()
{
// Debug.Log("[WebviewManager] SetFullScreen");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.SetFullScreen();
#endif
}
public void addH5Field(int field1, int field2, int field3, int field4, int field5, string field6, string field7, string dark_url, string light_url, bool is_gift, string web_through_str, string click_add_time)
{
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.addH5Field(field1,field2,field3,field4,field5,field6,field7,dark_url,light_url,is_gift,web_through_str,click_add_time);
#endif
}
public void ShowH5View(bool flag)
{
// Debug.Log("[WebviewManager] SetCTEnable");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.ShowH5View(flag);
#endif
}
public void SetIconProgress(float val)
{
// Debug.Log("[WebviewManager] SetCTEnable");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.SetIconProgress(val);
#endif
}
public void setInH5View(bool flag)
{
// Debug.Log("[WebviewManager] SetCTEnable");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.setInH5View(flag);
#endif
}
public void upDataH5times(string weblink, int times, bool is_dark)
{
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.upDataH5times( weblink, times,is_dark);
#endif
}
public void ShowFlyBtn(bool flag)
{
// Debug.Log("[WebviewManager] SetCTEnable");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.ShowFlyBtn(flag);
#endif
}
public void setFlyBtnTag(bool flag)
{
// Debug.Log($"[WebviewManager] setFlyBtnTag ---{flag}");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.setFlyBtnTag(flag);
#endif
}
public void setRewardBtnTag(bool flag)
{
// Debug.Log($"[WebviewManager] setRewardBtnTag--- {flag}");
#if UNITY_IOS && !UNITY_EDITOR
BrigdeIOS.setRewardBtnTag(flag);
#endif
}
public void ObjC_TouchClick(string name)
{
// Debug.Log("Touch click: " + name);
GameDispatcher.Instance.Dispatch(GameMsg.H5ViewClickBtn, name);
}
public void H5AutoRefresh(string times)
{
if (times == "") return;
DateTime newDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
newDate = newDate.AddSeconds(GameHelper.GetNowTime());
var newDays = newDate.Day;
if (times == "Dailyrefreshtimes")
{
var last_time = PlayerPrefs.GetInt("Dayreftimes", 0);
if (last_time == newDays)
{
var numbers = PlayerPrefs.GetInt("Dailyrefreshnum", 0);
numbers++;
PlayerPrefs.SetInt("Dailyrefreshnum", numbers);
}
else
{
PlayerPrefs.SetInt("Dailyrefreshnum", 1);
PlayerPrefs.SetInt("Dayreftimes", newDays);
string darkWVRefreshtime_str = "";
string darkWVDailyrefreshtimes_str = "";
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime.Length; i++)
{
if (i != 0) darkWVRefreshtime_str += "|";
darkWVRefreshtime_str += ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime[i].ToString();
}
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime2.Length; i++)
{
darkWVRefreshtime_str += "|";
darkWVRefreshtime_str += ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime2[i].ToString();
}
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes.Length; i++)
{
if (i != 0) darkWVDailyrefreshtimes_str += "|";
darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes[i].ToString();
}
WebviewManager.Instance.addH5Field(ConfigSystem.GetConfig<CommonModel>().flyCtRate, ConfigSystem.GetConfig<CommonModel>().otherH5switch,
ConfigSystem.GetConfig<CommonModel>().H5Refreshtime, ConfigSystem.GetConfig<CommonModel>().Dailyrefreshtimes, ConfigSystem.GetConfig<CommonModel>().darkThoughProbability, darkWVRefreshtime_str,
darkWVDailyrefreshtimes_str, "", "", GameHelper.IsGiftSwitch(), "", "");
}
}
else if (times.Contains("dark_Dailyrefreshtimes"))
{
var last_time = PlayerPrefs.GetInt("dark_refreshDay", 0);
if (last_time == newDays)
{
// var numbers = PlayerPrefs.GetInt("dark_Dayref", 0);
// numbers++;
// PlayerPrefs.SetInt("dark_Dayref", numbers);
string[] temp_arr = times.Split("|");
if (temp_arr.Length >= 2)
{
SaveData.GetSaveobject().dark_Dayref[Int32.Parse(temp_arr[1])]++;
SaveData.saveDataFunc();
}
}
else
{
// PlayerPrefs.SetInt("dark_Dayref", 1);
string[] temp_arr = times.Split("|");
if (temp_arr.Length >= 2)
{
SaveData.GetSaveobject().dark_Dayref[Int32.Parse(temp_arr[1])] = 1;
SaveData.saveDataFunc();
}
PlayerPrefs.SetInt("dark_refreshDay", newDays);
string darkWVRefreshtime_str = "";
string darkWVDailyrefreshtimes_str = "";
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime.Length; i++)
{
if (i != 0) darkWVRefreshtime_str += "|";
darkWVRefreshtime_str += ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime[i].ToString();
}
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime2.Length; i++)
{
darkWVRefreshtime_str += "|";
darkWVRefreshtime_str += ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime2[i].ToString();
}
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes.Length; i++)
{
if (i != 0) darkWVDailyrefreshtimes_str += "|";
darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes[i].ToString();
}
WebviewManager.Instance.addH5Field(ConfigSystem.GetConfig<CommonModel>().flyCtRate, ConfigSystem.GetConfig<CommonModel>().otherH5switch,
ConfigSystem.GetConfig<CommonModel>().H5Refreshtime, ConfigSystem.GetConfig<CommonModel>().Dailyrefreshtimes, ConfigSystem.GetConfig<CommonModel>().darkThoughProbability, darkWVRefreshtime_str,
darkWVDailyrefreshtimes_str, "", "", GameHelper.IsGiftSwitch(), "", "");
}
}
else
{
string[] temp_array = times.Split("|");
if (temp_array.Length >= 2 && temp_array[0] != null && temp_array[0] != "")
{
if (temp_array[1] == "h5")
{
H5sendClass info = new H5sendClass() { link = temp_array[0], type = "h5" };
NetworkKit.PostWithHeader<H5refreshTimes>("event/h5Impressions", info, (isSuccess, obj) =>
{
if (isSuccess)
{
int numbers = 0;
for (int i = 0; i < ConfigSystem.light_weblist.Count; i++)
{
if (ConfigSystem.light_weblist[i].webLink == temp_array[0])
{
// Debug.Log("uuuuuuuuuuuuuuuuu明穿透" + temp_array[0] + "已经刷新了" + obj.times + "次" + "上限是" + ConfigSystem.light_weblist[i].refreshMax + "次");
numbers = ConfigSystem.light_weblist[i].refreshMax - obj.times;
break;
}
}
if (numbers < 0) numbers = 0;
upDataH5times(temp_array[0], numbers, false);
}
});
}
else
{
H5sendClass info = new H5sendClass() { link = temp_array[0], type = "h6" };
NetworkKit.PostWithHeader<H5refreshTimes>("event/h5Impressions", info, (isSuccess, obj) =>
{
if (isSuccess)
{
int numbers = 0;
for (int i = 0; i < ConfigSystem.dark_weblist.Count; i++)
{
if (ConfigSystem.dark_weblist[i].webLink == temp_array[0])
{
// Debug.Log("uuuuuuuuuuuuuuuuu暗穿透" + temp_array[0] + "已经刷新了" + obj.times + "次" + "上限是" + ConfigSystem.dark_weblist[i].refreshMax + "次");
numbers = ConfigSystem.dark_weblist[i].refreshMax - obj.times;
break;
}
}
if (numbers < 0) numbers = 0;
upDataH5times(temp_array[0], numbers, true);
}
});
}
}
}
}
private GList select_glist;
private float select_glist_y;
public void TouchClickPoint(string name)
{
// Debug.Log("TouchClickPoint" + name);
if (name == null) return;
if (name == "flyBtn")
{
NetworkKit.BuriedPoint(BuriedPointEvent.Hall_behavior, BuriedPointEvent.fly_ct_number, 1);
//NetworkKit.BuriedPoint(BuriedPointEvent.Hall_behavior,BuriedPointEvent.fly_ct_people,1);
}
if (name == "rewardBtn")
{
NetworkKit.BuriedPoint(BuriedPointEvent.Hall_behavior, BuriedPointEvent.annular_ct_number, 1);
//NetworkKit.BuriedPoint(BuriedPointEvent.Hall_behavior,BuriedPointEvent.annular_ct_people,1);
}
if (name == "finish")
{
NetworkKit.BuriedPoint(BuriedPointEvent.Hall_behavior, BuriedPointEvent.annular_finish_number, 1);
}
else
{
string[] a = name.Split("|");
if (a.Length < 2) return;
if (!float.TryParse(a[0], out float x) || !float.TryParse(a[1], out float y))
{
Debug.LogError("Invalid format for coordinates: " + name);
return;
}
Vector2 fguiScreenPos = new(x * GRoot.inst.width, y * GRoot.inst.height);
Debug.Log(a[0] + "mmmmmmmmmmmmmmmmmm" + a[1]);
Debug.Log(fguiScreenPos[0] + "mmmmmmmmmmmmmmmmmm" + fguiScreenPos[1]);
// Debug.Log("mmmmmmmmmmmmmmmmmm" + a[1]);
// if (AppConst.DeviceLangue == "pt")
// {
// fguiScreenPos = new Vector2((float.Parse(a[0]) * GRoot.inst.width) / 1000000.0f,
// float.Parse(a[1]) * GRoot.inst.height / 1000000.0f);
// }
// else
// {
//}
GButton objUnderPoint = null;
var child_array = GRoot.inst.GetChildren().Reverse();
bool click_card = true;
foreach (GComponent child in child_array) //normal
{
if (child.GetChildren().Length > 0)
{
var com_array = child.GetChildren().Reverse();
foreach (GComponent com_child in com_array) //com_层面
{
if (child.name == "Popup" || child.name == "Highest")
{
click_card = false;/* */
}
var btn_array = com_child.GetChildren();
for (int i = btn_array.Length - 1; i >= 0; i--) //btn_层面
{
// if (btn_array[i] .name=="btn_collect")
// {
// Debug.Log(btn_array[i].x);
// Debug.Log(btn_array[i].y);
// Debug.Log(fguiScreenPos.x);
// Debug.Log(fguiScreenPos.y);
// Debug.Log(btn_array[i].position.x <= fguiScreenPos.x &&
// fguiScreenPos.x <= btn_array[i].position.x + btn_array[i].width);
// Debug.Log( btn_array[i].position.y <= fguiScreenPos.y &&
// fguiScreenPos.y <= btn_array[i].position.y + btn_array[i].height);
// }
if (btn_array[i] is GButton)
{
GButton temp = btn_array[i] as GButton;
if (temp.onStage && temp.visible && temp.position.x <= fguiScreenPos.x &&
fguiScreenPos.x <= temp.position.x + temp.width &&
temp.position.y <= fguiScreenPos.y &&
fguiScreenPos.y <= temp.position.y + temp.height)
{
objUnderPoint = btn_array[i] as GButton;
if (objUnderPoint.enabled)
{
objUnderPoint.FireClick(true, true);
}
else objUnderPoint.FireClick(true, false);
goto EndLoop;
}
}
else if (btn_array[i] is GTextInput)
{
GTextInput temp = btn_array[i] as GTextInput;
if (temp.onStage && temp.visible && temp.position.x <= fguiScreenPos.x &&
fguiScreenPos.x <= temp.position.x + temp.width &&
temp.position.y <= fguiScreenPos.y &&
fguiScreenPos.y <= temp.position.y + temp.height)
{
temp.RequestFocus();
goto EndLoop;
}
}
else if (btn_array[i] is GList)
{
GList temp = btn_array[i] as GList;
if (temp.onStage && temp.visible && temp.position.x <= fguiScreenPos.x &&
fguiScreenPos.x <= temp.position.x + temp.width &&
temp.position.y <= fguiScreenPos.y &&
fguiScreenPos.y <= temp.position.y + temp.height)
{
if (select_glist == null)
{
select_glist_y = fguiScreenPos.y;
select_glist = btn_array[i] as GList;
}
else
{
select_glist.scrollPane.posY -= (fguiScreenPos.y - select_glist_y);
select_glist_y = fguiScreenPos.y;
}
goto EndLoop;
}
}
else if (btn_array[i] is GComponent)
{
var child_btn_array = btn_array[i].asCom.GetChildren(); //嵌套的com
for (int j = child_btn_array.Length - 1; j >= 0; j--)
{
if (child_btn_array[j] is GButton)
{
Vector2 local_pos = new Vector2(btn_array[i].x + child_btn_array[j].x,
btn_array[i].y + child_btn_array[j].y);
if (child_btn_array[j].visible && child_btn_array[j].onStage && child_btn_array[j].visible && local_pos.x <= fguiScreenPos.x &&
fguiScreenPos.x <= local_pos.x + child_btn_array[j].width &&
local_pos.y <= fguiScreenPos.y && fguiScreenPos.y <=
local_pos.y + child_btn_array[j].height)
{
objUnderPoint = child_btn_array[j] as GButton;
if (objUnderPoint.enabled) objUnderPoint.FireClick(true, true);
else objUnderPoint.FireClick(true, false);
goto EndLoop;
}
}
}
}
}
}
if (child.name == "Popup" || child.name == "Highest")
{
goto EndLoop;
}
}
}
EndLoop: Debug.Log("");
if (click_card)
{
if (orthoCamera == null) orthoCamera = GameObject.Find("GameCamera").GetComponent<Camera>();
Ray ray = orthoCamera.ScreenPointToRay(new Vector2(float.Parse(a[0]) * Screen.width, (1 - float.Parse(a[1])) * Screen.height));
RaycastHit hit;
int layerMask = 1 << 6;
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{
GameDispatcher.Instance.Dispatch(GameMsg.card_click, hit.collider.gameObject.name);
}
}
}
}
public Camera orthoCamera;
public static Dictionary<string, string> adCallbackInfo = new Dictionary<string, string>();
public void SendH5Event(string numbers)
{
// adCallbackInfo.Clear();
// adCallbackInfo.Add("h5_revenue",ConfigSystem.GetConfig<CommonModel>().h5_refreshRevenue.ToString());
// //Debug.Log("sssssssssssssssssss"+JsonConvert.SerializeObject(adCallbackInfo));
// AppsFlyer.sendEvent("Growing_Total_01_002",adCallbackInfo);
}
public void RefreshUrl()
{
// if (gameUrlInfo == null) return;
//TODO: show invisible h5
var Dailyrefresh_reamain = 0;
var last_time = PlayerPrefs.GetInt("Dayreftimes", 0);
DateTime newDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
newDate = newDate.AddSeconds(GameHelper.GetNowTime());
var newDays = newDate.Day;
if (last_time == newDays)
{
Dailyrefresh_reamain = ConfigSystem.GetConfig<CommonModel>().Dailyrefreshtimes -
PlayerPrefs.GetInt("Dailyrefreshnum", 0);
}
else
{
PlayerPrefs.SetInt("Dailyrefreshnum", 0);
Dailyrefresh_reamain = ConfigSystem.GetConfig<CommonModel>().Dailyrefreshtimes;
PlayerPrefs.SetInt("Dayreftimes", newDays);
}
int dark_last_time = PlayerPrefs.GetInt("dark_refreshDay", 0);
DateTime dark_newDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
dark_newDate = dark_newDate.AddSeconds(GameHelper.GetNowTime());
var dark_newDays = dark_newDate.Day;
string darkWVDailyrefreshtimes_str = "";
if (SaveData.GetSaveobject().dark_Dayref == null)
{
SaveData.GetSaveobject().dark_Dayref = new int[2];
}
if (dark_last_time == dark_newDays)
{
// dark_Dailyrefresh_reamain = ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes[Int32.Parse(webview_index) - 1] -
// PlayerPrefs.GetInt("dark_Dayref", 0);
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes.Length; i++)
{
if (i != 0) darkWVDailyrefreshtimes_str += "|";
darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes[i] - SaveData.GetSaveobject().dark_Dayref[i];
}
}
else
{
// PlayerPrefs.SetInt("dark_Dayref", 0);
for (int i = 0; i < SaveData.GetSaveobject().dark_Dayref.Length; i++)
{
SaveData.GetSaveobject().dark_Dayref[i] = 0;
}
SaveData.saveDataFunc();
// dark_Dailyrefresh_reamain = ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes[Int32.Parse(webview_index)];
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes.Length; i++)
{
if (i != 0) darkWVDailyrefreshtimes_str += "|";
darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig<CommonModel>().darkWVDailyrefreshtimes[i];
}
PlayerPrefs.SetInt("dark_refreshDay", dark_newDays);
}
// var last_login_time = PlayerPrefs.GetInt("last_login_time", 0);//获取上次登录日期
// PlayerPrefs.SetInt("last_login_time", newDays);
string light_str = "";
string dark_str = "";
for (int i = 0; i < ConfigSystem.light_weblist.Count; i++)
{
int can_refresh_numbners = 0;
// if (last_login_time==newDays)
// {
// can_refresh_numbners=ConfigSystem.light_weblist[i].refreshMax- PlayerPrefs.GetInt(ConfigSystem.light_weblist[i].webLink, 0);
// if (can_refresh_numbners < 0) can_refresh_numbners = 0;
// }
// else
// {
can_refresh_numbners = ConfigSystem.light_weblist[i].refreshMax;
//if (can_refresh_numbners < 0) can_refresh_numbners = 9999999;
// PlayerPrefs.SetInt(ConfigSystem.light_weblist[i].webLink, 0);
// }
if (i != 0)
{
light_str += "|";
}
light_str += ConfigSystem.light_weblist[i].webLink + "#" + ConfigSystem.light_weblist[i].probability + "#" + can_refresh_numbners + "#" + ConfigSystem.light_weblist[i].darkWebTimesCT; ;
}
for (int i = 0; i < ConfigSystem.dark_weblist.Count; i++)
{
int can_refresh_numbners = 0;
// if (last_login_time==newDays)
// {
// can_refresh_numbners=ConfigSystem.dark_weblist[i].refreshMax- PlayerPrefs.GetInt(ConfigSystem.dark_weblist[i].webLink, 0);
// if (can_refresh_numbners < 0) can_refresh_numbners = 0;
// }
// else
// {
can_refresh_numbners = ConfigSystem.dark_weblist[i].refreshMax;
//if (can_refresh_numbners < 0) can_refresh_numbners = 9999999;
// PlayerPrefs.SetInt(ConfigSystem.dark_weblist[i].webLink, 0);
// }
if (i != 0)
{
dark_str += "|";
}
dark_str += ConfigSystem.dark_weblist[i].webLink + "#" + ConfigSystem.dark_weblist[i].probability + "#" + can_refresh_numbners + "#" + ConfigSystem.dark_weblist[i].darkWebTimesCT + "#" + ConfigSystem.dark_weblist[i].wvType + "#" + ConfigSystem.dark_weblist[i].darkWebTimesCT2;
}
string darkWVRefreshtime_str = "";
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime.Length; i++)
{
if (i != 0) darkWVRefreshtime_str += "|";
darkWVRefreshtime_str += ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime[i].ToString();
}
for (int i = 0; i < ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime2.Length; i++)
{
darkWVRefreshtime_str += "|";
darkWVRefreshtime_str += ConfigSystem.GetConfig<CommonModel>().darkWVRefreshtime2[i].ToString();
}
Debug.Log("--------------------------------");
string add_time = ConfigSystem.GetConfig<CommonModel>().WVClickAddTime[0] + "|" + ConfigSystem.GetConfig<CommonModel>().WVClickAddTime[1];
Debug.Log(add_time);
WebviewManager.Instance.addH5Field(ConfigSystem.GetConfig<CommonModel>().flyCtRate, ConfigSystem.GetConfig<CommonModel>().otherH5switch,
ConfigSystem.GetConfig<CommonModel>().H5Refreshtime, Dailyrefresh_reamain, ConfigSystem.GetConfig<CommonModel>().darkThoughProbability
, darkWVRefreshtime_str, darkWVDailyrefreshtimes_str, dark_str, light_str, GameHelper.IsGiftSwitch(), ConfigSystem.web_through_str, add_time);
// WebviewManager.Instance.OpenWebView(gameUrlInfo.webLink);
//WebviewManager.Instance.setFlyCtRate(ConfigSystem.GetConfig<CommonModel>().flyCtRate);
// RefreshDataCT(isTop, gameUrlInfo);
}
public void ClickAdEvent(string ad_msg)
{
string[] temp_array = ad_msg.Split("|");
if (temp_array.Length >= 2 && temp_array[0] != null && temp_array[0] != "")
{
H5sendClass info = new H5sendClass() { link = temp_array[0], type = temp_array[1] };
NetworkKit.PostWithHeader<object>("/event/h5Clicks", info, (isSuccess, obj) =>
{
// if (isSuccess)
// {
// Debug.Log("dadianchenggong" + temp_array[0]);
// }
});
}
}
public void diaoyongtest(string have)
{
if (have == "TRUE") NetworkManager.haveSimCard = true;
}
}
public class H5refreshTimes
{
public string link;
public int times;
}
public class H5sendClass
{
public string link;
public string type;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7dad26fe9bc254420b9e9f663ba75b2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: