//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Monday, October 09, 2017 //-------------------------------------------------------- using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.UI; using System; using System.Text.RegularExpressions; namespace vnxbqy.UI { public class Treasure { public int id { get; private set; } public int exp { get; private set; } public int level { get; private set; } public TreasureState state { get; set; } public List treasureStages = new List(); public Treasure(int id) { this.id = id; } public int skillId { get { var job = PlayerDatas.Instance.baseData.Job; var stage = treasureStages.Find((x) => { return x.unlockType == TreasureStageUnlock.Skill; }); return stage != null ? stage.GetSkill(job) : 0; } } public void RefreshLevel(int level, int exp) { this.level = level; this.exp = exp; } public void ParseStage(TreasureUpConfig config) { treasureStages.Add(new TreasureStage(config)); } } public struct VIPKillNPCTreasure { public int level; public long currentExp; } public class TreasureStage { public int stage { get; set; } public TreasureStageUnlock unlockType { get; private set; } public Dictionary propertyDict { get; private set; } public Dictionary skillDict { get; private set; } public int func { get; private set; } public int exp { get; set; } public int powerEx { get; set; } public TreasureStage(TreasureUpConfig config) { unlockType = TreasureStageUnlock.None; if (config.UnLockFuncID != 0) { unlockType = TreasureStageUnlock.Func; func = config.UnLockFuncID; } else if (config.UnLockSkill != null && config.UnLockSkill.Length > 1) { unlockType = TreasureStageUnlock.Skill; skillDict = new Dictionary(); for (int i = 0; i < config.UnLockSkill.Length; i++) { skillDict.Add(i + 1, config.UnLockSkill[i]); } } else if (!string.IsNullOrEmpty(config.AddAttr)) { unlockType = TreasureStageUnlock.Property; propertyDict = ConfigParse.GetDic(config.AddAttr); } exp = config.NeedExp; stage = config.LV; powerEx = config.PowerEx; } public int GetSkill(int _job) { if (skillDict.ContainsKey(_job)) { return skillDict[_job]; } return 0; } public int GetFightPower() { switch (unlockType) { case TreasureStageUnlock.Property: return UIHelper.GetFightPower(propertyDict); case TreasureStageUnlock.Skill: var job = PlayerDatas.Instance.baseData.Job; var _skillCfg = SkillConfig.Get(GetSkill(job)); if (_skillCfg != null) { return _skillCfg.FightPower; } break; } return 0; } } public class TreasureDungeon { public int treasureId; public List dungeonInfos = new List(); private int m_Level = 0; public int currentLevel { get { var model = ModelCenter.Instance.GetModel(); Treasure treasure; if (model.TryGetTreasure(treasureId, out treasure) && treasure.state == TreasureState.Collected) { return maxLevel; } return m_Level; } set { m_Level = value; } } public int maxLevel { get; private set; } public Redpoint challengeRedpoint; public TreasureDungeon(int treasureId,Redpoint challengeRedpoint) { this.treasureId = treasureId; this.challengeRedpoint = challengeRedpoint; } public void ParseDungeonInfo(TreasureDungeonConfig config) { if (dungeonInfos.FindIndex((x) => { return x.level == config.Level; }) == -1) { var json = LitJson.JsonMapper.ToObject(config.Attr); var propertyDict = new Dictionary(); foreach (var key in json.Keys) { var property = int.Parse(key); var value = int.Parse(json[key].ToString()); propertyDict.Add(property, value); } var dungeonInfo = new TreasureDungeonInfo() { key = config.ID, fightPower = config.fightPower, level = config.Level, propertyDict = propertyDict, lineId = config.LineID, defense = config.defense, }; dungeonInfos.Add(dungeonInfo); if (config.Level > maxLevel) { maxLevel = config.Level; } } } public TreasureDungeonInfo Get(int level) { return dungeonInfos.Find((x) => { return x.level == level; }); } public Dictionary GetUpperProperty(int level) { var lastDungeonInfo = Get(level - 1); var currentDungeonInfo = Get(level); if (currentDungeonInfo.Equals(default(TreasureDungeonInfo))) { return null; } var dict = new Dictionary(); foreach (var key in currentDungeonInfo.propertyDict.Keys) { if (level == 1) { dict.Add(key, currentDungeonInfo.propertyDict[key]); } else { if (lastDungeonInfo.propertyDict.ContainsKey(key)) { if (lastDungeonInfo.propertyDict[key] >= currentDungeonInfo.propertyDict[key]) { continue; } dict.Add(key, currentDungeonInfo.propertyDict[key] - lastDungeonInfo.propertyDict[key]); } else { dict.Add(key, currentDungeonInfo.propertyDict[key]); } } } return dict; } } public struct TreasureDungeonInfo { public int key; public int lineId; public int level; public Dictionary propertyDict; public int fightPower; public int defense; } public enum TreasureStageUnlock { None, Property, Skill, Func, } }