Example #1
0
    private void SetLevel(int level)
    {
        this.level = level > 0 ? level : 1;
        EnemyAttribution attribution = EnemyAttributionConfig.GetEnemyAttribution(enemyType);

        this.hp      = Mathf.RoundToInt(attribution.hp + (level - 1) * attribution.hpGrowth);
        this.attack  = Mathf.RoundToInt(attribution.attack + (level - 1) * attribution.attackGrowth);
        this.defence = Mathf.RoundToInt(attribution.defence + (level - 1) * attribution.defenceGrowth);
    }
Example #2
0
        /// <summary>
        /// 读取表数据,生成对应的数组
        /// </summary>
        /// <param name="filePath">excel文件全路径</param>
        /// <returns>Item数组</returns>
        public static EnemyAttribution[] CreateEnemyModelArrayWithExcel(string filePath)
        {
            //获得表数据
            int columnNum = 0, rowNum = 0;
            DataRowCollection collect = ReadExcel(filePath, ref columnNum, ref rowNum);

            //根据excel的定义,第二行开始才是数据
            EnemyAttribution[] array = new EnemyAttribution[rowNum - 1];
            for (int i = 1; i < rowNum; i++)
            {
                EnemyAttribution enemyModel = new EnemyAttribution();
                //解析每列的数据
                enemyModel.enemyType     = (EnemyType)int.Parse(collect[i][0].ToString());
                enemyModel.hp            = float.Parse(collect[i][1].ToString());
                enemyModel.hpGrowth      = float.Parse(collect[i][2].ToString());
                enemyModel.attack        = float.Parse(collect[i][3].ToString());
                enemyModel.attackGrowth  = float.Parse(collect[i][4].ToString());
                enemyModel.defence       = float.Parse(collect[i][5].ToString());
                enemyModel.defenceGrowth = float.Parse(collect[i][6].ToString());
                array[i - 1]             = enemyModel;
            }
            return(array);
        }