示例#1
0
        private void OnTriggerExit(Collider other)
        {
            ResetProgress();

            var playerSoundForOthers = PlaySoundForEveryone.Create(GlobalTargets.Everyone, ReliabilityModes.Unreliable);

            playerSoundForOthers.Position  = transform.position;
            playerSoundForOthers.SoundName = "Tap-Water";
            playerSoundForOthers.State     = false;
            playerSoundForOthers.Send();
        }
示例#2
0
        private void OnTriggerStay(Collider other)
        {
            if (_filled)
            {
                wetProgressSlider.value = 100;
                wetProgressText.text    = "100%";
                _error = true;
            }

            if (!_hasDrySpongeInHand)
            {
                _error = true;
            }

            if (_error)
            {
                return;
            }

            _currentProgress += deltaTime * 140 / 5;

            wetProgressSlider.value = (int)_currentProgress;

            wetProgressText.text = (int)_currentProgress + "%";

            if (_currentProgress >= 100)
            {
                RechargeSponge rechargeSponge = RechargeSponge.Create(GlobalTargets.OnlyServer, ReliabilityModes.ReliableOrdered);
                rechargeSponge.Player = _player;
                rechargeSponge.Send();

                _filled = true;

                var playerSoundForOthers = PlaySoundForEveryone.Create(GlobalTargets.Everyone, ReliabilityModes.Unreliable);
                playerSoundForOthers.Position  = transform.position;
                playerSoundForOthers.SoundName = "Tap-Water";
                playerSoundForOthers.State     = false;
                playerSoundForOthers.Send();
            }
            else
            {
                var playerSoundForOthers = PlaySoundForEveryone.Create(GlobalTargets.Everyone, ReliabilityModes.Unreliable);
                playerSoundForOthers.Position  = transform.position;
                playerSoundForOthers.SoundName = "Tap-Water";
                playerSoundForOthers.State     = true;
                playerSoundForOthers.Send();
            }
        }
示例#3
0
        public override void OnEvent(PlaySoundForEveryone playSoundForEveryone)
        {
            if (playSoundForEveryone.SoundName != "Tap-Water")
            {
                return;
            }

            if (!playSoundForEveryone.State)
            {
                _audioSource.Stop();
                return;
            }

            if (_audioSource.isPlaying)
            {
                return;
            }

            _audioSource.PlayOneShot(tapSound);
        }