示例#1
0
        private void CalculateDifferencies()
        {
            if (currentFinalTiles != null)
            {
                DisplayTile[][] Tiles = new DisplayTile[requestedFinalTiles.Length][];
                bool            differentLine;
                for (int i = 0; i < currentFinalTiles.Length; i++)
                {
                    Tiles[i]      = new DisplayTile[requestedFinalTiles[i].Length];
                    differentLine = false;
                    for (int j = 0; j < currentFinalTiles[i].Length; j++)
                    {
                        if (currentFinalTiles[i][j].Icon != requestedFinalTiles[i][j].Icon)
                        {
                            differentLine = true;
                        }

                        Tiles[i][j] = requestedFinalTiles[i][j];
                    }

                    if (!differentLine)
                    {
                        Tiles[i].ToList().ForEach(x => x.SkipThisTile = true);
                    }
                }

                bufferedTiles = Tiles;
            }
            else
            {
                bufferedTiles = requestedFinalTiles;
            }
            currentFinalTiles = requestedFinalTiles;
        }
示例#2
0
        private void DrawTile(DisplayTile tile, int x, int y)
        {
            Int32 w = this.GlyphPalette.GlyphDimensions.Width;
            Int32 h = this.GlyphPalette.GlyphDimensions.Height;

            x *= w;
            y *= h;

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            List <IGlyphProvider> gproviders = new List <IGlyphProvider>();

            foreach (RegionTile t in tile.RegionTiles)
            {
                foreach (IGlyphProvider p in t.GlyphProviders)
                {
                    gproviders.Add(p);
                }
            }

            foreach (IGlyphProvider glyphpro in gproviders)
            {
                GL.Begin(BeginMode.Quads);
                GL.Color4(glyphpro.BackgroundColor);
                GL.Vertex2(x, y);
                GL.Vertex2(x + w, y);
                GL.Vertex2(x + w, h + y);
                GL.Vertex2(x, h + y);
                GL.End();

                foreach (Glyph glyph in glyphpro.Glyphs)
                {
                    int uvrow = glyph.Index / GlyphPalette.ColumnCount;
                    int uvcol = glyph.Index % GlyphPalette.ColumnCount;

                    double u  = (double)uvcol / (double)GlyphPalette.ColumnCount;
                    double v  = (double)uvrow / (double)GlyphPalette.RowCount;
                    double du = 1.0 / (double)GlyphPalette.ColumnCount;
                    double dv = 1.0 / (double)GlyphPalette.RowCount;

                    GL.Enable(EnableCap.Texture2D);
                    GL.BindTexture(TextureTarget.Texture2D, paletteId);

                    GL.Begin(BeginMode.Quads);
                    GL.Color4(glyph.Color);
                    GL.TexCoord2(u, v); GL.Vertex2(x, y);
                    GL.TexCoord2(du + u, v); GL.Vertex2(x + w, y);
                    GL.TexCoord2(du + u, dv + v); GL.Vertex2(x + w, h + y);
                    GL.TexCoord2(u, dv + v); GL.Vertex2(x, h + y);
                    GL.End();
                    GL.Disable(EnableCap.Texture2D);
                }
            }
            GL.Disable(EnableCap.Blend);
        }
示例#3
0
        public DisplayTile GetDisplayTile()
        {
            DisplayTile lTile = DisplayTile.DoorClosed;

            if (this.IsOpen)
            {
                lTile = DisplayTile.DoorOpen;
            }
            return(lTile);
        }
示例#4
0
 private DisplayTile[][] CopyBaseTilesToDisplayTiles(BaseTile[][] requestedTiles)
 {
     DisplayTile[][] newTiles = new DisplayTile[requestedTiles.Length][];
     for (int i = 0; i < requestedTiles.Length; i++)
     {
         newTiles[i] = new DisplayTile[requestedTiles[i].Length];
         for (int j = 0; j < requestedTiles[i].Length; j++)
         {
             newTiles[i][j] = new DisplayTile()
             {
                 Color = requestedTiles[i][j].Color, Icon = requestedTiles[i][j].Icon
             };
         }
     }
     return(newTiles);
 }
示例#5
0
        private void Render()
        {
            GL.MatrixMode(MatrixMode.Modelview);

            GL.LoadIdentity();

            Int32 w = this.GlyphPalette.GlyphDimensions.Width;
            Int32 h = this.GlyphPalette.GlyphDimensions.Height;

            for (Int32 x = 0; x < this.Size.Width; x++)
            {
                for (Int32 y = 0; y < this.Size.Height; y++)
                {
                    DisplayTile tile = this.tiles[x, y];

                    DrawTile(tile, x, y);
                    tile.MarkRenderClean();
                }
            }
        }
示例#6
0
        private void DrawWindow()
        {
            GL.MatrixMode(MatrixMode.Modelview);

            GL.LoadIdentity();

            int w = this.GlyphPalette.GlyphDimensions.Width;
            int h = this.GlyphPalette.GlyphDimensions.Height;

            List <KeyValuePair <Point, IGlyphProvider> > gproviders = new List <KeyValuePair <Point, IGlyphProvider> >();

            for (int x = 0; x < this.Size.Width; x++)
            {
                for (int y = 0; y < this.Size.Height; y++)
                {
                    DisplayTile tile = this.tiles[x, y];
                    foreach (RegionTile t in tile.RegionTiles)
                    {
                        foreach (IGlyphProvider p in t.GlyphProviders)
                        {
                            gproviders.Add(new KeyValuePair <Point, IGlyphProvider>(new Point(x, y), p));
                        }
                    }
                }
            }

            /* Draw Glyphs */
            GL.Begin(PrimitiveType.Quads);
            foreach (KeyValuePair <Point, IGlyphProvider> kvp in gproviders)
            {
                IGlyphProvider glyphpro = kvp.Value;
                Point          loc      = kvp.Key;

                int screen_x = loc.X * w;
                int screen_y = loc.Y * h;
                {
                    int uvrow = (int)Sharplike.UI.GlyphDefault.Block / GlyphPalette.ColumnCount;
                    int uvcol = (int)Sharplike.UI.GlyphDefault.Block % GlyphPalette.ColumnCount;

                    double u  = (double)uvcol / (double)GlyphPalette.ColumnCount;
                    double v  = (double)uvrow / (double)GlyphPalette.RowCount;
                    double du = 1.0 / (double)GlyphPalette.ColumnCount;
                    double dv = 1.0 / (double)GlyphPalette.RowCount;

                    GL.Color4(glyphpro.BackgroundColor);
                    GL.TexCoord2(u, v); GL.Vertex2(screen_x, screen_y);
                    GL.TexCoord2(du + u, v); GL.Vertex2(screen_x + w, screen_y);
                    GL.TexCoord2(du + u, dv + v); GL.Vertex2(screen_x + w, h + screen_y);
                    GL.TexCoord2(u, dv + v); GL.Vertex2(screen_x, h + screen_y);
                }

                foreach (Glyph glyph in glyphpro.Glyphs)
                {
                    int uvrow = glyph.Index / GlyphPalette.ColumnCount;
                    int uvcol = glyph.Index % GlyphPalette.ColumnCount;

                    double u  = (double)uvcol / (double)GlyphPalette.ColumnCount;
                    double v  = (double)uvrow / (double)GlyphPalette.RowCount;
                    double du = 1.0 / (double)GlyphPalette.ColumnCount;
                    double dv = 1.0 / (double)GlyphPalette.RowCount;

                    GL.Color4(glyph.Color);
                    GL.TexCoord2(u, v); GL.Vertex2(screen_x, screen_y);
                    GL.TexCoord2(du + u, v); GL.Vertex2(screen_x + w, screen_y);
                    GL.TexCoord2(du + u, dv + v); GL.Vertex2(screen_x + w, h + screen_y);
                    GL.TexCoord2(u, dv + v); GL.Vertex2(screen_x, h + screen_y);
                }
            }
            GL.End();
        }
示例#7
0
 public void Select()
 {
     DisplayTile.SelectTile(state);
 }
示例#8
0
 void Start()
 {
     instance = this;
     image    = GetComponent <Image>();
 }
示例#9
0
    private void createTile(Vector3 position)
    {
        GameObject  tile       = Instantiate(DisplayTileObj, position, Quaternion.Euler(0.0F, 0.0F, 0.0F)) as GameObject;
        DisplayTile tileScript = tile.GetComponent <DisplayTile>();

        int rand = Random.Range(0, 5);

        if (rand == 0)
        {
            tile.GetComponent <SpriteRenderer>().sprite = TileSprite1;
        }
        else if (rand == 1)
        {
            tile.GetComponent <SpriteRenderer>().sprite = TileSprite2;
        }
        else if (rand == 2)
        {
            tile.GetComponent <SpriteRenderer>().sprite = TileSprite3;
        }
        else if (rand == 3)
        {
            tile.GetComponent <SpriteRenderer>().sprite = TileSprite4;
        }
        else if (rand == 4)
        {
            tile.GetComponent <SpriteRenderer>().sprite = TileSprite5;
        }

        rand = Random.Range(0, 4);
        if (rand == 0)
        {
            tile.GetComponent <SpriteRenderer>().color = Color.red;
        }
        else if (rand == 1)
        {
            tile.GetComponent <SpriteRenderer>().color = Color.blue;
        }
        else if (rand == 2)
        {
            tile.GetComponent <SpriteRenderer>().color = Color.green;
        }
        else if (rand == 3)
        {
            tile.GetComponent <SpriteRenderer>().color = Color.yellow;
        }

        rand = Random.Range(0, 3);
        if (rand == 0)
        {
            tile.transform.localScale = new Vector3(0.5F, 0.5F, 0.5F);
            tileScript.Speed          = 1.0F;
        }
        else if (rand == 1)
        {
            tile.transform.localScale = new Vector3(0.3F, 0.3F, 0.3F);
            tileScript.Speed          = 0.5F;
        }
        else if (rand == 2)
        {
            tile.transform.localScale = new Vector3(0.1F, 0.1F, 0.1F);
            tileScript.Speed          = 0.25F;
        }
    }