提交项目
This commit is contained in:
@@ -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:
|
||||
Reference in New Issue
Block a user