public void OnMoveCompletedOccured(MoveEvent _Move)
    {
        //Debug.LogError("OnMoveCompleted " + _Move.getMoveData() + " " + _Move.getNextTurn() + " " + _Move.getSender());
        if (_Move.getSender() != username && _Move.getMoveData() != null)
        {
            Dictionary <string, object> recievedData = MiniJSON.Json.Deserialize(_Move.getMoveData()) as Dictionary <string, object>;
            if (recievedData != null && !GameManager.Instance.IsGameOver)
            {
                if (recievedData.ContainsKey("oldTileRow"))
                {
                    var  matrixTile = TileManager.Instance.MatrixTiles;
                    Tile oldTile    = matrixTile[int.Parse(recievedData["oldTileRow"].ToString()), int.Parse(recievedData["oldTileColumn"].ToString())];
                    Tile newTile    = matrixTile[int.Parse(recievedData["newTileRow"].ToString()), int.Parse(recievedData["newTileColumn"].ToString())];
                    var  zombie     = oldTile.Soldier as Zombie;

                    if (recievedData.ContainsKey("RandomRank"))
                    {
                        var randomRank = int.Parse(recievedData["RandomRank"].ToString());
                        zombie.Rank      = (short)randomRank;
                        zombie.IsCopycat = true;
                    }

                    SoldierManager.Instance.MakeEnemyMove(zombie, newTile);

                    currentUsernameTurn = _Move.getNextTurn();
                    isMyTurn            = (_Move.getNextTurn() == username);
                    StartCoroutine(GameManager.Instance.CountTime());
                }
                else if (recievedData.ContainsKey("GameQuit"))
                {
                    GameManager.Instance.WinGame(PlayerSide, recievedData["GameQuit"].ToString());
                }
            }
        }
    }
    /// <summary>
    /// This method receives a move and changing turns between clients respectively.
    /// If a client didn't make any move in 30 seconds then end game and set the other client as the winner.
    /// If a move is made and the game is not initialize yet, then initialize the game.
    /// If a move is made and the game already initialized, then simulate a shot for the desirable client.
    /// </summary>
    /// <param name="_Move"></param>
    public void OnMoveCompleted(MoveEvent _Move)
    {
        //Debug.Log("OnMoveCompleted " + _Move.getMoveData() + " | " + _Move.getNextTurn());

        if (_Move.getNextTurn() == DefinedVariables.userName)
        {
            IsPlayerTurn = true;
        }
        else
        {
            IsPlayerTurn = false;
        }

        if (_Move.getMoveData() != null)
        {
            if (_Move.getSender() != DefinedVariables.userName && IsGameOver == false)
            {
                _receivedPlayData = MiniJSON.Json.Deserialize(_Move.getMoveData()) as Dictionary <string, object>;

                if (_receivedPlayData != null)
                {
                    if (IsMultiplayerInitiated == false)
                    {
                        SendGameInitializationData();
                        if (_receivedPlayData.ContainsKey("i1") && _receivedPlayData.ContainsKey("i2") && _receivedPlayData.ContainsKey("i3"))
                        {
                            MultiplayerInit(int.Parse(_receivedPlayData["i1"].ToString()), int.Parse(_receivedPlayData["i2"].ToString()), _receivedPlayData["i3"].ToString());
                        }
                        IsMultiplayerInitiated = true;
                    }
                    else
                    {
                        if (_receivedPlayData.ContainsKey("v1") && _receivedPlayData.ContainsKey("v2") && _receivedPlayData.ContainsKey("v3"))
                        {
                            SimulateOpponentMove(int.Parse(_receivedPlayData["v1"].ToString()), StringToVector3(_receivedPlayData["v2"].ToString()), int.Parse(_receivedPlayData["v3"].ToString()));
                            IsPuckMoving = true;
                        }
                    }
                }
            }
        }
        else
        {
            if (_Move.getNextTurn() == DefinedVariables.userName)
            {
                uiObject["Text_WinnerName"].GetComponent <Text>().text = DefinedVariables.userName;
            }
            else
            {
                uiObject["Text_WinnerName"].GetComponent <Text>().text = uiObject["Text_Computer"].GetComponent <Text>().text;
            }

            EndGame();
        }
    }
Exemple #3
0
 public void onMoveCompleted(MoveEvent move)
 {
     if (appwarp.isTexassGame)
     {
         texassGameManager.highLightTurnPlayer(move.getNextTurn());
     }
     else
     {
         waGameManager.highLightTurnPlayer(move.getNextTurn());
     }
 }
 public void onMoveCompleted(MoveEvent move)
 {
     Debug.Log("onMoveCompleted by: " + move.getSender() + "\nData: " + move.getMoveData() + "\nNextTurn: " + move.getNextTurn());
     if ((move.getNextTurn()).Equals(Constants.userName))
     {
         isUserTurn = true;
         Debug.Log("Your Turn");
     }
     else
     {
         isUserTurn = false;
         Debug.Log("Turn: " + move.getNextTurn());
     }
 }
