提交小游戏项目
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public sealed class CameraManager : BaseInterfaceManager<CameraManager>
|
||||
{
|
||||
public Transform mainCameraRoot;
|
||||
public GameObject mainCameraGo;
|
||||
public Camera mainCamera;
|
||||
|
||||
public Transform fguiCameraRoot;
|
||||
public GameObject fguiCameraGo;
|
||||
public Camera fguiCamera;
|
||||
|
||||
|
||||
public bool isEnabledWorldRaycast;
|
||||
public Physics2DRaycaster physics2DRaycaster;
|
||||
public PhysicsRaycaster physics3DRaycaster;
|
||||
|
||||
private bool isMainCameraShakeing;
|
||||
|
||||
#region Coordinate
|
||||
|
||||
public Vector2 WorldPosToFGUIPos(Vector3 worldPos)
|
||||
{
|
||||
Vector3 screenPos = mainCamera.WorldToScreenPoint(worldPos);
|
||||
|
||||
screenPos.y = ScreenConst.CurrResolution.y - screenPos.y;
|
||||
Vector2 pt = GRoot.inst.GlobalToLocal(screenPos);
|
||||
return pt;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Func
|
||||
|
||||
public void SetWorldRaycasterEnabled(bool enabled)
|
||||
{
|
||||
isEnabledWorldRaycast = enabled;
|
||||
if (physics2DRaycaster != null)
|
||||
{
|
||||
EventKit.Set2DRaycasterEnabled(physics2DRaycaster, isEnabledWorldRaycast);
|
||||
}
|
||||
|
||||
if (physics3DRaycaster != null)
|
||||
{
|
||||
EventKit.Set3DRaycasterEnabled(physics3DRaycaster, isEnabledWorldRaycast);
|
||||
}
|
||||
|
||||
AppDispatcher.Instance.Dispatch(AppMsg.WorldRaycast_EnableChange, isEnabledWorldRaycast);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Camera
|
||||
|
||||
public void CreateMainCamera()
|
||||
{
|
||||
// if (mainCamera) return;
|
||||
|
||||
// string name = "MainCamera";
|
||||
// mainCameraGo = new GameObject(name);
|
||||
// mainCameraGo.tag = name;
|
||||
// mainCameraGo.layer = LayerMaskConst.Default;
|
||||
// mainCameraGo.transform.localPosition = Vector3.zero;
|
||||
// int cullingMask = LayerMask.GetMask(LayerMaskConst.Default_Name);
|
||||
// mainCamera = CreateCamera(mainCameraGo, cullingMask: cullingMask);
|
||||
// mainCamera.clearFlags = CameraClearFlags.SolidColor;
|
||||
|
||||
// mainCamera.forceIntoRenderTexture = false;
|
||||
|
||||
// GameObject root = new GameObject(name + "Root");
|
||||
// root.transform.position = CameraConst.MainCameraPos;
|
||||
// root.SetParent(AppObjConst.CameraGo);
|
||||
// mainCameraGo.SetParent(root);
|
||||
|
||||
// CameraAdaptive adaptiveCom = mainCamera.gameObject.AddComponent<CameraAdaptive>();
|
||||
// adaptiveCom.DoAdaptive(isOrthographic: true, orthographicSize: ScreenConst.OrthographicSize_1280H);
|
||||
}
|
||||
|
||||
public void CreateFGUICamera()
|
||||
{
|
||||
if (fguiCamera) return;
|
||||
|
||||
StageCamera.CheckMainCamera();
|
||||
fguiCamera = StageCamera.main;
|
||||
fguiCamera.depth = CameraConst.UICameraDepth;
|
||||
|
||||
fguiCamera.forceIntoRenderTexture = false;
|
||||
fguiCameraGo = fguiCamera.gameObject;
|
||||
|
||||
GameObject root = new GameObject("FGUICameraRoot");
|
||||
root.transform.position = CameraConst.UICameraPos;
|
||||
root.SetParent(AppObjConst.CameraGo);
|
||||
fguiCameraGo.SetParent(root);
|
||||
fguiCameraRoot = root.transform;
|
||||
}
|
||||
|
||||
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 = CameraConst.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()
|
||||
{
|
||||
AppObjConst.CameraGo = new GameObject(AppObjConst.CameraGoName);
|
||||
AppObjConst.CameraGo.SetParent(AppObjConst.FrameGo);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
GeneralKit.Destroy(AppObjConst.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,416 @@
|
||||
using System;
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public enum MonthType : int
|
||||
{
|
||||
None = 0,
|
||||
January = 1,
|
||||
February = 2,
|
||||
March = 3,
|
||||
April = 4,
|
||||
May = 5,
|
||||
June = 6,
|
||||
July = 7,
|
||||
August = 8,
|
||||
September = 9,
|
||||
October = 10,
|
||||
November = 11,
|
||||
December = 12,
|
||||
}
|
||||
|
||||
public sealed class DateTimeManager : BaseInterfaceManager<DateTimeManager>
|
||||
{
|
||||
|
||||
|
||||
|
||||
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,50 @@
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public sealed class GameIManager : BaseInterfaceManager<GameIManager>
|
||||
{
|
||||
private float pauseCacheTimeScale = 1;
|
||||
|
||||
#region Scene
|
||||
|
||||
public void InitialMain()
|
||||
{
|
||||
SceneManager.Instance.InitialMain();
|
||||
}
|
||||
|
||||
public void EnterMain()
|
||||
{
|
||||
SceneManager.Instance.SwitchScene(SceneManager.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,200 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public sealed class ModuleManager : BaseInterfaceManager<ModuleManager>
|
||||
{
|
||||
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 = AppConst.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();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public BaseUICtrl GetUICtrl(string uiCtrlName)
|
||||
{
|
||||
BaseUICtrl uiCtrl = null;
|
||||
if (!uiCtrlDict.TryGetValue(uiCtrlName, out uiCtrl))
|
||||
{
|
||||
}
|
||||
|
||||
return uiCtrl;
|
||||
}
|
||||
|
||||
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 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,85 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TowerClimberChronicles
|
||||
{
|
||||
public sealed class SceneManager : BaseInterfaceManager<SceneManager>
|
||||
{
|
||||
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))
|
||||
{
|
||||
SceneSwitchManager.Instance.SwitchInitialScene(DefaultMainSceneIdx, scene.SwitchSceneComplete, param);
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchScene(int sceneIdx, object param = null)
|
||||
{
|
||||
BaseScene scene = GetScene(sceneIdx);
|
||||
if (SetScene(scene))
|
||||
{
|
||||
UIManager.Instance.SwitchSceneCloseAllUI();
|
||||
SceneSwitchManager.Instance.SwitchScene(sceneIdx, scene.SwitchSceneComplete, param);
|
||||
}
|
||||
}
|
||||
|
||||
private bool SetScene(BaseScene scene)
|
||||
{
|
||||
if (scene == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (scene == m_currScene)
|
||||
{
|
||||
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))
|
||||
{
|
||||
}
|
||||
|
||||
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