Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Loot-Tables, Random Maps and Monsters - Part II

, 17 Jul 2012 CPOL
Bringing RDS to life - How it all works.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using rds;

namespace rds_demo
{
	static class Demo2
	{
		public static void Run()
		{
			Console.WriteLine("*** DEMO 2 STARTED ***");
			Console.WriteLine("----------------------");

			RDSTable t = new RDSTable();

			RDSTable subtable1 = new RDSTable();
			RDSTable subtable2 = new RDSTable();
			RDSTable subtable3 = new RDSTable();

			t.AddEntry(subtable1, 10); // we add a table to a table thanks to the interfaces
			t.AddEntry(subtable2, 10);
			t.AddEntry(subtable3, 10);

			subtable1.AddEntry(new MyItem("Table 1 - Item 1"), 10);
			subtable1.AddEntry(new MyItem("Table 1 - Item 2"), 10);
			subtable1.AddEntry(new MyItem("Table 1 - Item 3"), 10);

			subtable2.AddEntry(new MyItem("Table 2 - Item 1"), 10);
			subtable2.AddEntry(new MyItem("Table 2 - Item 2"), 10);
			subtable2.AddEntry(new MyItem("Table 2 - Item 3"), 10);

			subtable3.AddEntry(new MyItem("Table 3 - Item 1"), 10);
			subtable3.AddEntry(new MyItem("Table 3 - Item 2"), 10);
			subtable3.AddEntry(new MyItem("Table 3 - Item 3"), 10);

			t.rdsCount = 3;

			// First demo: Simply loot 2 out of the 6
			Console.WriteLine("Step 1: Loot 3 items - 3 runs");
			for (int i = 0; i < 3; i++)
			{
				Console.WriteLine("Run {0}", i + 1);
				foreach (MyItem m in t.rdsResult)
					Console.WriteLine("    {0}", m);
			}

			// Set Table2 to be a unique drop (can be contained only once

			subtable2.rdsUnique = true;
			t.rdsCount = 10;

			Console.WriteLine("Step 2: Table 2 is now unique, loot 10 items - 3 runs");
			for (int i = 0; i < 3; i++)
			{
				Console.WriteLine("Run {0}", i + 1);
				foreach (MyItem m in t.rdsResult)
					Console.WriteLine("    {0}", m);
			}

			Console.WriteLine("-----------------------");
			Console.WriteLine("*** DEMO 2 COMPLETE ***");
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mike Barthold
Software Developer (Senior)
Austria Austria
Software Developer since the late 80's, grew up in the good old DOS-Era, switched to windows with Win95 and now doing .net since early 2002 (beta).
Long year c# experience in entertainment software, game programming, directX and XNA as well as SQLServer (DBA, Modelling, Optimizing, Replication, etc) and Oracle Databases in Enterprise environments.

| Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 17 Jul 2012
Article Copyright 2012 by Mike Barthold
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid