Ejemplo n.º 1
0
    IEnumerator WaitForCut(int i)
    {
        yield return(new WaitForSeconds(1.2f));

        if (soil [i].getType() == Soil.SoilTypes.PLANTED)
        {
            soil [i].soilType = Soil.SoilTypes.PLOWED;
        }
        if (soil [i].getType() == Soil.SoilTypes.WATEREDANDPLATED)
        {
            soil [i].soilType = Soil.SoilTypes.PLOWED;
        }
        playerStamina.loseStamina(5);
    }
Ejemplo n.º 2
0
    IEnumerator WaitForTextureChange(int i)
    {
        yield return(new WaitForSeconds(1.5f));

        if (soil [i].getType() == Soil.SoilTypes.PLANTED)
        {
            soil [i].soilType = Soil.SoilTypes.WATEREDANDPLATED;
        }
        else
        {
            soil [i].soilType = Soil.SoilTypes.WATERED;
        }

        Debug.Log("Boom");
        playerStamina.loseStamina(5);
        soil [i].getSoil().GetComponent <Renderer> ().material = watterM;
    }
Ejemplo n.º 3
0
    //In this function a ray cast is thrown to check if we can plow the soil square
    //if we can, the soil will be plowed and its state will change

    public void plowSoil()
    {
        CreateSoil s = FindObjectOfType(typeof(CreateSoil)) as CreateSoil;

        soil = s.allSquares;
        for (int i = 0; i < soil.Count; i++)
        {
            if (soil [i].getSoil().GetComponent <SoilCollision> ().collision == true && soil [i].getType().Equals(Soil.SoilTypes.NOTPLOWED))
            {
                Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit))
                {
                    if (soil [i].getSoil().transform.gameObject.Equals(hit.transform.gameObject))
                    {
                        Debug.Log("Boom");
                        playerStamina.loseStamina(5);
                        StartCoroutine(waitForTextureChange(i));
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
    public void plantSeeds()
    {
        typeOfSeeds();
        CreateSoil sl = FindObjectOfType(typeof(CreateSoil)) as CreateSoil;

        soil = sl.allSquares;
        for (int i = 0; i < soil.Count; i++)
        {
            if (soil [i].getSoil().GetComponent <SoilCollision> ().collision == true && (soil [i].getType().Equals(Soil.SoilTypes.PLOWED) ||
                                                                                         soil [i].getType().Equals(Soil.SoilTypes.WATERED)))
            {
                Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit))
                {
                    if (soil [i].getSoil().transform.gameObject.Equals(hit.transform.gameObject))
                    {
                        removeSeedsButton();
                        playerStamina.loseStamina(5);
                        Transform s = Instantiate(seeds.transform, new Vector3((soil [i].getSoil().transform.position.x), 0f, soil [i].getSoil().transform.position.z), soil [i].getSoil().transform.rotation) as Transform;
                        s.SetParent(seedsParent);
                        if (soil [i].getType() == Soil.SoilTypes.WATERED)
                        {
                            soil [i].soilType = Soil.SoilTypes.WATEREDANDPLATED;
                        }
                        else
                        {
                            soil [i].soilType = Soil.SoilTypes.PLANTED;
                        }
                        break;
                    }
                }
            }
        }
    }