private void SpawnSphere(Realtime realtime)
 {
     Realtime.Instantiate("SpherePrefab",
                          position: spawnPosition.position,
                          rotation: Quaternion.identity,
                          ownedByClient: false,
                          preventOwnershipTakeover: false,
                          useInstance: realtime);
 }
 private void LayBomb()
 {
     //Debug.Log("PotentialToLayBomb");
     if (plan.bombPosition == runPosition && !myTeam.hasBomb)
     {
         bombBlast = Realtime.Instantiate(prefabName: "Bomb Blast", ownedByClient: true, preventOwnershipTakeover: true, useInstance: app.realtime);
         bombBlast.transform.position = transform.position;
         myTeam.hasBomb = true;
     }
 }
 private void SpawnCube(Realtime realtime)
 {
     //Instantiate the CubePlayer for this client once we've successfully connected to the room
     Realtime.Instantiate("NormcoreGrabbable",
                          position: spawnPosition.position,
                          rotation: Quaternion.identity,
                          ownedByClient: false,
                          preventOwnershipTakeover: false,
                          useInstance: realtime);
 }
 private void DidConnectToRoom(Realtime realtime)
 {
     // Instantiate the CubePlayer for this client once we've successfully connected to the room
     Realtime.Instantiate("CubePlayer",                   // Prefab name
                          position: Vector3.up,           // Start 1 meter in the air
                          rotation: Quaternion.identity,  // No rotation
                          ownedByClient: true,            // Make sure the RealtimeView on this prefab is owned by this client
                          preventOwnershipTakeover: true, // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
                          useInstance: realtime);         // Use the instance of Realtime that fired the didConnectToRoom event.
 }
Beispiel #5
0
        private void InstantiateNewObjectInWorld(string prefab, Realtime realtime, bool ownedByClient = false)
        {
            Vector3 startingPosition = new Vector3(Random.Range(-4, 4), 3, Random.Range(-4, 4));

            Realtime.Instantiate(prefab,                         // Prefab name
                                 position: startingPosition,     // Start 1 meter in the air
                                 rotation: Quaternion.identity,  // No rotation
                                 ownedByClient: ownedByClient,   // Make sure the RealtimeView on this prefab is owned by this client
                                 preventOwnershipTakeover: true, // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
                                 useInstance: realtime);         // Use the instance of Realtime that fired the didConnectToRoom event.
        }
Beispiel #6
0
    private void DidConnectToRoom(Realtime realtime)
    {
        // Instantiate the Player for this client once we've successfully connected to the room
        GameObject playerGameObject = Realtime.Instantiate(prefabName: "Networked Boat",   // Prefab name
                                                           ownedByClient: true,            // Make sure the RealtimeView on this prefab is owned by this client
                                                           preventOwnershipTakeover: true, // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
                                                           useInstance: realtime);         // Use the instance of Realtime that fired the didConnectToRoom event.

        // Get a reference to the player
        BoatMover player = playerGameObject.GetComponent <BoatMover>();
    }
 private void LayMine()
 {
     if (plan.minePosition == runPosition && !myTeam.hasMine)
     {
         GameObject placedMine = Realtime.Instantiate(prefabName: "Mine", ownedByClient: true, preventOwnershipTakeover: true, useInstance: app.realtime);
         placedMine.GetComponent <RealtimeTransform>().RequestOwnership();
         placedMine.transform.position = transform.position;
         myTeam.totalMines            -= 1;
         myTeam.UpdateMineCountDisplay();
         myTeam.hasMine = true;
     }
 }
