示例#1
0
 public virtual void Init(BaseCoreMono mono)
 {
     SelfMono       = mono;
     SelfBaseGlobal = BaseGlobal.Ins;
     if (SelfMono is BaseUnit)
     {
         SelfBaseUnit = SelfMono as BaseUnit;
     }
 }
示例#2
0
 public override void OnCreate()
 {
     base.OnCreate();
     UnitType   = typeof(TUnit);
     ConfigType = typeof(TConfig);
     GMgr       = BaseGlobal.GetSpawnMgr(UnitType) as BaseUnitSpawnMgr <TUnit, TConfig>;
     if (GMgr == null)
     {
         CLog.Error("错误! GMgr(BaseUnitSpawnMgr)为空:{0},{1}", UnitType.ToString(), ConfigType.ToString());
     }
 }
示例#3
0
        // 卸载战场
        IEnumerator <float> _UnLoadBattle(Callback onDone)
        {
            if (CurData == null)
            {
                yield break;
            }
            IsLoadingBattle = false;
            IsLoadBattleEnd = false;
            IsGameStart     = false;
            CurData.OnBeRemoved();
            CurData = null;
            yield return(Timing.WaitForOneFrame);

            Callback_OnBattleUnLoad?.Invoke();
            yield return(Timing.WaitForOneFrame);

            Callback_OnLoadingProgressChanged?.Invoke("Start to load", 0.01f);
            //延时一秒.防止UI卡住
            yield return(Timing.WaitForSeconds(0.3f));

            var wait = SceneManager.UnloadSceneAsync(SceneName);

            while (!wait.isDone)
            {
                yield return(Timing.WaitForOneFrame);

                Callback_OnLoadingProgressChanged?.Invoke("UnloadScene", wait.progress);
            }

            //卸载未使用的资源
            GRMgr.UnloadScene(SceneAsset);

            Callback_OnLoadingProgressChanged?.Invoke("GC", 1.0f);
            BaseGlobal.ResumeGame();
            yield return(Timing.WaitForOneFrame);

            Callback_OnBattleUnLoaded?.Invoke();
            onDone?.Invoke();
        }
示例#4
0
        // 卸载战场
        IEnumerator <float> _unLoadBattle(Callback onDone)
        {
            IsLoadedScene        = false;
            IsLoadingBattle      = false;
            IsLoadBattleEnd      = false;
            IsGameStartOver      = false;
            IsInPauseLoadingView = false;
            CurData.OnBeRemoved();
            CurData = null;
            //暂停一段时间
            BaseGlobal.PauseGame(true);
            BaseInputMgr.ResetFullScreenState();
            Callback_OnBattleUnLoad?.Invoke();
            yield return(Timing.WaitForOneFrame);

            Callback_OnLoadingProgressChanged?.Invoke("Start to load", 0.01f);
            //延时一秒.防止UI卡住
            yield return(Timing.WaitForSeconds(0.5f));

            var wait = SceneManager.UnloadSceneAsync(SceneName);

            while (!wait.isDone)
            {
                yield return(Timing.WaitForOneFrame);

                Callback_OnLoadingProgressChanged?.Invoke("UnloadScene", wait.progress);
            }

            //卸载未使用的资源
            GRMgr.UnloadScene(SceneAsset);

            Callback_OnLoadingProgressChanged?.Invoke("GC", 1.0f);
            yield return(Timing.WaitForOneFrame);

            Callback_OnBattleUnLoaded?.Invoke();
            BaseGlobal.ResumeGame();
            onDone?.Invoke();
        }
示例#5
0
 protected override void OnEnable()
 {
     base.OnEnable();
     BaseGlobal = (BaseGlobal)target;
 }
示例#6
0
 public BaseSequence()
 {
     SelfBaseGlobal = BaseGlobal.Ins;
 }
示例#7
0
 public override void Awake()
 {
     base.Awake();
     SelfBaseGlobal = BaseGlobal.Ins;
 }
示例#8
0
 public virtual BaseUnit GetUnit(int id) => BaseGlobal.GetUnit <TUnit>(id);
示例#9
0
 public virtual BaseUnit GetUnit(string id) => BaseGlobal.GetUnit <TUnit>(id);