Exemple #5
0
    private void OnMoveCompleted(MoveEvent _Move)
    {
        if (_Move.getSender() != GlobalVariables.userId)
        {
            Dictionary <string, object> _data = (Dictionary <string, object>)MiniJSON.Json.Deserialize(_Move.getMoveData());
            if (_data != null && _data.ContainsKey("Index"))
            {
                string _index = _data["Index"].ToString();
                GlobalEnums.MatchState _currentState = PlacementLogic(_index);
                if (_currentState == GlobalEnums.MatchState.Tie || _currentState == GlobalEnums.MatchState.Winner)
                {
                    WarpClient.GetInstance().stopGame();
                }
            }
        }

        startTime = Time.time;
        if (_Move.getNextTurn() == GlobalVariables.userId)
        {
            isMyTurn = true;
        }
        else
        {
            isMyTurn = false;
        }
    }
Exemple #6
0
    //opponet move

    public void OnMoveCompleted(MoveEvent _Move)
    {
        //Debug.Log("OnMoveCompleted " + _Move.getMoveData() + " " + _Move.getNextTurn() + " " + _Move.getSender());
        if (_Move.getSender() != SC_MultiPlayer_Globals.userName && _Move.getMoveData() != null)
        {
            Dictionary <string, object> _recievedData = MiniJSON.Json.Deserialize(_Move.getMoveData()) as Dictionary <string, object>;
            if (_recievedData != null)
            {
                //int _index = int.Parse(_recievedData["Data"].ToString());
                //  SubmitLogic(_index);
                print("_recievedData= fromCol" + _recievedData["fromCol"] + " toCol= " + _recievedData["toCol"]);
                ProccessMove(_recievedData);
            }
        }

        // print("_Move.getNextTurn()" + _Move.getNextTurn() + "    +++     userName" + SC_MultiPlayer_Globals.userName);
        //if (_Move.getNextTurn() == SC_MultiPlayer_Globals.userName)
        //    currentTurn = SC_DefiendVariables.Turn.RedTurn;
        //else currentTurn = SC_DefiendVariables.Turn.blueTurn;

        if (_Move.getNextTurn() == SC_MultiPlayer_Globals.userName)
        {
            isMyTurn = true;
        }
        else
        {
            isMyTurn = false;
        }
    }
