Ejemplo n.º 1
0
 public ShadowTile(int dist, Point p, ShadowTile prev, Tile t)
 {
     this.distance = dist;
     this.position = p;
     this.previous = prev;
     this.tile     = t;
 }
Ejemplo n.º 2
0
        private void DrawObjectLayer(Dictionary <string, Dictionary <string, ArrayList> > layerData)
        {
            Camera cam = Systems.camera;

            short startX = Math.Max((short)0, cam.GridX);
            short startY = Math.Max((short)0, cam.GridY);

            short gridX = (short)(startX + (byte)TilemapEnum.MinWidth + 1);             // +1 is to render the edge.
            short gridY = (short)(startY + (byte)TilemapEnum.MinHeight + 1);            // +1 is to render the edge.

            if (gridX > this.xCount)
            {
                gridX = this.xCount;
            }                                                            // Must limit to room size.
            if (gridY > this.yCount)
            {
                gridY = this.yCount;
            }                                                            // Must limit to room size.

            // Camera Position
            bool isShaking = cam.IsShaking();
            int  camX      = cam.posX + (isShaking ? cam.GetCameraShakeOffsetX() : 0);
            int  camY      = cam.posY + (isShaking ? cam.GetCameraShakeOffsetY() : 0);

            // Loop through the tilemap data:
            for (short y = gridY; y-- > startY;)
            {
                short tileYPos = (short)(y * (byte)TilemapEnum.TileHeight - camY);

                string yStr = y.ToString();

                // Make sure this Y-line exists, or skip further review:
                if (!layerData.ContainsKey(yStr))
                {
                    continue;
                }
                var yData = layerData[yStr];

                for (short x = gridX; x-- > startX;)
                {
                    // Verify Tile Data exists at this Grid Square:
                    if (!yData.ContainsKey(x.ToString()))
                    {
                        continue;
                    }
                    var  xData   = yData[x.ToString()];
                    byte index   = byte.Parse(xData[0].ToString());
                    byte subType = byte.Parse(xData[1].ToString());

                    // Draw Layer
                    ShadowTile.Draw(index, subType, null, x * (byte)TilemapEnum.TileWidth - camX, tileYPos);
                }
                ;
            }
        }
Ejemplo n.º 3
0
        public void DrawCurrentGridSquare()
        {
            // Draw Currently Slotted Item & Highlighted Grid Square (if not overlapping a UI component)
            if (UIComponent.ComponentWithFocus == null)
            {
                // Draw Temporary Function Tool (if active)
                if (EditorTools.tempTool != null)
                {
                    EditorTools.tempTool.DrawFuncTool();
                }

                // Draw Function Tool (if active)
                else if (EditorTools.funcTool != null)
                {
                    EditorTools.funcTool.DrawFuncTool();
                }

                // Draw AutoTile Tool (if active)
                else if (EditorTools.autoTool.IsActive)
                {
                    EditorTools.autoTool.DrawAutoTiles();
                }

                // Draw Tile Tool (if active)
                else if (EditorTools.tileTool != null)
                {
                    EditorPlaceholder ph = EditorTools.tileTool.CurrentPlaceholder;

                    // Draw Tile
                    if (ph.tileId > 0)
                    {
                        if (Systems.mapper.TileDict.ContainsKey(ph.tileId))
                        {
                            TileObject tgo = Systems.mapper.TileDict[ph.tileId];
                            tgo.Draw(null, ph.subType, Cursor.TileGridX * (byte)TilemapEnum.TileWidth - Systems.camera.posX, Cursor.TileGridY * (byte)TilemapEnum.TileHeight - Systems.camera.posY);
                        }
                    }

                    // Draw Object
                    else if (ph.objectId > 0)
                    {
                        ShadowTile.Draw(ph.objectId, ph.subType, null, Cursor.TileGridX * (byte)TilemapEnum.TileWidth - Systems.camera.posX, Cursor.TileGridY * (byte)TilemapEnum.TileHeight - Systems.camera.posY);
                    }

                    Systems.spriteBatch.Draw(Systems.tex2dDarkRed, new Rectangle(Cursor.TileGridX * (byte)TilemapEnum.TileWidth - Systems.camera.posX, Cursor.TileGridY * (byte)TilemapEnum.TileHeight - Systems.camera.posY, (byte)TilemapEnum.TileWidth, (byte)TilemapEnum.TileHeight), Color.White * 0.25f);
                }
            }
        }
