public bool Fall(Vector2 a_newPos, ISpundObserver a_soundEffect)
 {
     if (a_newPos.Y > g_levelHeight + 1)
     {
         a_soundEffect.DeathSound();
         return true;
     }
     return false;
 }
        public bool IsCollidingAtTrap(Vector2 a_newPos, Vector2 a_size, ISpundObserver a_soundEffect)
        {
            Vector2 topLeft = new Vector2(a_newPos.X, a_newPos.Y - a_size.Y);   // (a_newPos.X / 2.0f, a_newPos.Y - a_size.Y);
            Vector2 bottomRight = new Vector2(a_newPos.X, a_newPos.Y);
            for (int x = 0; x < g_levelWidth; x++)
            {
                for (int y = 0; y < g_levelHeight; y++)
                {

                    if (bottomRight.X < (float)x)
                        continue;
                    if (bottomRight.Y < (float)y)
                        continue;
                    if (topLeft.X > (float)x + 0.8f)
                        continue;
                    if (topLeft.Y > (float)y + 0.8f)
                        continue;

                    if (m_tiles[x, y] == Tile.T_TRAP)
                    {
                        a_soundEffect.DeathSound();
                        return true;
                    }
                }

            }
            return false;
        }
        public bool IsCollidingAtPoint(Vector2 a_newPos, Vector2 a_size, ISpundObserver a_soundEffect)
        {
            Vector2 topLeft = new Vector2(a_newPos.X + a_size.X / 4, a_newPos.Y - a_size.Y);   // (a_newPos.X / 2.0f, a_newPos.Y - a_size.Y);
             Vector2 bottomRight = new Vector2(a_newPos.X + a_size.X / 20, a_newPos.Y);
            //int points = 0;

            for (int x = 0; x < g_levelWidth; x++)
            {
                for (int y = 0; y < g_levelHeight; y++)
                {

                    if (bottomRight.X < (float)x)
                        continue;
                    if (bottomRight.Y < (float)y)
                        continue;
                    if (topLeft.X > (float)x + 1.0f)
                        continue;
                    if (topLeft.Y > (float)y + 1.0f)
                        continue;

                    if (m_tiles[x, y] == Tile.T_POINTS)

                    {
                        m_tiles[x, y] = Tile.T_EMPTY;
                        a_soundEffect.PointSound();

                        return true;
                    }

                }

            }
            return false;
        }
        private bool CollideWithEnemyTwo(Vector2 a_newPos, ISpundObserver a_soundEffect)
        {
            for (int i = 0; i < m_enemy.Count; i++)
            {
                if ((m_enemy[i].GetPosition() - a_newPos).Length() < 0.5f)
                {
                    a_soundEffect.DeathSound();
                    return true;
                }

            }
            return false;
        }
        internal void UpdatePlayer(float a_elapsedTime, IStateObserver a_observer, ISpundObserver a_points)
        {
            Vector2 oldPos = m_player.GetPosition();
            //get a new position for the player
            m_player.Update(a_elapsedTime);
            Vector2 newPos = m_player.GetPosition();

            m_hasCollidedWithGround = false;
            Vector2 speed = m_player.GetSpeed();
            Vector2 afterCollidedPos = Collide(oldPos, newPos, m_player.m_sizes, ref speed, out m_hasCollidedWithGround, a_observer);

            //set the new speed and position after collision
            m_player.SetPosition(afterCollidedPos.X, afterCollidedPos.Y);
            m_player.SetPosition(afterCollidedPos.X, afterCollidedPos.Y);
            m_player.SetSpeed(speed.X, speed.Y);

            if (afterCollidedPos.X > Level.g_levelWidth - 3)
            {
                speed = new Vector2(0.0f, 0.0f);
                afterCollidedPos = new Vector2(5.0f, 0.0f);
                m_level.NextLevel(a_observer);

            }

            if(m_level.IsCollidingAtEscape(newPos, m_player.m_sizes))
            {
                m_level.GameCompleted(a_observer);

            }

            if (m_level.IsCollidingAtPoint(newPos, m_player.m_sizes, a_points))
            {
                m_player.GaindPoint();

                //  m_level.CountPoint(a_points);

            }

            if(m_level.Fall(newPos, a_points))
            {
                  m_level.Restart(a_observer);
            }
            if (m_level.IsCollidingAtEnemy(newPos, m_player.m_sizes, a_points))
            {

                m_level.Restart(a_observer);
                DoStartOver();

            }

            if (CollideWithEnemyTwo(newPos, a_points) == true)
            {
                m_level.Restart(a_observer);
                new Vector2(5.0f, 16f);
            }
            if (m_level.IsCollidingAtTrap(newPos, m_player.m_sizes, a_points))
            {
                m_level.Restart(a_observer);
               // return new Vector2(6.0f, 16f);
            }
        }
        internal void Update(float a_elapsedTime, IStateObserver a_observer, ISpundObserver a_points)
        {
            UpdateEnemy(a_elapsedTime);
               UpdatePlayer(a_elapsedTime, a_observer, a_points);

              //  a_model.Update(a_elapsedTime, a_points, a_model);
        }