Ejemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            if (HitTest(player.playerRect, consumableRect) && !Destroyed)
            {
                if (Points)
                {
                    scoreManager.AddPoints(numPoints);
                    var hitSound = GameContent.instance.fireflypickup.CreateInstance();
                    hitSound.Volume = 1f;
                    hitSound.Play();
                    Visible   = false;
                    Destroyed = true;
                }

                if (Health)
                {
                    if (player.Health < 5)
                    {
                        player.Health += 1;
                    }
                    var hitSound = GameContent.instance.fruitpickup.CreateInstance();
                    hitSound.Volume = 1f;
                    hitSound.Play();
                    Visible   = false;
                    Destroyed = true;
                }
            }

            //checks wave collisions
            for (int i = 0; i < player.echoWaves.Count; i++)
            {
                for (int j = 0; j < player.echoWaves[i].collisionRectangles.Count; j++)
                {
                    if (!Destroyed && HitTest(player.echoWaves[i].collisionRectangles[j], consumableRect))
                    {
                        visionTimer = (float)gameTime.TotalGameTime.TotalMilliseconds;
                        Visible     = true;
                    }
                }
            }


            Move();
            Sway();
            //VisionCheck(gameTime);


            if (X <= -50)
            {
                Destroyed = true;
                Visible   = false;
            }
        }
Ejemplo n.º 2
0
        public void Update(GameTime gameTime)
        {
            if (HitTest(player.playerRect, consumableRect) && !Destroyed)
            {
                if (Points)
                {
                    scoreManager.AddPoints(numPoints);
                    Visible   = false;
                    Destroyed = true;
                }

                if (Health)
                {
                    player.Health += 1;
                    Visible        = false;
                    Destroyed      = true;
                }
            }

            //checks wave collisions
            for (int i = 0; i < player.echoWaves.Count; i++)
            {
                for (int j = 0; j < player.echoWaves[i].collisionRectangles.Count; j++)
                {
                    if (!Destroyed && HitTest(player.echoWaves[i].collisionRectangles[j], consumableRect))
                    {
                        visionTimer = (float)gameTime.TotalGameTime.TotalMilliseconds;
                        Visible     = true;
                    }
                }
            }


            Move();
            Sway();
            VisionCheck(gameTime);


            if (X <= -50)
            {
                Destroyed = true;
                Visible   = false;
            }
        }