Beispiel #1
0
        //========================================================================================

        protected void ChangeSubSceneMode(eSubSceneMode newMode)
        {
            if (newMode != currentSubSceneMode && AvailableSubSceneModes.Contains(newMode))
            {
                currentSubSceneMode = newMode;
                hasSubSceneModeChanged = true;
            }
        }
Beispiel #2
0
 public SubSceneJob(RegionBase region, eSubSceneMode subSceneMode, eSubSceneType subSceneType, eSubSceneJobType jobType, Action <SubSceneJob> callback)
 {
     Region       = region;
     SubSceneMode = subSceneMode;
     SubSceneType = subSceneType;
     JobType      = jobType;
     Callback     = callback;
 }
Beispiel #3
0
        private SubSceneJob CreateUnloadSubSceneJob(eSubSceneMode subSceneMode, eSubSceneType subSceneType)
        {
            int index = (int)subSceneMode;
            eSubSceneState state = subSceneStates[index];

            //if (state == eSubSceneState.Unloaded || state == eSubSceneState.Unloading)
            //{
            //    return null;
            //}
            //else
            //{
                subSceneStates[index] = eSubSceneState.Unloading;
                return new SubSceneJob(this, subSceneMode, subSceneType, eSubSceneJobType.Unload, OnSubSceneJobDone);
            //}
        }
Beispiel #4
0
        /// <summary>
        /// Returns the Transform of the SubScene of chosen mode and type.
        /// </summary>
        /// <param name="subSceneType"></param>
        /// <param name="subSceneMode"></param>
        /// <param name="subSceneList"></param>
        /// <returns></returns>
        public Transform GetSubSceneRoot(eSubSceneType subSceneType, eSubSceneMode subSceneMode, List<SubScene> subSceneList = null)
        {
            if (subSceneList == null)
            {
                subSceneList = GetAllSubScenes();
            }

            foreach (var subScene in subSceneList)
            {
                if (subScene.SubSceneMode == subSceneMode && subScene.SubSceneType == subSceneType)
                {
                    return subScene.transform;
                }
            }

            return null;
        }
Beispiel #5
0
        public virtual void Initialize(SuperRegion superRegion)
        {
            if (isInitialized)
            {
                return;
            }

            myTransform = transform;
            this.superRegion = superRegion;

            currentSubSceneMode = InitialSubSceneMode;

            //initializing SubScene states array
            var subScenes = GetAllSubScenes();
            foreach (var subSceneType in Enum.GetValues(typeof(eSubSceneType)).Cast<eSubSceneType>())
            {
                int index = (int)subSceneType;
                subSceneStates[index] = eSubSceneState.Unloaded;

                //if (subScenes.FirstOrDefault(item => item.SubSceneType == subSceneType && item.SubSceneMode == currentSubSceneMode))
                //{
                //    subSceneStates[index] = eSubSceneState.Loaded;
                //}
            }

            //computing corner positions
            Bounds bounds = new Bounds(myTransform.position, boundsSize);
            boundsCorners = new List<Vector3>(){
                new Vector3(bounds.center.x + bounds.extents.x, bounds.center.y + bounds.extents.y, bounds.center.z + bounds.extents.z),
                new Vector3(bounds.center.x + bounds.extents.x, bounds.center.y + bounds.extents.y, bounds.center.z - bounds.extents.z),
                new Vector3(bounds.center.x + bounds.extents.x, bounds.center.y - bounds.extents.y, bounds.center.z + bounds.extents.z),
                new Vector3(bounds.center.x + bounds.extents.x, bounds.center.y - bounds.extents.y, bounds.center.z - bounds.extents.z),
                new Vector3(bounds.center.x - bounds.extents.x, bounds.center.y + bounds.extents.y, bounds.center.z + bounds.extents.z),
                new Vector3(bounds.center.x - bounds.extents.x, bounds.center.y + bounds.extents.y, bounds.center.z - bounds.extents.z),
                new Vector3(bounds.center.x - bounds.extents.x, bounds.center.y - bounds.extents.y, bounds.center.z + bounds.extents.z),
                new Vector3(bounds.center.x - bounds.extents.x, bounds.center.y - bounds.extents.y, bounds.center.z - bounds.extents.z)
            };

            isInitialized = true;
        }
Beispiel #6
0
        void IRegionEventHandler.CreateSubScene(eSubSceneMode subSceneMode, eSubSceneType subSceneType)
        {
            string subScenePath = WorldUtility.GetSubScenePath(gameObject.scene.path, Id, subSceneMode, subSceneType);
            string subScenePathFull = WorldUtility.GetFullPath(subScenePath);

            if (GetSubSceneRoot(subSceneType) != null)
            {
                return;
            }
            else if (System.IO.File.Exists(subScenePathFull))
            {
                Debug.LogFormat("SubScene \"{0}\" already exists but is not loaded!", subScenePath);
                return;
            }
            else
            {
                var rootGO = new GameObject(WorldUtility.GetSubSceneRootName(subSceneMode, subSceneType), typeof(SubScene));
                rootGO.GetComponent<SubScene>().Initialize(subSceneMode, subSceneType);

                var root = rootGO.transform;
                root.SetParent(transform, false);
            }
        }
Beispiel #7
0
 public void Initialize(eSubSceneMode subSceneMode, eSubSceneType subSceneType)
 {
     this.subSceneMode = subSceneMode;
     this.subSceneType = subSceneType;
 }
        /// <summary>
        /// Returns the internal path to a SubScene scene object.
        /// </summary>
        /// <param name="worldScenePath"></param>
        /// <param name="regionId"></param>
        /// <param name="subSceneMode"></param>
        /// <param name="subSceneType"></param>
        /// <returns></returns>
        public static string GetSubScenePath(string worldScenePath, string regionId, eSubSceneMode subSceneMode, eSubSceneType subSceneType)
        {
            string worldScenePathCleaned = worldScenePath.Remove(worldScenePath.LastIndexOf('.'));

            return(string.Concat(worldScenePathCleaned, "/", GetSubSceneName(regionId, subSceneMode, subSceneType), ".unity"));
        }
 /// <summary>
 /// Returns the name for a SubScene scene object.
 /// </summary>
 /// <param name="regionId"></param>
 /// <param name="subSceneMode"></param>
 /// <param name="subSceneType"></param>
 /// <returns></returns>
 public static string GetSubSceneName(string regionId, eSubSceneMode subSceneMode, eSubSceneType subSceneType)
 {
     return(string.Concat(GetSubSceneRootName(subSceneMode, subSceneType), "_", regionId, "_", subSceneMode.ToString()));
 }
Beispiel #10
0
 /// <summary>
 /// Returns the name for a SubScene root game object.
 /// </summary>
 /// <param name="subSceneMode"></param>
 /// <param name="subSceneType"></param>
 /// <returns></returns>
 public static string GetSubSceneRootName(eSubSceneMode subSceneMode, eSubSceneType subSceneType)
 {
     return(string.Concat("SubScene_", subSceneMode.ToString(), "_", subSceneType.ToString()));
 }