/// <summary>
 /// Call this func to display local player connected to the server
 /// the accepted name and returned color
 /// </summary>
 /// <param name="localName">Defined name</param>
 /// <param name="cutleryColor">Returned color</param>
 public void DisplayPlayerConnected(string localName, CutleryColor cutleryColor)
 {
     // call the func that will display this connection state
     // since the color is sented in a custom format, translate this to native color
     _connectionScreen.LocalClientConnected(localName,
                                            new Color(cutleryColor.R, cutleryColor.G, cutleryColor.B));
 }
 /// <summary>
 /// Call this func when the opponent player where reported to the client
 /// </summary>
 /// <param name="opName">Opponent name</param>
 /// <param name="cutleryColor">Opponent color</param>
 public void DisplayerConnectedOpponent(string opName, CutleryColor cutleryColor)
 {
     // call this func will display the opponet data
     // since the coloris sented in a custom format, translate this to native color
     _connectionScreen.OpponentClientConnected(opName,
                                               new Color(cutleryColor.R, cutleryColor.G, cutleryColor.B));
 }
    // func is called when a new player is spawned
    public void OnPlayerSpanw(Guid pId, string pName, int pNum, CutleryColor pColor,
                              bool isLocal, ClientNetworkController clientNetwork)
    {
        // save on func vars the id, name and color of the spawned player
        _playerId     = pId;
        _playerName   = pName;
        _playerColor  = new Color(pColor.R, pColor.G, pColor.B);
        _playerNumber = pNum;

        //the network manager defines if this player is the local player
        _isLocal = isLocal;


        // set the components to the info passed
        _playernameText.text    = _playerName;
        _playerColorImage.color = _playerColor;

        // load reference for the player score
        if (_playerNumber == 1)
        {
            // if player is the number 1 player
            // find and save the reference to the score displayer
            _ScoreDisplayer = GameObject.Find("Player1 scoreText").GetComponent <Text>();
            // find and save the reference to the score name displayer
            _scoreNameDisplayer = GameObject.Find("Player1ScoreName").GetComponent <Text>();
        }
        // if is the player 2
        else if (_playerNumber == 2)
        {
            Debug.Log("Player 2 setting goal box");
            //if player is the number 2 player
            // find and save the reference to the score displayer
            _ScoreDisplayer = GameObject.Find("Player2 scoreText").GetComponent <Text>();
            // find and save the reference to the score name displayer
            _scoreNameDisplayer = GameObject.Find("Player2ScoreName").GetComponent <Text>();
        }
        // set the player name and score
        _ScoreDisplayer.text     = "0";
        _scoreNameDisplayer.text = _playerName;

        // if is not a local , all the positions are controlled from the server
        if (!_isLocal)
        {
            // remove the rigidbody and the boxColider
            Destroy(_playerRigidbody);
            Destroy(GetComponent <BoxCollider2D>());

            // change the transparency of the nonLocal player
            _playerRenderer.color = new Color(_playerRenderer.color.r,
                                              _playerRenderer.color.g, _playerRenderer.color.b, 0.5f) * _playerColor;
        }
        else
        {
            //save the controller
            _clientNet = clientNetwork;
            // saving the old states
            _oldPosition = _playerTransform.position;
            // setting the jump state
            _lateJumpState = 0;
            // get the reference to the endGameScreenController
            _endScreenController = GameObject.Find("EndGameScreen").GetComponent <EndGameScreenController>();
        }
    }