#region File Description
//-----------------------------------------------------------------------------
// RandomCombat.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion
#region Using Statements
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework.Content;
#endregion
namespace RolePlayingGameData
{
///
/// Description of possible random combats in a particular map.
///
public class RandomCombat
{
///
/// The chance of a random combat starting with each step, from 1 to 100.
///
private int combatProbability;
///
/// The chance of a random combat starting with each step, from 1 to 100.
///
public int CombatProbability
{
get { return combatProbability; }
set { combatProbability = value; }
}
///
/// The chance of a successful escape from a random combat, from 1 to 100.
///
private int fleeProbability;
///
/// The chance of a successful escape from a random combat, from 1 to 100.
///
public int FleeProbability
{
get { return fleeProbability; }
set { fleeProbability = value; }
}
///
/// The range of possible quantities of monsters in the random encounter.
///
private Int32Range monsterCountRange;
///
/// The range of possible quantities of monsters in the random encounter.
///
public Int32Range MonsterCountRange
{
get { return monsterCountRange; }
set { monsterCountRange = value; }
}
///
/// The monsters that might be in the random encounter,
/// along with quantity and weight.
///
private List> entries =
new List>();
///
/// The monsters that might be in the random encounter,
/// along with quantity and weight.
///
public List> Entries
{
get { return entries; }
set { entries = value; }
}
#region Content Type Reader
///
/// Reads a RandomCombat object from the content pipeline.
///
public class RandomCombatReader : ContentTypeReader
{
protected override RandomCombat Read(ContentReader input,
RandomCombat existingInstance)
{
RandomCombat randomCombat = existingInstance;
if (randomCombat == null)
{
randomCombat = new RandomCombat();
}
randomCombat.CombatProbability = input.ReadInt32();
randomCombat.FleeProbability = input.ReadInt32();
randomCombat.MonsterCountRange = input.ReadObject();
randomCombat.Entries.AddRange(
input.ReadObject>>());
foreach (ContentEntry randomCombatEntry in randomCombat.Entries)
{
randomCombatEntry.Content = input.ContentManager.Load(
Path.Combine(@"Characters\Monsters",
randomCombatEntry.ContentName));
}
return randomCombat;
}
}
#endregion
}
}