Cameron Albert

Ramblings of software development, games and technology.

Archive for July 2007

C# Socket Server for Flash/ActionScript

After doing some research on available socket servers for Flash I decided to write my own in C#. Most of the server out there are written in Java and while there are some open source implementations I prefer to stick with a code base I know and understand.

I got the Flash movie to connect to the C# server yesterday using JSON protocal instead of XML as my transport mechanism. I used a .NET JSON library and an ActionScript 2.0 JSON library to build the objects on both sides. I created a C# class for passing data, serialize as a JSON string and send it the Flash movie. On the ActionScript side I created an AS class that mimics my C# data gram class and use the AS JSON lib to serialize and send that same object structure to the C# server. Working pretty good so far, I am able to login to the server and send and receive messages.

My next steps will be creating a basic flash game that I can use to run around and do battle while sending and receiving messages from the server. 

I have plans to make a Flash based PBBG with real time combat, we'll see how it goes. 🙂 

Written by Cameron

July 27, 2007 at 3:13 pm

Flash and PBBGs

I've been looking into Flash as a possible alternate UI for my PBBG Perenthia because of the benefits of being able to write a socket server that Flash can connect to and provide real time updates to players. The only way to accomplish this in a web scenario is to constantly poll the server for updates, rather than have them pushed to the client. I am trying to weigh the options and impact of this along with the UI beneifts Flash would deliver, such as animated characters, mobs, etc.

Written by Cameron

July 24, 2007 at 12:26 pm

Posted in Game Development

Knights of the Realm PBBG Update

I just released another update to the Knights of the Realm 2 PBBG. The update includes several bug fixes reported by the players as well as a few enhancements requested by the players.

The Knights of the Realm 2 PBBG is a combat oriented game where players compete against each other in nightly tournament events. The game is free and only requires a browser to play.

Written by Cameron

July 18, 2007 at 5:03 pm

Posted in Game Development

GridView Grouping and Summaries

If you are looking to group your grid view results and provide summaries such as totals, etc. I found a great utility for grouping GridView results. It is a set of classes that provide a helper for your grids to allow grouping. The component is super easy to use just remember that if you don't use a data source control you have to handle the GridView Sorting event. You don't actually have to have any code in the event handler, just handle the event.

Written by Cameron

July 18, 2007 at 1:49 pm

Perenthia Households

Over the next couple of days I will be implementing the household management screens into the main interface of my PBBG Perenthia. Players who create and manage a household will use these screens to add and edit ranks of advancement, set membership requirements, view active members and appoint household officers.

After the household screens are in place and tested I will implement the new tournament screen layouts which will allow players to participate in tournament events to increase their skills and fame.

Crafting is still bare bones and may be added during the beta, not sure yet how that will play out. Crafting will give players the ability to create items from core elements and other items. An example of crafting would be taking iron ore and using a forge to create a sword, maybe even wrap the hlt in leather. 

The adventuring aspect is more or less complete for the beta release and includes dynamically generated areas for players to roam around in complete with dynamic and randomly generated monsters. 

Skills will be the primary factors in all actions from adventuring to tournaments to crafting. The skills system is already in place but some hooks need to be added to the household interface to allow players to require certain levels of skills in order to advance within a household.

I am hoping these core elements will provide a flexible and fun playing environment for members. I have a large list of future enhancements and elements I removed from the alpha phase that could show themselves again, just not sure yet.

A new web site for Perenthia will go up when the game enters open beta so fi the site looks different when you visit again, be sure to sign up and play! 

Written by Cameron

July 17, 2007 at 10:44 pm

Posted in Game Development

X, Y, Z Coordinate Struct for .NET PBBGs

I created a struct in C# for storing the X, Y and Z coordinates for characters, objects and rooms within my current PBBG project Perenthia. The struct, called Vector, is serializable and can be used as the key value in a sorted or generic dictionary. Here is the code for the class.

