Exemplo n.º 1
0
        private void CheckLava(BoundingBox2D playerBox)
        {
            Vector2 bottomLeft  = new Vector2(playerBox.Left, playerBox.Bottom);
            Vector2 bottomRight = new Vector2(playerBox.Right, playerBox.Bottom);

            if (lava.CheckSubmerged(bottomLeft) || lava.CheckSubmerged(bottomRight))
            {
                if (!submerged)
                {
                    player.RegisterDamage(CollisionDirections.DOWN);
                    submerged = true;
                }
            }
            else if (submerged)
            {
                submerged = false;
            }
        }
Exemplo n.º 2
0
        public void Update(float dt)
        {
            for (int i = 0; i < setPieces.Count; i++)
            {
                SetPiece setPiece = setPieces[i];

                if (setPiece.Destroyed)
                {
                    setPieces.RemoveAt(i);
                }
                else
                {
                    setPiece.Update(dt);
                }
            }

            for (int i = 0; i < platforms.Count; i++)
            {
                Platform platform = platforms[i];

                if (platform.Destroyed)
                {
                    platforms.RemoveAt(i);
                }
                else
                {
                    BoundingBox2D boundingBox = platform.BoundingBox;
                    Vector2       bottomLeft  = new Vector2(boundingBox.Left, boundingBox.Bottom);
                    Vector2       bottomRight = new Vector2(boundingBox.Right, boundingBox.Bottom);

                    if (lava.CheckSubmerged(bottomLeft) || lava.CheckSubmerged(bottomRight))
                    {
                        platform.Destroy();
                        platforms.RemoveAt(i);
                    }
                    else
                    {
                        platform.Update(dt);
                    }
                }
            }

            GeneratePlatforms();
        }