public override void Initialize(bool bRandomize) { if (bRandomize) { int seed = UnityEngine.Random.Range (0, 8); Type = (PlanetType)seed; seed = UnityEngine.Random.Range (0, 5); Size = (PlanetSize)seed; Coordinates.Set (UnityEngine.Random.Range(-50f, 50f), UnityEngine.Random.Range(-50f, 50f)); } base.Initialize (bRandomize); switch (Type) { case PlanetType.Asteroid: { _baseModifiers.Fuel = 0f; _baseModifiers.Metal = UnityEngine.Random.Range (1.25f, 1.4f); _baseModifiers.Crystal = UnityEngine.Random.Range (.25f, .4f); _baseModifiers.Organic = 0; _initialRates = new GainRate (0f, 0f, 0f, 0f); break; } case PlanetType.Aquatic: { _baseModifiers.Fuel = UnityEngine.Random.Range (.8f, 1.1f); _baseModifiers.Metal = UnityEngine.Random.Range (.1f, .2f); _baseModifiers.Crystal = UnityEngine.Random.Range (.5f, .75f); _baseModifiers.Organic = UnityEngine.Random.Range (.5f, .75f); _initialRates = new GainRate (0f, 0f, .5f, 2f); break; } case PlanetType.Barren: { _baseModifiers.Fuel = 0f; _baseModifiers.Metal = UnityEngine.Random.Range (.5f, .75f); _baseModifiers.Crystal = UnityEngine.Random.Range (.1f, .2f); _baseModifiers.Organic = 0f; _initialRates = new GainRate (0f, 0f, 0f, 0f); break; } case PlanetType.Desert: { _baseModifiers.Fuel = UnityEngine.Random.Range (.8f, 1.1f); _baseModifiers.Metal = UnityEngine.Random.Range (.8f, 1.1f); _baseModifiers.Crystal = UnityEngine.Random.Range (.5f, .75f); _baseModifiers.Organic = UnityEngine.Random.Range (.1f, .2f); _initialRates = new GainRate (0f, 0f, 0f, 0f); break; } case PlanetType.Frozen: { _baseModifiers.Fuel = UnityEngine.Random.Range (.1f, .2f); _baseModifiers.Metal = UnityEngine.Random.Range (.1f, .2f); _baseModifiers.Crystal = UnityEngine.Random.Range (1.1f, 1.2f); _baseModifiers.Organic = 0f; _initialRates = new GainRate (0f, 0f, 0f, 0f); break; } case PlanetType.Gas: { _baseModifiers.Fuel = UnityEngine.Random.Range (1.4f, 1.6f); _baseModifiers.Metal = 0f; _baseModifiers.Crystal = 0f; _baseModifiers.Organic = 0f; _initialRates = new GainRate (.5f, 0f, 0f, 0f); break; } case PlanetType.Jungle: { _baseModifiers.Fuel = UnityEngine.Random.Range (1.1f, 1.2f); _baseModifiers.Metal = UnityEngine.Random.Range (.25f, .4f); _baseModifiers.Crystal = UnityEngine.Random.Range (.25f, .4f); _baseModifiers.Organic = UnityEngine.Random.Range (1.4f, 1.6f); _initialRates = new GainRate (2f, 0f, 1f, 5f); break; } case PlanetType.Terran: { _baseModifiers.Fuel = UnityEngine.Random.Range (.8f, 1.1f); _baseModifiers.Metal = UnityEngine.Random.Range (.8f, 1.1f); _baseModifiers.Crystal = UnityEngine.Random.Range (.8f, 1.1f); _baseModifiers.Organic = UnityEngine.Random.Range (.8f, 1.1f); _initialRates = new GainRate (4f, 4f, 4f, 4f); break; } case PlanetType.Volcanic: { _baseModifiers.Fuel = UnityEngine.Random.Range (1.1f, 1.2f); _baseModifiers.Metal = UnityEngine.Random.Range (1.25f, 1.4f); _baseModifiers.Crystal = UnityEngine.Random.Range (.25f, .4f); _baseModifiers.Organic = 0f; _initialRates = new GainRate (0f, 2f, 0f, 0f); break; } default: { _baseModifiers.Fuel = UnityEngine.Random.Range (0f, .1f); _baseModifiers.Metal = UnityEngine.Random.Range (0f, .1f); _baseModifiers.Crystal = UnityEngine.Random.Range (0f, .1f); _baseModifiers.Organic = UnityEngine.Random.Range (0f, .1f); _initialRates = new GainRate (0f, 0f, 0f, 0f); break; } } int _randomNum = -1; do { _randomNum = UnityEngine.Random.Range (0, Database.PlanetNames.Length - 1); } while (_selectedNames.Contains(_randomNum)); Name = Database.PlanetNames[_randomNum]; InteractRadius = ((int)Size + 1) * 2f; UpdateState += OnUpdateStateEvent; UpdateSecond += OnUpdateSecondEvent; CalcRates (); }
private void CalcRates () { _tempBonus.Fuel = 0f; _tempBonus.Metal = 0f; _tempBonus.Crystal = 0f; _tempBonus.Organic = 0f; _tempModifiers.Fuel = 0f; _tempModifiers.Metal = 0f; _tempModifiers.Crystal = 0f; _tempModifiers.Organic = 0f; for (int i = 0; i < Structures.Count; i++) { _tempBonus.Fuel += Structures[i].BonusFuel; _tempBonus.Metal += Structures[i].BonusMetal; _tempBonus.Crystal += Structures[i].BonusCrystal; _tempBonus.Organic += Structures[i].BonusOrganic; _tempModifiers.Fuel += Structures[i].ModifierFuel; _tempModifiers.Metal += Structures[i].ModifierMetal; _tempModifiers.Crystal += Structures[i].ModifierCrystal; _tempModifiers.Organic += Structures[i].ModifierOrganic; } _tempRate.Fuel = _baseModifiers.Fuel * (_initialRates.Fuel + _tempBonus.Fuel) * (1f + _tempModifiers.Fuel + ((int)Size * (int)Size * .05f)); _tempRate.Metal = _baseModifiers.Metal * (_initialRates.Metal + _tempBonus.Metal) * (1f + _tempModifiers.Metal + ((int)Size * (int)Size * .05f)); _tempRate.Crystal = _baseModifiers.Crystal * (_initialRates.Crystal + _tempBonus.Crystal) * (1f + _tempModifiers.Crystal + ((int)Size * (int)Size * .05f)); _tempRate.Organic = _baseModifiers.Organic * (_initialRates.Organic + _tempBonus.Organic) * (1f + _tempModifiers.Organic + ((int)Size * (int)Size * .05f)); CurrentRates = new GainRate (_tempRate.Fuel, _tempRate.Metal, _tempRate.Crystal, _tempRate.Organic); }