} // END StorageShow public int SetStorageUp(bodenArten bArten, int amount) { if (bodenArtenDictionary.ContainsKey(bArten)) { if (currentStorageValue < maxStorageValue) { int storedAmount = Mathf.Clamp(amount, 0, (maxStorageValue - currentStorageValue)); bodenArtenDictionary[bArten] += storedAmount; currentStorageValue += storedAmount; return(amount - storedAmount); } return(amount); } else { return(-1); } } // END SetStorageUp
private void ChangingOfTradingPrices(BODENARTEN bodenart) { float changeOfPriceMin = 0; float changeOfPriceMax = 0; float rnd = (int)UnityEngine.Random.Range(1, 100); if (rnd > 0 && rnd < 20) { changeOfPriceMin = 20; changeOfPriceMax = 40; } else if (rnd >= 20 && rnd <= 80) { changeOfPriceMin = 10; changeOfPriceMax = 20; } else if (rnd > 80 && rnd <= 100) { changeOfPriceMin = 30; changeOfPriceMax = 60; } float changeOfPricePercent = UnityEngine.Random.RandomRange(changeOfPriceMin, changeOfPriceMax); float chanceOfPriceDown = 50 + changesUP[bodenart]; float chanceOfPriceUp = 50 + changesDOWN[bodenart]; rnd = UnityEngine.Random.RandomRange(1f, chanceOfPriceDown + chanceOfPriceUp); if (rnd <= chanceOfPriceDown) // Preis Runter { tradingPrices[bodenart] = Mathf.Clamp((int)(tradingPrices[bodenart] * (100 - changeOfPricePercent) / 100), InitValues[bodenart] / 2, InitValues[bodenart] * 5); changesUP[bodenart] = Mathf.Clamp(changesUP[bodenart]--, 0, changesUP[bodenart]); changesDOWN[bodenart]++; } else // Preis Hoch { tradingPrices[bodenart] = Mathf.Clamp((int)(tradingPrices[bodenart] * (1 + (changeOfPricePercent / 100))), InitValues[bodenart] / 2, InitValues[bodenart] * 5); changesDOWN[bodenart] = Mathf.Clamp(changesDOWN[bodenart]--, 0, changesDOWN[bodenart]); changesUP[bodenart]++; } }
} // END StorageShow public int SetStorageUp(bodenArten bArten, int amount) { if (bodenArtenDictionary.ContainsKey(bArten)) { if (currentStorageValue < maxStorageValue) { int storedAmount = Mathf.Clamp(amount, 0, (maxStorageValue - currentStorageValue)); bodenArtenDictionary[bArten] += storedAmount; currentStorageValue += storedAmount; return (amount - storedAmount); } return amount; } else { return -1; } } // END SetStorageUp
private void ChangingOfTradingPrices(BODENARTEN bodenart) { float changeOfPriceMin = 0; float changeOfPriceMax = 0; float rnd = (int)UnityEngine.Random.Range(1, 100); if (rnd > 0 && rnd < 20) { changeOfPriceMin = 20; changeOfPriceMax = 40; } else if (rnd >= 20 && rnd <= 80) { changeOfPriceMin = 10; changeOfPriceMax = 20; } else if (rnd > 80 && rnd <= 100) { changeOfPriceMin = 30; changeOfPriceMax = 60; } float changeOfPricePercent = UnityEngine.Random.RandomRange(changeOfPriceMin, changeOfPriceMax); float chanceOfPriceDown = 50 + changesUP[bodenart]; float chanceOfPriceUp = 50 + changesDOWN[bodenart]; rnd = UnityEngine.Random.RandomRange(1f, chanceOfPriceDown + chanceOfPriceUp); if (rnd <= chanceOfPriceDown) // Preis Runter { tradingPrices[bodenart] = Mathf.Clamp((int)(tradingPrices[bodenart] * (100 - changeOfPricePercent) / 100), InitValues[bodenart] / 2, InitValues[bodenart] * 5); changesUP[bodenart] = Mathf.Clamp(changesUP[bodenart]--, 0, changesUP[bodenart]); changesDOWN[bodenart]++; } else // Preis Hoch { tradingPrices[bodenart] = Mathf.Clamp((int)(tradingPrices[bodenart] * (1 + (changeOfPricePercent / 100))), InitValues[bodenart] / 2, InitValues[bodenart] * 5); changesDOWN[bodenart] = Mathf.Clamp(changesDOWN[bodenart]--, 0, changesDOWN[bodenart]); changesUP[bodenart]++; } }