Beispiel #1
0
 private void Update()
 {
     this.input.x = Input.GetAxis("Horizontal");
     this.input.y = Input.GetAxis("Vertical");
     if (Input.GetKey(KeyCode.LeftShift))
     {
         this.targetCameraPosition.z = this.targetCameraPosition.z + this.input.y * this.cameraMoveAmount;
         this.targetCameraPosition.z = Mathf.Clamp(this.targetCameraPosition.z, -6.3f, -1f);
     }
     else
     {
         this.targetCameraRotation.y = this.targetCameraRotation.y + this.input.x * this.cameraRotateAmount;
         this.targetCameraRotation.x = this.targetCameraRotation.x + this.input.y * this.cameraRotateAmount;
         this.targetCameraRotation.x = Mathf.Clamp(this.targetCameraRotation.x, this.cameraAngleLimits.x, this.cameraAngleLimits.y);
     }
     this.cameraTranslationTransform.localPosition = Vector3.SmoothDamp(this.cameraTranslationTransform.localPosition, this.targetCameraPosition, ref this.cameraPositionSmoothDampVelocity, 1f / this.cameraMoveSpeed, float.PositiveInfinity, Time.unscaledDeltaTime);
     this.cameraRotation = Vector3.SmoothDamp(this.cameraRotation, this.targetCameraRotation, ref this.cameraRotationSmoothDampVelocity, 1f / this.cameraRotationSpeed, float.PositiveInfinity, Time.unscaledDeltaTime);
     this.cameraRotationTransform.localEulerAngles = this.cameraRotation;
     this.cameraTranslationTransform.LookAt(this.cameraLookAtPosition);
     if (Input.GetAxis("Mouse ScrollWheel") < 0f)
     {
         this.Next();
     }
     else if (Input.GetAxis("Mouse ScrollWheel") > 0f)
     {
         this.Previous();
     }
     if (Input.GetKeyDown(KeyCode.U))
     {
         this.ui.SetActive(!this.ui.activeSelf);
     }
     if (Input.GetKeyDown(KeyCode.O))
     {
         if (this.particleMode == DemoManager.ParticleMode.looping)
         {
             this.SetToOneshotParticleMode(true);
         }
         else
         {
             this.SetToLoopingParticleMode(true);
         }
     }
     if (Input.GetKeyDown(KeyCode.L))
     {
         this.SetLevel((this.currentLevel + 1) % (DemoManager.Level)Enum.GetNames(typeof(DemoManager.Level)).Length);
     }
     else if (Input.GetKey(KeyCode.R))
     {
     }
     if (this.particleMode == DemoManager.ParticleMode.oneshot)
     {
         Vector3 mousePosition = Input.mousePosition;
         if (Input.GetMouseButtonDown(0))
         {
             CameraShake cameraShake = UnityEngine.Object.FindObjectOfType <CameraShake>();
             cameraShake.Add(0.2f, 5f, 0.2f, CameraShakeTarget.Position, CameraShakeAmplitudeCurve.FadeInOut25);
             cameraShake.Add(4f, 5f, 0.5f, CameraShakeTarget.Rotation, CameraShakeAmplitudeCurve.FadeInOut25);
             this.oneshotParticleSystems.InstantiateParticlePrefab(mousePosition, this.mouse.distanceFromCamera);
         }
         if (Input.GetMouseButton(1))
         {
             this.oneshotParticleSystems.InstantiateParticlePrefab(mousePosition, this.mouse.distanceFromCamera);
         }
     }
     if (Input.GetKeyDown(KeyCode.R))
     {
         this.ResetCameraTransformTargets();
     }
 }
