少年修仙传客户端代码仓库
client_linchunjie
2018-10-18 f93c57bfd57f97e78c3a00a29f302f5e8c83cdee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TableConfig;
 
public class AssetPreLoad : SingletonMonobehaviour<AssetPreLoad>
{
    public void PreLoadNPC(int _mapId)
    {
        NpcPreloadConfig _config = Config.Instance.Get<NpcPreloadConfig>(_mapId);
 
        if (_config == null)
        {
            return;
        }
 
        for (int i = 0; i < _config.NpcIDs.Length; ++i)
        {
            if (_config.NpcIDs[i] == 0)
            {
                continue;
            }
 
            var gameObject = InstanceResourcesLoader.LoadNpcPrefab(_config.NpcIDs[i]);
            if (gameObject)
            {
                GAMgr.Instance.AddNeedDestroyPrefab(gameObject);
                GameObjectPoolManager.Instance.CacheNpc(_config.NpcIDs[i], _config.NpcCount[i], true);
            }
        }
    }
 
    List<EffectConfig> m_Effects = null;
    List<EffectConfig> effects
    {
        get { return m_Effects ?? (m_Effects = Config.Instance.GetAllValues<EffectConfig>()); }
    }
 
    List<int> loadedJobs = new List<int>();
 
    public void PreLoadJobEffect(int _job)
    {
        if (loadedJobs.Contains(_job))
        {
            return;
        }
 
        loadedJobs.Add(_job);
 
        var preLoadEffects = new List<int>();
        foreach (var config in effects)
        {
            if (config.job == _job
             || config.job == 4)// 4 为约定的职业通用特效
            {
                preLoadEffects.Add(config.id);
            }
        }
 
        if (preLoadEffects.Count > 0)
        {
            StartCoroutine(Co_AsyncLoadEffects(preLoadEffects));
        }
    }
 
    IEnumerator Co_AsyncLoadEffects(List<int> _effectIds)
    {
        for (int i = 0; i < _effectIds.Count; i++)
        {
            var effectId = _effectIds[i];
            InstanceResourcesLoader.LoadEffectAsync(effectId, OnAsyncLoadEffect);
 
            yield return null;
        }
    }
 
    private void OnAsyncLoadEffect(bool _ok, Object _object)
    {
        if (_ok)
        {
            GameObjectPoolManager.Instance.CacheGameObject(_object as GameObject, 1, false);
        }
    }
 
}