How to handle sending and receiving the state of your game.

Options
I'm working on a 4 player board game where the players have their own stats, and they will be moving across the board for the duration of the game. I have it setup so each player can send stats and that works as intended, but when I try to send out the state of the game to all the players I get issues. Sometimes the state of the game will get sent correctly when it is Player 1's turn, but then when you go to Player 2's turn the game still thinks its player 1's turn or it will skip turns. Also each players turn has multiple states that it can be in.

How would I go about setting up my Unity project to work with sending the state of the game. Do I need multiple Photon Views, just one, or is there another way to do it.

Best Answer

Answers

  • So I figured that I would use the turn manager callback that is included with PUN, but I have a question. How much data can be sent at once when a player makes a move? I need to send the state of the games play area, and some other values to help determine player actions when a turn is being taken.
  • WizByte_Games
    edited November 2017
    Options
    Hey Christian thanks for the reply. I should have explained more about the game as you said. Here a little more detail about my project. This project is a new project that I started from scratch.
    • The game is a four player board game where each player gets to take a turn moving across the board.
    • Each turn can have multiple phases (Battle, Moving, Shopping, Rebirth, or other evens.)
    • During each phase I would need to send what phase of the turn the game is in and a couple of values to tell the other players what is going on during the turn.
    • After a player finishes his/her turn the game will move on to the next players turn.

    I assume you can only send one move using the send move function per turn. I was thinking of using a hashtable to send the data, but when I tried it said hashtables couldn't be serialized. Even though in the Photon source code there are clearly serialized hashtables.
  • Apparently i have to write this post again because of some random error :(

    Herer is a bit about my game
    • The game project is made from scratch
    • in the game there are four players on a game board.
    • each player takes a turn to perform various actions in their turn (Movement, Battle, Shopping)
    • Each turn has multiple phases (Start, Rebirth, Movement, Action, End)
    What I was trying to do was send the phase that a turn is in plus other values that tell what actions the player took during that phase to other players in the room. I tried using hashtables but I got an error saying that they couldn't be serialized even though in the docs it says you can use hashtables.
  • So I think i have found a solution to my problem. I shouldn't be trying to push a bunch of data during a certain phase of the players turn. I should just push the data that is important to that phase and then I don't have to have the client and server player keep track of what phase a turn is in just what data was changed during that phase.