GameController, HudController, MenuController.

Hey guys, I wanted your opinion on this.

I’m refactoring my code right now, and here is how it is structured:

GameController calls HudController, which tells MenuController to draw things.

I’m trying to get rid of HudController since the only reason why it ever existed was to shield my graphics artist from tampering with most of the code I was writing. I don’t feel it is necessary to do this now with the new object oriented code I have written.

So my question is, is it better to have MenuController know about everything (such as PlayerController) and determine what to draw based on their respective values, or is it better to have PlayerController inform MenuController what their states are?

class Menu extends MonoBehaviour
{
  var player : PlayerController;
  function OnGUI ()
  {
    if (player.IsSelectingWeapon())
    {
      DrawSelectingWeapon();
    }
  }
}

In this example, MenuController will have a reference to a bunch of different classes.

Or more like this…

class PlayerController extends MonoBehaviour
{
  function OnGUI ()
  {
    if (SelectingWeapon())
    {
       menuController.DrawSelectingWeapon();
    }
  }
}
In this example, all of my classes will have a reference to MenuController.

I'm just not sure which one to do-- in the above example, I maximize portability on a bunch of classes, but on the bottom half, I maximize portability on my MenuController. I'm just not sure how to approach it.

Thanks,
-Rob

Solved:

I subclassed the section of the menu which was application specific, and I call out to the parts that I need.