Jump to content

  • Log In with Google      Sign In   
  • Create Account

IndyOfComo

Member Since 18 Jul 2012
Offline Last Active Today, 09:22 AM

Topics I've Started

List<MyParentClass>

04 December 2013 - 03:47 PM

Somewhere in stackoverflow I found a question similar to my situation, which was like finding a needle in a haystack. But I foolishly closed my browser before I was completely done with my coding.

 

Here's my goal....

 

class BasicComponent

{

     List<GroupIcon> icon;

}

 

class ItemGroup : BasicComponent

{

     icon.Add(new ItemIcon(seed));

}

 

class MonsterGroup : BasicComponent

{

     icon.Add(new MonsterIcon(seed));

}

 

class GroupIcon {}

class ItemIcon : GroupIcon {}

class MonsterIcon : GroupIcon {}

 

Using an interface for the icons worked great, until I needed additional methods for certain icons--not just different execution of the methods, but whole new methods. Since of course if the method wasn't defined in the interface the compiler couldn't find it, and I didn't want to add it to the interface and have to define it in all the other classes which didn't need it.

 

The answer I had found at stackoverflow was basically making my own List<> which only accepted certain types of objects. The code looked something like this:

class IconList<T> : List<Type>
        {
            public void Add(Type t)
            {
                if (!typeof(GroupIcon).IsAssignableFrom(t))
                {
                    throw new ArgumentException("Type must be IGroupIcon, or implement/inherit it.");
                }
                else
                {
                    base.Add(t);
                }
            }
        }

But this isn't really working for me yet, so I have something wrong. For instance, this accessor...

public GroupIcon SelectedIcon
        {
            get { return icons[selectedPointer]; }
        }

can't compile cause it's trying to convert Type into GroupIcon. And if I change it to Add(GroupIcon t) then IsAssignableFrom() isn't valid. (of course).

 

What'd I do wrong here?


Hours per week

18 November 2013 - 10:13 AM

I'm just interested in hearing how much time people put into their game development. If you like, please respond with an average weekly total in hours, and what's your level of experience. (Are you hobby programmer only, or professional as well? Is this your first or second game, or have you completed 10 games?)


In-game GUI...maybe?

25 September 2013 - 03:24 PM

This may just be a terminology issue for me...  My next task on our game is to make a screen where the player can see some information on units and do some manipulation if he wants. The various information should be grouped an arranged in an easy-to-understand and clear method. And that method will need a style which fits the game and isn't hard to read.

 

Now, I'm thinking there has to be library out there already for this kind of stuff.  It can't be as inflexible as making a separate png or jpg for each and every sub-window on the screen. Certainly there's a way to say this style(like a font), rectangle, in this dimensions. It's possibly simple, but even if it's not it is certainly frequently necessary. So I google for...GUI's? I'm not sure that's right, because when I do I get ugly office stuff like this (not.jpg), and not things like (yes1.jpg)(yes2.jpg).


Overwriting Equal() and get-hash funct. for HashTable

17 September 2013 - 02:10 PM

So the MSDN for HashTables says:

The objects used as keys by a Hashtable are required to override the Object.GetHashCode method (or the IHashCodeProviderinterface) and the Object.Equals method (or the IComparer interface).

 

 

However, is that really necessary for elemental data types? The example further down that page doesn't show any kind of overwriting for the string key.


Merge tools

06 September 2013 - 02:43 PM

What would folks suggest for a merge tool?

 

Our project is in C#(XNA). We're using Mercurial and interfacing with it via TortoiseHG. Occasionally I have a lot of work to do helping the merge tool make decisions, and even then sometimes I get it wrong. I know I have two tools at my disposal, though so far I have only used Kdiff3 (just trying to reduce time spent learning different interfaces).  Sometimes kdiff3 can't tell that my partner and I added things to the same spot and that we need both. (I haven't been able to find a "keep both" command during the merge process.)

 

Or maybe I'm just Doing It Wrong. But I'd like to hear thoughts on merge tools.


PARTNERS