Beispiel #2
0
                void Update()
                {
                    // ...

                    input.x = Input.GetAxis("Horizontal");
                    input.y = Input.GetAxis("Vertical");

                    // Get targets.

                    if (Input.GetKey(KeyCode.LeftShift))
                    {
                        targetCameraPosition.z += input.y * cameraMoveAmount;
                        targetCameraPosition.z  = Mathf.Clamp(targetCameraPosition.z, -6.3f, -1.0f);
                    }
                    else
                    {
                        targetCameraRotation.y += input.x * cameraRotateAmount;
                        targetCameraRotation.x += input.y * cameraRotateAmount;

                        targetCameraRotation.x = Mathf.Clamp(targetCameraRotation.x, cameraAngleLimits.x, cameraAngleLimits.y);
                    }

                    // Camera position.

                    cameraTranslationTransform.localPosition = Vector3.SmoothDamp(
                        cameraTranslationTransform.localPosition, targetCameraPosition, ref cameraPositionSmoothDampVelocity, 1.0f / cameraMoveSpeed, Mathf.Infinity, Time.unscaledDeltaTime);

                    // Camera container rotation.

                    cameraRotation = Vector3.SmoothDamp(
                        cameraRotation, targetCameraRotation, ref cameraRotationSmoothDampVelocity, 1.0f / cameraRotationSpeed, Mathf.Infinity, Time.unscaledDeltaTime);

                    cameraRotationTransform.localEulerAngles = cameraRotation;

                    // Look at origin.

                    cameraTranslationTransform.LookAt(cameraLookAtPosition);

                    // Scroll through systems.

                    if (Input.GetAxis("Mouse ScrollWheel") < 0)
                    {
                        Next();
                    }
                    else if (Input.GetAxis("Mouse ScrollWheel") > 0)
                    {
                        Previous();
                    }

                    // Toggle UI.

                    if (Input.GetKeyDown(KeyCode.U))
                    {
                        ui.SetActive(!ui.activeSelf);
                    }

                    // Switch between one-shot and looping prefabs.

                    if (Input.GetKeyDown(KeyCode.O))
                    {
                        if (particleMode == ParticleMode.looping)
                        {
                            SetToOneshotParticleMode(true);
                        }
                        else
                        {
                            SetToLoopingParticleMode(true);
                        }
                    }

                    // Cycle levels.

                    if (Input.GetKeyDown(KeyCode.L))
                    {
                        SetLevel((Level)((int)(currentLevel + 1) % System.Enum.GetNames(typeof(Level)).Length));
                    }

                    // Random prefab while holding key.

                    else if (Input.GetKey(KeyCode.R))
                    {
                        //if (particleMode == ParticleMode.oneshot)
                        //{
                        //    oneshotParticleSystems.randomize();
                        //    updateCurrentParticleSystemNameText();

                        //    // If also holding down, auto-spawn at random point.

                        //    if (Input.GetKey(KeyCode.T))
                        //    {
                        //        //oneshotParticleSystems.instantiateParticlePrefabRandom();
                        //    }
                        //}
                    }

                    // Left-click to spawn once.
                    // Right-click to continously spawn.

                    if (particleMode == ParticleMode.oneshot)
                    {
                        Vector3 mousePosition = Input.mousePosition;

                        if (Input.GetMouseButtonDown(0))
                        {
                            CameraShake cameraShake = FindObjectOfType <CameraShake>();

                            cameraShake.Add(0.2f, 5.0f, 0.2f, CameraShakeTarget.Position, CameraShakeAmplitudeCurve.FadeInOut25);
                            cameraShake.Add(4.0f, 5.0f, 0.5f, CameraShakeTarget.Rotation, CameraShakeAmplitudeCurve.FadeInOut25);

                            oneshotParticleSystems.InstantiateParticlePrefab(mousePosition, mouse.distanceFromCamera);
                        }
                        if (Input.GetMouseButton(1))
                        {
                            oneshotParticleSystems.InstantiateParticlePrefab(mousePosition, mouse.distanceFromCamera);
                        }
                    }

                    // Reset.

                    if (Input.GetKeyDown(KeyCode.R))
                    {
                        ResetCameraTransformTargets();
                    }
                }