示例#1
0
文件: ring.cs 项目: Fatty-AR/Fatty-AR
    // Update is called once per frame
    void Update()
    {
        if (currentAmout < targetProcess)
        {
            controller.enabled        = false;
            switchButton.interactable = false;
            //Debug.Log("currentAmount:" + currentAmout.ToString());
            currentAmout += speed;
            if (currentAmout > targetProcess)
            {
                currentAmout = targetProcess;
            }
            indicator.GetComponent <Text>().text      = ((int)currentAmout).ToString() + "%";
            process.GetComponent <Image>().fillAmount = currentAmout / 100.0f;
        }
        else
        {
            satisfiedBar.size += 0.08f;
            healthBar.size    += 0.05f;
            if (satisfiedBar.size >= 0.75f)
            {
                cb                  = satisfiedBar.colors;
                cb.normalColor      = Color.red;
                satisfiedBar.colors = cb;
                if (canexit == false)
                {
                    Vector3       exitposition;
                    System.Random randomnum   = new System.Random();
                    System.Random positionnum = new System.Random();
                    int           key         = randomnum.Next(1, 12);
                    if (key >= 1 && key <= 3)
                    {
                        exitposition.x = -3.7f;
                        int posi = positionnum.Next(0, 6);
                        exitposition.z = posi - 3;
                        exitposition.y = 0.0f;
                    }
                    else if (key >= 4 && key <= 6)
                    {
                        exitposition.x = 3.7f;
                        int posi = positionnum.Next(0, 6);
                        exitposition.z = posi - 3;
                        exitposition.y = 0.0f;
                    }
                    else if (key >= 7 && key <= 9)
                    {
                        exitposition.z = -2.5f;
                        int posi = positionnum.Next(0, 10);
                        exitposition.x = posi - 5;
                        exitposition.y = 0.0f;
                    }
                    else
                    {
                        exitposition.z = 2.5f;
                        int posi = positionnum.Next(0, 10);
                        exitposition.x = posi - 5;
                        exitposition.y = 0.0f;
                    }
                    GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    cube.transform.position = exitposition;
                    canexit = true;

                    if (satisfiedBar.size >= 1.0f)
                    {
                        controller.enabled = false;
                    }
                }
            }
            currentAmout              = 0;
            controller.enabled        = true;
            switchButton.interactable = true;
            circle.SetActive(false);
            process.GetComponent <Image>().fillAmount = 0;
            eatScript.SizeUp();
            AddBuff();
        }
    }
示例#2
0
文件: ring.cs 项目: Fatty-AR/Fatty-AR
    // Update is called once per frame
    void Update()
    {
        if (currentAmout < targetProcess)
        {
            eating                    = true;
            controller.enabled        = false;
            switchButton.interactable = false;
            //Debug.Log("currentAmount:" + currentAmout.ToString());
            currentAmout += speed;
            if (currentAmout > targetProcess)
            {
                currentAmout = targetProcess;
            }
            indicator.GetComponent <Text>().text      = ((int)currentAmout).ToString() + "%";
            process.GetComponent <Image>().fillAmount = currentAmout / 100.0f;
        }
        else
        {
            eating             = false;
            satisfiedBar.size += 0.08f;
            healthBar.size    += 0.05f;
            if (satisfiedBar.size >= 0.75f)
            {
                if (canexit == false)
                {
                    Vector3       exitposition;
                    Vector3       exitrotation;
                    System.Random randomnum   = new System.Random();
                    System.Random positionnum = new System.Random();
                    int           key         = randomnum.Next(1, 4);
                    if (key == 1)
                    {
                        exitposition.x = -3.8f;
                        int posi = positionnum.Next(0, 5);
                        exitposition.z = posi - 3;
                        exitposition.y = 0.0f;
                        exitrotation.x = 0.0f;
                        exitrotation.y = 90.0f;
                        exitrotation.z = 0.0f;
                    }
                    else if (key == 2)
                    {
                        exitposition.x = 4.4f;
                        int posi = positionnum.Next(0, 5);
                        exitposition.z = posi - 3;
                        exitposition.y = 0.0f;
                        exitrotation.x = 0.0f;
                        exitrotation.y = -90.0f;
                        exitrotation.z = 0.0f;
                    }
                    else if (key == 3)
                    {
                        exitposition.z = -3.1f;
                        int posi = positionnum.Next(0, 8);
                        exitposition.x = posi - 4;
                        exitposition.y = 0.0f;
                        exitrotation.x = 0.0f;
                        exitrotation.y = 0.0f;
                        exitrotation.z = 0.0f;
                    }
                    else
                    {
                        exitposition.z = 2.9f;
                        int posi = positionnum.Next(0, 8);
                        exitposition.x = posi - 4;
                        exitposition.y = 0.0f;
                        exitrotation.x = 0.0f;
                        exitrotation.y = 180.0f;
                        exitrotation.z = 0.0f;
                    }
                    GameObject door = Instantiate(doorPrefab, exitposition, transform.rotation);
                    door.transform.Rotate(exitrotation);
                    //GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    //cube.transform.position = exitposition;
                    canexit = true;

                    if (satisfiedBar.size >= 1.0f)
                    {
                        controller.enabled = false;
                    }
                }
            }
            currentAmout              = 0;
            controller.enabled        = true;
            switchButton.interactable = true;
            circle.SetActive(false);
            process.GetComponent <Image>().fillAmount = 0;
            eatScript.SizeUp();
            AddBuff();
            scoreScript.addScore(20);
        }
    }