public MoveConsumption(ClassType classType)
 {
     // TODO Load from config file
     m_MoveConsumptionInfo = new MoveConsumptionInfo
     {
         type         = classType,
         consumptions = new float[TerrainType.MaxLength.ToInteger()]
     };
     for (int i = 0; i < m_MoveConsumptionInfo.consumptions.Length; i++)
     {
         m_MoveConsumptionInfo.consumptions[i] = UnityEngine.Random.Range(0.5f, 3f);
     }
 }
Exemple #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);
        }
 public MoveConsumption(MoveConsumptionInfo info)
 {
     this.info = info;
 }