// Add this Upgrade to a tower public void AddUpgrade(TowerAttributes towerAttributes) { Upgrade upgrade = towerAttributes.gameObject.AddComponent(_upgradeScript.GetClass()) as Upgrade; upgrade.InitializeUpgrade(this, towerAttributes.GetComponent <TowerBase>()); towerAttributes.ActiveUpgrades.Add(this); // add Upgrade to tower }
// add two sets of attributes together public static TowerAttributes operator +(TowerAttributes lhs, TowerAttributes rhs) { TowerAttributes ret = new TowerAttributes(); ret.displayName = rhs.displayName + lhs.displayName; ret.cost = lhs.cost + rhs.cost; ret.range = lhs.range + rhs.range; ret.damage = lhs.damage + rhs.damage; ret.rateOfFire = lhs.rateOfFire + rhs.rateOfFire; ret.missileSpeed = lhs.missileSpeed + rhs.missileSpeed; ret.applySlow = lhs.applySlow || rhs.applySlow; ret.slowTime = lhs.slowTime + rhs.slowTime; ret.slowFactor = lhs.slowFactor + rhs.slowFactor; ret.applyBurn = lhs.applyBurn || rhs.applyBurn; ret.burnTime = lhs.burnTime + rhs.burnTime; ret.burnCount = lhs.burnCount + rhs.burnCount; ret.burnDamage = lhs.burnDamage + rhs.burnDamage; ret.applyAOE = lhs.applyAOE || rhs.applyAOE; ret.AOERadius = lhs.AOERadius + rhs.AOERadius; return ret; }
public static string GetUpgradeTooltip(TowerAttributes lhs, TowerAttributes rhs) { string str = ""; str += GetColoredRichTextForOutcome("Range",lhs.range.CompareTo(rhs.range)); str += GetColoredRichTextForOutcome("Damage", lhs.damage.CompareTo(rhs.damage)); str += GetColoredRichTextForOutcome("Rate of Fire", lhs.rateOfFire.CompareTo(rhs.rateOfFire), false); return str; }
void ApplyCreepEffectWithAttributes(GameObject creep, TowerAttributes attributes) { if (creep.GetComponent<Creep>()) { CreepEffect effect = creep.GetComponent<CreepEffect>(); if (effect == null) effect = creep.gameObject.AddComponent<CreepEffect>(); effect.damage += attributes.damage; // if (attributes.applyBurn) { effect.burnCount = Mathf.Max(effect.burnCount, attributes.burnCount); effect.burnDamage = Mathf.Max(effect.burnDamage, attributes.burnDamage); effect.burnTime = (effect.burnTime > 0) ? Mathf.Min(effect.burnTime, attributes.burnTime) : attributes.burnTime; } // if (attributes.applySlow) { effect.slowFactor = (effect.slowFactor > 0) ? Mathf.Min(effect.slowFactor, attributes.slowFactor) : attributes.slowFactor; effect.slowTime = Mathf.Max(effect.slowTime, attributes.slowTime); } } else { Debug.LogWarning("Attempted to apply CreepEffect to non-Creep; doing nothing."); } }
void ApplyAttributes(int path) { Mesh upgradeMesh = GetCurrentUpgrade(path).mesh; Material upgradeMaterial = GetCurrentUpgrade(path).material; if (upgradeMesh) { GetComponent<MeshFilter>().mesh = upgradeMesh; } if(upgradeMaterial) { GetComponent<MeshRenderer>().material = upgradeMaterial; } upgradeAttributes = new TowerAttributes(); for (int i = 0; i < upgradeTree.Count; i++) { if (upgradeLevels[i] >= 0) { upgradeAttributes += GetCurrentUpgrade(i); } } ApplyAttributes(); }