少年修仙传客户端代码仓库
client_Hale
2019-04-11 9f89e3be35da42eb9ccb44e6589d62f320aa444c
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, October 12, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
 
namespace Snxxz.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;
 
        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.gameObject.SetActive(true);
                    m_Instance.m_ShowCamera.enabled = false;
                    DontDestroyOnLoad(gameObject);
                }
 
                return m_Instance;
            }
        }
 
        public void BeginShowTreasure(int _treasureId, RawImage _rawImage)
        {
            var instance = UI3DModelFactory.LoadUITreasure(_treasureId);
            if (instance == null)
            {
                return;
            }
 
            StopShow();
 
            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 BeginShowGodWeapon(int _type, RawImage _rawImage)
        {
            var instance = UI3DModelFactory.LoadUIGodWeapon(_type);
            if (instance == null)
            {
                return;
            }
 
            StopShow();
 
            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 StopShow()
        {
            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;
            }
 
        }
 
        private void Awake()
        {
            OnQualityChange();
            SystemSetting.Instance.qualityLevelChangeEvent += OnQualityChange;
        }
 
        private void OnDestroy()
        {
            SystemSetting.Instance.qualityLevelChangeEvent -= OnQualityChange;
        }
 
        private void OnQualityChange()
        {
        }
 
    }
 
}