// Update is called once per frame
    void Update()
    {
        // Old method
        if (Input.GetKeyDown(KeyCode.N))
        {
            Shake.ShakeCamera(BigShakeAmount, BigShakeDuration);
        }

        if (Input.GetKeyDown(KeyCode.M))
        {
            Shake.ShakeCamera(SmallShakeAmount, SmallShakeDuration);
        }

        // New method
        if (Input.GetKeyDown(KeyCode.A))
        {
            Shake.ShakeCameraBig();
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            Shake.ShakeCameraSmall();
        }
    }
示例#2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.CompareTag("Player"))
        {
            GameObject player = GameObject.FindGameObjectWithTag("Player");
            if (player != null)
            {
                // If player hits with the wrong shape, stop the game
                if (PlayerCtrl.currentShapeID != (redShapeID % 3) && !playerDefeated)
                {
                    player.GetComponent <PlayerCtrl>().Defeated();
                    playerDefeated = true;
                }

                // Else, continue, and create effect
                else
                {
                    // LOGICAL EFFECTS
                    if (!resourceAddedToPlayer)
                    {
                        if (redShapeID < 3) // If this is red obstacle, add point
                        {
                            GM_prefsCtrl.ChangePointsGained((int)Random.Range(1, 6));
                        }
                        else if (redShapeID >= 3) // If this is yellow obstacle, add point and gold
                        {
                            GM_prefsCtrl.ChangePointsGained((int)Random.Range(1, 6));
                            GM_prefsCtrl.ChangeMoneyGained((int)Random.Range(1, 3));
                        }
                        resourceAddedToPlayer = true;
                    }

                    // VISUAL EFFECTS
                    // Disappear the visible image and collider of this obstacle
                    for (int childIndex = 0; childIndex < transform.childCount; childIndex++)
                    {
                        if (childIndex < transform.childCount - 1)
                        {
                            transform.GetChild(childIndex).gameObject.SetActive(false);
                        }

                        // Spawn particle effect
                        else
                        {
                            transform.GetChild(childIndex).gameObject.SetActive(true);
                        }
                    }
                    redBoxCollider.enabled = false;

                    // Shake camera
                    if (virtualCam != null)
                    {
                        CamShake shakeScript = virtualCam.GetComponent <CamShake>();
                        if (shakeScript != null)
                        {
                            // Change this according to the current time scale
                            shakeScript.ShakeCamera(2.5f, 7, 0.5f);
                        }
                    }

                    // SOUND EFFECTS
                    expSound.Play();

                    Destroy(gameObject, 1f);
                }
            }
        }
    }
示例#3
0
 public void ShakeTiny()
 {
     shake.ShakeCamera(0.3f, 0.2f);
 }