private void setTrickWonMessage(PlayGameMessage playGameMessage) { destroyChilds(Player1TopPosition); destroyChilds(Player2TopPosition); destroyChilds(Player1BottomPosition); destroyChilds(Player2BottomPosition); if (playGameMessage.wonPlayerName == CurrentPlayerName) { ShowThinkBubble("I m lucky in this trick!"); loadWonCard(playerWonCardPanel); playerWonTrickCount++; playerWonTrickCountText.text = playerWonTrickCount.ToString(); loadPanelCardButtons(currentCardList, true); } else { ShowThinkBubble("You won the trick!"); loadWonCard(opponentWonCardPanel); opponentWonTrickCount++; opponentWonTrickCountText.text = opponentWonTrickCount.ToString(); loadPanelCardButtons(currentCardList, false); } }
private void SendFinishMessage(string finishStatus) { PlayGameMessage message = new PlayGameMessage(0, 0, 0, 0, 0, 0, finishStatus); Connection.Send(message); Connection.Dispose(); listenThread.Abort(); }
private void setTrickWonMessage(PlayGameMessage playGameMessage) { if (playGameMessage.wonPlayerName == CurrentPlayerName) { if (currentPlayerMessageCount % 3 == 0) { ShowThinkBubble("You won the trick!"); } else if (currentPlayerMessageCount % 3 == 1) { ShowThinkBubble("You are lucky on this time!"); } else if (currentPlayerMessageCount % 3 == 2) { ShowThinkBubble("Hey hey you get the advantage!"); } currentPlayerMessageCount++; loadWonCard(playerWonCardPanel); playerWonTrickCount++; playerWonTrickCountText.text = playerWonTrickCount.ToString(); StartCoroutine(RemoveAfterSeconds(3)); loadPanelCardButtonsSetActive(currentCardList, true); } else { if (nextPlayerMessageCount % 3 == 0) { ShowThinkBubble("I'm lucky in this trick!"); } else if (nextPlayerMessageCount % 3 == 1) { ShowThinkBubble("I am moving forward!"); } else if (nextPlayerMessageCount % 3 == 2) { ShowThinkBubble("I am making an advantage!"); } nextPlayerMessageCount++; loadWonCard(opponentWonCardPanel); opponentWonTrickCount++; opponentWonTrickCountText.text = opponentWonTrickCount.ToString(); loadPanelCardButtonsSetActive(currentCardList, false); } ResetQuad(currentQuadObject, false); ResetQuad(currentOpnontQuadObject, true); }
private void playGameMessage(PlayGameMessage playGameMessage) { //if (playGameMessage.playerName == CurrentPlayerName) //{ // playerCardPanel.gameObject.SetActive(true); //} //else //{ // playerCardPanel.gameObject.SetActive(false); //} }
private void setOtherPlayerCard(PlayGameMessage playGameMessage) { if (playGameMessage.playerName != CurrentPlayerName) { loadOpponentPanelCardButtons(currentCardList.Count - 1); if (playGameMessage.playerName.ToLower() == player1name) { loadSelectedCardToPanel(playGameMessage.card, Player1BottomPosition); } else { loadSelectedCardToPanel(playGameMessage.card, Player2BottomPosition); } loadPanelCardButtons(currentCardList, true); } }
private void OnUpdateGame(PlayGameMessage playGameMessage) { //Проверка доступности клавиатуры: if (!isKeyboardEnable) { return; } //Обновление позиции мяча: ball.Top = TableHeight - playGameMessage.BallPositionY; ball.Left = playGameMessage.BallPositionX; //Обновление позиции игроков: leftBoard.Top = TableHeight - playGameMessage.LeftPlayerPositionY; rightBoard.Top = TableHeight - playGameMessage.RightPlayerPositionY; //Обновление счета: leftPlayerScore.Text = playGameMessage.LeftPlayerScore + "/5"; rightPlayerScore.Text = playGameMessage.RightPlayerScore + "/5"; }
private void playWrongCardPopup(PlayGameMessage playGameMessage) { if (playGameMessage.playerName == CurrentPlayerName) { audioSource.clip = wrongButtonClickAudio; audioSource.Play(); currentCardList.Add(lastSelectedCard); if (this.CurrentPlayerName.ToLower() == player1name) { destroyChilds(Player1TopPosition); } else { destroyChilds(Player2TopPosition); } loadPanelCardButtons(currentCardList, true); } }
private void setOtherPlayerCard(PlayGameMessage playGameMessage) { if (playGameMessage.playerName != CurrentPlayerName) { int cardCount = currentCardList.Count - 1; String quadName = "OQuad_" + oponentCardCount; GameObject myQuad = GameObject.Find(quadName); Material yourMaterial = (Material)Resources.Load("images/Materials/" + playGameMessage.card, typeof(Material)); myQuad.GetComponent <Renderer>().material = yourMaterial; currentOpnontQuadObject = myQuad; isOppenonetPlayerMoveCard = true; opponenetWayPoint = opponenetWayPoints[0]; oponentCardCount++; } }
private void playWrongCardPopup(PlayGameMessage playGameMessage) { if (playGameMessage.playerName == CurrentPlayerName) { audioSource.clip = wrongButtonClickAudio; audioSource.Play(); currentCardList.Add(lastSelectedCard); currentButton.gameObject.SetActive(true); wayPoint = null; isPlayerMoveCard = false; //currentQuadObject = null; ShowThinkBubble("Dont play wrong card!"); loadPanelCardButtonsSetActive(currentCardList, true); ResetQuad(currentQuadObject, false); } }
private void GameUpdate() { while (status == Status.PLAYING) { //Частота обновления игры Thread.Sleep(33); //Блокировка потока левого игрока для извлечения позиции по оси Y Monitor.Enter(onlineLeftPlayer); int leftBoardPositionY = onlineLeftPlayer.PositionByY; Monitor.Exit(onlineLeftPlayer); //Блокировка потока правого игрока для извлечения позиции по оси Y Monitor.Enter(onlineRightPlayer); int rightBoardPositionY = onlineRightPlayer.PositionByY; Monitor.Exit(onlineRightPlayer); ball.Move(leftBoardPositionY, rightBoardPositionY); //Проверка гола левому игроку if (WasLeftGoal()) { //Добавление очков правому игроку Monitor.Enter(onlineRightPlayer); Player player = onlineRightPlayer; player.Score += 1; bool isWin = IsWin(player); Monitor.Exit(onlineRightPlayer); Console.WriteLine("GOAL TO THE LEFT PLAYER!"); if (isWin) { //Победитель Monitor.Enter(onlineRightPlayer); onlineRightPlayer.FinishAsWinner(); Monitor.Exit(onlineRightPlayer); Console.WriteLine("RIGHT PLAYER HAS WIN!"); //Проигравший Monitor.Enter(onlineLeftPlayer); onlineLeftPlayer.FinishAsLoser(); Monitor.Exit(onlineLeftPlayer); Console.WriteLine("LEFT PLAYER HAS LOST!"); Finish(); break; } ball = new Ball(); } //Проверка гола правому игроку if (WasRightGoal()) { //Добавление очков правому игроку Monitor.Enter(onlineLeftPlayer); Player player = onlineLeftPlayer; player.Score += 1; bool isWin = IsWin(player); Monitor.Exit(onlineLeftPlayer); Console.WriteLine("GOAL TO THE RIGHT PLAYER!"); if (isWin) { //Победитель Monitor.Enter(onlineLeftPlayer); onlineLeftPlayer.FinishAsWinner(); Monitor.Exit(onlineLeftPlayer); Console.WriteLine("LEFT PLAYER HAS WIN!"); //Проигравший Monitor.Enter(onlineRightPlayer); onlineRightPlayer.FinishAsLoser(); Monitor.Exit(onlineRightPlayer); Console.WriteLine("RIGHT PLAYER HAS LOST!"); Finish(); break; } ball = new Ball(); } //Сообщение об игре PlayGameMessage playGameMessage = new PlayGameMessage( onlineLeftPlayer.PositionByY, onlineLeftPlayer.Score, onlineRightPlayer.PositionByY, onlineRightPlayer.Score, ball.PositionByX, ball.PositionByY, PlayGameMessage.PlayingGameStatus ); //Отправка сообщения левому игроку Monitor.Enter(onlineLeftPlayer); onlineLeftPlayer.Send(playGameMessage); Monitor.Exit(onlineLeftPlayer); //Отправка сообщения правому игроку Monitor.Enter(onlineRightPlayer); this.onlineRightPlayer.Send(playGameMessage); Monitor.Exit(onlineRightPlayer); } }