Exemplo n.º 1
0
        public override void Update(Tile tile)
        {
            // Entity collision and damage.
            // TODO: Change collision detection so that only entities in the same chunk get checked.
            if (_isSpittingFire)
            {
                foreach (var entity in GameWorld.Entities)
                {
                    if (entity.CollRectangle.Intersects(_collRectangle))
                    {
                        entity.TakeDamage(null, Damage);
                    }
                }

                foreach (Player player in GameWorld.GetPlayers())
                {
                    if (player.CollRectangle.Intersects(_collRectangle))
                    {
                        player.TakeDamage(null, Damage);
                    }
                }
            }

            // Particles and visual effects.
            _spitTimer.Increment();
            if (_isSpittingFire)
            {
                tile.AnimationStopped = false;
                _flameSound.PlayIfStopped();
                if (_spitTimer.TimeElapsedInMilliSeconds < FireTime)
                {
                    _fireBallTimer.Increment();
                    if (_fireBallTimer.TimeElapsedInMilliSeconds > ParticleTime)
                    {
                        _fireBallTimer.Reset();
                        ParticleSystem.Add(Particles.ParticleType.FireBall, _leftCornerTile + new Vector2(3, 0) * 2, CalcHelper.GetRandXAndY(new Rectangle(-10, -50, 20, 30)) / 10f, Color.White);
                        ParticleSystem.Add(Particles.ParticleType.FireBall, _leftCornerTile + new Vector2(12, 0) * 2, CalcHelper.GetRandXAndY(new Rectangle(-10, -50, 20, 30)) / 10f, Color.White);
                    }
                }
                else
                {
                    _isSpittingFire = false;
                    _spitTimer.Reset();
                }
            }
            else
            {
                _flameSound.Stop();
                tile.AnimationStopped = true;
                tile.CurrentFrame     = 1;
                if (_spitTimer.TimeElapsedInMilliSeconds > IdleTime)
                {
                    _isSpittingFire = true;
                    _spitTimer.Reset();
                }
            }

            base.Update(tile);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Provides sound and effects for destruction.
 /// </summary>
 /// <param name="t"></param>
 private static void Destroy(Tile t)
 {
     IdleTimerForSave.Reset();
     _hasChangedSinceLastSave = true;
     _destruction.PlayIfStopped();
     CreateDestructionParticles(t.GetDrawRectangle());
     TMBAW_Game.Camera.Shake();
 }
Exemplo n.º 3
0
 private void Item_CollidedWithTerrain(Entity entity, Tile tile)
 {
     if (Math.Abs(Velocity.Y) > 3)
     {
         // Prevent annoying bounce sound for infinity.
         if (_pickUpTimer.TimeElapsedInMilliSeconds < 5000)
         {
             BounceSound?.PlayIfStopped();
         }
     }
 }
Exemplo n.º 4
0
        public void OnCollisionWithTerrainBelow(Entity entity, Tile tile)
        {
            SetY(tile.DrawRectangle.Y - CollRectangle.Height);
            if (Velocity.Y < 3)
            {
                Velocity.Y = 0;
            }
            else
            {
                Velocity.Y *= -.9f;

                _hitGround.PlayIfStopped();
            }
        }
Exemplo n.º 5
0
        public override void Update(Tile tile)
        {
            heatTimer.Increment();
            bubblingSound.PlayIfStopped();

            if (heatTimer.TimeElapsedInMilliSeconds > 500)
            {
                heatTimer.Reset();
                if (GameWorld.GetTileAbove(tile.TileIndex).Id == TMBAW_Game.TileType.Air)
                {
                    ParticleSystem.Add(ParticleType.HeatEffect, new Vector2(tile.GetDrawRectangle().Center.X, tile.GetDrawRectangle().Top), CalcHelper.GetRandXAndY(new Rectangle(-10, -10, 10, 0)) / 10, Color.White);
                }
            }
        }
Exemplo n.º 6
0
        public override void Update()
        {
            GameTime gameTime = TMBAW_Game.GameTime;

            _pickUpTimer.Increment();
            foreach (Player player in GameWorld.GetPlayers())
            {
                if (player.GetCollRectangle().Intersects(DrawRectangle) && _pickUpTimer.TimeElapsedInMilliSeconds > 500)
                {
                    OnPlayerPickUp?.Invoke(new PickedUpArgs(player));
                    PickUpSound?.PlayOnce();
                    ToDelete = true;
                    LoopSound?.Stop();
                    break;
                }
            }

            LoopSound?.PlayIfStopped();

            base.Update();
        }
Exemplo n.º 7
0
 public void Update()
 {
     _ambience?.PlayIfStopped();
 }