Performing an Ad-Hoc Distribution Build with Unity iPhone

Posted in: C#,Game Development,iPhone SDK |

To make an Ad Hoc distribution build to send out to your beta testers, you first have to create the Mobile Provision Profile on the Program Portal.  Once you’ve created this profile, downloaded and installed it according to Apple’s directions, your ready to begin.

Launch Unity iPhone and open the project you wish to build.  Make sure that under Edit->Project Settings->Player the iPhone Bundle Identifier matches the App ID identifier in your profile (if your profile is something like SAD723.*, you may enter any “com.yourdomain.AppName” combination).  Now, set your stripping level and Script Call Optimizations as necessary.

Goto File->Build Settings, setup your build as you normally would for Desktop or Web distribution.  Select ‘Compress Textures’ and ‘Strip Debug Symbols’ (these are really not needed on the device, and only useful if you know what your doing).  Select the ‘Build’ option, not the ‘Build & Run’ option.

Once your XCode Project is available to select in Finder, replace the Icon.png with the icon you wish to use for your application.  The icon must be a 57×57 PNG image.  Optionally, you can select the appropriate Default.png by changing the name of one of the predefined splash images (required for iPhone Basic) or, alternatively using your own (iPhone Advaced required for custom splash).

Once you have done this, go ahead and open the XCode Project.  Under Project->Edit Project Settings, select the appropriate “iPhone Distribution: Company Name” code signing certificate under “Coding Signing Identity”.  Double click in the “Code Signing Entitlements” just above that and enter the value “Entitlements.plist”.

Now, close the project settings and right click on the project in the left pane.  Select Add->New File.  Under “Code Signing” select “Entitlements”.  Name the file “Entitlements.plist” (the same as you entered above).  Once the file is created, open the file with the Property List Editor and uncheck the “get-tasks-allow” option.

Now make sure that the drop-down on the top-left of the project window says “Device – 2.1 | Release”.

You are now ready to build, so let’s do that now by selecting Build->Build.  Do -not- “Build and Go”.

Once your project is built, drill-down into the Products folder of your XCode Project and right click on the “.app” file that is there.  It should be named the same as the last part of your Bundle Identifier (“com.yourcompany.YourAppName” – ie; “YourAppName”).  Right click this file and say “Reveal in Finder”.  Drag the “.app” file onto your desktop, and copy over the “.mobileprovision” file you downloaded to create this build.  Select both, and right click and tell Finder to compress them.

You may now distribute this archive to your beta testers for review.

Where I spend my day …

my desk, where I spend all my time.

my desk, where I spend all my time.

XNA Code Generator for Tile Studio 2.55

Posted in: C#,Game Development |

Playing with XNA yesterday made me wonder how easy it would be to build a Tile based game, such as a 2D 'walk around' adventure game (ie; Zelda, or the likes). I downloaded a copy of Tile Studio 2.55 not too long ago and have been staring at it's icon on my desktop for quite some time now.

It came 'out of the box' with a handful of nice code generators, and it even included a .NET code generator ... but it only supported the BooGame library, and generated Boo code.

So, I thought to myself, why not look for an XNA Exporter ... so I loaded up the Tile Studio website, and found nothing there. I googled briefly and found nothing as well. So, I started on a little code adventure and decided to build my own. Now, keep in mind, I'm by no means an XNA Expert so my method for creating the tile map in C# may or may not be 'the best' or even 'proper'. However, the map works ... and I'm happy. I started on the project around 10:20am and am now writing this post at 11:50am ... so, it wasn't "too hard" and didn't take too much time. The time spent also included learning the Tile Studio Definition language and how it worked as well.

So, onto some 'proof', here's a few screenshots:

Tile Studio Map

This is Tile Studio, with my little map loaded up
--the Map is 100x100, and the Tiles are 20x20.

Visual Studio Project Files

Here is my Visual Studio project, after performing a code generation
in Tile Studio and refreshing the project directory and including the files.

XNA Game with Tile Studio Generated Map

And, here is my Map rendering to an XNA Game Window.

Now, in the project files shot you might notice that there are three files highlighted. The first is the exported Tile Map file from Tile Studio, the second is the actual Map definition (Tile2.cs) and the third is a helper class I wrote that is automatically exported for you that contains the MapDefinition and Tile classes.

And, here's the best part, your not gonna believe it ... or maybe you will. To load the map up, you simply do:

C#:
  1. //In Class scope
  2. WatrRoad map;

C#:
  1. // in LoadContent
  2. map = new WatrRoad(Content.Load<Texture2D>("WatrRoad"));

C#:
  1. // in Draw
  2. map.Draw(spriteBatch);

And that's it ... the MapDefinition provides a 'Draw' method to loop through all the tiles and render them to the screen. I've not yet optimized this to store a cached copy, but I also haven't tested it with any real 'logic' yet to try building a game. You can download a copy of the XNA C# Tile Studio Definition file from here, expect updates in the future to support more of Tile Studio's feature set.

Download the Definition File Here

Download the Full Example Project Here

Currently Supported Features:

  • Export Tile Sets to BMP and place in 'Content' sub-directory
  • Export CS File containing all Maps
  • Export TileStudioMap.cs containing MapDefinition and Tile helper classes
  • Easy Map instantiation, just pass a reference to the Map's Texture2D containing the Tiles
  • Easy Map Rendering, just call the Map's "Draw" method and pass the SpriteBatch

Evil Clutches ala XNA, My First XNA Game

