Esempio n. 1
0
        private bool CheckDistrictData(Block_District_Config config)
        {
            bool result = true;

            if (config == null)
            {
                return(false);
            }
            List <Vector2> posList = new List <Vector2>();

            for (int i = 0; i < config.gridConfig.Count; i++)
            {
                byte[] posArray = config.gridConfig[i].coordinate;
                if (posArray.Length != 2)
                {
                    DebugPlus.LogError("[BlockConfigData] : Pos FormatError! array= " + posArray.ToString() + " Name=" + config.configName);
                    result = false;
                    continue;
                }
                Vector2 pos = new Vector2(posArray[0], posArray[1]);
                if (posList.Contains(pos))
                {
                    DebugPlus.LogError("[BlockConfigData] : Find Same Coordinate! array=" + posArray.ToString() + " Name=" + config.configName);
                    result = false;
                    continue;
                }
            }

            ///Check Match
            for (int i = 0; i < config.areaX; i++)
            {
                for (int j = 0; j < config.areaY; j++)
                {
                    Vector2 pos = new Vector2(i, j);
                    if (!posList.Contains(pos))
                    {
                        DebugPlus.LogError("[BlockConfigData] : Find Empty Coordinate! posX=" + i + " ,  PosY= " + j + "Name = " + config.configName);
                        result = false;
                        continue;
                    }
                }
            }

            ///Check Size
            if (Utility.TryParseInt((config.realityRatio * config.areaX).ToString()) == 0 || Utility.TryParseInt((config.realityRatio * config.areaY).ToString()) == 0)
            {
                DebugPlus.LogError("[BlockConfigData] : DistrictRealSize is not interger!" + config.configName);
                result = false;
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 生成所有初始区划信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="block"></param>
        /// <returns></returns>
        public static Dictionary <Vector2, DistrictAreaInfo> GetBlockDistictInfo(Config.Block_District_Config config)
        {
            ///Config already Check! not deal exception!
            Dictionary <Vector2, DistrictAreaInfo> result = new Dictionary <Vector2, DistrictAreaInfo>();

            if (config != null)
            {
                for (int i = 0; i < config.gridConfig.Count; i++)
                {
                    Vector2          pos  = new Vector2(config.gridConfig[i].coordinate[0], config.gridConfig[i].coordinate[1]);
                    DistrictAreaInfo info = new DistrictAreaInfo();
                    info = info.InitData(config.gridConfig[i]);

                    result.Add(pos, info);
                }
            }
            return(result);
        }