Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
//        if(P.limitX){
//            if(this.transform.position.x > P.xMax){
//                this.transform.Translate(-0.01f,0f,0f);
//            }
//            else if(this.transform.position.x < P.xMin){
//                this.transform.Translate(0.01f,0f,0f);
//            }
//        }
        if (P.limitZ)
        {
            if (this.transform.position.z >= P.zMax)
            {
                Debug.Log("limit");
                this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z - 1f);
            }
            else if (this.transform.position.z <= P.zMin)
            {
                this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z + 1f);
            }
        }
        // zoomCamera();
        if (water == null)
        {
            return;
        }
        waterLevel = wp.GetActualHeight();

        if (boat_limit_both_x_and_z)
        {
            // float on right level
//            if(transform.position.y > 13f){
//                transform.position = new Vector3 (
//                    transform.position.x,
//                    waterLevel, //wp.GetActualHeight (),
//                    transform.position.z);
//            }
            if (transform.position.y > 0f)
            {
                transform.position = new Vector3(
                    transform.position.x,
                    waterLevel * 0.9f, //wp.GetActualHeight (),
                    transform.position.z);
            }
            if (transform.position.y < -0.2f)
            {
                transform.position = new Vector3(
                    transform.position.x,
                    waterLevel + offset, //wp.GetActualHeight (),
                    transform.position.z);
            }


            if (a == 0)
            {
                if (transform.position.z < -60)
                {
                    P.xMin = -50f;
                }
            }
            if (transform.position.z > -60)
            {
                a += 1; P.xMin = -66.65f;
                rotate_boat_mesh.transform.localRotation = Quaternion.Slerp(rotate_boat_mesh.transform.rotation, targetrotation, Time.deltaTime * 5f);
            }
        }

        if (transform.position.x < -60)
        {
            P.xMax = -60;
            rotate_boat_mesh.transform.localRotation = Quaternion.Slerp(rotate_boat_mesh.transform.rotation, targetrotation2, Time.deltaTime * 5f);
        }
        if (transform.position.x < -60 && transform.position.z < -71.36f)
        {
            P.zMin = -71.36f;
            P.zMax = -70.36f;
        }



        if (changelimit)
        {
            transform.position = new Vector3(
                transform.position.x,
                waterLevel + offset, //wp.GetActualHeight (),
                transform.position.z
                );

            if (waterLevel >= 27.1f)
            {
                transform.position = new Vector3(
                    transform.position.x,
                    waterLevel + 1.8f, //wp.GetActualHeight (),
                    transform.position.z
                    );
            }

            if (wp.currentVolume >= 0.5f)
            {
                P.xMax = -17;
            }
        }
        if (0.0f < wp.currentVolume && wp.currentVolume < 0.99f)
        {
            if (E.shootingWater)
            {
                //transform.Translate(Vector3.up*waterLevel*fillspeed);
                change = E.shootingWater;
                time   = Time.time;
            }
            if (E.shootingWater != change)
            {
                StartCoroutine("floating_effect");
            }


            if (E.absorbingWater)
            {
                //  transform.Translate(Vector3.down*waterLevel*fillspeed);
                change2 = E.absorbingWater;
                time    = Time.time;
            }
        }
    }
Beispiel #2
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;
            }
        }
    }