コード例 #1
0
ファイル: BuildWorld.cs プロジェクト: nattsr/ParticlePack
    //===================================================================


    //===================================================================
    // Update is called once per frame
    void Update()
    {
        // Input
        bool userGeneratedInput = (Input.GetKey(KeyCode.Q) || Input.GetKeyDown(KeyCode.E)) && Time.time >= lastGenerationTime + (1f / depostionRatePerSec);
        bool autoGeneratedInput = automaticDepostion == true & Time.time >= lastGenerationTime + (1f / depostionRatePerSec);

        if (userGeneratedInput == true || autoGeneratedInput == true)
        {
            if (cementationActive == true)
            {
                rock.beds[rock.currentBed].CementAndUncement(true);
                cementationActive = false;
            }

            if (disappearActive == true)
            {
                rock.beds[rock.currentBed].AppearAndDisappear(false);
                disappearActive = false;
            }

            if (saveActive == true && saveStatus == false)
            {
                Debug.Log("Starting Saving");
                saveStatus = saveData();
                saveStatus = true;
            }

            if (exitActive == true && saveStatus == true)
            {
                Application.Quit();
            }


            rock.instantiateGrain();
            lastGenerationTime = Time.time;

            // Check if we reached the next bed
            if (rock.beds[rock.currentBed].IsDeposted() == true)
            {
                AfterBedOperations();
            }
        }


        // Input

        if (Input.GetKeyUp(KeyCode.C))
        {
            stabilizeCamera = !stabilizeCamera;
        }
        if (Input.GetKeyUp(KeyCode.F5) == true)
        {
            saveData();
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            ShakingFraction += .0001f;
        }
        if (Input.GetKeyDown(KeyCode.H))
        {
            ShakingFraction -= .0001f;
        }
        if (Input.GetKeyDown(KeyCode.N))
        {
            ShakingRotationFraction += .0001f;
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            ShakingRotationFraction -= .0001f;
        }
        if (Input.GetKeyUp(KeyCode.K))
        {
            shakeTransversly = !shakeTransversly;
        }
        if (Input.GetKeyUp(KeyCode.M))
        {
            shakeRotationaly = !shakeRotationaly;
        }

        if (Input.GetKeyUp(KeyCode.R))
        {
            automaticDepostion = !automaticDepostion;
        }
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            CloseApplication();
        }
        if (Input.GetKeyUp(KeyCode.G))
        {
            Physics.gravity = new Vector3(0, -1f * Mathf.Abs(Physics.gravity.y + 9.81f), 0);
        }
        if (Input.GetKeyUp(KeyCode.X))
        {
            rock.CementAndUnCement(false);
        }
        if (Input.GetKeyUp(KeyCode.Z))
        {
            rock.CementAndUnCement(true);
        }

        if (Input.GetKeyDown(KeyCode.Equals))
        {
            TimeScale += 0.2f;
        }
        if (Input.GetKeyDown(KeyCode.Minus))
        {
            TimeScale -= 0.2f;
        }

        if (Input.GetKeyDown(KeyCode.Y))
        {
            FixedDeltaTime += 0.001f;
        }
        if (Input.GetKeyDown(KeyCode.T))
        {
            FixedDeltaTime -= 0.001f;
        }

        if (Input.GetKeyDown(KeyCode.F1))
        {
            Application.Quit();
        }



        // Shaker
        shaker.shakeBox(shakeTransversly, shakeRotationaly, ShakingFraction, ShakingRotationFraction);
        OnValidate();
    }