Implement the gui and logic for quitting or leaving the game.
This is a critical Fsm.
This Fsm is relying on the fact the the "game" gameObject doesn't exists when the user is not in a room.
This Fsm has two functions:
- We display the Quit button. Since we assume we only exists when the user is in a room, we do that as soon as we START If the user press the button, we transit through the QUIT event we created for the occasion, and make a simply call to the photon system to tell it we want to leave the room.
- Instead of relying on the user leaving the room manually, we use the Photon Events to let the system tell us we indeed left the room or that we disconnected ( likely because an internet connection failure). We do that by simply watching PHOTON / LEFT ROOM and PHOTON / DISCONNECTED FROM PHOTON We can afford do do that because the action we need on both case is the same: we reload the scene. This is one clear benefit of reloading every time the scene when the status of the game changes.
Photon Actions used:
- Photon Network Leave Room ( in state "leave room")