using 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);
|
}
|
}
|
}
|
}
|
|
int m_WearyValue = 0;
|
public int wearyValue {
|
get { return m_WearyValue; }
|
set {
|
if (m_WearyValue != value)
|
{
|
m_WearyValue = value;
|
if (bossWearyValueChangeEvent != null)
|
{
|
bossWearyValueChangeEvent();
|
}
|
}
|
}
|
}
|
|
int m_BigBoxCollectCount = 0;
|
public int bigBoxCollectCount {
|
get { return m_BigBoxCollectCount; }
|
set {
|
if (m_BigBoxCollectCount != value)
|
{
|
m_BigBoxCollectCount = value;
|
if (bigBoxCollectCountChangeEvent != null)
|
{
|
bigBoxCollectCountChangeEvent();
|
}
|
}
|
}
|
}
|
|
public event Action<int> bossSelectedEvent;
|
public event Action bossWearyValueChangeEvent;
|
public event Action bigBoxCollectCountChangeEvent;
|
public event Action boxSurplusChangeEvent;
|
public event Action eliteSurplusChangeEvent;
|
|
List<int> sortedBossIds = new List<int>();
|
Dictionary<int, DogzDungeonBossData> bosses = new Dictionary<int, DogzDungeonBossData>();
|
public DogzDungeonBox dogzDungeonBox = new DogzDungeonBox();
|
public DogzDungeonGuard dogzDungeonGuard = new DogzDungeonGuard();
|
Redpoint redpoint = new Redpoint(DOGZDUNGEON_REDPOINT);
|
|
FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
|
|
public override void Init()
|
{
|
}
|
|
public override void UnInit()
|
{
|
}
|
|
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 GetRecommendBoss()
|
{
|
if (bigBoxCollectCount < 2) //未疲劳
|
{
|
return 999;//大宝箱npc id
|
}
|
|
if (wearyValue < GeneralConfig.Instance.bossWearyValues[1])
|
{
|
var playerLevel = PlayerDatas.Instance.baseData.LV;
|
for (int i = sortedBossIds.Count - 1; i >= 0; i--)
|
{
|
var bossId = sortedBossIds[i];
|
var dogzConfig = ConfigManager.Instance.GetTemplate<DogzDungeonConfig>(bossId);
|
if (dogzConfig.MonsterType == 3 || dogzConfig.MonsterType == 4)
|
{
|
var npcConfig = ConfigManager.Instance.GetTemplate<NPCConfig>(bossId);
|
if (IsBossUnLocked(bossId) && findPreciousModel.IsBossAlive(bossId) && playerLevel >= npcConfig.NPCLV)
|
{
|
return bossId;
|
}
|
}
|
}
|
|
return sortedBossIds[0];
|
}
|
|
return 999;//大宝箱 npcid
|
}
|
|
public bool IsBossUnLocked(int _bossId)
|
{
|
return bosses.ContainsKey(_bossId) && bosses[_bossId].isUnLocked;
|
}
|
|
public void UpdateBoxSurplusInfo()
|
{
|
|
if (boxSurplusChangeEvent != null)
|
{
|
boxSurplusChangeEvent();
|
}
|
}
|
|
public void UpdateEliteSurplusInfo()
|
{
|
if (eliteSurplusChangeEvent != null)
|
{
|
eliteSurplusChangeEvent();
|
}
|
}
|
|
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 DogzDungeonBox
|
{
|
public int bigBoxSurplus;
|
public int smallBoxSurplus;
|
|
public void UpdateBoxInfo(int _big, int _small)
|
{
|
bigBoxSurplus = _big;
|
smallBoxSurplus = _small;
|
}
|
}
|
|
public class DogzDungeonGuard
|
{
|
public int guardSurplus;
|
|
public void UpdateGuardInfo(int _surplus)
|
{
|
guardSurplus = _surplus;
|
}
|
}
|
|
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;
|
}
|
}
|
|
}
|