Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 20 Oct 2009
Offline Last Active Jun 04 2013 06:58 PM

Posts I've Made

In Topic: Dictionary of Dictionaries based on Type

03 June 2013 - 08:50 PM

What's your end goal exactly?



My hope is to be able to get objects doing something like
Texture2D texture = listOfObjects<Texture2D>("nameOfTexture");

SpriteFont font = listOfObjects<SpriteFont>("nameOfFont");

// etc. 


That's exactly what XNA's ContentManager does.


Texture2D texture = Content.Load<Texture2D>("nameOfTexture");

SpriteFont font = Content.Load<SpriteFont>("nameOfFont");


Why not just use that?


The ContentManager is used to Load objects, not get them once they've been loaded. I don't think I'd be creating new variables for each and every texture and so on. A Dictionary seems more appropriate.


As for the generic solution I was after, I've come up with this:


        Dictionary<Type, object> dict;

        public void Add<T>(string key, T value)
            Type type = typeof(T);
            bool dictContainsKey = dict.ContainsKey(type);

            if (!dictContainsKey)
                dict.Add(type, new Dictionary<string, T>());

            Dictionary<string, T> nestedDict = dict[type] as Dictionary<string, T>;

            if (nestedDict.ContainsKey(key))
                nestedDict[key] = value;
                nestedDict.Add(key, value);

        public T Get<T>(string key)
            Type type = typeof(T);
            bool dictContainsKey = dict.ContainsKey(type);

            if (!dictContainsKey)
                return default(T);

            Dictionary<string, T> nestedDict = dict[type] as Dictionary<string, T>;

            if (nestedDict.ContainsKey(key))
                return nestedDict[key];
                return default(T);

What are your thoughts - is this a bad / unnecessary implementation?


Admittedly it's a little messy, and probably unnecessary. For whatever reason I felt a single Dictionary with all assets is the way to go. My plan was to then write getters and setters and so on for accessing specific types, such as GetTexture(string key) { return // ... gets Texture2D from nested dictionary in dict }


Anyway, I guess having Dictionaries for each type seems to be a more suitable and cleaner solution.


Thanks everybody for your input.

In Topic: Dictionary of Dictionaries based on Type

03 June 2013 - 07:14 PM

My initial implementation is in fact having multiple dictionaries for each type, which is absolutely fine.


I suppose the reason I wanted it this way was so that the class could be generic enough to be used across projects.


If I required a dictionary of objects using a class that was specific to a particular game, such as a Level class, then the list would be generic enough for me to Add and Get levels, as opposed to adding a new dictionary for Levels which would be specific to a game project.


Does that make sense? 


Thank you for your response!

In Topic: Planescape: Torment - minus the D&D stuff

02 February 2012 - 04:46 AM

If you strip the combat out of Planescape then it would've become an Adventure Game. Which it could be argued that it would've been more appealing to a wider audience. However, Planescape did flop big-time when it was released, and one of the reasons could've been that the combat system (even though at the time, most RPGs had the same or very close combat system) was very bad.

Absolutely - it would have been an adventure game. And that's what everybody loves about the game; it's in-depth and ridiculously well written story. In other words, the adventuring portion (the greater portion).

I don't understand the love for Adventure Games (point-and-click ones), because everytime I try to make one it feels like I've stripped everything out of an actual video game and instead created a cartoon show. It's very unmotivating...

It's true with linear adventure games. You're just moving from one node to the next, solving arbitrary inventory puzzles. I dislike most that are structured this way.

The beauty of PS:T is it's non-linearity, and the stupendous amount of choice players have. The game often intellectually challenges in regards to knowing where to go, what people to go talk to, what places to look, who to probe for information, and what choices to make to turn a conversation to your favor.

With games such as this, the interactivity is *pivotal* to the experience.

With those that say that role playing games, or games in general *require* combat in order for it to *work* are severely limiting themselves with such narrow-mindedness. There are so many different ways games can offer challenges, or breathtaking experiences. It is by far not limited to combat.

The amount of combat in PS:T is still relatively very small, but yet it still *feels* padded out, only because of the clunky D&D mechanics, and in turn, feels less enjoyable. A different approach would likely have kept the level of immersion more consistent throughout the game. That is all I'm really saying.

In Topic: Planescape: Torment - minus the D&D stuff

30 January 2012 - 12:26 AM

There are certainly examples of RPG-style games without any combat--To the Moon being the most recent one, but also A Light's End on XBLIG, and...and...

OK, maybe there's not a lot of them, but it happens, sometimes. And it's awesome for players like me, who fit exactly into the mold you're talking about--I tend to play games because I want to get immersed in a story where it feels like I'm the star and I'm the director, not necessarily because I want to hit things with a sword. Not that I think combat is inherently bad--for me, personally, it just tends to be filler that gets in the way of what I'm most interested in.

You describe me exactly. It's not that combat itself is bad - and again, with our example here, I'm not saying that the narrative should have been altered not to include fighting. I'm just saying that sometimes, games like Heavy Rain - a game entirely focused on its story, and the way it tells it - doesn't need to have a combat engine like Tekken or Virtua Fighter, or give the player full FPS controls for segments involving shooting. The game Dreamfall: The Longest Journey suffered from using such contrived combat mechanics, and in my opinion alongside *many* others, so does Planescape: Torment.

Heavy Rain is an 8ish hour long adventure game. Imagine that length being padded out because of a complicated fighting engine with a steep learning curve. The player would be forced to master the mechanics well enough to progress through one or two tough battles that are setting them back, when all they really want is to save the damn kid and see how the mystery unfolds.

My argument isn't against combat, or D&D. I'm simply exploring the idea: would Planescape: Torment have been more *immersive* if it were stripped of its D&D mechanics? What are the alternatives? What alternatives do you think would have worked?

Thanks for everybody's input so far.

In Topic: c# generic xml serializer class that can serialize dictionaries

22 January 2012 - 02:32 PM

This probably belongs in the General Programming section - I've made this post in there instead. This thread can be removed.