Beispiel #1
0
        private void Callback_TileGridReset(GameLogic.TileGrid tiles,
                                            Vector2i oldSize, Vector2i newSize)
        {
            //Reposition the quad so it perfectly covers the map in world space.
            Transform quadTr = tileQuad.transform;

            quadTr.localScale = new Vector3(Map.Tiles.Width, Map.Tiles.Height, 1.0f);
            quadTr.position   = new Vector3(Map.Tiles.Width * 0.5f,
                                            Map.Tiles.Height * 0.5f,
                                            quadTr.position.z);

            //Update the tile data texture.

            tileGridTex.Resize(Tiles.Width, Tiles.Height);

            Color[] cols = new Color[tileGridTex.width * tileGridTex.height];
            foreach (Vector2i tilePos in new Vector2i.Iterator(new Vector2i(tileGridTex.width,
                                                                            tileGridTex.height)))
            {
                int index    = tilePos.x + (tilePos.y * tileGridTex.width);
                var tileType = Tiles[tilePos];
                cols[index] = tileTypeToMaterialParam[tileType];
            }

            tileGridTex.SetPixels(cols);
            tileGridTex.Apply();

            tileQuad.GetComponentInChildren <SpriteRenderer>().material.SetTexture(paramName_TileGridTex, tileGridTex);
        }
Beispiel #2
0
 private void Callback_TileChanged(GameLogic.TileGrid tiles, Vector2i pos,
                                   GameLogic.TileTypes oldVal, GameLogic.TileTypes newVal)
 {
     //Update the tile data texture.
     tileGridTex.SetPixel(pos.x, pos.y, tileTypeToMaterialParam[newVal]);
     tileGridTex.Apply();
 }
Beispiel #3
0
        private void Callback_TileTypeChanged(GameLogic.TileGrid tiles,
                                              Vector2i tilePos,
                                              GameLogic.TileTypes oldType,
                                              GameLogic.TileTypes newType)
        {
            foreach (var kvp in UIObjectsByTileType)
            {
                kvp.Value.SetActive(kvp.Key == newType);
            }

            switch (newType)
            {
            case GameLogic.TileTypes.Empty:
                Label_Title.Key = "WINDOW_TILE_EMPTY";
                break;

            case GameLogic.TileTypes.Wall:
                Label_Title.Key = "WINDOW_TILE_WALL";
                break;

            case GameLogic.TileTypes.Deposit:
                Label_Title.Key = "WINDOW_TILE_DEPOSIT";
                break;

            case GameLogic.TileTypes.Bedrock:
                Label_Title.Key = "WINDOW_TILE_BEDROCK";
                break;
            }
        }