Exemplo n.º 1
0
        public IEnumerator CreatePrefabCacheAsysc <T>(ePath path, string prefabName, int preloadCount, System.Action <int> completed) where T : Component
        {
            GameObject gameObject = null;

            yield return(LoadActorAsysc(path, prefabName, resource =>
            {
                gameObject = resource;
            }));

            int resultCode = -1;

            if (gameObject != null)
            {
                resultCode = CreatePoolCache <T>(gameObject, false, preloadCount);

                if (completed != null)
                {
                    completed(resultCode);
                }
            }
            else
            {
                if (completed != null)
                {
                    completed(resultCode);
                }
            }
        }
Exemplo n.º 2
0
        public PrefabResource CreateUIResource(string prefabName, ePath pathType, bool dontDestroyOnLoad)
        {
            IResource res = FindResource(eResourceType.UI, prefabName);

            if (res != null)
            {
                return((PrefabResource)res);
            }

            return((PrefabResource)CreateResource(eResourceType.UI, prefabName, pathType));
        }
Exemplo n.º 3
0
        public PrefabResource CreatePrefabResource(string prefabName, ePath pathType)
        {
            IResource res = FindResource(eResourceType.Prefab, prefabName);

            if (res != null)
            {
                return((PrefabResource)res);
            }

            return((PrefabResource)CreateResource(eResourceType.Prefab, prefabName, pathType));
        }
Exemplo n.º 4
0
        public SpriteAssetResource CreateSpriteAssetResource(ePath ePath, string name, bool assetbundle)
        {
            IResource res = null;

            res = FindResource(eResourceType.SpriteAsset, name.ToLower());
            if (res != null)
            {
                return((SpriteAssetResource)res);
            }
            return((SpriteAssetResource)MakeSpriteResource(eResourceType.SpriteAsset, ePath, name.ToLower()));
        }
    public BreadthFirstSearchRadius(Pos start, RadiusRange radius, int maxIter = 100000)
    {
        _start   = start;
        _range   = radius._range;
        _type    = radius._path;
        _maxIter = maxIter;

        _fastestPath       = new Dictionary <Pos, Pos>();
        _distanceFromStart = new Dictionary <Pos, float>();
        _searched          = new List <Pos>();
    }
Exemplo n.º 6
0
        public SpriteResource CreateSpriteResource(string name, ePath ePath, bool assetbundle)
        {
            IResource res = FindResource(eResourceType.Sprite, name.ToLower());

            if (res != null)
            {
                return(res as SpriteResource);
            }
            res = MakeSpriteResource(eResourceType.Sprite, ePath, name.ToLower());

            return((SpriteResource)res);
        }
Exemplo n.º 7
0
        public SoundResource CreateSoundResource(string name, ePath ePath)
        {
            IResource res = null;

            res = FindResource(eResourceType.Sound, name);
            if (res != null)
            {
                return((SoundResource)res);
            }

            return((SoundResource)CreateResource(eResourceType.Sound, name, ePath));
        }
Exemplo n.º 8
0
        public IEnumerator CreatePrefabResourceAsync(ePath path, string prefabName, System.Action <PrefabResource> action)
        {
            IResource res = FindResource(eResourceType.Prefab, prefabName);

            if (res != null)
            {
                action(res as PrefabResource);
            }
            else
            {
                yield return(CreateResourceAsync(eResourceType.Prefab, prefabName, path, result =>
                {
                    action(result as PrefabResource);
                }));
            }
        }
Exemplo n.º 9
0
        private GameObject LoadPrefab(ePath path, string prefabName)
        {
            if (string.IsNullOrEmpty(prefabName))
            {
                return(null);
            }

            PrefabResource resource = Global.ResourceMgr.CreatePrefabResource(prefabName, path);

            if (resource != null)
            {
                return(resource.ResourceGameObject);
            }

            return(null);
        }
Exemplo n.º 10
0
        public IEnumerator CreateUIResourceAsync(string prefabName, ePath pathType, bool dontDestroyOnLoad, System.Action <PrefabResource> action)
        {
            IResource res = FindResource(eResourceType.UI, prefabName);

            if (res != null)
            {
                action(res as PrefabResource);
            }
            else
            {
                yield return(CreateResourceAsync(eResourceType.UI, prefabName, pathType, result =>
                {
                    action(result as PrefabResource);
                }));
            }
        }
Exemplo n.º 11
0
        public PrefabResource CreateGameResource(string name, ePath ePath)
        {
            IResource res = null;

            //             if (ePath == E_Path.Sprite)
            //             {
            //                 return CreateSpriteResource(name, ePath);
            //             }

            res = FindResource(eResourceType.Prefab, name);
            if (res != null)
            {
                return((PrefabResource)res);
            }

            return((PrefabResource)CreateResource(eResourceType.Prefab, name, ePath));
        }
Exemplo n.º 12
0
        private IEnumerator LoadActorAsysc(ePath path, string prefabName, System.Action <GameObject> action)
        {
            if (string.IsNullOrEmpty(prefabName))
            {
                if (action != null)
                {
                    action(null);
                }

                yield break;
            }

            PrefabResource prefabResource = null;

            yield return(Global.ResourceMgr.CreatePrefabResourceAsync(path, prefabName, resource =>
            {
                if (action != null)
                {
                    prefabResource = resource;
                    action(prefabResource != null ? resource.ResourceGameObject : null);
                }
            }));
        }
