bingo 项目提交

This commit is contained in:
2026-04-20 13:49:36 +08:00
commit ad5920ac6a
5585 changed files with 1216243 additions and 0 deletions
Binary file not shown.
@@ -0,0 +1,136 @@
using System.Collections;
using UnityEngine;
using AppsFlyerSDK;
using System.Collections.Generic;
using Unity.Advertisement.IosSupport;
using BingoBrain;
using BingoBrain.Core;
using System;
using DG.Tweening;
public 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 = "6557062195";
m_Coroutine = IsfvKit.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);
}
IsfvKit.StopCoroutine(m_Coroutine);
m_Coroutine = IsfvKit.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;
}
GameHelper.PostFunnelLogin("afSend");
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("ds3rwfCqqVQYHAwt6ZJQSg", 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);
var conversionDataDictionary = AppsFlyer.CallbackStringToDictionary(conversionData);
var json = SerializeUtil.ToJsonIndented(conversionDataDictionary);
BingoBea.Instance.attribution =
conversionDataDictionary.TryGetValue("af_status", out var afStatus)
? afStatus.ToString().ToLower()
: "organic";
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
GameHelper.PostFunnelLogin("afRecv", true);
}
public void onConversionDataFail(string error)
{
if (is_init) return;
is_init = true;
AppsFlyer.AFLog("onConversionDataFail", error);
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
GameHelper.PostFunnelLogin("afRecv", false);
}
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: ada89242b4e294948bcb65153a496fcc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+53
View File
@@ -0,0 +1,53 @@
using System.Collections.Generic;
namespace BingoBrain.Core
{
public sealed class Ard : Singleton<Ard>
{
private List<InterfaceManager> allManager = new();
public void Init()
{
foreach (var manager in allManager)
{
manager.Init();
}
foreach (var manager in allManager)
{
manager.StartUp();
}
}
public void SetDar(InterfaceManager interfaceManager)
{
if (!allManager.Contains(interfaceManager))
{
allManager.Add(interfaceManager);
}
}
public void DisposeAllManager()
{
foreach (var manager in allManager)
{
manager.DisposeBefore();
}
foreach (var manager in allManager)
{
manager.Dispose();
}
Uvsjk.Destroy(OCConst.MonoManagerGo);
allManager.Clear();
}
public override void Dispose()
{
base.Dispose();
allManager.Clear();
allManager = null;
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f6a04b8a543c2964ab598fc4296d0c70
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+290
View File
@@ -0,0 +1,290 @@
using BingoBrain.Core;
using UnityEditor;
using UnityEngine.Events;
namespace BingoBrain.Asset
{
using System;
using System.Linq;
using UnityEngine;
using System.Collections.Generic;
using Object = UnityEngine.Object;
using BingoBrain.Asset.Editor;
public class BetKit : Singleton<BetKit>
{ private readonly Dictionary<string, Dictionary<int, string>> mGameObject2AbMap = new();
private readonly Dictionary<string, Dictionary<int, string>> mSprite2AbMap = new();
private readonly Dictionary<string, Dictionary<int, string>> mAudio2AbMap = new();
private IBigose LoadAssetType { get; set; }
public void Init(IBigose loadAssetType = null)
{
//#if UNITY_EDITOR
LoadAssetType = new BingoseKit();
// #else
// LoadAssetType = loadAssetType ?? new AssetBundleKit();
// #endif
}
public void LoadAsset<T>(string assetUrl, string assetName, UnityAction<T> onCompleted, bool isRecord = true)
where T : Object
{
if (string.IsNullOrEmpty(assetUrl) || string.IsNullOrEmpty(assetName))
{
Debug.LogError("AssetUrl or AssetName is Empty.");
onCompleted?.Invoke(default);
return;
}
Init();
if (LoadAssetType == null)
{
Debug.LogError("Please Call LoadBox.Instance.Init() first.");
onCompleted?.Invoke(default);
return;
}
LoadAssetType.GetAsset<T>(assetUrl, assetName, (obj) =>
{
if (obj != null && isRecord)
{
RecordGameObject(assetUrl, obj);
}
onCompleted?.Invoke(obj);
});
}
public T LoadAsset<T>(string assetUrl, string assetName, bool isRecord = true) where T : Object
{
if (string.IsNullOrEmpty(assetUrl) || string.IsNullOrEmpty(assetName))
{
Debug.LogError("AssetUrl or AssetName is Empty.");
return default;
}
Init();
if (LoadAssetType == null)
{
Debug.LogError("Please Call LoadBox.Instance.Init() first.");
return default;
}
var obj = LoadAssetType.GetAsset<T>(assetUrl, assetName);
if (obj != null && isRecord)
{
RecordGameObject(assetUrl, obj);
}
return obj;
}
#region Sprite相关
public void LoadSprite(string assetUrl, string assetName, UnityAction<Sprite> onCompleted, bool isRecord = true)
{
LoadAsset(assetUrl, assetName, onCompleted, isRecord);
}
public Sprite LoadSprite(string assetUrl, string assetName, bool isRecord = true)
{
return LoadAsset<Sprite>(assetUrl, assetName, isRecord);
}
public void LoadSprite(string assetUrl, Action<Sprite> onCompleted)
{
if (string.IsNullOrEmpty(assetUrl))
{
Debug.LogError("AssetUrl is Empty.");
onCompleted?.Invoke(null);
return;
}
Init();
if (LoadAssetType == null)
{
Debug.LogError("Please Call LoadKit.Instance.Init() first.");
onCompleted?.Invoke(null);
return;
}
string assetName;
if (assetUrl.Contains("/"))
{
assetName = assetUrl.Split('/').Last();
assetUrl = assetUrl.Replace($"/{assetName}", string.Empty);
}
else
{
assetName = assetUrl.Split('.').Last();
assetUrl = assetUrl.Replace($".{assetName}", string.Empty);
}
LoadAssetType.GetAsset(assetUrl, assetName, delegate(Sprite sprite)
{
if (sprite != null)
{
RecordSprite(assetUrl, sprite);
}
onCompleted?.Invoke(sprite);
});
}
public void RecordSprite(string assetName, Sprite sprite)
{
if (sprite == null || string.IsNullOrEmpty(assetName))
{
Debug.LogError("ABName is Null or Sprite is Null");
return;
}
var instanceId = sprite.GetInstanceID();
if (mSprite2AbMap.Keys.Contains(assetName))
{
if (!mSprite2AbMap[assetName].Keys.Contains(instanceId))
{
mSprite2AbMap[assetName].Add(instanceId, sprite.name);
}
}
else
{
var spriteNameIns = new Dictionary<int, string> { { instanceId, sprite.name } };
mSprite2AbMap.Add(assetName, spriteNameIns);
}
}
#endregion
#region GameObject相关
public GameObject LoadGameObject(string assetUrl, string assetName, bool isRecord = true)
{
return LoadAsset<GameObject>(assetUrl, assetName, isRecord);
}
public void LoadGameObjectAndClone(string assetUrl, string assetName,
UnityAction<GameObject> onCompleted = null,
Transform parent = null, bool worldPositionStays = false)
{
LoadAsset<GameObject>(assetUrl, assetName,
gameObject => { InstantiateAndRecord(gameObject, parent, worldPositionStays, onCompleted); }, false);
}
public GameObject LoadGameObjectAndCloneSync(string assetUrl, string assetName, Transform parent = null,
bool worldPositionStays = false)
{
var gameObject = LoadGameObject(assetUrl, assetName, false);
return InstantiateAndRecord(gameObject, parent, worldPositionStays);
}
public void RecordGameObject(string assetName, Object gameObject)
{
if (gameObject == null || string.IsNullOrEmpty(assetName))
{
Debug.LogError("ABName is Null or Sprite is Null");
return;
}
var instanceId = gameObject.GetInstanceID();
if (mGameObject2AbMap.Keys.Contains(assetName))
{
if (!mGameObject2AbMap[assetName].Keys.Contains(instanceId))
{
mGameObject2AbMap[assetName].Add(instanceId, gameObject.name);
}
}
else
{
var gameNameIns = new Dictionary<int, string> { { instanceId, gameObject.name } };
mGameObject2AbMap.Add(assetName, gameNameIns);
}
}
public GameObject InstantiateAndRecord(GameObject gameObject, Transform parent = null,
bool worldPositionStays = false, UnityAction<GameObject> onCompleted = null)
{
if (gameObject == null)
{
Debug.LogError("GameObject is Null");
return null;
}
var newGameObject = parent
? Object.Instantiate(gameObject, parent, worldPositionStays)
: Object.Instantiate(gameObject);
if (newGameObject != null)
{
RecordCloneGameObject(gameObject, newGameObject);
}
onCompleted?.Invoke(newGameObject);
return newGameObject;
}
private void RecordCloneGameObject(GameObject gameObject, GameObject newGameObject)
{
if (gameObject == null || newGameObject == null)
{
return;
}
var oldInstanceId = gameObject.GetInstanceID();
var instanceId = newGameObject.GetInstanceID();
foreach (var keyValuePair in mGameObject2AbMap)
{
if (!keyValuePair.Value.Keys.Contains(oldInstanceId) ||
keyValuePair.Value.Keys.Contains(instanceId)) continue;
keyValuePair.Value.Add(instanceId, newGameObject.name);
break;
}
}
#endregion
#region
public void LoadAudio(string assetUrl, string assetName, UnityAction<AudioClip> onCompleted)
{
LoadAsset(assetUrl, assetName, onCompleted);
}
#endregion
public void RecycleAsset(string assetUrl, UnityAction onCompleted = null)
{
Init();
if (LoadAssetType != null)
{
LoadAssetType.RecycleAsset(assetUrl, onCompleted);
}
else
{
Debug.LogError("Please Call LoadBox.Instance.Init() first.");
}
}
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 283019491b0d411db1c4a6967309149e
timeCreated: 1682578772
+72
View File
@@ -0,0 +1,72 @@
using System.Text;
using BingoBrain.Core;
using UnityEngine;
using UnityEditor;
using UnityEngine.Events;
using Object = UnityEngine.Object;
namespace BingoBrain.Asset.Editor
{
public class BingoseKit : Singleton<BingoseKit>, IBigose
{
private string assetRootPath = "AssetHotFix/";
public T GetAsset<T>(string assetUrl, string assetName) where T : Object
{
var assetPath = new StringBuilder(AssetPathFormat(assetUrl));
// var assetFullPath = "";
// if (assetName.EndsWith("!a.png"))
// {
// //assetFullPath = AssetPathFormat(assetUrl, assetName);
// }
// else
// {
assetName = assetName.Split(".")[0];
//}
// if (assetFullPath.IsNullOrWhiteSpace())
// {
// // Debug.LogError($"[ Jarvis ] [ AssetDataBaseKit ] 未找到该资源,请确认路径是否正确 [ {assetPath}/{assetName} ] ");
// }
var asset = Resources.Load<T>(assetPath.ToString() + "/" + assetName);
return asset;
}
public static T GetAssetstatic<T>(string assetUrl, string assetName) where T : Object
{
var assetPath = $"{"AssetHotFix/"}{assetUrl.Replace(".", "/")}";
assetName = assetName.Split(".")[0];
var asset = Resources.Load<T>(assetPath.ToString() + "/" + assetName);
return asset;
}
public void GetAsset<T>(string assetUrl, string assetName, UnityAction<T> onCompleted) where T : Object
{
var asset = GetAsset<T>(assetUrl, assetName);
onCompleted?.Invoke(asset);
}
public void RecycleAsset(string assetUrl, UnityAction onCompleted)
{
onCompleted?.Invoke();
}
private string AssetPathFormat(string assetUrl, string assetName)
{
var replace = assetUrl.Replace(".", "/");
var sb = new StringBuilder(replace);
var folderPath = sb + "/";
var assetPath = $"{assetRootPath}{folderPath}{assetName}";
return assetPath;
}
private string AssetPathFormat(string assetUrl)
{
var assetPath = $"{assetRootPath}{assetUrl.Replace(".", "/")}";
return assetPath;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ab04c207993344cca1762aee3d1e840f
timeCreated: 1683361552
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 75c9b664059ad8548943c2dcce3e3b4e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,332 @@
using FairyGUI;
using DG.Tweening;
using UnityEngine;
using UnityEngine.EventSystems;
namespace BingoBrain.Core
{
public sealed class CameraBoardk : BaseInterfaceManager<CameraBoardk>
{
public Transform mainCameraRoot;
public GameObject mainCameraGo;
public Camera mainCamera;
public Transform fguiCameraRoot;
public GameObject fguiCameraGo;
public Camera fguiCamera;
public Transform uiCameraRoot;
public GameObject uiCameraGo;
public Camera uiCamera;
public GameObject otherCameraGo;
public Camera otherCamera;
public bool isEnabledWorldRaycast;
public Physics2DRaycaster physics2DRaycaster;
public PhysicsRaycaster physics3DRaycaster;
private bool isMainCameraShakeing;
#region Coordinate
public Vector3 CameraToCameraWorldPos(Camera cameraForm, Camera cameraTo, Vector3 worldPosition)
{
Vector3 screenPosition = cameraForm.WorldToScreenPoint(worldPosition);
return cameraTo.ScreenToWorldPoint(screenPosition);
}
public Vector2 WorldPosToFGUIPos(Vector3 worldPos)
{
Vector3 screenPos = mainCamera.WorldToScreenPoint(worldPos);
screenPos.y = CenConst.CurrResolution.y - screenPos.y;
Vector2 pt = GRoot.inst.GlobalToLocal(screenPos);
return pt;
}
public Vector2 WorldPosToFGUILocalPos(Vector3 worldPos, GObject gObject)
{
Vector3 screenPos = mainCamera.WorldToScreenPoint(worldPos);
screenPos.y = Screen.height - screenPos.y;
Vector2 pt = GRoot.inst.GlobalToLocal(screenPos);
Vector2 logicScreenPos = gObject.RootToLocal(pt, GRoot.inst);
return pt;
}
public Vector3 FGUIPosToWorldPos(Vector3 fguiPos)
{
Vector2 screenPos = GRoot.inst.LocalToGlobal(fguiPos);
screenPos.y = CenConst.CurrResolution.y - screenPos.y;
Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);
return worldPos;
}
public Vector3 ScreenPosToWorldPos(Vector3 screenPos)
{
Vector3 pos = mainCamera.ScreenToWorldPoint(screenPos);
return pos;
}
public Vector2 ScreenPosToWorldPosV2(Vector3 screenPos)
{
Vector2 pos = mainCamera.ScreenToWorldPoint(screenPos);
return pos;
}
public Vector3 UIWorldCameraPosToViewportPoint(Vector3 pos)
{
Vector3 point = uiCamera.WorldToViewportPoint(pos);
return point;
}
#endregion
#region Func
public float GetCameraAdaptiveRatio()
{
float value = mainCamera.orthographicSize - (CenConst.StandardHeight / 2f / BingoConst.PixelsPerUnit);
return value;
}
public float GetHeightAdaptiveRatio()
{
float value = (Screen.height / Screen.width) -
(CenConst.StandardResolution.y / CenConst.StandardResolution.x);
return value;
}
public float GetCameraOrthographicSize(Camera camera)
{
return camera.orthographicSize;
}
public Vector2 GetCameraScreenHalfSize(Camera camera)
{
return new Vector2(camera.orthographicSize * camera.aspect, camera.orthographicSize);
}
public void BindWorldRaycaster(Physics2DRaycaster physics2DRaycaster)
{
this.physics2DRaycaster = physics2DRaycaster;
}
public void BindWorldRaycaster(PhysicsRaycaster physics3DRaycaster)
{
this.physics3DRaycaster = physics3DRaycaster;
}
public void SetWorldRaycasterEnabled(bool enabled)
{
isEnabledWorldRaycast = enabled;
if (physics2DRaycaster != null)
{
Pvds.Set2DRaycasterEnabled(physics2DRaycaster, isEnabledWorldRaycast);
}
if (physics3DRaycaster != null)
{
Pvds.Set3DRaycasterEnabled(physics3DRaycaster, isEnabledWorldRaycast);
}
AppDispatcher.Instance.Dispatch(CsjInfoC.WorldRaycast_EnableChange, isEnabledWorldRaycast);
}
public void ShakeMainCamera()
{
if (isMainCameraShakeing) return;
isMainCameraShakeing = true;
Vector3 shakeInitPos = mainCamera.transform.localPosition;
Tweener tweener = mainCamera.transform.DOShakePosition(1f, 0.2f, 100, 90, false, true);
tweener.OnComplete(() =>
{
isMainCameraShakeing = false;
mainCamera.transform.localPosition = shakeInitPos;
});
}
public void PanningFarGamePlayCamera()
{
mainCamera.orthographicSize = CenConst.OrthographicSize_1280H;
}
public void PanningNearGamePlayCamera()
{
Tweener tweener = DOTween.To(() => mainCamera.orthographicSize,
x => mainCamera.orthographicSize = x,
CenConst.OrthographicSize_1280H, 0.8f);
tweener.SetEase(Ease.InSine);
}
public bool IsPointInViewport(Camera camera, Vector3 pos)
{
Vector3 viewportPos = Camera.main.WorldToViewportPoint(pos);
if (pos.x < 0 || pos.x > 1 || pos.y < 0 || pos.y > 1)
{
return false;
}
return true;
}
public bool IsRendererInCameraViewport(Camera camera, Renderer renderer)
{
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);
return GeometryUtility.TestPlanesAABB(planes, renderer.bounds);
}
#endregion
#region Camera
public void SetCameraResolution(float width, float height)
{
ScalableBufferManager.ResizeBuffers(width, height);
}
public void CreateMainCamera()
{
if (mainCamera) return;
string name = "MainCamera";
mainCameraGo = new GameObject(name);
mainCameraGo.tag = name;
mainCameraGo.layer = AskConst.Default;
mainCameraGo.transform.localPosition = Vector3.zero;
int cullingMask = LayerMask.GetMask(AskConst.Default_Name);
mainCamera = CreateCamera(mainCameraGo, cullingMask: cullingMask);
mainCamera.clearFlags = CameraClearFlags.SolidColor;
mainCamera.forceIntoRenderTexture = false;
GameObject root = new GameObject(name + "Root");
root.transform.position = EraConst.MainCameraPos;
root.SetParent(OCConst.CameraGo);
mainCameraGo.SetParent(root);
mainCameraRoot = root.transform;
SunDgas adaptiveCom = mainCamera.gameObject.AddComponent<SunDgas>();
adaptiveCom.DoAdaptive(isOrthographic: true, orthographicSize: CenConst.OrthographicSize_1280H);
}
public void CreateFGUICamera()
{
if (fguiCamera) return;
StageCamera.CheckMainCamera();
fguiCamera = StageCamera.main;
fguiCamera.depth = EraConst.UICameraDepth;
fguiCamera.forceIntoRenderTexture = false;
fguiCameraGo = fguiCamera.gameObject;
GameObject root = new GameObject("FGUICameraRoot");
root.transform.position = EraConst.UICameraPos;
root.SetParent(OCConst.CameraGo);
fguiCameraGo.SetParent(root);
fguiCameraRoot = root.transform;
}
public void CreateUICamera()
{
if (uiCamera) return;
string name = "UICamera";
uiCameraGo = new GameObject(name);
uiCameraGo.transform.localPosition = Vector3.zero;
int cullingMask = LayerMask.GetMask(AskConst.UI_Name);
uiCamera = CreateCamera(uiCameraGo, cullingMask: cullingMask);
uiCamera.depth = EraConst.UICameraDepth;
uiCamera.forceIntoRenderTexture = false;
GameObject root = new GameObject(name + "Root");
root.transform.position = EraConst.UICameraPos;
root.SetParent(OCConst.CameraGo);
uiCameraGo.SetParent(root);
uiCameraRoot = root.transform;
SunDgas adaptiveCom = uiCamera.gameObject.AddComponent<SunDgas>();
adaptiveCom.DoAdaptive(isOrthographic: true, orthographicSize: CenConst.OrthographicSize_1280H);
}
public Camera CreateOtherCamera(Vector3 position, Vector3 rotation, bool isOrthographic_param,
float orthographicSize_param)
{
if (otherCamera) return otherCamera;
string name = "OtherCamera";
otherCameraGo = new GameObject(name);
otherCameraGo.layer = AskConst.Default;
otherCameraGo.transform.localPosition = Vector3.zero;
int cullingMask = LayerMask.GetMask(AskConst.Default_Name);
otherCamera = CreateCamera(otherCameraGo, cullingMask: cullingMask);
otherCamera.forceIntoRenderTexture = false;
GameObject root = new GameObject(name + "Root");
root.transform.position = position;
root.transform.localEulerAngles = rotation;
root.SetParent(OCConst.CameraGo);
otherCameraGo.SetParent(root);
SunDgas adaptiveCom = otherCamera.gameObject.AddComponent<SunDgas>();
adaptiveCom.DoAdaptive(isOrthographic: isOrthographic_param, orthographicSize: orthographicSize_param);
return otherCamera;
}
public Camera CreateCamera(GameObject cameraGo, int cullingMask)
{
Camera cameraCom = cameraGo.AddComponent<Camera>();
cameraCom.clearFlags = CameraClearFlags.Depth;
cameraCom.backgroundColor = Color.black;
cameraCom.cullingMask = cullingMask;
cameraCom.nearClipPlane = -30f;
cameraCom.farClipPlane = 30f;
cameraCom.rect = new Rect(0, 0, 1f, 1f);
cameraCom.depth = EraConst.MainDepth;
cameraCom.renderingPath = RenderingPath.UsePlayerSettings;
cameraCom.useOcclusionCulling = false;
cameraCom.allowHDR = false;
cameraCom.allowMSAA = false;
cameraCom.orthographicSize = 9.6f;
cameraCom.forceIntoRenderTexture = false;
return cameraCom;
}
#endregion
#region Mgr
public override void Init()
{
base.Init();
InitCameraMgr();
CreateMainCamera();
CreateFGUICamera();
}
private void InitCameraMgr()
{
OCConst.CameraGo = new GameObject(OCConst.CameraGoName);
OCConst.CameraGo.SetParent(OCConst.bfdn);
}
public override void Dispose()
{
base.Dispose();
Uvsjk.Destroy(OCConst.CameraGo);
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 45cef881d003bb84394180b075125699
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,363 @@
using System;
namespace BingoBrain.Core
{
public sealed class DateTimeBoardk : BaseInterfaceManager<DateTimeBoardk>
{
public static DateTime StartTimestampDT = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
private long HeartBeatInterval = 7;
private int FixTimeOffset = 0;
public int ServerRTTOneWayTimeOffset { get; private set; }
public long ServerTickTimestamp { get; private set; }
#region CurrTime
public long GetCurrTimestamp()
{
long timestamp = (long)(DateTime.Now - StartTimestampDT).TotalSeconds;
return timestamp;
}
public string GetCurrTimestampInfo()
{
long timestamp = (long)(DateTime.Now - StartTimestampDT).TotalSeconds;
return timestamp.ToString();
}
#endregion
#region ServerCurrTime
public void SetHeartBeatTime(int heartBeatInterval)
{
HeartBeatInterval = heartBeatInterval;
}
public long GetHeartBeatTime()
{
return HeartBeatInterval;
}
public void SetServerCurrTimestamp(long serverCurrTimestamp)
{
ServerTickTimestamp = serverCurrTimestamp;
ServerRTTOneWayTimeOffset = (int)(GetCurrTimestamp() - serverCurrTimestamp);
}
public float GetServerTimeOffset()
{
return ServerRTTOneWayTimeOffset;
}
public long GetServerTickTimestamp()
{
return ServerTickTimestamp;
}
public DateTime GetServerTickDateTime()
{
return GetDateTime(ServerTickTimestamp);
}
public long GetServerCurrTimestamp(bool isFix = false)
{
var servertimes = GetCurrTimestamp() - ServerRTTOneWayTimeOffset;
if(isFix)
{
servertimes += FixTimeOffset;
}
return servertimes;
}
public void SetTimeOffset(int offset)
{
FixTimeOffset += offset;
}
public DateTime GetServerCurrDateTime()
{
long timestamp = GetServerCurrTimestamp();
return GetDateTime(timestamp);
}
#endregion
#region Interval
public long GetCurrTimeInterval(long timestamp)
{
return timestamp - GetCurrTimestamp();
}
public long GetServerCurrTimeInterval(long timestamp)
{
return timestamp - GetServerCurrTimestamp();
}
public int GetInteralDay(ulong time)
{
ulong interal = time - (ulong)GetServerCurrTimestamp();
int day = UnityEngine.Mathf.CeilToInt(interal * 1f / (60 * 60 * 24));
return day;
}
public void GetIntervalHMS(long interval, out int hour, out int minute, out int second)
{
second = (int)(interval % 60);
int tempMinute = (int)(interval / 60);
hour = tempMinute / 60;
minute = tempMinute - (hour * 60);
}
public void GetIntervalMS(long interval, out int minute, out int second)
{
second = (int)(interval % 60);
minute = (int)(interval / 60);
}
public string GetIntervalHMSTextEn(long interval)
{
int hour, minute, second;
GetIntervalHMS(interval, out hour, out minute, out second);
return string.Format("{0:00}:{1:00}:{2:00}", hour, minute, second);
}
public string GetIntervalHMSTextCn(long interval)
{
int hour, minute, second;
GetIntervalHMS(interval, out hour, out minute, out second);
return string.Format("{0:00}{1:00}{2:00}", hour, minute, second);
}
public string GetIntervalMSTextEn(long interval)
{
int minute, second;
GetIntervalMS(interval, out minute, out second);
return string.Format("{0:00}:{1:00}", minute, second);
}
public string GetIntervalMSTextCn(long interval)
{
int minute, second;
GetIntervalMS(interval, out minute, out second);
return string.Format("{0:00}{1:00}", minute, second);
}
public string GetIntervalDateSimpleString(long interval)
{
DateTime dateTime = GetDateTime(interval);
return DateTimeToSimpleString(dateTime);
}
#endregion
#region DateTime
public DateTime GetCurrDateTime()
{
return DateTime.Now;
}
public double GetTimestamp(DateTime date)
{
return (date - StartTimestampDT).TotalSeconds;
}
public DateTime GetDateTime(long timestamp)
{
DateTime dt = StartTimestampDT.AddSeconds(timestamp);
return dt;
}
public int GetCurrTimeZone()
{
return int.Parse(GetCurrDateTime().ToString("%z"));
}
public int GetNowYear()
{
DateTime time = GetCurrDateTime();
return time.Year;
}
public int GetNowMonth()
{
DateTime time = GetCurrDateTime();
return time.Month;
}
public int GetNowDay()
{
DateTime time = GetCurrDateTime();
return time.Day;
}
public int GetNowHour()
{
DateTime time = GetCurrDateTime();
return time.Hour;
}
public int GetNowMinute()
{
DateTime time = GetCurrDateTime();
return time.Minute;
}
public int GetNowSecond()
{
DateTime time = GetCurrDateTime();
return time.Second;
}
public int GetNowMillisecond()
{
DateTime time = GetCurrDateTime();
return time.Millisecond;
}
#endregion
#region DateTimeFormat
public string DateTimeToMMdd(DateTime date)
{
return date.ToString("MM/dd");
}
public string DateTimeToYYYYMMDD(DateTime time)
{
return time.ToString("yyyyMMdd");
}
public string DateTimeToSimpleString(DateTime time)
{
return time.ToString("yyyy/MM/dd");
}
public string DateTimeToString(DateTime time)
{
return time.ToString("yyyy/MM/dd HH:mm:ss");
}
public string DateTimeToDetailString(DateTime time)
{
return time.ToString("yyyy/MM/dd HH:mm:ss:ffff dddd");
}
public DateTime GetDateTimeBy_yyyyMMddStr(string str)
{
return new DateTime(GetYearByDateStr(str), GetMonthByDateStr(str), GetDayByDateStr(str));
}
public string TimestampToString(long endTimestamp)
{
return DateTimeToString(GetDateTime(endTimestamp));
}
#endregion
#region Conversion
public float Millisecond2Second(uint millisecond)
{
if (millisecond == 0)
{
return 0f;
}
return millisecond / 1000f;
}
public double GetTimestampInMilliSecond(DateTime date)
{
return GetTimestamp(date) * 1000;
}
public string GetMSMTimeUID()
{
int minute = GetNowMinute();
int second = GetNowSecond();
int millisecond = GetNowMillisecond();
return string.Concat(minute, second, millisecond);
}
#endregion
#region Calculate
public int GetMonthDuration(string oldDate, string newDate)
{
int year = GetYearByDateStr(newDate) - GetYearByDateStr(oldDate);
int month = GetMonthByDateStr(newDate) - GetMonthByDateStr(oldDate);
return year * 12 + month;
}
public int GetMonthDuration(DateTime oldDate, DateTime newDate)
{
int year = newDate.Year - oldDate.Year;
int month = newDate.Month - oldDate.Month;
return year * 12 + month;
}
public int GetDayByDateStr(string dateStr)
{
int date = int.Parse(dateStr.Substring(6, 2));
return date;
}
public int GetMonthByDateStr(string dateStr)
{
int date = int.Parse(dateStr.Substring(4, 2));
return date;
}
public int GetYearByDateStr(string dateStr)
{
int date = int.Parse(dateStr.Substring(0, 4));
return date;
}
public DateTime FirstDayOfMonth(DateTime datetime)
{
return datetime.AddDays(1 - datetime.Day);
}
public DateTime LastDayOfMonth(DateTime datetime)
{
return datetime.AddDays(1 - datetime.Day).AddMonths(1).AddDays(-1);
}
public long GetCurrTimesTampByMillisecond()
{
long time = (long)(DateTime.Now - StartTimestampDT).TotalMilliseconds;
return time;
}
public string DateTimeToFFFString(DateTime time)
{
return time.ToString("HH:mm:ss ff");
}
public long GetServerCurrTimestampByMillisecond()
{
return GetCurrTimesTampByMillisecond() - ServerRTTOneWayTimeOffset * 1000;
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c2ef349abda84fd42801a3062464921f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,89 @@
using UnityEngine;
namespace BingoBrain.Core
{
public sealed class GameBoardk : BaseInterfaceManager<GameBoardk>
{
public bool IsPause { get; private set; }
private float pauseCacheTimeScale = 1;
#region Game
public void Restart()
{
Debug.Log("[GameMgr]Restart");
Pva.Restart();
}
public void Quit()
{
Debug.Log("[GameMgr]Quit");
Pva.Quit();
}
public void Pause()
{
Debug.Log("[GameMgr]Pause");
IsPause = true;
AppDispatcher.Instance.Dispatch(CsjInfoC.App_GamePause);
Audio.Instance.PauseAllSource();
pauseCacheTimeScale = Time.timeScale;
Time.timeScale = 0;
}
public void Resume()
{
Debug.Log("[GameMgr]Resume");
IsPause = false;
AppDispatcher.Instance.Dispatch(CsjInfoC.App_GameResume);
Audio.Instance.UnPauseAllSource();
Time.timeScale = pauseCacheTimeScale;
}
#endregion
#region Scene
public void InitialMain()
{
Debug.Log("[ BingoBrain ] [ GameMgr ] InitialMain");
SceneBoardk.Instance.InitialMain();
}
public void EnterMain()
{
Debug.Log("[GameMgr]EnterMain");
SceneBoardk.Instance.SwitchScene(SceneBoardk.DefaultMainSceneIdx);
}
#endregion Scene
#region Msg
private void AddListener()
{
}
private void RemoveListener()
{
}
#endregion Msg
#region Private
public override void Init()
{
base.Init();
AddListener();
}
public override void Dispose()
{
base.Dispose();
RemoveListener();
}
#endregion Private
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 65948735d1d6a7249a4ee2778a8867b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,310 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace BingoBrain.Core
{
public sealed class ModuleBoardk : BaseInterfaceManager<ModuleBoardk>
{
private Dictionary<string, BaseModel> modelDict = new();
private Dictionary<string, Type> uiTypeDict = new();
private Dictionary<string, BaseCtrl> ctrlDict = new();
private Dictionary<string, BaseUICtrl> uiCtrlDict = new();
public override void Init()
{
base.Init();
InitAllModule();
}
private void InitAllModule()
{
List<string> ctrlDisableList = BingoConst.CtrlDisableList;
foreach (BaseModel model in modelDict.Values)
{
model.New();
}
foreach (BaseCtrl ctrl in ctrlDict.Values)
{
if (!ctrl.isEnable)
{
continue;
}
if (ctrlDisableList.Contains(ctrl.ctrlName))
{
ctrl.isEnable = false;
continue;
}
ctrl.isEnable = true;
ctrl.New();
}
foreach (BaseUICtrl uiCtrl in uiCtrlDict.Values)
{
if (!uiCtrl.isEnable)
{
continue;
}
if (ctrlDisableList.Contains(uiCtrl.ctrlName))
{
uiCtrl.isEnable = false;
continue;
}
uiCtrl.isEnable = true;
uiCtrl.New();
}
foreach (BaseModel model in modelDict.Values)
{
model.Init();
}
foreach (BaseCtrl ctrl in ctrlDict.Values)
{
ctrl.Init();
}
foreach (BaseUICtrl uiCtrl in uiCtrlDict.Values)
{
uiCtrl.Init();
}
Debug.Log("[ BingoBrain ] [ ModuleManager ] InitModule");
}
public void StartUpAllModule()
{
foreach (BaseModel model in modelDict.Values)
{
model.StartUp();
}
foreach (BaseCtrl ctrl in ctrlDict.Values)
{
ctrl.StartUp();
}
foreach (BaseUICtrl uiCtrl in uiCtrlDict.Values)
{
uiCtrl.StartUp();
}
Debug.Log("[ BingoBrain ] [ ModuleManager ] StartUpAllModule");
}
public void AllModuleReadData()
{
foreach (BaseModel model in modelDict.Values)
{
model.ReadData();
}
foreach (BaseCtrl ctrl in ctrlDict.Values)
{
ctrl.ReadData();
}
foreach (BaseUICtrl uiCtrl in uiCtrlDict.Values)
{
uiCtrl.ReadData();
}
Debug.Log("[ BingoBrain ] [ ModuleManager ] AllModuleReadData");
}
public void AllModuleGameStart()
{
foreach (BaseModel model in modelDict.Values)
{
model.GameStart();
}
foreach (BaseCtrl ctrl in ctrlDict.Values)
{
ctrl.GameStart();
}
foreach (BaseUICtrl uiCtrl in uiCtrlDict.Values)
{
uiCtrl.GameStart();
}
}
public BaseModel GetModel(string modelName)
{
BaseModel model = null;
if (!modelDict.TryGetValue(modelName, out model))
{
Debug.LogError("[ BingoBrain ] [ ModuleManager ] No Have This Model " + modelName);
}
return model;
}
public Type GetUIType(string uiName)
{
Type uitype = null;
if (!uiTypeDict.TryGetValue(uiName, out uitype))
{
Debug.LogError("[ BingoBrain ] [ ModuleManager ] No Have this UI " + uiName);
}
return uitype;
}
public BaseCtrl GetCtrl(string ctrlName)
{
BaseCtrl ctrl = null;
if (!ctrlDict.TryGetValue(ctrlName, out ctrl))
{
Debug.LogError("[ BingoBrain ] [ ModuleManager ] No Have This Ctrl " + ctrlName);
}
return ctrl;
}
public BaseUICtrl GetUICtrl(string uiCtrlName)
{
BaseUICtrl uiCtrl = null;
if (!uiCtrlDict.TryGetValue(uiCtrlName, out uiCtrl))
{
Debug.LogError("[ BingoBrain ] [ ModuleManager ] No Have This UICtrl " + uiCtrlName);
}
return uiCtrl;
}
public void SetActiveCtrl(string ctrlName, bool isEnable)
{
BaseCtrl ctrl = GetCtrl(ctrlName);
if (isEnable)
{
if (!ctrl.isEnable && !ctrl.IsNew)
{
ctrl.isEnable = true;
ctrl.New();
ctrl.Init();
ctrl.StartUp();
}
}
else
{
if (ctrl.isEnable && ctrl.IsNew)
{
ctrl.isEnable = false;
ctrl.Dispose();
}
}
}
public void SetActiveUICtrl(string uiCtrlName, bool isEnable)
{
BaseUICtrl uiCtrl = GetUICtrl(uiCtrlName);
if (isEnable)
{
if (!uiCtrl.isEnable && !uiCtrl.IsNew)
{
uiCtrl.isEnable = true;
uiCtrl.New();
uiCtrl.Init();
uiCtrl.StartUp();
}
}
else
{
if (uiCtrl.isEnable && uiCtrl.IsNew)
{
uiCtrl.isEnable = false;
uiCtrl.Dispose();
}
}
}
public void ResetModel(string modelName)
{
BaseModel model = GetModel(modelName);
model.Reset();
}
public void AddModel(string modelName, BaseModel model)
{
model.modelName = modelName;
modelDict[modelName] = model;
}
public void AddUIType(string uiName, Type uiType)
{
uiTypeDict[uiName] = uiType;
}
public void AddCtrl(string ctrlName, BaseCtrl ctrl)
{
ctrl.ctrlName = ctrlName;
ctrlDict[ctrlName] = ctrl;
}
public void AddUICtrl(string ctrlName, BaseUICtrl uiCtrl)
{
uiCtrl.ctrlName = ctrlName;
uiCtrlDict[ctrlName] = uiCtrl;
}
public void ResetAllModel()
{
foreach (BaseModel model in modelDict.Values)
{
model.Reset();
}
}
public void DisposeAllModel()
{
foreach (BaseModel model in modelDict.Values)
{
model.Dispose();
}
modelDict.Clear();
}
public void DisposeAllCtrl()
{
foreach (BaseCtrl ctrl in ctrlDict.Values)
{
ctrl.Dispose();
}
foreach (BaseUICtrl uiCtrl in uiCtrlDict.Values)
{
uiCtrl.Dispose();
}
ctrlDict.Clear();
uiCtrlDict.Clear();
}
public void DisposeAllModule()
{
DisposeAllModel();
DisposeAllCtrl();
}
public override void Dispose()
{
base.Dispose();
modelDict = null;
uiTypeDict = null;
ctrlDict = null;
uiCtrlDict = null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eeedf720d335ccb4fa1e3d3497001ec3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,88 @@
using System.Collections.Generic;
using UnityEngine;
namespace BingoBrain.Core
{
public sealed class SceneBoardk : BaseInterfaceManager<SceneBoardk>
{
public const int DefaultMainSceneIdx = 0;
private Dictionary<int, BaseScene> sceneDict = new();
private BaseScene m_currScene;
public void AddScene(BaseScene scene)
{
if (!sceneDict.ContainsKey(scene.SceneIdx))
{
sceneDict[scene.SceneIdx] = scene;
}
}
public void InitialMain(object param = null)
{
if (sceneDict.Count == 0) return;
BaseScene scene = GetScene(DefaultMainSceneIdx);
if (SetScene(scene))
{
SceneSwitch.Instance.SwitchInitialScene(DefaultMainSceneIdx, scene.SwchSneCote, param);
}
}
public void SwitchScene(int sceneIdx, object param = null)
{
BaseScene scene = GetScene(sceneIdx);
if (SetScene(scene))
{
UI.Instance.SwitchSceneCloseAllUI();
SceneSwitch.Instance.SwitchScene(sceneIdx, scene.SwchSneCote, param);
}
}
private bool SetScene(BaseScene scene)
{
if (scene == null)
{
Debug.LogError("[SceneMgr]Set Scene Failed: Scene Is Null");
return false;
}
else if (scene == m_currScene)
{
Debug.LogError("[SceneMgr]Set Scene Failed: Switch Repetitive Scene");
return false;
}
if (m_currScene != null)
{
m_currScene.Leave();
}
m_currScene = scene;
m_currScene.Enter();
return true;
}
private BaseScene GetScene(int sceneIdx)
{
BaseScene scene = null;
if (!sceneDict.TryGetValue(sceneIdx, out scene))
{
Debug.LogError("[SceneMgr]No Have This Scene: " + sceneIdx);
}
return scene;
}
public override void Dispose()
{
base.Dispose();
foreach (BaseScene scene in sceneDict.Values)
{
scene.Dispose();
}
sceneDict.Clear();
sceneDict = null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c5e07bf3e2b867c4b9d7776206acc020
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+65
View File
@@ -0,0 +1,65 @@
using System.IO;
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
using UnityEngine.Networking;
namespace BingoBrain.Asset
{
public class CachKit
{
/// <summary>
/// 保存文本文件
/// </summary>
/// <param name="content"></param>
/// <param name="filePath"></param>
/// <param name="fileName"></param>
private static void SaveTextFile(string content, string filePath, string fileName)
{
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
File.WriteAllText($"{filePath}{fileName}.txt", content);
}
/// <summary>
/// 下载文本文件
/// </summary>
/// <param name="url"></param>
/// <param name="fileName"></param>
/// <param name="action"></param>
/// <param name="isSave"></param>
/// <returns></returns>
public static IEnumerator GetTextFromUrl(string url, string fileName, UnityAction<string> action = null,
string savePath = null, bool isSave = true)
{
var unityWebRequest = UnityWebRequest.Get(url);
yield return unityWebRequest.SendWebRequest();
if (unityWebRequest.result is UnityWebRequest.Result.ConnectionError
or UnityWebRequest.Result.ProtocolError)
{
Debug.LogError($"加载 [ {fileName} ] 文本文件失败 {unityWebRequest.error} [ url: {url} ]");
action?.Invoke(default);
yield break;
}
var content = unityWebRequest.downloadHandler.text;
if (isSave)
{
savePath ??= GetAssetSavePath();
SaveTextFile(content, savePath, fileName);
}
action?.Invoke(content);
}
public static string GetAssetSavePath()
{
return $"{Application.persistentDataPath}/BingoBase/";
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fe2634714606b7443a3b12c2393423fd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+70
View File
@@ -0,0 +1,70 @@
using UnityEngine;
using System.Collections.Generic;
using BingoBrain;
public class ErrorLogger : MonoBehaviour
{
// 用于存储报错信息的列表
void OnEnable()
{
// 注册事件处理函数
Application.logMessageReceived += HandleLog;
}
void OnDisable()
{
// 注销事件处理函数
Application.logMessageReceived -= HandleLog;
}
// 事件处理函数
void HandleLog(string logString, string stackTrace, LogType type)
{
// 只处理错误和异常类型的日志
if (type == LogType.Error || type == LogType.Exception)
{
// 这里可以添加代码将报错信息发送给服务器
SendErrorToServer(logString, stackTrace, type);
}
}
// 示例函数,展示如何将报错信息发送给服务器
void SendErrorToServer(string error, string stackTrace, LogType type)
{
// Debug.Log(error);
// Debug.Log(stackTrace);
GameHelper.SendLogToServer(error, stackTrace, type);
// 这里填写将报错信息发送到服务器的代码
}
}
namespace DontConfuse
{
public class ErrorClass
{
public long uid;
public string device;
public string os_ver;
public string network;
public string device_id;
public string pack_name;
public string version;
public string channel;
public string level;
public string message;
public string stacktrace;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fc07076291cb048e184fc5b653cbeb0e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+21
View File
@@ -0,0 +1,21 @@
namespace BingoBrain.Core
{
public class ExiteValue<T>
{
public T oldValue;
public T newValue;
public ExiteValue()
{
}
public ExiteValue(T oldValue, T newValue)
{
this.oldValue = oldValue;
this.newValue = newValue;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c53b34a8fdfa77143b24d0660057d5a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,89 @@
using System.Text;
using UnityEngine;
namespace BingoBrain.Core
{
public static class GameObjectExtend
{
public static void SetParent(this GameObject gameObject, GameObject parentGo, bool worldPositionStays = false)
{
if (parentGo)
{
gameObject.transform.SetParent(parentGo.transform, worldPositionStays);
}
}
public static void SetParent(this GameObject gameObject, Transform parentTf, bool worldPositionStays = false)
{
if (parentTf)
{
gameObject.transform.SetParent(parentTf, worldPositionStays);
}
}
public static void SetLayer(this GameObject gameObject, string layerName)
{
Transform[] transArr = gameObject.transform.GetComponentsInChildren<Transform>();
for (int i = 0; i < transArr.Length; i++)
{
transArr[i].gameObject.layer = LayerMask.NameToLayer(layerName);
}
}
public static void SetLayer(this GameObject gameObject, LayerMask layer)
{
Transform[] transArr = gameObject.transform.GetComponentsInChildren<Transform>();
for (int i = 0; i < transArr.Length; i++)
{
transArr[i].gameObject.layer = layer;
}
}
public static void DestroyAllChild(this GameObject gameObject)
{
foreach (Transform child in gameObject.transform)
{
Object.Destroy(child.gameObject);
}
}
public static T GetSoleComponent<T>(this GameObject gameObject) where T : Component
{
T component = gameObject.GetComponent<T>();
if (component == null) component = gameObject.AddComponent<T>();
return component;
}
public static string GetGameObjectRelativePath(this GameObject gameObject, GameObject child)
{
string parentPath = gameObject.GetGameObjectPath();
string childPath = child.GetGameObjectPath();
if (childPath.StartsWith(parentPath))
{
return childPath.Remove(0, parentPath.Length + 1);
}
else
{
return string.Empty;
}
}
public static string GetGameObjectPath(this GameObject gameObject)
{
Transform transform = gameObject.transform;
StringBuilder sb = new StringBuilder();
sb.Append(transform.name);
while (transform.parent != null)
{
transform = transform.parent;
sb.Insert(0, transform.name + "/");
}
return sb.ToString();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f33a4adea56c7dc41944ee83d4ef3f84
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+14
View File
@@ -0,0 +1,14 @@
using UnityEngine.Events;
using Object = UnityEngine.Object;
namespace BingoBrain.Asset
{
public interface IBigose
{
T GetAsset<T>(string assetUrl, string assetName) where T : Object;
void GetAsset<T>(string assetUrl, string assetName, UnityAction<T> onCompleted) where T : Object;
void RecycleAsset(string assetUrl, UnityAction onCompleted);
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4f5f73f6c2c342f9a9ee2cae54688486
timeCreated: 1682576608
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f14f42c47ff29474bb4170a49c3bc8c1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
namespace BingoBrain.HotFix
{
public static partial class BingoInfo
{
public const string NAME = "BingoInfo";
public const uint BASE = 0;
private static uint Cursor_BASE = BASE;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7d7b577419d940f468e1a95a9afb1dd9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+62
View File
@@ -0,0 +1,62 @@
public static class CsjInfoC
{
public const uint BASE = 3333;
private static uint Cursor_BASE = BASE;
public static readonly uint App_Quit = ++Cursor_BASE;
public static readonly uint App_Focus_False = ++Cursor_BASE;
public static readonly uint App_Pause_True = ++Cursor_BASE;
public static readonly uint App_GamePause = ++Cursor_BASE;
public static readonly uint App_GameResume = ++Cursor_BASE;
public static readonly uint App_SwitchLanguage = ++Cursor_BASE;
public static readonly uint UI_DisplayLoadingUI = ++Cursor_BASE;
public static readonly uint UI_HideLoadingUI = ++Cursor_BASE;
public static readonly uint UI_LoadingInitAsset = ++Cursor_BASE;
public static readonly uint AppManagerRegister = ++Cursor_BASE;
public static readonly uint InitUIMgr = ++Cursor_BASE;
public static readonly uint UIEvent_UIOpen = ++Cursor_BASE;
public static readonly uint UIEvent_UIClose = ++Cursor_BASE;
public static readonly uint UIEvent_UIDisplay = ++Cursor_BASE;
public static readonly uint UIEvent_UIHide = ++Cursor_BASE;
public static readonly uint KeyCode_Home = ++Cursor_BASE;
public static readonly uint KeyCode_Escape = ++Cursor_BASE;
public static readonly uint TimeScale_Change = ++Cursor_BASE;
public static readonly uint WorldRaycast_EnableChange = ++Cursor_BASE;
public static readonly uint LoginInit = ++Cursor_BASE;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2b87eaa2cadb1da4f8dba83b0b9d3731
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+12
View File
@@ -0,0 +1,12 @@
public static class GinInfoC
{
public const string NAME = "MainThreadMsg";
public const uint BASE = 0;
private static uint Cursor_BASE = BASE;
public static readonly uint App_Focus_True = ++Cursor_BASE;
public static readonly uint App_Pause_False = ++Cursor_BASE;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0061a4ff521ce154c8ca284f91d1cf8f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
namespace BingoBrain
{
public static partial class SkinInfo
{
public const string NAME = "SkinInfo";
public const uint BASE = 0;
private static uint Cursor_BASE = BASE;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb50862938136744db6a10a950ab4a27
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f45f78800937eda4280b97dc62745da6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,147 @@
using BingoBrain;
namespace BingoBrain.Core
{
using System;
using UnityEngine;
using System.Collections.Generic;
internal class IsfvBehaviour : SingletonUnity<IsfvBehaviour>
{
private readonly Dictionary<string, IsfvData> _asyncDataDict = new Dictionary<string, IsfvData>();
private readonly Dictionary<string, IsfvData> _asyncTmpDataDict = new Dictionary<string, IsfvData>();
private readonly Dictionary<string, IsfvData> _updateActionDict = new Dictionary<string, IsfvData>();
private readonly List<string> _keyClean = new List<string>();
private void Update()
{
_asyncTmpDataDict.ForEachSafe((s, data) => data.PassTime(Time.deltaTime));
_asyncDataDict.ForEachSafe((s, data) => data.PassTime(Time.deltaTime));
try
{
_updateActionDict.ForEachSafe((k, v) => { v?.dealMethod?.Invoke(); });
}
catch (Exception)
{
}
ClearTempFinished();
ClearFinished();
ClearUpdateActionFinished();
}
private void ClearFinished()
{
_keyClean.Clear();
foreach (var dealData in _asyncDataDict)
{
if (dealData.Value.IsComplete)
{
_keyClean.Add(dealData.Key);
}
}
foreach (var key in _keyClean)
{
_asyncDataDict.Remove(key);
}
}
private void ClearTempFinished()
{
_keyClean.Clear();
foreach (var dealData in _asyncTmpDataDict)
{
if (dealData.Value.IsComplete)
{
_keyClean.Add(dealData.Key);
}
}
foreach (var key in _keyClean)
{
_asyncTmpDataDict.Remove(key);
}
}
public void AddAsyncData(string key, IsfvData isfvData)
{
RemoveAsyncData(key);
_asyncDataDict.Add(key, isfvData);
}
public void AddAsyncTempData(string key, IsfvData isfvData)
{
RemoveAsyncTempData(key);
_asyncTmpDataDict.Add(key, isfvData);
}
public void RemoveAsyncTempData(string key)
{
if (_asyncTmpDataDict.ContainsKey(key))
{
_asyncTmpDataDict.Remove(key);
}
}
public void RemoveAsyncData(string key)
{
if (_asyncDataDict.ContainsKey(key))
{
_asyncDataDict.Remove(key);
}
}
public void AddUpdateAction(string key, IsfvData isfvData)
{
RemoveAsyncData(key);
_updateActionDict.Add(key, isfvData);
}
public void RemoveUpdateAction(string key)
{
if (_updateActionDict.ContainsKey(key))
{
_updateActionDict.Remove(key);
}
}
public void ClearUpdateActionFinished()
{
_keyClean.Clear();
foreach (var dealData in _updateActionDict)
{
if (dealData.Value.IsComplete)
{
_keyClean.Add(dealData.Key);
}
}
foreach (var key in _keyClean)
{
_updateActionDict.Remove(key);
}
}
public void RemoveAllAction()
{
_updateActionDict.Clear();
_asyncDataDict.Clear();
_asyncTmpDataDict.Clear();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 984d18c5a4974e729d72276896426930
timeCreated: 1682577036
+52
View File
@@ -0,0 +1,52 @@
namespace BingoBrain.Core
{
public class IsfvData
{
public delegate void DealMethod();
private float _currentTime;
public float DelayTime = 1f;
public DealMethod dealMethod;
public int RepeatCount = 1;
public bool IsComplete => RepeatCount == 0;
public void PassTime(float time)
{
_currentTime += time;
if (!(_currentTime >= DelayTime))
{
return;
}
_currentTime -= DelayTime;
Run();
}
private void Run()
{
if (RepeatCount == -1)
{
dealMethod?.Invoke();
}
else
{
if (RepeatCount > 0)
{
dealMethod?.Invoke();
RepeatCount--;
}
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4e51ff91679a44d1b1efe3438d508e74
timeCreated: 1682577036
+139
View File
@@ -0,0 +1,139 @@
using System;
namespace BingoBrain.Core
{
using UnityEngine;
using System.Collections;
public static class IsfvKit
{
private static IsfvBehaviour _sIsfvBehaviour;
private static readonly object SynClock = new object();
private static IsfvBehaviour MIsfvBehaviour
{
get
{
if (_sIsfvBehaviour != null)
{
return _sIsfvBehaviour;
}
lock (SynClock)
{
if (_sIsfvBehaviour != null)
{
return _sIsfvBehaviour;
}
_sIsfvBehaviour = IsfvBehaviour.Instance;
if (_sIsfvBehaviour != null)
{
_sIsfvBehaviour.name = "[ AsyncKit ]";
}
}
return _sIsfvBehaviour;
}
}
public static Coroutine StartCoroutine(IEnumerator enumerator)
{
return MIsfvBehaviour.StartCoroutine(enumerator);
}
public static void StopCoroutine(Coroutine methodName)
{
MIsfvBehaviour.StopCoroutine(methodName);
}
public static void StopAllCoroutine()
{
MIsfvBehaviour.StopAllCoroutines();
}
public static void StartAction(string key, IsfvData.DealMethod method, float delayTime, int repeat = 1)
{
var temp = new IsfvData { dealMethod = method, DelayTime = delayTime, RepeatCount = repeat };
MIsfvBehaviour.AddAsyncData(key, temp);
}
public static void StopAction(string key)
{
MIsfvBehaviour.RemoveAsyncData(key);
}
public static void StopAllAction()
{
MIsfvBehaviour.RemoveAllAction();
}
public static void StartUpdateAction(string key, IsfvData.DealMethod method, float time)
{
var temp = new IsfvData { dealMethod = method, DelayTime = time, RepeatCount = -1 };
MIsfvBehaviour.AddUpdateAction(key, temp);
}
public static void StopUpdateAction(string key)
{
MIsfvBehaviour.RemoveUpdateAction(key);
}
public static void DelayedAction(float delayTime, IsfvData.DealMethod method, int repeat = 1,
string key = null)
{
key ??= $"{nameof(DelayedAction)}{DateTime.Now.Millisecond}";
var temp = new IsfvData
{
dealMethod = () =>
{
method?.Invoke();
ClearDelayedAction(key);
},
DelayTime = delayTime, RepeatCount = repeat
};
MIsfvBehaviour.AddAsyncTempData(key, temp);
}
public static void ClearDelayedAction(string key)
{
MIsfvBehaviour.RemoveAsyncTempData(key);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 93122ca4429e463aba586a345558ed8e
timeCreated: 1682577036
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 10e424129050f3a4ab3fdc991bf91318
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+123
View File
@@ -0,0 +1,123 @@
namespace BingoBrain.Core
{
public abstract class BaseCtrl
{
public string ctrlName;
public bool isEnable = true;
public bool IsNew { get; private set; }
protected ModuleBoardk ModuleBoardk;
protected ModelDispatcher modelDispatcher;
protected CtrlDispatcher ctrlDispatcher;
protected UICtrlDispatcher uiCtrlDispatcher;
protected DataDispatcher dataDispatcher;
protected GameDispatcher gameDispatcher;
public void New()
{
if (!isEnable) return;
OnNew();
IsNew = true;
}
public virtual void Init()
{
if (!isEnable) return;
Assignment();
AddListener();
AddServerListener();
OnInit();
}
public virtual void StartUp()
{
if (!isEnable) return;
OnStartUp();
}
public void ReadData()
{
OnReadData();
}
public virtual void GameStart()
{
if (!isEnable) return;
OnGameStart();
}
public virtual void Dispose()
{
if (!isEnable) return;
RemoveListener();
RemoveServerListener();
OnDispose();
UnAssignment();
IsNew = false;
}
protected virtual void Assignment()
{
ModuleBoardk = ModuleBoardk.Instance;
modelDispatcher = ModelDispatcher.Instance;
ctrlDispatcher = CtrlDispatcher.Instance;
uiCtrlDispatcher = UICtrlDispatcher.Instance;
dataDispatcher = DataDispatcher.Instance;
gameDispatcher = GameDispatcher.Instance;
}
protected virtual void UnAssignment()
{
ModuleBoardk = null;
modelDispatcher = null;
ctrlDispatcher = null;
uiCtrlDispatcher = null;
dataDispatcher = null;
gameDispatcher = null;
}
protected virtual void OnNew()
{
}
protected abstract void OnInit();
protected virtual void OnStartUp()
{
}
protected virtual void OnReadData()
{
}
protected virtual void OnGameStart()
{
}
protected abstract void OnDispose();
protected virtual void AddListener()
{
}
protected virtual void RemoveListener()
{
}
protected virtual void AddServerListener()
{
}
protected virtual void RemoveServerListener()
{
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b81051b63111ae24091f178cd25ab0a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,242 @@
using System;
using UnityEngine;
using System.Collections.Generic;
namespace BingoBrain.Core
{
public abstract class BaseDispatcher<T, Msg, Param> : IDisposable where T : class, new() where Param : class
{
private static T m_instance;
public static T Instance
{
get
{
if (m_instance == null)
{
m_instance = new T();
}
return m_instance;
}
}
private Dictionary<Msg, List<Action<Param>>> m_msgPriorityDict = new();
private Dictionary<Msg, List<Action<Param>>> m_msgDict = new();
private Dictionary<Msg, List<Action<Param>>> m_msgFinallyDict = new();
private Dictionary<Msg, List<Action<Param>>> m_msgOnceDict = new();
public void AddPriorityListener(Msg msgId, Action<Param> listener)
{
if (m_msgPriorityDict.TryGetValue(msgId, out var value))
{
value.Add(listener);
}
else
{
var list = Uncc<Action<Param>>.Get();
list.Add(listener);
m_msgPriorityDict.Add(msgId, list);
}
}
public void AddListener(Msg msgId, Action<Param> listener)
{
if (m_msgDict.TryGetValue(msgId, out var value))
{
value.Add(listener);
}
else
{
var list = Uncc<Action<Param>>.Get();
list.Add(listener);
m_msgDict.Add(msgId, list);
}
}
public void AddFinallyListener(Msg msgId, Action<Param> listener)
{
if (m_msgFinallyDict.TryGetValue(msgId, out var value))
{
value.Add(listener);
}
else
{
var list = Uncc<Action<Param>>.Get();
list.Add(listener);
m_msgFinallyDict.Add(msgId, list);
}
}
public void AddOnceListener(Msg msgId, Action<Param> listener)
{
if (m_msgOnceDict.TryGetValue(msgId, out var value))
{
value.Add(listener);
}
else
{
var list = Uncc<Action<Param>>.Get();
list.Add(listener);
m_msgOnceDict.Add(msgId, list);
}
}
private bool ContainsListener(Msg msgId, Action<Param> listener, Dictionary<Msg, List<Action<Param>>> msgDict)
{
return msgDict.TryGetValue(msgId, out var list) && list.Contains(listener);
}
private bool ContainsPriorityListener(Msg msgId, Action<Param> listener)
{
return ContainsListener(msgId, listener, m_msgPriorityDict);
}
private bool ContainsListener(Msg msgId, Action<Param> listener)
{
return ContainsListener(msgId, listener, m_msgDict);
}
private bool ContainsFinallyListener(Msg msgId, Action<Param> listener)
{
return ContainsListener(msgId, listener, m_msgFinallyDict);
}
private bool ContainsOnceListener(Msg msgId, Action<Param> listener)
{
return ContainsListener(msgId, listener, m_msgOnceDict);
}
public void RemovePriorityListener(Msg msgId, Action<Param> listener)
{
if (m_msgPriorityDict.TryGetValue(msgId, out var list))
{
if (list.Contains(listener))
{
list.Remove(listener);
if (list.Count == 0)
{
Uncc<Action<Param>>.Release(list);
m_msgPriorityDict.Remove(msgId);
}
}
}
}
public void RemoveListener(Msg msgId, Action<Param> listener)
{
if (m_msgDict.TryGetValue(msgId, out var list))
{
if (list.Contains(listener))
{
list.Remove(listener);
if (list.Count == 0)
{
Uncc<Action<Param>>.Release(list);
m_msgDict.Remove(msgId);
}
}
}
}
public void RemoveFinallyListener(Msg msgId, Action<Param> listener)
{
if (m_msgFinallyDict.TryGetValue(msgId, out var list))
{
if (list.Contains(listener))
{
list.Remove(listener);
if (list.Count == 0)
{
Uncc<Action<Param>>.Release(list);
m_msgFinallyDict.Remove(msgId);
}
}
}
}
public void RemoveOnceListener(Msg msgId, Action<Param> listener)
{
if (m_msgOnceDict.ContainsKey(msgId))
{
List<Action<Param>> list = m_msgOnceDict[msgId];
if (list.Contains(listener))
{
list.Remove(listener);
if (list.Count == 0)
{
Uncc<Action<Param>>.Release(list);
m_msgOnceDict.Remove(msgId);
}
}
}
}
public void Dispatch(Msg msgId, Param param = null)
{
InvokeMethods(m_msgPriorityDict, msgId, param);
InvokeMethods(m_msgDict, msgId, param);
InvokeMethods(m_msgFinallyDict, msgId, param);
InvokeMethods(m_msgOnceDict, msgId, param);
if (m_msgOnceDict.ContainsKey(msgId))
{
Uncc<Action<Param>>.Release(m_msgOnceDict[msgId]);
m_msgOnceDict.Remove(msgId);
}
}
private void InvokeMethods(Dictionary<Msg, List<Action<Param>>> msgDict, Msg msgId, Param param)
{
if (!msgDict.ContainsKey(msgId)) return;
var rawList = msgDict[msgId];
int funcCount = rawList.Count;
if (funcCount == 1)
{
Action<Param> onEvent = rawList[0];
onEvent(param);
return;
}
var invokeFuncs = Uncc<Action<Param>>.Get();
invokeFuncs.AddRange(rawList);
for (var i = 0; i < funcCount; i++)
{
try
{
var onEvent = invokeFuncs[i];
onEvent(param);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
Uncc<Action<Param>>.Release(invokeFuncs);
}
public void Clear()
{
m_msgPriorityDict.Clear();
m_msgDict.Clear();
m_msgFinallyDict.Clear();
m_msgOnceDict.Clear();
}
public void Dispose()
{
m_instance = null;
m_msgPriorityDict.Clear();
m_msgDict.Clear();
m_msgFinallyDict.Clear();
m_msgOnceDict.Clear();
m_msgPriorityDict = null;
m_msgDict = null;
m_msgFinallyDict = null;
m_msgOnceDict = null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c4b55125cefc9754888cccfc76bee4c9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,59 @@
using System;
namespace BingoBrain.Core
{
public abstract class BaseInterfaceManager<T> : IDisposable, InterfaceManager where T : BaseInterfaceManager<T>, new()
{
public bool IsInit { get; private set; }
public bool IsStartUp { get; private set; }
public bool IsDispose { get; private set; }
private static T m_instance;
public static T Instance
{
get
{
if (m_instance == null)
{
m_instance = new T();
m_instance.New();
}
return m_instance;
}
}
public BaseInterfaceManager()
{
}
protected virtual void New()
{
IsDispose = false;
}
public virtual void Init()
{
IsInit = true;
}
public virtual void StartUp()
{
IsStartUp = true;
}
public virtual void DisposeBefore()
{
IsDispose = true;
IsInit = false;
IsStartUp = false;
}
public virtual void Dispose()
{
m_instance = null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0395f071bf7ad864083ee86433bcec9b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,224 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace BingoBrain.Core
{
public class BaseMainThreadDispatcher<T, Msg, Param> : SingletonUnity<T>
where T : SingletonUnity<T>
where Param : class
{
private class MainThreadMsgClass
{
public Msg currMsgId;
public Param currParam;
}
private Queue<MainThreadMsgClass> m_msgQueue = new Queue<MainThreadMsgClass>();
private Dictionary<Msg, List<Action<Param>>> m_msgPriorityDict = new Dictionary<Msg, List<Action<Param>>>();
private Dictionary<Msg, List<Action<Param>>> m_msgDict = new Dictionary<Msg, List<Action<Param>>>();
private Dictionary<Msg, List<Action<Param>>> m_msgOnceDict = new Dictionary<Msg, List<Action<Param>>>();
private object m_queueLock = new object();
private void Update()
{
if (m_msgQueue.Count <= 0) return;
while (m_msgQueue.Count > 0)
{
MainThreadMsgClass msg;
lock (m_queueLock)
{
msg = m_msgQueue.Dequeue();
}
AutoDispatch(msg.currMsgId, msg.currParam);
}
}
public void AddPriorityListener(Msg msgId, Action<Param> listener)
{
if (m_msgPriorityDict.ContainsKey(msgId))
{
m_msgPriorityDict[msgId].Add(listener);
}
else
{
List<Action<Param>> list = Uncc<Action<Param>>.Get();
list.Add(listener);
m_msgPriorityDict.Add(msgId, list);
}
}
public void AddListener(Msg msgId, Action<Param> listener)
{
if (m_msgDict.ContainsKey(msgId))
{
m_msgDict[msgId].Add(listener);
}
else
{
List<Action<Param>> list = Uncc<Action<Param>>.Get();
list.Add(listener);
m_msgDict.Add(msgId, list);
}
}
public void AddOnceListener(Msg msgId, Action<Param> listener)
{
if (m_msgOnceDict.ContainsKey(msgId))
{
m_msgOnceDict[msgId].Add(listener);
}
else
{
List<Action<Param>> list = Uncc<Action<Param>>.Get();
list.Add(listener);
m_msgOnceDict.Add(msgId, list);
}
}
public void RemovePriorityListener(Msg msgId, Action<Param> listener)
{
if (m_msgPriorityDict.ContainsKey(msgId))
{
List<Action<Param>> list = m_msgPriorityDict[msgId];
if (list.Contains(listener))
{
list.Remove(listener);
if (list.Count == 0)
{
Uncc<Action<Param>>.Release(list);
m_msgPriorityDict.Remove(msgId);
}
}
}
}
public void RemoveListener(Msg msgId, Action<Param> listener)
{
if (m_msgDict.ContainsKey(msgId))
{
List<Action<Param>> list = m_msgDict[msgId];
if (list.Contains(listener))
{
list.Remove(listener);
if (list.Count == 0)
{
Uncc<Action<Param>>.Release(list);
m_msgDict.Remove(msgId);
}
}
}
}
public void RemoveOnceListener(Msg msgId, Action<Param> listener)
{
if (m_msgOnceDict.ContainsKey(msgId))
{
List<Action<Param>> list = m_msgOnceDict[msgId];
if (list.Contains(listener))
{
list.Remove(listener);
if (list.Count == 0)
{
Uncc<Action<Param>>.Release(list);
m_msgOnceDict.Remove(msgId);
}
}
}
}
public void Dispatch(Msg msgId, Param param = null)
{
if (!m_msgPriorityDict.ContainsKey(msgId)
&& !m_msgDict.ContainsKey(msgId)
&& !m_msgOnceDict.ContainsKey(msgId))
return;
MainThreadMsgClass msg = new MainThreadMsgClass
{
currMsgId = msgId,
currParam = param,
};
lock (m_queueLock)
{
m_msgQueue.Enqueue(msg);
}
}
private void AutoDispatch(Msg msgId, Param param)
{
InvokeMethods(m_msgPriorityDict, msgId, param);
InvokeMethods(m_msgDict, msgId, param);
InvokeMethods(m_msgOnceDict, msgId, param);
if (m_msgOnceDict.ContainsKey(msgId))
{
Uncc<Action<Param>>.Release(m_msgOnceDict[msgId]);
m_msgOnceDict.Remove(msgId);
}
}
private void InvokeMethods(Dictionary<Msg, List<Action<Param>>> msgDict, Msg msgId, Param param)
{
if (!msgDict.ContainsKey(msgId)) return;
List<Action<Param>> rawList = msgDict[msgId];
int funcCount = rawList.Count;
if (funcCount == 1)
{
Action<Param> onEvent = rawList[0];
onEvent(param);
return;
}
List<Action<Param>> invokeFuncs = Uncc<Action<Param>>.Get();
invokeFuncs.AddRange(rawList);
for (int i = 0; i < funcCount; i++)
{
try
{
Action<Param> onEvent = invokeFuncs[i];
onEvent(param);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
Uncc<Action<Param>>.Release(invokeFuncs);
}
public void Clear()
{
lock (m_queueLock)
{
m_msgQueue.Clear();
}
m_msgPriorityDict.Clear();
m_msgDict.Clear();
m_msgOnceDict.Clear();
}
protected override string ParentRootName
{
get { return OCConst.DispatcherGoName; }
}
protected override void OnDestroy()
{
base.OnDestroy();
m_msgPriorityDict.Clear();
m_msgDict.Clear();
m_msgOnceDict.Clear();
m_msgPriorityDict = null;
m_msgDict = null;
m_msgOnceDict = null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e02321e1c5d556b4484a914fec6eafbd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+173
View File
@@ -0,0 +1,173 @@
namespace BingoBrain.Core
{
public abstract class BaseModel
{
public string modelName;
private string localStorageKey;
protected ModuleBoardk MOduleBoardk;
protected ModelDispatcher modelDispatcher;
protected CtrlDispatcher ctrlDispatcher;
protected UICtrlDispatcher uiCtrlDispatcher;
protected DataDispatcher dataDispatcher;
protected GameDispatcher gameDispatcher;
public void New()
{
OnNew();
}
public void Init()
{
Assignment();
AddListener();
AddServerListener();
OnInit();
}
public void StartUp()
{
OnStartUp();
}
public void ReadData()
{
OnReadData();
}
public void GameStart()
{
OnGameStart();
}
public void Reset()
{
Dispose();
Init();
}
public void Dispose()
{
RemoveListener();
RemoveServerListener();
OnDispose();
UnAssignment();
}
protected virtual void Assignment()
{
MOduleBoardk = ModuleBoardk.Instance;
modelDispatcher = ModelDispatcher.Instance;
ctrlDispatcher = CtrlDispatcher.Instance;
uiCtrlDispatcher = UICtrlDispatcher.Instance;
dataDispatcher = DataDispatcher.Instance;
gameDispatcher = GameDispatcher.Instance;
}
protected virtual void UnAssignment()
{
MOduleBoardk = null;
modelDispatcher = null;
ctrlDispatcher = null;
uiCtrlDispatcher = null;
dataDispatcher = null;
gameDispatcher = null;
}
protected virtual void OnNew()
{
}
protected abstract void OnInit();
protected virtual void OnStartUp()
{
}
protected virtual void OnReadData()
{
}
protected virtual void OnGameStart()
{
}
protected abstract void OnReset();
protected abstract void OnDispose();
protected virtual void AddListener()
{
}
protected virtual void RemoveListener()
{
}
protected virtual void AddServerListener()
{
}
protected virtual void RemoveServerListener()
{
}
#region LocalStorage
protected virtual void WriteLocalStorage()
{
}
private string GetLocalStorageKey()
{
if (string.IsNullOrEmpty(localStorageKey))
{
localStorageKey = string.Concat("M_", modelName, "_", Pva.UserInfo.userId);
}
return localStorageKey;
}
protected void SetCustomLocalStorageKey(string customSuffixKey)
{
localStorageKey = string.Concat(modelName, "_", customSuffixKey);
}
protected void WriteLocalStorage(object storageData)
{
string key = GetLocalStorageKey();
RrysKit.WriteObject(key, storageData);
}
protected object ReadLocalStorage<T>()
{
string key = GetLocalStorageKey();
return RrysKit.ReadObject<T>(key);
}
protected bool HasLocalStorage()
{
string key = GetLocalStorageKey();
return RrysKit.HasKey(key);
}
protected void DeleteLocalStorage()
{
string key = GetLocalStorageKey();
RrysKit.DeleteKey(key);
}
#endregion
#region
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2ab9296c1feb18b42a12bbc53cdfc39b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,29 @@
namespace BingoBrain.Core
{
public abstract class BaseScene
{
public abstract int SceneIdx { get; }
public void Enter()
{
Pva.Enter();
OnEnter();
}
public void Leave()
{
OnLeave();
}
public void SwchSneCote(object param)
{
OnSwhSceCompl(param);
}
protected abstract void OnEnter();
protected abstract void OnLeave();
protected abstract void OnSwhSceCompl(object param);
public abstract void Dispose();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 36208f1ae07fbee498389575991236b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,39 @@
namespace BingoBrain.Core
{
/// <summary>
/// 系统
/// 承载逻辑
/// 1EntitySystem
/// 2GameObjectSystem
/// </summary>
public abstract class BaseSystem
{
public BaseSystem()
{
}
public virtual void Init()
{
}
public virtual void InitLate()
{
}
public virtual void Dispose()
{
}
public virtual void Update()
{
}
public virtual void LateUpdate()
{
}
public virtual void FixedUpdate()
{
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: db46851f313c4809855238569ed6cfac
timeCreated: 1692256359
+500
View File
@@ -0,0 +1,500 @@
using FairyGUI;
using System.Collections.Generic;
namespace BingoBrain.Core
{
public abstract class BaseUI
{
#region Field
protected UI MUI;
protected ModuleBoardk ModuleBoardk;
protected ModelDispatcher modelDispatcher;
protected CtrlDispatcher ctrlDispatcher;
protected UICtrlDispatcher uiCtrlDispatcher;
protected DataDispatcher dataDispatcher;
protected GameDispatcher gameDispatcher;
public string uiName;
public string rawGameObjectName;
public string gameObjectName;
public UIInfo uiInfo;
public uint uiOpenCumsumId;
public int currLayer;
public BaseUICtrl baseUICtrl;
public object uiArgs;
public GObject baseGObj;
public GComponent baseUI;
public Window windowUI;
public GGraph uiMask;
public List<SubUI> subUIs;
public bool isOpen;
public bool isVisible;
public bool isClose;
public GTweener openUiGTweener;
public GTweener closeUiGTweener;
#endregion
#region Constructor
public BaseUI()
{
}
public BaseUI(BaseUICtrl baseUICtrl)
{
New(baseUICtrl);
}
public void New(BaseUICtrl baseUICtrl)
{
this.baseUICtrl = baseUICtrl;
Assignment();
OnNew();
Process_Init();
}
protected virtual void Assignment()
{
MUI = UI.Instance;
ModuleBoardk = ModuleBoardk.Instance;
modelDispatcher = ModelDispatcher.Instance;
ctrlDispatcher = CtrlDispatcher.Instance;
uiCtrlDispatcher = UICtrlDispatcher.Instance;
dataDispatcher = DataDispatcher.Instance;
gameDispatcher = GameDispatcher.Instance;
}
protected virtual void UnAssignment()
{
MUI = null;
ModuleBoardk = null;
modelDispatcher = null;
ctrlDispatcher = null;
uiCtrlDispatcher = null;
dataDispatcher = null;
gameDispatcher = null;
}
#endregion
#region Interface: UI
public void Open(object args = null)
{
uiArgs = args;
MUI.Internal_OpenUI(this, args);
}
public void OpenUISequence(object args = null)
{
uiArgs = args;
MUI.Internal_OpenUISequence(this, args);
}
public void Close()
{
if (isClose) return;
MUI.Internal_CloseUI(this);
}
public void Hide()
{
MUI.Internal_HideUI(this);
}
public void Display(object args = null)
{
uiArgs = args;
MUI.Internal_DisplayUI(this, args);
}
#endregion
#region Interface: SubUI
protected SubUI OpenSubUI(string subUiName, string assetName, bool needStandardResolution = false)
{
return OpenSubUI(subUiName, uiInfo.packageName, assetName, needStandardResolution);
}
protected SubUI OpenSubUI(string subUiName, string packageName, string assetName,
bool needStandardResolution = false)
{
return MUI.OpenSubUI(this, subUiName, packageName, assetName, needStandardResolution);
}
protected void CloseSubUI(SubUI subUI)
{
MUI.CloseSubUI(this, subUI);
}
protected void CloseAllSubUI()
{
MUI.CloseAllSubUI(this);
}
#endregion
#region Process
private void Process_Init()
{
isOpen = false;
isVisible = false;
isClose = false;
uiInfo = new UIInfo();
SetUIInfo(uiInfo);
PostProcess_UIInfo();
OnInit();
}
private void PostProcess_UIInfo()
{
}
public void Process_Bind()
{
OnBind();
}
public void Process_OpenBefore(object args)
{
OnOpenBefore(args);
}
public void Process_Open(object args)
{
OnOpen(args);
AddListener();
AddServerListener();
isOpen = true;
}
public void Process_OpenUIAnimEnd()
{
OnOpenUIAnimEnd();
}
public void Process_Close()
{
RemoveListener();
RemoveServerListener();
OnClose();
isClose = true;
}
public void Process_CloseUIAnimEnd()
{
OnCloseUIAnimEnd();
}
public void Process_Destroy()
{
OnDestroy();
UnAssignment();
isOpen = false;
isVisible = false;
isClose = true;
baseGObj = null;
baseUI = null;
windowUI = null;
}
public void Process_Hide()
{
isVisible = false;
baseUI.visible = isVisible;
OnHide();
}
public void Process_Display(object args)
{
isVisible = true;
baseUI.visible = isVisible;
OnDisplay(args);
}
public void ProcessFunc_SwitchLanguage()
{
if (isClose) return;
if (baseUI == null) return;
if (baseUI.isDisposed) return;
InternaProcesslFunc_GComponentSwitchLanguage(baseUI);
OnSwitchLanguage();
}
private void InternaProcesslFunc_GComponentSwitchLanguage(GComponent switchCom)
{
if (switchCom == null) return;
if (switchCom.isDisposed) return;
for (int i = 0; i < switchCom.GetChildrenCount(); i++)
{
GObject gObject = switchCom.GetChildAt(i);
if (gObject == null || gObject.isDisposed) continue;
GComponent childCom = gObject.asCom;
if (childCom != null)
{
InternaProcesslFunc_GComponentSwitchLanguage(childCom);
continue;
}
else
{
if (gObject.packageItem != null) continue;
if (gObject.parent == null) continue;
string text = null;
if (gObject is GTextField)
{
GTextField gTextField = gObject.asTextField;
if (gTextField == null) continue;
if (!gTextField.Ex_IsAutoMultiLang) continue;
text = gObject.Ex_GetMultiLangText();
if (text != null)
{
gTextField.text = text;
continue;
}
}
}
}
}
#endregion
#region Virtual Logic
protected virtual void OnNew()
{
}
protected abstract void SetUIInfo(UIInfo uiInfo);
protected virtual void OnInit()
{
}
protected virtual void OnBind()
{
}
protected virtual void OnOpenBefore(object args)
{
}
protected virtual void OnOpen(object args)
{
}
protected virtual void OnOpenUIAnimEnd()
{
}
protected virtual void OnClose()
{
}
protected virtual void OnCloseUIAnimEnd()
{
}
protected virtual void OnDestroy()
{
}
protected virtual void OnHide()
{
}
protected virtual void OnDisplay(object args)
{
}
public virtual void OnUpdate()
{
}
public virtual void OnSwitchLanguage()
{
}
protected virtual void AddListener()
{
}
protected virtual void RemoveListener()
{
}
protected virtual void AddServerListener()
{
}
protected virtual void RemoveServerListener()
{
}
#endregion
#region Event
protected void AutoBindButtonEvent(EventCallback1 callback)
{
AutoBindButtonEvent(baseUI, callback);
}
protected void AutoBindButtonEvent(GComponent gComponent, EventCallback1 callback)
{
GObject[] gObjects = gComponent.GetChildren();
for (int i = 0; i < gObjects.Length; i++)
{
GObject gObject = gObjects[i];
if (gObject.asButton != null)
{
gObject.onClick.Remove(callback);
gObject.onClick.Add(callback);
continue;
}
GComponent otherGComponent = gObject.asCom;
if (otherGComponent != null)
{
AutoBindButtonEvent(otherGComponent, callback);
continue;
}
}
}
protected void BaseUIClickEvent(GComponent gComponent)
{
}
#endregion
#region Anim
public void KillOpenUIAnim()
{
if (openUiGTweener != null)
{
if (!openUiGTweener.allCompleted)
{
openUiGTweener.Kill(complete: false);
}
openUiGTweener = null;
}
}
public void KillCloseUIAnim()
{
if (closeUiGTweener != null)
{
if (!closeUiGTweener.allCompleted)
{
closeUiGTweener.Kill(complete: false);
}
closeUiGTweener = null;
}
}
#endregion
#region Func
public uint GetOpenUIMsgId()
{
if (uiInfo.openUIMsgId == 0)
{
if (baseUICtrl == null) return 0;
uiInfo.openUIMsgId = baseUICtrl.GetOpenUIMsg(uiName);
}
return uiInfo.openUIMsgId;
}
public uint GetCloseUIMsgId()
{
if (uiInfo.closeUIMsgId == 0)
{
if (baseUICtrl == null) return 0;
uiInfo.closeUIMsgId = baseUICtrl.GetCloseUIMsg(uiName);
}
return uiInfo.closeUIMsgId;
}
public void CtrlCloseUI()
{
if (baseUICtrl == null) return;
baseUICtrl.DispatchCloseUI(uiName);
}
public UILayerType GetCurrRenderLayer()
{
string uiLayer = baseUI.parent.name;
switch (uiLayer)
{
case RyerConst.Background:
return UILayerType.Background;
case RyerConst.Bottom:
return UILayerType.Bottom;
case RyerConst.Normal:
return UILayerType.Normal;
case RyerConst.Top:
return UILayerType.Top;
case RyerConst.FullScreen:
return UILayerType.FullScreen;
case RyerConst.Popup:
return UILayerType.Popup;
case RyerConst.Highest:
return UILayerType.Highest;
case RyerConst.Animation:
return UILayerType.Animation;
case RyerConst.Tips:
return UILayerType.Tips;
case RyerConst.Loading:
return UILayerType.Loading;
case RyerConst.System:
return UILayerType.System;
case RyerConst.NetworkError:
return UILayerType.NetworkError;
default:
return UILayerType.None;
}
}
public int GetCurrRenderQueueIdx()
{
return baseUI.parent.GetChildIndex(baseUI);
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2304886815d7ebc45aff43b801f57c13
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
namespace BingoBrain.Core
{
public abstract class BaseUICtrl : BaseCtrl
{
protected override void Assignment()
{
base.Assignment();
}
protected override void UnAssignment()
{
base.UnAssignment();
}
public virtual uint GetOpenUIMsg(string uiName)
{
return 0;
}
public virtual uint GetCloseUIMsg(string uiName)
{
return 0;
}
public void DispatchOpenUI(string uiName = null, object args = null)
{
uint msgId = GetOpenUIMsg(uiName);
if (msgId == 0)
{
OpenUI(args);
return;
}
if (uiCtrlDispatcher != null)
{
uiCtrlDispatcher.Dispatch(msgId, args);
}
}
public void DispatchCloseUI(string uiName = null, object args = null)
{
uint msgId = GetCloseUIMsg(uiName);
if (msgId == 0)
{
CloseUI(args);
return;
}
if (uiCtrlDispatcher != null)
{
uiCtrlDispatcher.Dispatch(msgId, args);
}
}
public abstract void OpenUI(object args = null);
public abstract void CloseUI(object args = null);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17086b56b8ce86e44a2a0e0f23b0f5ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,43 @@
namespace BingoBrain.Core
{
public abstract class BaseUnity<T> : SingletonUnity<T>, InterfaceManager
where T : BaseUnity<T>
{
public bool IsInit { get; private set; }
public bool IsStartUp { get; private set; }
public bool IsDispose { get; private set; }
protected override string ParentRootName
{
get { return OCConst.MonoManagerGoName; }
}
protected override void New()
{
base.New();
IsDispose = false;
}
public virtual void Init()
{
IsInit = true;
}
public virtual void StartUp()
{
IsStartUp = true;
}
public virtual void DisposeBefore()
{
IsDispose = true;
IsInit = false;
IsStartUp = false;
}
protected override void OnDestroy()
{
base.OnDestroy();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8c01f68bc92a2b648a38f328f7e95ce6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+164
View File
@@ -0,0 +1,164 @@
using UnityEngine;
using DG.Tweening;
using System.Collections;
using UnityEngine.Android;
namespace BingoBrain.Core
{
public class Bea : MonoBehaviour
{
public static bool IsAppQuit { get; private set; }
public bool IsRestart { get; private set; }
public int RestartCount { get; private set; }
public bool IsAppFocus { get; private set; }
public bool IsAppPause { get; private set; }
public long LastFocusFlaseTime { get; private set; }
public virtual void Init()
{
IsAppFocus = true;
}
public virtual void Enable()
{
CreateEnvironment();
}
public virtual void Restart()
{
Debug.Log("[Application]Restart");
IsRestart = true;
RestartCount++;
StartCoroutine(OnRestart());
}
public virtual void Quit()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
private void CreateEnvironment()
{
OCConst.ApplicationGo = gameObject;
OCConst.EngineSingletonGo = new GameObject(OCConst.EngineSingletonGoName);
OCConst.EngineSingletonGo.SetParent(OCConst.bfdn);
}
private IEnumerator OnRestart()
{
DOTween.KillAll();
ClearAllObjects();
yield return vbadConst.WaitForEndOfFrame;
CloseApp();
Uvsjk.Destroy(OCConst.EngineSingletonGo);
yield return vbadConst.WaitForEndOfFrame;
Enable();
}
private void CloseApp()
{
if (UI.Instance != null)
{
UI.Instance.DisposeAllUI();
}
ModuleBoardk.Instance.DisposeAllModule();
Ard.Instance.DisposeAllManager();
Ard.Instance.Dispose();
}
private void ClearAllObjects()
{
var otherGos = FindObjectsOfType<GameObject>();
foreach (var otherGo in otherGos)
{
if (IsCanDestroyObj(otherGo))
{
Uvsjk.Destroy(otherGo);
}
}
}
private bool IsCanDestroyObj(GameObject go)
{
if (go.transform.parent == null)
{
if (go.name is OCConst.LauncherGoName or
OCConst.EngineEventSystemGoName or
OCConst.ApplicationGoName or
OCConst.EngineSingletonGoName or
OCConst.DOTweenGoName or
OCConst.SuperInvokeGoName)
{
return false;
}
return true;
}
return IsCanDestroyObj(go.transform.parent.gameObject);
}
private void OnApplicationPause(bool pause)
{
IsAppPause = pause;
Debug.Log("??????????1222222222222");
if (pause)
{
AppDispatcher.Instance.Dispatch(CsjInfoC.App_Pause_True, pause);
}
else
{
MainThreadDispatcher.Instance.Dispatch(GinInfoC.App_Pause_False, pause);
AppDispatcher.Instance.Dispatch(CsjInfoC.App_Focus_False, pause);
}
}
private void OnApplicationQuit()
{
Debug.Log("[ BingoBrain ] [ Application ] OnApplicationQuit");
IsAppQuit = true;
AppDispatcher.Instance.Dispatch(CsjInfoC.App_Focus_False);
CloseApp();
AppDispatcher.Instance.Dispatch(CsjInfoC.App_Quit);
AssetBundle.UnloadAllAssetBundles(true);
}
#if UNITY_ANDROID
private void Update()
{
if (Application.platform == RuntimePlatform.Android && Input.GetKeyDown(KeyCode.Home))
{
OnClickKeyCodeHome();
}
if (Application.platform == RuntimePlatform.Android && Input.GetKeyDown(KeyCode.Escape))
{
OnClickKeyCodeEscape();
}
}
#endif
protected virtual void OnClickKeyCodeHome()
{
AppDispatcher.Instance.Dispatch(CsjInfoC.KeyCode_Home);
Debug.Log("[ BingoBrain ] [ Application ] OnClickAppHome");
}
protected virtual void OnClickKeyCodeEscape()
{
AppDispatcher.Instance.Dispatch(CsjInfoC.KeyCode_Escape);
Debug.Log("[ BingoBrain ] [ Application ] OnClickAppEscape");
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f456d9a76e898ac4db489cb8c7fcb3b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
using BingoBrain.HotFix;
namespace BingoBrain.Core
{
public class Bingo : SingletonUnity<Bingo>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 41b35f98275b2ce40ac58d230dba9d80
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+235
View File
@@ -0,0 +1,235 @@
using UnityEngine;
using BingoBrain.HotFix;
using System.Collections;
using BingoBrain;
namespace BingoBrain.Core
{
public class BingoBea : Bea
{
private static BingoBea m_instance;
public string attribution = "organic";
public static BingoBea Instance
{
get
{
if (m_instance == null)
{
if (IsAppQuit)
{
return null;
}
OCConst.ApplicationGo = new GameObject(OCConst.ApplicationGoName);
OCConst.ApplicationGo.SetParent(OCConst.bfdn);
m_instance = OCConst.ApplicationGo.AddComponent<BingoBea>();
}
return m_instance;
}
}
private void OnApplicationFocus(bool focus)
{
//IsAppFocus = focus;
if (focus)
{
// MainThreadDispatcher.Instance.Dispatch(GinInfoC.App_Focus_True, focus);
AppDispatcher.Instance.Dispatch(GinInfoC.App_Focus_True, focus);
}
else
{
// LastFocusFlaseTime = DateTimeBoardk.Instance.GetServerCurrTimestamp();
AppDispatcher.Instance.Dispatch(CsjInfoC.App_Focus_False, focus);
}
}
public override void Init()
{
base.Init();
if (!RrysKit.HasKey(FsyConst.App_isNewInstall))
{
RrysKit.WriteInt(FsyConst.App_isNewInstall, 1);
}
else
{
}
AppDispatcher.Instance.AddListener(CsjInfoC.AppManagerRegister,
(obj) => { BingoBoard.SetData(); });
}
public override void Enable()
{
base.Enable();
InitPlugin();
InitAppSetting();
ManagerBoard.Register();
BingoBoard.Board();
ManagerBoard.RegisterData();
Ard.Instance.Init();
ModuleBoardk.Instance.StartUpAllModule();
InitSettingMode();
StartUpGameMain();
}
private void OnDestroy()
{
m_instance = null;
}
#region Enable
private void InitPlugin()
{
Bsaddd.Init();
}
private void InitAppSetting()
{
if (!BingoConst.UseInternalSetting) return;
Physics.autoSimulation = true;
Physics.autoSyncTransforms = true;
Physics2D.simulationMode = SimulationMode2D.Script;
Physics2D.autoSyncTransforms = true;
Debug.unityLogger.logEnabled = BingoConst.IsEnabledEngineLog;
Debug.unityLogger.filterLogType = BingoConst.EnabledFilterLogType;
Screen.sleepTimeout = BingoConst.SleepTimeoutMode;
Application.runInBackground = BingoConst.IsRunInBG;
QualitySettings.vSyncCount = 0;
QualitySettings.lodBias = 1;
QualitySettings.antiAliasing = BingoConst.AntiAliasing;
Application.targetFrameRate = BingoConst.LowFrameRate;
}
private void StartUpGameMain()
{
if (!IsRestart)
{
GameBoardk.Instance.InitialMain();
}
else
{
GameBoardk.Instance.EnterMain();
}
}
#endregion Enable
#region SettingMode
private void InitSettingMode()
{
if (!BingoConst.UseInternalSetting) return;
InitResolutionMode();
InitFrameRateMode();
}
private bool isHDMode;
public bool IsHDMode
{
get { return isHDMode; }
set
{
isHDMode = value;
RrysKit.WriteBool(FsyConst.Application_isHDMode, isHDMode);
SetResolutionMode(isHDMode);
}
}
private bool isHFRMode;
public bool IsHFRMode
{
get { return IsHFRMode; }
set
{
isHFRMode = value;
RrysKit.WriteBool(FsyConst.Application_isHFRMode, isHFRMode);
SetFrameRateMode(isHFRMode);
}
}
private void InitResolutionMode()
{
isHDMode = RrysKit.ReadBool(FsyConst.Application_isHDMode, true);
SetResolutionMode(isHDMode);
}
private void InitFrameRateMode()
{
isHFRMode = RrysKit.ReadBool(FsyConst.Application_isHFRMode, true);
SetFrameRateMode(isHFRMode);
}
private void SetResolutionMode(bool isHDMode)
{
if (isHDMode)
{
CenConst.CurrResolution.x = CenConst.RawResolution.x * BingoConst.HDHighViewScale;
CenConst.CurrResolution.y = CenConst.RawResolution.y * BingoConst.HDHighViewScale;
}
else
{
CenConst.CurrResolution.x = CenConst.RawResolution.x * BingoConst.HDLowViewScale;
CenConst.CurrResolution.y = CenConst.RawResolution.y * BingoConst.HDLowViewScale;
}
SetScreenResolution(CenConst.CurrResolution.x, CenConst.CurrResolution.y, true);
}
private void SetFrameRateMode(bool isHFRMode)
{
Application.targetFrameRate = isHFRMode ? BingoConst.HighFrameRate : BingoConst.LowFrameRate;
QualitySettings.vSyncCount = 0;
QualitySettings.lodBias = 1;
}
private void SetScreenResolution(float width, float height, bool isFullScreen)
{
StartCoroutine(OnSetScreenResolution(width, height, isFullScreen));
}
private IEnumerator OnSetScreenResolution(float width, float height, bool isFullScreen)
{
yield return vbadConst.WaitForEndOfFrame;
var allCams = Camera.allCameras;
if (allCams == null)
{
yield break;
}
foreach (var cam in allCams)
{
cam.enabled = false;
}
Screen.SetResolution((int)width, (int)height, isFullScreen);
Screen.fullScreen = true;
yield return vbadConst.WaitForEndOfFrame;
if (allCams == null)
{
yield break;
}
foreach (var cam in allCams)
{
cam.enabled = true;
}
}
#endregion SettingMode
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e34e769b3926fa24eb9398b230d7c31b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+29
View File
@@ -0,0 +1,29 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
using System;
using System.Text;
using BingoBrain;
using UnityEngine;
namespace BingoBrain.Core
{
public class Bingoaav : MonoBehaviour
{
public void Awake()
{
StartBingo();
}
public static void StartBingo()
{
OCConst.bfdn = new GameObject($"{OCConst.vas}");
OCConst.bfdn.AddComponent<Bingo>();
OCConst.WorldSpaceGo = new GameObject(OCConst.bfd);
OCConst.WorldSpaceGo.SetParent(OCConst.bfdn);
DontDestroyOnLoad(OCConst.bfdn);
Pva.Congds(BingoBea.Instance);
GameHelper.PostFunnelLogin("bootstrap");
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 958cbcd088fb3bc4c826840c9648b64e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
namespace BingoBrain.Core
{
public interface InterfaceManager
{
void Init();
void StartUp();
void DisposeBefore();
void Dispose();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e53d06f42f51d84498ab4ffe80556de6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+67
View File
@@ -0,0 +1,67 @@
using BingoBrain.HotFix;
namespace BingoBrain.Core
{
public class UserInfo
{
public string userId;
}
/// <summary>
/// 全局应用
/// 应用层逻辑注入到框架层
/// </summary>
public static class Pva
{
#region User
public static UserInfo UserInfo;
#endregion User
#region Application
private static Bea _sCurrBea = null;
public static void Congds(Bea bea)
{
_sCurrBea = bea;
_sCurrBea.Init();
_sCurrBea.Enable();
}
public static void Restart()
{
_sCurrBea.Restart();
}
public static void Quit()
{
_sCurrBea.Quit();
}
#endregion Application
#region UIMsg
private static float LoadingProgressDelayTime = 0f;
public static void Enter()
{
AppDispatcher.Instance.Dispatch(CsjInfoC.UI_DisplayLoadingUI);
}
public static void HideLoadingUI(bool isDelay = false)
{
if (!isDelay)
{
AppDispatcher.Instance.Dispatch(CsjInfoC.UI_HideLoadingUI);
return;
}
TimerHelper.mEasy.AddTimer(0.5f, () => { AppDispatcher.Instance.Dispatch(CsjInfoC.UI_HideLoadingUI); });
}
#endregion UIMsg
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 58141605cb271ab488578de8509d91e7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+24
View File
@@ -0,0 +1,24 @@
using FairyGUI;
namespace BingoBrain.Core
{
public class SubUI
{
public string uiName;
public string packageName;
public string assetName;
public string rawGameObjectName;
public string gameObjectName;
public GObject baseGObj;
public GComponent baseUI;
public SubUI(string uiName, string packageName, string assetName)
{
this.uiName = uiName;
this.packageName = packageName;
this.assetName = assetName;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bffd78e7d21b93a42a38ac88f77d3432
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+101
View File
@@ -0,0 +1,101 @@
using UnityEngine;
using System.Collections.Generic;
namespace BingoBrain.Core
{
public static class UIInfoConst
{
public static Color DefaultUIMaskColor = new Color(0, 0, 0, 0.8f);
}
public class UIInfo
{
public string packageName = null;
public string assetName = null;
public UILayerType layerType = UILayerType.Normal;
public UIGComType gComType = UIGComType.GComponent;
public UIType uiType = UIType.NormalUI;
public uint openUIMsgId = 0;
public uint closeUIMsgId = 0;
public bool isCache = false;
public bool isSwitchSceneCloseUI = false;
public bool isTickUpdate = false;
public bool isClosetWorldRaycast = false;
public bool isNeedOpenAnim = false;
public bool isNeedCloseAnim = false;
public bool isNeedUIMask = false;
public bool isNeedUIMaskCloseEvent = false;
public Color uiMaskCustomColor = UIInfoConst.DefaultUIMaskColor;
}
public enum UILayerType : int
{
None = -1,
Background = 0,
Bottom = 1,
Normal = 2,
Top = 3,
FullScreen = 4,
Popup = 5,
Highest = 6,
Animation = 7,
Tips = 8,
Loading = 9,
System = 10,
NetworkError = 11,
}
public enum UIGComType : int
{
GComponent = 0,
Window = 1,
}
public enum UIType : int
{
NormalUI = 0,
FullScreenUI = 1,
ConfirmationUI = 2,
}
public class EnumComparer_UILayerType : IEqualityComparer<UILayerType>
{
public static EnumComparer_UILayerType Instance = new EnumComparer_UILayerType();
public bool Equals(UILayerType x, UILayerType y)
{
return (int)x == (int)y;
}
public int GetHashCode(UILayerType obj)
{
return (int)obj;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aaef7fcebcd15164bb758addcacaef25
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+36
View File
@@ -0,0 +1,36 @@
using BingoBrain;
using BingoBrain.Core;
public class LoginModel
{
public static LoginModel Instance;
public long uid;
public bool new_player;
public string token;
public long expires_at;
public string country;
public bool is_magic;
public string invite_code;
public string invite_url;
public long last_login_time;
public string play_data;
public string setting;
public string cdn_url;
public long login_time;
public long reg_time;
public Preferences preferences;
public bool debug_log = true;
public int enwp;
public LoginModel()
{
Instance = this;
}
#region
#endregion
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6745d5edf5a21460dbc8a71d1128ebfc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+200
View File
@@ -0,0 +1,200 @@
using UnityEngine;
using Newtonsoft.Json;
using BingoBrain.Core;
using BingoBrain;
using DG.Tweening;
using BingoBrain.HotFix;
using DontConfuse;
using System;
public class LoginSystem : BaseSystem
{
//is debug test (LoginCountLimit 应该为 5 测试改为2)
private const int LoginCountLimit = 5;
private int loginCount = 0;
public LoginSystem(bool isAutoInit = true)
{
if (isAutoInit)
{
Init();
}
}
public sealed override void Init()
{
base.Init();
InitData();
AddListener();
}
private void InitData()
{
}
private void AddListener()
{
NetworkDispatcher.Instance.AddListener(NetworkMsg.Login, OnRequestLogin);
NetworkDispatcher.Instance.AddListener(NetworkMsg.Reconnect, OnResponseReconnect);
}
private void RemoveListener()
{
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.Login, OnRequestLogin);
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.Reconnect, OnResponseReconnect);
}
private void RequestLogin()
{
var requestLoginData = new RequestLoginData
{
device_id = SystemInfo.deviceUniqueIdentifier,
// device_id ="E742FE8B-C32E-56A7-8F8A-6B3BC0F3169",
pack_name = NetworkMsg.Identifier,
app_version = Application.version,
channel = BingoBea.Instance.attribution,
sim = WebviewManager.haveSimCard
};
Debug.Log(SystemInfo.deviceUniqueIdentifier);
GameHelper.PostFunnelLogin("loginSend");
Debug.Log(JsonConvert.SerializeObject(requestLoginData));
NetworkKit.Post<LoginModel>("login", requestLoginData, (isSuccess, loginData) =>
{
if (isSuccess)
{
var loginModel = GameHelper.GetLoginModel();
loginModel.cdn_url = loginData.cdn_url;
loginModel.setting = loginData.setting;
loginModel.play_data = loginData.play_data;
loginModel.token = loginData.token;
loginModel.uid = loginData.uid;
loginModel.country = loginData.country;
loginModel.expires_at = loginData.expires_at;
loginModel.is_magic = loginData.is_magic;
loginModel.invite_code = loginData.invite_code;
loginModel.invite_url = loginData.invite_url;
loginModel.last_login_time = loginData.last_login_time;
loginModel.login_time = loginData.login_time;
loginModel.reg_time = loginData.reg_time;
loginModel.new_player = loginData.new_player;
loginModel.debug_log = loginData.debug_log;
loginModel.enwp = loginData.enwp;
loginModel.preferences = new Preferences();
NetworkKit.CDNUrl = $"{loginData.cdn_url}/";
NetworkKit.SetCacheToken(loginData.token);
//RequestHeart();
DateTimeBoardk.Instance.SetServerCurrTimestamp(loginData.login_time);
Sequence mLoopSequence = DOTween.Sequence();
mLoopSequence.AppendCallback(() =>
{
RequestHeart();
}).AppendInterval(60).SetLoops(-1);
//TimerHelper.UnscaleGeneral.AddLoopTimer(60, (timer) => { RequestHeart(); });
//NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetPlayData);
//UICtrlDispatcher.Instance.Dispatch(SkinInfo.EnterBingoUI_Open);
PreferencesMgr.Instance.PlayerName = loginData.invite_code;
NetworkDispatcher.Instance.Dispatch(ExternalInfo.GetConfig);
MaxADKit.Init();
GameHelper.PostFunnelLogin("loginRecv", true);
if (GameHelper.IsGiftSwitch())
{
GameObject.Find("MainCameraRoot").SetActive(false);
}
else{
GameObject.Find("sheep_parent").SetActive(false);
}
}
else
{
//UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
Debug.Log("登陆请求失败");
GameHelper.PostFunnelLogin("loginRecv", false);
float times = loginCount == 0 ? 0 : 5f;
DOVirtual.DelayedCall(times,()=>{
if (loginCount < LoginCountLimit) {
loginCount++;
RequestLogin();
} else {
loginCount = 0;
Action _OnFail = () =>
{
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
};
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.TipsViewUI_Open, _OnFail);
}
});
}
});
}
private void RequestHeart()
{
NetworkKit.PostWithHeader("user/health");
}
private void OnRequestLogin(object obj = null)
{
RequestLogin();
}
private void OnResponseReconnect(object obj)
{
}
public override void Dispose()
{
base.Dispose();
RemoveListener();
}
}
public partial class NetworkMsg
{
private static uint MsgRootLogic = 100000;
public static uint GetConfig = ++MsgRootLogic;
public static uint Reconnect = ++MsgRootLogic;
public static uint Login = ++MsgRootLogic;
public static uint SavePlayData = ++MsgRootLogic;
public static uint GetPlayData = ++MsgRootLogic;
public static uint SendInviteCode = ++MsgRootLogic;
public static uint GetInviteData = ++MsgRootLogic;
public static uint UpdateCheckInviteData = ++MsgRootLogic;
public static string Identifier = "com.interactivegames123.bingograssland";
public static uint Start = ++MsgRootLogic;
public static uint NotNetwork = ++MsgRootLogic;
}
public class RequestLoginData
{
public string device_id;
public string pack_name;
public string app_version;
public string channel;
public bool sim;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8c3f8903825dc41c9990270946039428
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+402
View File
@@ -0,0 +1,402 @@
#if UNITY_EDITOR
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace FutureEditor
{
public class MVCBuildWindow : EditorWindow
{
private static string mvcClassName; //mvc 模块名
private static string fguiPackageName; //FGUI 包名
private static string fguiCompName; //FGUI 组建名
private static string foldePath;
static string mvcRootPath = "/BingoBrain/ModuleUI/"; //创建MVC模块的目录
[MenuItem("Jarvis/MVC/创建MVC代码模板", false, 0)]
private static void ShowWindow()
{
MVCBuildWindow window = GetWindow<MVCBuildWindow>(true, "创建MVC代码模板窗口");
window.minSize = new Vector2(280f, 170f);
window.maxSize = window.minSize;
window.Show();
}
private void OnGUI()
{
EditorGUILayout.Space();
EditorGUILayout.BeginVertical();
GUILayout.Space(5);
GUILayout.BeginHorizontal();
GUILayout.Label("MVC模块名:");
mvcClassName = EditorGUILayout.TextField(mvcClassName, GUILayout.Height(20));
GUILayout.EndHorizontal();
GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.Label("FGUI包名:");
fguiPackageName = EditorGUILayout.TextField(fguiPackageName, GUILayout.Height(20));
GUILayout.EndHorizontal();
GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.Label("FGUI组件名:");
fguiCompName = EditorGUILayout.TextField(fguiCompName, GUILayout.Height(20));
GUILayout.EndHorizontal();
GUILayout.Space(10);
if (GUILayout.Button("创建", GUILayout.Height(25)))
{
CreateMVC(mvcClassName);
}
EditorGUILayout.EndVertical();
}
private static void CreateMVC(string mvcName)
{
if (!string.IsNullOrEmpty(mvcName))
{
string mvcPath = mvcRootPath + mvcName;
foldePath = Application.dataPath + mvcPath;
if (Directory.Exists(foldePath))
{
Debug.LogError("[MVCBuildWindow]Folde is exist!!!: " + foldePath);
Debug.LogError("[MVCBuildWindow]Create MVC Fail:" + mvcName);
return;
}
Directory.CreateDirectory(foldePath);
CreateModel(mvcName);
CreateUI(mvcName);
CreateCtrl(mvcName);
CreateUICtrl(mvcName);
RegisterModule(mvcName);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
SelectObject("Assets/" + mvcPath);
Debug.Log("[MVCBuildWindow]创建MVC代码模板完成");
}
}
private static void SelectObject(string path)
{
Object obj = AssetDatabase.LoadMainAssetAtPath(path);
if (obj == null) return;
EditorGUIUtility.PingObject(obj);
Selection.activeObject = obj;
}
private static void CreateModel(string className)
{
string modelClassStr =
@"using BingoBrain.Core;
namespace BingoBrain
{
public class #ClassName#Model : BaseModel
{
#region 生命周期
protected override void OnInit()
{
}
protected override void OnDispose()
{
}
protected override void OnReset()
{
}
#endregion
}
}";
string replaceClassName = "#ClassName#";
modelClassStr = modelClassStr.Replace(replaceClassName, className);
string targetPath = foldePath + "/" + className + "Model.cs";
File.WriteAllText(targetPath, modelClassStr, new UTF8Encoding(false));
}
private static void CreateUI(string className)
{
string uiClassStr =
@"using BingoBrain.Core;
using BingoBrain.HotFix;
using FGUI.ACommon;
using UnityEngine;
namespace BingoBrain
{
public class #ClassName#UI : BaseUI
{
private #ClassName#UICtrl ctrl;
private #ClassName#Model model;
private FGUI.#PackageName#.#CompName# ui;
public #ClassName#UI(#ClassName#UICtrl ctrl) : base(ctrl)
{
uiName = UIConst.#ClassName#UI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = ""#PackageName#"";
uiInfo.assetName = ""#CompName#"";
uiInfo.layerType = UILayerType.Normal;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region 生命周期
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.#ClassName#Model) as #ClassName#Model;
}
protected override void OnClose()
{
}
protected override void OnBind()
{
ui = baseUI as FGUI.#PackageName#.#CompName#;
}
protected override void OnOpenBefore(object args)
{
InitView();
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region 消息
protected override void AddListener()
{
}
protected override void RemoveListener()
{
}
#endregion
//初始化页面逻辑
private void InitView()
{
}
}
}";
string replacePackageName = "#PackageName#";
uiClassStr = uiClassStr.Replace(replacePackageName, fguiPackageName);
string replaceCompName = "#CompName#";
uiClassStr = uiClassStr.Replace(replaceCompName, fguiCompName);
string replaceClassName = "#ClassName#";
uiClassStr = uiClassStr.Replace(replaceClassName, className);
string targetPath = foldePath + "/" + className + "UI.cs";
File.WriteAllText(targetPath, uiClassStr, new UTF8Encoding(false));
}
private static void CreateCtrl(string className)
{
string ctrlClassStr =
@"using BingoBrain.Core;
namespace BingoBrain
{
public class #ClassName#Ctrl : BaseCtrl
{
public static #ClassName#Ctrl Instance { get; private set; }
private #ClassName#Model model;
#region 生命周期
protected override void OnInit()
{
Instance = this;
//model = ModuleManager.Instance..GetModel(ModelConst.#ClassName#Model) as #ClassName#Model;
}
protected override void OnDispose()
{
Instance = null;
}
#endregion
}
}";
string replaceClassName = "#ClassName#";
ctrlClassStr = ctrlClassStr.Replace(replaceClassName, className);
string targetPath = foldePath + "/" + className + "Ctrl.cs";
File.WriteAllText(targetPath, ctrlClassStr, new UTF8Encoding(false));
}
private static void CreateUICtrl(string className)
{
string uiCtrlClassStr =
@"using BingoBrain.Core;
using BingoBrain.HotFix;
namespace BingoBrain
{
public class #ClassName#UICtrl : BaseUICtrl
{
private #ClassName#UI ui;
private #ClassName#Model model;
private uint openUIMsg = SkinInfo.#ClassName#UI_Open;
private uint closeUIMsg = SkinInfo.#ClassName#UI_Close;
#region 生命周期
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.#ClassName#Model) as #ClassName#Model;
}
protected override void OnDispose()
{
}
public override void OpenUI(object args = null)
{
if (ui == null)
{
ui = new #ClassName#UI(this);
ui.Open(args);
}
}
public override void CloseUI(object args = null)
{
if (ui != null && !ui.isClose)
{
ui.Close();
}
ui = null;
}
#endregion
#region 消息
public override uint GetOpenUIMsg(string uiName)
{
return openUIMsg;
}
public override uint GetCloseUIMsg(string uiName)
{
return closeUIMsg;
}
protected override void AddListener()
{
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
}
protected override void RemoveListener()
{
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
}
protected override void AddServerListener()
{
}
protected override void RemoveServerListener()
{
}
#endregion
}
}";
string replaceClassName = "#ClassName#";
uiCtrlClassStr = uiCtrlClassStr.Replace(replaceClassName, className);
string targetPath = foldePath + "/" + className + "UICtrl.cs";
File.WriteAllText(targetPath, uiCtrlClassStr, new UTF8Encoding(false));
}
//测试
// [MenuItem("Jarvis/MVC/RegisterModuleXXX", false, 0)]
// static void RegisterModuleXXX(){
// RegisterModule("mmm");
// AssetDatabase.SaveAssets();
// AssetDatabase.Refresh();
// }
//注册模块
static void RegisterModule(string name){
//模块管理路径以及相关文件路径
string moduleMngRootPath = Application.dataPath + "/BingoBrain/ModuleBoard/";
string ctrlPath = moduleMngRootPath + "CtrlConst.cs";
string modelPath = moduleMngRootPath + "ModelConst.cs";
string uiConstPath = moduleMngRootPath + "UIConst.cs";
string uiCtrlPath = moduleMngRootPath + "UICtrlConst.cs";
string moduleMngPath = moduleMngRootPath + "ModuleBoard.cs";
string UICtrlMsgPath = Application.dataPath + "/BingoBrain/Model/Info/SkinInfot.cs";
//注册模块的常量
InsertString(ctrlPath, $"\tpublic const string {name}Ctrl = \"{name}Ctrl\";\n\t");
InsertString(modelPath, $"\tpublic const string {name}Model = \"{name}Model\";\n\t");
InsertString(uiConstPath, $"\tpublic const string {name}UI = \"{name}UI\";\n\t");
InsertString(uiCtrlPath, $"\tpublic const string {name}UICtrl = \"{name}UICtrl\";\n\t");
//在模块类注册新模块
InsertStringBeforeCharIndex(moduleMngPath, 0, $"\tmoduleBoardk.AddModel(ModelConst.{name}Model, new {name}Model());\n\t\t");
InsertStringBeforeCharIndex(moduleMngPath, 1, $"\tmoduleBoardk.AddUIType(UIConst.{name}UI, typeof({name}UI));\n\t\t");
InsertStringBeforeCharIndex(moduleMngPath, 2, $"\tmoduleBoardk.AddCtrl(CtrlConst.{name}Ctrl, new {name}Ctrl());\n\t\t");
InsertStringBeforeCharIndex(moduleMngPath, 3, $"\tmoduleBoardk.AddUICtrl(UICtrlConst.{name}UICtrl, new {name}UICtrl());\n\t\t");
InsertString(UICtrlMsgPath, $"\tpublic static uint {name}UI_Open = ++cursor_OpenClose;\n\t\tpublic static uint {name}UI_Close = ++cursor_OpenClose;\n\t");
}
static void InsertString(string path, string str){
string f = File.ReadAllText(path);
int index = f.IndexOf('}');
f = f.Insert(index, str);
File.WriteAllText(path, f);
}
static void InsertStringBeforeCharIndex(string path, int charIndex, string str){
string f = File.ReadAllText(path);
int indexCount = 0;
int index = -1;
for (int i = 0; i < f.Length; i++)
{
char c = f[i];
if (c == '}' ){
if (indexCount == charIndex){
index = i;
break;
}
else{
indexCount++;
}
}
}
if (index != -1){
f = f.Insert(index, str);
File.WriteAllText(path, f);
}
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f5710d8468c84d0b95aa4cc0b36b25e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7926ab78fe6049f3bff905262b9b4695
timeCreated: 1682307945
@@ -0,0 +1,4 @@
namespace BingoBrain.Core
{
public class AppDispatcher : BaseDispatcher<AppDispatcher, uint, object> { }
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 38ec268add4ac6743a27b7167bdcb36a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace BingoBrain.Core
{
public class ChannelDispatcher : BaseMainThreadDispatcher<ChannelDispatcher, uint, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 218317b638152b54baaa92a640f944ec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace BingoBrain.Core
{
public class CtrlDispatcher : BaseDispatcher<CtrlDispatcher, uint, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f627301519ad9ac43ba05e525564d3a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace BingoBrain.Core
{
public class DataDispatcher : BaseDispatcher<DataDispatcher, string, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 080dce14c0be15a448f7a6f1d316700f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace BingoBrain.Core
{
public class GameDispatcher : BaseDispatcher<GameDispatcher, uint, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ab8a1624eafed174385147056385f287
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More