少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, May 03, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
 
 
namespace Snxxz.UI
{
 
    public class DungeonBossBriefInfoBehaviour : MonoBehaviour
    {
        [SerializeField] Button m_MoveTo;
        [SerializeField] Text m_Level;
        [SerializeField] TimerBehaviour m_RebornTime;
        [SerializeField] Text m_Alive;
        [SerializeField] Text m_RebornAtOnce;
        [SerializeField] RebornRightNowBossInfoQuery m_BossInfoQuery;
 
        int bossId = 0;
        FindPreciousModel model { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
 
        Action onMoveToBoss;
 
        public void Display(int _bossId, Action _onMoveToBoss)
        {
            bossId = _bossId;
            onMoveToBoss = _onMoveToBoss;
            var config = NPCConfig.Get(bossId);
            m_Level.text = Language.Get("Z1024", config.NPCLV);
 
            m_BossInfoQuery.bossId = bossId;
            OnBossInfoUpdate(bossId);
            model.bossInfoUpdateEvent -= OnBossInfoUpdate;
            model.bossInfoUpdateEvent += OnBossInfoUpdate;
 
            m_MoveTo.RemoveAllListeners();
            m_MoveTo.AddListener(MoveToNpc);
        }
 
        public void Dispose()
        {
            onMoveToBoss = null;
            m_MoveTo.RemoveAllListeners();
            model.bossInfoUpdateEvent -= OnBossInfoUpdate;
        }
 
        private void OnBossInfoUpdate(int _bossId)
        {
            if (bossId != _bossId)
            {
                return;
            }
 
            FindPreciousModel.BossInfo bossInfo;
            if (model.TryGetBossInfo(bossId, out bossInfo))
            {
                if (!bossInfo.IsBossAlive())
                {
                    m_RebornTime.Begin((int)(bossInfo.refreshTime - TimeUtility.ServerNow).TotalSeconds);
                }
                else
                {
                    m_RebornTime.gameObject.SetActive(false);
                }
            }
            else
            {
                m_RebornTime.gameObject.SetActive(false);
            }
        }
 
        private void LateUpdate()
        {
            FindPreciousModel.BossInfo bossInfo;
            if (model.TryGetBossInfo(bossId, out bossInfo))
            {
                var isAlive = bossInfo.IsBossAlive();
 
                if (isAlive)
                {
                    if (!m_Alive.gameObject.activeInHierarchy)
                    {
                        m_Alive.gameObject.SetActive(true);
                    }
                }
                else
                {
                    if (m_Alive.gameObject.activeInHierarchy)
                    {
                        m_Alive.gameObject.SetActive(false);
                    }
                }
 
                var rebornAtOnce = bossInfo.refreshTime < TimeUtility.ServerNow && !isAlive;
 
                if (rebornAtOnce)
                {
                    if (!m_RebornAtOnce.gameObject.activeInHierarchy)
                    {
                        m_RebornAtOnce.gameObject.SetActive(true);
                    }
                }
                else
                {
                    if (m_RebornAtOnce.gameObject.activeInHierarchy)
                    {
                        m_RebornAtOnce.gameObject.SetActive(false);
                    }
                }
 
            }
        }
 
        private void MoveToNpc()
        {
            if (PlayerDatas.Instance.hero != null)
            {
                PlayerDatas.Instance.hero.StopPathFind();
            }
            MapTransferUtility.Instance.MoveToNPC(bossId);
 
            if (onMoveToBoss != null)
            {
                onMoveToBoss();
            }
        }
 
    }
 
}