Exemplo n.º 13
0
        private IResource CreateResource(eResourceType eType, string name, ePath ePath)
        {
            // 사운드는 넘어오는 name이 실제 파일 이름이 아니라 내부 이름이므로 변경 프로세스가 필요
            //             if (eType == E_ResourceType.Sound)
            //             {
            //                 SoundInfo si;
            //                 if (DataManager.Instance.GetScriptData<SoundData>(E_GameScriptData.Sound).GetSoundInfo(name, out si))
            //                 {
            //                     name = si.Filename;
            //                 }
            //             }

            bool   isAssetBundle = false;
            string path          = StringUtil.Format("{0}/{1}", m_pathManager.GetPath(ePath), name);
            //string path = m_pathManager.GetPath(ePath) + name;
            Object objresource = Resources.Load(path);

            if (objresource == null)
            {
                return(null);
            }

            return(CreateResource(eType, name, path, objresource, isAssetBundle));
        }
Exemplo n.º 14
0
        private IResource MakeSpriteResource(eResourceType eType, ePath ePath, string name)
        {
            string path = StringUtil.Format("{0}/{1}", m_pathManager.GetPath(ePath), name);

            Sprite[]          allresource       = null;
            Object            obj               = null;
            Object            autotile          = null;
            SpritePackerAsset spritePackerAsset = null;

            if (ePath == Resource.ePath.MapAutoTile)
            {
                obj = Resources.Load(path);
                string autotilepath = m_pathManager.GetPath(ePath) + "AutoTile";
                autotile = Resources.Load(autotilepath);
                if (obj is SpritePackerAsset)
                {
                    spritePackerAsset = (SpritePackerAsset)obj;
                    allresource       = spritePackerAsset.AllSprites;
                }
            }
            if (ePath == Resource.ePath.UISprite)
            {
                obj = Resources.Load(path);
            }
            else if (ePath == Resource.ePath.MapAsset || ePath == Resource.ePath.MapAutoAsset || ePath == Resource.ePath.MapActorAsset)
            {
                obj = Resources.Load(path);
                if (obj is SpritePackerAsset)
                {
                    spritePackerAsset = (SpritePackerAsset)obj;
                    allresource       = spritePackerAsset.AllSprites;
                }
            }
            else
            {
                allresource = Resources.LoadAll <Sprite>(path);
            }

            IResource resource = null;

            if (eType == eResourceType.SpriteAsset)
            {
                if (obj == null)
                {
                    Debug.LogError("TileSprite MakeSpriteResource name error" + name);
                    return(null);
                }

                resource = new SpritePackerResource(spritePackerAsset, spritePackerAsset.AllSprites, false);
            }
            else if (eType == eResourceType.Sprite)
            {
                if (obj == null)
                {
                    Debug.LogError("UISprite MakeSpriteResource name error" + name);
                    return(null);
                }

                resource = new SpriteResource(obj, false);
            }
            else
            {
                if (allresource == null)
                {
                    Debug.LogError("SpriteResource name error" + name);
                    return(null);
                }

                resource = new SpritePackerResource(spritePackerAsset, allresource, false);
            }
            string[] split        = path.Split('/');
            string   resourcename = split[split.Length - 1];

            resource.InitLoad(resourcename, path);
            Dictionary <int, IResource> dicRes = GetDicResource(eType);

            if (dicRes.ContainsKey(resource.GetHashCode()))
            {
                Debug.LogError("MakeSpriteResource name error" + name);
            }
            else
            {
                dicRes.Add(resource.GetHashCode(), resource);
            }
            return(resource);
        }
Exemplo n.º 15
0
 public string GetPath(ePath eType)
 {
     return(m_dicPath[eType]);
 }
Exemplo n.º 16
0
        public int CreatePoolCache(ePath path, string prefabName, int preloadCount, int capacity)
        {
            GameObject gameObject = LoadPrefab(path, prefabName);

            return(CreatePoolCache(gameObject, preloadCount, capacity));
        }
Exemplo n.º 17
0
        public T CreatePoolComponent <T>(ePath path, string prefabName, Vector3 position, Quaternion rotation, Transform parentTransform, bool active = true) where T : Component
        {
            GameObject gameObject = LoadPrefab(path, prefabName);

            return(CreatePoolComponent <T>(gameObject, position, rotation, parentTransform, active));
        }
Exemplo n.º 18
0
        public IEnumerator CreateResourceAsync(eResourceType resourceType, string resourceName, ePath pathType, System.Action <IResource> action)
        {
            if (string.IsNullOrEmpty(resourceName) == true)
            {
                action(null);
                yield break;
            }

            bool   isAssetBundle = false;
            string resourcePath  = StringUtil.Format("{0}/{1}", m_pathManager.GetPath(pathType), resourceName);

            UnityEngine.Object resourceData = null;

            ResourceRequest request = Resources.LoadAsync(resourcePath);

            yield return(request);

            resourceData = request.asset;

            if (resourceData == null)
            {
                LogError("resource is null: " + resourceType.ToString() + ", " + pathType.ToString() + ", " + resourceName);
                action(null);
                yield break;
            }

            action(CreateResource(resourceType, resourceName, resourcePath, resourceData, isAssetBundle));
        }
Exemplo n.º 19
0
 public RadiusRange(ePath path, float range)
 {
     _path  = path;
     _range = range;
 }