public void Init() { // Init gameManager GameManager = new GameManager(); GameManager.OnGameFinished += GameManager_OnGameFinished; // Update clients OthelloPlayer1.SetColor(Color.Black); OthelloPlayer1.SetAvatarID(0); OthelloPlayer2.SetColor(Color.White); OthelloPlayer2.SetAvatarID(19); // Game is ready OthelloPlayer1.GameReady(); OthelloPlayer2.GameReady(); }
/// <summary> /// Send avatardID from both client after this function /// </summary> /// <param name="game"></param> public void Load(SaveFile saveFile) { // Init gameManager GameManager = new GameManager(); GameManager.OnGameFinished += GameManager_OnGameFinished; // Load the game GameManager.Load(saveFile.States); // Update clients OthelloPlayer1.SetColor((Color)saveFile.Player1Color); OthelloPlayer1.SetAvatarID(saveFile.Player1AvatarID); OthelloPlayer2.SetColor((Color)saveFile.Player2Color); OthelloPlayer2.SetAvatarID(saveFile.Player2AvatarID); // Notify clients of opponent avatar OthelloPlayer1.OpponentAvatarChanged(saveFile.Player2AvatarID); OthelloPlayer2.OpponentAvatarChanged(saveFile.Player1AvatarID); // Immediatly start the game StartGame(); }