-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestGenerator.cs
More file actions
125 lines (104 loc) · 4.18 KB
/
Copy pathQuestGenerator.cs
File metadata and controls
125 lines (104 loc) · 4.18 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System.Collections.Generic;
using UnityEngine;
public class QuestGenerator : MonoBehaviour
{
[SerializeField] private List<string> questTitles;
[SerializeField] private List<string> questDescriptions;
[SerializeField] private List<ItemReward> possibleRewards;
[SerializeField] private int minExperience = 100;
[SerializeField] private int maxExperience = 1000;
[SerializeField] private int minGold = 50;
[SerializeField] private int maxGold = 500;
public Quest GenerateRandomQuest(int playerLevel = 1)
{
Quest newQuest = new Quest();
// Random quest type
newQuest.type = (QuestType)Random.Range(0, System.Enum.GetValues(typeof(QuestType)).Length);
// Random title and description
newQuest.title = questTitles[Random.Range(0, questTitles.Count)];
newQuest.description = questDescriptions[Random.Range(0, questDescriptions.Count)];
// Set required level based on player level
newQuest.requiredLevel = Mathf.Max(1, playerLevel - Random.Range(0, 3));
// Generate objectives based on type
newQuest.objectives = GenerateObjectives(newQuest.type, playerLevel);
// Generate rewards
newQuest.reward = GenerateReward(playerLevel);
return newQuest;
}
private List<QuestObjective> GenerateObjectives(QuestType type, int playerLevel)
{
List<QuestObjective> objectives = new List<QuestObjective>();
int baseAmount = Mathf.Max(1, playerLevel / 2);
switch (type)
{
case QuestType.Collection:
objectives.Add(new QuestObjective
{
description = "Collect items",
requiredAmount = Random.Range(baseAmount, baseAmount + 5),
currentAmount = 0,
isCompleted = false,
location = GetRandomLocation(),
radius = 10f
});
break;
case QuestType.Elimination:
objectives.Add(new QuestObjective
{
description = "Defeat enemies",
requiredAmount = Random.Range(baseAmount, baseAmount + 3),
currentAmount = 0,
isCompleted = false,
location = GetRandomLocation(),
radius = 15f
});
break;
case QuestType.Exploration:
objectives.Add(new QuestObjective
{
description = "Explore location",
requiredAmount = 1,
currentAmount = 0,
isCompleted = false,
location = GetRandomLocation(),
radius = 5f
});
break;
// Add other quest types as needed
default:
objectives.Add(new QuestObjective
{
description = "Complete objective",
requiredAmount = 1,
currentAmount = 0,
isCompleted = false
});
break;
}
return objectives;
}
private QuestReward GenerateReward(int playerLevel)
{
float levelMultiplier = 1f + (playerLevel * 0.1f);
QuestReward reward = new QuestReward
{
experience = Mathf.RoundToInt(Random.Range(minExperience, maxExperience) * levelMultiplier),
gold = Mathf.RoundToInt(Random.Range(minGold, maxGold) * levelMultiplier),
reputationGain = Random.Range(5, 15) * levelMultiplier
};
// Add random items from possible rewards
int itemCount = Random.Range(1, 3);
for (int i = 0; i < itemCount && i < possibleRewards.Count; i++)
{
reward.items.Add(possibleRewards[Random.Range(0, possibleRewards.Count)]);
}
return reward;
}
private Vector3 GetRandomLocation()
{
// This is a simple implementation - you should modify this based on your game's needs
float x = Random.Range(-50f, 50f);
float z = Random.Range(-50f, 50f);
return new Vector3(x, 0, z);
}
}