First Week!

Standard

The first week, first impressions, first assignments, lots of lessons. A smooth transition to the work life, getting used to the project and the workflow… And I am excited to write what I’ve learned. 

My assignment is to get my hands dirty with the generators featured in the ProDnD app. Some maps in the app needed visual reworks (more playability, more visually appeal) and I learned a few things while I work on them..

-Extension Methods-

Extension methods are used for adding methods to the types that are created already, without modifying/recompiling the type.

This process is used with the basic map object in the generator code. Say, we need to define a new kind of filter type. Since we are dealing with procedurally generated maps, we use noises to manage the randomity, then apply filters to make it look better. And when we introduce a new filter we want to add it without touching to the Map class that we are going to use. With this tool, we can add this without a fuss.

First, we define a new class for the filter. Then we define the new method to be added.


public static class FilterNoise {

     public static void FilterNoise(this Map map)

     {

        //do stuff. . .
     }

}

You should define a static class and static methods. Also, should use “this” keyword in the parameter field. It tells the compiler that it is an extension method for the Map class.

Screenshot_1

And ta-dah! You can call the method like this:

map.FilterNoise();

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s