<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Focused Games</title>
	<atom:link href="http://focusedgames.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://focusedgames.com</link>
	<description>Games, Articles and more...</description>
	<pubDate>Fri, 14 Aug 2009 14:09:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Update</title>
		<link>http://focusedgames.com/2009/08/14/update/</link>
		<comments>http://focusedgames.com/2009/08/14/update/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 14:09:29 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=116</guid>
		<description><![CDATA[As you have probably noticed, the site has been in disarray for quite some time now. The articles and projects have not been updated since Xna 3.0 and some even before that. Rest assured that I am working on a new release of the site and will update the current content in due time.
In the [...]]]></description>
			<content:encoded><![CDATA[<p>As you have probably noticed, the site has been in disarray for quite some time now. The articles and projects have not been updated since Xna 3.0 and some even before that. Rest assured that I am working on a new release of the site and will update the current content in due time.</p>
<p>In the meantime you can stay up-to-date with news related to me and Focused Games over at <a href="http://jsedlak.com">jsedlak.com</a>.</p>
<p>Thank you,<br/>John Sedlak</p>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2009/08/14/update/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Shot of the Day</title>
		<link>http://focusedgames.com/2008/12/15/shot-of-the-day/</link>
		<comments>http://focusedgames.com/2008/12/15/shot-of-the-day/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 06:33:52 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[FGF]]></category>

		<category><![CDATA[Games]]></category>

		<category><![CDATA[Windows]]></category>

		<category><![CDATA[Xbox 360]]></category>

		<category><![CDATA[Foxhorn]]></category>

		<category><![CDATA[Live]]></category>

		<category><![CDATA[Thrust]]></category>

		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=111</guid>
		<description><![CDATA[Yes, the console is back and will remain in some form or another. I have been working on integrating new features into FGF as school has started to wind down for the semester. The below shot is of the current build of Foxhorn which includes LAN and Live session creation, search and join through the [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, the console is back and will remain in some form or another. I have been working on integrating new features into FGF as school has started to wind down for the semester. The below shot is of the current build of Foxhorn which includes LAN and Live session creation, search and join through the console (The new build of the GUI library is not ready for testing yet).</p>
<p>Right now I am testing a few features being built into Thrust for the next release including the ability to log and share data between people playing a game on Live. The goal is to abstract the idea of a high scores sharing component to be able to share anything. The next release of Thrust will come with two things to share: high scores and error reports. While high scores will be a liberal thing to hand out, error reports will be setup in a client / server manner where only one server exists and is only connected to when a) it is up and running and b) the client wants to or can (ie the game detects he/she is idle in the menus).</p>
<div style="text-align:center;"><a href='http://focusedgames.com/wp-content/uploads/2008/12/foxhorn_001.jpg'><img src="http://focusedgames.com/wp-content/uploads/2008/12/foxhorn_001-300x175.jpg" alt="Foxhorn" title="Foxhorn" width="300" height="175" class="alignnone size-medium wp-image-112" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2008/12/15/shot-of-the-day/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Versionator Now Available For Vista</title>
		<link>http://focusedgames.com/2008/12/10/versionator-now-available-for-vista/</link>
		<comments>http://focusedgames.com/2008/12/10/versionator-now-available-for-vista/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 00:00:30 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[Applications]]></category>

		<category><![CDATA[Versionator]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=110</guid>
		<description><![CDATA[The first public release of the Versionator application is available today for Vista. I am unsure of how the program will run in XP right now because I am using a Glass Extender class to make the entire form glass. I am fairly certain this will result in a runtime error on XP, but have [...]]]></description>
			<content:encoded><![CDATA[<p>The first public release of the <a href="http://focusedgames.com/applications">Versionator</a> application is available today for Vista. I am unsure of how the program will run in XP right now because I am using a Glass Extender class to make the entire form glass. I am fairly certain this will result in a runtime error on XP, but have not tested yet. A second version for XP will be released soon if necessary. As usual I have included source code and install files for x86 and x64 machines.</p>
<ul>
<li><a href="http://focusedgames.com/wp-content/plugins/download-monitor/download.php?id=25" title="Version 1.1.0.0 downloaded 355 times" >Versionator Vista X64 Setup (355) - 731.74 KB</a></li>
<li><a href="http://focusedgames.com/wp-content/plugins/download-monitor/download.php?id=26" title="Version 1.1.0.0 downloaded 364 times" >Versionator Vista X86 Setup (364) - 731.7 KB</a></li>
<li><a href="http://focusedgames.com/wp-content/plugins/download-monitor/download.php?id=27" title="Version 1.1.0.0 downloaded 358 times" >Versionator Source (358) - 183.54 KB</a></li>
</ul>
<p><br/></p>
<div style="text-align:center;"><a href='http://focusedgames.com/images/screenshots/versionator/versionator_002.jpg'><img src="http://focusedgames.com/images/screenshots/versionator/versionator_002_400x259.jpg" alt="Versionator" title="Versionator" width="300" height="228" class="alignnone size-medium wp-image-98" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2008/12/10/versionator-now-available-for-vista/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Vodka Paper Available</title>
		<link>http://focusedgames.com/2008/12/08/vodka-paper-available/</link>
		<comments>http://focusedgames.com/2008/12/08/vodka-paper-available/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 16:42:09 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[FGF]]></category>

		<category><![CDATA[Vodka]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=108</guid>
		<description><![CDATA[While Vodka&#8217;s initial public release is still a few months away, my senior project related to it has been finished. A part of this project was writing the final paper on the project. The paper covers the design, implementation, problems and future of the Vodka project.
You can download the paper here: Vodka (Final Paper) (427) [...]]]></description>
			<content:encoded><![CDATA[<p>While Vodka&#8217;s initial public release is still a few months away, my senior project related to it has been finished. A part of this project was writing the final paper on the project. The paper covers the design, implementation, problems and future of the Vodka project.</p>
<p>You can download the paper here: <a href="http://focusedgames.com/wp-content/plugins/download-monitor/download.php?id=24" title="Version 1.0 downloaded 427 times" >Vodka (Final Paper) (427) - 742.94 KB</a></p>
<p>Vodka is a service based Content Management System / Platform designed with one thing in mind: make a powerful content system that is easy to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2008/12/08/vodka-paper-available/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bartender</title>
		<link>http://focusedgames.com/2008/12/04/bartender/</link>
		<comments>http://focusedgames.com/2008/12/04/bartender/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 02:29:00 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[FGF]]></category>

		<category><![CDATA[Bartender]]></category>

		<category><![CDATA[Vodka]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=107</guid>
		<description><![CDATA[Screenshot of the day: Bartender is an application I am writing to help manage data in Vodka based software. In the below screenshot I have successfully connected to my Vodka site and downloaded a piece of content. To do this, the application first authenticates a user and then sends off for the content. It is [...]]]></description>
			<content:encoded><![CDATA[<p>Screenshot of the day: Bartender is an application I am writing to help manage data in Vodka based software. In the below screenshot I have successfully connected to my Vodka site and downloaded a piece of content. To do this, the application first authenticates a user and then sends off for the content. It is important to note that the membership and content services are separate entities, but the content service relies on the membership service to verify a specific user has rights to do anything.</p>
<div style="text-align:center;"><a href="http://focusedgames.com/images/screenshots/bartender/bartender_001.jpg"><img src="http://focusedgames.com/images/screenshots/bartender/bartender_001_medium.jpg" alt="Bartender"></a></div>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2008/12/04/bartender/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Genetics for Games: Part 1</title>
		<link>http://focusedgames.com/2008/11/10/genetics-for-games-part-1/</link>
		<comments>http://focusedgames.com/2008/11/10/genetics-for-games-part-1/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 22:14:13 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[AI]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[XNA]]></category>

		<category><![CDATA[Genetics]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=103</guid>
		<description><![CDATA[One of the biggest features lacking in most small games and even larger games is some form of intelligent computer player. This article series is aimed to get you, the developer, to start thinking outside of the box when it comes to creating your game&#8217;s AI players. We will eventually be discussing what a genetic [...]]]></description>
			<content:encoded><![CDATA[<p>One of the biggest features lacking in most small games and even larger games is some form of intelligent computer player. This article series is aimed to get you, the developer, to start thinking outside of the box when it comes to creating your game&#8217;s AI players. We will eventually be discussing what a genetic algorithm is as well as neural networks but for now, we need to start with the basics.</p>
<p><span id="more-103"></span></p>
<p>One common misconception is that an AI character must be scripted, that they have to know what to do in every single case. While this is fantastic for those that know every possible case and want to know every possible outcome, it does nothing for emergent gameplay. Consider the possibilities if the AI didn&#8217;t know what they were doing the first time they did it. Hopefully you have arrived at the conclusion that an AI character starts to think and act like a human player with one giant flaw: the AI simply does not have the brain of a human. If you thought of this, you are right. However, what if we were to give the AI the ability to learn and thus be able to create a brain? Excited yet? Let&#8217;s start building us a framework.</p>
<div style="text-align:center;"><a name="figure1"> Figure 1: Creating the Solution</a><br />
<a href='http://focusedgames.com/wp-content/uploads/2008/11/genetics001.jpg'><img src="http://focusedgames.com/wp-content/uploads/2008/11/genetics001-300x215.jpg" alt="Creating the Solution" title="Creating the Solution" width="300" height="215" class="alignnone size-medium wp-image-104" /></a></div>
<p>To start us off I am going to create an empty solution in Visual Studio 2008 as shown in <a href="#figure1">Figure 1</a>. If you are unable to do this, create an Xna 3.0 Windows Game Library instead, calling it IntelligenceFramework. I start with an empty solution because it allows me to have more control over the projects created. The next step is just adding a Game Library called IntelligenceFramework. And to finish off with the creation stage, I will go ahead and remove the content project and the default Class1.cs file.</p>
<p>When we consider a human on a basic level, a conclusion can be drawn that humans can do a few generic things: use something, consume something, wear something, and release something. We can use these abstractions to create some interfaces. The first thing we will need is what represents the character, or human. For now, this IActor interface will have two methods with which we can add and remove objects that follow one of the above actions.</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('1038');">[<span id="1038_symbol">-</span>]</a></span><span class="codebox_left"><span id="l103code8"><a href="javascript:;" onclick="javascript:showCodeTxt('103code8'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="1038"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="103code8"><pre class="csharp"><span style="color: #0600FF;">namespace</span> IntelligenceFramework
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">interface</span> IActor
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">void</span> Add<span style="color: #000000;">&#40;</span>IUseable useable<span style="color: #000000;">&#41;</span>;
        <span style="color: #0600FF;">void</span> Remove<span style="color: #000000;">&#40;</span>IUseable useable<span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Clearly we need to create the IUseable interface now. This interface will serve as the basis for many other interfaces. We need to abstract all of them (IConsumable, IWearable, IReleaseable, et al) to a common level of functionality so the actor classes can deal with them in a single manor. The two operations needed are Deploy and Retract for the simple reason that the Actor class needs to be able to use (Deploy) the item and then [possibly] get rid of it (Retract).</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('1039');">[<span id="1039_symbol">-</span>]</a></span><span class="codebox_left"><span id="l103code9"><a href="javascript:;" onclick="javascript:showCodeTxt('103code9'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="1039"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="103code9"><pre class="csharp"><span style="color: #0600FF;">namespace</span> IntelligenceFramework
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">interface</span> IUseable
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">void</span> Deploy<span style="color: #000000;">&#40;</span>IActor actor<span style="color: #000000;">&#41;</span>;
        <span style="color: #0600FF;">void</span> Retract<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>This is probably getting more and more abstract and thus it is time to throw it into a real world situation! Let&#8217;s add a class to the project and call it Actor. The Actor class will implement that IActor interface we created before. If you are asking yourself why I have taken the route of using interfaces instead of just creating the Actor class itself, it is because I don&#8217;t want to limit users to my idea of how the implementation should be. For instance, you will see in the following code that I do not Deploy or Retract the item when it is added or removed. This is, of course, a possibility depending on what kind of IUseable classes you are creating.</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('10310');">[<span id="10310_symbol">-</span>]</a></span><span class="codebox_left"><span id="l103code10"><a href="javascript:;" onclick="javascript:showCodeTxt('103code10'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="10310"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="103code10"><pre class="csharp"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Actor <span style="color: #008000;">:</span> IActor
<span style="color: #000000;">&#123;</span>
    List<span style="color: #008000;">&lt;</span>IUseable<span style="color: #008000;">&gt;</span> inventory <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>IUseable<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Add<span style="color: #000000;">&#40;</span>IUseable useable<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>useable <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">return</span>;
&nbsp;
        <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>; i <span style="color: #008000;">&lt;</span> inventory.<span style="color: #0000FF;">Count</span>; i<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>inventory<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> <span style="color: #008000;">==</span> useable<span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">return</span>;
&nbsp;
        inventory.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>useable<span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Remove<span style="color: #000000;">&#40;</span>IUseable useable<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>useable <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">return</span>;
&nbsp;
        inventory.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span>useable<span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">protected</span> IUseable<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> Inventory <span style="color: #000000;">&#123;</span> get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> inventory.<span style="color: #0000FF;">ToArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Now that we have a base class, create a new project so we can test it out! I am going to create a Console Application and call it RpgDriver for reasons you will soon find out. I am using a Console Application so as not to overload you with other things that would have to be done. The point of this project is to test out our framework easily and quickly. After referencing the IntelligenceFramework project, add a class to RpgDriver called Character. The Character class will inherit Actor and implement some new functionality.</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('10311');">[<span id="10311_symbol">-</span>]</a></span><span class="codebox_left"><span id="l103code11"><a href="javascript:;" onclick="javascript:showCodeTxt('103code11'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="10311"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code" id="103code11"><pre class="csharp"><span style="color: #FF0000;">class</span> Character <span style="color: #008000;">:</span> Actor
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> Character<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Health <span style="color: #008000;">=</span> <span style="color: #FF0000;">25</span>;
        MaxHealth <span style="color: #008000;">=</span> <span style="color: #FF0000;">100</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Use<span style="color: #000000;">&#40;</span>Type typeOfUseable<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>; i <span style="color: #008000;">&lt;</span> Inventory.<span style="color: #0000FF;">Length</span>; i<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            IUseable item <span style="color: #008000;">=</span> Inventory<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>;
&nbsp;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>item.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">==</span> typeOfUseable<span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                item.<span style="color: #0000FF;">Deploy</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span><span style="color: #000000;">&#41;</span>;
                <span style="color: #0600FF;">break</span>;
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> Health <span style="color: #000000;">&#123;</span> get; set; <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> MaxHealth <span style="color: #000000;">&#123;</span> get; set; <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Here we are adding a function, named Use, that allows us to deploy a single instance of a certain type of item. We are also giving the character some health, however notice we are not filling the health to the max. The next step is to create our item: the health potion! Add a new class, called HealthPotion, to the project that implements the IUseable interface.</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('10312');">[<span id="10312_symbol">-</span>]</a></span><span class="codebox_left"><span id="l103code12"><a href="javascript:;" onclick="javascript:showCodeTxt('103code12'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="10312"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code" id="103code12"><pre class="csharp"><span style="color: #FF0000;">class</span> HealthPotion <span style="color: #008000;">:</span> IUseable
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Deploy<span style="color: #000000;">&#40;</span>IActor actor<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Actor <span style="color: #008000;">=</span> actor;
&nbsp;
        Character character <span style="color: #008000;">=</span> Actor <span style="color: #0600FF;">as</span> Character;
&nbsp;
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>character <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
&nbsp;
            character.<span style="color: #0000FF;">Health</span> <span style="color: #008000;">+=</span> <span style="color: #FF0000;">50</span>;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>character.<span style="color: #0000FF;">Health</span> <span style="color: #008000;">&gt;</span> character.<span style="color: #0000FF;">MaxHealth</span><span style="color: #000000;">&#41;</span> character.<span style="color: #0000FF;">Health</span> <span style="color: #008000;">=</span> character.<span style="color: #0000FF;">MaxHealth</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        Actor.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span><span style="color: #000000;">&#41;</span>;
        Retract<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Retract<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Actor <span style="color: #008000;">=</span> <span style="color: #0600FF;">null</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> IActor Actor <span style="color: #000000;">&#123;</span> get; set; <span style="color: #000000;">&#125;</span> 
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Fortunately the implementation is rather simple. On Deploy being called, the HealthPotion attempts to up the characters health by up to 50 points and then removes itself from the Actor&#8217;s inventory. The last thing to do with our test project is to write some test code! In Program.cs, type in the following:</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('10313');">[<span id="10313_symbol">-</span>]</a></span><span class="codebox_left"><span id="l103code13"><a href="javascript:;" onclick="javascript:showCodeTxt('103code13'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="10313"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="103code13"><pre class="csharp"><span style="color: #FF0000;">class</span> Program
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Character myChar <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Character<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
        myChar.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> HealthPotion<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
        myChar.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> HealthPotion<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
        myChar.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> HealthPotion<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
        myChar.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> HealthPotion<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
        Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;{0:000}/{1:000}&quot;</span>, myChar.<span style="color: #0000FF;">Health</span>, myChar.<span style="color: #0000FF;">MaxHealth</span><span style="color: #000000;">&#41;</span>;
&nbsp;
        myChar.<span style="color: #0000FF;">Use</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>HealthPotion<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
        Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;{0:000}/{1:000}&quot;</span>, myChar.<span style="color: #0000FF;">Health</span>, myChar.<span style="color: #0000FF;">MaxHealth</span><span style="color: #000000;">&#41;</span>;
&nbsp;
        myChar.<span style="color: #0000FF;">Use</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>HealthPotion<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
        Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;{0:000}/{1:000}&quot;</span>, myChar.<span style="color: #0000FF;">Health</span>, myChar.<span style="color: #0000FF;">MaxHealth</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Now run it! You will see the health of the character move up and hit a max of 100 as the inventory length drops as potions are used.</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('10314');">[<span id="10314_symbol">-</span>]</a></span><span class="codebox_left"><span id="l103code14"><a href="javascript:;" onclick="javascript:showCodeTxt('103code14'); return false;">View Code</a> HTML</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="10314"><td width="1%" class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="103code14"><pre>025/100
075/100
100/100
Press any key to continue . . .</pre></td></tr></table></div>

<p>What is important to take away from all of this is that the Actor and Character classes do not know what they are actually using. All they know is that they can use the item and it may or may not have an effect on their properties. In this case we added a simple HealthPotion class that ups the health of the Character class and used the item manually. In the next part of this series I will cover how we can extend the base interface[s] to allow a health potion to be automatically used as well as used in certain situations. Further down the line we will cover how we can use genetics to get an AI to pick up items, use them and learn whether they are good or bad for the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2008/11/10/genetics-for-games-part-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blur and Glow</title>
		<link>http://focusedgames.com/2008/11/03/blur-and-glow/</link>
		<comments>http://focusedgames.com/2008/11/03/blur-and-glow/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 21:39:42 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[XNA]]></category>

		<category><![CDATA[XNA;Blur;Glow;HLSL]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=100</guid>
		<description><![CDATA[Having trouble with your blurring and/or glowing? Well have I got a sample for you! The Blur and Glow Sample (2221) shows you how to do both with great results. An Xbox 360 version is included as well and the code is written for the XNA 3.0 Framework.


]]></description>
			<content:encoded><![CDATA[<p>Having trouble with your blurring and/or glowing? Well have I got a sample for you! The <a href="http://focusedgames.com/wp-content/plugins/download-monitor/download.php?id=23" title="Version 1.0.0.0 downloaded 2221 times" >Blur and Glow Sample (2221)</a> shows you how to do both with great results. An Xbox 360 version is included as well and the code is written for the XNA 3.0 Framework.</p>
<div style="text-align:center;"><a href='http://focusedgames.com/wp-content/uploads/2008/11/blur04.jpg'><img src="http://focusedgames.com/wp-content/uploads/2008/11/blur04-300x233.jpg" alt="Blur" title="Blur" width="300" height="233" class="alignnone size-medium wp-image-101" /></a></p>
<p><a href='http://focusedgames.com/wp-content/uploads/2008/11/blur05.jpg'><img src="http://focusedgames.com/wp-content/uploads/2008/11/blur05-300x233.jpg" alt="Blur and Glow" title="Blur and Glow" width="300" height="233" class="alignnone size-medium wp-image-102" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2008/11/03/blur-and-glow/feed/</wfw:commentRss>
		</item>
		<item>
		<title>May His Words Guide You</title>
		<link>http://focusedgames.com/2008/10/31/may-his-words-guide-you/</link>
		<comments>http://focusedgames.com/2008/10/31/may-his-words-guide-you/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 03:57:14 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Testing]]></category>

		<category><![CDATA[XBLCG]]></category>

		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=99</guid>
		<description><![CDATA[As you already know, XNA 3.0 is out and you can now start submitting games to XBLCG for real. Well Nick has made a fantastic post about a feature of the new Xna site. In the post, May The Playtest Be With You, Nick discusses the importance of not clogging the review pipeline with a [...]]]></description>
			<content:encoded><![CDATA[<p>As you already know, XNA 3.0 is out and you can now start submitting games to XBLCG for real. Well <a href="http://nickontech.com"><b>Nick</b></a> has made a fantastic post about a feature of the new Xna site. In the post, <a href="http://www.nickontech.com/2008/10/may-the-playtest-be-with-you/"><b><em>May The Playtest Be With You</em></b></a>, Nick discusses the importance of not clogging the review pipeline with a game that hasn&#8217;t been tested by others.</p>
<p>So if you are about to submit a game for review and have not had anyone look at it, be sure to use the playtest feature. If nothing else, give the game to a few friends to try out.</p>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2008/10/31/may-his-words-guide-you/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Features of FGF 1.3</title>
		<link>http://focusedgames.com/2008/10/17/features-of-fgf-13/</link>
		<comments>http://focusedgames.com/2008/10/17/features-of-fgf-13/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 08:45:21 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[FGF]]></category>

		<category><![CDATA[FGDN]]></category>

		<category><![CDATA[Galactic Wars]]></category>

		<category><![CDATA[Thrust]]></category>

		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=95</guid>
		<description><![CDATA[The Focused Games Framework is well on its way to hitting the next version. All libraries in FGF will be updated to reflect this new number (1.3) as it will be a major release. If you have any requests or bug reports, please get them to me as soon as possible. Many thanks to those [...]]]></description>
			<content:encoded><![CDATA[<p>The Focused Games Framework is well on its way to hitting the next version. All libraries in FGF will be updated to reflect this new number (1.3) as it will be a major release. If you have any requests or bug reports, please get them to me as soon as possible. Many thanks to those that have gone out of their way to really test the code. Here are a few things to look forward to in FGF 1.3 (and beyond):</p>
<ol>
<li><b>A License</b><br/>
<p>FGF will be released under an official license. The license will remain fairly loose with a few restrictions put on distribution. For example, you can redistribute the libraries with your game/software but cannot redistribute the libraries as a standalone piece of software.</p>
</li>
<li><b>Refined State Management</b><br/>
<p>A lot of work has been going into getting all the kinks out of the state system because it is a very large part of Thrust. I am streamlining the Load code to give the end-developer more control over what is happening. I will be releasing some samples that cover this system in detail as well.</p>
</li>
<li><b>Return of the Control</b><br/>
<p>I have made the decision to start going back to GUI Controls. Although menus have done me well in the past, controls will allow me to truely delegate responsibility. I will be including some basic controls that implement much of the same functionality you see in the GUI library today. The menu system will state in tact, but look for it to be removed in a later release.</p>
</li>
<li><b>Gamer Profiles</b><br/>
<p>I have spent some time learning about the gamer profile APIs and will be including some classes that help manage user specific data. This will include helper classes for gamer profiles, storage, signing users in and out, et cetera.</p>
</li>
<li><b>A Better XmlProvider</b><br/>
<p>One of the best unused features of FGF is the XmlProvider class. It is an incredibly powerful and useful Xml serializer / deserializer. I have rebuilt it from the ground up to be even better. Not only that, I have ported it to the Zune and Xbox 360 platforms.</p>
</li>
<li><b>Samples</b><br/>
<p>I understand that many developers need samples. If you haven&#8217;t yet, check out the currently <a href="http://jsedlak.homedns.org:6666/FGDN/fgf-samples"><b>available samples</b></a>. I will be adding to this list as time goes on.</p>
</li>
<li><b>Clear Error Messages</b><br/>
<p>One of the things I do worst is trap errors. It is a bad habit that I am attempting to change. Starting with Vodka, FGF will be getting clear cut exceptions, a numbering scheme and an online database of these errors with explanations and possible solutions. Check out <a href="http://jsedlak.homedns.org:6666/FGDN">FGDN</a> for more.</p>
</li>
<li><b>A Faster Framework</b><br/>
<p>Last but certainly not least, I have made great strides in the performance of some of the core components of Thrust. This is especially true on the Zune where garbage collections were causing a big problem. I have taken extensive looks at the memory useage and garbage generation on the Zune with Thrust and have solved many of the issues.</p>
</li>
</ol>
<p>If you are still with me, you are wondering what is bringing on most of these changes. As I gear up to release more games that are better (overall) and better suited for Xbox Live Community Games, I need to make sure that my core code works well. The biggest driving factor to most of the new changes is the newest version of Galactic Wars. The following <a href="http://videos.focusedgames.com/GW_101608.wmv"><b>video of Galactic Wars</b></a> shows the smooth transitions between different UI states. This build of the game is using a post 1.2 build of FGF which makes it a lot easier to support a lot of what you see. My favorite part is how easy it is to handle when all gamers have signed out.</p>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2008/10/17/features-of-fgf-13/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Closer Look at Profile Management</title>
		<link>http://focusedgames.com/2008/10/16/a-closer-look-at-profile-management/</link>
		<comments>http://focusedgames.com/2008/10/16/a-closer-look-at-profile-management/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 17:13:31 +0000</pubDate>
		<dc:creator>John Sedlak</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[XNA]]></category>

		<category><![CDATA[FGF]]></category>

		<category><![CDATA[Galactic Wars]]></category>

		<category><![CDATA[Profile Management]]></category>

		<category><![CDATA[Thrust]]></category>

		<guid isPermaLink="false">http://focusedgames.com/?p=94</guid>
		<description><![CDATA[Soon after making the decision to get started on Galactic Wars [3] 2.0, I ran into the problem of managing users and their profiles in a way that was not going to limit what I could do with the game. This article gives you a closer look at how I am handling users in the [...]]]></description>
			<content:encoded><![CDATA[<p>Soon after making the decision to get started on Galactic Wars [3] 2.0, I ran into the problem of managing users and their profiles in a way that was not going to limit what I could do with the game. This article gives you a closer look at how I am handling users in the game.<span id="more-94"></span></p>
<p>I have decided to model my system after Halo 3, making a few assumptions along the way:</p>
<ol>
<li><b>Abstract Game from Player Specifics</b><br/>
<p>By removing the use of any specific PlayerIndex in the code, I can build a game that supports any player on the system so long as they are signed in.</p>
</li>
<li><b>Force Sign-In</b><br/>
<p>I am only going to worry about players that are signed in to GamerServices (online or not). When a user signs off, the system makes sure it is not the last player. If it was the last player, it raises event with which I use to go back to the start screen.</p>
</li>
<li><b>One NetworkSession to Rule Them All</b><br/>
<p>By utilizing the built-in Network Session code, I will force all gameplay to go through a standardized lobby which will work for any type of gameplay whether it be campaign, local multiplayer, coop, deathmatch or whatever I decide to add to the game. This is very similar to Halo 3&#8217;s system and is done to ease the development of the UI code.</p>
</li>
</ol>
<p>Let&#8217;s take a look at the code. I first declare the class which includes a list of profiles, an event and two event handlers.</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('9419');">[<span id="9419_symbol">-</span>]</a></span><span class="codebox_left"><span id="l94code19"><a href="javascript:;" onclick="javascript:showCodeTxt('94code19'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="9419"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="94code19"><pre class="csharp"><span style="color: #0600FF;">using</span> Microsoft.<span style="color: #0000FF;">Xna</span>.<span style="color: #0000FF;">Framework</span>.<span style="color: #0000FF;">GamerServices</span>;
&nbsp;
<span style="color: #0600FF;">namespace</span> FocusedGames.<span style="color: #0000FF;">GalacticWars</span>.<span style="color: #0000FF;">Data</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #FF0000;">class</span> ProfileManager
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> List<span style="color: #008000;">&lt;</span>Profile<span style="color: #008000;">&gt;</span> activeProfiles <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>Profile<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">event</span> EventHandler LostAllGamers;
&nbsp;
        <span style="color: #0600FF;">public</span> ProfileManager<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            SignedInGamer.<span style="color: #0000FF;">SignedIn</span> <span style="color: #008000;">+=</span> OnGamerSignedIn;
            SignedInGamer.<span style="color: #0000FF;">SignedOut</span> <span style="color: #008000;">+=</span> OnGamerSignedOut;
        <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Next we need to handle when a gamer signs out. If the profile exists in our system, we need to remove them and make sure we still have gamers left.</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('9420');">[<span id="9420_symbol">-</span>]</a></span><span class="codebox_left"><span id="l94code20"><a href="javascript:;" onclick="javascript:showCodeTxt('94code20'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="9420"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="94code20"><pre class="csharp">        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">virtual</span> <span style="color: #0600FF;">void</span> OnGamerSignedOut<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, SignedOutEventArgs e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Profile usedProfile <span style="color: #008000;">=</span> GetProfile<span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Gamer</span><span style="color: #000000;">&#41;</span>;
&nbsp;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>usedProfile <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                activeProfiles.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span>usedProfile<span style="color: #000000;">&#41;</span>;
&nbsp;
                CheckForGamer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Similarly, when a gamer signs in we need to make sure that it isn&#8217;t already in the system for some reason. If it isn&#8217;t, we create / load it and add it.</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('9421');">[<span id="9421_symbol">-</span>]</a></span><span class="codebox_left"><span id="l94code21"><a href="javascript:;" onclick="javascript:showCodeTxt('94code21'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="9421"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="94code21"><pre class="csharp">        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">virtual</span> <span style="color: #0600FF;">void</span> OnGamerSignedIn<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, SignedInEventArgs e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Profile newProfile <span style="color: #008000;">=</span> GetProfile<span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Gamer</span><span style="color: #000000;">&#41;</span>;
&nbsp;
            <span style="color: #008080; font-style: italic;">// If the profile isn't in our system, we need</span>
            <span style="color: #008080; font-style: italic;">// to load it!</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>newProfile <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                newProfile <span style="color: #008000;">=</span> Profile.<span style="color: #0000FF;">FromGamer</span><span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Gamer</span><span style="color: #000000;">&#41;</span>;
&nbsp;
                <span style="color: #0600FF;">if</span><span style="color: #000000;">&#40;</span>newProfile <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                    activeProfiles.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>newProfile<span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Finally, the two helper methods:</p>

<div class="wp_codebox_msgheader"><span class="codebox_right"><a href="javascript:;" onclick="toggle_collapse('9422');">[<span id="9422_symbol">-</span>]</a></span><span class="codebox_left"><span id="l94code22"><a href="javascript:;" onclick="javascript:showCodeTxt('94code22'); return false;">View Code</a> CSHARP</span></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="9422"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="94code22"><pre class="csharp">        <span style="color: #0600FF;">public</span> Profile GetProfile<span style="color: #000000;">&#40;</span>SignedInGamer gamer<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>; i <span style="color: #008000;">&lt;</span> activeProfiles.<span style="color: #0000FF;">Count</span>; i<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>activeProfiles<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Gamer</span> <span style="color: #008000;">==</span> gamer<span style="color: #000000;">&#41;</span>
                    <span style="color: #0600FF;">return</span> activeProfiles<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>;
&nbsp;
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">null</span>;
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> CheckForGamer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// If no profiles are here, we need to </span>
            <span style="color: #008080; font-style: italic;">// grab one!</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>activeProfiles.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #008080; font-style: italic;">// Delegate the responsibility. Listener can move to a specific screen.</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>LostAllGamers <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span> LostAllGamers.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>, EventArgs.<span style="color: #0000FF;">Empty</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> Profile<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> ActiveProfiles <span style="color: #000000;">&#123;</span> get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> activeProfiles.<span style="color: #0000FF;">ToArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>On the next page we will cover exactly what the Profile class is and what it does!</p>
]]></content:encoded>
			<wfw:commentRss>http://focusedgames.com/2008/10/16/a-closer-look-at-profile-management/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
