2019-09-06 11:04:28 +08:00
|
|
|
package config;
|
|
|
|
|
|
|
|
import manager.STableManager;
|
|
|
|
import manager.Table;
|
2019-10-11 16:32:20 +08:00
|
|
|
import util.StringUtil;
|
2019-09-06 11:04:28 +08:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
|
|
|
|
|
|
|
|
|
@Table(name ="SkillLogicConfig")
|
|
|
|
public class SSkillLogicConfig implements BaseConfig {
|
|
|
|
public static Map<Integer, SSkillLogicConfig> sSkillLogicConfigMap;
|
|
|
|
public static Map<Integer,SSkillLogicVo> sSkillLogicVoMap;
|
|
|
|
private int id;
|
|
|
|
|
|
|
|
private float[][] target;
|
|
|
|
|
|
|
|
private int[][] effect;
|
|
|
|
|
|
|
|
private float[][] effectValue;
|
|
|
|
|
|
|
|
private float cd;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init() throws Exception {
|
|
|
|
sSkillLogicConfigMap = STableManager.getConfig(SSkillLogicConfig.class);
|
|
|
|
Map<Integer,SSkillLogicVo> skillLogicVoMap = new ConcurrentHashMap<>();
|
|
|
|
for (Map.Entry<Integer,SSkillLogicConfig> entry :sSkillLogicConfigMap.entrySet()){
|
|
|
|
SSkillLogicConfig sSkillLogicConfig = entry.getValue();
|
|
|
|
SSkillLogicVo sSkillLogicVo = getSSkillLogicVo(sSkillLogicConfig);
|
|
|
|
skillLogicVoMap.put(entry.getKey(),sSkillLogicVo);
|
|
|
|
}
|
|
|
|
sSkillLogicVoMap = skillLogicVoMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SSkillLogicVo getsSkillLogicVo(int skillId) {
|
|
|
|
return sSkillLogicVoMap.get(skillId);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Map<Integer, SSkillLogicConfig> getsSkillLogicConfigMap() {
|
|
|
|
return sSkillLogicConfigMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float[][] getTarget() {
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int[][] getEffect() {
|
|
|
|
return effect;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float[][] getEffectValue() {
|
|
|
|
return effectValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getCd() {
|
|
|
|
return cd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SSkillLogicVo getSSkillLogicVo(SSkillLogicConfig sSkillLogicConfig) {
|
|
|
|
float[][] targets = sSkillLogicConfig.getTarget();
|
|
|
|
int[][] effect = sSkillLogicConfig.getEffect();
|
|
|
|
float[][] effectValue = sSkillLogicConfig.getEffectValue();
|
|
|
|
// System.out.println(sSkillLogicConfig.getId() +":"+targets.length + ":" +effect.length +":" + effectValue.length);
|
|
|
|
List<SkillTargetVo> skillTargetVos = new CopyOnWriteArrayList<>();
|
|
|
|
int index = 0;
|
|
|
|
for (int i = 0; i < targets.length ; i++){
|
|
|
|
SkillTargetVo skillTargetVo = new SkillTargetVo();
|
|
|
|
skillTargetVo.setTargetId((int) targets[i][0]);
|
|
|
|
skillTargetVo.setContinuedTime(targets[i][1]);
|
|
|
|
skillTargetVo.setEffectVale(getEffectVal(effect[i],effectValue,index));
|
|
|
|
index = index + effect[i].length;
|
|
|
|
skillTargetVos.add(skillTargetVo);
|
|
|
|
}
|
|
|
|
SSkillLogicVo sSkillLogicVo = new SSkillLogicVo();
|
|
|
|
sSkillLogicVo.setSkillId(sSkillLogicConfig.getId());
|
|
|
|
sSkillLogicVo.setCd(sSkillLogicConfig.getCd());
|
|
|
|
sSkillLogicVo.setSkillTargetVoList(skillTargetVos);
|
|
|
|
return sSkillLogicVo;
|
|
|
|
}
|
|
|
|
|
|
|
|
private float[][] getEffectVal(int[] effects, float[][] effectValues,int index) {
|
|
|
|
int effectIndex;
|
|
|
|
StringBuilder effectInfo = new StringBuilder();
|
|
|
|
for (int i = 0; i < effects.length; i++) {
|
|
|
|
if (index ==0){
|
|
|
|
effectIndex = i;
|
|
|
|
}else{
|
|
|
|
effectIndex =index + i;
|
|
|
|
}
|
|
|
|
if (effectInfo.length() == 0){
|
|
|
|
effectInfo = new StringBuilder(String.valueOf(effects[i]));
|
|
|
|
}else {
|
|
|
|
effectInfo.append("|").append(effects[i]);
|
|
|
|
}
|
|
|
|
float[] effectValue = effectValues[effectIndex];
|
|
|
|
for (float effectVal : effectValue) {
|
|
|
|
effectInfo.append("#").append(effectVal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return StringUtil.parseFiledFloat2(effectInfo.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|