hero up star

back_recharge
wangyuan 2019-01-23 16:03:21 +08:00
parent b838bf774e
commit 873c6c346e
4 changed files with 83 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import com.ljsd.jieling.logic.Table;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
@Table(name = "HeroRankupConfig")
public class SCHeroRankUpConfig implements BaseConfig{
@ -33,7 +34,7 @@ public class SCHeroRankUpConfig implements BaseConfig{
for(SCHeroRankUpConfig scHeroRankUpConfig: config.values()){
int type = scHeroRankUpConfig.getType();
if(!result.containsKey(type)){
result.put(type,new HashMap<>());
result.put(type,new TreeMap<>());
}
if(type == 1){
result.get(type).put(scHeroRankUpConfig.getLimitLevel(),scHeroRankUpConfig);

View File

@ -14,13 +14,23 @@ public class SGameSetting implements BaseConfig {
private int[] speedFormula;
private static SGameSetting gameSetting;
@Override
public void init() throws Exception {
Map<Integer, SGameSetting> config = STableManager.getConfig(SGameSetting.class);
gameSetting = config.get(1);
}
public int getId() {
public static SGameSetting getGameSetting() {
return gameSetting;
}
public int getId() {
return id;
}
@ -32,11 +42,11 @@ public class SGameSetting implements BaseConfig {
return speedFormula;
}
public float calSpeed(float speed){
float result = 0.0f;
public float calSpeed(float speed,int level){
float result = speed;
int length = speedFormula.length;
for(int i=0;i< speedFormula.length;i++){
double pow = Math.pow(speed, --length);
double pow = Math.pow(level, --length);
result += speedFormula[i]*pow;
}
return result;

View File

@ -6,4 +6,11 @@ public interface GlobalsDef {
int BREAK_TYPE =1 ; //1突破
int UP_STAR_TYPE = 2; //2升星
//英雄属性
int HP_TYPE =1;
int ATTACK_TYPE =2;
int PhysicalDefence_TYPE =3;
int MagicDefence_TYPE =4;
int SPEED_TYPE =5;
}

View File

@ -324,6 +324,65 @@ public class HeroLogic {
}
//初始属性*1+化境增长)*等级系数 + 初始属性*突破系数
public float calHeroAttribute(Hero hero,int type){
int templateId = hero.getTemplateId();
SCHero scHero = SCHero.getsCHero().get(templateId);
float baseValue = getBaseValueByType(scHero,type);
float characterLevelPara = SHeroLevlConfig.getsCHero().get(hero.getLevel()).getCharacterLevelPara();
//计算化境增长
Map<Integer, SCHeroRankUpConfig> scHeroRankUpConfigByTypeOfStar = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.UP_STAR_TYPE);
SCHeroRankUpConfig scHeroRankUpConfig = scHeroRankUpConfigByTypeOfStar.get(hero.getStar());
float rankupPara =0.0f;
if( scHeroRankUpConfig!=null ){
rankupPara = scHeroRankUpConfig.getRankupPara();
}
//突破系数
float breakPara = 0.0f;
int heroLevel = hero.getLevel();
Map<Integer, SCHeroRankUpConfig> scHeroRankUpConfigByTypOfBreak = SCHeroRankUpConfig.getScHeroRankUpConfigByType(GlobalsDef.BREAK_TYPE);
for( SCHeroRankUpConfig scHeroRankUpConfigTmp :scHeroRankUpConfigByTypOfBreak.values()){
if( heroLevel >= scHeroRankUpConfigTmp.getLimitLevel() ){
breakPara = scHeroRankUpConfigTmp.getRankupPara();
}
if(heroLevel <= scHeroRankUpConfigTmp.getOpenLevel()){
break;
}
}
if(type == GlobalsDef.SPEED_TYPE){
return SGameSetting.getGameSetting().calSpeed(baseValue,heroLevel);
}
return baseValue * ( 1 + rankupPara/10000.f) * characterLevelPara * breakPara;
}
private float getBaseValueByType(SCHero scHero,int type){
float result = 0.0f;
switch (type){
case GlobalsDef.HP_TYPE:
result = scHero.getHp();
break;
case GlobalsDef.ATTACK_TYPE:
result = scHero.getAttack();
break;
case GlobalsDef.PhysicalDefence_TYPE:
result = scHero.getPhysicalDefence();
break;
case GlobalsDef.MagicDefence_TYPE:
result = scHero.getMagicDefence();
break;
case GlobalsDef.SPEED_TYPE:
result = scHero.getSpeed();
break;
}
return result;
}