| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Saturday, March 31, 2018 |
| | | //-------------------------------------------------------- |
| | | |
| | | using UnityEngine; |
| | | using System; |
| | | |
| | | namespace TableConfig { |
| | | |
| | | |
| | | public partial class FamilyConfig : ConfigBase { |
| | | |
| | | public int familyLV { get ; private set ; } |
| | | public int memberCnt { get ; private set ; } |
| | | public int deputyLeaderCnt { get ; private set ; } |
| | | public int eliteCnt { get ; private set ; } |
| | | public int needMoney { get ; private set ; } |
| | | public int weekMissionMoneyMax { get ; private set ; } |
| | | |
| | | public override string getKey() |
| | | { |
| | | return familyLV.ToString(); |
| | | } |
| | | |
| | | public override void Parse() { |
| | | try |
| | | { |
| | | familyLV=IsNumeric(rawContents[0]) ? int.Parse(rawContents[0]):0; |
| | | |
| | | memberCnt=IsNumeric(rawContents[1]) ? int.Parse(rawContents[1]):0; |
| | | |
| | | deputyLeaderCnt=IsNumeric(rawContents[2]) ? int.Parse(rawContents[2]):0; |
| | | |
| | | eliteCnt=IsNumeric(rawContents[3]) ? int.Parse(rawContents[3]):0; |
| | | |
| | | needMoney=IsNumeric(rawContents[4]) ? int.Parse(rawContents[4]):0; |
| | | |
| | | weekMissionMoneyMax=IsNumeric(rawContents[5]) ? int.Parse(rawContents[5]):0; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | DesignDebug.Log(ex); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //--------------------------------------------------------
|
| | | // [Author]: Fish
|
| | | // [ Date ]: Wednesday, February 13, 2019
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | |
|
| | | public partial class FamilyConfig
|
| | | {
|
| | |
|
| | | public readonly int familyLV;
|
| | | public readonly int memberCnt;
|
| | | public readonly int deputyLeaderCnt;
|
| | | public readonly int eliteCnt;
|
| | | public readonly int needMoney;
|
| | | public readonly int weekMissionMoneyMax;
|
| | | public readonly int bossFBCnt;
|
| | |
|
| | | public FamilyConfig(string input)
|
| | | {
|
| | | try
|
| | | {
|
| | | var tables = input.Split('\t');
|
| | |
|
| | | int.TryParse(tables[0],out familyLV); |
| | |
|
| | | int.TryParse(tables[1],out memberCnt); |
| | |
|
| | | int.TryParse(tables[2],out deputyLeaderCnt); |
| | |
|
| | | int.TryParse(tables[3],out eliteCnt); |
| | |
|
| | | int.TryParse(tables[4],out needMoney); |
| | |
|
| | | int.TryParse(tables[5],out weekMissionMoneyMax); |
| | |
|
| | | int.TryParse(tables[6],out bossFBCnt); |
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | DebugEx.Log(ex);
|
| | | }
|
| | | }
|
| | |
|
| | | static Dictionary<int, FamilyConfig> configs = new Dictionary<int, FamilyConfig>();
|
| | | public static FamilyConfig Get(int id)
|
| | | { |
| | | if (!inited)
|
| | | {
|
| | | Debug.Log("FamilyConfig 还未完成初始化。");
|
| | | return null;
|
| | | }
|
| | | |
| | | if (configs.ContainsKey(id))
|
| | | {
|
| | | return configs[id];
|
| | | }
|
| | |
|
| | | FamilyConfig config = null;
|
| | | if (rawDatas.ContainsKey(id))
|
| | | {
|
| | | config = configs[id] = new FamilyConfig(rawDatas[id]);
|
| | | rawDatas.Remove(id);
|
| | | }
|
| | |
|
| | | return config;
|
| | | }
|
| | |
|
| | | public static bool Has(int id)
|
| | | {
|
| | | return configs.ContainsKey(id) || rawDatas.ContainsKey(id);
|
| | | }
|
| | |
|
| | | public static bool inited { get; private set; }
|
| | | protected static Dictionary<int, string> rawDatas = null;
|
| | | public static void Init(bool sync=false)
|
| | | {
|
| | | inited = false;
|
| | | var path = string.Empty;
|
| | | if (AssetSource.refdataFromEditor)
|
| | | {
|
| | | path = ResourcesPath.CONFIG_FODLER +"/Family.txt";
|
| | | }
|
| | | else
|
| | | {
|
| | | path = AssetVersionUtility.GetAssetFilePath("config/Family.txt");
|
| | | }
|
| | |
|
| | | if (sync)
|
| | | {
|
| | | var lines = File.ReadAllLines(path);
|
| | | rawDatas = new Dictionary<int, string>(lines.Length - 3);
|
| | | for (int i = 3; i < lines.Length; i++)
|
| | | {
|
| | | var line = lines[i];
|
| | | var index = line.IndexOf("\t");
|
| | | var idString = line.Substring(0, index);
|
| | | var id = int.Parse(idString);
|
| | |
|
| | | rawDatas[id] = line;
|
| | | }
|
| | | inited = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | ThreadPool.QueueUserWorkItem((object _object) =>
|
| | | {
|
| | | var lines = File.ReadAllLines(path);
|
| | | rawDatas = new Dictionary<int, string>(lines.Length - 3);
|
| | | for (int i = 3; i < lines.Length; i++)
|
| | | {
|
| | | var line = lines[i];
|
| | | var index = line.IndexOf("\t");
|
| | | var idString = line.Substring(0, index);
|
| | | var id = int.Parse(idString);
|
| | |
|
| | | rawDatas[id] = line;
|
| | | }
|
| | |
|
| | | inited = true;
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|