示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (!progress)
        {
            if (Input.GetKeyDown("f"))
            {
                plow();
            }
            if (Input.GetKeyDown("y"))
            {
                curCategory = bag.getNextItemCategory();
                overlay.setCategory(curCategory);
            }
            if (Input.GetKeyDown("x"))
            {
                curItem = bag.getNextItem();
                overlay.setCurItem(curItem);
                overlay.setCurItemName(bag.getName(curItem));
            }
            if (Input.GetKeyDown("v"))
            {
                plant(curItem);
            }
            if (Input.GetKeyDown("enter"))
            {
                progress = true;
                bool down = true;
                while (down == true)
                {
                    if (GameObject.Find("Directional light").GetComponent <Light>().intensity > 0)
                    {
                        GameObject.Find("Directional light").GetComponent <Light>().intensity -= Time.deltaTime;
                    }
                    else
                    {
                        down = false;
                    }
                }

                foreach (KeyValuePair <long, GameObject> entry in world.tilelog)
                {
                    entry.Value.GetComponent <tileproperties>().grow();
                }
                bool up = true;
                while (up == true)
                {
                    if (GameObject.Find("Directional light").GetComponent <Light>().intensity < 1)
                    {
                        GameObject.Find("Directional light").GetComponent <Light>().intensity += Time.deltaTime;
                    }
                    else
                    {
                        up = false;
                    }
                }
                progress = false;
            }
        }
        else
        {
            if (Input.GetKeyDown("esc"))
            {
                //cancel current action
            }
        }
    }