Esempio n. 1
0
    public GameObject nutrientLostSound;                        //!< for holding a reference to the nutrient lost sound

    /**
     * the function to generate what nutrients are on the food blob
     */
    public void GenerateEnzymes(int minNutrients, int maxNutrients, Color[] availableColors)
    {
        NumNutrients = Random.Range(minNutrients, maxNutrients + 1);                    // randomly choose the number of nutrients on the blob

        // find a reference to the current nutrient manager and game manager
        m_NutrientManager = FindObjectOfType(typeof(NutrientManager)) as NutrientManager;
        m_GameManager     = FindObjectOfType(typeof(IntestineGameManager)) as IntestineGameManager;

        // populate the number of nutrients decided earlier
        for (int i = 0; i < NumNutrients; i++)
        {
            float radius = .4f;                                         // choose .4f as a radius to start with
            float angle  = ((2 * Mathf.PI) / NumNutrients) * i;         // divide the circle into the right number of angle chunks in rads
            float xPos   = radius * Mathf.Cos(angle);                   // find the x position as radius*cos(theta)
            float zPos   = radius * Mathf.Sin(angle);                   // find the y position as radius*sin(theta)

            Vector3 position = transform.position;                      // 3 dimensional vector for position
            position.x += xPos;                                         // set the x position of the vector
            position.z += zPos;                                         // set the z position of the vector
            position.y  = .5f;                                          // set the y position of the vector

            // randomly choose a color for the nutrient
            int      randomIndex = MDPUtility.RandomInt(availableColors.Length);
            Nutrient nutrient    = m_NutrientManager.InstantiateNutrient(availableColors[randomIndex], position);
            nutrient.intestineGameManager = m_GameManager;                      // assign the game manager reference on the nutrient to be
            // the same as the one referenced in this class

            // Attach new enzyme as a child object
            nutrient.transform.parent = gameObject.transform;
            ((Behaviour)nutrient.GetComponent("Halo")).enabled = false;                 // halo should be false unless explicitly enabled
        }
    }
Esempio n. 2
0
 void UpdateAppearUI()
 {
     cameraPosition = GameManager.GetGameManagerInstance().GetCameraPosition();
     if (cameraPosition == GameManager.CameraPosition.Out)
     {
         Calender.GetComponent <MeshRenderer>().enabled     = true;
         Nutrient.GetComponent <MeshRenderer>().enabled     = false;
         ShelterStats.GetComponent <MeshRenderer>().enabled = false;
         TurnEndButton.SetActive(true);
         UpgradeButton.SetActive(false);
     }
     else if (cameraPosition == GameManager.CameraPosition.Mid)
     {
         Calender.GetComponent <MeshRenderer>().enabled     = true;
         Nutrient.GetComponent <MeshRenderer>().enabled     = true;
         ShelterStats.GetComponent <MeshRenderer>().enabled = false;
         TurnEndButton.SetActive(true);
         UpgradeButton.SetActive(true);
     }
     else if (cameraPosition == GameManager.CameraPosition.In)
     {
         Calender.GetComponent <MeshRenderer>().enabled     = true;
         Nutrient.GetComponent <MeshRenderer>().enabled     = true;
         ShelterStats.GetComponent <MeshRenderer>().enabled = true;
         TurnEndButton.SetActive(true);
         UpgradeButton.SetActive(true);
     }
     else if (cameraPosition == GameManager.CameraPosition.Default)
     {
         Debug.Log("cameraPosition : Default");
     }
     else
     {
         Debug.LogError("Invalid input at 'UpdateAppearUI' method");
     }
 }