コード例 #1
0
        public void Draw(SpriteBatch spriteBatch, RenderLayers layer)
        {
            // padding area of 5 for draws
            Rectangle area = GetScreenArea(5);

            for (int x = area.Left; x <= area.Right; x++)
            {
                for (int y = area.Top; y <= area.Bottom; y++)
                {
                    CoverData data = GetData(x, y);

                    // don't do anything
                    if (data.Orientation == 0)
                    {
                        continue;
                    }

                    if (_coveringTypes[data.Type].Layer != layer)
                    {
                        continue;
                    }

                    _coveringTypes[data.Type].Draw(spriteBatch, x, y, data.Variation, data.Orientation);
                }
            }
        }
コード例 #2
0
        public void Update(GameTime gameTime)
        {
            // update array if necessary
            if (Main.tile.GetLength(0) != _dataWidth || Main.tile.GetLength(1) != _dataHeight)
            {
                UpdateChunksArray();
            }

            // padding area of 20 for updates
            Rectangle area = GetScreenArea(20);

            for (int x = area.Left; x <= area.Right; x++)
            {
                for (int y = area.Top; y <= area.Bottom; y++)
                {
                    CoverData data = GetData(x, y);

                    // don't do anything
                    if (data.Orientation == 0)
                    {
                        continue;
                    }

                    var type = _coveringTypes[data.Type];

                    if (!type.IsValidAt(x, y))
                    {
                        RemoveAt(x, y);
                        continue;
                    }

                    type.Update(gameTime, x, y, data.Variation, data.Orientation);
                }
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        public void SetData(int x, int y, CoverData data)
        {
            if (!_coveringTypes[data.Type].IsValidAt(x, y))
            {
                return;
            }

            ValidateExists(x, y);
            GetChunkAt(x, y).SetData(GetPositionInChunk(x, y), data);
        }