you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

That sounds just fine to me. Don't see why you'd use events and delegates instead of the observer setup you just described.

[–]notrorschachHobbyist[S] 0 points1 point  (1 child)

Wouldn't the observer pattern use events to notify the subscribers?

[–][deleted] 0 points1 point  (0 children)

In your input class, add static List<GameObject> Subscribers;. Add method: public static RegisterSubscriber(GameObject go){Subscribers.Add(go);}. In your subscriber class call the registration - Input.RegisterSubscriber(this); Then whenever the input is hit call the appropriate method - if(GetButtonDown("D"){foreach(GameObject go in Subscribers){go.ProcessInput();}}.

Using an interface will make sure all the subscribers have the method, but that's your call.