Post Hurricane

It’s been a long while since I’ve updated. Hurricane Sandy came by and really did a number on the area that I live in. Even with that in mind, I have so many fortunate circumstances that while there were a lot of delays, my family and I are safe.

So first update is that Unity 4.0 is officially out. Oddly I had to make a few tweaks before everything would work as it did previously. I’m not 100% sure this build will work as it requires a new web player plug-in and I don’t have my laptop next to validate. However, it’s a bit late for my old geezery self, so I’ll check tomorrow.

The build on the phone is still slightly disappointing as the load times on it are longer than 15-20 seconds.

Regardless, I hope that I can get some stream back into getting my first shooter out there.

Slimming down and navigating around

So, I effectively removed about a meg of junk that was in a bunch of the tutorial code and I also wrote some code to gracefully quit the game. I also refactored the main level base class to be more scriptable. The game seems to take more than 20 seconds to load a level for the first time on my Galaxy Nexus and I have a feeling it’s due to the mono CLR spinning up. I wasted a good deal of code trying to provide more feedback to the user as they would wait forever for the game to load, but I realize. It’s back on to some content.

RTFM

Well, I was playing around with loading various resources through code instead of having a funky static class factory that held pre-instantiated objects… This did not bode well.

http://docs.unity3d.com/Documentation/ScriptReference/Resources.LoadAssetAtPath.html

As soon as I attempted to launch it from the web player, nothing was working correctly. Apparently had I just read this documentation ahead of time.

Thus, I’ll will experiment with more.

Doing a little bit of googling, I’ll need to refactor to use this method instead

http://docs.unity3d.com/Documentation/ScriptReference/Resources.Load.html

Update — Unity truly is awesome, I think I spent about 5 minutes moving files around and everything is up and running!

More Ion cannon tweaking!

So I also spend a good portion of tonight messing with WordPress, but I did make a few tweaks to the ion cannon. It doesn’t spam out as much combat text, the damage is tweaked to be slightly higher than the spray gun.

I want to work a little on the story engine next and then a few modes for navigating through levels. Until then, I sleep!

WPF notify helper – C# 5.0

So after looking at the documentation on what’s new in C# 5.0, I read about the feature that you can get a function’s caller information that looks like the following.

public void DoProcessing()
{
    TraceMessage("Something happened.");
}
 
public void TraceMessage(string message,
        [CallerMemberName] string memberName = "",
        [CallerFilePath] string sourceFilePath = "",
        [CallerLineNumber] int sourceLineNumber = 0)
{
    Trace.WriteLine("message: " + message);
    Trace.WriteLine("member name: " + memberName);
    Trace.WriteLine("source file path: " + sourceFilePath);
    Trace.WriteLine("source line number: " + sourceLineNumber);
}

This snippet is stolen straight from msdn.
http://msdn.microsoft.com/en-us/library/hh534540(v=vs.110).aspx

I also saw another example of where this would be used for WPF classes that implement INotifyPropertyChanged. The example looked liked the following

protected void RaisePropertyChanged([CallerMemberName] string memberName = "")
{
    RaisePropertyChanged(memberName);
}

This actually reminded me of what I did in some of my WCF services to get the calling method name displayed when invoked, so that I could print out who called it(using WindowsIdentity) and what method they called. However, I accomplished it using the StackTrace class and StackFrame. So I quickly came with a way to get similar functionality until 5.0 is ready for my eager hands.

The result looks like the following

protected void RaisePropertyChanged()
{
    var frame = new StackTrace().GetFrame(1);
    string name = frame.GetMethod().Name.Substring(4);
    RaisePropertyChanged(name);
}

So when you create your Bindable properties you could simplify code that would look like

public const straing ProgressValuePropertyName = "ProgressValue";
private double _progressValue;
public double ProgressValue
{
    get { return _progressValue; }
    set { _progressValue = value; RaisePropertyChanged(ProgressValuePropertyName); }
}

into

private double _progressValue;
public double ProgressValue
{
    get { return _progressValue; }
    set { _progressValue = value; RaisePropertyChanged(); }
}

So while this is a small step forward, it’s still nowhere nearly as clean as using PostSharp and AOP to look like

[RaisePropertyChanged]
public double ProgressValue { get; set; }

Thinking about my brain dump right now, I’m going to play with the Roslyn services to see if that is going to generally offer the same capabilities as PostSharp.

Game scripting engine

So I’m starting to get back into the groove of coding my game and I’m at somewhat of a roadblock on how much I should make scriptable.

So for a brain dump, I’ll state what am I looking for right now?

Dialog sequencing
Entity administration(adding/removing/altering)
Triggering other sequences
I’m wanting at least these features so at any given level I can do the following.

Tell a story as the level begins
Add stuff to kill
Do something if you die
Do something when the boss dies
Perhaps this is too much and should be hard coded in the game for a unique kind of boss mob. Not sure, but I feel that’s restrictive. I’ll start with the goal of these things now using some sort of xml scripting syntax.

I thought about using Lua or JS, but I just can’t imagine that it would be easier using that than some fixed rule system. So homegrown ScriptML it is.

Suggestions welcome!