Exemple #7
0
 private void switchTurns(MoveEvent _Move)
 {
     if (_Move.getNextTurn() == SC_MenuLogic.Instance.userId)
     {
         currentTurn = GlobalEnums.Turns.PlayersTurn;
     }
     else
     {
         currentTurn = GlobalEnums.Turns.FoesTurn;
     }
 }
    //opponet move

    public void OnMoveCompleted(MoveEvent _Move)
    {
        print("onMoveComplete.count = " + onMoveCompletedCounter);

        //Debug.Log("OnMoveCompleted " + _Move.getMoveData() + " " + _Move.getNextTurn() + " " + _Move.getSender());
        if (_Move.getSender() != SC_MultiPlayer_Globals.userName && _Move.getMoveData() != null && SC_MultiPlayer_Globals.GamePhase == SC_MultiPlayer_Globals.GameSituation.setPieces && onMoveCompletedCounter > 3 && doneRestarting == false)
        {
            Dictionary <string, object> _recievedData = MiniJSON.Json.Deserialize(_Move.getMoveData()) as Dictionary <string, object>;
            if (_recievedData != null)
            {
                int _toCol = 9 - Convert.ToInt32(_recievedData["toCol"]);
                int _toRow = 9 - Convert.ToInt32(_recievedData["toRow"]);
                //int _fromCol = 9 - Convert.ToInt32(_recievedData["fromCol"]);
                //int _fromRow = 9 - Convert.ToInt32(_recievedData["fromRow"]);

                SC_MultiPlayer_Globals.SoldierRank strength = (SC_MultiPlayer_Globals.SoldierRank)Enum.Parse(typeof(SC_MultiPlayer_Globals.SoldierRank), _recievedData["strength"].ToString());
                SC_MultiPlayer_View.Instance.movePieceToNewLocation(SC_MultiPlayer_Globals.Instance.unityObjects["Enemy (" + _recievedData["name"] + ")"].GetComponent <SC_MultiPlayer_PieceLogic>(), gameBoard[_toRow][_toCol].tile.GetComponent <SC_MultiPlayer_TileLogic>());
                print("inside the first if!!!!!");
            }
        }
        else if (hasTransferedInfo && _Move.getSender() != SC_MultiPlayer_Globals.userName)
        {
            print("(hasTransferedInfo && _Move.getSender() != SC_MultiPlayer_Globals.userName)");
            hasTransferedInfo = false;
            SetEnemyPieces(_Move);
            InitializeEnemyPieces();
        }

        else if (_Move.getSender() != SC_MultiPlayer_Globals.userName && _Move.getMoveData() != null && onMoveCompletedCounter > 2 && SC_MultiPlayer_Globals.GamePhase == SC_MultiPlayer_Globals.GameSituation.Running)
        {
            print("before the dictonery1");
            Dictionary <string, object> _recievedData = MiniJSON.Json.Deserialize(_Move.getMoveData()) as Dictionary <string, object>;
            if (_recievedData != null)
            {
                //print("_recievedData= fromCol" + _recievedData["fromCol"] + " toCol= " + _recievedData["toCol"]);
                ProccessMove(_recievedData);
            }
        }


        if (_Move.getNextTurn() == SC_MultiPlayer_Globals.userName)
        {
            isMyTurn = true;
        }
        else
        {
            isMyTurn = false;
        }

        SwitchTurn();
        onMoveCompletedCounter++;
    }
 public void onMoveCompleted(MoveEvent move)
 {
     AppWarpManager.instance.Print("move complt");
     Log("OnMoveCompleted::" + move.getMoveData());
     if (move.getNextTurn() == test.username)
     {
         AppWarpManager.IsMyTurn = true;
     }
     else
     {
         AppWarpManager.IsMyTurn = false;
     }
 }
 public void OnMoveCompleted(MoveEvent Move)
 {
     Debug.Log("OnMoveCompleted " + Move.getMoveData() + "" + Move.getNextTurn());
     if (Move.getSender() != SC_DefinedVariables.userName)
     {
         if (Move.getMoveData() != null)
         {
             Dictionary <string, object> receivedData = MiniJSON.Json.Deserialize(Move.getMoveData()) as Dictionary <string, object>;
             int index1 = int.Parse(receivedData["Value1"].ToString());
             int index2 = int.Parse(receivedData["Value2"].ToString());
             StartCoroutine(SwapAnimation(index1, index2));
             if (Move.getNextTurn() == SC_DefinedVariables.userName)
             {
                 SC_DefinedVariables.IsMyTurn = true;
             }
             else
             {
                 SC_DefinedVariables.IsMyTurn = false;
             }
         }
     }
 }
Exemple #11
0
 public void OnMoveCompleted(MoveEvent _Move)
 {
     Debug.Log("OnMoveCompleted " + _Move.getMoveData() + "" + _Move.getNextTurn());
     if (_Move.getSender() != Global_Variables.User)
     {
         if (_Move.getMoveData() != null)
         {
         }
         else
         {
             WarpClient.GetInstance().stopGame();
         }
     }
 }
    private void HandleOnMoveCompletedByPlayer(MoveEvent moveEvent)
    {
        HideTurnTimer();

        if (playerID.Equals(moveEvent.getNextTurn()))
        {
            if (playerInfo.Player_Status != (int)PLAYER_ACTION.ACTION_WAITING_FOR_GAME &&
                playerInfo.Player_Status != (int)PLAYER_ACTION.FOLD &&
                playerInfo.Player_Status != (int)PLAYER_ACTION.TIMEOUT &&
                playerInfo.Player_Status != (int)PLAYER_ACTION.ALLIN)
            {
                DisplayPlayerData();
                DisplayTurnTimer();
            }
        }
    }
 public void onMoveCompleted(MoveEvent moveEvent)
 {
     if (moveEvent.getRoomId().Equals(GlobalContext.GameRoomId))
     {
         if(moveEvent.getMoveData()!=null)
         MoveMessage.buildMessage(System.Text.Encoding.UTF8.GetBytes(moveEvent.getMoveData()));
         if (moveEvent.getNextTurn().ToString().Equals(GlobalContext.localUsername))
         {
             GlobalContext.IsMyTurn = true;
             if (RemoteUserPaused != null)
                 Deployment.Current.Dispatcher.BeginInvoke(new UICallback(ChangeTurnCallback));
         }
         else
         {
             GlobalContext.IsMyTurn = false;
             if (RemoteUserPaused != null)
                 Deployment.Current.Dispatcher.BeginInvoke(new UICallback(ChangeTurnCallback));
         }
     }
 }
Exemple #14
0
    private void OnMoveCompleted(MoveEvent _Move)
    {
        startTimer = Time.time;
        if (_Move.getSender() != GlobalVariables.userID)
        {
            Dictionary <string, object> _data = (Dictionary <string, object>)MiniJSON.Json.Deserialize(_Move.getMoveData());

            if (_data != null && _data.ContainsKey("Index"))
            {
                if (_data.ContainsKey("Index"))
                {
                    int _index = int.Parse(_data["Index"].ToString());
                    if (_index > 0 && gameStarted)
                    {
                        GlobalEnums.MatchState _currState = PlacementLogic(_index);
                        if (_currState != GlobalEnums.MatchState.NoWinner)
                        {
                            gameStarted = false;
                        }
                    }
                    else if (_index < 0)
                    {
                        gameover["Screen_RestartQ"].SetActive(true);
                        WarpClient.GetInstance().stopGame();
                    }
                }
            }
            if (_Move.getNextTurn() == GlobalVariables.userID)
            {
                isMyTurn = true;
            }
            else
            {
                isMyTurn = false;
            }
        }
    }
    internal bool HandleMsgAck(MoveEvent move)
    {
        if (move.getSender() != SharedDataHandler.username)
        {
            //Debug.Log("HandleMsgAck: sender=" + move.getSender() + ", data=" + move.getMoveData() + ", nextTurn=" + move.getNextTurn());
            if (move.getMoveData() != null)
            {
                receivedData.Clear();
                receivedData = MiniJSON.Json.Deserialize(move.getMoveData()) as Dictionary <string, object>;
                if (receivedData != null)
                {
                    ParseJsonData(receivedData[DATA_KEY_VAR_NAME].ToString());
                }
            }
            else
            {
                Debug.Log("data is null!");
                SharedDataHandler.client.stopGame();
            }
        }

        //returns whether its our turn or rival's:
        return(move.getNextTurn() == SharedDataHandler.username);
    }
Exemple #16
0
    private void OnMoveCompleted(MoveEvent _Move)
    {
        var sender = _Move.getSender();

        Debug.Log("sender - " + sender);
        if (_Move.getSender() != UserId)
        {
            Dictionary <string, object>        _characterDictionaryTmp = (Dictionary <string, object>)MiniJSON.Json.Deserialize(_Move.getMoveData());
            Dictionary <Character, Vector2Int> _overwatchDictionaryTmp = new Dictionary <Character, Vector2Int>();

            if (_characterDictionaryTmp != null)
            {
                foreach (var check in _characterDictionary.ToList())
                {
                    var isExist = false;
                    foreach (var alive in _characterDictionaryTmp)
                    {
                        if (alive.Key == check.Key.getCharacterID.ToString())
                        {
                            isExist = true;

                            //New Movement
                            string   tmpXY          = alive.Value.ToString();
                            char[]   delimiterChars = { '(', ',', ')' };
                            string[] newXY          = tmpXY.Split(delimiterChars);
                            var      newX           = int.Parse(newXY[1]);
                            var      newY           = int.Parse(newXY[2]);
                            _gameBoard.SetObjectOnTile(newX, newY, check.Key.transform);
                            _characterDictionary[check.Key] = new Vector2Int(newX, newY);

                            //New Health
                            var newHealth = _characterDictionaryTmp[check.Key.getCharacterID.ToString() + " health"].ToString();
                            check.Key.remainingHealth = int.Parse(newHealth);

                            //New Overwatch
                            if (_characterDictionaryTmp.ContainsKey(check.Key.getCharacterID.ToString() + " overwatch"))
                            {
                                var      newOverwatch = _characterDictionaryTmp[check.Key.getCharacterID.ToString() + " overwatch"].ToString();
                                string[] overwatchXY  = newOverwatch.Split(delimiterChars);
                                var      overwatchX   = int.Parse(overwatchXY[1]);
                                var      overwatchY   = int.Parse(overwatchXY[2]);
                                _overwatchDictionaryTmp.Add(check.Key, new Vector2Int(overwatchX, overwatchY));
                            }
                        }
                    }

                    if (!isExist)
                    {
                        check.Key.isDead = true;
                    }
                }
                _overwatchDictionary = _overwatchDictionaryTmp;
            }
            else
            {
                Debug.Log("Data not received");
            }
        }
        var nextTurn = _Move.getNextTurn();

        Debug.Log("nextTurn - " + nextTurn);
        WhosTurn         = _playersDictionary[nextTurn];
        GUI.stateChanged = true;
        _reload          = true;
    }
 public void onMoveCompleted(MoveEvent move)
 {
     Log ("onMoveCompleted by : " + move.getSender());
     Debug.Log ("OnMoveCompleted"+move.getMoveData());
     if(move.getMoveData()!=null)
     m_apppwarp.moveCompleted (move.getSender (), move.getMoveData (), move.getNextTurn ());
 }
    public void OnMoveCompleted(MoveEvent move)
    {
        Debug.Log("Data: " + move.getMoveData());
        Debug.Log("OnMoveCompleted" + ", Next turn: " + move.getNextTurn() + ", Data: " + move.getMoveData() + " current Time: " + Time.time);

        if (move.getNextTurn() == userName)
        {
            Dictionary<string, object> _recData = Json.Deserialize(move.getMoveData()) as Dictionary<string, object>;
            OpponentLogic(_recData);
            isMyTurn = true;
        }
        else
        {
            isMyTurn = false;
        }
    }
Exemple #19
0
    public void OnMoveCompleted(MoveEvent move)
    {
        Debug.Log("move recieved from " + move.getSender());
        Debug.Log("OnMoveCompleted next turn is of player" + " " + move.getNextTurn());

        if (move.getSender() != userName)
        {
            Debug.Log("received move   " + move.getMoveData().ToString());
            ParseEnemyMove(move.getMoveData());
        }
    }
 public void OnMoveCompleted(MoveEvent move)
 {
     Debug.Log("OnMoveCompleted" + " " + move.getNextTurn() + " " + move.getMoveData());
     if (move.getNextTurn () == userName)
         isMyTurn = true;
     else isMyTurn = false;
 }
Exemple #21
0
    private void OnMoveCompleted(MoveEvent _Move)
    {
        if (_Move.getSender() != SC_Menu.Instance.userId)
        {
            Dictionary <string, object> _data = (Dictionary <string, object>)MiniJSON.Json.Deserialize(_Move.getMoveData());

            if (_data != null && _data.ContainsKey("Attack"))
            {
                attackNumber = int.Parse(_data["Attack"].ToString());
                for (int i = 0; i <= attackNumber; i++)
                {
                    string _cardName   = _data["CardName" + i].ToString();
                    string _healthLeft = _data["HealthLeft" + i].ToString();
                    CardAttack(_cardName, _healthLeft);
                }
            }

            if (_data.ContainsKey("NewCard1"))
            {
                string _cardName = _data["NewCard1"].ToString();
                PlaceNewCard(_cardName);
            }

            if (_data.ContainsKey("NewCard2"))
            {
                string _cardName = _data["NewCard2"].ToString();
                PlaceNewCard(_cardName);
            }

            if (_data.ContainsKey("Hero"))
            {
                int _heroHP = int.Parse(_data["Hero"].ToString());
                HeroAttack(_heroHP);
            }

            if (_data.ContainsKey("GameOver"))
            {
                gameover();
            }

            if (currentTurn == SC_GlobalEnums.turns.PlayerOne)
            {
                currentTurn = SC_GlobalEnums.turns.PlayerTwo;
            }
            else if (currentTurn == SC_GlobalEnums.turns.PlayerTwo)
            {
                currentTurn = SC_GlobalEnums.turns.PlayerOne;
            }

            UpdateGui();
            PlayerOneDraw();
            attackNumber = 0;
            screenList["Button_End_Turn"].SetActive(true);
        }


        if (_Move.getNextTurn() == SC_Menu.Instance.userId)
        {
            isMyTurn = true;
        }
        else
        {
            isMyTurn = false;
        }
    }
Exemple #22
0
 private void HandleOnMoveCompletedByPlayer(MoveEvent move)
 {
     currentTurnPlayerID = move.getNextTurn();
 }
    //CALLED WHEN SEND MOVE WAS SENT
    public void OnMoveCompleted(MoveEvent move)
    {
        Debug.Log ("OnMoveComplete : " + move.getMoveData ());
        //not my turn
        if (move.getNextTurn () == userName) {

            Dictionary<string,object> _recData = Json.Deserialize (move.getMoveData ()) as Dictionary<string,object>;

            float _xPos = float.Parse (_recData ["x position"].ToString ());
            float _zPos = float.Parse (_recData ["z position"].ToString ());
            float _fPos = float.Parse (_recData ["final position"].ToString ());
            float _fforce = float.Parse (_recData ["init force"].ToString ());
            int _totalMoveCount = int.Parse (_recData ["totalMoveCount"].ToString ());

            OpponentLogic (_xPos, _zPos,_fPos,_fforce,_totalMoveCount);

            Defined_Vars.isMyTurn = true;
        }
    }