[TASK] Added main "game manager" to switch between the minigame and the map + added simple UI to show that a sticker was collected

This commit is contained in:
2019-08-28 01:11:46 +02:00
parent 9057c295da
commit c52392eacd
16 changed files with 2423 additions and 102 deletions

View File

@@ -15,7 +15,10 @@ public class CollectableDuckManager : MonoBehaviour
public AbstractMap map;
public Transform player;
public Transform collectableDuckParent;
public event EventHandler<CollectableDuckData> DuckClicked;
/// <summary>
/// Spawn distance in meters (i.e. how close should the player be to a duck before it spawns on the map
/// </summary>
@@ -24,6 +27,7 @@ public class CollectableDuckManager : MonoBehaviour
public CollectableDuck duckSpawnPrefab;
private static CollectableDuckManager _instance;
public static CollectableDuckManager Instance
{
get { return _instance; }
@@ -86,7 +90,7 @@ public class CollectableDuckManager : MonoBehaviour
{
// Spawn the duck
var duckSpawn = Instantiate(duckSpawnPrefab, map.GeoToWorldPosition(duck.LatitudeLongitude),
Quaternion.identity, transform);
Quaternion.identity, collectableDuckParent);
duckSpawn.CollectableDuckData = duck;
var duckModel = Instantiate(duck.ModelPrefab, duckSpawn.transform);
duckModel.transform.localPosition = Vector3.zero;
@@ -113,14 +117,20 @@ public class CollectableDuckManager : MonoBehaviour
}
}
public void DuckCollected(CollectableDuckData duck)
public void OnDuckClicked(CollectableDuckData duck)
{
if (DuckClicked != null)
{
DuckClicked.Invoke(this, duck);
}
}
public void OnDuckCollected(CollectableDuckData duck)
{
_collectedDucks.Add(duck);
PlayerPrefs.SetInt("duck." + duck.Id, 1);
DuckStickerManager.Instance.OnStickerCollected(duck.StickerData);
RemoveDuck(duck);
}
}