Example #1
0
        protected override void OnDataChanged()
        {
            if (m_LoadingStage == LoadingStage.Loading)
            {
                m_LoadingStage = LoadingStage.None;

                ShowOrHideLoadingObject(false);
            }
        }
        public static void InsertInitialLoadStage(LoadingStage stage, int where)
        {
            if (where >= LoadingScreen.BootLoadList.Count || where < 0)
            {
                Log.Warning($"An attempt was made to insert a loading stage into the boot load list at index {where} which is out of bounds considering it contains {LoadingScreen.BootLoadList.Count} items. This attempt will be ignored.");
                return;
            }

            LoadingScreen.BootLoadList.Insert(where, stage);
        }
Example #3
0
 public void HandshakeInitializeGUI()
 {
     Thread t = new Thread(new ParameterizedThreadStart(this.LoadTextures));
     t.Start((object)GameFramework.Instance());
     _loading_textures = true;
     lock (this)
     {
         Stage = LoadingStage.TEXTURE;
     }
     SceneMode = MODE.SCENE_RENDER;
 }
Example #4
0
        public override void OnDrag(PointerEventData eventData)
        {
            base.OnDrag(eventData);

            if (m_LoadingStage == LoadingStage.None && m_AutoLoading)
            {
                if (verticalNormalizedPosition > 1f && (content.anchoredPosition.y + viewRect.rect.height - content.rect.height) > m_LoadingDistance)
                {
                    m_LoadingStage = LoadingStage.MoveToBottom;
                }
            }
        }
Example #5
0
        public void HandshakeInitializeGUI()
        {
            Thread t = new Thread(new ParameterizedThreadStart(this.LoadTextures));

            t.Start((object)GameFramework.Instance());
            _loading_textures = true;
            lock (this)
            {
                Stage = LoadingStage.TEXTURE;
            }
            SceneMode = MODE.SCENE_RENDER;
        }
Example #6
0
 public override void FinishLoading()
 {
     if (_updateStage == LoadingStage.Loading)
     {
         _updateStage = LoadingStage.None;
         if (loadingObject != null)
         {
             loadingObject.SetActive(false);
             loadingObject.transform.SetParent(transform, false);
         }
     }
 }
Example #7
0
        public override void OnEndDrag(PointerEventData eventData)
        {
            base.OnEndDrag(eventData);

            if (m_LoadingStage == LoadingStage.MoveToBottom)
            {
                m_LoadingStage = LoadingStage.Loading;

                ShowOrHideLoadingObject(true);

                m_OnLoadingStart.Call();
            }
        }
Example #8
0
        public void HandshakeInitializeGUI()
        {
            Thread t = new Thread(new ParameterizedThreadStart(this.LoadTextures));

            t.Start((object)GameFramework.Instance());
            //DDD_Global.Instance.PlayerID = _menu_selection;
            _player_window.Hide();
            _continue = true;
            _continue_btn.Selected = false;
            _loading_textures      = true;
            lock (this)
            {
                Stage = LoadingStage.TEXTURE;
            }
        }
Example #9
0
        public override void OnEndDrag(PointerEventData eventData)
        {
            base.OnEndDrag(eventData);

            if (_updateStage == LoadingStage.MoveToBottom)
            {
                if (loadingObject != null)
                {
                    loadingObject.transform.SetParent(content, false);
                    loadingObject.transform.SetAsLastSibling();
                    loadingObject.SetActive(true);
                }

                _updateStage = LoadingStage.Loading;

                startLoadingAction.Call();
            }
        }
Example #10
0
        public void LoadTextures(object obj) {
            GameFramework g = (GameFramework)obj;
            GameTexture _texture;
            List<string> names = new List<string>();


            try
            {
                StreamReader s = new StreamReader(ImageLib.GetManifestResourceStream("ImageLibrary.mf"));

                while (!s.EndOfStream)
                {
                    names.Add(s.ReadLine());
                }
                for (int i = 0; i < names.Count; i++)
                {
                    _texture = g.CreateTexture(ImageLib.GetManifestResourceStream(names[i]));
                    g.StoreTexture(names[i], _texture);
                    lock (this)
                    {
                        Message = string.Format("Texture {0} of {1}", i + 1, names.Count);
                    }
                }
                s.Close();
            }
            catch (Exception)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message = "Error loading texture";
                    MsgColor = Color.Red;
                }
                return;
            }

            lock (this)
            {
                Stage = LoadingStage.BACKGROUND;
            }
            try
            {
                 GameTexture Map = g.CreateTexture(DDD_Global.Instance.MapLocation);

                Controller.UTM_Mapping.ImageHeight = Map.height;
                Controller.UTM_Mapping.ImageWidth = Map.width;
                g.StoreTexture("MAP", Map);

            }
            catch (ArgumentException)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message = "Map file missing: " + DDD_Global.Instance.MapName;
                    MsgColor = Color.Red;
                }
                return;
            }

            lock (this)
            {
                Stage = LoadingStage.FINISHED;
            }
        }
