Пример #1
0
    }//end start

    //removes the last material placed
    void Undo()
    {
        if (layers == null)
        {
            return;
        }
        if (layers.Length <= 0)
        {
            return;
        }

        Destroy(layers[layers.Length - 1].sf.gameObject);
        Mlayer[] temp = new Mlayer[layers.Length - 1];
        for (int i = 0; i < temp.Length; i++)
        {
            temp[i] = layers[i];
        }
        layers = temp;
    } //end undo
Пример #2
0
    }//end evaluate

    void Update()
    {
        if (fade > 0)
        {
            fade -= Time.deltaTime * .75f;
        } //fade print successful message
        tappos = new Vector3(-1, -1, -1);//initialize tap position
        Vector3 tp = new Vector3(0, 0, 0);//initialize touch position

        if (Input.touchCount > 0)//check for touch
        {
            for (int i = 0; i < Input.touchCount; i++)
            {
                if (Input.touches[i].phase == TouchPhase.Ended)
                {
                    tappos = Input.touches[i].position;
                }
                tp = Input.touches[i].position;
            }
        }

        if (state == 6)
        {
            if (pw != null) //remove trickle effect upon entering results screen
            {
                Destroy(pw.tri.gameObject);
                Destroy(pw.gameObject);
            }
        }

        spraying = false;                                                   //reinitialize spraying bool
        Rect areatank = new Rect(w * .015f, h * .3f, w * .725f, h * .675f); //tank clickable area


        if (state != pstate && state == 0)
        {
            f5.empty = true;
        }//reinitialize last flow effect upon entering first state

        if (state == -1)//splash state
        {
            if (sptimer > 0)
            {
                sptimer -= Time.deltaTime;
            }
            else
            {
                state = 0;
            }
        }

        if (state == 5)//delay before evaluating trial data and moving to final results screen
        {
            delay -= Time.deltaTime;
            if (delay <= 0)
            {
                Evaluate();
                SaveData();
                state = 6;
            }
        }
        if (state == 6) //go to jar camera while on results state
        {
            c_cam = 1;
        }
        else
        {
            c_cam = 0;
        }

        if (state == 3) //fill tank with water
        {
            if (pw == null)
            {
                GameObject go = (GameObject)Instantiate(wt, wt.transform.position, wt.transform.rotation);
                go.SetActive(true);
                pw = go.GetComponent <PourWater>();
                if (layers.Length >= 1)
                {
                    pw.sf = layers[layers.Length - 1].sf;
                }
                else
                {
                    pw.sf = emptysf;
                }
            }
            if (water.type != 5)
            {
                water.type = 5;
            }
            if (pw.tri != null)
            {
                if (pw.tri.stop)
                {
                    if (water.linetop < ef.linetop)
                    {
                        water.linetop += Time.deltaTime * 1.25f;
                        if (water.linetop > ef.linetop)
                        {
                            water.linetop = ef.linetop;
                        }
                    }
                }
            }
        }

        if (state == 7) //raise/lower water level
        {
            if (Input.GetMouseButton(0))
            {
                if (_lower.Contains(mp))
                {
                    held = 3;
                }
                if (_raise.Contains(mp))
                {
                    held = 4;
                }
            }
            if (tp != Vector3.zero)
            {
                if (_lower.Contains(tp))
                {
                    held = 3;
                }
                if (_raise.Contains(tp))
                {
                    held = 4;
                }
            }
        }

        if (state == 1)//fade pump while raising/lowering tube
        {
            pump.color = new Color(1, 1, 1, .25f);
            if (Input.GetMouseButtonDown(0))
            {
                if (_lower.Contains(mp))
                {
                    held = 1;
                }
                if (_raise.Contains(mp))
                {
                    held = 2;
                }
            }
            if (tp != Vector3.zero)
            {
                if (_lower.Contains(tp))
                {
                    held = 1;
                }
                if (_raise.Contains(tp))
                {
                    held = 2;
                }
            }
            if (!sipR.enabled)
            {
                sipR.enabled = true;
            }
        }
        else
        {
            pump.color = Color.white;
        }

        if (held == 1)//raise/lower pump
        {
            if (!Input.GetMouseButton(0) && tp == Vector3.zero)
            {
                held = 0;
            }
            else
            {
                Vector3 scale = siphon.transform.localScale;
                scale.y += Time.deltaTime * 1.5f;
                if (scale.y > 8f)
                {
                    scale.y = 8f;
                }
                siphon.transform.localScale = scale;
            }
        }
        if (held == 2)
        {
            if (!Input.GetMouseButton(0) && tp == Vector3.zero)
            {
                held = 0;
            }
            else
            {
                Vector3 scale = siphon.transform.localScale;
                scale.y -= Time.deltaTime * 1.5f;
                if (scale.y < 0)
                {
                    scale.y = 0;
                }
                siphon.transform.localScale = scale;
            }
        }
        if (held == 3)//raise/lower fill level
        {
            if (!Input.GetMouseButton(0) && tp == Vector3.zero)
            {
                held = 0;
            }
            else
            {
                ef.linetop -= Time.deltaTime;
                held        = 0;
            }
        }
        if (held == 4)
        {
            if (!Input.GetMouseButton(0) && tp == Vector3.zero)
            {
                held = 0;
            }
            else
            {
                ef.linetop += Time.deltaTime;
                held        = 0;
            }
        }
        if ((Input.GetMouseButton(0) || tp != Vector3.zero) && state == 0)//spray material if current material either hasn't been placed or is the most recently placed
        {
            if ((areatank.Contains(mp) || areatank.Contains(tp)) && spraytype > 0)
            {
                //USE SUPER FILL
                spraying = true;
                if (layers.Length == 0)
                {
                    layers         = new Mlayer[1];
                    layers[0]      = new Mlayer();
                    layers[0].type = spraytype;
                    GameObject go = (GameObject)Instantiate(sf.gameObject, sf.transform.position, sf.transform.rotation);
                    go.SetActive(true);
                    layers[0].sf    = go.GetComponent <SuperFill>();
                    layers[0].sf.aq = this;
                    Material[] mt = new Material[2];
                    mt[0] = fmats[spraytype - 1];
                    mt[1] = tmats[spraytype - 1];
                    layers[0].sf.GetComponent <Renderer>().materials = mt;
                    layers[0].sf.name = 0.ToString();
                }
                else
                {
                    bool has = false;
                    for (int i = 0; i < layers.Length; i++)
                    {
                        if (layers[i].type == spraytype)
                        {
                            has = true;
                        }
                    }
                    if (has)
                    {
                        if (layers[layers.Length - 1].type == spraytype)
                        {
                            layers[layers.Length - 1].sf.getClosestPoint();

                            if (layers.Length > 1)
                            {
                                layers[layers.Length - 1].amount = layers[layers.Length - 1].sf.newVertices[69].y - layers[layers.Length - 2].sf.newVertices[69].y;
                            }
                            else
                            {
                                layers[layers.Length - 1].amount = layers[layers.Length - 1].sf.newVertices[69].y;
                            }
                        }
                    }
                    else
                    {
                        Mlayer[] temp = new Mlayer[layers.Length + 1];
                        for (int i = 0; i < layers.Length; i++)
                        {
                            temp[i] = layers[i];
                        }
                        temp[temp.Length - 1]      = new Mlayer();
                        temp[temp.Length - 1].type = spraytype;
                        GameObject go = (GameObject)Instantiate(sf.gameObject, sf.transform.position, sf.transform.rotation);
                        go.SetActive(true);
                        temp[temp.Length - 1].sf    = go.GetComponent <SuperFill>();
                        temp[temp.Length - 1].sf.aq = this;
                        Material[] mt = new Material[2];
                        mt[0] = fmats[spraytype - 1];
                        mt[1] = tmats[spraytype - 1];
                        temp[temp.Length - 1].sf.GetComponent <Renderer>().materials = mt;
                        temp[temp.Length - 1].sf.newVertices        = temp[temp.Length - 2].sf.newVertices;
                        temp[temp.Length - 1].sf.ps                 = temp[temp.Length - 2].sf;
                        temp[temp.Length - 1].sf.name               = (temp.Length - 1).ToString();
                        temp[temp.Length - 1].sf.transform.position = new Vector3(temp[temp.Length - 1].sf.transform.position.x, temp[temp.Length - 1].sf.transform.position.y, temp[temp.Length - 1].sf.ps.transform.position.z + .0001f);
                        layers = temp;
                    }
                }
            }
        }
        for (int i = 0; i < cams.Length; i++)//set active camera
        {
            if (i == c_cam)
            {
                cams[i].enabled = true;
            }
            else
            {
                cams[i].enabled = false;
            }
        }

        pstate = state;//reset pstate
    }