/// <summary> /// 获取或创建移动消耗 /// </summary> /// <param name="classType"></param> /// <returns></returns> public MoveConsumption GetOrCreateMoveConsumption(ClassType classType) { if (!moveConsumptions.TryGetValue(classType, out MoveConsumption consumption)) { MoveConsumptionInfoConfig config = DR.Book.SRPG_Dev.Framework.ConfigFile.Get <MoveConsumptionInfoConfig>(); MoveConsumptionInfo info = config[classType]; if (info == null) { Debug.LogErrorFormat("RoleModel -> MoveConsumption key `{0}` is not found.", classType.ToString()); return(null); } consumption = new MoveConsumption(info); moveConsumptions.Add(classType, consumption); } return(consumption); }
protected override XmlConfigFile FormatBuffer(XmlConfigFile buffer) { // 长度要和 TerrainType 数量保持一致 int length = (int)TerrainType.Length; 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)); }