Example #11
0
        public void LoadTextures(object obj) {
            string path = string.Empty;
            try
            {
                path = string.Format("{0}\\{1}.dll", DDD_Global.Instance.DDDClientShareFolder, DDD_Global.Instance.ImageLibrary);
                if (!File.Exists(path))
                {
                    path = string.Format(@"{0}\DDDClient\{1}.dll", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), DDD_Global.Instance.ImageLibrary);
                }
                ImageLib = Assembly.LoadFile(path);
            }
            catch (Exception e)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message = "Missing Image Libary";
                    MsgColor = Color.Red;
                    Thread.Sleep(2000);

                    throw new Exception(Message + ":" + path + ":" + e.Message);

                }
                return;
            }

            
            GameFramework g = (GameFramework)obj;
            GameTexture _texture;
            List<string> names = new List<string>();


            try
            {
                StreamReader s = new StreamReader(ImageLib.GetManifestResourceStream("ImageLibrary.mf"));

                while (!s.EndOfStream)
                {
                    names.Add(s.ReadLine());
                }
                for (int i = 0; i < names.Count; i++)
                {
                    string[] texture_name = names[i].Split(':');
                    _texture = g.CreateTexture(ImageLib.GetManifestResourceStream(texture_name[0]));
                    _texture.rotate = bool.Parse(texture_name[1]);
                    g.StoreTexture(texture_name[0], _texture);
                    lock (this)
                    {
                        Message = string.Format("Texture {0} of {1}", i + 1, names.Count);
                    }
                }
                s.Close();
            }
            catch (Exception)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message = "Error loading texture";
                    MsgColor = Color.Red;
                }
                return;
            }

            lock (this)
            {
                Stage = LoadingStage.BACKGROUND;
            }

            bool continue_looping = true;
            GameTexture Map;
            while (continue_looping)
            {
                if (DDD_Global.Instance.MapLocation != string.Empty)
                {
                    try
                    {
                        if (File.Exists(DDD_Global.Instance.MapLocation))
                        {
                            Map = g.CreateTexture(DDD_Global.Instance.MapLocation);
                        }
                        else
                        {
                            Map = g.CreateTexture(string.Format("{0}\\MapLib\\{1}", DDD_Global.Instance.DDDClientShareFolder, DDD_Global.Instance.MapName));
                        }
                        Controller.UTM_Mapping.ImageHeight = Map.height;
                        Controller.UTM_Mapping.ImageWidth = Map.width;
                        g.StoreTexture("MAP", Map);
                        continue_looping = false;
                    }
                    catch (Exception)
                    {
                        SceneMode = MODE.SCENE_ERROR;
                        Message = "Map file missing: " + DDD_Global.Instance.MapName;
                        MsgColor = Color.Red;
                        continue_looping = false;
                        Thread.Sleep(2000);

                        throw new Exception(Message);
                    }

                }
                else
                {
                    Thread.Sleep(2000);
                }
            }

            
            lock (this)
            {
                Stage = LoadingStage.FINISHED;
                DDD_RangeRings.SetCanvasPtr(GameFramework.Instance().CANVAS);
            }
        }
