示例#1
0
    private void OnTriggerEnter(Collider other)
    {
        if (!sentinel)
        {
            sentinel = true;
            if (other.CompareTag("Breakable"))
            {
                BreakableObject breakable = other.transform.parent.GetComponent <BreakableObject>();

                if (!breakable.isBroken)
                {
                    AudioManager.GetComponent <AudioSource>().PlayOneShot(AudioManager.GetComponent <AudioLoader>().GetBreakingSound(), 0.5f); // plays random breaking sound
                    CameraShaker.Instance.camera = camera;
                    CameraShaker.Instance.ShakeOnce(4f, 4f, 0.1f, .3f);
                    if (isReturning)
                    {
                        score.AddScore(-1);
                    }
                    else
                    {
                        score.AddScore(1);
                    }
                }
                else if (breakable.isBroken && isReturning)
                {
                    AudioManager.GetComponent <AudioSource>().PlayOneShot(AudioManager.GetComponent <AudioLoader>().GetFixingSound(), 0.5f); // plays random fixing sound
                    score.AddScore(1);
                }

                breakable.SwitchState();
            }
            else if (other.CompareTag("CutSceneRoom"))
            {
                isReturning = true;
                mode        = GameMode.CutScene;
                //if (orientation == Orientation.Left) orientation = Orientation.Right;
                //else if (orientation == Orientation.Right) orientation = Orientation.Left;

                //Vector3 position = transform.position;
                //if (playerType == PlayerType.PlayerOne) position.x = 5;
                //else position.x = 0;
                //transform.position = position;
            }
            else if (other.CompareTag("EndWall"))
            {
                mode = GameMode.GameOver;
                //gameOver = true;
            }
            else if (other.CompareTag("Trap"))
            {
                score.AddScore(-1);
            }
        }
    }