Beispiel #8
0
    private void Update()
    {
        if (!_realtime.connected)
        {
            return;
        }

        // Start by figuring out which hand we're tracking
        XRNode node         = _hand == Hand.LeftHand ? XRNode.LeftHand : XRNode.RightHand;
        string leftTrigger  = "Oculus_CrossPlatform_PrimaryIndexTrigger";
        string rightTrigger = "Oculus_CrossPlatform_SecondaryIndexTrigger";

        // Get the position & rotation of the hand
        bool handIsTracking = UpdatePose(node, ref _handPosition, ref _handRotation);

        // Figure out if the trigger is pressed or not
        bool triggerPressed = Input.GetAxisRaw(leftTrigger) > 0.1f || Input.GetAxisRaw(rightTrigger) > 0.1f;

        // If we lose tracking, stop drawing
        if (!handIsTracking)
        {
            triggerPressed = false;
        }

        // If the trigger is pressed and we haven't created a new brush stroke to draw, create one!
        if (triggerPressed && _activeBrushStroke == null)
        {
            // Instantiate a copy of the Brush Stroke prefab.
            // GameObject brushStrokeGameObject = Instantiate(_brushStrokePrefab);
            GameObject brushStrokeGameObject = Realtime.Instantiate(_brushStrokePrefab.name, ownedByClient: true, useInstance: _realtime);
            brushStrokeGameObject.tag = "brushStroke";

            // Grab the BrushStroke component from it
            _activeBrushStroke = brushStrokeGameObject.GetComponent <BrushStroke>();

            // Tell the BrushStroke to begin drawing at the current brush position
            _activeBrushStroke.BeginBrushStrokeWithBrushTipPoint(transform.position, transform.rotation);
        }

        // If the trigger is pressed, and we have a brush stroke, move the brush stroke to the new brush tip position
        if (triggerPressed)
        {
            _activeBrushStroke.MoveBrushTipToPoint(transform.position, transform.rotation);
        }

        // If the trigger is no longer pressed, and we still have an active brush stroke, mark it as finished and clear it.
        if (!triggerPressed && _activeBrushStroke != null)
        {
            _activeBrushStroke.EndBrushStrokeWithBrushTipPoint(transform.position, transform.rotation);
            _activeBrushStroke = null;
        }
    }
Beispiel #9
0
 // Start is called before the first frame update
 void Start()
 {
     EventManager.OnTurnUpdate += InstantiateTimer;
     _realtime      = FindObjectOfType <Realtime>();
     globalTurnSync = FindObjectOfType <NetworkSyncManager>();
     if (globalTurnSync.currentSyncedTurn == 0 && (int)boatColor == 0)
     {
         personalTimer = Realtime.Instantiate(prefabName: "YellowTimer", ownedByClient: true, preventOwnershipTakeover: true, useInstance: _realtime);
     }
     else if (globalTurnSync.currentSyncedTurn == 1 && (int)boatColor == 1)
     {
         personalTimer = Realtime.Instantiate(prefabName: "RedTimer", ownedByClient: true, preventOwnershipTakeover: true, useInstance: _realtime);
     }
 }
Beispiel #10
0
    private void DidConnectToRoom(Realtime realtime)
    {
        Debug.Log("the client ID of the current player is - " + _realtime.clientID);
        // Instantiate the Player and Boat for this client once we've successfully connected to the room
        if (_realtime.clientID == 0)
        {
            GameObject playerAvatar = Realtime.Instantiate(prefabName: "Yellow Team Av",   // Prefab name
                                                           ownedByClient: true,            // Make sure the RealtimeView on this prefab is owned by this client
                                                           preventOwnershipTakeover: true, // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
                                                           useInstance: realtime);         // Use the instance of Realtime that fired the didConnectToRoom event.

            for (int i = 0; i < localRef.yellowStartPositions.Length; i++)
            {
                GameObject playerBoat = Realtime.Instantiate(prefabName: "Yellow Ship",
                                                             ownedByClient: true,
                                                             preventOwnershipTakeover: true,
                                                             useInstance: realtime);
                localRef.PlaceYellowBoats(playerBoat, i);
            }


            currentGameStatus = PlayerStatus.OnePlayer;
            //localRef.ConnectYellow();
        }

        if (_realtime.clientID == 1)
        {
            GameObject playerAvatar = Realtime.Instantiate(prefabName: "Red Team Av",      // Prefab name
                                                           ownedByClient: true,            // Make sure the RealtimeView on this prefab is owned by this client
                                                           preventOwnershipTakeover: true, // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
                                                           useInstance: realtime);         // Use the instance of Realtime that fired the didConnectToRoom event.

            for (int i = 0; i < localRef.yellowStartPositions.Length; i++)
            {
                GameObject playerBoat = Realtime.Instantiate(prefabName: "Red Ship",
                                                             ownedByClient: true,
                                                             preventOwnershipTakeover: true,
                                                             useInstance: realtime);
                localRef.PlaceRedBoats(playerBoat, i);
            }

            currentGameStatus = PlayerStatus.TwoPlayer;
            //localRef.ConnectRed();
        }



        // Get a reference to the player
        //BoatMover player = playerGameObject.GetComponent<BoatMover>();
    }
