Пример #1
0
    void SetDestinationToMousePosition()
    {
        if (!SocketClient.ActiveGameData.IsPlayerAndActive(PlayerId))
        {
            return; // its not this players turn.
        }
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit, 300, layerMask))
        {
            Protocol.MovePlayerProtocol movePlayer = new Protocol.MovePlayerProtocol()
            {
                player_id = PlayerId,
                position  = hit.point
            };

            // send the move to position to the server and update the local player :)
            SocketClient.ActiveSocket.QueueMessage(movePlayer);
            MoveAgentToPosition(hit.point);
        }

        loc = new Vector3((int)hit.point.x, hit.point.y, (int)hit.point.z);

        Debug.DrawRay(ray.origin, ray.direction * 500, Color.red);
    }
Пример #2
0
    private void MovePlayer(Protocol.BaseProtocol protocol)
    {
        Protocol.MovePlayerProtocol movePlayer = protocol as Protocol.MovePlayerProtocol;

        if (movePlayer.player_id == PlayerId)
        {
            MoveAgentToPosition(movePlayer.position);
        }
    }