Add timed victory and config changes

This commit is contained in:
craftwill 2023-11-13 20:03:28 -05:00
parent e8d89dbd03
commit c8d2e43326
9 changed files with 28 additions and 14 deletions

View File

@ -249,7 +249,7 @@ MonoBehaviour:
_position: {x: 0, y: 0}
_scale: {x: 1, y: 1}
_waveConfig: {fileID: 11400000, guid: d8140ae36f1b7fd4fb1a57ab3dc69de4, type: 2}
_startPopulation: 5
_startFood: 30
_startPopulation: 10
_startFood: 40
_startWood: 0
_startRock: 0

View File

@ -193,7 +193,7 @@ MonoBehaviour:
_position: {x: 0, y: 0}
_scale: {x: 1, y: 1}
_waveConfig: {fileID: 11400000, guid: e9e134bb6a24e4647a27955d3d276bd2, type: 2}
_startPopulation: 5
_startFood: 30
_startPopulation: 10
_startFood: 40
_startWood: 0
_startRock: 0

View File

@ -195,7 +195,7 @@ MonoBehaviour:
_position: {x: 0, y: 0}
_scale: {x: 1, y: 1}
_waveConfig: {fileID: 11400000, guid: c22ff5f49b21f9844a4d9693dc06777c, type: 2}
_startPopulation: 5
_startFood: 30
_startPopulation: 10
_startFood: 40
_startWood: 0
_startRock: 0

View File

@ -225,7 +225,7 @@ MonoBehaviour:
_position: {x: 0, y: 0}
_scale: {x: 1, y: 1}
_waveConfig: {fileID: 11400000, guid: 5ccff833a19a71f4499a3b3d786f4d11, type: 2}
_startPopulation: 5
_startFood: 30
_startPopulation: 10
_startFood: 40
_startWood: 0
_startRock: 0

View File

@ -148,6 +148,8 @@ MonoBehaviour:
_position: {x: -10, y: -1, z: 0}
- _tile: {fileID: 11400000, guid: e0b1d2d816ae5624c99b09a2bebb2a39, type: 2}
_position: {x: -10, y: 0, z: 0}
- _tile: {fileID: 11400000, guid: 3723ba09738ef6245947ae3ba7978b21, type: 2}
_position: {x: -10, y: 1, z: 0}
- _tile: {fileID: 11400000, guid: e0b1d2d816ae5624c99b09a2bebb2a39, type: 2}
_position: {x: -9, y: -1, z: 0}
- _tile: {fileID: 11400000, guid: e0b1d2d816ae5624c99b09a2bebb2a39, type: 2}
@ -195,7 +197,7 @@ MonoBehaviour:
_position: {x: 0, y: 0}
_scale: {x: 1, y: 1}
_waveConfig: {fileID: 11400000, guid: 2462ecbf554cf1d4883dea95b2504a9f, type: 2}
_startPopulation: 5
_startFood: 30
_startPopulation: 10
_startFood: 40
_startWood: 0
_startRock: 0

View File

@ -207,7 +207,7 @@ MonoBehaviour:
_position: {x: 0, y: 0}
_scale: {x: 1, y: 1}
_waveConfig: {fileID: 11400000, guid: eee8fc46b43d8144ca603169dc9f26d6, type: 2}
_startPopulation: 5
_startFood: 30
_startPopulation: 10
_startFood: 40
_startWood: 0
_startRock: 0

View File

@ -43,6 +43,7 @@ public class WaveConfig : ScriptableObject
return interval;
}
}
public float GameDuration { get { return _gameDuration; } }
/**
* Returns the updated game interval after adjusting to enemies spawned at the start
*/

View File

@ -1,3 +1,5 @@
using GatherAndDefend.Events;
using System.Threading.Tasks;
using System.Collections.Generic;
using UnityEngine;
@ -15,7 +17,7 @@ public class WaveObserver : Singleton<WaveObserver>
private bool _once = true;
private int _currentGroupIndex = 0;
public void SetLevelConfig(WaveConfig config)
public void Init(WaveConfig config)
{
_levelConfig = Object.Instantiate(config);
_copyConstantSpawn = new List<int>();
@ -39,6 +41,15 @@ public class WaveObserver : Singleton<WaveObserver>
}
_groupSpawnTimers.Add(_levelConfig.NestedGroupSpawn[index].triggerTime);
}
// Start game timer, at the end, player wins.
GameTimer();
}
private async void GameTimer()
{
await Task.Delay((int) _levelConfig.GameDuration * 60 * 1000);
EventAggregator.Instance.GetEvent<LastWaveCompletedEvent>().Invoke();
}
/**

View File

@ -166,7 +166,7 @@ public class LevelManager : Singleton<LevelManager>
_currentLevel = level;
_waveObserver = WaveObserver.Instance;
_waveObserver.SetLevelConfig(_currentLevel.WaveConfig);
_waveObserver.Init(_currentLevel.WaveConfig);
Grid grid = Object.FindObjectOfType<Grid>();
//create new grid if there is none
if (!grid)