Storing and distributing GameRoom's assets

Options
eyewitness4560
edited February 2014 in Photon Server
Hi there, we'd like some input on how to manage our game rooms;

Ideally we would like to generate and store the parameters for a given room (one solar system in our game, and by parameters I mean art asset ID's number of planets, their location, orientation and so on) in the GameProperties. Is this the right place for it, or should we put all of this in an initialization event after the create/join happens?

Thanks in advance!

Andrew

Comments

  • Tobias
    Options
    Actually, both would be fine but the room's properties have a slight benefit: They can be modified and you always just have the latest state of those. Buffered events can be stored and removed (individually or in a bulk operation) at will, too, but it's more work for you.

    So: Store as few values as you need to generate the system in your room props.
    Depending on your algorithms, you could try to go as low as storing just one integer for a whole system. When you initialize Random with it, you get the same sequence of random numbers on all machines, so you can procedurally generate the system by this. That is: If you're not building it in the first place.
  • Thanks, we did just that and put it into the room properties by it's set method. We did this in the constructor of the room, but for some reason the first actor in the room (the one who creates it) does not recieve the data... Any ideas where our problems may lie? :)
  • Tobias
    Options
    In the constructor of the Room?
    Are you talking about the server or the client side?
    Client side, you can set room properties in CreateRoom(..., roomProps), or when you are actually in the room (wait for the callback that you joined and make sure only the master client (first one) set the props). If a client sets the properties, I'm not sure if we do a callback (cause you just set them yourself).
    Server side, I will have to ask my colleague to help with hints or code (I rarely work in the server myself).

    Please let us know which callback you miss where.
  • Server side... we're using/expanding loadbalancing. Its for predefined specific game "maps" or rooms.
  • Tobias has almost answered the question...

    The first client can pass initial properties via the CreateRoom(..., roomProps) method. He does not receive the properties in the operation response / callback, because he has set them himself and already "knows" what he has set. If you don't pass the properties from the client, but set them in the constructor on the server-side, you need to modify the code where the CreateGameResponse is created and add the properties to the response.

    In LoadBalancing.GameServer.Game -> HandleCreateGameOperation, add code similar to the code from the "join" operation:

    if (this.Properties.Count > 0)
    {
    response.CurrentGameProperties = this.Properties.GetProperties();
    }
  • Works perfectly, thank you! :D