[Serializable]
    public struct Vector : IEquatable<Vector>
    {
        public static readonly Vector Empty = new Vector(0, 0, 0);

        public Vector(int x, int y, int z)
        {
            _x = x;
            _y = y;
            _z = z;
        }

        public void SetLocation(int x, int y)
        {
            this.SetLocation(x, y, this.Z);
        }

        public void SetLocation(int x, int y, int z)
        {
            _x = x;
            _y = y;
            _z = z;
        }

        public Vector Copy()
        {
            return new Vector(this.X, this.Y, this.Z);
        }

        public static Vector FromString(string value)
        {
            if (!String.IsNullOrEmpty(value))
            {
                string[] parts = value.Split(',');
                if (parts != null && parts.Length == 3)
                {
                    int x, y, z;
                    if (Int32.TryParse(parts[0], out x))
                    {
                        if (Int32.TryParse(parts[1], out y))
                        {
                            if (Int32.TryParse(parts[2], out z))
                            {
                                return new Vector(x, y, z);
                            }
                        }
                    }
                }
            }
            return Vector.Empty;
        }

        #region GetHashCode
        public override int GetHashCode()
        {
            // The Y value should always come first in any kind of sorting, comparison or hashing operations
            // followed by X and then Z because typical loops would start with the Y value.
            return (this.Y.GetHashCode() + this.X.GetHashCode() + this.Z.GetHashCode());
        }
        #endregion

        #region Equals
        public bool Equals(Vector obj)
        {
            // The Y value should always come first in any kind of sorting, comparison or hashing operations
            // followed by X and then Z because typical loops would start with the Y value.
            if (obj != null)
            {
                if (obj.Y == this.Y)
                {
                    if (obj.X == this.X)
                    {
                        return (obj.Z == this.Z);
                    }
                }
            }
            return false;
        }

        public override bool Equals(object obj)
        {
            if (obj is Vector)
            {
                return this.Equals((Vector)obj);
            }
            return base.Equals(obj);
        }
        #endregion

        #region ToString
        public override string ToString()
        {
            return String.Format("{0},{1},{2}", _x, _y, _z);
        }
        public string ToString(bool forDisplay)
        {
            if (forDisplay)
            {
                return String.Format("X = {0}, Y = {1}, Z = {2}", _x, _y, _z);
            }
            return this.ToString();
        }
        #endregion

        #region Operators
        public static Vector operator +(Vector v1, Vector v2)
        {
            return new Vector(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
        }

        public static Vector operator -(Vector v1, Vector v2)
        {
            return new Vector(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
        }

        public static bool operator ==(Vector v1, Vector v2)
        {
            return v1.Equals(v2);
        }

        public static bool operator !=(Vector v1, Vector v2)
        {
            return (!v1.Equals(v2));
        }

        public static bool operator >=(Vector v1, Vector v2)
        {
            // The Y value should always come first in any kind of sorting, comparison or hashing operations
            // followed by X and then Z because typical loops would start with the Y value.
            if (v1.Y >= v2.Y)
            {
                if (v1.X >= v2.X)
                {
                    return (v1.Z >= v2.Z);
                }
            }
            return false;
        }

        public static bool operator <=(Vector v1, Vector v2)
        {
            // The Y value should always come first in any kind of sorting, comparison or hashing operations
            // followed by X and then Z because typical loops would start with the Y value.
            if (v1.Y <= v2.Y)
            {
                if (v1.X <= v2.X)
                {
                    return (v1.Z <= v2.Z);
                }
            }
            return false;
        }
        #endregion

        #region Properties
        private int _x;

        public int X
        {
            get { return _x; }
            set { _x = value; }
        }

        private int _y;

        public int Y
        {
            get { return _y; }
            set { _y = value; }
        }

        private int _z;

        public int Z
        {
            get { return _z; }
            set { _z = value; }
        }
        #endregion

        #region IEquatable<Vector> Members

        bool IEquatable<Vector>.Equals(Vector other)
        {
            return this.Equals(other);
        }

        #endregion
    }

Written by Cameron

July 16, 2007 at 3:18 pm

BlogEngine.NET

I have to say that BlogEngine.NET is a great blog utility. I was using .Text for a long time and just never wanted to go through the conversion to Community Server. I just did not need a community, I just wanted a blog. I reviewed a bunch of different blog engines out there and really liked all the features of BlogEngine.NET. If you are looking to setup a blog and want to have control over your data store using providers and have all the latest features like tagging, auto pings, etc. then snag BlogEngine.NET.

Written by Cameron

July 13, 2007 at 12:05 pm

Posted in General