-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Add/Update] Add TimeManager, Update GameManager to bind/unbind events
- Loading branch information
1 parent
6078af5
commit 0bb68f5
Showing
7 changed files
with
79 additions
and
40 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
MissileCommander/.idea/.idea.MissileCommander/.idea/contentModel.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections; | ||
using UnityEngine; | ||
|
||
namespace MissileCommander | ||
{ | ||
public class TimeManager : MonoBehaviour | ||
{ | ||
public event Action onGameStart; | ||
private bool _isGameStarted = false; | ||
|
||
public void StartGame(float startDelay = 1f) | ||
{ | ||
if (_isGameStarted) { return; } | ||
|
||
_isGameStarted = true; | ||
StartCoroutine(DelayedGameStart(startDelay)); | ||
} | ||
|
||
private IEnumerator DelayedGameStart(float delayTime) | ||
{ | ||
WaitForSeconds delay = new WaitForSeconds(delayTime); | ||
yield return delay; | ||
|
||
onGameStart?.Invoke(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.