XNA Game Development Forums
2012/05/21 20:28:50 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: extending ObjectManager?  (Read 2297 times)
Wally
Newbie
*
Offline Offline

Posts: 3


View Profile
« on: 2008/09/02 05:29:34 »

Hello,
First I want to say Hi everyone on the board, forum is awesome, tutorials are great. I managed to follow tutorials but i have a question regarding ObjectManager.
So i started to code some demo to test drive little engine, and got to a little problem. I changed type for storing objects from Collections to Dictionary, so i can get object from ObjectManager from object name, and that works fine.
But at some point i would like to iterate through every object in my ObjectManager and change some of object properties. Like shaders, putting flags or something.
Now im not sure what is the right way to do this, i doubt making whole Collection public is a good idea. Maybe to put all objects in LinkedList so i can return just first element, and cycle through rest. Anyway I need some advice on this matter.  Thanks in advance.
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #1 on: 2008/09/02 15:31:35 »

The Dictionary has a Values property that just returns a list of the actual objects in the collection. Why don't you make a get { return dictionary.Values; } or something similar?
Logged
solthar
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #2 on: 2008/09/03 20:55:05 »

Got me thinking on that, couldn't you just use a foreach to loop through it all?

eg;

Code:
using System.Collections.Generic;

//...

foreach (KeyValuePair<string, HMObject > pair in dictionaryName)
{
    //pair.Key returns string key value
    //pair.Value returns HMObject
}

Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #3 on: 2008/09/04 08:30:23 »

That's exactly what I meant

Code:
foreach(HMObject object in dictionary.Values){

}
Logged
Wally
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #4 on: 2008/09/04 11:18:20 »

Thank you guys, alot. You own Smiley
Logged
Wally
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #5 on: 2008/09/05 15:40:31 »

That's exactly what I meant

Code:
foreach(HMObject object in dictionary.Values){

}

Sorry for double post.Maybe I am missing something and sound ridiculus but i dont see a way going through HMObjects through dictionary because it a list od HMNodes that actually contains my object. I have objManager from Pdf tuts.So i came with this solution.

Code:
foreach(HMObjectNode  obNode in myChildren.Values )
              {
                 obNode.MyObject.Position = ........
             
              }

Since current implementation of manager dont have childs in HMObjectNode i think this would do..
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
extending the camera classes/cameramanager Hazy Mind XNA Engine Mikeske 7 2079 Last post 2009/12/16 01:46:28
by Mikeske
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.105 seconds with 19 queries.