Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

[Development] Game Framework / RPG Development

so it will be a textbased game or are you going to use 2D/3D graphics? IF yes i would suggest the XNA framework.

For the A / An you can improve the logic and check the "enemies" name for e,a,i,o,u and if it is you write AN otherwiese A

for examle (pseudo)
PHP Code

<?php 
List<char> aeiou = new List<char>{ 'a','e','i','o','u'}
string s1 = "Skeleton";
string s2 = "Elephant";
if(
aeiou.Contains(s1[0].ToLower()))
Console.Write("AN");
else
Console.Write("A"); 

My bad, I did not read the whole post and scrolled down =) i re-read it :-D

are you using any kind of database to store information like available monsters and their stats etc.?

Then i would recommend (if it's should be easy) SQLite + FluentHibernate

I'm interested in helping / working with you...will it be open source?
Then you could upload it on GIT or SourceForge and we/people could work and help you, it would be cool if we can create some kind of MU online clone :)
(Oct 1, 2011 07:39 AM)Eternal Darkness Wrote:  
Code
Public Class Form1
    Dim a As String 'Characters name
    Dim b As Char

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  a = "A wild walka"
  MsgBox(Decisions(a))
    End Sub

    Public Function Decisions(ByVal k As String) As String
  b = k
  If b = "A" Or b = "E" Or b = "I" Or b = "O" Or b = "U" Then
    Return "An"
  Else
    Return "A"
  End If
    End Function
End Class

Simple a/an code...
Hope your game takes off...
I'd like to help you build, and learn from, this sometime bro. :3

first off all that's VB.NET but we are in the C# section!
secondly i posted already an example on which he can/should build on
and i am like 99% sure that your code even doesnt work...
(Oct 6, 2011 06:04 PM)Eternal Darkness Wrote:  http://www.developerfusion.com/tools/con...to-csharp/
We both know about this. I am 100% sure... Plus we both know VB.Net...

Gratz. :3 Trying to add to my post bro so I am not just another leech. Excuse me for posting a snippet...

Also, I totally (don't) have time to read through your posts before posting.

Code should work... I posted the code after I did a quick test... :l

Ok then i have some questions - maybe VB .NET is handling this different to what i would expect and how C# is doing:

here you assign a string to a
Code
a = "A wild walka"

here you call a method with parameter a and you use the return value of the method for the messagebox
Code
MsgBox(Decisions(a))

here you assign b with k, which is "A wild walka" (local copy of the parameter)
Code
Public Function Decisions(ByVal k As String) As String
  b = k //local copy of the full string ?!

i dont know if the compiler handles = in if statements as == (equals) operator and not as ASSIGN = ... lets pretend it does a comparison
you test for "A wild walka"="A" OR "A wild walka"="E" .. etc
which is wrong... you want to check the enemies name...and therefore the first character of its name... like b="ape" ... b[0]=="a" OR... etc..
or am i wrong and the VB.NET compiler is that smart and does it automatically?!
Code
If b = "A" Or b = "E" Or b = "I" Or b = "O" Or b = "U" Then

(Oct 6, 2011 07:56 PM)Asydix Wrote:  I still think my code is simpler :)

Nuff' with the arguing guys <3

wasn arguing, i was confused bc i read the code with c# .NET thinking and if u look at the code out of this view it's wrong, that's why i asked a second time and explained where the points are which are strange in my eyes ..

ur code is simpler thats right but:

1. U are everytime initializing the aeiou array which is memory waste - this array never changes, so make it global & static
2. You are using a string array, which is again waste, because all you actually need is a char array
3. Create a static list and use contains - SHORTEST, SIMPLEST

Code
private static IList<char> aeiou = new List<char>{ 'a','e','i','o','u'}

public static string AorAN(string text)
{
//you should do some checks on text if it's null/empty etc.
//otherwise it will crash on the next line if it's null or string.Empty;
return aieou.Contains(text[0].ToLower()) ? "An" : "A";
}

P.S. When is the reposirty up, wanna have a look at your code :)
Code
Math.Round(Number, 0, MidpointRounding.AwayFromZero); // you should have a look at this function and the parameters
otherwise...why so complicated, this should also work
Code
public static Double GreaterPoint5(Double Number)
  {

    var i = Number - Convert.ToInt32(Number);//should get rid of the full number
     return i >=.5 ? Math.Ceiling(Number) : Math.Floor(Number);
}

You should change your General class and its functions to static...why? because that's their purpose :-D

another thing you should learn/read is inheritance and abstract classes ...

weapons, potions, armor (if you want even enemies and the player) are objects which will have some basic information which they share like "Name"
then you do something like Item:WorldObject, Weapon:Item, Sword:Weapon (if you want swords to have specific attributes and others than Axes or Bows)...

Same for Players and Enemies.... Character:WorldObject, NPC:Character, Player:Character etc.

you will save a lot of redundant code and trouble...i had just a quick look....


your code logic is twisted, you item class inherits from player, which makes now sense ?!
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/
Hey I didnt want you to scare you off the project.. i just know from my own experience that if you do it kinda messy at the beginning you will have lot of trouble/problems later fixing things
or read your own code :) i am currently working on a project and have already over 20.000 lines of code, if i would not have any folder structure I would be lost :)
or if i would not use some of the inheritance i would have to change things like at 20 places, but now just in 1 :)

There is a good XNA RPG tutorial which you should work throu, it uses 2D engine BUT you can convert it almost 1 to 1 into a console text based RPG..
and it's pretty good for starters, to get your first "framework" going. One important thing you missed is a "GameScreens(Handler)" Class
or Input class (of course the input works different in XNA/Console) but even in your game u need to take input from the user at several places...and once programmed as a (static) inputhandler class, you don't need to worry anymore for wrong input etc.

Your task should be to fix up your project and finish it :)
But yes, to accomplish that you need to read tutorials to get a better understanding of game concept etc.

the tutorial i was talking about:
http://xnagpa.net/rpgtutorials.html <<its for the older 3.x XNA framework
http://xnagpa.net/xna4rpg.php <<for XNA 4.0


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by BarretSep 30, 2017 07:48 AM 19 868 Sep 30, 2017 07:48 AM
Last Post: Barret
[C] by Lexxi.Dec 8, 2016 09:07 PM 12 603 Dec 8, 2016 09:07 PM
Last Post: Lexxi.
[Java] by Lexxi.Dec 7, 2016 01:02 PM 1 235 Dec 7, 2016 01:02 PM
Last Post: CAFEEFAC