public override Gazer.SoundEffectType OnInteract(Gazer gazer)
 {
     Gazer.SoundEffectType returnSound = Gazer.SoundEffectType.None;
     if (interactive == true)
     {
         if (HoldingItem != null)
         {
             TransferItem(this, gazer.PlayerHolder);
             OnGazeExit(gazer);
             returnSound = Gazer.SoundEffectType.PickUpKey;
         }
         else if (gazer.PlayerHolder.HoldingItem != null)
         {
             TransferItem(gazer.PlayerHolder, this);
             OnGazeExit(gazer);
             returnSound = Gazer.SoundEffectType.DropKey;
         }
     }
     return(returnSound);
 }
Пример #2
0
    public override Gazer.SoundEffectType OnInteract(Gazer gazer)
    {
        Gazer.SoundEffectType returnSound = Gazer.SoundEffectType.None;
        if (IsInteractive == true)
        {
            // Check if they're holding the correct item
            if (gazer.PlayerHolder.HoldingItem == associatedCode)
            {
                // Associate with the end of this key animation
                gazer.PlayerHolder.HoldingItem.OnAnimationEnd += HoldingItem_OnAnimationEnd;
                ItemHolder.TransferItem(gazer.PlayerHolder, keyHolder);

                // Play sound effect
                correctKeySound.Play();

                // Play drop sound
                returnSound = Gazer.SoundEffectType.DropKey;
            }
            else
            {
                // Display error
                errorLabel.gameObject.SetActive(true);
                if (firstTimeTryingKey == true)
                {
                    errorLabel.TranslationKey = FirstWrongKeyText;
                    firstTimeTryingKey        = false;
                }
                else
                {
                    errorLabel.TranslationKey = OtherWrongKeyText.RandomElement;
                }

                // Play sound effect
                wrongKeySound.Play();
            }
            IsInteractive = false;
        }
        return(returnSound);
    }