示例#1
0
    private void UpdatePlayers(RTPacket packet)
    {
        CheckPeers(packet, (index) =>
        {
            Transform playerTransform   = m_players[index].transform;
            Rigidbody2D playerRigidBody = m_players[index].GetComponent <Rigidbody2D>();
            Quaternion playerRot        = playerTransform.rotation;
            Vector3 playerAngles        = playerRot.eulerAngles;

            // Referenced from PlayerController.SendTransformUpdates()
            Vector3 newPos = packet.Data.GetVector3(1).Value;
            Signs sign     = (Signs)packet.Data.GetInt(2);
            newPos         = SignsExt.Vector3Sign(newPos, sign);

            float newRot   = packet.Data.GetFloat(3).Value;
            Vector2 newVel = packet.Data.GetVector2(4).Value;
            newVel         = SignsExt.Vector2Sign(newVel, (Signs)packet.Data.GetInt(5));

            playerTransform.position = newPos;
            playerRigidBody.velocity = newVel;
            playerAngles.z           = newRot;
            playerRot.eulerAngles    = playerAngles;

            playerTransform.rotation = playerRot;
        });
    }
示例#2
0
    private void UpdateEnemiesSpawn(RTPacket packet)
    {
        RTData data = packet.Data;

        int     id       = data.GetInt(1).Value;
        Vector2 position = data.GetVector2(3).Value;

        position = SignsExt.Vector2Sign(position, (Signs)data.GetInt(4).Value);
        float   rotation = data.GetFloat(5).Value;
        Vector2 velocity = data.GetVector2(6).Value;

        velocity = SignsExt.Vector3Sign(velocity, (Signs)data.GetInt(7).Value);

        m_enemyGenerator.GenerateEnemy(id, position, rotation, velocity, true);
    }