少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
 
public class ChallengeDemonKingModel : Model
{
    public const int PERSONALBOSS_MAPID = 31240;                //数据地图ID
    public const int PERSONAL_REDPOINTID = 76003;
    int m_showNpcID;                                            //当前展示的BossID
    public int showNpcID
    {
        get
        {
            return m_showNpcID;
        }
        set
        {
            if (value == m_showNpcID)
                return;
            m_showNpcID = value;
            UpdateShow?.Invoke();
            DebugEx.Log($"挑战妖王当前展示的NPCID {value}");
        }
    }
    public Dictionary<int, int> realmNpcIDDict;
    public Dictionary<int, int> lineIdDict;
    public List<string> npcIDList;
    public event Action UpdateShow;
    DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
 
    public override void Init()
    {
        realmNpcIDDict = PersonalBossConfig.GetNPCIDDictForRealm();
        lineIdDict = PersonalBossConfig.GetNPCIDDictForLineId();
        npcIDList = PersonalBossConfig.GetKeys();
        showNpcID = int.Parse(npcIDList[JumpIndex()]);
    }
 
    public override void UnInit()
    {
 
    }
 
    //获取Cell的状态
    //0 已通关-不可扫荡 1 已通关-可扫荡-免费 2 未通关-可挑战(待首通) 3 未通关-不可挑战(境界够前一关没打) 4 未通关-不可解锁(境界不够) 5 已通关-可扫荡-可付费 6 已通关-不可扫荡
    public int GetCellState(int npcid)
    {
        int lineId = PersonalBossConfig.Get(npcid).lineId;
        int realmLv = NPCConfig.Get(npcid).Realm;
        //已通关
        if (IsFBPass(lineId))
        {
            if (IsSweep(npcid))
            {
                if (IsFreeTime(npcid))
                {
                    return 1;
                }
                else
                {
                    //次数不够
                    if (dungeonModel.GetTotalTimes(ChallengeDemonKingModel.PERSONALBOSS_MAPID) - dungeonModel.GetEnterTimes(ChallengeDemonKingModel.PERSONALBOSS_MAPID) < 1)
                    {
                        return 6;
                    }
                    else
                    {
                        return 5;
                    }
                }
            }
            else
            {
                return 0;
            }
        }
        //未通关
        else
        {
            if (PlayerDatas.Instance.baseData.realmLevel >= realmLv)
            {
                int lastNPCID = GetLastNPCID(npcid);
                if (lastNPCID == 0)
                {
                    return 2;
                }
                else
                {
                    int lastLineId = PersonalBossConfig.Get(lastNPCID).lineId;
                    return IsFBPass(lastLineId) ? 2 : 3;
                }
            }
            else
            {
                return 4;
            }
        }
    }
 
    //是否通关过这个副本
    bool IsFBPass(int lineId)
    {
        DungeonRecord dungeonRecord;
        if (dungeonModel.TryGetRecord(PERSONALBOSS_MAPID, out dungeonRecord))
        {
            if (dungeonRecord.lineGrades.ContainsKey(lineId) && dungeonRecord.lineGrades[lineId] != 0)
            {
                return true;
            }
        }
        return false;
    }
 
    //是否可以扫荡
    bool IsSweep(int npcid)
    {
        //不存在下一个已通关的关卡就可以扫荡
        int nextNpcId = GetNextNPCID(npcid);
        if (nextNpcId == 0)
            return true;
        int nextLineId = PersonalBossConfig.Get(nextNpcId).lineId;
        return !IsFBPass(nextLineId);
    }
 
    //获得上一关的lineid 返回0说明没有上一关
    int GetLastNPCID(int npcid)
    {
        int index = npcIDList.IndexOf(npcid.ToString());
        int lastIndex = index - 1;
        return lastIndex >= 0 ? int.Parse(npcIDList[lastIndex]) : 0;
    }
 
    //获得下一关的lineid 返回0说明没有下一关
    int GetNextNPCID(int npcid)
    {
        int index = npcIDList.IndexOf(npcid.ToString());
        int nextIndex = index + 1;
        return nextIndex <= npcIDList.Count - 1 ? int.Parse(npcIDList[nextIndex]) : 0;
    }
 
    //跳转到可扫荡boss的索引
    public int JumpIndex()
    {
        int jumpindex = 0;
        for (int i = 0; i < npcIDList.Count; i++)
        {
            int npcId = int.Parse(npcIDList[i]);
            int state = GetCellState(npcId);
            if (state == 1 || state == 5 || state == 6)
            {
                jumpindex = i;
            }
        }
        return jumpindex;
    }
 
    //这次扫荡是否免费的
    public bool IsFreeTime(int npcid)
    {
        var config = PersonalBossConfig.Get(npcid);
        DungeonRecord dungeonRecord;
        if (dungeonModel.TryGetRecord(PERSONALBOSS_MAPID, out dungeonRecord))
        {
            if (dungeonRecord.lineGrades.ContainsKey(config.lineId) && dungeonRecord.enterTimes > 0)
            {
                return false;
            }
        }
        return true;
 
    }
}