Ejemplo n.º 1
0
    //recebe do servidor uma pickedupsheep message
    private void OnReceivePickedUpSheepMessage(NetworkMessage _message)
    {
        PickedUpSheepMessage _msg = _message.ReadMessage <PickedUpSheepMessage>();

        if (_msg.playerName != transform.name)
        {
            sheepManager.GetComponent <SheepAI>().processPickedUpSheepMessage(_msg);
        }
    }
    public void SendPickedUpSheepMessage(string _sheepID, Vector3 _position, Quaternion _rotation, float _timeTolerp, int state, int anim_index)
    {
        PickedUpSheepMessage _msg = new PickedUpSheepMessage()
        {
            playerName     = transform.name,
            sheepName      = _sheepID,
            sheepPosition  = _position,
            sheepRotation  = _rotation,
            time           = _timeTolerp,
            sheepState     = state,
            sheepAnimation = anim_index
        };

        //NetworkServer.SendToAll(sheep_movement_msg, _msg);
        NetworkManager.singleton.client.Send(picked_up_sheep_message, _msg);
    }
    public void processPickedUpSheepMessage(PickedUpSheepMessage _msg)
    {
        GameObject sheep = GameObject.Find(_msg.sheepName);

        if (sheep != null)
        {
            SheepMovement sheep_movement = sheep.GetComponent <SheepMovement>();
            Rigidbody     sheep_rb       = sheep.GetComponent <Rigidbody>();

            sheep_rb.velocity        = Vector3.zero;
            sheep_rb.angularVelocity = Vector3.zero;
            sheep_rb.useGravity      = false;

            sheep_movement.setPickedUpBy(_msg.playerName);
            sheep_movement.setState(_msg.sheepState);
            sheep_movement.localMove(_msg.sheepPosition, _msg.sheepRotation, _msg.time, _msg.sheepAnimation);
        }
    }
Ejemplo n.º 4
0
    public void SendPickedUpSheep(NetworkMessage _message)
    {
        PickedUpSheepMessage _msg = _message.ReadMessage <PickedUpSheepMessage>();

        NetworkServer.SendToAll(picked_up_sheep_message, _msg);
    }