Example #1
0
        public void SyncListUintTest()
        {
            SyncListUInt serverList = new SyncListUInt();
            SyncListUInt clientList = new SyncListUInt();

            serverList.Add(1U);
            serverList.Add(2U);
            serverList.Add(3U);
            SerializeDeltaTo(serverList, clientList);

            Assert.That(clientList, Is.EquivalentTo(new[] { 1U, 2U, 3U }));
        }
Example #2
0
        public void ReadonlyTest()
        {
            SyncListUInt serverList = new SyncListUInt();
            SyncListUInt clientList = new SyncListUInt();

            // data has been flushed,  should go back to clear
            Assert.That(clientList.IsReadOnly, Is.False);

            serverList.Add(1U);
            serverList.Add(2U);
            serverList.Add(3U);
            SerializeDeltaTo(serverList, clientList);

            // client list should now lock itself,  trying to modify it
            // should produce an InvalidOperationException
            Assert.That(clientList.IsReadOnly, Is.True);
            Assert.Throws <InvalidOperationException>(() => { clientList.Add(5U); });
        }
Example #3
0
 void DataToList(int width, int height, byte[,] data)
 {
     for (int i = 0; i < width * height;)
     {
         byte b1 = data[i % width, i / width];
         i++;
         byte b2 = data[i % width, i / width];
         i++;
         byte b3 = data[i % width, i / width];
         i++;
         byte b4 = data[i % width, i / width];
         i++;
         uint u = ((uint)b1 << 24) ^ ((uint)b2 << 16) ^ ((uint)b3 << 8) ^ ((uint)b4 << 0);
         serverData.Add(u);
     }
 }
    //CONVERTED
    public void MommaHit(GameObject goHit)
    {
        // Make a new object
        GameObject go = (GameObject)Instantiate(BabyPrefab, new Vector3(), new Quaternion());

        go.transform.position = goHit.transform.position;
        //TODO: Create reference for active player rigidbody
        go.GetComponent <SpringJoint>().connectedBody = activePlayer.GetComponent <NetworkedPlayer>().GetHand().GetComponent <Rigidbody>();

        go.GetComponent <Rigidbody>().drag           = .7f - (score / 100);
        go.GetComponent <Rigidbody>().mass           = .2f - (score / 340);
        go.GetComponent <Rigidbody>().angularDrag    = 200;
        go.GetComponent <Rigidbody>().freezeRotation = true;
        go.transform.localScale = go.transform.localScale * (2.0f - (score / 30));
        go.GetComponent <MeshRenderer>().material.SetFloat("_Score", (float)score);

        //audioSource.clip = AudioList[(int)score];

        //    go.GetComponent<SpringJoint>().enabled = false; connectedBody = HandR.GetComponent<Rigidbody>();
        NetworkServer.Spawn(go);
        BabyIDs.Add(go.GetComponent <NetworkIdentity>().netId);

        score++;
        Game.current.lastScore = score;
        if (score > Game.current.highScore)
        {
            Game.current.highScore = score;
        }

        ScoreText.GetComponent <TextMesh>().text = score.ToString();

        resizeRoom();
        moveMomma();

        int aLIndex = Random.Range(0, MommaHitAudioList.Length);

        MommaHitSound.clip = MommaHitAudioList[aLIndex];
        MommaHitSound.Play();
        RpcPlayMommaHitAudio(aLIndex);
    }
    private void SetupSyncedObjects()
    {
        //Spawn and Sync Room
        GameObject nRoom = (GameObject)Instantiate(roomPrefab, Vector3.zero, Quaternion.identity);

        NetworkServer.Spawn(nRoom);
        Room   = nRoom;
        roomId = Room.GetComponent <NetworkIdentity>().netId;

        //Spawn and Sync Platform
        GameObject targetCameraRig = GameObject.Find("[CameraRig](Clone)");

        if (targetCameraRig != null)
        {
            targetPlayAreaVertex = targetCameraRig.GetComponent <SteamVR_PlayArea>().vertices[0];
        }
        else
        {
            targetPlayAreaVertex = defaultPlatformVertex;
        }

        GameObject nPlat = (GameObject)Instantiate(PlatformPrefab, new Vector3(0f, -0.49f, 0f), Quaternion.identity);

        nPlat.transform.localScale = new Vector3(Mathf.Abs(targetPlayAreaVertex.x) * 1.5f, 1.0f, Mathf.Abs(targetPlayAreaVertex.z) * 1.5f);
        nPlat.GetComponent <MeshRenderer>().material.SetVector("_Size", nPlat.transform.localScale);
        nPlat.GetComponent <MeshRenderer>().material.SetFloat("_Learning", 0);
        NetworkServer.Spawn(nPlat);
        Platform   = nPlat;
        platformId = Platform.GetComponent <NetworkIdentity>().netId;



        //Spawn and Sync Title
        Vector3    tPos   = new Vector3(0f, 1.5f, -3f);
        GameObject nTitle = (GameObject)Instantiate(TitlePrefab, tPos, Quaternion.Euler(0, 180f, 0));

        nTitle.GetComponent <MeshRenderer>().material.SetVector("_Scale", nTitle.transform.localScale);
        NetworkServer.Spawn(nTitle);
        Title   = nTitle;
        titleId = Title.GetComponent <NetworkIdentity>().netId;


        //Spawn and Sync Highscore balls
        for (int i = 0; i < 10; i++)
        {
            float   rad = Random.Range(4, 10);
            Vector3 p   = Random.onUnitSphere * rad;

            GameObject nHSBall = (GameObject)Instantiate(HighScorePrefab, p, new Quaternion());
            nHSBall.transform.localScale = new Vector3(rad / 4, rad / 4, rad / 4);
            NetworkServer.Spawn(nHSBall);
            highScoreBalls.Add(nHSBall);
            SetHighScoreBallPitch(nHSBall);
            highScoreBallIDs.Add(nHSBall.GetComponent <NetworkIdentity>().netId);
        }
        setHighScoreBalls(Game.current.highScore);
        //RpcSetHighScoreBalls(Game.current.highScore);


        //Spawn and Sync Momma Ball
        GameObject nMom = (GameObject)Instantiate(MommaPrefab, new Vector3(0, 3, 0), new Quaternion());

        NetworkServer.Spawn(nMom);
        Momma     = nMom;
        mommaID   = Momma.GetComponent <NetworkIdentity>().netId;
        ScoreText = Momma.transform.Find("Score").gameObject;

        //Spawn and Sync MenuBaby
        GameObject nMBaby = (GameObject)Instantiate(BabyPrefab, new Vector3(0, 1, -2), Quaternion.identity);

        nMBaby.GetComponent <Rigidbody>().drag           = .7f - (score / 100);
        nMBaby.GetComponent <Rigidbody>().mass           = .2f - (score / 340);
        nMBaby.GetComponent <Rigidbody>().angularDrag    = 200;
        nMBaby.GetComponent <Rigidbody>().freezeRotation = true;
        nMBaby.transform.localScale = nMBaby.transform.localScale * (2.0f - (score / 30));
        nMBaby.GetComponent <MeshRenderer>().material.SetFloat("_Score", (float)score);
        nMBaby.GetComponent <TrailRenderer>().enabled = false;
        NetworkServer.Spawn(nMBaby);
        menuBaby   = nMBaby;
        menuBabyID = menuBaby.GetComponent <NetworkIdentity>().netId;

        //Spawn and Sync Start Button
        GameObject nSB = (GameObject)Instantiate(StartButtonPrefab, new Vector3(0, 1, -Platform.transform.localScale.z * .55f), new Quaternion());

        NetworkServer.Spawn(nSB);
        StartButton   = nSB;
        startButtonId = StartButton.GetComponent <NetworkIdentity>().netId;


        //Set active player to first spawn player object
        activePlayer = GameObject.Find("VRBlarpPlayer(Clone)");
        if (activePlayer == null)
        {
            activePlayer = GameObject.Find("NonVRBlarpPlayer(Clone)");
        }
        activePlayerId = activePlayer.GetComponent <NetworkIdentity>().netId;

        Room.GetComponent <RoomNetworked>().handL = activePlayer.GetComponent <NetworkedPlayer>().shield;
        Room.GetComponent <RoomNetworked>().handR = activePlayer.GetComponent <NetworkedPlayer>().hand;
        //activePlayerHand = GameObject.Find("handR");
        syncedObejctsSpawned = true;
        syncedObjectsSetUp   = true;
    }
Example #6
0
 public void AddTeammate(uint mob)
 {
     teammates.Add(mob);
 }