Task 3 – Asynchronously updating enemy stats
Updating the stats of enemies (such as health, speed, or damage) might need to be done asynchronously, especially if it involves fetching or syncing information from a game server. Implement an UpdateAllEnemyStatsAsync
method that recursively goes through a hierarchy of waves (containing both enemies and sub-waves) and updates stats for each enemy asynchronously.
For the sake of this exercise, simulate the asynchronous update operation with the UpdateStatsAsync(Enemy enemy)
method, which returns Task
. Your recursive function should await the completion of stat updates for each enemy before moving to the next:
class Enemy { public string Name { get; set; } // Assume other stat properties like Health, Speed, Damage } class Wave { public List<object> Contents { get; set; } = new(); } // Simulated asynchronous update method async Task UpdateStatsAsync...