Example #12
0
        public void LoadTextures(object obj)
        {
            string path = string.Empty;

            try
            {
                path = string.Format("{0}\\{1}.dll", DDD_Global.Instance.DDDClientShareFolder, DDD_Global.Instance.ImageLibrary);
                if (!File.Exists(path))
                {
                    path = string.Format(@"{0}\DDDClient\{1}.dll", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), DDD_Global.Instance.ImageLibrary);
                }
                ImageLib = Assembly.LoadFile(path);
            }
            catch (Exception e)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message   = "Missing Image Libary";
                    MsgColor  = Color.Red;
                    Thread.Sleep(2000);

                    throw new Exception(Message + ":" + path + ":" + e.Message);
                }
                return;
            }


            GameFramework g = (GameFramework)obj;
            GameTexture   _texture;
            List <string> names = new List <string>();


            try
            {
                StreamReader s = new StreamReader(ImageLib.GetManifestResourceStream("ImageLibrary.mf"));

                while (!s.EndOfStream)
                {
                    names.Add(s.ReadLine());
                }
                for (int i = 0; i < names.Count; i++)
                {
                    string[] texture_name = names[i].Split(':');
                    _texture        = g.CreateTexture(ImageLib.GetManifestResourceStream(texture_name[0]));
                    _texture.rotate = bool.Parse(texture_name[1]);
                    g.StoreTexture(texture_name[0], _texture);
                    lock (this)
                    {
                        Message = string.Format("Texture {0} of {1}", i + 1, names.Count);
                    }
                }
                s.Close();
            }
            catch (Exception)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message   = "Error loading texture";
                    MsgColor  = Color.Red;
                }
                return;
            }

            lock (this)
            {
                Stage = LoadingStage.BACKGROUND;
            }

            bool        continue_looping = true;
            GameTexture Map;

            while (continue_looping)
            {
                if (DDD_Global.Instance.MapLocation != string.Empty)
                {
                    try
                    {
                        if (File.Exists(DDD_Global.Instance.MapLocation))
                        {
                            Map = g.CreateTexture(DDD_Global.Instance.MapLocation);
                        }
                        else
                        {
                            Map = g.CreateTexture(string.Format("{0}\\MapLib\\{1}", DDD_Global.Instance.DDDClientShareFolder, DDD_Global.Instance.MapName));
                        }
                        Controller.UTM_Mapping.ImageHeight = Map.height;
                        Controller.UTM_Mapping.ImageWidth  = Map.width;
                        g.StoreTexture("MAP", Map);
                        continue_looping = false;
                    }
                    catch (Exception)
                    {
                        SceneMode        = MODE.SCENE_ERROR;
                        Message          = "Map file missing: " + DDD_Global.Instance.MapName;
                        MsgColor         = Color.Red;
                        continue_looping = false;
                        Thread.Sleep(2000);

                        throw new Exception(Message);
                    }
                }
                else
                {
                    Thread.Sleep(2000);
                }
            }


            lock (this)
            {
                Stage = LoadingStage.FINISHED;
                DDD_RangeRings.SetCanvasPtr(GameFramework.Instance().CANVAS);
            }
        }
Example #13
0
        IEnumerator LoadingRunning()
        {
            eLoadingStage = LoadingStage.LS_START;
            Debug.LogFormat("[gameLoading]:{0}", eLoadingStage);

            var begin = Time.time;

            if (loadingAnimation != null)
            {
                //AudioManager.Instance.PlayMusic(loadingSoundEffect,1.0f,false,false);

                loadingAnimation.AnimationState.SetAnimation(0, loadingStartAnimation[(int)eLoadingStage], false);

                loadingAnimation.AnimationState.Complete += (Spine.TrackEntry trackEntry) =>
                {
                    if (null != trackEntry)
                    {
                        string animationName = trackEntry.Animation.Name;

                        if (animationName == loadingStartAnimation[(int)LoadingStage.LS_START])
                        {
                            eLoadingStage = LoadingStage.LS_RUNNING;
                            loadingAnimation.AnimationState.SetAnimation(0, loadingStartAnimation[(int)eLoadingStage], true);
                        }
                        //else if(animationName == loadingStartAnimation[(int)LoadingStage.LS_END])
                        //{
                        //eLoadingStage = LoadingStage.LS_TRIGGER_FINISH;
                        //}
                    }
                };
            }

            while (eLoadingStage == LoadingStage.LS_START)
            {
                yield return(null);
            }

            Debug.LogFormat("[gameLoading]:{0}", eLoadingStage);
            yield return(enumeratorRunning);

            var delta = Time.time - begin;

            if (delta < loadingSoundEffect.length)
            {
                yield return(new WaitForSeconds(loadingSoundEffect.length - delta));
            }

            if (!actionLoadingResult())
            {
                if (null != actionFailed)
                {
                    actionFailed.Invoke();
                }
                //yield return UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync("LoadingScene");
                yield break;
            }

            eLoadingStage = LoadingStage.LS_END;
            Debug.LogFormat("[gameLoading]:{0}", eLoadingStage);
            loadingAnimation.AnimationState.SetAnimation(0, loadingStartAnimation[(int)eLoadingStage], false);

            yield return(null);

            Resources.UnloadUnusedAssets();
            System.GC.Collect();
            yield return(new WaitForSeconds(0.30f));

            eLoadingStage = LoadingStage.LS_TRIGGER_FINISH;
            Debug.LogFormat("[gameLoading]:{0}", eLoadingStage);

            yield return(enumeratorEnd);

            if (!actionLoadingResult())
            {
                //yield return UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync("LoadingScene");
                if (null != actionFailed)
                {
                    actionFailed.Invoke();
                }
            }
        }