Ejemplo n.º 4
0
        public void DrawBlueprintByLayer(LayerEnum layerEnum, short x, short y, short xStart, short yStart)
        {
            // Get the value stored in this blueprint at correct tile position:
            ArrayList bpData = this.gridTrack[(byte)layerEnum, y, x];

            if (bpData == null)
            {
                return;
            }

            // Verify that a TileID (or ObjectID) is present
            byte objOrTileID = byte.Parse(bpData[0].ToString());

            if (objOrTileID == 0)
            {
                return;
            }

            // Drawing Objects
            if (layerEnum == LayerEnum.obj)
            {
                ShadowTile.Draw(objOrTileID, byte.Parse(bpData[1].ToString()), null, (xStart + x) * (byte)TilemapEnum.TileWidth - Systems.camera.posX, (yStart + y) * (byte)TilemapEnum.TileHeight - Systems.camera.posY);
            }

            // Drawing Tiles
            else
            {
                var tileDict = Systems.mapper.TileDict;

                if (tileDict.ContainsKey(objOrTileID))
                {
                    TileObject tgo = tileDict[objOrTileID];
                    tgo.Draw(null, byte.Parse(bpData[1].ToString()), (xStart + x) * (byte)TilemapEnum.TileWidth - Systems.camera.posX, (yStart + y) * (byte)TilemapEnum.TileHeight - Systems.camera.posY);
                }
            }
        }
Ejemplo n.º 5
0
 public PathfindingData(Tile t, ShadowTile st)
 {
     this.tile   = t;
     this.shadow = st;
 }
Ejemplo n.º 6
0
 ///<summary>
 /// Assigns the previous property.
 /// <param name="previous"> ShadowTile to assign as previous.</param>
 ///</summary>
 public void AssignPrevious(ShadowTile previous)
 {
     this.previous = previous;
 }
Ejemplo n.º 7
0
        public void Draw()
        {
            byte tileWidth = (byte)TilemapEnum.TileWidth + 2;

            // Draw Utility Bar Background
            Systems.spriteBatch.Draw(Systems.tex2dWhite, new Rectangle(this.x, this.y - 2, this.width, this.height + 2), Color.DarkSlateGray);
            Systems.spriteBatch.Draw(Systems.tex2dWhite, new Rectangle(this.x + 2, this.y, this.width - 2, this.height), Color.White);

            // Tile Outlines
            for (byte i = 0; i <= (byte)UtilityBarEnum.BarTiles; i++)
            {
                Systems.spriteBatch.Draw(Systems.tex2dWhite, new Rectangle(this.x + i * tileWidth, this.y, 2, this.height), Color.DarkSlateGray);
            }

            // Tile Icons
            if (TileTool.tileToolMap.ContainsKey(EditorUI.currentSlotGroup))
            {
                List <EditorPlaceholder[]>    placeholders = TileTool.tileToolMap[EditorUI.currentSlotGroup].placeholders;
                Dictionary <byte, TileObject> tileDict     = Systems.mapper.TileDict;

                for (byte i = 0; i < 10; i++)
                {
                    if (placeholders.Count <= i)
                    {
                        continue;
                    }
                    EditorPlaceholder ph = placeholders[i][0];
                    byte tileId          = ph.tileId;

                    // Draw Tile
                    if (tileId > 0)
                    {
                        if (!tileDict.ContainsKey(tileId))
                        {
                            continue;
                        }
                        tileDict[tileId].Draw(null, ph.subType, this.x + i * tileWidth + 2, this.y);
                    }

                    // Draw Object (if tile is not present)
                    else if (ph.objectId > 0)
                    {
                        ShadowTile.Draw(ph.objectId, ph.subType, null, this.x + i * tileWidth + 2, this.y);
                    }
                }
            }

            // Draw Keybind Text
            for (byte i = 0; i < 10; i++)
            {
                Systems.fonts.baseText.Draw((i + 1).ToString(), this.x + i * tileWidth + 4, this.y + this.height - 18, Color.DarkOrange);
            }

            // Function Icons
            foreach (KeyValuePair <byte, FuncButton> button in this.buttonMap)
            {
                byte barIndex = button.Key;
                button.Value.DrawFunctionTile(this.x + barIndex * tileWidth + 2, this.y);
            }

            // Hovering Visual
            if (UIComponent.ComponentWithFocus is UtilityBar)
            {
                short mx = (short)Snap.GridFloor(tileWidth, Cursor.MouseX - this.x);

                Systems.spriteBatch.Draw(Systems.tex2dDarkRed, new Rectangle(this.x + mx * tileWidth, this.y, tileWidth, this.height), Color.White * 0.5f);
            }
        }
