This observer pattern seems really great and I think that it is going to make my simulation a lot better when it gets implemented, but that is easier said than done. What I am planning on is having each player be an observer of each other when they are within a certain distance. So there is going to be a (possibly array) list of all player locations. The program will keep running calculation of how far each player is from each other. When players are within X units away from each other they will add to the observers list. Then the players will get the faction of the other and if they are enemies, they will attack if the other player is within Y units and their state is 'Capturing'. I'm not quite sure what I'm doing wrong, but I think my problem is with the update() method in side the observers. Maybe that is the issue. Here is a question to the readers: When the update takes place in this pattern, who calls in and how is that sent to the observer?
No comments:
Post a Comment