Quantcast
Channel: Photon Server — Photon Engine
Viewing all articles
Browse latest Browse all 1557

Authoritative Server, Card Game, How to store game state/objects and sync individual actions

$
0
0
Using unity 2017 and Photon On Premise server and have a question about how to store/sync data with the players.

I previously completed a single player version of my game in Unity. I am now building a multiplayer mode.

I setup Photon Server on my machine, using the load balancer/master/game server config. My unity game is now able to connect to the master server and then to the game server and send requests. All of this is functioning properly.

My game data is pretty simple. Basically a deck of cards per player separated into stacks, with a few shared stacks.
Game
	SharedStack1
		Card10
	SharedStack2
		Card11
	Players
		Player1
			Stack1
				Card1
			Stack2
				Card2
				Card3
		Player2
			Stack3
				Card4
			Stack4
				Card5
				Card6
What I'd like to do initialize all the decks/stacks on the server, and when match making is complete and the game is ready to start, send an event that contains all the cards for each player (Each client would get the other players cards as well, so they can watch them play visually). In unity, the client would receive this event , store a local gamestate, and then visually build it.

Then, as each player moves cards from stack to stack, their move would be validated client side, then submitted to the server and processed. If valid, it would then be sent to the other players so the move can be made locally on their side and then reflected in their local version of the game state.

What I want to do, is send each "action" individually, as opposed to sending the entire GameProperties hash table to each user everytime something changes. In the case that a user tries to make a move that shows as valid on client, but invalid on server, I would trigger a "OutOfSync" event for that client and when recieved, unity would freeze their game and reinitialize the gamestate/visuals.

I'm unsure of what the best way to send these actions are, or if i am going down the wrong road and should just use the game properties the way the documentation suggests.

Viewing all articles
Browse latest Browse all 1557

Trending Articles