开发者

How I create an event that will send for each registered different values

I am developing a card game. In the start of the game each player gets five cards. I开发者_JS百科 want to create an event that each on of the players will register to it. The event will be activated in the start of the game from a class called controller (the class who manage the game). I want that this event will call the RecieveCards(CardList) of each player.

Each player should get diffrent cards...

The second option, and the simple one (without event), is to create a loop in the controller class that will run on all the players and for each player will call the ReciveCards(CardList).

I think that the first soultion is much more elegant, but I don't know how it is possible that it will send diffrent cards for each player it .. is there any pattern for it?

Edit: sorry, C# 3.0


You can use Observer Pattern to notify the prayers about the start of the game or you can use event approach. In this case when the event in raised a player should ask for his set of cards.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