コード例 #1
0
    private void OnTriggerExit2D(Collider2D other)
    {
        if (other.tag == "PuzzleShellTwoInteractZone")
        {
            ShellPuzzleTwo shell = other.GetComponentInParent <ShellPuzzleTwo>();
            shell.InactiveButtonSprite();
        }

        if (other.tag == "InteractZone")
        {
            InteractZone zone = other.GetComponent <InteractZone>();

            if (!zone.buttonisActivated)
            {
                zone.InactiveButtonSprite();
            }
        }

        if (other.tag == "GrassZone")
        {
            playerSoundManager.surface = PlayerSoundManager.Surface.sand;
        }
    }
コード例 #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Pearl")
        {
            AudioSource pearlAudio = other.GetComponent <AudioSource>();
            if (pearlAudio.isPlaying)
            {
                pearlAudio.Stop();
            }

            Pearl pearl = other.GetComponent <Pearl>();

            if (collisionChecker.collisions.above)
            {
                pearl.MoveUp();
            }
            else if (collisionChecker.collisions.below)
            {
                pearl.MoveDown();
            }
            else if (collisionChecker.collisions.left)
            {
                pearl.MoveLeft();
            }
            else if (collisionChecker.collisions.right)
            {
                pearl.MoveRight();
            }
        }

        if (other.tag == "PearlInteractZone")
        {
            Pearl pearl = other.GetComponentInParent <Pearl>();

            if (!pearl.hasBeenPushed)
            {
                pearl.PlayPuzzleSound();
            }
        }

        if (other.tag == "InteractZone")
        {
            InteractZone zone = other.GetComponent <InteractZone>();
            zone.ActivatedButtonSprite();
        }

        if (other.tag == "PuzzleShellTwo")
        {
            ShellPuzzleTwo shell = other.GetComponent <ShellPuzzleTwo>();
            shell.ActivateShell();
        }

        if (other.tag == "PuzzleShellTwoInteractZone")
        {
            ShellPuzzleTwo shell = other.GetComponentInParent <ShellPuzzleTwo>();
            shell.PlayShellSound();
            shell.ActivatedButtonSprite();
        }

        if (other.tag == "PuzzleButtonOne")
        {
            PuzzleButtonOne button = other.GetComponentInParent <PuzzleButtonOne>();

            if (!button.isPuzzleSolved)
            {
                button.PlayPuzzleSounds();
            }
        }

        if (other.tag == "PuzzleButtonTwo")
        {
            PuzzleButtonTwo button = other.GetComponentInParent <PuzzleButtonTwo>();

            if (!button.isPuzzleSolved)
            {
                button.PlayPuzzleSounds();
            }
        }

        if (other.tag == "PuzzleButtonThree")
        {
            PuzzleButtonThree button = other.GetComponent <PuzzleButtonThree>();

            if (!button.isPuzzleSolved)
            {
                button.ActivateDialogueBox();
                canMove = false;
            }
        }

        if (other.tag == "EnterZone")
        {
            MountainEntry mountain = other.GetComponent <MountainEntry>();

            int mountainNumber = mountain.mountainNumber;
            gameManager.currentMountainNumber = mountainNumber;

            mountain.EnterMountain();
        }

        if (other.tag == "ExitZone")
        {
            gameManager.playerExitingMountain = true;
            MountainExit mountain = other.GetComponent <MountainExit>();
            mountain.ExitMountain();
        }

        if (other.tag == "GrassZone")
        {
            playerSoundManager.surface = PlayerSoundManager.Surface.grass;
        }
    }