少年修仙传客户端代码仓库
hch
2023-06-14 f23c81d21c9cc4c9f06e8bed3ebb7ddbe7e15ac3
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Saturday, April 07, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
 
namespace Snxxz.UI
{
 
    public class RuneTowerPassedInfoPanel : MonoBehaviour
    {
        [SerializeField] ScrollRect m_ScrollRect;
        [SerializeField] RuneTowerPassedInfoBehaviour[] m_Behaviours;
 
        RuneTowerModel model { get { return ModelCenter.Instance.GetModel<RuneTowerModel>(); } }
 
        public void Display()
        {
            var passedTowers = RuneTowerConfig.GetKeys();
            for (int i = 0; i < m_Behaviours.Length; i++)
            {
                var behaviour = m_Behaviours[i];
                if (i < passedTowers.Count)
                {
                    behaviour.SetActive(true);
                    var towerId = int.Parse(passedTowers[i]);
 
                    var state = GetTowerState(towerId);
                    if (state == 1)
                    {
                        behaviour.Display(towerId, true);
                    }
                    else if (state == -1)
                    {
                        behaviour.Display(towerId, false);
                    }
                    else
                    {
                        var latestPassedFloor = ModelCenter.Instance.GetModel<RuneModel>().passRuneTowerFloor;
                        behaviour.Display(towerId, (int)latestPassedFloor);
                    }
                }
                else
                {
                    behaviour.SetActive(false);
                }
            }
 
            m_ScrollRect.verticalNormalizedPosition = 1f;
        }
 
        private int GetTowerState(int _towerId)
        {
            var latestPassedFloor = ModelCenter.Instance.GetModel<RuneModel>().passRuneTowerFloor;
            var lastPassTowerId = -1;
            if (latestPassedFloor > 0)
            {
                lastPassTowerId = RuneTowerFloorConfig.Get((int)latestPassedFloor).TowerId;
            }
 
            if (model.allTowerCompleted)
            {
                return 1;
            }
            else if (latestPassedFloor == 0)
            {
                return -1;
            }
            else if (_towerId == lastPassTowerId)
            {
                if (lastPassTowerId == model.currentTower)
                {
                    return 0;
                }
                else
                {
                    return 1;
                }
            }
            else
            {
                return lastPassTowerId > _towerId ? 1 : -1;
            }
        }
 
 
    }
 
}