示例#10
0
        // 加载战场
        // readData:是否读取数据
        IEnumerator <float> _loadBattle(bool readData = true)
        {
            BaseGlobal.ResumeGame();
            BaseInputMgr.ResetFullScreenState();
            Callback_OnBattleLoadStart?.Invoke();
            yield return(Timing.WaitForOneFrame);

            float startTime = Time.realtimeSinceStartup;

            IsLoadedScene        = false;
            IsLoadingBattle      = true;
            IsLoadBattleEnd      = false;
            IsGameStartOver      = false;
            IsGameStart          = false;
            IsInPauseLoadingView = false;
            //开始Tip
            BattleCoroutine.Run(_randTip());
            //开始加载
            Callback_OnBattleLoad?.Invoke();
            yield return(Timing.WaitForOneFrame);

            OnLoadSceneStart();
            Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("StartToLoad"), 0.0f);
            //演示几秒,给UI渐变的时间
            yield return(Timing.WaitForSeconds(DelayLoadSceneTime));

            //加载场景
            SceneName  = CurData.GetSceneName();
            SceneAsset = GRMgr.LoadScene(SceneName);
            while (!SceneAsset.IsDone)
            {
                yield return(Timing.WaitForOneFrame);

                Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("LoadingScene"), SceneAsset.Progress * 0.8f);
            }
            //延时一帧
            yield return(Timing.WaitForOneFrame);

            Scene = SceneManager.GetSceneByName(SceneName);
            SceneManager.SetActiveScene(Scene);
            IsLoadedScene = true;
            Callback_OnBattleLoadedScene?.Invoke();
            if (BaseSceneObject == null)
            {
                CLog.Error("错误,场景里没有SceneObject");
            }
            //这里必须延迟一帧,等待UI创建,注册事件
            yield return(Timing.WaitForOneFrame);

            //读取数据前,资源加载
            yield return(Timing.WaitUntilDone(BattleCoroutine.Run(BeforeReadData())));

            Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("BeforeReadData"), 0.9f);
            if (readData)
            {
                BaseGlobal.IsUnReadData = false;
                //读取战场数据
                BaseGlobal.DBMgr.ReadGameDBData();
                BaseGlobal.IsUnReadData = true;
            }
            yield return(Timing.WaitForOneFrame);

            Callback_OnBattleReadDataEnd?.Invoke();
            //增加加载战场次数
            LoadBattleCount++;
            //读取数据后资源加载
            yield return(Timing.WaitUntilDone(BattleCoroutine.Run(AffterReadData())));

            Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("AffterReadData"), 0.95f);
            while (IsInCustomLoading)
            {
                yield return(Timing.WaitForOneFrame);
            }
            GC.Collect();
            Callback_OnLoadingProgressChanged?.Invoke(Util.GetStr("GC"), 1.0f);
            IsLoadingBattle = false;
            //场景加载结束
            Callback_OnBattleLoaded?.Invoke();
            IsLoadBattleEnd = true;
            yield return(Timing.WaitForOneFrame);

            //游戏开始(预处理最后阶段)
            SelfBaseGlobal.OnGameStart1();
            SelfBaseGlobal.OnGameStart2();
            Callback_OnGameStart?.Invoke();
            yield return(Timing.WaitForOneFrame);

            SelfBaseGlobal.OnGameStarted1();
            SelfBaseGlobal.OnGameStarted2();
            Callback_OnGameStarted?.Invoke();
            IsGameStart = true;
            //暂停在加载界面
            Callback_OnInPauseLoadingView?.Invoke();
            IsInPauseLoadingView = NeedPauseLoading;
            while (IsInPauseLoadingView)
            {
                yield return(Timing.WaitForOneFrame);
            }
            SelfBaseGlobal.OnCloseLoadingView();
            Callback_OnCloseLoadingView?.Invoke();
            //锁定进入战场流程
            while (IsLockBattleStartFlow)
            {
                yield return(Timing.WaitForOneFrame);
            }
            yield return(Timing.WaitUntilDone(BattleCoroutine.Run(BattleStart())));

            //进入自定义流程的时候暂停
            Callback_OnStartCustomBattleCoroutine?.Invoke();
            if (PlotMgr != null)
            {
                PlotMgr?.SetPlotPause(true);
                yield return(Timing.WaitUntilDone(PlotMgr.CustomStartBattleCoroutine()));

                PlotMgr?.SetPlotPause(false);
            }
            Callback_OnEndCustomBattleCoroutine.Invoke();
            //结尾部分
            SelfBaseGlobal.OnGameStartOver();
            Callback_OnGameStartOver?.Invoke();
            IsGameStartOver = true;
        }
示例#11
0
 public void Jump(Vector3 pos, float?heightPercent = null)
 {
     Jump(BaseGlobal.GetTransform(pos), heightPercent);
 }
示例#12
0
 public List <long> GetEntityIDs(HashList <BaseUnit> entity) => BaseGlobal.GetUnitIDs(entity);
示例#13
0
 public HashList <BaseUnit> GetEntity(List <long> ids) => BaseGlobal.GetUnit(ids);
示例#14
0
 public BaseUnit GetEntity(string id, Type unitType        = null, bool isLogError = true) => BaseGlobal.GetUnit(id, unitType, isLogError);
示例#15
0
 public TUnit GetEntity <TUnit>(string id, bool isLogError = true) where TUnit : BaseUnit => BaseGlobal.GetUnit <TUnit>(id, isLogError);