| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Thursday, December 21, 2017 |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System; |
| | | using TableConfig; |
| | | |
| | | namespace Snxxz.UI |
| | | { |
| | | |
| | | public class DemonJarModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, ISwitchAccount, IPlayerLoginOk |
| | | { |
| | | public const int TOTALTIME_LIMIT = 5; |
| | | |
| | | public const int DEMONJAR_SINGLEMAPID = 52020; |
| | | public const int DEMONJAR_MAPID = 52010; |
| | | const int DEMONJAR_REDPOINTID = 76005; |
| | | |
| | | Redpoint redpoint = new Redpoint(DEMONJAR_REDPOINTID); |
| | | |
| | | bool m_IsDoubleAward = false; |
| | | public bool isDoubleAward { |
| | | get { return m_IsDoubleAward; } |
| | | set { |
| | | if (m_IsDoubleAward != value) |
| | | { |
| | | m_IsDoubleAward = value; |
| | | |
| | | if (doubleAwardChangeEvent != null) |
| | | { |
| | | doubleAwardChangeEvent(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public bool doubleToKillLowerBossHint { get; set; } |
| | | |
| | | public bool lockSelectedBoss = false; |
| | | |
| | | 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 demonJarSoulBuf = 0; |
| | | public int demonJarSoulIncreaseDelta { get; set; } |
| | | |
| | | public event Action<int> bossSelectedEvent; |
| | | public event Action<int> participantChangeEvent; |
| | | public event Action doubleAwardChangeEvent; |
| | | |
| | | List<int> sortedBossIds = new List<int>(); |
| | | Dictionary<int, DemonJarBossData> demonBosses = new Dictionary<int, DemonJarBossData>(); |
| | | Dictionary<int, int> lineToBoss = new Dictionary<int, int>(); |
| | | |
| | | FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } } |
| | | DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } } |
| | | TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } } |
| | | |
| | | public override void Init() |
| | | { |
| | | doubleToKillLowerBossHint = true; |
| | | ParseConfig(); |
| | | |
| | | dungeonModel.dungeonRecordChangeEvent += OnDungeonRecordUpdate; |
| | | dungeonModel.updateDungeonBuyCnt += OnDungeonBuyCount; |
| | | } |
| | | |
| | | public override void UnInit() |
| | | { |
| | | dungeonModel.dungeonRecordChangeEvent -= OnDungeonRecordUpdate; |
| | | dungeonModel.updateDungeonBuyCnt -= OnDungeonBuyCount; |
| | | } |
| | | |
| | | public void OnBeforePlayerDataInitialize() |
| | | { |
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= OnPlayerLevelUp; |
| | | ModelCenter.Instance.GetModel<MapModel>().mapLinesUpdateEvent -= OnMapLineUpdateEvent; |
| | | } |
| | | |
| | | public void OnAfterPlayerDataInitialize() |
| | | { |
| | | var bossId = GetLatestUnLockBoss(); |
| | | if (bossId != 0 && !findPreciousModel.IsBossSubscribed(bossId)) |
| | | { |
| | | findPreciousModel.RequestSubscribeBoss(bossId, true); |
| | | } |
| | | |
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += OnPlayerLevelUp; |
| | | ModelCenter.Instance.GetModel<MapModel>().mapLinesUpdateEvent += OnMapLineUpdateEvent; |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | | { |
| | | demonJarSoulBuf = treasureModel.GetPrivilegeValue(2); |
| | | demonJarSoulIncreaseDelta = 0; |
| | | |
| | | var bossId = GetLatestUnLockBoss(); |
| | | AutoSubscribeLastUnLockBoss(bossId); |
| | | } |
| | | |
| | | public void OnSwitchAccount() |
| | | { |
| | | doubleToKillLowerBossHint = true; |
| | | } |
| | | |
| | | public bool TryGetBossData(int _bossId, out DemonJarBossData _data) |
| | | { |
| | | return demonBosses.TryGetValue(_bossId, out _data); |
| | | } |
| | | |
| | | public void RequestSetDoubleAward(bool _double) |
| | | { |
| | | var send = new CB103_tagCMSetFMTDouble(); |
| | | send.IsDouble = (byte)(_double ? 1 : 0); |
| | | |
| | | GameNetSystem.Instance.SendInfo(send); |
| | | } |
| | | |
| | | public List<int> GetDemonJarBosses() |
| | | { |
| | | var dungeonModel = ModelCenter.Instance.GetModel<DungeonModel>(); |
| | | var bosses = new List<int>(); |
| | | for (int i = 0; i < sortedBossIds.Count; i++) |
| | | { |
| | | var bossId = sortedBossIds[i]; |
| | | var config = ConfigManager.Instance.GetTemplate<DemonJarConfig>(bossId); |
| | | |
| | | var grade = dungeonModel.GetDungeonGrade(new Dungeon(DEMONJAR_MAPID, config.LineID)); |
| | | if (config.CanEnterTimes > 0 && grade > 0) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | bosses.Add(bossId); |
| | | } |
| | | |
| | | return new List<int>(bosses); |
| | | } |
| | | |
| | | public int GetBossIdByLine(int _line) |
| | | { |
| | | if (lineToBoss.ContainsKey(_line)) |
| | | { |
| | | return lineToBoss[_line]; |
| | | } |
| | | else |
| | | { |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | public bool IsBossUnLocked(int _bossId) |
| | | { |
| | | var playerLevel = PlayerDatas.Instance.baseData.LV; |
| | | return demonBosses.ContainsKey(_bossId) && playerLevel >= demonBosses[_bossId].unLockLevel; |
| | | } |
| | | |
| | | public int GetLatestUnLockBoss() |
| | | { |
| | | if (FuncOpen.Instance.IsFuncOpen(76)) |
| | | { |
| | | var latestBossId = 0; |
| | | for (int i = sortedBossIds.Count - 1; i >= 0; i--) |
| | | { |
| | | var bossId = sortedBossIds[i]; |
| | | if (demonBosses[bossId].unLockLevel <= PlayerDatas.Instance.baseData.LV) |
| | | { |
| | | latestBossId = bossId; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return latestBossId; |
| | | } |
| | | else |
| | | { |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | public int GetSurplusTimes() |
| | | { |
| | | var totalTimes = dungeonModel.GetDungeonTotalTimes(DEMONJAR_MAPID); |
| | | var enterTimes = dungeonModel.GetDungeonEnterTimes(DEMONJAR_MAPID); |
| | | |
| | | return totalTimes - enterTimes; |
| | | } |
| | | |
| | | public bool IsPersonalBoss(int _bossId) |
| | | { |
| | | if (ConfigManager.Instance.ContainKey<DemonJarConfig>(_bossId)) |
| | | { |
| | | var config = ConfigManager.Instance.GetTemplate<DemonJarConfig>(_bossId); |
| | | return config.CanEnterTimes != 0; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public List<FakeBossKillRecord> GetFakeBossKillRecords(int _bossId) |
| | | { |
| | | var records = new List<FakeBossKillRecord>(); |
| | | var killTime = DateTime.Now; |
| | | var config = ConfigManager.Instance.GetTemplate<DemonJarConfig>(_bossId); |
| | | |
| | | for (int i = 0; i < 5; i++) |
| | | { |
| | | var index = (byte)(UnityEngine.Random.Range(0, GeneralConfig.Instance.openJobs.Length)); |
| | | var playerName = StringUtility.Contact(RandomNameConfig.GetFirstName(1), RandomNameConfig.GetSecondName(1)); |
| | | |
| | | var exitFakePlayer = false; |
| | | for (int j = 0; j < records.Count; j++) |
| | | { |
| | | var fakePlayer = records[j]; |
| | | if (fakePlayer.playerName == playerName) |
| | | { |
| | | exitFakePlayer = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (!exitFakePlayer) |
| | | { |
| | | killTime -= new TimeSpan(UnityEngine.Random.Range(3, 5) * TimeSpan.TicksPerMinute); |
| | | records.Add(new FakeBossKillRecord(playerName, killTime, UnityEngine.Random.Range(config.KillHurtMin, config.KillHurtMax))); |
| | | } |
| | | } |
| | | |
| | | return records; |
| | | } |
| | | |
| | | public void UpdateDemonJarSoul() |
| | | { |
| | | var demonJarSoul = treasureModel.GetPrivilegeValue(2); |
| | | demonJarSoulIncreaseDelta = demonJarSoul - demonJarSoulBuf; |
| | | demonJarSoulBuf = demonJarSoul; |
| | | } |
| | | |
| | | private void OnPlayerLevelUp(PlayerDataRefresh _type) |
| | | { |
| | | switch (_type) |
| | | { |
| | | case PlayerDataRefresh.LV: |
| | | var bossId = GetLatestUnLockBoss(); |
| | | AutoSubscribeLastUnLockBoss(bossId); |
| | | |
| | | if (PlayerDatas.Instance.baseData.LV == GeneralConfig.Instance.demonJarRedPoint) |
| | | { |
| | | var count = dungeonModel.GetDungeonTotalTimes(DEMONJAR_MAPID) - dungeonModel.GetDungeonEnterTimes(DEMONJAR_MAPID); |
| | | redpoint.state = count > 0 ? RedPointState.Quantity : RedPointState.None; |
| | | redpoint.count = count; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void OnMapLineUpdateEvent(int _mapId) |
| | | { |
| | | if (_mapId != DEMONJAR_MAPID) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | foreach (var boss in demonBosses.Values) |
| | | { |
| | | if (boss.participant != 0) |
| | | { |
| | | boss.participant = 0; |
| | | if (participantChangeEvent != null) |
| | | { |
| | | participantChangeEvent(boss.id); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | boss.participant = 0; |
| | | } |
| | | } |
| | | |
| | | var mapModel = ModelCenter.Instance.GetModel<MapModel>(); |
| | | var lines = mapModel.GetMapLines(DEMONJAR_MAPID); |
| | | for (int i = 0; i < sortedBossIds.Count; i++) |
| | | { |
| | | var bossId = sortedBossIds[i]; |
| | | var bossConfig = ConfigManager.Instance.GetTemplate<DemonJarConfig>(bossId); |
| | | if (bossConfig == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | for (int j = 0; j < lines.Count; j++) |
| | | { |
| | | if (lines[j].lineIndex == bossConfig.LineID) |
| | | { |
| | | demonBosses[bossId].participant = lines[j].playerCount; |
| | | if (participantChangeEvent != null) |
| | | { |
| | | participantChangeEvent(bossId); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void OnDungeonRecordUpdate(int _dataMapId) |
| | | { |
| | | if (DEMONJAR_MAPID == _dataMapId && PlayerDatas.Instance.baseData.LV >= GeneralConfig.Instance.demonJarRedPoint) |
| | | { |
| | | var count = dungeonModel.GetDungeonTotalTimes(_dataMapId) - dungeonModel.GetDungeonEnterTimes(_dataMapId); |
| | | redpoint.state = count > 0 ? RedPointState.Quantity : RedPointState.None; |
| | | redpoint.count = count; |
| | | } |
| | | } |
| | | |
| | | private void OnDungeonBuyCount() |
| | | { |
| | | if (PlayerDatas.Instance.baseData.LV >= GeneralConfig.Instance.demonJarRedPoint) |
| | | { |
| | | var count = dungeonModel.GetDungeonTotalTimes(DEMONJAR_MAPID) - dungeonModel.GetDungeonEnterTimes(DEMONJAR_MAPID); |
| | | redpoint.state = count > 0 ? RedPointState.Quantity : RedPointState.None; |
| | | redpoint.count = count; |
| | | } |
| | | |
| | | } |
| | | |
| | | private void AutoSubscribeLastUnLockBoss(int _bossId) |
| | | { |
| | | if (_bossId == 0) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | foreach (var boss in demonBosses.Values) |
| | | { |
| | | if (boss.id != _bossId && this.findPreciousModel.IsBossAutoSubscribe((int)_bossId)) |
| | | { |
| | | this.findPreciousModel.RequestDeSubscribeBoss((int)_bossId); |
| | | } |
| | | } |
| | | |
| | | if (_bossId != 0 && !this.findPreciousModel.IsBossNeverSubscribe((int)_bossId)) |
| | | { |
| | | var npcConfig = ConfigManager.Instance.GetTemplate<NPCConfig>((int)_bossId); |
| | | if (PlayerDatas.Instance.baseData.LV >= npcConfig.NPCLV) |
| | | { |
| | | var config = ConfigManager.Instance.GetTemplate<DemonJarConfig>((int)_bossId); |
| | | if (config.AutoAttention == 1) |
| | | { |
| | | this.findPreciousModel.RequestSubscribeBoss((int)_bossId, true); |
| | | var model = ModelCenter.Instance.GetModel<DungeonModel>(); |
| | | var grade = model.GetDungeonGrade(new Dungeon(DEMONJAR_MAPID, config.LineID)); |
| | | if ((config.CanEnterTimes == 0 || grade == 0) && this.findPreciousModel.IsBossAlive((int)_bossId)) |
| | | { |
| | | this.findPreciousModel.AddOneBossRebornNotify((int)_bossId); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void ParseConfig() |
| | | { |
| | | var demonJarConfigs = ConfigManager.Instance.GetAllValues<DemonJarConfig>(); |
| | | foreach (var config in demonJarConfigs) |
| | | { |
| | | var bossData = demonBosses[config.NPCID] = new DemonJarBossData(config.NPCID); |
| | | var npcConfig = ConfigManager.Instance.GetTemplate<NPCConfig>(config.NPCID); |
| | | bossData.unLockLevel = npcConfig.NPCLV; |
| | | lineToBoss[config.LineID] = config.NPCID; |
| | | } |
| | | |
| | | sortedBossIds.AddRange(demonBosses.Keys); |
| | | sortedBossIds.Sort((int a, int b) => |
| | | { |
| | | var data1 = demonBosses[a]; |
| | | var data2 = demonBosses[b]; |
| | | return DemonJarBossData.UnLockLevelCompare(data1, data2); |
| | | }); |
| | | } |
| | | |
| | | public struct FakeBossKillRecord |
| | | { |
| | | public string playerName; |
| | | public DateTime killTime; |
| | | public long hurt; |
| | | |
| | | public FakeBossKillRecord(string _playerName, DateTime _killTime, int _hurt) |
| | | { |
| | | playerName = _playerName; |
| | | killTime = _killTime; |
| | | hurt = _hurt; |
| | | } |
| | | |
| | | public override string ToString() |
| | | { |
| | | return Language.Get("FightTreasure_KillTime", killTime.ToString("HH:mm:ss"), playerName); |
| | | } |
| | | |
| | | } |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Thursday, December 21, 2017
|
| | | //--------------------------------------------------------
|
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System;
|
| | | using TableConfig;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | |
|
| | | public class DemonJarModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, ISwitchAccount, IPlayerLoginOk
|
| | | {
|
| | | public const int TOTALTIME_LIMIT = 5;
|
| | |
|
| | | public const int DEMONJAR_SINGLEMAPID = 52020;
|
| | | public const int DEMONJAR_MAPID = 52010;
|
| | | const int DEMONJAR_REDPOINTID = 76005;
|
| | |
|
| | | Redpoint redpoint = new Redpoint(DEMONJAR_REDPOINTID);
|
| | |
|
| | | bool m_IsDoubleAward = false;
|
| | | public bool isDoubleAward {
|
| | | get { return m_IsDoubleAward; }
|
| | | set {
|
| | | if (m_IsDoubleAward != value)
|
| | | {
|
| | | m_IsDoubleAward = value;
|
| | |
|
| | | if (doubleAwardChangeEvent != null)
|
| | | {
|
| | | doubleAwardChangeEvent();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public bool doubleToKillLowerBossHint { get; set; }
|
| | |
|
| | | public bool lockSelectedBoss = false;
|
| | |
|
| | | 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 demonJarSoulBuf = 0;
|
| | | public int demonJarSoulIncreaseDelta { get; set; }
|
| | |
|
| | | public event Action<int> bossSelectedEvent;
|
| | | public event Action<int> participantChangeEvent;
|
| | | public event Action doubleAwardChangeEvent;
|
| | |
|
| | | List<int> sortedBossIds = new List<int>();
|
| | | Dictionary<int, DemonJarBossData> demonBosses = new Dictionary<int, DemonJarBossData>();
|
| | | Dictionary<int, int> lineToBoss = new Dictionary<int, int>();
|
| | |
|
| | | FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
|
| | | DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
| | | TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
|
| | |
|
| | | TreasureSoulModel treasureSoulModel { get { return ModelCenter.Instance.GetModel<TreasureSoulModel>(); } }
|
| | |
|
| | | public override void Init()
|
| | | {
|
| | | doubleToKillLowerBossHint = true;
|
| | | ParseConfig();
|
| | |
|
| | | dungeonModel.dungeonRecordChangeEvent += OnDungeonRecordUpdate;
|
| | | dungeonModel.updateDungeonBuyCnt += OnDungeonBuyCount;
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | | {
|
| | | dungeonModel.dungeonRecordChangeEvent -= OnDungeonRecordUpdate;
|
| | | dungeonModel.updateDungeonBuyCnt -= OnDungeonBuyCount;
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | | {
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= OnPlayerLevelUp;
|
| | | ModelCenter.Instance.GetModel<MapModel>().mapLinesUpdateEvent -= OnMapLineUpdateEvent;
|
| | | }
|
| | |
|
| | | public void OnAfterPlayerDataInitialize()
|
| | | {
|
| | | var bossId = GetLatestUnLockBoss();
|
| | | if (bossId != 0 && !findPreciousModel.IsBossSubscribed(bossId))
|
| | | {
|
| | | findPreciousModel.RequestSubscribeBoss(bossId, true);
|
| | | }
|
| | |
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += OnPlayerLevelUp;
|
| | | ModelCenter.Instance.GetModel<MapModel>().mapLinesUpdateEvent += OnMapLineUpdateEvent;
|
| | | }
|
| | |
|
| | | public void OnPlayerLoginOk()
|
| | | {
|
| | | demonJarSoulBuf = treasureSoulModel.GetTreasureSoulValue(2);
|
| | | demonJarSoulIncreaseDelta = 0;
|
| | |
|
| | | var bossId = GetLatestUnLockBoss();
|
| | | AutoSubscribeLastUnLockBoss(bossId);
|
| | | }
|
| | |
|
| | | public void OnSwitchAccount()
|
| | | {
|
| | | doubleToKillLowerBossHint = true;
|
| | | }
|
| | |
|
| | | public bool TryGetBossData(int _bossId, out DemonJarBossData _data)
|
| | | {
|
| | | return demonBosses.TryGetValue(_bossId, out _data);
|
| | | }
|
| | |
|
| | | public void RequestSetDoubleAward(bool _double)
|
| | | {
|
| | | var send = new CB103_tagCMSetFMTDouble();
|
| | | send.IsDouble = (byte)(_double ? 1 : 0);
|
| | |
|
| | | GameNetSystem.Instance.SendInfo(send);
|
| | | }
|
| | |
|
| | | public List<int> GetDemonJarBosses()
|
| | | {
|
| | | var dungeonModel = ModelCenter.Instance.GetModel<DungeonModel>();
|
| | | var bosses = new List<int>();
|
| | | for (int i = 0; i < sortedBossIds.Count; i++)
|
| | | {
|
| | | var bossId = sortedBossIds[i];
|
| | | var config = Config.Instance.Get<DemonJarConfig>(bossId);
|
| | |
|
| | | var grade = dungeonModel.GetDungeonGrade(new Dungeon(DEMONJAR_MAPID, config.LineID));
|
| | | if (config.CanEnterTimes > 0 && grade > 0)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | bosses.Add(bossId);
|
| | | }
|
| | |
|
| | | return new List<int>(bosses);
|
| | | }
|
| | |
|
| | | public int GetBossIdByLine(int _line)
|
| | | {
|
| | | if (lineToBoss.ContainsKey(_line))
|
| | | {
|
| | | return lineToBoss[_line];
|
| | | }
|
| | | else
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | }
|
| | |
|
| | | public bool IsBossUnLocked(int _bossId)
|
| | | {
|
| | | var playerLevel = PlayerDatas.Instance.baseData.LV;
|
| | | return demonBosses.ContainsKey(_bossId) && playerLevel >= demonBosses[_bossId].unLockLevel;
|
| | | }
|
| | |
|
| | | public int GetLatestUnLockBoss()
|
| | | {
|
| | | if (FuncOpen.Instance.IsFuncOpen(76))
|
| | | {
|
| | | var latestBossId = 0;
|
| | | for (int i = sortedBossIds.Count - 1; i >= 0; i--)
|
| | | {
|
| | | var bossId = sortedBossIds[i];
|
| | | if (demonBosses[bossId].unLockLevel <= PlayerDatas.Instance.baseData.LV)
|
| | | {
|
| | | latestBossId = bossId;
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | return latestBossId;
|
| | | }
|
| | | else
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | }
|
| | |
|
| | | public int GetSurplusTimes()
|
| | | {
|
| | | var totalTimes = dungeonModel.GetDungeonTotalTimes(DEMONJAR_MAPID);
|
| | | var enterTimes = dungeonModel.GetDungeonEnterTimes(DEMONJAR_MAPID);
|
| | |
|
| | | return totalTimes - enterTimes;
|
| | | }
|
| | |
|
| | | public bool IsPersonalBoss(int _bossId)
|
| | | {
|
| | | if (Config.Instance.ContainKey<DemonJarConfig>(_bossId))
|
| | | {
|
| | | var config = Config.Instance.Get<DemonJarConfig>(_bossId);
|
| | | return config.CanEnterTimes != 0;
|
| | | }
|
| | | else
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | public List<FakeBossKillRecord> GetFakeBossKillRecords(int _bossId)
|
| | | {
|
| | | var records = new List<FakeBossKillRecord>();
|
| | | var killTime = DateTime.Now;
|
| | | var config = Config.Instance.Get<DemonJarConfig>(_bossId);
|
| | |
|
| | | for (int i = 0; i < 5; i++)
|
| | | {
|
| | | var index = (byte)(UnityEngine.Random.Range(0, GeneralConfig.Instance.openJobs.Length));
|
| | | var playerName = StringUtility.Contact(RandomNameConfig.GetFirstName(1), RandomNameConfig.GetSecondName(1));
|
| | |
|
| | | var exitFakePlayer = false;
|
| | | for (int j = 0; j < records.Count; j++)
|
| | | {
|
| | | var fakePlayer = records[j];
|
| | | if (fakePlayer.playerName == playerName)
|
| | | {
|
| | | exitFakePlayer = true;
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | if (!exitFakePlayer)
|
| | | {
|
| | | killTime -= new TimeSpan(UnityEngine.Random.Range(3, 5) * TimeSpan.TicksPerMinute);
|
| | | records.Add(new FakeBossKillRecord(playerName, killTime, UnityEngine.Random.Range(config.KillHurtMin, config.KillHurtMax)));
|
| | | }
|
| | | }
|
| | |
|
| | | return records;
|
| | | }
|
| | |
|
| | | public void UpdateDemonJarSoul()
|
| | | {
|
| | | var demonJarSoul = treasureSoulModel.GetTreasureSoulValue(2);
|
| | | demonJarSoulIncreaseDelta = demonJarSoul - demonJarSoulBuf;
|
| | | demonJarSoulBuf = demonJarSoul;
|
| | | }
|
| | |
|
| | | private void OnPlayerLevelUp(PlayerDataRefresh _type)
|
| | | {
|
| | | switch (_type)
|
| | | {
|
| | | case PlayerDataRefresh.LV:
|
| | | var bossId = GetLatestUnLockBoss();
|
| | | AutoSubscribeLastUnLockBoss(bossId);
|
| | |
|
| | | if (PlayerDatas.Instance.baseData.LV == GeneralConfig.Instance.demonJarRedPoint)
|
| | | {
|
| | | var count = dungeonModel.GetDungeonTotalTimes(DEMONJAR_MAPID) - dungeonModel.GetDungeonEnterTimes(DEMONJAR_MAPID);
|
| | | redpoint.state = count > 0 ? RedPointState.Quantity : RedPointState.None;
|
| | | redpoint.count = count;
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnMapLineUpdateEvent(int _mapId)
|
| | | {
|
| | | if (_mapId != DEMONJAR_MAPID)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | foreach (var boss in demonBosses.Values)
|
| | | {
|
| | | if (boss.participant != 0)
|
| | | {
|
| | | boss.participant = 0;
|
| | | if (participantChangeEvent != null)
|
| | | {
|
| | | participantChangeEvent(boss.id);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | boss.participant = 0;
|
| | | }
|
| | | }
|
| | |
|
| | | var mapModel = ModelCenter.Instance.GetModel<MapModel>();
|
| | | var lines = mapModel.GetMapLines(DEMONJAR_MAPID);
|
| | | for (int i = 0; i < sortedBossIds.Count; i++)
|
| | | {
|
| | | var bossId = sortedBossIds[i];
|
| | | var bossConfig = Config.Instance.Get<DemonJarConfig>(bossId);
|
| | | if (bossConfig == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | for (int j = 0; j < lines.Count; j++)
|
| | | {
|
| | | if (lines[j].lineIndex == bossConfig.LineID)
|
| | | {
|
| | | demonBosses[bossId].participant = lines[j].playerCount;
|
| | | if (participantChangeEvent != null)
|
| | | {
|
| | | participantChangeEvent(bossId);
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private void OnDungeonRecordUpdate(int _dataMapId)
|
| | | {
|
| | | if (DEMONJAR_MAPID == _dataMapId && PlayerDatas.Instance.baseData.LV >= GeneralConfig.Instance.demonJarRedPoint)
|
| | | {
|
| | | var count = dungeonModel.GetDungeonTotalTimes(_dataMapId) - dungeonModel.GetDungeonEnterTimes(_dataMapId);
|
| | | redpoint.state = count > 0 ? RedPointState.Quantity : RedPointState.None;
|
| | | redpoint.count = count;
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnDungeonBuyCount()
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.LV >= GeneralConfig.Instance.demonJarRedPoint)
|
| | | {
|
| | | var count = dungeonModel.GetDungeonTotalTimes(DEMONJAR_MAPID) - dungeonModel.GetDungeonEnterTimes(DEMONJAR_MAPID);
|
| | | redpoint.state = count > 0 ? RedPointState.Quantity : RedPointState.None;
|
| | | redpoint.count = count;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private void AutoSubscribeLastUnLockBoss(int _bossId)
|
| | | {
|
| | | if (_bossId == 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | foreach (var boss in demonBosses.Values)
|
| | | {
|
| | | if (boss.id != _bossId && this.findPreciousModel.IsBossAutoSubscribe((int)_bossId))
|
| | | {
|
| | | this.findPreciousModel.RequestDeSubscribeBoss((int)_bossId);
|
| | | }
|
| | | }
|
| | |
|
| | | if (_bossId != 0 && this.findPreciousModel.IsBossNeverSubscribe((int)_bossId))
|
| | | {
|
| | | var npcConfig = Config.Instance.Get<NPCConfig>((int)_bossId);
|
| | | if (PlayerDatas.Instance.baseData.LV >= npcConfig.NPCLV)
|
| | | {
|
| | | var config = Config.Instance.Get<DemonJarConfig>((int)_bossId);
|
| | | if (config.AutoAttention == 1)
|
| | | {
|
| | | this.findPreciousModel.RequestSubscribeBoss((int)_bossId, true);
|
| | | var model = ModelCenter.Instance.GetModel<DungeonModel>();
|
| | | var grade = model.GetDungeonGrade(new Dungeon(DEMONJAR_MAPID, config.LineID));
|
| | | if ((config.CanEnterTimes == 0 || grade == 0) && this.findPreciousModel.IsBossAlive((int)_bossId))
|
| | | {
|
| | | this.findPreciousModel.AddOneBossRebornNotify((int)_bossId);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void ParseConfig()
|
| | | {
|
| | | var demonJarConfigs = Config.Instance.GetAllValues<DemonJarConfig>();
|
| | | foreach (var config in demonJarConfigs)
|
| | | {
|
| | | var bossData = demonBosses[config.NPCID] = new DemonJarBossData(config.NPCID);
|
| | | var npcConfig = Config.Instance.Get<NPCConfig>(config.NPCID);
|
| | | bossData.unLockLevel = npcConfig.NPCLV;
|
| | | lineToBoss[config.LineID] = config.NPCID;
|
| | | }
|
| | |
|
| | | sortedBossIds.AddRange(demonBosses.Keys);
|
| | | sortedBossIds.Sort((int a, int b) =>
|
| | | {
|
| | | var data1 = demonBosses[a];
|
| | | var data2 = demonBosses[b];
|
| | | return DemonJarBossData.UnLockLevelCompare(data1, data2);
|
| | | });
|
| | | }
|
| | |
|
| | | public struct FakeBossKillRecord
|
| | | {
|
| | | public string playerName;
|
| | | public DateTime killTime;
|
| | | public long hurt;
|
| | |
|
| | | public FakeBossKillRecord(string _playerName, DateTime _killTime, int _hurt)
|
| | | {
|
| | | playerName = _playerName;
|
| | | killTime = _killTime;
|
| | | hurt = _hurt;
|
| | | }
|
| | |
|
| | | public override string ToString()
|
| | | {
|
| | | return Language.Get("FightTreasure_KillTime", killTime.ToString("HH:mm:ss"), playerName);
|
| | | }
|
| | |
|
| | | }
|
| | | } |
| | | |
| | | public class DemonJarBossData |
| | | { |
| | | public int id { get; private set; } |
| | | public int unLockLevel { get; set; } |
| | | public int participant { get; set; } |
| | | |
| | | public DemonJarBossData(int _id) |
| | | { |
| | | this.id = _id; |
| | | } |
| | | |
| | | public static int UnLockLevelCompare(DemonJarBossData _lhs, DemonJarBossData _rhs) |
| | | { |
| | | return _lhs.unLockLevel < _rhs.unLockLevel ? -1 : 1; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
|
| | | public class DemonJarBossData
|
| | | {
|
| | | public int id { get; private set; }
|
| | | public int unLockLevel { get; set; }
|
| | | public int participant { get; set; }
|
| | |
|
| | | public DemonJarBossData(int _id)
|
| | | {
|
| | | this.id = _id;
|
| | | }
|
| | |
|
| | | public static int UnLockLevelCompare(DemonJarBossData _lhs, DemonJarBossData _rhs)
|
| | | {
|
| | | return _lhs.unLockLevel < _rhs.unLockLevel ? -1 : 1;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|