86 lines
1.8 KiB
C#
86 lines
1.8 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
|
|
/// <summary>
|
|
/// Defines the current status of a quest
|
|
/// </summary>
|
|
public enum QuestStatus
|
|
{
|
|
NotStarted,
|
|
Active,
|
|
Completed,
|
|
Failed,
|
|
Abandoned
|
|
}
|
|
|
|
/// <summary>
|
|
/// Defines the type of quest objective
|
|
/// </summary>
|
|
public enum ObjectiveType
|
|
{
|
|
KillEnemies,
|
|
CollectItems,
|
|
TalkToNPC,
|
|
ReachLocation,
|
|
UseItem,
|
|
Custom
|
|
}
|
|
|
|
/// <summary>
|
|
/// Individual quest objective data
|
|
/// </summary>
|
|
[System.Serializable]
|
|
public class QuestObjective
|
|
{
|
|
public string objectiveId;
|
|
public string description;
|
|
public ObjectiveType type;
|
|
public int targetAmount = 1;
|
|
public int currentAmount = 0;
|
|
public bool isCompleted = false;
|
|
public bool isOptional = false;
|
|
|
|
/// <summary>
|
|
/// Progress this objective by a specified amount
|
|
/// </summary>
|
|
public void AddProgress(int amount = 1)
|
|
{
|
|
currentAmount = Mathf.Min(currentAmount + amount, targetAmount);
|
|
CheckCompletion();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set progress to a specific value
|
|
/// </summary>
|
|
public void SetProgress(int amount)
|
|
{
|
|
currentAmount = Mathf.Clamp(amount, 0, targetAmount);
|
|
CheckCompletion();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if objective is completed
|
|
/// </summary>
|
|
private void CheckCompletion()
|
|
{
|
|
isCompleted = currentAmount >= targetAmount;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get progress as percentage (0-1)
|
|
/// </summary>
|
|
public float GetProgressPercentage()
|
|
{
|
|
return targetAmount > 0 ? (float)currentAmount / targetAmount : 0f;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset objective progress
|
|
/// </summary>
|
|
public void Reset()
|
|
{
|
|
currentAmount = 0;
|
|
isCompleted = false;
|
|
}
|
|
}
|