Example #14
0
        void LoadLevel()
        {
            if (load_stage != null)
                //load_stage = new LoadingStage(LoadedResources, this);
            //else
            {

                load_stage.backgroundThread.Abort();
                load_stage.EndLoading();

                while (load_stage.backgroundThread.IsThreadPoolThread)
                {
                    //wait?
                }
                load_stage.SetThreads();
            }

            Loaded = false;
            LOADING = false;

            load_stage = new LoadingStage(LoadedResources, this);

            timeStart = DateTime.Now;
            timeEnd = TimeSpan.Zero;
            load_frame_count = 0;

            GetLoadList();

            List<String> resList = GetLevelTextures();
            load_stage.AddToTex2DList(resList);

            resList = GetLevelModels();
            load_stage.AddToModelList(resList);

            load_stage.LoadContent();
        }
Example #15
0
        public void LoadTextures(object obj)
        {
            GameFramework g = (GameFramework)obj;
            GameTexture   _texture;
            List <string> names = new List <string>();


            try
            {
                StreamReader s = new StreamReader(ImageLib.GetManifestResourceStream("ImageLibrary.mf"));

                while (!s.EndOfStream)
                {
                    names.Add(s.ReadLine());
                }
                for (int i = 0; i < names.Count; i++)
                {
                    _texture = g.CreateTexture(ImageLib.GetManifestResourceStream(names[i]));
                    g.StoreTexture(names[i], _texture);
                    lock (this)
                    {
                        Message = string.Format("Texture {0} of {1}", i + 1, names.Count);
                    }
                }
                s.Close();
            }
            catch (Exception)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message   = "Error loading texture";
                    MsgColor  = Color.Red;
                }
                return;
            }

            lock (this)
            {
                Stage = LoadingStage.BACKGROUND;
            }
            try
            {
                GameTexture Map = g.CreateTexture(DDD_Global.Instance.MapLocation);

                Controller.UTM_Mapping.ImageHeight = Map.height;
                Controller.UTM_Mapping.ImageWidth  = Map.width;
                g.StoreTexture("MAP", Map);
            }
            catch (ArgumentException)
            {
                lock (this)
                {
                    SceneMode = MODE.SCENE_ERROR;
                    Message   = "Map file missing: " + DDD_Global.Instance.MapName;
                    MsgColor  = Color.Red;
                }
                return;
            }

            lock (this)
            {
                Stage = LoadingStage.FINISHED;
            }
        }
 public static void AddInitialLoadStage(LoadingStage stage)
 {
     LoadingScreen.BootLoadList.Add(stage);
 }
