So i am in the middle of creating an equation that will become the basis of my Monster Spawner.
The goal is to increase the difficulty over time for the player.
My approach goes as follows:
i have one struct within a struct.
The first struct determines the Tier that the enemy is in and the second struct the tier within the tier that the enemy is in.
There is a currentTierDifficulty variable which is based on the TimeElapsed. The current tiercap starts at 1 and finishes at whatever number of tiers there are. (realistically around 8 or less). The currenttierdifficulty increases around 0.002 every second which should make it reach tier 8 in around an hour.
The CurrenttTierCap is the currentTierDifficulty rounded to the nearest integer.
any tier below the the currentcap is available to be chosen.
i want each tier to be weighted.
for example:
CurrentTierDifficulty = 3.6
currentTierCap = 4
tier 1 <=== (0.4)
tier 2 <=== (0.2)
tier 3 <=== (0.15)
tier 4 <=== (0.05)
tier 5 not available because lower than currenttiercap
tier 6 not available because lower than currenttiercap
tier 7 not available because lower than currenttiercap
etc
but i also want the weight to slowly shift towards the end of the tier list so that toward the end of the one hour, you will only have tier 5, 6 and 7 monsters spawning.
so whenever i decide to spawn an enemy, a function checks the two struct and randomly selects a monster based on all of this information
i tried to make it as clear as i possibly can.
i have added a picture of what i have so far and where i am stuck.![alt text][1]
[Serializable]
public struct EnemyTier
{
public float BaseWeight;
[Serializable]
public struct NamedEnemy
{
public string name;
public int BaseHealth;
public float BaseDamage;
public float BaseSpeed;
public GameObject EnemyPrefab;
}
public NamedEnemy[] Enemie;
}
public EnemyTier[] Enemies;
int TotalNumberofTiers;
public int TimeinMinutes = 400;
public float TierDifficulty = 1;
public float TierIncreasePer10Seconds;//default is 0.002 per sec = 7.2 in one hour
private void Start()
{
TotalNumberofTiers = Enemies.Count();
TierIncreasePer10Seconds = TotalNumberofTiers / TimeinMinutes;
InvokeRepeating("DifficultyAdjustment", 10,10);
}
/// <summary>
/// selects the appropriate enemy from the structs
/// </summary>
public GameObject EnemySelection()
{
int PrecentageChance = 100 / TotalNumberofTiers;
int CurrentTierCap = Mathf.RoundToInt(TierDifficulty);