Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
343 changes: 178 additions & 165 deletions Assets/Scenes/Game.unity

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Assets/Scripts/Game/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

public class Player : MonoBehaviour
{

public event System.Action<Package> packageDropped;

[Header("Startup Settings")]
public bool worldIsSpherical = true;
public PlayerStartPoint startPoint;
Expand Down Expand Up @@ -380,7 +377,6 @@ public Package DropPackage()
{
Package package = Instantiate(packagePrefab, packageDropPoint.position, packageDropPoint.rotation);
package.Init(worldLookup);
packageDropped?.Invoke(package);
return package;
}

Expand Down
22 changes: 22 additions & 0 deletions Assets/Scripts/Game/Quest/PackageCleanup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using UnityEngine;

namespace GeoGame.Quest
{
public class PackageCleanup : MonoBehaviour
{
QuestSystem questSystem;
PackageDropInfo lastPackageDropInfo;

void Awake() => questSystem = GetComponent<QuestSystem>();

void OnEnable() => questSystem.packageDropped += OnPackageDropped;

void OnDisable() => questSystem.packageDropped -= OnPackageDropped;

void OnPackageDropped(PackageDropInfo packageDropInfo)
{
lastPackageDropInfo?.Destroy();
lastPackageDropInfo = packageDropInfo;
}
}
}
3 changes: 3 additions & 0 deletions Assets/Scripts/Game/Quest/PackageCleanup.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Assets/Scripts/Game/Quest/PackageDropInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using UnityEngine;

namespace GeoGame.Quest
{
public class PackageDropInfo
{
private readonly Package package;
private readonly CityMarker cityMarker;

public PackageDropInfo(Package package, CityMarker cityMarker)
{
this.package = package;
this.cityMarker = cityMarker;
}

public void Destroy()
{
Object.Destroy(package.gameObject);
Object.Destroy(cityMarker.gameObject);
}
}
}
3 changes: 3 additions & 0 deletions Assets/Scripts/Game/Quest/PackageDropInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions Assets/Scripts/Game/Quest/QuestSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace GeoGame.Quest
{
public class QuestSystem : MonoBehaviour
{
public event System.Action<PackageDropInfo> packageDropped;
public float timedModeDurationSeconds = 15 * 60;

public const int numActiveQuests = 3;
Expand Down Expand Up @@ -211,8 +212,7 @@ public void TryDropPackage()
// Drop package
if (activeDeliverQuestIndex >= 0)
{
Package package = player.DropPackage();
StartCoroutine(HandleDelivery(package, activeDeliverQuestIndex));
StartCoroutine(HandleDelivery(activeDeliverQuestIndex));
}
else
{
Expand All @@ -224,8 +224,10 @@ public void TryDropPackage()
}
}

IEnumerator HandleDelivery(Package package, int questIndex)
IEnumerator HandleDelivery(int questIndex)
{
Package package = player.DropPackage();

displayingDeliveryResults = true;
float startTime = Time.time;

Expand All @@ -250,7 +252,8 @@ IEnumerator HandleDelivery(Package package, int questIndex)
Vector3 cityPoint = cityPointUnitSphere * targetCityTerrainHeight;
CityMarker cityMarker = Instantiate(cityMarkerPrefab, parent: transform);
cityMarker.Init(cityPoint, gameCamera.transform.position);


packageDropped?.Invoke(new PackageDropInfo(package, cityMarker));

// Calculate results
DeliveryResult result = new DeliveryResult();
Expand Down