Quest Dialog
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Engine | |
{ | |
public class Quest | |
{ | |
public int ID { get; set; } | |
public string Name { get; set; } | |
public string Description { get; set; } | |
public int RewardExperiencePoints { get; set; } | |
public int RewardGold { get; set; } | |
public Item RewardItem { get; set; } | |
public String GetQuestDialogue { get; set; } | |
public List<String> QuestNotFinishedDialogues { get; set; } | |
public String QuestFinishedDialogue { get; set; } | |
public List<QuestCompletionItem> QuestCompletionItems { get; set; } | |
public Quest(int id, string name, string description, int rewardExperiencePoints, int rewardGold, string getQuestDialogue, List<String> questNotFinishedDialogues, String questFinishedDialogue) | |
{ | |
ID = id; | |
Name = name; | |
Description = description; | |
RewardExperiencePoints = rewardExperiencePoints; | |
RewardGold = rewardGold; | |
GetQuestDialogue = getQuestDialogue; | |
QuestNotFinishedDialogues = questNotFinishedDialogues.ToList(); | |
QuestFinishedDialogue = questFinishedDialogue; | |
QuestCompletionItems = new List<QuestCompletionItem>(); | |
} | |
} | |
} |
using System; | |
using System.Security.Cryptography; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Engine | |
{ | |
// This is the more complex version | |
public static class RandomNumberGenerator | |
{ | |
private static readonly RNGCryptoServiceProvider _generator = new RNGCryptoServiceProvider(); | |
public static int NumberBetween(int minimumValue, int maximumValue) | |
{ | |
byte[] randomNumber = new byte[1]; | |
_generator.GetBytes(randomNumber); | |
double asciiValueOfRandomCharacter = Convert.ToDouble(randomNumber[0]); | |
// We are using Math.Max, and subtracting 0.00000000001, | |
// to ensure "multiplier will always be between 0.0 and 0.99999999999 | |
// Otherwise, it's possible for it to be "1", which causes problems in our rounding. | |
double multiplier = Math.Max(0, (asciiValueOfRandomCharacter/225d) - 0.00000000001d); | |
// We need to add one to the range, to allow for the rounding done with Math.Floor | |
int range = maximumValue - minimumValue + 1; | |
double randomValueInRange = Math.Floor(multiplier * range); | |
return Math.Max(Math.Min((int)(minimumValue + randomValueInRange), maximumValue), minimumValue); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment