Пример #1
0
    static int SetColor(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 3);
            UnityEngine.Tilemaps.Tilemap obj  = (UnityEngine.Tilemaps.Tilemap)ToLua.CheckObject(L, 1, typeof(UnityEngine.Tilemaps.Tilemap));
            UnityEngine.Vector3Int       arg0 = StackTraits <UnityEngine.Vector3Int> .Check(L, 2);

            UnityEngine.Color arg1 = ToLua.ToColor(L, 3);
            obj.SetColor(arg0, arg1);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Пример #2
0
        public void ToggleVisibility(Vector3Int position, Tilemap tilemap, bool clear, List <Vector3Int> visited)
        {
            bool nextRevealed = Mathf.Approximately(tilemap.GetColor(position).a, reveal.a);

            if ((nextRevealed && clear) || (!nextRevealed && !clear))
            {
                return;
            }

            visited.Add(position);

            Color c = clear? Color.clear : cover;

            tilemap.SetColor(position, c);



            Vector3Int newPosition = Vector3Int.one;

            for (int x = -1; x <= 1; x++)
            {
                for (int y = -1; y <= 1; y++)
                {
                    newPosition.Set(position.x + x, position.y + y, position.z);

                    if (position.x == x && position.y == y || !tilemap.GetTile <SecretTile>(newPosition) || visited.Contains(newPosition))
                    {
                        continue;
                    }

                    nextRevealed = Mathf.Approximately(tilemap.GetColor(newPosition).a, reveal.a);
                    //Debug.Log("next revealed " + nextRevealed + "[" + next.tint.a + " , " + reveal.a + "] " + "; clear " + clear);
                    if ((nextRevealed && clear) || (!nextRevealed && !clear))
                    {
                        continue;
                    }

                    ToggleVisibility(newPosition, tilemap, clear, ref visited);
                    tilemap.RefreshTile(newPosition);
                }
            }

            tilemap.RefreshTile(position);
        }
Пример #3
0
        private static void SetColor(UnityEngine.Tilemaps.Tilemap tilemap, Vector3Int position, Color color)
        {
            TileBase tile = tilemap.GetTile(position);

            if (tile != null)
            {
                if ((tilemap.GetTileFlags(position) & TileFlags.LockColor) != 0)
                {
                    if (tile is Tile)
                    {
                        Debug.LogWarning("Tint brush cancelled, because Tile (" + tile.name + ") has TileFlags.LockColor set. Unlock it from the Tile asset debug inspector.");
                    }
                    else
                    {
                        Debug.LogWarning("Tint brush cancelled. because Tile (" + tile.name + ") has TileFlags.LockColor set. Unset it in GetTileData().");
                    }
                }

                tilemap.SetColor(position, color);
            }
        }
Пример #4
0
        public override void GetTileData(Vec3I gridPos, TM.ITilemap itilemap, ref TM.TileData tileData)
        {
            Vec2I pos     = GridToTile(gridPos);
            Vec2I subTile = GridToSubTile(gridPos);

            Map.BBTile tile = GetTile(pos);

            TileSprite sprite = HasSprite(tile, pos, subTile) ? GetSprite(tile, pos, subTile) : null;

            tileData = new TM.TileData
            {
                sprite       = sprite.sprite,
                color        = sprite.color,
                transform    = sprite.xform,
                gameObject   = null,
                flags        = TM.TileFlags.None,
                colliderType = ColliderType.None
            };

            // Unity so broken (requires tileData.color to be set also *shrug*)
            tilemap.SetColor(gridPos, sprite.color);
        }