public void OnSnapshotReceived(JUMPCommand_Snapshot data) { WordsWar_Snapshot snap = new WordsWar_Snapshot(data.CommandData); GameStatus.text = snap.Stage.ToString(); MyScore.text = snap.MyScore.ToString(); OpponentScore.text = snap.OpponentScore.ToString(); UIStage = snap.Stage; if (UIStage == WordsWarGameStages.SendBoardID) { Message.text = "Receiving board .. " + snap.BoardID.ToString(); BoardSol = BoardManager.GetBoard(snap.BoardID); Board.text = BoardSol.SolvedBoard.ToString().ToUpper(); // "Playing Board: " + snap.BoardID.ToString(); WordsWarCommand_BoardReceived ack = new WordsWarCommand_BoardReceived(JUMPMultiplayer.PlayerID, snap.BoardID); Singleton <JUMPGameClient> .Instance.SendCommandToServer(ack); } else if (UIStage == WordsWarGameStages.CountingDown) { TimeLeft.text = snap.CountingDownRemaining.ToString("0."); } else if (UIStage == WordsWarGameStages.Playing) { TimeLeft.text = snap.PlayTimeRemaining.ToString("0."); } else if (UIStage == WordsWarGameStages.GameOver) { Message.text = (snap.WinnerPlayerID == JUMPMultiplayer.PlayerID) ? "You Won :)" : "You Lost :("; } }
public JUMPCommand_Snapshot TakeSnapshot(int ForPlayerID) { WordsWar_Snapshot snap = new WordsWar_Snapshot(); snap.ForPlayerID = ForPlayerID; snap.MyScore = 0; snap.OpponentScore = 0; snap.BoardID = GameState.BoardID; snap.Stage = GameState.Stage; snap.CountingDownRemaining = GameState.CountingDownRemaining; snap.PlayTimeRemaining = GameState.PlayTimeRemaining; snap.WinnerPlayerID = GameState.WinnerPlayerID; foreach (var item in GameState.Players) { if (item.Value.PlayerID == ForPlayerID) { snap.MyScore = item.Value.Score; } else { snap.OpponentScore = item.Value.Score; } } return((JUMPCommand_Snapshot)snap); }