Beispiel #11
0
    void Start()
    {
        _realtimeView = GetComponent <RealtimeView>();

        if (_realtimeView.isOwnedLocally)
        {
            // Local player avatar, let's create a blarp!
            GameObject playerBlarpGameObject = Realtime.Instantiate(blarpPrefab.name, true, true, true);
            blarp = playerBlarpGameObject.GetComponent <PullTowardsHand>();


            GameObject playerBlarpGameObject1 = Realtime.Instantiate(shieldPrefab.name, true, true, true);
            shield = playerBlarpGameObject1.GetComponent <Paddle>();
        }
    }
    public virtual void StartDrawing(Vector3 startPosition)
    {
        drawingStartPosition = startPosition;
        // m_Shape = UnityEngine.Object.Instantiate(m_ShapeToClone, drawingStartPositionNonNull, Quaternion.identity, m_ParentTransform);
        m_Shape           = Realtime.Instantiate(shapeName);
        realtimeTransform = m_Shape.GetComponent <RealtimeTransform>();

        print("Instatiated " + m_Shape.name);
        print(realtimeTransform);
        realtimeTransform.RequestOwnership();

        m_Shape.transform.position = drawingEndPositionNonNull;
        m_Shape.transform.rotation = Quaternion.identity;
        m_Shape.transform.SetParent(m_ParentTransform);
    }
    // Update is called once per frame
    void Update()
    {
        if (!_realtime.connected)
        {
            return;
        }

        floatingSphere.transform.position = leftCont.position;

        if (Input.GetKeyDown("space"))
        {
            // GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            GameObject sphereObj = Realtime.Instantiate(spherePrefab.name, ownedByClient: true, useInstance: _realtime);
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow) || Bpressed.stateDown)
        {
            if (current_index == 0)
            {
                current_index = colors_list.Length - 1;
            }
            else
            {
                current_index -= 1;
            }
            AdjustPreviewSphere();
        }
        if (Input.GetKeyDown(KeyCode.RightArrow) || Apressed.stateDown)
        {
            if (current_index == colors_list.Length - 1)
            {
                current_index = 0;
            }
            else
            {
                current_index += 1;
            }
            AdjustPreviewSphere();
        }
        if (squeeze.axis > 0.8f)
        {
            Debug.Log("Squeezing");
            GameObject sphereObj = Realtime.Instantiate(spherePrefab.name, position: leftCont.position, rotation: leftCont.rotation, ownedByClient: true, useInstance: _realtime);
            sphereObj.GetComponent <Renderer>().material.color = _sphereModel.sphereColor;
        }
    }
Beispiel #14
0
    private void DidConnectToRoom(Realtime realtime)
    {
        Debug.Log("the client ID of the current player is - " + _realtime.clientID);
        // Instantiate the Player and Boat for this client once we've successfully connected to the room
        if (_realtime.clientID == 0)
        {
            GameObject playerAvatar = Realtime.Instantiate(prefabName: "Yellow Team Av",   // Prefab name
                                                           ownedByClient: true,            // Make sure the RealtimeView on this prefab is owned by this client
                                                           preventOwnershipTakeover: true, // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
                                                           useInstance: realtime);         // Use the instance of Realtime that fired the didConnectToRoom event.

            for (int i = 0; i < app.gameRefModel.yellowStartPositions.Length; i++)
            {
                GameObject playerBoat = Realtime.Instantiate(prefabName: "Yellow Ship",
                                                             ownedByClient: true,
                                                             preventOwnershipTakeover: true,
                                                             useInstance: realtime);
                PlaceBoats(playerBoat, i, GameRefModel.BoatColors.Yellow);
            }



            app.gameRefModel.localTeam = GameRefModel.BoatColors.Yellow;
        }

        if (_realtime.clientID == 1)
        {
            GameObject playerAvatar = Realtime.Instantiate(prefabName: "Red Team Av",      // Prefab name
                                                           ownedByClient: true,            // Make sure the RealtimeView on this prefab is owned by this client
                                                           preventOwnershipTakeover: true, // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
                                                           useInstance: realtime);         // Use the instance of Realtime that fired the didConnectToRoom event.

            for (int i = 0; i < app.gameRefModel.yellowStartPositions.Length; i++)
            {
                GameObject playerBoat = Realtime.Instantiate(prefabName: "Red Ship",
                                                             ownedByClient: true,
                                                             preventOwnershipTakeover: true,
                                                             useInstance: realtime);
                PlaceBoats(playerBoat, i, GameRefModel.BoatColors.Red);
            }


            app.gameRefModel.localTeam = GameRefModel.BoatColors.Red;
        }
    }
