Example #1
0
        private void Die()
        {
            IsDead = true;
            Health = 0;

            PlayerMovement movement = gameObject.GetComponent <PlayerMovement>();

            movement.MovementEnabled = false;

            Animator animator = GetComponent <Animator>();

            animator.enabled = false;
            double deathAnimationLength = 1.00d;

            if (DeathAudioClip != null)
            {
                BackgroundMusicSystem backgroundMusicSystem =
                    transform.parent.GetComponentInChildren <BackgroundMusicSystem>();
                backgroundMusicSystem.StopBackgroundMusic();
                deathAnimationLength = DeathAudioClip.length;
                _audioSource.PlayOneShot(DeathAudioClip);
            }

            int z = 90;

            if (movement.IsFacingRight)
            {
                z *= -1;
            }

            gameObject.transform.Rotate(0, 0, z);
            Invoke("TrueDeath", Convert.ToSingle(deathAnimationLength * 1.15));
        }
        private void StartFight()
        {
            _fightStarted = true;
            _backgroundMusicSystem.StopBackgroundMusic();
            _backgroundMusicSystem.BackgroundMusicAudioClip = FightMusic;
            _backgroundMusicSystem.StartBackgroundMusic();
            foreach (IBoss boss in _bosses)
            {
                boss.StartMoving();
            }

            PlayerMovement movement = Player.GetComponent <PlayerMovement>();

            movement.MovementEnabled = true;

            Invoke("RemoveText", _skippedIntro ? 3f : 0.5f);
        }