Пример #1
0
    private void ResetNorthMagnets()
    {
        // Find all placed north magnets in the map
        northMagnetsPlaced = GameObject.FindGameObjectsWithTag("NorthMagnet");
        // If there are magnets that have been placed
        // Cycle through northMagnetsPlaced array and set their velocities to 0
        // Set gameobjects to false
        if (northMagnetsPlaced.Length > 0)
        {
            foreach (GameObject northMagnet in northMagnetsPlaced)
            {
                northMagnet.GetComponent <Rigidbody>().velocity = Vector3.zero;
                northMagnet.SetActive(false);
            }
        }
        else
        {
            debugText.text = "No north magnets in the puzzle";
        }

        // Reset ballsPlaced variable in BetaMagnetPlacement class
        betaManager.Reset();
        // Attach magnet to oculus go remote
        betaManager.MagnetAttach();
    }
Пример #2
0
    private void MagnetPlace(Vector3 targetPos)
    {
        // Check if all given magnets are not placed
        // and there is an attached magnet
        if (ballsPlaced < betaManager.MaxPlaceableMagnets && magnetAttach.IsMagnetAttached == true)
        {
            magnetAttach.IsMagnetAttached = false;                                // A magnet has been placed, set IsMagnetAttached to false
            ballsPlaced++;                                                        // Increment number of balls placed by one
            magnetSpawnPointTrans.GetComponent <Transform>().DetachChildren();    // Detach magnet from spawn point's transform
            GameObject magnet             = magnetAttach.currentMagnet;
            Transform  magnetTrans        = magnet.GetComponent <Transform>();
            Canvas     magnetRadiusCanvas = magnet.GetComponentInChildren <Canvas>(); // Turns on canvas used for seeing magnet's radius

            magnetTrans.position       = targetPos;                                   // Set parsed in target position to position of magnet to be placed
            magnetTrans.rotation       = Quaternion.Euler(0, 0, 0);                   // Set rotation of magnet to 0 on all axes
            magnetRadiusCanvas.enabled = true;                                        // Turns on canvas for seeing magnets radius

            magnetTrans.SetParent(gameManager.FindActivePuzzle().GetComponent <Transform>());

            // If there are more balls to be placed
            // attach another magnet to the end of the remote
            if (ballsPlaced != betaManager.MaxPlaceableMagnets)
            {
                betaManager.MagnetAttach();
            }

            // Play magnet place sound
            AudioManager.Instance.Play("BetaMagnetPlace");
        }
    }
Пример #3
0
 // Method for going to the next puzzle or complete the level
 // Sets MaxPlaceableMagnets in the beta level manager to the MaxMagnets of the next puzzle
 private void NextLevelOrPuzzle()
 {
     // If the next calculated puzzle return as null go to the next level
     if (GameManager.Instance.FindNextPuzzle(GameManager.Instance.FindActivePuzzle()) == null)
     {
         // Play photon shoot sound
         AudioManager.Instance.Play("PhotonShoot");
         // Call level completed method in the game manager
         GameManager.Instance.LevelCompleted();
         // Find and disable magnet counter
         GameObject.Find("Magnet Counter Canvas").SetActive(false);
     }
     else
     {
         // Play photon shoot sound
         AudioManager.Instance.Play("PhotonShoot");
         // Go to the next puzzle if there is one
         GameManager.Instance.NextPuzzle();
         betaSetMaxMagnets = GameObject.Find(GameManager.Instance.FindActivePuzzle().name).GetComponent <BetaSetMaxMagnets>();
         // Set the max placeable magnets for the next puzzle
         betaLevelManager.MaxPlaceableMagnets = betaSetMaxMagnets.maxMagnets;
         // Reset the puzzle
         betaLevelManager.Reset();
         // Attach a new magnet
         betaLevelManager.MagnetAttach();
     }
 }