예제 #1
0
파일: FoodBlob.cs 프로젝트: richardshi/mdp
    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
        }
    }
예제 #2
0
    /**
     * Use this for initialization
     * Gets the tower the menu is on and initializes values for drawing it when brought up
     */
    void Start()
    {
        // set all the sizes relative to screen size
        UPGRADE_BUTTON_WIDTH  = Screen.width * (76.5f / 1024f);         // Any size you want, multiply by 1.5 and divide by 1024 or 768
        UPGRADE_BUTTON_HEIGHT = Screen.height * (90f / 768f);
        SELL_BUTTON_WIDTH     = Screen.width * (165f / 1024f);
        SELL_BUTTON_HEIGHT    = Screen.height * (63f / 768f);

        // find the instestine game manager and store the reference
        m_GameManager = GameObject.Find("Managers").GetComponent <IntestineGameManager>();

        // find the reference to the tower script attached to the same tower this script is attached to
        m_Tower = gameObject.GetComponent <Tower>();


        doubleClickTime = 0.5f;
        clickTimer      = 0f;
    }
예제 #3
0
    private const float timer  = 2.0f;                          //!< a timer

    /**
     * Use for initialization
     * Finds debugger and checks if we are using it's values
     */
    void Start()
    {
        // make sure we aren't in tutorial
        if (Application.loadedLevelName != "SmallIntestineTutorial")
        {
            // if we aren't in the tutorial get a reference to the debugger
            debugConfig = ((GameObject)GameObject.Find("Debug Config")).GetComponent <DebugConfig>();

            // if we are using the debugger values get the tower base cost from there
            if (debugConfig.debugActive)
            {
                TOWER_BASE_COST = debugConfig.TOWER_BASE_COST;
            }
        }

        m_IsSpawnActive = false;                        // the spawn active should default to false

        // find a reference to the current intestine game manager
        m_GameManager = GameObject.Find("Managers").GetComponent <IntestineGameManager> ();
    }
예제 #4
0
    private bool m_CanFire;                                     //!< a flag that says whether a tower can currently fire

    /**
     * Use this for initialization
     * INitializes tower values on spawn
     */
    void Start()
    {
        gameObject.layer = LayerMask.NameToLayer("Tower");              // move the tower to the tower layer once placed

        // make sure we aren't in tutorial
        if (Application.loadedLevelName != "SmallIntestineTutorial")
        {
            // if we aren't in the tutorial get the debugger
            debugConfig = ((GameObject)GameObject.Find("Debug Config")).GetComponent <DebugConfig>();
            if (debugConfig.debugActive)                        // if we're using the debugger get the costs from there
            {
                TOWER_BASE_COST            = debugConfig.TOWER_BASE_COST;
                TOWER_UPGRADE_LEVEL_1_COST = debugConfig.TOWER_UPGRADE_LEVEL_1_COST;
                TOWER_UPGRADE_LEVEL_2_COST = debugConfig.TOWER_UPGRADE_LEVEL_2_COST;
            }
        }
        m_Cooldown        = BaseCooldown;                                                      // set the base cooldown
        m_CurrentCooldown = m_Cooldown;                                                        // initialize the cooldown timer
        m_CanFire         = true;                                                              // set that the tower can fire

        m_NutrientManager = GameObject.Find("Managers").GetComponent <NutrientManager>();      // find the nutrient manager
        m_GameManager     = GameObject.Find("Managers").GetComponent <IntestineGameManager>(); // find the game manager
    }
예제 #5
0
    private float distanceTravelled;                                            //!< to store the distance travelled by the particle

    /**
     * Use this for initialization
     */
    void Start()
    {
        // get a reference to the intestine game manager currently being used
        intestineGameManager = GameObject.Find("Managers").GetComponent <IntestineGameManager>();
        speed = Random.Range(.7f, 1f);
    }
예제 #6
0
    private Color Fats1Color = new Color(37f / 255f, 97f / 255f, 139f / 255f, 1);       //!< create a new color for the Fats1 Particles

    // Use this for initialization
    void Start()
    {
        zymeScript = ((GameObject)Instantiate(zyme)).GetComponent <ZymePopupScript> ();
        // get a reference to the intestine game manager currently being used
        gameManager = GameObject.Find("Managers").GetComponent <IntestineGameManager>();
    }
예제 #7
0
 // Use this for initialization
 void Start()
 {
     intestineGameManager = FindObjectOfType(typeof(IntestineGameManager)) as IntestineGameManager;
     zymeScript           = ((GameObject)Instantiate(zyme)).GetComponent <ZymePopupScript> ();
 }