Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class Commodities : MonoBehaviour {
- // Pricing of commodities
- float CrudeOilPriceRussia;
- float CrudeOilPriceNorway;
- float NaturalGasPriceRussia;
- float NaturalGasPriceSaudiArabia;
- float CornPriceUnitedStates;
- float CornPriceArgentina;
- float CoffeePriceBrazil;
- float CoffeePriceVietnam;
- float SugarPriceBrazil;
- float SugarPriceINdia;
- float SteelPriceUnitedStates;
- float SteelPriceChina;
- float IronPriceAustralia;
- float IronPriceSouthAfrica;
- // Supply of commodities
- float CrudeOilSupplyRussia;
- float CrudeOilSupplyNorway;
- float NaturalGasSupplyRussia;
- float NaturalGasSupplySaudiArabia;
- float CornSupplyUnitedStates;
- float CornSupplyArgentina;
- float CoffeeSupplyBrazil;
- float CoffeeSupplyVietnam;
- float SugarSupplyBrazil;
- float SugarSupplyIndia;
- float SteelSupplyUnitedStates;
- float SteelSupplyChina;
- float IronSupplyAustralia;
- float IronSupplySouthAfrica;
- // Daily supply deliveries
- public float DailyCrudeOilAmountRussia = 100000;
- public float DailyCrudeOilAmountNorway = 90000;
- public Text supply;
- // Use this for initialization
- void Start() {
- // Crude oil: Subject to change when adding saving system
- CrudeOilSupplyRussia = 40000000;
- CrudeOilSupplyNorway = 36000000;
- CrudeOilPriceRussia = 20.50f;
- CrudeOilPriceNorway = 22f;
- supply.text = "Supply: " + CrudeOilSupplyRussia.ToString("n2") + " price: $" + CrudeOilPriceRussia;
- }
- /*
- * Start of adding & decreasing crude oil supply
- * */
- public void AddCrudeOil(float amount) {
- CrudeOilSupplyRussia += amount;
- float fraction = amount / CrudeOilSupplyRussia;
- float increments = Mathf.Sign(fraction) * Mathf.Floor(Mathf.Abs(fraction) / 0.00125f); // the number of 0.125% changes on this day
- if (increments > 0) {
- CrudeOilPriceRussia *= Mathf.Pow(0.9994f, increments);
- } else if (increments < 0) {
- CrudeOilPriceRussia *= Mathf.Pow(1.001f, increments);
- }
- supply.text = "Supply: " + CrudeOilSupplyRussia.ToString("n2") + " price: " + CrudeOilPriceRussia;
- }
- public void DecreaseCrudeOil(float amount) {
- CrudeOilSupplyRussia -= amount;
- float fraction = amount / CrudeOilSupplyRussia;
- float increments = Mathf.Sign(fraction) * Mathf.Floor(Mathf.Abs(fraction) / 0.00125f); // the number of 0.125% changes on this day
- if (increments > 0) {
- CrudeOilPriceRussia *= Mathf.Pow(1.001f, increments);
- }
- else if (increments < 0) {
- CrudeOilPriceRussia *= Mathf.Pow(0.9994f, increments);
- }
- supply.text = "Supply: " + CrudeOilSupplyRussia.ToString("n2") + " price: " + CrudeOilPriceRussia;
- }
- /*
- * End of adding & decreasing crude oil supply
- * */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement