Turn based Multiplayer Game - Advice needed

[SITUATION]
Okay so I am currently trying out Photon Unity Networking which in my own opinion, IS AWESOME!!! :D
I really like the idea of getting to feel and touch the cloud service with limited amount of ccu' available, so you get the chance to try out
all the good features PUN is providing.
That being said, I am totally new to Networking related to Unity, I get the general concept of OnPhotonSerializeView and RPC's and their respective limitations.
Since I am developing a Turn-based Multiplayer game, I think the best solution would be to utilize RPC's since I have no need for immediate info from players and information should only be send when and action is taking by the players.

[PROBLEM/QUESTION]
My currently Setup is a Master Client Instantiating a SceneObject called GameController, which sole purpose is to manage the game for the players, like having turn counter, players, creating a Tile Grid Map which I made from scratch (Annotated A*) Pathfinding.

Question No1.
So my first question is now, because as it is, the GameController should be available for both players, and there should only ever be one in the game, but since it is created by the master client I don't know how to engage it with other players who are not master clients. I know it is owned by the scene and controlled locally by the master, but I am fairly new to Netwroking as I said so I might have skipped or not noticed how you do this.

Question No2.
My second question is that, as it is now, both players are creating their respective Tile Grid Map, and it was my intention to update each tiles state with the usage of RPC's, so for instance if Player1 moves to Tile with position {1,1], Player2s' Tile with position [1,1] would have its state set to Player1 is now on it.
But i would really like it if those Tiles could also become Scene objects, but they immediately lose parenting when i try this for the non-master clients
I forgot to mention, the GameController GameObject is the parent of all Tile GameObjects.

Question No3.
So my final question is, how do I send Object data over the network, I know this might have been answered before, and if it has, just link to the topic and I will take a look :)

This is the last exception I received btw before literally gave up :P
Exception: cannot serialize(): Tile
ExitGames.Client.Photon.Protocol.Serialize (System.IO.MemoryStream dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol.SerializeObjectArray (System.IO.MemoryStream dout, System.Object[] objects, Boolean setType)
ExitGames.Client.Photon.Protocol.Serialize (System.IO.MemoryStream dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol.SerializeHashTable (System.IO.MemoryStream dout, ExitGames.Client.Photon.Hashtable serObject, Boolean setType)
ExitGames.Client.Photon.Protocol.Serialize (System.IO.MemoryStream dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol.SerializeHashTable (System.IO.MemoryStream dout, ExitGames.Client.Photon.Hashtable serObject, Boolean setType)
ExitGames.Client.Photon.Protocol.Serialize (System.IO.MemoryStream dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol.SerializeParameterTable (System.IO.MemoryStream memStream, System.Collections.Generic.Dictionary`2 parameters)
ExitGames.Client.Photon.Protocol.SerializeOperationRequest (System.IO.MemoryStream memStream, Byte operationCode, System.Collections.Generic.Dictionary`2 parameters, Boolean setType)
ExitGames.Client.Photon.EnetPeer.SerializeOperationToMessage (Byte opc, System.Collections.Generic.Dictionary`2 parameters, EgMessageType messageType, Boolean encrypt)
ExitGames.Client.Photon.EnetPeer.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypt, EgMessageType messageType)

Thank you so much in advance!
PS. Code can be provided aswell if my description is not clear enough :)

Comments

  • Cool to read you like PUN! Even more so, reading that you do despite the issues you got :)

    RPCs for a turnbased game should be fine. You're on track, I'd say.
    You can save state of a game in "Custom Properties" maybe. Check out Room SetCustomProperties.

    A1: I don't understand the issue. I think it should be possible to find it by name or type or something. Anyone can call RPCs on that controller object and they get executed on all clients (as this is the idea of the RPC).
    You can even setup the GameController as part of the scene and just load it with the scene. Then you don't even have to instantiate it.

    A2: I think you should not make the tile something "networked". Create a TileMap class which knows the actual visual GOs per tile and make this TileMap known to your GameController. The Controller can then modify the map and this takes care of the GOs. You don't really need PhotonViews per Tile this way.
    I don't know why your GOs lose parenting. I guess I would need to debug it but that's beyond scope here.

    A3: In Photon you can only send "known" datatypes. It can't serialize just any class you might need and create.
    That's what fails andthe error message you get.
    To serialize Tile, you need to register 2 methods to convert it to and from a binary (byte[]) form. In PUN, some Unity-typical classes are made serializable this way in CustomTypes class. Have a look and try to replicate the solution.
    Or: Instead of passing a Tile instance as RPC parameter, you can pass a tile ID (it's index): RPC("tileaction", ..., myTile.ID()).
    You can create a simple ID as: "Y*tilesInX + X". As example.
  • Thank you so much for the quick response!
    I will definitely look into it, and hopefully resolve my issues ;)
    Cheers!