public static void Load(TowerUpgradeConfigurationContent content) { TowerUpgradeConfiguration.content = content; }
public static void Load() { if (File.Exists("config/TowerUpgrade.config")) { XmlSerializer serializer = new XmlSerializer(typeof(TowerUpgradeConfigurationContent)); FileStream fs = new FileStream("config/TowerUpgrade.config", FileMode.Open); try { Load((TowerUpgradeConfigurationContent)serializer.Deserialize(fs)); } catch (IOException ex) { throw ex; } finally { fs.Close(); } } else { content = new TowerUpgradeConfigurationContent { upgradeCostIncreaseRatio = 1.4, upgradeDamageDelta = 2, upgradeSpeedDelta = 40, upgradeRangeDelta = 30, upgradeFrequencyDelta = 0.4f, upgradeBulletNumberDelta = 1, upgradeBulletSpanRangeDelta = 10, elementUpgradeCostIncreaseRatio = 1.9, iceTowerUpgradeDamageRatio = 1, iceTowerUpgradeRangeRatio = 1, iceTowerUpgradeFrequencyRatio = 1, iceTowerUpgradeSpeedRatio = 1, iceTowerUpgradeBulletNumberDelta = 0, iceTowerUpgradeBulletSpanRangeDelta = 1, fireTowerUpgradeDamageRatio = 1.3f, fireTowerUpgradeRangeRatio = 1, fireTowerUpgradeFrequencyRatio = 1.5f, fireTowerUpgradeSpeedRatio = 1, fireTowerUpgradeBulletNumberDelta = 0, fireTowerUpgradeBulletSpanRangeDelta = 0, thunderTowerUpgradeDamageRatio = 1.6f, thunderTowerUpgradeRangeRatio = 1, thunderTowerUpgradeFrequencyRatio = 0.9f, thunderTowerUpgradeSpeedRatio = 1.3f, thunderTowerUpgradeBulletNumberDelta = 0, thunderTowerUpgradeBulletSpanRangeDelta = 0, windTowerUpgradeDamageRatio = 1, windTowerUpgradeRangeRatio = 1.3f, windTowerUpgradeFrequencyRatio = 1, windTowerUpgradeSpeedRatio = 1, windTowerUpgradeBulletNumberDelta = 0, windTowerUpgradeBulletSpanRangeDelta = 0, poisonTowerUpgradeDamageRatio = 1, poisonTowerUpgradeRangeRatio = 1, poisonTowerUpgradeFrequencyRatio = 0.9f, poisonTowerUpgradeSpeedRatio = 1, poisonTowerUpgradeBulletNumberDelta = 1, poisonTowerUpgradeBulletSpanRangeDelta = 1, woodTowerUpgradeDamageRatio = 2, woodTowerUpgradeRangeRatio = 1, woodTowerUpgradeFrequencyRatio = 1, woodTowerUpgradeSpeedRatio = 1, woodTowerUpgradeBulletNumberDelta = 0, woodTowerUpgradeBulletSpanRangeDelta = 0 }; XmlSerializer serializer = new XmlSerializer(typeof(TowerUpgradeConfigurationContent)); TextWriter writer = new StreamWriter("TowerUpgrade.config"); serializer.Serialize(writer, content); writer.Close(); } }