Build a C#/WPF RPG

This is a new version of my previous lessons in Learn C# by Building a Simple RPG. Except, the user interface will use WPF/XAML, instead of Windows Forms.

I’m also trying a different style for these lessons. They will be mostly video-based, so I can talk about why I’m writing the code a specific way. I hope this will give you an idea of how a programmer thinks, when they work on a program.

There will still be a webpage here for each lesson. They will summarize any new techniques covered in the video. You can also leave questions on those pages.

 

NOTE: This course is “in-progress”.

 

Overview

Lesson 00.1: Overview

 

Preparation

Lesson 01.1: Installing Visual Studio Community 2015 – Update 3

Lesson 01.2: Installing TortoiseSVN and VisualSVN

 

Planning

Lesson 02.1: Planning the Game

 

Programming

Lesson 03.1: Creating the Solution and Game Screen

Lesson 03.2: Creating and Using a Subversion Repository

Lesson 03.3: Creating the Player Class

Lesson 03.4: Creating the GameSession (ViewModel) Class

Lesson 03.5: Displaying the Player Object

Lesson 03.6: Update Player data with the PropertyChanged event

Lesson 04.1: Creating the Location class

Lesson 04.2: Creating the World

Lesson 04.3: Moving in the game world

Lesson 04.4: Improving the World – Inheritance and INotifyPropertyChanged

Lesson 04.5: Improving the World – Factory and Guard Clauses

 

Future lessons (exact content and order may change)

  • 05.1 – Creating game items
    • Factory class
  • 05.2 – Add items to Player inventories
    • Display datagridview of inventory
  • 06.1 – Creating Quests
  • 06.2 – Adding Quests to Locations
    • Giving quests to the player
    • Display quests in datagridview
  • 07.1 – Creating monsters
    • MonsterFactory class
      • Need a new instance for each monster
      • Loot distribution (random)
  • 07.2 – Adding monsters to locations
    • List of monsters, random selection
    • Add the game message box
  • 07.3 – Fighting monsters
    • Display weapon controls
    • Combat
      • Player loses
      • Player wins
        • Gets loot/experience points/gold
  • 08.1 – Creating vendors
    • With inventories
    • Add to Locations
    • Display “Trade” button
  • 08.2 – Add “Trade” screen
    • Buy/sell items
  • ?? – Save/load game

11 thoughts on “Build a C#/WPF RPG

  1. Scott, I hope you will be continuing this series in the near future. I enjoyed following the Windows Forms version and feel like it was a valuable lesson. Now, I would like to move into the WPF world and ‘get more serious’ about interfaces, application programming and the like. your videos are extremely clear and easy to follow and really helps someone like me who is extremely visually oriented. Anyway, great job and like I said, please keep going!

  2. Scott,

    I want to thank you for putting these lessons together. I just finished your ebook version of “Learn C# By Building a Simple RPG”, or at least the first 18 lessons of it, and while you went into a lot of depth with your descriptions, hearing you talk about what you’re doing really helps to cement the ideas for me. I’m new to programming in general, so your lessons and the C# Yellow Book have been a huge help.

    Thank you again, I look forward to your next lesson.

    1. Thank you Kyle,

      I got busy during the holidays, but new lessons are on the way. I’m currently editing the second version of the next lesson (I didn’t like the first version), and should post it this weekend.

  3. I really loved your first series because it wasn’t all video. I learn a lot better when I read things – because they are easy to access later. Its so hard to find things later in a video. I realize it is probably a lot more work to write things out and you are kindly doing something for so many by teaching us coding in an interesting way. If you do decide to release transcripts I’m sure many will appreciate it.

    By the way, one thing that isn’t yet clear is the advantage of WPF/XAML, instead of Windows Forms. Could you enlighten us?

    1. Thanks for reminding me. Before the holidays, I started to search for a transcriber – but got busy with everything else. I’ll get back to finding someone.

      For WPF versus Windows Forms: It’s a little simpler to connect WPF to events (button clicks, text changed, etc.). But, the biggest advantage of WPF is that more people (and businesses) are using it to develop their programs. Most new projects I’ve seen over the last two years are in WPF. So, if you look for a C# programming job, you’ll probably need to know it.

    2. I would like to add that as I am currently learning WPF some of the advantages I’ve seen first is the flexibility of the new tools in VS 2015,next I would say designing the code logically in an XML format but more than anything the ability to embed controls within other controls so easily because they are designed to be this easy. In Winforms way way more difficult to achieve the same results. So you can really spice up your interfaces now quite easily.

      1. Another thing that would be very nice is to write C# code that outputs everything in HTML5 so it can be run through a browser – and then potentially become a multi-player game.

        What is the recommended way to take say WPF code and convert it so it runs as a web app?

        How about creating mobile phone apps using Xamarin to implement the RPG games?

        1. When the program has most of the basic features, I’ll show how to quickly attach different front-ends.

          Because we are using MVVM, it will be very simple to make the program work as a web program, as a console app, or any other type of user interface. If you haven’t already seen it in the previous course (building a similar game with a Windows Forms front-end), in Lesson 23.1, I show how to quickly create a console front-end for that game. That program did not have the ViewModel layer, so it wasn’t as simple as this one will be. However, it was still a relatively easy task.

  4. atm i try to change my views with the MVVM model
    i have a start screnn with change to the game screen however if have now to ViewModel folders one in the engine project and one in the WPFUI project.
    now my problem is i can change the view to the game screnn but now im stuck because im in the engine viewmodel folder is there a way to get back to the wpfui viewmodel or should i try it with a mvvm in only one project?

    1. I would keep all the ViewModels in the Engine project. This is not required. However, it will make several things easier – including automated tests, which we will add later.

      You could put the code to change to the different window in the XAML.CS, because that is functionality of the user interface (close this window, and display another window).

Leave a Reply

Your email address will not be published. Required fields are marked *