Beispiel #15
0
 private void InstantiateTimer()
 {
     if (app.networkSyncManager.currentSyncedTurn == 0 && (int)teamData.teamColor == 0)
     {
         personalTimer = Realtime.Instantiate(prefabName: "YellowTimer", ownedByClient: true, preventOwnershipTakeover: true, useInstance: realtime);
     }
     else if (app.networkSyncManager.currentSyncedTurn == 1 && (int)teamData.teamColor == 1)
     {
         personalTimer = Realtime.Instantiate(prefabName: "RedTimer", ownedByClient: true, preventOwnershipTakeover: true, useInstance: realtime);
     }
     else
     {
         if (personalTimer != null)
         {
             Realtime.Destroy(personalTimer);
         }
     }
 }
Beispiel #16
0
 void InstantiateTimer()
 {
     if (globalTurnSync.currentSyncedTurn == 0 && (int)boatColor == 0)
     {
         personalTimer = Realtime.Instantiate(prefabName: "YellowTimer", ownedByClient: true, preventOwnershipTakeover: true, useInstance: _realtime);
     }
     else if (globalTurnSync.currentSyncedTurn == 1 && (int)boatColor == 1)
     {
         personalTimer = Realtime.Instantiate(prefabName: "RedTimer", ownedByClient: true, preventOwnershipTakeover: true, useInstance: _realtime);
     }
     else
     {
         if (personalTimer != null)
         {
             Realtime.Destroy(personalTimer);
         }
     }
 }
Beispiel #17
0
 private void CheckToPlacePickup()
 {
     Debug.Log("the current turn count is" + currentTurn);
     if (app.realtime.clientID == 0)
     {
         if (currentTurn == nextPickupTurn)
         {
             int randomSpot = Random.Range(0, spawnPositions.Length);
             placedPickup = Realtime.Instantiate(prefabName: "Mine Pickup", ownedByClient: true, preventOwnershipTakeover: true, useInstance: app.realtime);
             placedPickup.GetComponent <RealtimeTransform>().RequestOwnership();
             placedPickup.transform.position = spawnPositions[randomSpot];
             nextPickupTurn  += turnsBetweenPickups;
             pickupExpiration = currentTurn + pickupDuration;
         }
         if (currentTurn == pickupExpiration)
         {
             Realtime.Destroy(placedPickup);
         }
     }
 }
