just a quick example
Code
/// <summary>
/// Basic class which describes any object in the world
/// </summary>
public class WorldObject
{
public string Name { get; set; }
public string Description { get; set; }
/// <summary>
///
/// </summary>
/// <param name="name"><b>Name:</b> Sets the Name of the Object</param>
/// <param name="description"><b>Description:</b> Sets the Description for the Object</param>
public WorldObject(string name = "", string description = "")
{
Name = name;
Description = description;
}
}
public class Item : WorldObject
{
public bool CanBeStacked { get; set; }
public bool CanBeUsed { get; set; }
public decimal Weight { get; set; }
public decimal Amount { get; set; }
public decimal Value { get; set; }
public Item(string name = "null", string description = "null", decimal weight = 1, decimal amount = 1,
decimal value = 0) : base(name, description)
{
Weight = weight;
Amount = amount;
Value = value;
}
}
public class Character : WorldObject
{
public int Level { get; set; }
public decimal Strength { get; set; }
public decimal Dextery { get; set; }
public decimal MaxHealth { get; set; }
public decimal CurrentHealth { get; set; }
public delegate void DeathEventHandler(object sender, EventArgs e);
public event DeathEventHandler Died;
public Character()
{
//whatever
}
/// <summary>
///
/// </summary>
/// <param name="enemy">reference of the enemy who is attacking</param>
public virtual void DealDamage(ref Character enemy) //virtual so you can overwrite it for your player if you want, or do some BASIC calculation for baisc enemies/players and more advanced for Bosses or special...
{
//here you write somelogic, if the enemy successfully attacked
//this. defendet or counter attacked etc.
CurrentHealth -= enemy.Strength;
if(CurrentHealth<=0)
{
Died(this, null);//this will raise the event that this player/npc, died
}
}
}
[Flags]//you can list all you effects/buffs/debuffs here, or you can have several enums for "elemets", "buffs","debuffs", i choose this because with flags
//you can do combinations...but you you need to calculate it out for example the value of fire+resitence needs to be unique for FireResistance
public enum EffectName
{
None=0x000,
Heal=0x001,
Revive=0x002,
Death=0x004,
Resistence=0x008,
Absorb=0x010,
Fire=0x020,
FireResitance = 0x028,
Ice=0x03F
}
/// <summary>
///
/// </summary>
public class FirePotion : Item
{
/// <summary>
///
/// </summary>
public EffectName PotionEffect = EffectName.Fire | EffectName.Resistence; //which will be FireResitance
}
(Oct 9, 2011 04:13 PM)Asydix Wrote: I have no previous experience of doing something like this; I'll get right on learning that :)
that's why i mentioned that i would like to help :)
there are lot's of little things if you do them or correct them right now you will save a lot of time later :)
there are some RPG XNA tutorials which you should read, even if you don't use XNA ... it gives you some good training
You should add folder structure like:
Project
|___Enums
| |____Classes (mage, warrior etc)
| |____Elements (Fire, Wind, Ice etc)
|
|___Items
| |___Weapons
| | |___Swords
| | | |_Katana
| | |
| | |___Axes
| |
| |___Potions
etc..
use auto properties where possible!
the naming guideline in C# is variables camel case and properties Pascal case (
http://www.akadia.com/services/naming_conventions.html)
try to use events for things like "level up" , "death"...
i dont know if its because its unfinished but you dont use some variables in your formulas but you define them
and your attack formula is very confusing, because in the end you check the final damage > minDamage and you add 1 until its more than min damage and or you return a random number between 1 and 10...
what the heck? ... if you do a correct calculation of the damage you deal you dont need any while to add 1 until is more than min damage...
if you had planed it more carefully you would say: if my calculation returns less then the expected min damage, return min damage (and not add value x until dmg is >= minDamage.. and even then!!! you should add the difference between the calculated dmg and then min damage and not add 1 in a loop....)
you should do first a specification plan everything and afterwards start developing.. like i said you inherit from the wrong classes etc.
and rewrite the whole thing while it's still possible
have a look at:
http://www.freewebs.com/campelmxna/tutorials.htm and
http://sourceforge.net/projects/console-rpg/