Example #17
0
        public void HandshakeInitializeGUI()
        {
            Thread t = new Thread(new ParameterizedThreadStart(this.LoadTextures));
            t.Start((object)GameFramework.Instance());
            //DDD_Global.Instance.PlayerID = _menu_selection;
            _player_window.Hide();
            _continue = true;
            _continue_btn.Selected = false;
            _loading_textures = true;
            lock (this)
            {
                Stage = LoadingStage.TEXTURE;
            }

        }
        public void OnGUI()
        {
            if (!shouldShow)
            {
                return;
            }

            if (!LongEventHandler.AnyEventNowOrWaiting)
            {
                Log.Message("Long event has finished, hiding loading screen.");
                shouldShow = false;
                return;
            }

            if (background == null)
            {
                background = SolidColorMaterials.NewSolidColorTexture(new Color(0.1f, 0.1f, 0.1f, 1));
            }
            if (warningBarColor == null)
            {
                warningBarColor = SolidColorMaterials.NewSolidColorTexture(new Color(0.89f, 0.8f, 0.11f)); //RGB (226,203,29)
            }
            if (errorBarColor == null)
            {
                errorBarColor = SolidColorMaterials.NewSolidColorTexture(new Color(0.73f, 0.09f, 0.09f)); //RGB(185, 24, 24)
            }
            try
            {
                List <LoadingStage>?currentList = null;
                if (BootLoadList.Contains(_currentStage))
                {
                    currentList = BootLoadList;
                }

                if (currentList == null)
                {
                    Log.Error("BetterLoading: Current Load Stage is not in a load list!");
                    shouldShow = false;
                    return;
                }

                var idx = currentList.IndexOf(_currentStage);

                //Handle cases where this stage is complete.
                while (_currentStage.IsCompleted())
                {
                    if (idx + 1 >= currentList.Count)
                    {
                        Log.Message("BetterLoading: Finished processing load list, hiding.");
                        shouldShow = false;
                        return;
                    }

                    //Move to next stage
                    Log.Message("BetterLoading: Finished stage " + _currentStage.GetStageName() + " at " + DateTime.Now.ToLongTimeString());
                    _currentStage.BecomeInactive();
                    StageTimingData.ExecutedStages.Last().end = DateTime.Now;

                    _currentStage = currentList[idx + 1];
                    _currentStage.BecomeActive();
                    Log.Message("BetterLoading: Starting stage " + _currentStage.GetStageName());
                    StageTimingData.ExecutedStages.Add(new StageTimingData
                    {
                        start = DateTime.Now,
                        stage = _currentStage
                    });
                    idx++;
                }

                var currentProgress = _currentStage.GetCurrentProgress();
                var maxProgress     = _currentStage.GetMaximumProgress();

                if (maxProgress == 0)
                {
                    Log.Warning($"BetterLoading :: Stage {_currentStage.GetType().FullName} returned maxProgress = 0");
                    maxProgress = 1;
                }

                if (currentProgress > maxProgress)
                {
                    Log.Error(
                        $"BetterLoading: Clamping! The stage of type {_currentStage.GetType().FullName} has returned currentProgress {currentProgress} > maxProgress {maxProgress}. Please report this!",
                        true);
                    currentProgress = maxProgress;
                }

                //Draw background
                var bgRect = new Rect(0, 0, Screen.width, Screen.height);
                GUI.DrawTexture(bgRect, background);

                //Draw title
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;

                var titleRect = new Rect(200, 200, Screen.width - 400, 40);
                Widgets.Label(titleRect, "Initializing Game...");

                Text.Font = GameFont.Small;


                //Render current stage bar and label
                var pct = currentProgress / (float)maxProgress;

                var currentStageText = _currentStage.GetStageName();
                var subStageText     = _currentStage.GetCurrentStepName();
                if (subStageText != null)
                {
                    currentStageText = $"{currentStageText} - {subStageText}";
                }

                var rect = new Rect(200, Screen.height - 440, Screen.width - 400, 40);

                var color = _currentStage.HasError() ? errorBarColor : _currentStage.HasWarning() ? warningBarColor : null;

                if (color != null)
                {
                    Widgets.FillableBar(rect, pct, color);
                }
                else
                {
                    Widgets.FillableBar(rect, pct); //use default blue
                }
                Widgets.Label(rect, $"{currentProgress}/{maxProgress} ({pct.ToStringPercent()})");
                Text.Anchor = TextAnchor.UpperLeft;

                rect.y += 50;
                Widgets.Label(rect, currentStageText);

                //Render global progress bar.
                rect = new Rect(200, Screen.height - 240, Screen.width - 400, 40);

                Text.Anchor = TextAnchor.MiddleCenter;

                pct = (idx + 1) / (float)currentList.Count;
                Widgets.FillableBar(rect, pct);
                Widgets.Label(rect, $"{idx + 1}/{currentList.Count} ({pct.ToStringPercent()})");

                Text.Anchor = TextAnchor.UpperLeft;
            }
            catch (Exception e)
            {
                Log.ErrorOnce($"Encountered exception while rendering loading screen: {e}", 0xBEEF99, true);
            }
        }