Forum C# Accessing Broadcast,Players,etc outside of Game<> class

Accessing Broadcast,Players,etc outside of Game<> class

Postby wgfunstormcontest » November 28th, 2012, 9:42 pm

I have a class called Map, in Map.cs, separate from the Game class and Game.cs file.

I can't use Broadcast, Players, or any of the other PlayerIO methods/properties that are part of Game from there.

How can I use them? Do I have to pass a reference to my game class to every class I create that wants to use those?
wgfunstormcontest
 
Posts: 55
Joined: September 25th, 2012, 8:26 pm

Re: Accessing Broadcast,Players,etc outside of Game<> class

Postby dreamora » November 29th, 2012, 8:03 am

Yupp you need to pass the game class or the specific Player.IO class instances (like BigDB) around to the associated classes that need it because singleton patterns aren't possible in Player.IO in the traditional / standard way
dreamora
 
Posts: 225
Joined: March 2nd, 2012, 9:58 am

Re: Accessing Broadcast,Players,etc outside of Game<> class

Postby wgfunstormcontest » November 29th, 2012, 1:23 pm

So now each instance of my classes outside of my main game class has a reference to my Util, Globals, and Game class. If I add up all these references across all class instances that can exist during gameplay, it's starting to approach 100, and will probably continue to increase.

So apart from being annoying, is there any technical downside to having a lot of references? I don't know c# very well but I imagine it may just be a lot of pointers to my existing classes which should be fine... or am I totally misunderstanding it?
wgfunstormcontest
 
Posts: 55
Joined: September 25th, 2012, 8:26 pm

Re: Accessing Broadcast,Players,etc outside of Game<> class

Postby dreamora » November 29th, 2012, 2:56 pm

nope, no downside aside of a bit more ram usage for the references as you correctly assume.
dreamora
 
Posts: 225
Joined: March 2nd, 2012, 9:58 am


Return to C#



cron