Simple Achievement System in C#


Achievements are becoming more and more usual in games. They provide the player a sense of accomplishment and progress by rewarding them with badges that proves their skill and experience. Some achievements are simple and other require a combination of particular actions to unlock. In this article I show you how to make a simple Achievement System using C# and will demonstrate it using Unity3D, but this should be easy enough for you to port it to whatever language you’re more familiar with for your games.

Continue reading

Non Blocking C# Task Cancelling


In our previous sample snippet, Cancel a Loop in a Task with CancellationTokens in c# , I try to explain how we can get out of a looping c# task, but a problem may arise from that situation. If we were to wait for any result out of that Task, we would be blocking the calling thread until the task returned, which is not good if we are on the main thread. We would locking our UI and might crash our application.

So I’ve been testing different ways to get out of that loop without causing any trouble, and you can achieve what we want many different ways.

So, to begin with, I think I would correctly assume that it is only necessary to wait for a task to complete if that task will return something. If there is no return value, why would we want to call wait on it? We can just break out of it, correct me if I’m wrong. If we have a return value, then it is necessary to surround the wait call on the task with try/catch to receive its result. But then again, we can avoid the locking here with a continuation task, which will create and start the task after the first one completes, giving us the result from the previous task to work with.

Continue reading

Measure Method Time Performance


Quick snippet to let you check the time used by any method you have.

This will write to the console the time spent on the method.

Just remember to use System.Diagnostics.
More info on Stopwatch.

That’s it. Enjoy.

Cancel a Loop in a Task with CancellationTokens in C#


This post explains the use of Cancellation Token in C# using Tasks, which are available since .Net Framework 4.

Say you’ve created a asynchronous Task. The method you’re running inside your task contains a loop ( infinite or not ), and you want to break out of it peacefully. You would need to create a CancellationTokenSource and pass a Cancellation Token to the Task so it can be accessed in the main loop. Continue reading

October Challenge.. Again!


Last year I posted quite enthusiastly that I was going to participate in Ludum Dare’s october challenge, which is “Finish a game — Take it to market — Earn $1”.

Back when I posted that, I had just found was Unity3D was and was amazed of how quickly I could do game prototypes. As you may know, I’m developing Memtiles and although I would love to say that I’m really in this year, it might be complicated. Anyway, Ludum Dare’s October Challenge is up again, so go for it!

I’ve aimed the end of the month to release the game. If everything goes according to plan, I’m going to have all the artwork ready, music, and gameplay. Then I release it, and make a marketing plan to advertise it. So I might not be making my first $1 this month, but hey, at least I’ll be finishing my first game 🙂

PS: As soon as I have the final artwork, I’ll post some more screenshots. 🙂 I can already say that the games looks nothing like the Beta version. 🙂 Its much, much better 🙂

Memtiles is almost done


After nearly a month after the beta release of Memtiles, I’m nearly in the end of development. I’ve basically being updating and creating new assets, textures, checking for sound effects, hiring for music composition and graphics. So it has been pretty busy. Mainly because I’m working part-time on this project, only when I come home from work, and on weekends.

Today I lost all connections to my assets, prefabs, textures, everything.. I don’t know what happened to Unity3D, but that sure as hell cost me 3 hours rebuilding all prefabs. I guess I should back my things before opening a new branch.. or check what to ignore on bitbucket.. Anyway, I have my prefabs back.

Screen Shot 2013-09-21 at 1.35.38 AM

So now I can actually focus on progressing in the development. I still have game art and sound/music coming up.

Hopefully I will still release this by mid/end october.

Memtiles for Android in Beta Phase



So I’m making a casual memory game for mobile platforms. Its a simple educational puzzle, where you need to retrieve the tile pairs on the grid.

There is currently only one mode and one theme, but more will be added this month. There will be 3 more themes and a new game mode (maybe). There is also the educational part to do 🙂

You can play it online in your browser at and also download the latest apk version for Android, from 2.3.1 to 4.x.

Please report any bug you might find, as well as suggestions. 🙂


Generic Method


I’ve come up with a pretty neat solution to this:
If you don’t want to write the same method for different data types, you can use generics.

It’s pretty easy once you know what to look for 🙂 Just search Generics c# and you’ll find a bunch of questions and answers on StackOverflow, msdn and CodeProject 🙂
Here’s the solution:

Pretty Cool eh!? 🙂

Now instead of having multiple methods to make the same operation, you have one that works for many types.