示例#1
0
    // Update is called once per frame
    void Update()
    {
        e.waterStored = 2f;
        waterLevel    = well.GetActualHeight();
        if (playRaiseSound)
        {
            firebase2RaiseSound.SetActive(true);
        }
        if (playRaiseSound == false)
        {
            firebase2RaiseSound.SetActive(false);
        }
        if (playDropSound)
        {
            firebase2DropSound.SetActive(true);
        }
        if (playDropSound == false)
        {
            firebase2DropSound.SetActive(false);
        }
        if (firebase2.transform.position.y < waterLevel)
        {
            L2.waterputsFireOut();
        }
        if (raise_firebase2)
        {
            if (firebase2.transform.localPosition.y < 12.0f)
            {
                firebase2.transform.localPosition += new Vector3(0, -17f * Time.deltaTime * (-2.0f), 0);
            }
            if (button.transform.position.y > 11.64f)
            {
                //need to wait
                button.transform.position -= new Vector3(0, 12.55f * Time.deltaTime * (0.5f), 0);
                firebase2DropSound.SetActive(true);
            }
        }
        else
        {
            if (button.transform.position.y < 12.51f)
            {
                button.transform.position += new Vector3(0, 11.64f * Time.deltaTime * (0.5f), 0);
            }
            if (firebase2.transform.localPosition.y > -0.1f)
            {
                firebase2.transform.localPosition += new Vector3(0, -5 * Time.deltaTime * (2.0f), 0);
            }
        }
        if (w1.currentVolume == 1)
        {
            L.waterputsFireOut();
        }

        //lake1

        // if watergate opened and lake1 filled: lake1's water will fall down to lake2
        if (WaterGate.transform.localPosition.y <= 23.5f && w1.currentVolume > 0.0f)
        {
            lake2_cover.SetActive(false);
            lake2.layer = 4;
            w2.Fill(2);
            w1.Drain(2);
            Instantiate(waterfall, waterflowposition2.transform.position, waterflowposition2.transform.rotation);
        }

        //lake 2


        //if open Lid losing water . waterflow press button:firebase 2 raise
        if ((p.gotLid || wellLid.gameObject.GetComponent <Renderer>().enabled == true) && w2.currentVolume > 0.0f)
        {
            w2.drainSpeed = 0.0005f;     //change lake2 drain speed here
            w2.Drain(0.1f);
            Instantiate(waterflow, waterflowposition.transform.position, waterflowposition.transform.rotation);
            raise_firebase2 = true;
            playRaiseSound  = true;
            playDropSound   = false;
        }
        else
        {
            raise_firebase2 = false;
            playRaiseSound  = false;
            //playDropSound = true;
        }

        //well 3
        //sail.transform.localPosition =new Vector3(sail.transform.localPosition.x, 1.41f*well.currentVolume*6.5f,sail.transform.localPosition.z);
        //close LID:water raise
        if (wellLid.gameObject.GetComponent <Renderer>().enabled == true)
        {
        }
        //open LID:  water can not above the hole
        if (well.currentVolume > 0.0f && wellLid.gameObject.GetComponent <Renderer>().enabled == false)
        {
            Instantiate(wellflow, wellLid.transform.position, wellLid.transform.rotation);
            if (well.currentVolume < 0.08f)
            {
                well.currentVolume += 0.0001f * Time.deltaTime;
            }
            else
            {
                well.currentVolume = 0.08f;
            }
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (isPaused)
        {
            return;
        }

        if (scene.name != "Tutorial")
        {
            //Cycling through elements
            if (scene.name != "Level 1")
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    if ((int)elementIndex == 1)
                    {
                        ShiftElementLeft();
                    }
                    else if ((int)elementIndex == 0)
                    {
                        ShiftElementRight();
                    }
                    switchSound.Play();
                    GUICanvas.GetComponent <GUIControl>().SelectElement((int)elementIndex);
                }
//            else if ( Input.GetKeyDown(KeyCode.E) )
//            {
//                ShiftElementRight();
//                switchSound.Play();
//                GUICanvas.GetComponent<GUIControl>().SelectElement( (int)elementIndex );
//            }
            }
            //For left clicking
            if (Input.GetMouseButtonDown(0))
            {
                leftClicking = true;
                switch (elementIndex)
                {
                //BLOW WIND
                case elementType.wind:
                    windPushOrPull = 1;
                    windBlowing    = true;
                    windCollider.GetComponent <WindProperties>().SetBlowing(true);
                    forwardWindParticles.GetComponent <ParticleSystem>().Play();
                    backwardWindParticles.GetComponent <ParticleSystem>().Stop();
                    windSound.Play();
                    //AudioSource.PlayClipAtPoint(windSound, transform.position);
                    //fireSound.SetActive(false);
                    //windSound.SetActive(true);
                    //waterSound.SetActive(false);
                    break;

                //SPRAY WATER
                case elementType.water:
                    shootingWater  = true;
                    absorbingWater = false;
                    //fireSound.SetActive(false);
                    rainSound.Play();
                    //windSound.SetActive(false);
                    //waterSound.SetActive(true);
                    break;

                case elementType.fire:
                    //INSERT WHAT TO DO FOR FIRE
                    fireSound.SetActive(true);
                    //windSound.SetActive(false);
                    waterSound.SetActive(false);

                    break;
                }
            }

            //For right clicking
            else if (Input.GetMouseButtonDown(1))
            {
                rightClicking = true;
                switch (elementIndex)
                {
                //PULL WIND
                case elementType.wind:
                    windPushOrPull = -1;
                    windBlowing    = true;
                    windCollider.GetComponent <WindProperties>().SetBlowing(true);
                    forwardWindParticles.GetComponent <ParticleSystem>().Stop();
                    backwardWindParticles.GetComponent <ParticleSystem>().Play();
                    windSound.Play();
                    //AudioSource.PlayClipAtPoint(windSound, transform.position);
                    fireSound.SetActive(false);
                    //windSound.SetActive(true);
                    waterSound.SetActive(false);
                    break;

                //ABSORB WATER
                case elementType.water:
                    absorbingWater = true;
                    shootingWater  = false;
                    break;

                case elementType.fire:
                    //INSERT WHAT TO DO FOR FIRE
                    break;
                }
            }

            //RELEASE LEFT CLICK
            if (Input.GetMouseButtonUp(0))
            {
                leftClicking = false;
                switch (elementIndex)
                {
                case elementType.wind:
                    forwardWindParticles.GetComponent <ParticleSystem>().Stop();
                    windSound.Stop();
                    if (rightClicking)
                    {
                        windPushOrPull = -1;
                        backwardWindParticles.GetComponent <ParticleSystem>().Play();
                        windSound.Play();
                    }
                    else
                    {
                        windBlowing = false;
                        windCollider.GetComponent <WindProperties>().SetBlowing(false);
                    }
                    break;

                case elementType.water:
                    spraywaterParticles.GetComponent <ParticleSystem>().Stop();
                    spraywaterParticles.GetComponent <RainProperties>().SetRaining(false);
                    rainSound.Stop();
                    playGrowingSound = false;
                    shootingWater    = false;
                    if (rightClicking)
                    {
                        absorbingWater = true;
                    }
                    break;
                }
            }

            //RELEASE RIGHT CLICK
            if (Input.GetMouseButtonUp(1))
            {
                rightClicking = false;
                switch (elementIndex)
                {
                case elementType.wind:
                    backwardWindParticles.GetComponent <ParticleSystem>().Stop();
                    windSound.Stop();
                    if (leftClicking)
                    {
                        windPushOrPull = 1;
                        forwardWindParticles.GetComponent <ParticleSystem>().Play();
                    }
                    else
                    {
                        windBlowing = false;
                        windCollider.GetComponent <WindProperties>().SetBlowing(false);
                    }
                    break;

                case elementType.water:
                    absorbingWater = false;
                    if (leftClicking)
                    {
                        shootingWater = true;
                    }
                    break;
                }
            }
        }

        //Handle wind
        if (windBlowing)
        {
            if (windPushOrPull == -1)
            {
                RaycastHit hit;
                Vector3    desiredDir = backwardWindParticles.position - headObject.position;
                if (Physics.Raycast(headObject.position, desiredDir, out hit, 13.17f, LayerMask.GetMask("Ground")))
                {
                    backwardWindParticles.position = hit.point;
                }
                else
                {
                    backwardWindParticles.position = backWindPos.position;
                }
            }
            Vector3 lookDir = headObject.forward;
            //model.transform.eulerAngles = new Vector3(0f, gameObject.transform.eulerAngles.y, 0f);
            windDirection = windPushOrPull * lookDir;
            windCollider.GetComponent <WindProperties>().SetWindDir(windDirection);
        }

        //Handle water
        if (shootingWater)
        {
            spraywaterParticles.GetComponent <ParticleSystem>().Play();
            spraywaterParticles.GetComponent <RainProperties>().SetRaining(true);
            if (waterIn != null)
            {
                waterStored -= waterIn.GetComponent <WaterProperties>().Fill(waterStored);
            }

            else
            {
                RaycastHit hit;
                if (Physics.Raycast(headObject.position, headObject.forward, out hit, 50))
                {
                    if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Water"))
                    {
                        waterStored -= hit.transform.GetComponent <WaterProperties>().Fill(waterStored);
                    }

                    /*
                     *                  if( hit.transform.gameObject.tag =="original vine" )
                     * {
                     *  vineBridge.transform.localScale += new Vector3(0, Time.deltaTime*0.4f*8f, 0);
                     *                          vineBridge.transform.position += new Vector3(0, 0, Time.deltaTime*0.4f*4f);
                     *  playGrowingSound = true;
                     * }
                     */
                    if (hit.transform.gameObject.tag == "fire base1")
                    {
                        Debug.Log("222");
                        L.waterputsFireOut();
                    }
                }
            }
        }

        else if (absorbingWater)
        {
            if (waterIn != null)
            {
                waterStored += waterIn.GetComponent <WaterProperties>().Drain(waterCapacity - waterStored);
            }

            else
            {
                RaycastHit hit;
                if (Physics.Raycast(headObject.position, headObject.forward, out hit, 50))
                {
                    if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Water"))
                    {
                        waterStored += hit.transform.GetComponent <WaterProperties>().Drain(waterCapacity - waterStored);
                    }
                }
            }
        }

        if (leftClicking || rightClicking)
        {
            anim.SetLayerWeight(1, (anim.GetLayerWeight(1) * 3 + 0.75f) / 4);
            if (!eyesClosed)
            {
                eyesClosed = true;
                Renderer r = model.transform.Find("Plane").GetComponent <Renderer>();
                r.material = closedEyesMaterial;
            }
        }

        else
        {
            anim.SetLayerWeight(1, anim.GetLayerWeight(1) * 0.75f);
            if (eyesClosed)
            {
                eyesClosed = false;
                Renderer r = model.transform.Find("Plane").GetComponent <Renderer>();
                r.material = openEyesMaterial;
            }
        }
    }