少年修仙传客户端代码仓库
hch
2 天以前 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, October 12, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
 
namespace vnxbqy.UI
{
 
    public class UI3DTreasureExhibition : MonoBehaviour
    {
        const string EFFECT_BONE = "Bone_effect";
 
        [SerializeField] Transform m_ShowPoint;
        [SerializeField] Camera m_ShowCamera;
 
        //法宝
        int m_TreasureId = 0;
        GameObject treasureModel = null;
        SFXController effect;
 
        //法器
        string m_FaqiPathName;
        string m_FaqiModelName;
        GameObject faqiModel = null;
 
        GameObject weaponModel = null;
        int m_GodWeaponType = 0;
 
        static UI3DTreasureExhibition m_Instance = null;
        public static UI3DTreasureExhibition Instance {
            get {
                if (m_Instance == null)
                {
                    var gameObject = Instantiate(BuiltInLoader.LoadPrefab("UI3DTreasureExhibitionStage"));
                    m_Instance = gameObject.GetComponent<UI3DTreasureExhibition>();
                    Instance.transform.position = new Vector3(0, 2000, 3000);
                    m_Instance.name = "UI3DTreasureExhibitionStage";
                    m_Instance.SetActive(true);
                    m_Instance.m_ShowCamera.enabled = false;
                    DontDestroyOnLoad(gameObject);
                }
 
                return m_Instance;
            }
        }
 
 
        public void ShowFaQiModel(string pathName, string modelName, RawImage _rawImage, int effectID)
        {
            var instance = UI3DModelFactory.LoadUIFaqi(pathName, modelName);
            if (instance == null)
            {
                return;
            }
 
            Stop();
 
            m_ShowCamera.enabled = true;
            m_FaqiPathName = pathName;
            m_FaqiModelName = modelName;
            faqiModel = instance;
            instance.transform.SetParentEx(m_ShowPoint, Vector3.zero, Quaternion.identity, Vector3.one);
            instance.SetActive(true);
 
            var fbPoint = faqiModel.transform.GetChildTransformDeeply(EFFECT_BONE);
            if (fbPoint == null)
            {
                fbPoint = faqiModel.transform;
            }
 
            effect = SFXPlayUtility.Instance.Play(effectID, fbPoint);
            if (effect != null)
            {
                LayerUtility.SetLayer(effect.gameObject, LayerUtility.UILayer, true);
            }
 
            if (_rawImage != null)
            {
                _rawImage.texture = m_ShowCamera.targetTexture;
                _rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
            }
        }
 
 
        public void ShowTreasure(int _treasureId, RawImage _rawImage)
        {
            var instance = UI3DModelFactory.LoadUITreasure(_treasureId);
            if (instance == null)
            {
                return;
            }
 
            Stop();
 
            m_ShowCamera.enabled = true;
            m_TreasureId = _treasureId;
            treasureModel = instance;
 
            var config = TreasureConfig.Get(_treasureId);
 
            var scale = (config == null || config.UIScale == 0) ? 100 : config.UIScale;
            instance.transform.SetParentEx(m_ShowPoint, Vector3.zero, Quaternion.identity, Vector3.one * ((float)scale / 100));
            instance.SetActive(true);
 
            var mountPoint = treasureModel.transform.GetChildTransformDeeply(EFFECT_BONE);
            if (mountPoint == null)
            {
                mountPoint = treasureModel.transform;
            }
 
            effect = SFXPlayUtility.Instance.Play(config.EffectID, mountPoint);
            if (effect != null)
            {
                LayerUtility.SetLayer(effect.gameObject, LayerUtility.UILayer, true);
            }
 
            if (_rawImage != null)
            {
                _rawImage.texture = m_ShowCamera.targetTexture;
                _rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
            }
        }
 
        public void ShowGodWeapon(int _type, RawImage _rawImage)
        {
            var instance = UI3DModelFactory.LoadUIGodWeapon(_type);
            if (instance == null)
            {
                return;
            }
 
            Stop();
 
            m_ShowCamera.enabled = true;
            m_GodWeaponType = _type;
            weaponModel = instance;
            instance.transform.SetParentEx(m_ShowPoint, Vector3.zero, Quaternion.identity, Vector3.one);
            instance.SetActive(true);
 
            if (_rawImage != null)
            {
                _rawImage.texture = m_ShowCamera.targetTexture;
                _rawImage.material = MaterialUtility.GetGUIRenderTextureMaterial();
            }
        }
 
        public void Stop()
        {
            m_ShowCamera.enabled = false;
            if (effect != null)
            {
                SFXPlayUtility.Instance.Release(effect);
                effect = null;
            }
 
            if (weaponModel != null)
            {
                UI3DModelFactory.ReleaseUIGodWeapon(m_GodWeaponType, weaponModel);
                weaponModel = null;
                m_GodWeaponType = 0;
            }
 
            if (treasureModel != null)
            {
                UI3DModelFactory.ReleaseUITreasure(m_TreasureId, treasureModel);
                treasureModel = null;
                m_TreasureId = 0;
            }
 
            if (faqiModel != null)
            {
                UI3DModelFactory.ReleaseUIFaqi(m_FaqiPathName, m_FaqiModelName, faqiModel);
                faqiModel = null;
                m_FaqiPathName = string.Empty;
                m_FaqiModelName = string.Empty;
            }
        }
 
        private void Awake()
        {
            OnQualityChange();
            SystemSetting.Instance.qualityLevelChangeEvent += OnQualityChange;
        }
 
        private void OnDestroy()
        {
            SystemSetting.Instance.qualityLevelChangeEvent -= OnQualityChange;
        }
 
        private void OnQualityChange()
        {
        }
 
    }
 
}