chunk 1: core gameplay scripts scenes runtime assets
This commit is contained in:
48
Assets/Scripts/MissionManager.cs
Normal file
48
Assets/Scripts/MissionManager.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MissionManager : MonoBehaviour
|
||||
{
|
||||
public static MissionManager Instance { get; private set; }
|
||||
|
||||
public List<Mission> Missions { get; set; }
|
||||
public int TotalXPEarned { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Populate the list of missions
|
||||
Missions = new List<Mission>
|
||||
{
|
||||
new Mission("Complete Tutorial", "Finish the game tutorial", 100),
|
||||
new Mission("Defeat 10 Enemies", "Defeat 10 enemies in combat", 200),
|
||||
new Mission("Win 3 Matches", "Win 3 matches in multiplayer mode", 300)
|
||||
};
|
||||
}
|
||||
|
||||
public void CompleteMission(string missionName)
|
||||
{
|
||||
// Find the mission with the specified name
|
||||
Mission mission = Missions.Find(m => m.Name == missionName);
|
||||
|
||||
if (mission != null && !mission.IsCompleted)
|
||||
{
|
||||
// Mark the mission as completed
|
||||
mission.IsCompleted = true;
|
||||
|
||||
// Award XP to the player
|
||||
TotalXPEarned += mission.XPReward;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user