public void init(TowerTemplate towerTemplate, Vector2Int posInCell) { if (towerTemplate != null) { this.tt = towerTemplate; this.atkType = towerTemplate.tbase.atkType; this.mainAtk = towerTemplate.tbase.mainAtk; this.extraAtk = towerTemplate.tbase.extraAtk; this.atkInterval = towerTemplate.tbase.towerModel.atkInterval; this.atkRange = towerTemplate.tbase.towerModel.atkRange; this.atkPreTime = towerTemplate.tbase.towerModel.atkPreTime; this.mingzhong = towerTemplate.tbase.mingzhong; //this.tt = towerTemplate; for (int i = 0; i < towerTemplate.tbase.skills.Count; i++) { skillComponent.skills [i] = new SkillState(towerTemplate.tbase.skills[i].skillId, towerTemplate.tbase.skills[i].skillLevel); skillComponent.skillCoolDown [i] = 3000; } } this.posInCell = posInCell; Vector2Int posLt = MapManager.getInstance().CellToWorld(posInCell.y, posInCell.x); //posLt += new Vector2Int (MapManager.TILE_WIDTH * 5,-MapManager.TILE_HEIGHT * 5); posXInt = posLt.x; posYInt = posLt.y; atkCoolDown = 1000; atkBhvTimer = 0; initialized = true; }
public void AddAtkInfo(string name, int count, int damage, int skillId = 0) { AtkInfo atkInfo = new AtkInfo(); atkInfo.name = name; atkInfo.count = count; atkInfo.damage = damage; atkInfo.skillId = skillId; atkInfos.Add(atkInfo); }
public void setDamage(AtkInfo mainAtk, List <AtkInfo> extraAtk) { _damage_list.RemoveChildrenToPool(); { TowerDamageItem damage = (TowerDamageItem)_damage_list.AddItemFromPool(); damage.setDamage(mainAtk.property, mainAtk.damage / 1000); } for (int i = 0; i < extraAtk.Count; i++) { TowerDamageItem damage = (TowerDamageItem)_damage_list.AddItemFromPool(); damage.setDamage(extraAtk[i].property, extraAtk[i].damage / 1000); } }
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); }
public AtkInfo(AtkInfo other) { this.damage = other.damage; this.property = other.property; }