Example #1
0
 public void Active()
 {
     IsActive    = true;
     audioSource = new AudioSource();
     audioSource.Play(clipSplash);
     AudioManager.DisposeAudioSource(audioSource);
 }
        protected override void OnCollisionWithObject(Collision collision)
        {
            base.OnCollisionWithObject(collision);

            if (collision.collider is IHittable h)
            {
                h.OnHit(this);
            }
            else
            {
                float deltaX = collision.Delta.X;
                float deltaY = collision.Delta.Y;

                if (deltaY > deltaX && Velocity.Length > 0 && !(collision.collider is Player p))
                {
                    Velocity      = Vector2.Zero;
                    CanWalkable   = true;
                    startRotation = false;
                    Position      = new Vector2(Position.X - deltaX, Position.Y);
                    PlayAudio(clipStopped);

                    if (!PlayScene.Player.IsDead)
                    {
                        AudioManager.DisposeAudioSource(audioSource);
                    }
                }
            }
        }
Example #3
0
        protected virtual void OnDie()
        {
            IsActive = false;
            Animation.Reset();

            AudioManager.DisposeAudioSource(audioSource);
        }
        public override void Exit()
        {
            base.Exit();

            AudioManager.DisposeAudioSource(audioSource);
            ((LizardEnemy)Owner).FinishAttack();
        }
Example #5
0
        protected virtual void PlayAudio(AudioClip clip, float volume = 0.5f)
        {
            audioSource = new AudioSource();

            audioSource.Volume = volume;
            audioSource.Play(clip);
            AudioManager.DisposeAudioSource(audioSource);
        }
Example #6
0
        private void PlayAudio(AudioClip clip)
        {
            if (audioSourceOnPicked == null)
            {
                audioSourceOnPicked = new AudioSource();
            }

            audioSourceOnPicked.Play(clip);
            AudioManager.DisposeAudioSource(audioSourceOnPicked);
        }
Example #7
0
        public override void Enter()
        {
            base.Enter();
            //Player.GetSprite().SetAdditiveTint(0, 0.15f, 0, 0);
            Player.RigidBody.Velocity = Vector2.Zero;
            timeToLoadGame            = 4f;

            audioSource = new AudioSource();
            audioSource.Play(clipSmashed);
            AudioManager.DisposeAudioSource(audioSource);
        }
Example #8
0
        public override void OnHit(GameObject hitObject)
        {
            base.OnHit(hitObject);

            if (countdownStarted)
            {
                audioSourceCountDown.Stop();
                AudioManager.DisposeAudioSource(audioSourceCountDown);
                countdownStarted = false;
            }
        }
Example #9
0
        public override void OnDie()
        {
            base.OnDie();

            if (countdownStarted)
            {
                audioSourceCountDown.Stop();
                AudioManager.DisposeAudioSource(audioSourceCountDown);
                countdownStarted = false;
            }
        }
Example #10
0
        protected override void OnCollisionWithPlayer(Player p, Collision collisionInfo)
        {
            if (audioSourceBurn == null)
            {
                audioSourceBurn = new AudioSource();
            }

            audioSourceBurn.Play(clipBurned);
            AudioManager.DisposeAudioSource(audioSourceBurn);

            p.OnHit(playerAnimDie);
        }
Example #11
0
        private void StartCountDown()
        {
            if (audioSourceCountDown == null)
            {
                audioSourceCountDown = new AudioSource();
            }

            audioSourceCountDown.Play(clipCountdown);
            AudioManager.DisposeAudioSource(audioSourceCountDown);

            Animation.NextFrame();
            Animation.IsActive = true;
            countdownStarted   = true;
        }
        public override void OnHit(GameObject hitObject)
        {
            if (audioSource == null)
            {
                audioSource = new AudioSource();
            }

            audioSource.Play(clipHitted);
            AudioManager.DisposeAudioSource(audioSource);

            isHitted                       = true;
            Animation.IsActive             = true;
            RigidBody.IsCollisionsAffected = false;

            GameManager.CurrentCheckpoint = this;
        }
        protected override void OnCollisionFromY(Player player, Collision colllisionInfo)
        {
            float deltaY = colllisionInfo.Delta.Y;

            if (deltaY < 0)
            {
                OnHit(player);
            }
            else if (PlayerImpactY >= minInpactToDetectYCollision)
            {
                bounceMultiplierY = Math.Abs(bounceMultiplierY);
                bounceBehaviour.Bounce(player);

                audioSourceBounce = new AudioSource();
                audioSourceBounce.Play(clipBounce);
                AudioManager.DisposeAudioSource(audioSourceBounce);
            }
            //else //dici al player che è grounded? mentre il player se è bounce non fa nulla??? è il player che chiama Bounce?? on collision del player viene chiamato alla fine
        }
Example #14
0
        public override void Update()
        {
            if (crateTriggered)
            {
                if (timeToTriggered <= 0)
                {
                    audioSource = new AudioSource();
                    audioSource.Play(clipTriggered);
                    AudioManager.DisposeAudioSource(audioSource);

                    IsActive       = false;
                    crate.IsActive = true;
                    crateTriggered = false;
                }
                else
                {
                    timeToTriggered -= Game.DeltaTime;
                }
            }
        }