Posted in: C#,Game Development |

I was speaking with a co-worker last night, and we got into the topic of game development and XNA.  As usual, I took the topic and went a little overboard and decided to install XNA at home and 'go at it'.  Since I recently finished the 'Evil Clutches' chapter from Game Makers' Apprentice and, also released the 'Evil Clutches Javascript' version; I decided to attempt making Evil Clutches in XNA.  It was a fairly straight forward process, and required almost no reading on my part.  I was able to install XNA, Launch Visual Studio 2005 and create a new project and just 'begin'.

I was actually very impressed with how simple it was to build the game, so much so that I referred to it as 'childs play' to my co-worker just after finishing up the Alpha. With that said, here's the basic process I went through;

  1. Step 1: Launch Visual Studio 2005 and create a new Windows Game
  2. Add my Art resources to the Games' Content
  3. Create a GameObject base class to store common information (Position, Texture, Color, Collision Detection, etc).
  4. Create object classes for my Dragon, Boss, Fireball, Demon and Baby objects.
  5. Apply basic 'render' logic to the 'Draw' method of my Game class
  6. Apply basic 'call object Update' logic to my Update
  7. Create the necessary 'Update' methods on my object classes
  8. Revisit the Game's Update method and apply basic Input logic (Escape to Exit, Up/Down to move Dragon, Space to Shoot)
  9. Add a SpriteFont and add logic to print the score on the screen
  10. Package it up and Write this blog post.

It really was that simple, and the entire process took me less then two hours.  Seriously, I banged the whole thing out just by looking up the 'How To' references on MSDN. Now, of course, as with everything in software development the 'easy ten step process' I listed above had lots of little 'inbetweens' (actual logic, etc).

You can download the 1.0.0.0-alpha release of my 'Evil Clutches XNA'.  If there's an interest in XNA Game Development tutorials, then I might write up a 'The Making of Evil Clutches for XNA' post, so let me know in the comments if your interested in that sort of things.

JsonViewEngine for ASP.NET MVC Framework

Posted in: C# |

I am currently tasked with a project at work that, after building out the design documents, was going to rely on ASP.NET MVC and at the same time take advantage of the URL Rewriting that comes with it 'out of the box' for 'data source urls' for AJAX requests. We decided to use the jQuery library, and the $.getJSON() function within it to request for JSON data.

Well, if you've played with ASP.NET MVC, you've probably noticed that it doesn't have any 'quick and simple' "json serialization in a view" ... or, does it?

I recently saw Scott Guthrie at a local .NET User Group event, and he mentioned that the ASP.NET MVC Framework was completely "pluggable", and you could easily replace the built-in View Engine. So, I immediately searched for examples, found one ... tossed it out and whipped together a really quick and simple 'JsonViewEngine' class.

Here's the code:


C#:
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics.CodeAnalysis;
  5. using System.IO;
  6. using System.Security.Permissions;
  7. using System.Web;
  8. using System.Web.Script.Serialization;
  9. using System.Web.UI;
  10. using System.Web.Mvc;
  11.  
  12.  
  13. namespace Sim.Microsite.Framework.Web.Mvc.JsonViewEngine
  14. {
  15.     [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  16.     [AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  17.     public class JsonViewEngine: IViewEngine
  18.     {
  19.         #region IViewEngine Members
  20.         public void RenderView(ViewContext viewContext)
  21.         {
  22.             if (viewContext == null)
  23.             {
  24.                 throw new ArgumentNullException("viewContext");
  25.             }
  26.            
  27.             viewContext.HttpContext.Response.Clear();
  28.             viewContext.HttpContext.Response.ContentType = "application/json";
  29.  
  30.             System.Text.StringBuilder jsonText = new System.Text.StringBuilder();
  31.             JsonFx.Json.JsonWriter jsonWriter = new JsonFx.Json.JsonWriter(jsonText);
  32.             jsonWriter.Write(viewContext.ViewData);
  33.  
  34.             viewContext.HttpContext.Response.Write( jsonText.ToString() );
  35.         }
  36.         #endregion
  37.     }
  38. }

As you may or may not be able to tell, I am using the JsonFx serializer for this project, but you could easily replace that with the built-in System.Web.Script.Serialization.JavaScriptSerializer or any other library of your choice.

After building this, I also decided to take it and create an XmlViewEngine that simply returns XML data, as we have some use for that as well with this project ... I'll leave you to implement that on your own, it's basically the same code ... just uses XmlSerializer instead -- however, I wrote some custom code for serializing the IDictionary that the default ViewPage uses for ViewData (even though ViewData is defined as an object in the viewContext ... ViewPage defines it as generic dictionary).

So ... have fun with that.

TGB Resource Maker

Posted in: C#,Game Development |

During the design and general work flow of the Urban Platform Kit, I've decided that it would be within my best interests to create a "Resource Maker" application for the Torque Game Builder.

What does this mean? Well, it means my task list just grew quite a bit, and I added a new project onto my "pending" list.

I am not sure what the overall outcome of this project will be -- but I do know that i will be using it to create the resourceDatabase.cs for the Urban Platform Kit -- LOTS of graphics, and hand editting that file is not the funnest thing in the world -- some added items I'll be adding to the project for simplicity is the ability to take a number of PNG's and tile them into a single PNG (including transparencies) so I don't have to keep creating the 'sheets' when steve hands me new or updated art work (what a pain that is ... Wow!)

LinkShare  Referral  Prg - default banner