public Tower GetElementUpgradeSample(ElelmentType elementType) { Tower newTower = Duplicate(); newTower.ElementUpgrade(elementType); return(newTower); }
public virtual void ElementUpgrade(ElelmentType elementType, Game game) { if (game.Money >= UpgradeCost) { game.Money -= UpgradeCost; ElementUpgrade(elementType); } }
public void ShowTowerElementUpgradeInfo(Tower tower, ElelmentType elementType) { Tower upgradedTower = tower.GetElementUpgradeSample(elementType); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("{0} → {1}\n", tower.Name, upgradedTower.Name); stringBuilder.AppendFormat("消耗金錢 {0}\n", tower.UpgradeCost); if (tower.Damage != upgradedTower.Damage) { stringBuilder.AppendFormat("傷害: {0} → {1}\n", tower.Damage, upgradedTower.Damage); } else { stringBuilder.AppendFormat("傷害: {0}\n", tower.Damage); } if (tower.Range != upgradedTower.Range) { stringBuilder.AppendFormat("射程: {0} → {1}\n", tower.Range, upgradedTower.Range); } else { stringBuilder.AppendFormat("射程: {0}\n", tower.Range); } if (tower.Frequency != upgradedTower.Frequency) { stringBuilder.AppendFormat("頻率: {0} → {1} 次/秒\n", tower.Frequency, upgradedTower.Frequency); } else { stringBuilder.AppendFormat("頻率: {0} 次/秒\n", tower.Frequency); } if (tower.Speed != upgradedTower.Speed) { stringBuilder.AppendFormat("初速度: {0} → {1}\n", tower.Speed, upgradedTower.Speed); } else { stringBuilder.AppendFormat("初速度: {0}\n", tower.Speed); } if (tower.BulletNumber != upgradedTower.BulletNumber) { stringBuilder.AppendFormat("彈數: {0} → {1}\n", tower.BulletNumber, upgradedTower.BulletNumber); } else { stringBuilder.AppendFormat("彈數: {0}\n", tower.BulletNumber); } if (tower.BulletSpanRange != upgradedTower.BulletSpanRange) { stringBuilder.AppendFormat("砲彈夾角:{0} → {1}\n", tower.BulletSpanRange, upgradedTower.BulletSpanRange); } towerInfoText.text = stringBuilder.ToString(); }
public override void ElementUpgrade(ElelmentType elementType, Game game) { base.ElementUpgrade(elementType, game); switch (elementType) { case ElelmentType.Ice: TowerInstance.GetComponent <SpriteRenderer>().color = new Color(170f / 255f, 255f / 255f, 228 / 255f); break; case ElelmentType.Fire: TowerInstance.GetComponent <SpriteRenderer>().color = new Color(255f / 255f, 84f / 255f, 0f / 255f); break; case ElelmentType.Thunder: TowerInstance.GetComponent <SpriteRenderer>().color = new Color(120f / 255f, 56f / 255f, 138f / 255f); break; case ElelmentType.Wind: TowerInstance.GetComponent <SpriteRenderer>().color = new Color(160f / 255f, 255f / 255f, 171f / 255f); break; case ElelmentType.Poison: TowerInstance.GetComponent <SpriteRenderer>().color = new Color(37f / 255f, 82f / 255f, 33f / 255f); break; case ElelmentType.Wood: TowerInstance.GetComponent <SpriteRenderer>().color = new Color(0f / 255f, 197f / 255f, 9f / 255f); break; } if (elementType == ElelmentType.Wind) { float radius = Range / 30f; TowerInstance.GetComponent <CircleCollider2D>().radius = radius; TowerInstance.transform.GetChild(0).localScale = new Vector3(2f * radius, 2f * radius, 1f); } }
public virtual void ElementUpgrade(ElelmentType elementType) { Level = Level + 1; UpgradeCost = Convert.ToInt32(Math.Ceiling(UpgradeCost * 1.9)); DestroyReturn = Convert.ToInt32(Math.Ceiling(DestroyReturn * 1.9)); if (ElementType == ElelmentType.Normal) { ElementType = elementType; } switch (ElementType) { case ElelmentType.Ice: Name = "冰凍塔"; Damage = Convert.ToInt32(Damage * TowerUpgradeConfiguration.IceTowerUpgradeDamageRatio); Range = Range * TowerUpgradeConfiguration.IceTowerUpgradeRangeRatio; Frequency = Frequency * TowerUpgradeConfiguration.IceTowerUpgradeFrequencyRatio; Speed = Speed * TowerUpgradeConfiguration.IceTowerUpgradeSpeedRatio; BulletNumber = BulletNumber + TowerUpgradeConfiguration.IceTowerUpgradeBulletNumberDelta; BulletSpanRange = BulletSpanRange + TowerUpgradeConfiguration.IceTowerUpgradeBulletSpanRangeDelta; break; case ElelmentType.Fire: Name = "火焰塔"; Damage = Convert.ToInt32(Damage * TowerUpgradeConfiguration.FireTowerUpgradeDamageRatio); Range = Range * TowerUpgradeConfiguration.FireTowerUpgradeRangeRatio; Frequency = Frequency * TowerUpgradeConfiguration.FireTowerUpgradeFrequencyRatio; Speed = Speed * TowerUpgradeConfiguration.FireTowerUpgradeSpeedRatio; BulletNumber = BulletNumber + TowerUpgradeConfiguration.FireTowerUpgradeBulletNumberDelta; BulletSpanRange = BulletSpanRange + TowerUpgradeConfiguration.FireTowerUpgradeBulletSpanRangeDelta; break; case ElelmentType.Thunder: Name = "閃電塔"; Damage = Convert.ToInt32(Damage * TowerUpgradeConfiguration.ThunderTowerUpgradeDamageRatio); Range = Range * TowerUpgradeConfiguration.ThunderTowerUpgradeRangeRatio; Frequency = Frequency * TowerUpgradeConfiguration.ThunderTowerUpgradeFrequencyRatio; Speed = Speed * TowerUpgradeConfiguration.ThunderTowerUpgradeSpeedRatio; BulletNumber = BulletNumber + TowerUpgradeConfiguration.ThunderTowerUpgradeBulletNumberDelta; BulletSpanRange = BulletSpanRange + TowerUpgradeConfiguration.ThunderTowerUpgradeBulletSpanRangeDelta; break; case ElelmentType.Wind: Name = "風暴塔"; Damage = Convert.ToInt32(Damage * TowerUpgradeConfiguration.WindTowerUpgradeDamageRatio); Range = Range * TowerUpgradeConfiguration.WindTowerUpgradeRangeRatio; Frequency = Frequency * TowerUpgradeConfiguration.WindTowerUpgradeFrequencyRatio; Speed = Speed * TowerUpgradeConfiguration.WindTowerUpgradeSpeedRatio; BulletNumber = BulletNumber + TowerUpgradeConfiguration.WindTowerUpgradeBulletNumberDelta; BulletSpanRange = BulletSpanRange + TowerUpgradeConfiguration.WindTowerUpgradeBulletSpanRangeDelta; break; case ElelmentType.Poison: Name = "毒物塔"; Damage = Convert.ToInt32(Damage * TowerUpgradeConfiguration.PoisonTowerUpgradeDamageRatio); Range = Range * TowerUpgradeConfiguration.PoisonTowerUpgradeRangeRatio; Frequency = Frequency * TowerUpgradeConfiguration.PoisonTowerUpgradeFrequencyRatio; Speed = Speed * TowerUpgradeConfiguration.PoisonTowerUpgradeSpeedRatio; BulletNumber = BulletNumber + TowerUpgradeConfiguration.PoisonTowerUpgradeBulletNumberDelta; BulletSpanRange = BulletSpanRange + TowerUpgradeConfiguration.PoisonTowerUpgradeBulletSpanRangeDelta; break; case ElelmentType.Wood: Name = "森林塔"; Damage = Convert.ToInt32(Damage * TowerUpgradeConfiguration.WoodTowerUpgradeDamageRatio); Range = Range * TowerUpgradeConfiguration.WoodTowerUpgradeRangeRatio; Frequency = Frequency * TowerUpgradeConfiguration.WoodTowerUpgradeFrequencyRatio; Speed = Speed * TowerUpgradeConfiguration.WoodTowerUpgradeSpeedRatio; BulletNumber = BulletNumber + TowerUpgradeConfiguration.WoodTowerUpgradeBulletNumberDelta; BulletSpanRange = BulletSpanRange + TowerUpgradeConfiguration.WoodTowerUpgradeBulletSpanRangeDelta; break; } }