public void updateCalcedProperty(TowerTemplate tt) { TowerBase tb = tt.tbase; TowerBattleProperty property = TowerBattleProperty.genTowerBattleProperty(tt); _property.setName(tb.tname); if (tb.atkType == eAtkType.MELLE_AOE || tb.atkType == eAtkType.MELLE_POINT) { string s = "Melee"; _property.setAtkRange(s); } else { string s = string.Format("{0:f1}", property.atkRange * 0.001f); _property.setAtkRange(s); } int atkInteval = tb.towerModel.atkInterval; int actualInteval = (int)(atkInteval / (1.0f + property.atkSpd * 0.01f)); string ss = string.Format("{0:f1}", actualInteval * 0.001f); _property.setAtkSpd(ss, property.atkSpd + ""); _property.setHit(tb.mingzhong); //string s = string s =string.Format("{0:f2}", x); _property.setDamage(property.mainAtk, property.extraAtk); _property.setSkill(property.originSkills); }
public void updateView(TowerTemplate tt) { TowerBattleProperty property = TowerBattleProperty.genTowerBattleProperty(tt); TowerBase tb = tt.tbase; _name.text = tb.tname; _cost1.text = tb.cost [0] + ""; _cost2.text = tb.cost [1] + ""; _cost3.text = tb.cost [2] + ""; if (tb.atkType == eAtkType.MELLE_AOE || tb.atkType == eAtkType.MELLE_POINT) { string s = "Melee"; _range.text = s; } else { string s = getAtkRangeTxt(property.atkRange); _range.text = s; } int atkInteval = tb.towerModel.atkInterval; _spd.text = getAtkSpdTxt(atkInteval); setHit(tb.mingzhong); //setAtkRange(tb.towerModel.atkRange+""); //setAtkSpd(tb.towerModel.atkInterval+""); setDamage(property.mainAtk, property.extraAtk); setSkill(property.originSkills); }
public static TowerBattleProperty genTowerBattleProperty(TowerTemplate tt) { TowerBase tb = tt.tbase; List <TowerComponent> components = new List <TowerComponent>(); foreach (TowerComponent tc in tt.components) { if (tc == null || tc.cid == null) { continue; } components.Add(tc); } int atkRange = tb.towerModel.atkRange; int atkSpeed = tb.atkSpd; List <AtkInfo> extraAtk = new List <AtkInfo> (); AtkInfo mainAtk = new AtkInfo(tb.mainAtk); for (int i = 0; i < tb.extraAtk.Count; i++) { extraAtk.Add(new AtkInfo(tb.extraAtk[i])); } List <SkillState> skills = new List <SkillState> (); skills.AddRange(tb.skills); //List<SkillState> extraSkills = new List<SkillState> (); foreach (TowerComponent tc in components) { foreach (TowerComponentEffect effect in tc.effects) { switch (effect.type) { case eTowerComponentEffectType.ATK_CHANGE: mainAtk.damage += effect.x; break; case eTowerComponentEffectType.EXTRA_ABILITY: // string skillId = effect.extra; int skillLevel = effect.x; TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(skillId); { bool found = false; for (int i = 0; i < skills.Count; i++) { if (skills [i].skillId == skillId) { found = true; skills [i].skillLevel += skillLevel; if (skills [i].skillLevel > ts.maxLv) { skills [i].skillLevel = ts.maxLv; } break; } } if (!found) { SkillState skill = new SkillState(); skill.skillId = skillId; skill.skillLevel = skillLevel; skills.Add(skill); } } break; case eTowerComponentEffectType.ATK_SPD_CHANGE: atkSpeed += effect.x; break; case eTowerComponentEffectType.ATK_RANGE_CHANGE: atkRange += effect.x; break; case eTowerComponentEffectType.EXTRA_ATK: if (mainAtk.property == (eProperty)effect.x) { mainAtk.damage += effect.y; } else { bool found = false; for (int i = 0; i < extraAtk.Count; i++) { if (extraAtk [i].property == (eProperty)effect.x) { found = true; extraAtk [i].damage += effect.y; break; } } if (!found) { extraAtk.Add(new AtkInfo(effect.x, effect.y)); } } break; default: break; } } } TowerBattleProperty res = new TowerBattleProperty(); res.atkRange = atkRange; res.atkSpd = atkSpeed; res.mainAtk = mainAtk; res.extraAtk = extraAtk; res.originSkills = skills; return(res); }