From 72f94e2e0120db00113d0934d52151c436407c5a Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期六, 18 八月 2018 11:33:53 +0800
Subject: [PATCH] 1889 【前端】神兽地界及界面相关

---
 System/DogzDungeon/DogzDungeonModel.cs |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 101 insertions(+), 2 deletions(-)

diff --git a/System/DogzDungeon/DogzDungeonModel.cs b/System/DogzDungeon/DogzDungeonModel.cs
index e34dcd3..45152e9 100644
--- a/System/DogzDungeon/DogzDungeonModel.cs
+++ b/System/DogzDungeon/DogzDungeonModel.cs
@@ -1,20 +1,119 @@
 锘縰sing System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using TableConfig;
+using System;
 
 namespace Snxxz.UI
 {
     public class DogzDungeonModel : Model
     {
+
+        public const int DOGZDUNGEON_REDPOINT = 76009;
+        public const int DATA_MAPID = 1010010;
+
+
+        int m_SelectedBoss = 0;
+        public int selectedBoss {
+            get {
+                return this.m_SelectedBoss;
+            }
+            set {
+                if (this.m_SelectedBoss != value)
+                {
+                    this.m_SelectedBoss = value;
+                    if (bossSelectedEvent != null)
+                    {
+                        bossSelectedEvent(value);
+                    }
+                }
+            }
+        }
+
+        public event Action<int> bossSelectedEvent;
+
+        List<int> sortedBossIds = new List<int>();
+        Dictionary<int, DogzDungeonBossData> bosses = new Dictionary<int, DogzDungeonBossData>();
+
+        FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
+
         public override void Init()
         {
-            throw new System.NotImplementedException();
         }
 
         public override void UnInit()
         {
-            throw new System.NotImplementedException();
+        }
+
+        public bool TryGetBossData(int _bossId, out DogzDungeonBossData _data)
+        {
+            return bosses.TryGetValue(_bossId, out _data);
+        }
+
+        public List<int> GetBosses()
+        {
+            return new List<int>(bosses.Keys);
+        }
+
+        public int GetLatestUnLockBoss()
+        {
+            var playerLevel = PlayerDatas.Instance.baseData.LV;
+            for (int i = sortedBossIds.Count - 1; i >= 0; i--)
+            {
+                var bossId = sortedBossIds[i];
+                var npcConfig = ConfigManager.Instance.GetTemplate<NPCConfig>(bossId);
+                if (IsBossUnLocked(bossId) && findPreciousModel.IsBossAlive(bossId) && playerLevel >= npcConfig.NPCLV)
+                {
+                    return bossId;
+                }
+            }
+
+            return sortedBossIds[0];
+        }
+
+        public bool IsBossUnLocked(int _bossId)
+        {
+            return bosses.ContainsKey(_bossId) && bosses[_bossId].isUnLocked;
+        }
+
+        private void ParseConfig()
+        {
+            var configs = ConfigManager.Instance.GetAllValues<DogzDungeonConfig>();
+            foreach (var config in configs)
+            {
+                bosses[config.NPCID] = new DogzDungeonBossData(config.NPCID);
+                sortedBossIds.Add(config.NPCID);
+            }
+
+            sortedBossIds.Sort(DogzDungeonBossData.LevelCompare);
+        }
+
+    }
+
+
+    public class DogzDungeonBossData
+    {
+        public int id { get; private set; }
+        public bool isUnLocked {
+            get {
+                var config = ConfigManager.Instance.GetTemplate<NPCConfig>(id);
+                return PlayerDatas.Instance.baseData.LV >= config.NPCLV;
+            }
+        }
+
+        public DogzDungeonBossData(int _id)
+        {
+            this.id = _id;
+        }
+
+        public static int LevelCompare(int a, int b)
+        {
+            var configA = ConfigManager.Instance.GetTemplate<NPCConfig>(a);
+            var configB = ConfigManager.Instance.GetTemplate<NPCConfig>(b);
+
+            return configA.NPCLV < configB.NPCLV ? -1 : 1;
         }
     }
+
 }
 

--
Gitblit v1.8.0