Ejemplo n.º 8
0
        public void Draw()
        {
            if (EditorTools.tileTool is TileTool == false)
            {
                return;
            }

            byte tileHeight = (byte)TilemapEnum.TileHeight + 2;

            // Draw Editor Scroller Background
            Systems.spriteBatch.Draw(Systems.tex2dWhite, new Rectangle(this.x, this.y, this.width, this.height), Color.DarkSlateGray);
            Systems.spriteBatch.Draw(Systems.tex2dWhite, new Rectangle(this.x + 2, this.y + 2, (byte)TilemapEnum.TileWidth, this.height - 6), Color.White);

            // Grid Outline
            for (byte i = 1; i < (byte)EScrollerEnum.NumTiles; i++)
            {
                Systems.spriteBatch.Draw(Systems.tex2dWhite, new Rectangle(this.x, this.y + i * tileHeight, this.width, 2), Color.DarkSlateGray);
            }

            // Draw TileTool Subtype Buttons
            List <EditorPlaceholder[]> placeholders = EditorTools.tileTool.placeholders;

            // Placeholder Loop
            byte len = (byte)placeholders.Count;

            EditorPlaceholder[] pData = placeholders[EditorTools.tileTool.index];

            byte phSubLen = (byte)pData.Length;

            for (byte s = 0; s < phSubLen; s++)
            {
                EditorPlaceholder ph = pData[s];

                byte subType = ph.subType;
                byte tileId  = ph.tileId;

                // Draw Tiles
                if (tileId > 0)
                {
                    if (Systems.mapper.TileDict.ContainsKey(tileId))
                    {
                        TileObject tgo = Systems.mapper.TileDict[tileId];
                        tgo.Draw(null, subType, this.x + 2, this.y + 50 * s + 2);
                    }
                }

                // Draw Objects
                else if (ph.objectId > 0)
                {
                    ShadowTile.Draw(ph.objectId, ph.subType, null, this.x + 2, this.y + 50 * s + 2);
                }
            }

            // Highlight the active color
            short my = (short)Snap.GridFloor(tileHeight, EditorTools.tileTool.subIndex * tileHeight - this.y);

            Systems.spriteBatch.Draw(Systems.tex2dDarkRed, new Rectangle(this.x, this.y + my * tileHeight, this.width, tileHeight), Color.White * 0.5f);

            // Hovering Visual
            if (UIComponent.ComponentWithFocus is EditorScroller)
            {
                short my2 = (short)Snap.GridFloor(tileHeight, Cursor.MouseY - this.y);

                Systems.spriteBatch.Draw(Systems.tex2dDarkRed, new Rectangle(this.x, this.y + my2 * tileHeight, this.width, tileHeight), Color.White * 0.5f);
            }
        }