コード例 #1
0
ファイル: DemoManager.cs プロジェクト: zwx0641/Color2
                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();
                    }
                }
コード例 #2
0
ファイル: DemoManager.cs プロジェクト: britt103/HiveArmada
                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();
                    }

                    // 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))
                        {
                            oneshotParticleSystems.InstantiateParticlePrefab(mousePosition, mouse.distanceFromCamera);
                        }
                        if (Input.GetMouseButton(1))
                        {
                            oneshotParticleSystems.InstantiateParticlePrefab(mousePosition, mouse.distanceFromCamera);
                        }
                    }

                    // Reset.

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