Esempio n. 1
0
        public override void Update(GameTime gameTime, int x, int y, int variation, int orientation)
        {
            // try move upwards
            Tile above = Framing.GetTileSafely(x, y - 1);

            if (above != null && above.liquid > 0)
            {
                CoverData data = CoveringsManager.GetData(x, y);
                CoveringsManager.RemoveAt(x, y);
                CoveringsManager.SetData(x, y - 1, data);

                // update that tile
                Update(gameTime, x, y - 1, variation, orientation);
                return; // return quick
            }

            // try move downwards if our current tile is empty
            Tile tile = Framing.GetTileSafely(x, y);

            if (tile.liquid == 0)
            {
                CoverData data = CoveringsManager.GetData(x, y);
                // because IsValidAt(x,y) returned true, we know the tile below has liquid in it
                // so just move this covering to that tile
                CoveringsManager.RemoveAt(x, y);
                CoveringsManager.SetData(x, y + 1, data);

                // update that tile
                Update(gameTime, x, y + 1, variation, orientation);
                return; // return quick
            }

            base.Update(gameTime, x, y, variation, orientation);
        }
        protected void DrawCoveringsOnTileVariations(SpriteBatch spriteBatch, int x, int y, Color clr, bool halfBrick, byte slope, int variation, int orientation)
        {
            Tile  tile  = Framing.GetTileSafely(x, y);
            Point frame = GetFrame(variation, orientation);
            ReadableOrientation readOri = (ReadableOrientation)orientation;

            // if this has an up/left orientation and so does the one to bottom left
            if ((readOri.Left || (tile.slope() == 2 && (readOri.Up || readOri.Left))) && ((ReadableOrientation)CoveringsManager.GetData(x - 1, y + 1).Orientation).Up)
            {
                DrawSpecificYFrame(spriteBatch, x, y + 1, frame, 20, clr);
                if (halfBrick)
                {
                    readOri.Left = true;
                }
            }

            // if this has an up orientation and so does the one to bottom right
            if ((readOri.Right || (tile.slope() == 1 && (readOri.Up || readOri.Right))) && ((ReadableOrientation)CoveringsManager.GetData(x + 1, y + 1).Orientation).Up)
            {
                DrawSpecificYFrame(spriteBatch, x, y + 1, frame, 20, clr, SpriteEffects.FlipHorizontally);
                if (halfBrick)
                {
                    readOri.Right = true;
                }
            }

            // if this has an down orientation and so does the one to bottom left
            if (readOri.Down && ((ReadableOrientation)CoveringsManager.GetData(x - 1, y + 1).Orientation).Down)
            {
                DrawSpecificYFrame(spriteBatch, x - 1, y, frame, 20, clr, SpriteEffects.FlipVertically);
            }

            // if this has an down orientation and so does the one to bottom left
            if (readOri.Down && ((ReadableOrientation)CoveringsManager.GetData(x + 1, y + 1).Orientation).Down)
            {
                DrawSpecificYFrame(spriteBatch, x + 1, y, frame, 20, clr, SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically);
            }

            // we do this so any changes made to the orientation from the above hacks take effect
            frame = GetFrame(variation, (int)readOri);

            if (halfBrick)
            {
                switch ((int)readOri)
                {
                case 4:
                    break;

                case 1:     // draw top half of texture moved down a bit
                case 2:
                case 3:
                case 8:
                case 9:
                case 10:
                case 11:
                    spriteBatch.Draw(Texture, new Vector2(x, y) * 16f - Main.screenPosition + Vector2.UnitY * 8f, new Rectangle(frame.X, frame.Y, 16, 8), clr, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    return;

                case 5:
                case 7:
                case 13:
                case 15:
                    // draw bottom half first
                    spriteBatch.Draw(Texture, new Vector2(x, y) * 16f - Main.screenPosition + Vector2.UnitY * 8f, new Rectangle(frame.X, frame.Y + 8, 16, 8), clr, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    // draw top half moved down a bit
                    spriteBatch.Draw(Texture, new Vector2(x, y) * 16f - Main.screenPosition + Vector2.UnitY * 8f, new Rectangle(frame.X, frame.Y, 16, 8), clr, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    return;

                case 6:     // draw bottom half
                case 12:
                case 14:
                    spriteBatch.Draw(Texture, new Vector2(x, y) * 16f - Main.screenPosition + Vector2.UnitY * 8f, new Rectangle(frame.X, frame.Y + 8, 16, 8), clr, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    return;
                }
            }

            if (slope > 0)
            {
                switch ((int)readOri)
                {
                case 1:
                    if (slope == 1)
                    {
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);     // TR
                        return;
                    }
                    if (slope == 2)
                    {
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);     // TL
                        return;
                    }
                    break;

                case 2:
                    if (slope == 1)
                    {
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);     // TR
                        return;
                    }
                    if (slope == 3)
                    {
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);     // BR
                        return;
                    }
                    break;

                case 3:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        return;

                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 2, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);         // BR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 1, clr);
                        return;
                    }
                    break;

                case 4:
                    if (slope == 3)
                    {
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);     // BR
                        return;
                    }
                    if (slope == 4)
                    {
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);     // BL
                        return;
                    }
                    break;

                case 5:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 4, clr);
                        return;

                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 4, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);         // BR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 1, clr);
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 1, clr);
                        return;
                    }
                    break;

                case 6:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 4, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);         // BR
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 2, clr);
                        return;
                    }
                    break;

                case 7:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 4, clr);
                        return;

                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 6, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);        // BR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 1, clr);         // BR
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 3, clr);
                        return;
                    }
                    break;

                case 8:
                    if (slope == 2)
                    {
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);     // BR
                        return;
                    }
                    if (slope == 4)
                    {
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);     // BL
                        return;
                    }
                    break;

                case 9:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 8, clr);
                        return;

                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 1, clr);
                        return;
                    }
                    break;

                case 10:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 8, clr);
                        return;

                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 2, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);         // BR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 8, clr);
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 2, clr);
                        return;
                    }
                    break;

                case 11:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 8, clr);
                        return;

                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 2, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);         // BR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 9, clr);
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 3, clr);
                        return;
                    }
                    break;

                case 12:
                    switch (slope)
                    {
                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 4, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);         // BR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 8, clr);
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        return;
                    }
                    break;

                case 13:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 12, clr);
                        return;

                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 4, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);         // BR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 9, clr);
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 1, clr);
                        return;
                    }
                    break;

                case 14:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 12, clr);
                        return;

                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 6, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);         // BR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 8, clr);
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 2, clr);
                        return;
                    }
                    break;

                case 15:
                    switch (slope)
                    {
                    case 1:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 17, clr);         // TR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 12, clr);
                        return;

                    case 2:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 16, clr);         // TL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 6, clr);
                        return;

                    case 3:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 18, clr);         // BR
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 9, clr);
                        return;

                    case 4:
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 19, clr);         // BL
                        DrawSpecificYFrame(spriteBatch, x, y, frame, 3, clr);
                        return;
                    }
                    break;
                }
            }

            spriteBatch.Draw(Texture, new Vector2(x, y) * 16f - Main.screenPosition, new Rectangle(frame.X, frame.Y, 16, 16), clr, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
        }