Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        elapsedTime += Time.deltaTime;
        if (scoreType == "Tree" && gameIsOver == false)
        {
            GameObject[] trees = GameObject.FindGameObjectsWithTag("Tree");
            treeValue  = trees.Length;
            score.text = "Trees: " + treeValue;
        }
        if (scoreType == "Score" && elapsedTime > timeLimit)
        {
            elapsedTime = 0;
            GameObject[] trees = GameObject.FindGameObjectsWithTag("Tree");
            treeValue = 0;
            for (int i = 0; i < trees.Length; i++)                                           // For every tile in range
            {
                Script_Tree other_Script = trees[i].gameObject.GetComponent <Script_Tree>(); // Get the Script
                if (other_Script.state == "Alive")
                {
                    treeValue += 2;
                }
            }

            globalScore += treeValue;
            score.text   = globalScore.ToString();
        }
        if (alreadyMoved == false)
        {
            LookForGameOver();
        }
    }
Ejemplo n.º 2
0
    void LookForGameOver()
    {
        GameObject[] go = GameObject.FindGameObjectsWithTag("Tree");
        for (int i = 0; i < go.Length; i++)
        {
            Script_Tree script_t = go[i].gameObject.GetComponent <Script_Tree>();// Get the Script

            if (script_t.state == "Alive")
            {
                return;
            }
        }
        GoToGameOver();
    }
Ejemplo n.º 3
0
    void Update()
    {
        if (goTree != null) // Check if the tile has a tree
        {
            if (forest == true)
            {
                GenerateForest();
            }
            elapsedTime += Time.deltaTime;

            if (elapsedTime > timeLimit)     // Check the time
            {
                elapsedTime = 0;
                Script_Tree goTree_Script = goTree.GetComponent <Script_Tree>();

                Collider[] hitColliders = Physics.OverlapSphere(transform.position, 1.5f); //get every tile in range of the main tile

                for (int i = 0; i < hitColliders.Length; i++)                              // For every tile in range
                {
                    if (goTree_Script.state == "Alive")
                    {
                        if (hitColliders[i].tag == "Ground")                                                    // Check for grow
                        {
                            Script_Tile other_Script = hitColliders[i].gameObject.GetComponent <Script_Tile>(); // Get the Script
                            if (other_Script.goTree == null)                                                    // Check that it has no tree
                            {
                                other_Script.GenerateTree(false);
                            }
                        }
                    }



                    if (goTree_Script.infectionStage > 0)
                    {
                        if (hitColliders[i].tag == "Tree")
                        {
                            Script_Tree other_Script = hitColliders[i].gameObject.GetComponent <Script_Tree>(); // Get the Script
                            if (other_Script.infectionStage == 0)                                               // Check that it has no tree
                            {
                                other_Script.Resist();
                            }
                        }
                    }
                }
            }
        }
    }