Click here to Skip to main content
15,892,575 members
Articles / Programming Languages / C#

Loot-Tables, Random Maps and Monsters - Part II

Rate me:
Please Sign up or sign in to vote.
4.92/5 (24 votes)
17 Jul 2012CPOL10 min read 51.7K   921   33  
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 Demo5
	{
		public static void Run()
		{
			Console.WriteLine("*** DEMO 5 STARTED ***");
			Console.WriteLine("----------------------");

			Console.Write("Enter Area Level: ");
			int baselevel = Convert.ToInt32(Console.ReadLine());
			Console.Write("Enter Monster Level: ");
			int moblevel = Convert.ToInt32(Console.ReadLine());
			Console.Write("Enter Player Level: ");
			int playerlevel = Convert.ToInt32(Console.ReadLine());

			// This table contains only 1 entry to demonstrate the RDSValue<T> class.
			// In a real scenario, a gold drop is only one of many entries for the loot
			// of a mob of course.
			RDSTable gold = new RDSTable();
			gold.AddEntry(new GoldDrop(baselevel, moblevel, playerlevel), 1);

			Console.WriteLine("Querying Gold drop: " + ((GoldDrop)gold.rdsResult.First()).rdsValue.ToString("n2"));

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

	public class GoldDrop : RDSValue<double>
	{
		public GoldDrop(int arealevel, int moblevel, int playerlevel):
			base(0, 1)
		{
			rdsValue = 10 * arealevel + (moblevel - arealevel) + (arealevel - playerlevel);
		}
	}
}

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)


Written By
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. Started with Android development in 2014.

Developer of the gml-raptor platform (See my github profile below).

My Game Developer Profile at itch.io
My Repositories at github

Comments and Discussions