Beispiel #18
0
    public void StartNewMessage()
    {
        if (connected)
        {
            print("connecsst");

            if (makingString == true)
            {
                print("TO MANNY MESSAGIS");
            }
            else
            {
                bigStringGO  = Realtime.Instantiate("BigStringBoy");
                bigStringBoy = bigStringGO.GetComponent <BigStringBoy>();
                bigStringGO.GetComponent <RealtimeTransform>().RequestOwnership();
                bigStringGO.GetComponent <RealtimeView>().RequestOwnership();
                bigStringGO.transform.position = transform.position + transform.forward;
                bigStringGO.transform.rotation = transform.rotation;
                makingString = true;
                print("yaayss");
            }
        }
    }
        private void DidConnectToRoom(Realtime realtime)
        {
            // Instantiate the Player for this client once we've successfully connected to the room
            GameObject playerGameObject = Realtime.Instantiate(prefabName: "Hoverbird Player",               // Prefab name
                                                               ownedByClient: true,                          // Make sure the RealtimeView on this prefab is owned by this client
                                                               preventOwnershipTakeover: true,               // Prevent other clients from calling RequestOwnership() on the root RealtimeView.
                                                               useInstance: realtime);                       // Use the instance of Realtime that fired the didConnectToRoom event.

            // Get a reference to the player
            HoverbirdPlayer player = playerGameObject.GetComponent <HoverbirdPlayer>();

            // Get the constraint used to position the camera behind the player
            ParentConstraint cameraConstraint = _camera.GetComponent <ParentConstraint>();

            // Add the camera target so the camera follows it
            ConstraintSource constraintSource = new ConstraintSource {
                sourceTransform = player.cameraTarget, weight = 1.0f
            };
            int constraintIndex = cameraConstraint.AddSource(constraintSource);

            // Set the camera offset so it acts like a third-person camera.
            cameraConstraint.SetTranslationOffset(constraintIndex, new Vector3(0.0f, 1.0f, -4.0f));
            cameraConstraint.SetRotationOffset(constraintIndex, new Vector3(15.0f, 0.0f, 0.0f));
        }
 void connectedToRoom(Realtime room)
 {
     Realtime.Instantiate("userPrefab");
 }
    private void Update()
    {
        if (!_realtime.connected)
        {
            return;
        }

        if (_realtime.clientID == _rt.ownerID)
        {
            // Start by figuring out which hand we're tracking
            XRNode node     = _hand == Hand.LeftHand ? XRNode.LeftHand : XRNode.RightHand;
            string trigger  = _hand == Hand.LeftHand ? "Left Trigger" : "Right Trigger";
            string joyclick = _hand == Hand.LeftHand ? "Left Joyclick" : "Right Joyclick";
            string axisY    = _hand == Hand.LeftHand ? "Left AxisY" : "Right AxisY";
            string axisX    = _hand == Hand.LeftHand ? "Left AxisX" : "Right AxisX";

            // Get the position & rotation of the hand
            bool handIsTracking = true; _handPosition = transform.position; _handRotation = transform.rotation;

            // Figure out if the trigger is pressed or not
            bool triggerPressed = Input.GetAxisRaw(trigger) > 0.1f;
            //bool triggerReleased = Input.GetAxisRaw(trigger) < 0.1f;

            //Figure out if the joystick is clicked or not
            bool joyclickPressed = Input.GetButtonDown(joyclick);

            // Figure out if the joystick / touchpad is pressed or not
            bool axisYMoved = Input.GetAxisRaw(axisY) < -0.2f || Input.GetAxisRaw(axisY) > 0.2f;
            //Debug.Log(Input.GetAxisRaw(axisY));
            bool axisXMoved = Input.GetAxisRaw(axisX) < -0.2f || Input.GetAxisRaw(axisX) > 0.2f;

            if (joyclickPressed)
            {
                Debug.Log("You pressed the joystick!");
                NextAction();
            }

            if (!axisXMoved)
            {
                didOnceX = false;
            }

            if (joyclickPressed)
            {
                SceneChanger sc = GameObject.FindObjectOfType <SceneChanger>();
                sc.Restart();
            }


            //actions if moving stuff should be handled by GazeXR
            if (action == 1)
            {
                // return; maybe still do TRIGGER stuff here at least!
                if (triggerPressed && !didOnceTrig)
                {
                    didOnceTrig = true;
                }

                if (triggerPressed && !didOnceTrig)
                {
                }

                if (!triggerPressed)
                {
                    didOnceTrig = false;
                }
            }

            //actions if drawing
            if (action == 0)
            {
                // If we lose tracking, stop drawing

                /*
                 * if (!handIsTracking)
                 * {
                 *  triggerPressed = false;
                 *  axisYMoved = false;
                 * }
                 */

                if (!axisYMoved)
                {
                    //Debug.Log("The Y Axis has NOT Moved");
                    //_brushPos.GetComponent<MeshRenderer>().enabled = false;
                }

                //If you move the joystick up or down, you're chaning the brush tip location
                if (axisYMoved && _brushPos.localPosition.z > 0f)
                {
                    //Debug.Log("The Y Axis has Moved");
                    //_brushPos.GetComponent<MeshRenderer>().enabled = true;
                    _brushPos.localPosition = new Vector3(_brushPos.localPosition.x, _brushPos.localPosition.y, _brushPos.localPosition.z - (Input.GetAxisRaw(axisY) * _speed));
                    VibrateControllers(.1f, .1f, .15f);
                }
                if (axisYMoved && _brushPos.localPosition.z <= 0.05f)
                {
                    _brushPos.localPosition = new Vector3(_brushPos.localPosition.x, _brushPos.localPosition.y, 0.05f);
                }

                //if you move the joystick left or right, you're changing the color
                if (axisXMoved)
                {
                    //_brushStrokePrefab.GetComponent<BrushStroke>().ResizeWidth(Input.GetAxisRaw(axisY) * (_speed/2));

                    /*
                     * Color newColor = new Color(brushMat.color.r - (Input.GetAxisRaw(axisY) * _speed), Random.value, Random.value, 1.0f);
                     * // apply it on  material
                     * brushMat.color = newColor;
                     */
                }


                // If the trigger is pressed and we haven't created a new brush stroke to draw, create one!
                if (triggerPressed && _activeBrushStroke == null)
                {
                    // Instantiate a copy of the Brush Stroke prefab, set it to be owned by us.
                    GameObject brushStrokeGameObject = Realtime.Instantiate(_brushStrokePrefab.name, ownedByClient: true, useInstance: _realtime);

                    // Make that brush stroke a child of the current state
                    //brushStrokeGameObject.transform.parent = currentOption.transform;

                    // Grab the BrushStroke component from it
                    _activeBrushStroke = brushStrokeGameObject.GetComponent <BrushStroke>();

                    // Tell the BrushStroke to begin drawing at the current brush position
                    _activeBrushStroke.BeginBrushStrokeWithBrushTipPoint(_brushPos.position, _handRotation);
                    VibrateControllers(.12f, .12f, .2f);
                }

                // If the trigger is pressed, and we have a brush stroke, move the brush stroke to the new brush tip position
                if (triggerPressed)
                {
                    _activeBrushStroke.MoveBrushTipToPoint(_brushPos.position, _handRotation);
                    VibrateControllers(.12f, .12f, .2f);
                    //_brushPos.GetComponent<MeshRenderer>().enabled = true;
                }


                // If the trigger is no longer pressed, and we still have an active brush stroke, mark it as finished and clear it.
                if (!triggerPressed && _activeBrushStroke != null)
                {
                    _activeBrushStroke.EndBrushStrokeWithBrushTipPoint(_brushPos.position, _handRotation);
                    _activeBrushStroke = null;
                    //_ot.gr.VibrateControllers(.24f, .12f, .4f);
                }
            }

            //actions if mask swapping
            if (action == 2)
            {
                if (axisXMoved && Input.GetAxisRaw(axisX) > 0 && !didOnceX)
                {
                    didOnceX = true;
                    VibrateControllers(.12f, .2f, .2f);
                }
                if (axisXMoved && Input.GetAxisRaw(axisX) < 0 && !didOnceX)
                {
                    didOnceX = true;
                    VibrateControllers(.2f, .12f, .2f);
                }
            }

            //actions if stage swapping
            if (action == 3)
            {
                if (axisXMoved && Input.GetAxisRaw(axisX) > 0 && !didOnceX)
                {
                    didOnceX = true;
                }
                if (axisXMoved && Input.GetAxisRaw(axisX) < 0 && !didOnceX)
                {
                    didOnceX = true;
                }
            }

            //actions if just squeezing your hands

            /*
             * if (action == 4)
             * {
             *  if (Input.GetAxisRaw(trigger) > 0.5f)
             *  {
             *      _ps.SetHandState(1);
             *  }
             *  else
             *  {
             *      _ps.SetHandState(0);
             *  }
             * } */
        }
    }