protected override XmlConfigFile FormatBuffer(XmlConfigFile buffer)
        {
            // 长度要和TerrainType数量保持一致
            int length = (int)TerrainType.MaxLength;
            MoveConsumptionInfoConfig config = buffer as MoveConsumptionInfoConfig;

            for (int i = 0; i < config.datas.Length; i++)
            {
                if (config.datas[i].consumptions.Length != length)
                {
                    int oldLength = config.datas[i].consumptions.Length;
                    Array.Resize(ref config.datas[i].consumptions, length);
                    for (int j = oldLength; j < length; j++)
                    {
                        config.datas[i].consumptions[j] = 255f;
                    }
                }
            }

            return(base.FormatBuffer(config));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取或创建移动消耗
        /// </summary>
        /// <param name="classType"></param>
        /// <returns></returns>
        public MoveConsumption GetOrCreateMoveConsumption(ClassType classType)
        {
            MoveConsumption consumption;

            if (!m_MoveConsumptions.TryGetValue(classType, out consumption))
            {
                MoveConsumptionInfoConfig config = MoveConsumptionInfoConfig.Get <MoveConsumptionInfoConfig>();
                MoveConsumptionInfo       info   = config[classType];
                if (info == null)
                {
                    Debug.LogErrorFormat(
                        "RoleModel -> MoveConsumption key `{0}` is not found.",
                        classType.ToString());
                    return(null);
                }
                else
                {
                    consumption = new MoveConsumption(info);
                    m_MoveConsumptions.Add(classType, consumption);
                }
            }

            return(consumption);
        }