Saturday, October 15, 2011

Warping works

Map warps work now.

I created a MapFactory class, which creates the map layouts. Later this class will provide both maps loaded from files and autogenerated maps, but currently it has two methods makeBrownMap and makeGreenMap, which return hardcoded map layouts made entirely of dirt and grass tiles. These maps also come with a warp to the center of the other map visually indicated by tiles of the other type.

The warp areas themselves are handled by a new map instance controller, the WarpController, which receives InterMessagePositionChange messages from the MapObjectManager whenever it changes the position of an object. The WarpController then checks if it's inside one of its warps, and when it does, it dispatches a InterMessageCharacterMapChange message. The MapInstance has subscribed to this message on the local dispatcher of each map and can thus initiate the transfer from the old to the new map instance.

So what's next for this milestone? Ah, local chatting. That one is interesting, because I want chat messages to go only to those nearby and not to everyone on the same map. That means I can not just use the local dispatcher. This concept of area-confined messages might also be interesting for object movement information, because informing the clients only about objects on their screens instead of everything on the map could conserve bandwidth and also hide information the user is not supposed to know (player killers in PvP, for example, would greatly enjoy a hack which shows them everyone on the map, while their victims don't notice the PKer before it appears on the screen). Or I just go the other way around and add a minimap to the client which shows all objects on the map.

No comments:

Post a Comment