-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuest.cs
More file actions
79 lines (70 loc) · 1.6 KB
/
Copy pathQuest.cs
File metadata and controls
79 lines (70 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Quest
{
public string questId;
public string title;
public string description;
public QuestType type;
public List<QuestObjective> objectives;
public QuestReward reward;
public QuestStatus status;
public string questGiver;
public float timeLimit = -1f; // -1 means no time limit
public int requiredLevel = 1;
public Quest()
{
questId = Guid.NewGuid().ToString();
objectives = new List<QuestObjective>();
status = QuestStatus.Available;
}
public bool IsComplete()
{
if (objectives == null || objectives.Count == 0) return false;
return objectives.TrueForAll(o => o.isCompleted);
}
}
[System.Serializable]
public class QuestObjective
{
public string description;
public int requiredAmount;
public int currentAmount;
public bool isCompleted;
public Vector3 location;
public float radius = 5f;
public void UpdateProgress(int amount)
{
currentAmount = Mathf.Min(currentAmount + amount, requiredAmount);
isCompleted = currentAmount >= requiredAmount;
}
}
[System.Serializable]
public class QuestReward
{
public int experience;
public int gold;
public List<ItemReward> items;
public float reputationGain;
public QuestReward()
{
items = new List<ItemReward>();
}
}
public enum QuestType
{
Collection,
Elimination,
Exploration,
Escort,
Delivery
}
public enum QuestStatus
{
Available,
Active,
Completed,
Failed
}