Coding Support
Read Ad-free Manga, Manhwa, and Manhua at https://trilliux.me!

You are not connected. Please login or register

View previous topic View next topic Go down Message [Page 1 of 1]

1
To make an RPG Game using C# Empty To make an RPG Game using C# Sat Jun 08, 2013 11:57 am

ashunkown

ashunkown
CS Member
Can I use C# to make an RPG game? Is it possible? I really want one for my forum members. Thanks Very Happy

2
To make an RPG Game using C# Empty Re: To make an RPG Game using C# Sat Jun 08, 2013 12:02 pm

Support

Support
Site Admin
What type of RPG game do you want to make? Very Happy Please state clearly.

EDIT: But if you want one, here's a sample:

Code:
void Main()
{
  int state = 0;
  string command = "";

  while (command != "Quit")
  {
      if (command == "Look" && state == 0)
      {
        // Explore the dungeon.
        DoExploreDungeon();
      }
      else if (command == "Attack" && state == 0)
      {
        // There's nothing to attack when you're just exploring!
        DoNothingToAttack();
      }
      else if (command == "Look" && state == 1)
      {
        // You can't explore when a monster is attacking you!
        DoMonsterFreeHit();
      }
      else if (command == "Attack" && state == 1)
      {
        // Attack the monster.
        DoAttackEvilMonster();
      }
  }
}

Code:
void Main()
{
  RPGController rpg = new RPGController();
  string command = "";

  while (command != "Quit")
  {
      if (command == "Look")
      {
        rpg.Explore();
      }
      else if (command == "Attack")
      {
        rpg.Battle();
      }
  }
}

Code:
public interface IState
    {
        int Explore();
        int Battle(int level);
    }

Code:
public class ExploreState : IState
    {
        private RPGController context;

        public ExploreState(RPGController context)
        {
            this.context = context;
        }

        #region IState Members

        public int Explore()
        {
            Console.WriteLine("You look around for something to kill.");

            int ran = RandomGenerator.GetRandomNumber(5);
            if (ran == 0)
            {
                Console.WriteLine("A monster approaches! Prepare for battle!");
                context.SetState(context.GetBattleState());
            }
            else if (ran == 1)
            {
                Console.WriteLine("You find a golden jewel behind a tree!");
                return 2;
            }

            return 0;
        }

        public int Battle(int level)
        {
            Console.WriteLine("You find nothing to attack.");
            return 0;
        }

        #endregion
    }

Code:
public class BattleState : IState
    {
        private RPGController context;
        private int rounds = 0;

        public BattleState(RPGController context)
        {
            this.context = context;
        }

        #region IState Members

        public int Explore()
        {
            Console.WriteLine("You'd love to, but see, there's this big ugly monster in front of you!");
            return 0;
        }

        public int Battle(int level)
        {
            Console.Write("You try to slay the monster.. ");
         
            rounds++;

            System.Threading.Thread.Sleep(1000);

            int maxRan = 10 - level;
            if (maxRan < 1)
            {
                maxRan = 1;
            }

            int ran = RandomGenerator.GetRandomNumber(maxRan);
            if (ran == 0)
            {
                Console.WriteLine("he's dead!");
                context.SetState(context.GetExploreState());
             
                int tempRounds = rounds;
                rounds = 0;

                return tempRounds;
            }
            else
            {
                Console.WriteLine("but fail.");
            }

            if (rounds >= 9)
            {
                Console.WriteLine("You panic and run away in fear.");
                context.SetState(context.GetExploreState());

                rounds = 0;
            }

            return 0;
        }

        #endregion
    }

Code:
public class RPGController
    {
        private IState exploreState;
        private IState battleState;
        private IState state;
        private int level = 1;

        public RPGController()
        {
            exploreState = new ExploreState(this);
            battleState = new BattleState(this);

            state = exploreState;
        }

        public int Explore()
        {
            return state.Explore();
        }

        public int Battle()
        {
            return state.Battle(level);
        }

        public void SetState(IState state)
        {
            this.state = state;
        }

        public void SetLevel(int level)
        {
            this.level = level;
        }

        public int GetLevel()
        {
            return level;
        }

        public IState GetExploreState()
        {
            return exploreState;
        }

        public IState GetBattleState()
        {
            return battleState;
        }
    }

https://twzforums.forumotion.com

3
To make an RPG Game using C# Empty Re: To make an RPG Game using C# Sat Jun 08, 2013 9:13 pm

ashunkown

ashunkown
CS Member
dont work Sad
I want Pokemon rpg

4
To make an RPG Game using C# Empty Re: To make an RPG Game using C# Sat Jun 08, 2013 9:18 pm

Support

Support
Site Admin
Replace the images with Pokemon images. I don't know how to make a Pokemon RPG specifically, sorry Razz

~Locked

https://twzforums.forumotion.com

Sponsored content


View previous topic View next topic Back to top Message [Page 1 of 1]

Similar topics

-

» how i make clock in c#?

Permissions in this forum:
You cannot reply to topics in this forum