Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class Commodities : MonoBehaviour {
  7.  
  8. // Pricing of commodities
  9. float CrudeOilPriceRussia;
  10. float CrudeOilPriceNorway;
  11.  
  12. float NaturalGasPriceRussia;
  13. float NaturalGasPriceSaudiArabia;
  14.  
  15. float CornPriceUnitedStates;
  16. float CornPriceArgentina;
  17.  
  18. float CoffeePriceBrazil;
  19. float CoffeePriceVietnam;
  20.  
  21. float SugarPriceBrazil;
  22. float SugarPriceINdia;
  23.  
  24. float SteelPriceUnitedStates;
  25. float SteelPriceChina;
  26.  
  27. float IronPriceAustralia;
  28. float IronPriceSouthAfrica;
  29.  
  30. // Supply of commodities
  31. float CrudeOilSupplyRussia;
  32. float CrudeOilSupplyNorway;
  33.  
  34. float NaturalGasSupplyRussia;
  35. float NaturalGasSupplySaudiArabia;
  36.  
  37. float CornSupplyUnitedStates;
  38. float CornSupplyArgentina;
  39.  
  40. float CoffeeSupplyBrazil;
  41. float CoffeeSupplyVietnam;
  42.  
  43. float SugarSupplyBrazil;
  44. float SugarSupplyIndia;
  45.  
  46. float SteelSupplyUnitedStates;
  47. float SteelSupplyChina;
  48.  
  49. float IronSupplyAustralia;
  50. float IronSupplySouthAfrica;
  51.  
  52. // Daily supply deliveries
  53. public float DailyCrudeOilAmountRussia = 100000;
  54. public float DailyCrudeOilAmountNorway = 90000;
  55.  
  56. public Text supply;
  57.  
  58. // Use this for initialization
  59. void Start() {
  60. // Crude oil: Subject to change when adding saving system
  61. CrudeOilSupplyRussia = 40000000;
  62. CrudeOilSupplyNorway = 36000000;
  63. CrudeOilPriceRussia = 20.50f;
  64. CrudeOilPriceNorway = 22f;
  65.  
  66. supply.text = "Supply: " + CrudeOilSupplyRussia.ToString("n2") + " price: $" + CrudeOilPriceRussia;
  67.  
  68. }
  69.  
  70. /*
  71. * Start of adding & decreasing crude oil supply
  72. * */
  73. public void AddCrudeOil(float amount) {
  74. CrudeOilSupplyRussia += amount;
  75.  
  76. float fraction = amount / CrudeOilSupplyRussia;
  77. float increments = Mathf.Sign(fraction) * Mathf.Floor(Mathf.Abs(fraction) / 0.00125f); // the number of 0.125% changes on this day
  78.  
  79. if (increments > 0) {
  80. CrudeOilPriceRussia *= Mathf.Pow(0.9994f, increments);
  81. } else if (increments < 0) {
  82. CrudeOilPriceRussia *= Mathf.Pow(1.001f, increments);
  83. }
  84.  
  85. supply.text = "Supply: " + CrudeOilSupplyRussia.ToString("n2") + " price: " + CrudeOilPriceRussia;
  86. }
  87.  
  88. public void DecreaseCrudeOil(float amount) {
  89. CrudeOilSupplyRussia -= amount;
  90.  
  91. float fraction = amount / CrudeOilSupplyRussia;
  92. float increments = Mathf.Sign(fraction) * Mathf.Floor(Mathf.Abs(fraction) / 0.00125f); // the number of 0.125% changes on this day
  93.  
  94. if (increments > 0) {
  95. CrudeOilPriceRussia *= Mathf.Pow(1.001f, increments);
  96. }
  97. else if (increments < 0) {
  98. CrudeOilPriceRussia *= Mathf.Pow(0.9994f, increments);
  99. }
  100.  
  101. supply.text = "Supply: " + CrudeOilSupplyRussia.ToString("n2") + " price: " + CrudeOilPriceRussia;
  102. }
  103.  
  104. /*
  105. * End of adding & decreasing crude oil supply
  106. * */
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement