예제 #1
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;
        }
    }
    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();
        }
    }
예제 #4
0
    //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++;
    }
예제 #5
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();
         }
     }
 }
예제 #6
0
        public void onMoveCompleted(MoveEvent move)
        {
            Log(move.getMoveData());

            /*string Move = move.getMoveData ();
             * int i = int.Parse (Move [0].ToString());
             * int j = int.Parse (Move [1].ToString());
             * int k = int.Parse (Move [2].ToString());
             * Log (i + "  " + j + "  " + k);
             */
        }
 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));
         }
     }
 }
예제 #8
0
 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;
             }
         }
     }
 }
예제 #9
0
 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;
     }
 }
예제 #10
0
 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());
     }
 }
예제 #11
0
    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);
    }
예제 #12
0
    private void SetEnemyPieces(MoveEvent _Move)
    {
        Dictionary <string, object> _recievedData = MiniJSON.Json.Deserialize(_Move.getMoveData()) as Dictionary <string, object>;

        if (_recievedData != null)
        {
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    print("EnemyPlayer " + i + "-" + j + ": " + _recievedData[i + "-" + j]);
                    gameBoard[9 - i][9 - j].piece.pieceStrengh = (SC_MultiPlayer_Globals.SoldierRank)Enum.Parse(typeof(SC_MultiPlayer_Globals.SoldierRank), _recievedData[i + "-" + j].ToString());
                }
            }

            //ProccessMove(_recievedData);
            boolGetEnemyData = true;
        }
    }
예제 #13
0
 public void OnMoveCompleted(MoveEvent move)
 {
     Debug.Log("OnMoveCompleted" + " " + move.getNextTurn() + " " + move.getMoveData());
     if (move.getNextTurn () == userName)
         isMyTurn = true;
     else isMyTurn = false;
 }
예제 #14
0
 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;
        }
    }
예제 #16
0
    private void OnMoveCompleted(MoveEvent _Move)
    {
        Dictionary <string, object> _data = (Dictionary <string, object>)MiniJSON.Json.Deserialize(_Move.getMoveData());

        currentTime = startTime;

        managePlayersClock(_Move);

        if (_data != null && _data.ContainsKey("firstPokemonID") && _data.ContainsKey("battleBackgroundIndex") && _Move.getSender() != SC_MenuLogic.Instance.userId)
        {
            initBattle();
            Img_battleBG.sprite = battleBackgrounds[int.Parse(_data["battleBackgroundIndex"].ToString())];

            if (SC_DeckMenuLogic.currentCardIndex == -1)
            {
                initPlayer(000, SC_DeckMenuLogic.currentSliderValue);
            }
            else
            {
                initPlayer(SC_GameLogic.allPokemons[SC_DeckMenuLogic.currentCardIndex].ID, SC_DeckMenuLogic.currentSliderValue);
            }

            initFoe(int.Parse(_data["firstPokemonID"].ToString()), SC_DeckMenuLogic.currentSliderValue);

            Dictionary <string, object> _toSend = new Dictionary <string, object>();
            _toSend.Add("secondPokemonID", playerPokemon.ID);
            string _send = MiniJSON.Json.Serialize(_toSend);
            WarpClient.GetInstance().sendMove(_send);
        }
        else if (_data != null && _data.ContainsKey("secondPokemonID") && _Move.getSender() != SC_MenuLogic.Instance.userId)
        {
            initFoe(int.Parse(_data["secondPokemonID"].ToString()), SC_DeckMenuLogic.currentSliderValue);

            Dictionary <string, object> _toSend = new Dictionary <string, object>();
            _toSend.Add("startBattle", true);
            string _send = MiniJSON.Json.Serialize(_toSend);
            WarpClient.GetInstance().sendMove(_send);
        }
        else if (_data != null && _data.ContainsKey("startBattle"))
        {
            SC_GameLogic.EnterBattle(true);
            isInBattle    = true;
            isMultiplayer = true;

            if (_Move.getSender() != SC_MenuLogic.Instance.userId)
            {
                PlayerTimeLeft.enabled = true;
                FoeTimeLeft.enabled    = false;
            }
            else if (_Move.getSender() == SC_MenuLogic.Instance.userId)
            {
                FoeTimeLeft.enabled    = true;
                PlayerTimeLeft.enabled = false;
            }
        }

        if (_data != null && _data.ContainsKey("attackMoveID") && _Move.getSender() != SC_MenuLogic.Instance.userId)
        {
            int _attackMoveID = int.Parse(_data["attackMoveID"].ToString());
            currentTurn            = GlobalEnums.Turns.FoesTurn;
            isFoeAttackingATM      = true;
            isSelectionMenuEnabled = false;
            isMovesMenuEnabled     = false;
            isWaitingForRespond    = true;
            AttackOpponent(foePokemon, SC_GameLogic.getMoveByID(_attackMoveID), playerPokemon);
            isFoeAttackingATM = false;
            return;
        }
        else if (_data != null && _data.ContainsKey("attackMoveID") && _Move.getSender() == SC_MenuLogic.Instance.userId)
        {
            return;
        }

        handleRunnigFromBattle(_Move, _data);
        handleLostOfTime(_Move, _data);

        switchTurns(_Move);
    }
예제 #17
0
    public void onMoveCompleted(MoveEvent move)
    {
        Log("Move Completed by : " + move.getSender() + "Move data  : " + move.getMoveData());

        FireOnMoveCompletedByPlayer(move);
    }
예제 #18
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());
        }
    }
예제 #19
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;
        }
    }
예제 #20
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;
        }
    }
예제 #21
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;
            }
        }
    }
예제 #22
0
 public void onMoveCompleted(MoveEvent move)
 {
     notifications+="onMoveCompleted  username" + move.getSender()+ " move  "+move.getMoveData()+"\n";
     Debug.Log ("onMoveCompleted by : " + move.getSender());
 }
예제 #23
0
    public void OnMoveCompleted(MoveEvent _Move)
    {
        temp = JsonUtility.FromJson <msgJson>(_Move.getMoveData());

        if (temp != null)
        {
            if (temp.msgSend == "OwnerReady" && !isOwner)
            {
                myTurn = true;
                if (SC_Multyplayer_Globals.Instance.numberOfShips == 0)
                {
                    statusStartGame();
                    return;
                }
            }
            if (temp.msgSend == "Ready")
            {
                startGame();
                return;
            }

            if (temp.msgSend == "shoot" && !myTurn)
            {
                string tempMsg;
                isHit = checkedForHit(temp.index);
                if (isHit)
                {
                    SC_Multyplayer_Globals.Instance.mainBtnObjects["Main_Btn (" + temp.index + ")"].GetComponent <Image>().color = new Color(255, 0, 0, 255);
                    tempMsg = "isHit";
                    SC_Multyplayer_Globals.Instance.PlayerShips--;
                    if (SC_Multyplayer_Globals.Instance.PlayerShips == 0)
                    {
                        tempMsg = "EndGame";
                    }
                }
                else
                {
                    SC_Multyplayer_Globals.Instance.mainBtnObjects["Main_Btn (" + temp.index + ")"].GetComponent <Image>().color = new Color(113, 113, 113, 255);
                    tempMsg = "miss";
                }
                SendPlayerMove(temp.index, tempMsg);
            }

            if (temp.msgSend == "isHit" && myTurn)
            {
                SC_Multyplayer_Globals.Instance.EnemyBtnObjects["Enemy_Btn (" + temp.index + ")"].GetComponent <Image>().color = new Color(255, 0, 0, 255);

                SendPlayerMove(temp.index, "switchTurn");
            }

            if (temp.msgSend == "miss" && myTurn)
            {
                Debug.Log("miss");
                SC_Multyplayer_Globals.Instance.EnemyBtnObjects["Enemy_Btn (" + temp.index + ")"].GetComponent <Image>().color = new Color(113, 113, 113, 255);
                SendPlayerMove(temp.index, "switchTurn");
            }

            if (temp.msgSend == "EndGame")
            {
                SC_Multyplayer_Globals.Instance.MultiplayerObjects["Panel_EndGame"].SetActive(true);
                if (SC_Multyplayer_Globals.Instance.PlayerShips == 0)
                {
                    SC_Multyplayer_Globals.Instance.MultiplayerObjects["Txt_EndGame"].GetComponent <Text>().text = "You Lose";
                }
                else
                {
                    SC_Multyplayer_Globals.Instance.MultiplayerObjects["Txt_EndGame"].GetComponent <Text>().text = "You Win !";
                }
                WarpClient.GetInstance().stopGame();
            }

            if (temp.msgSend == "Timeout")
            {
                SC_Multyplayer_Globals.Instance.MultiplayerObjects["Panel_EndGame"].SetActive(true);
                SC_Multyplayer_Globals.Instance.MultiplayerObjects["Txt_EndGame"].GetComponent <Text>().text = "Timeout";
            }

            if (temp.msgSend == "switchTurn")
            {
                if (myTurn == true)
                {
                    myTurn = false;
                    SC_Multyplayer_Globals.Instance.MultiplayerObjects["logs"].GetComponent <Text>().text = "Rival Turn";
                }
                else
                {
                    myTurn = true;
                    SC_Multyplayer_Globals.Instance.MultiplayerObjects["logs"].GetComponent <Text>().text = "Your Turn";
                }
            }
        }
        else
        {
            SendPlayerMove(0, "Timeout");
        }
    }
예제 #24
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;
    }
    //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;
        }
    }