Ejemplo n.º 1
0
        private void checkDamage()
        {
            if (_isGrounded && _groundHitSpeed >= 16 || _isDead)
            {
                _isDead = true;

                Console.WriteLine("ded, D E D");

                if (_firstFrame)
                {
                    currentFrame = 22;
                    _firstFrame  = false;
                }
                else
                {
                    _frame = 0.0f;
                    NextFrame();
                    //After the last frame is played, the level will be reseted
                    if (currentFrame > 25)
                    {
                        currentFrame  = 25;
                        _playerLives -= 1;
                        Level level = parent as Level;
                        level.ResetLevel();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks other collisions like the pumpkins, keys and spikes
        /// </summary>
        private void checkOtherCollisions()
        {
            foreach (var other in GetCollisions())
            {
                if (other is Pickup)
                {
                    Pickup pickup = other as Pickup;
                    switch (pickup.GetPickupType)
                    {
                    case PickupType.Pumpkin:
                        _score++;
                        pickup.Destroy();
                        break;

                    case PickupType.Key:
                        hasKey = true;
                        pickup.Destroy();
                        break;
                    }
                }
                if (other is Tile)
                {
                    Tile tile = other as Tile;
                    if (tile.GetTileType == TileType.Deadly)
                    {
                        Level level = parent as Level;
                        level.ResetLevel();
                    }
                    if (tile.GetTileType == TileType.Exit && hasKey)
                    {
                        Level level = parent as Level;
                        level.NextLevel();
                    }
                }
            }
        }