Friday, April 11, 2014

Some Completed Projects 3/3 - Village Trader

Hello everyone!

This post is the third of three presenting information on a couple of projects I've completed in the last two weeks.

After I finished up with the resource buildings in UDK I decided to try a similar concept in C#. Since I couldn't think of another project to do in C#, I figured I'd give it a shot. I figured this would give me a chance to learn a few more controls from the Visual Studio Toolbox, like panels and a progress bar. I had also planned to learn how to use the Task Parallel Library to do multithreading for the resource gathering, but that ended up being way over-complicated, so I used timers instead(I would essentially be creating a timer with the new tasks) since they supported all the features I needed without a lot of work.

The game (besides being really boring) puts you as a trader who has contracts with several resource gatherers(Steel, Candles, and Wheat). You provide these gatherers with workers and you can collect any resources they gather. You can then sell these resources to establishments in the local community (Blacksmith, Cathedral, and Windmill respectively) for a profit. After a variable amount of time it displays how much gold you made and your average gold per second. You can choose between a 3, 5, or 10 minute duration. Here are screenshots of the game, and you can download it here:



The gold and average is different on this due to the
screenshot coming from a different round.


There is a lot of balancing that would need to go into this to be remotely entertaining, as well as some structural changes. Since this was a C# learning project, not a game development one, I chose to leave out a lot of the balancing in order to complete it faster.

I learned quite a bit from this project, which was good. I learned that working with panels to create a 'paged' WinForm is tedious, unless there is some way to hide the panels in the editor. I read about using a tab control to achieve a more designer friendly 'paged' window, but that came with its own set of issues. It seems to me that the panel method is difficult at design time, but nice at runtime, while the tabbed method is easy at design time and (potentially) difficult at runtime. I also learned more about timers and how to update a progress bar based upon how far along the timer is. I also worked with picture boxes, which I hadn't used before.

Another thing I learned was how to make a custom UserControl. I had made one previously for another small project, but I didn't add any custom events that could be called so interactions between the control and the main form were messy to say the least. On this project I actually took the time to learn how to add custom events properly.The control I made was essentially a numeric stepper(or a NumericUpDown in C#/Visual Studio). I decided on creating my own because I wanted specific methods to run when I either increased or decreased the value of the stepper. The default stepper only has a ValueChanged event so I would have had to save the old value to a variable the compare it to the new one and see if it increased or decreased. I also didn't want the user to be able to input their own number into the textbox, since this would be displaying the amount of workers assigned and I wanted all the numeric checks to run through my custom Increased/Decreased events. I also wanted the control to blend in with the background more, so by default it has a gray background.  Here is a comparison between my custom stepper and the NumericUpDown:




I think that about wraps up the little projects I've been working on recently. There have been tutorials, but nothing too spectacular.



Some Completed Projects Part 2/3 - Resource Buildings

Hello everyone!

This post is the second of three presenting information on a couple of projects I've completed in the last two weeks.

During a break from a C# tutorial I was playing a round on Stronghold Crusader and I was looking at the resource gathering buildings and thought, "Hmm, I wonder if I can make something like that..." I've been interested in attempting to make an RTS after Winds of Commerce, but I think I have a lot of learning to do. Anyway, I decided to let my mind drift away from C# and back into Unrealscript. I decided to try and make a stone mine that gathers up to three units of stone if there are enough workers to run the building. Here is a demo that I made for it:



I added in some rudimentary functionality to select different buildings. Ideally this would be done via a point and click mouse system, but that was not my primary focus for this project. It just uses a trace to see if the actor that was hit was a resource building, then assigns the hit building to the currentBuilding. If I were going to make an RTS this would only be a small part of the game, but it was fun to do. Learned some stuff about the trace function, and getting a specific instance of an object.

There are only a couple things I would like to add to the building. One is actual animations to show the stone being mined. Another is some indicator as to whether or not the building is fully staffed. Scaling the buildings up to the correct size would also be nice. The last thing I would probably do is add some sort of graphical interface to aid with all of the tasks.

Some Completed Projects Part 1/3 - Meal Generator

Hello everyone!

This post is the first of three presenting information on a couple of projects I've completed in the last two weeks.

Last week I finished up the meal generator I was talking about in this post.  You can download it here. Just unzip it and double click the MealGenerator.application.



It works pretty well, though after using it a bit I thought of some stuff that would make it more complete. Some things I would like to add:

  • Having the list 'print' to a rich text box that would allow the user to edit the list, or add stuff before it actually gets printed. 
  • A section for additional items that you need to get, since some things don't need to be bought every time(Bottle of Ketchup, Box of Rice, etc...). You would just put those down in this additional list if you knew you need to buy those items this trip.
  • Have all the windows display at the same place over the main window.
  • Add another list of sides
  • Better search functionality, so if there are several things that share the same name/type you can search through them. Currently it just selects the first one that meets the criteria.
  • Additional options for quantity on ingredients, i.e. 1/2 Cup
If I decide to do another version I'll add these features, but that will be much later.