Exemple #1
0
        protected static ComponentRenderer GetRenderer()
        {
            ComponentRenderer renderer = new ComponentRenderer();
            StaticTexture     texture  = new StaticTexture(GetTextureID(), RenderLayer.DirtBase);

            renderer.RenderQueue.Add(texture);
            return(renderer);
        }
Exemple #2
0
        public void InitialStartup()
        {
            StaticTexture MapleStump  = new StaticTexture(AssetManager.NameToIndex[TextureLoader.MapleStump], RenderLayer.TreeStump);
            StaticTexture MapleTrunk  = new StaticTexture(AssetManager.NameToIndex[TextureLoader.MapleTrunk], RenderLayer.TreeTrunk);
            StaticTexture MapleLeaves = new StaticTexture(AssetManager.NameToIndex[TextureLoader.MapleLeaves1], RenderLayer.TreeLeaves);

            OffsetTexture OffsetMapleStump  = new OffsetTexture(RenderLayer.TreeStump, MapleStump, MapleTree.XOffset, MapleTree.YOffset);
            OffsetTexture OffsetMapleTrunk  = new OffsetTexture(RenderLayer.TreeTrunk, MapleTrunk, MapleTree.XOffset, MapleTree.YOffset);
            OffsetTexture OffsetMapleLeaves = new OffsetTexture(RenderLayer.TreeLeaves, MapleLeaves, MapleTree.XOffset, MapleTree.YOffset);

            MapleTree.OffsetStump  = OffsetMapleStump;
            MapleTree.OffsetTrunk  = OffsetMapleTrunk;
            MapleTree.OffsetLeaves = OffsetMapleLeaves;

            StaticTexture OakStump  = new StaticTexture(AssetManager.NameToIndex[TextureLoader.OakStump], RenderLayer.TreeStump);
            StaticTexture OakTrunk  = new StaticTexture(AssetManager.NameToIndex[TextureLoader.OakTrunk], RenderLayer.TreeTrunk);
            StaticTexture OakLeaves = new StaticTexture(AssetManager.NameToIndex[TextureLoader.OakLeaves1], RenderLayer.TreeLeaves);

            OffsetTexture OffsetOakStump  = new OffsetTexture(RenderLayer.TreeStump, OakStump, OakTree.XOffset, OakTree.YOffset);
            OffsetTexture OffsetOakTrunk  = new OffsetTexture(RenderLayer.TreeTrunk, OakTrunk, OakTree.XOffset, OakTree.YOffset);
            OffsetTexture OffsetOakLeaves = new OffsetTexture(RenderLayer.TreeLeaves, OakLeaves, OakTree.XOffset, OakTree.YOffset);

            OakTree.OffsetStump  = OffsetOakStump;
            OakTree.OffsetTrunk  = OffsetOakTrunk;
            OakTree.OffsetLeaves = OffsetOakLeaves;

            StaticTexture PineStump  = new StaticTexture(AssetManager.NameToIndex[TextureLoader.PineStump], RenderLayer.TreeStump);
            StaticTexture PineTrunk  = new StaticTexture(AssetManager.NameToIndex[TextureLoader.PineTrunk], RenderLayer.TreeTrunk);
            StaticTexture PineLeaves = new StaticTexture(AssetManager.NameToIndex[TextureLoader.PineLeaves1], RenderLayer.TreeLeaves);

            OffsetTexture OffsetPineStump  = new OffsetTexture(RenderLayer.TreeStump, PineStump, PineTree.XOffset, PineTree.YOffset);
            OffsetTexture OffsetPineTrunk  = new OffsetTexture(RenderLayer.TreeTrunk, PineTrunk, PineTree.XOffset, PineTree.YOffset);
            OffsetTexture OffsetPineLeaves = new OffsetTexture(RenderLayer.TreeLeaves, PineLeaves, PineTree.XOffset, PineTree.YOffset);

            PineTree.OffsetStump  = OffsetPineStump;
            PineTree.OffsetTrunk  = OffsetPineTrunk;
            PineTree.OffsetLeaves = OffsetPineLeaves;
        }
Exemple #3
0
        private StaticTexture GenerateTileTexture(TileGrid grid, int x, int y, bool edgesExtend = true, int yInc = 0)
        {
            if (grid[x, y] == '0')
            {
                return(new StaticTexture()
                {
                    Visible = false
                });
            }

            StaticTexture tex = new StaticTexture()
            {
                Visible = true
            };

            int num = 0;

            byte[] adjacent = new byte[9];
            bool   center   = true;

            Tileset t = Tilesets[(char)grid[x, y]];

            for (int ty = -1; ty < 2; ty++)
            {
                for (int tx = -1; tx < 2; tx++)
                {
                    bool res = CheckTile(grid, t, x + tx, y + ty, edgesExtend);
                    if (res)
                    {
                        adjacent[num++] = 1;
                    }
                    else
                    {
                        adjacent[num++] = 0;
                        center          = false;
                    }
                }
            }

            if (center)
            {
                if (!CheckTile(grid, t, x - 2, y, edgesExtend) ||
                    !CheckTile(grid, t, x + 2, y, edgesExtend) ||
                    !CheckTile(grid, t, x, y - 2, edgesExtend) ||
                    !CheckTile(grid, t, x, y + 2, edgesExtend))
                {
                    tex.Texture = t.Padding[TileRand[(x + yInc) % TILE_RAND_SIZE] % t.Padding.Count];
                }
                else
                {
                    tex.Texture = t.Center[TileRand[(x + yInc) % TILE_RAND_SIZE] % t.Center.Count];
                }
            }
            else
            {
                tex.Texture = GFX.Empty; // Set to arbitrary texture incase there isn't a valid mask.
                tex.Visible = false;
                foreach (TileMask m in t.Masks)
                {
                    bool found = true;
                    int  index = 0;
                    while (index < 9 && found)
                    {
                        if (m.Mask[index] != 2 && m.Mask[index] != adjacent[index])
                        {
                            found = false;
                        }

                        index++;
                    }

                    if (found)
                    {
                        tex.Texture = m.Textures[TileRand[(x + yInc) % TILE_RAND_SIZE] % m.Textures.Count];
                        tex.Visible = true;
                        break;
                    }
                }
            }

            tex.Position = new Vector2(x * 8, y * 8);

            return(tex);
        }