Exemple #1
0
    void PaintNormalTile(PATile tile, int t, int specifiedIndex = -1, UVRotateType rotateType = UVRotateType.None)
    {
        if (tile == null)
        {
            return;
        }

        tile.SetTileProp(t, t, 0, specifiedIndex, rotateType);
        UpdateTileUV(tile);
    }
Exemple #2
0
    void PaintPostProcessMultiElementTile(PATile tile)
    {
        if (tile.QtrTileTypeCount() >= 3)
        {
            TileMixConfigAsset.TileMixConfig mixConfig = GetTileMixConfig(tile);
            if (mixConfig == null)
            {
                Debug.LogError("mixConfig == null tile.x = " + tile.x + " tile.y = " + tile.y);
                tile.SetTileProp(0, 0, 0);
                UpdateTileUV(tile);
                return;
            }

            tile.SetTileProp(FireLevel1Brush, FireLevel1Brush, 0, mixConfig.tilesetIndex, (UVRotateType)mixConfig.rotateType);
        }
        else
        {
            tile.SetTilePropByQtrTile();
        }
        UpdateTileUV(tile);
    }
    public void PaintTile5x5(PATile tile, int t)
    {
        if (tile == null)
        {
            return;
        }
        int i;

        t = Mathf.Clamp(t, 0, settings.tsTypes.Count);

        IntermediateInfo[] imInfo = new IntermediateInfo[24];
        PATile[]           tile2  = GetNeighboringTilesNxN(tile, 1);
        PATile[]           tile3  = GetNeighboringTilesNxN(tile, 3);
        PATile[]           nTiles = GetNeighboringTilesNxN(tile, 5);
        PATile[]           tls    = GetNeighboringTilesNxN(tile, 7);

        tile.SetTileProp(t, t, 0);
        UpdateTileUV(tile);

        for (i = 0; i < 8; ++i)
        {
            if (tile2[i] != null)
            {
                tile2[i].SetTileProp(t, t, 0);
                UpdateTileUV(tile2[i]);
            }
        }
        for (i = 0; i < 16; ++i)
        {
            if (tile3[i] != null)
            {
                tile3[i].SetTileProp(t, t, 0);
                UpdateTileUV(tile3[i]);
            }
        }

        //Array visualization, where 'c' = current tile
        // 0  1  2  3  4  5  6  7  8
        // 31 0  1  2  3  4  5  6  9
        // 30 23 x  x  x  x  x  7  10
        // 29 22 x  x  x  x  x  8  11
        // 28 21 x  x  c  x  x  9  12
        // 27 20 x  x  x  x  x  10 13
        // 26 19 x  x  x  x  x  11 14
        // 25 18 17 16 15 14 13 12 15
        // 24 23 22 21 20 19 18 17 16
        //0
        CalcTileBits(t, nTiles[0], 2, out imInfo[0]);
        //1
        CalcTileBits(t, nTiles[1], 3, out imInfo[1]);
        //2
        CalcTileBits(t, nTiles[2], 3, out imInfo[2]);
        //3
        CalcTileBits(t, nTiles[3], 3, out imInfo[3]);
        //4
        CalcTileBits(t, nTiles[4], 3, out imInfo[4]);
        //5
        CalcTileBits(t, nTiles[5], 3, out imInfo[5]);
        //6
        CalcTileBits(t, nTiles[6], 1, out imInfo[6]);

        //7
        CalcTileBits(t, nTiles[7], 9, out imInfo[7]);
        //8
        CalcTileBits(t, nTiles[8], 9, out imInfo[8]);
        //9
        CalcTileBits(t, nTiles[9], 9, out imInfo[9]);
        //10
        CalcTileBits(t, nTiles[10], 9, out imInfo[10]);
        //11
        CalcTileBits(t, nTiles[11], 9, out imInfo[11]);

        //12
        CalcTileBits(t, nTiles[12], 8, out imInfo[12]);
        //13
        CalcTileBits(t, nTiles[13], 12, out imInfo[13]);
        //14
        CalcTileBits(t, nTiles[14], 12, out imInfo[14]);
        //15
        CalcTileBits(t, nTiles[15], 12, out imInfo[15]);
        //16
        CalcTileBits(t, nTiles[16], 12, out imInfo[16]);
        //17
        CalcTileBits(t, nTiles[17], 12, out imInfo[17]);
        //18
        CalcTileBits(t, nTiles[18], 4, out imInfo[18]);

        //19
        CalcTileBits(t, nTiles[19], 6, out imInfo[19]);
        //20
        CalcTileBits(t, nTiles[20], 6, out imInfo[20]);
        //21
        CalcTileBits(t, nTiles[21], 6, out imInfo[21]);
        //22
        CalcTileBits(t, nTiles[22], 6, out imInfo[22]);
        //23
        CalcTileBits(t, nTiles[23], 6, out imInfo[23]);

        //0
        //CalcIntermediateTileBits(tls[0], 2, imInfo[0]);
        ////1
        //CalcIntermediateTileBits(tls[1], 3, imInfo[0]);
        ////2
        //CalcIntermediateTileBits(tls[2], 3, imInfo[1]);
        ////3
        //CalcIntermediateTileBits(tls[3], 3, imInfo[2]);
        ////4
        //CalcIntermediateTileBits(tls[4], 3, imInfo[3]);
        ////5
        //CalcIntermediateTileBits(tls[5], 3, imInfo[4]);
        ////6
        //CalcIntermediateTileBits(tls[6], 1, imInfo[4]);

        ////7
        //CalcIntermediateTileBits(tls[7], 9, imInfo[4]);
        ////8
        //CalcIntermediateTileBits(tls[8], 9, imInfo[5]);
        ////9
        //CalcIntermediateTileBits(tls[9], 9, imInfo[6]);
        ////10
        //CalcIntermediateTileBits(tls[10], 9, imInfo[7]);
        ////11
        //CalcIntermediateTileBits(tls[11], 9, imInfo[8]);

        ////12
        //CalcIntermediateTileBits(tls[12], 8, imInfo[8]);
        ////13
        //CalcIntermediateTileBits(tls[13], 12, imInfo[8]);
        ////14
        //CalcIntermediateTileBits(tls[14], 12, imInfo[9]);
        ////15
        //CalcIntermediateTileBits(tls[15], 12, imInfo[10]);
        ////16
        //CalcIntermediateTileBits(tls[16], 12, imInfo[11]);
        ////17
        //CalcIntermediateTileBits(tls[17], 12, imInfo[12]);
        ////18
        //CalcIntermediateTileBits(tls[18], 4, imInfo[12]);

        ////19
        //CalcIntermediateTileBits(tls[19], 6, imInfo[12]);
        ////20
        //CalcIntermediateTileBits(tls[20], 6, imInfo[13]);
        ////21
        //CalcIntermediateTileBits(tls[21], 6, imInfo[14]);
        ////22
        //CalcIntermediateTileBits(tls[22], 6, imInfo[15]);
        ////23
        //CalcIntermediateTileBits(tls[23], 6, imInfo[0]);
    }
    public void PaintTile1x1(PATile tile, int t)
    {
        if (tile == null)
        {
            return;
        }
        t = Mathf.Clamp(t, 0, settings.tsTypes.Count);

        //int i, transitionId;
        //PATSTransition transition = FindTransitionForType(t, out transitionId);
        //if (transition == null) return;

        IntermediateInfo[] imInfo = new IntermediateInfo[8];
        PATile[]           nTiles = GetNeighboringTilesNxN(tile, 1);
        PATile[]           tls    = GetNeighboringTilesNxN(tile, 3);

        //Current tile
        tile.SetTileProp(t, t, 0);
        UpdateTileUV(tile);

        //0
        CalcTileBits(t, nTiles[0], 2, out imInfo[0]);
        //1
        CalcTileBits(t, nTiles[1], 3, out imInfo[1]);
        //2
        CalcTileBits(t, nTiles[2], 1, out imInfo[2]);
        //3
        CalcTileBits(t, nTiles[3], 9, out imInfo[3]);
        //4
        CalcTileBits(t, nTiles[4], 8, out imInfo[4]);
        //5
        CalcTileBits(t, nTiles[5], 12, out imInfo[5]);
        //6
        CalcTileBits(t, nTiles[6], 4, out imInfo[6]);
        //7
        CalcTileBits(t, nTiles[7], 6, out imInfo[7]);

        //Array visualization, where 'c' = current tile
        // 0  1  2  3  4
        //15  0  1  2  5
        //14  7  c  3  6
        //13  6  5  4  7
        //12 11 10  9  8

        //0
        CalcIntermediateTileBits(tls[0], 2, imInfo[0]);
        //1
        CalcIntermediateTileBits(tls[1], 3, imInfo[0]);
        //2
        CalcIntermediateTileBits(tls[2], 3, imInfo[1]);
        //3
        CalcIntermediateTileBits(tls[3], 3, imInfo[2]);
        //4
        CalcIntermediateTileBits(tls[4], 1, imInfo[2]);

        //5
        CalcIntermediateTileBits(tls[5], 9, imInfo[2]);
        //6
        CalcIntermediateTileBits(tls[6], 9, imInfo[3]);
        //7
        CalcIntermediateTileBits(tls[7], 9, imInfo[4]);

        //8
        CalcIntermediateTileBits(tls[8], 8, imInfo[4]);
        //9
        CalcIntermediateTileBits(tls[9], 12, imInfo[4]);
        //10
        CalcIntermediateTileBits(tls[10], 12, imInfo[5]);
        //11
        CalcIntermediateTileBits(tls[11], 12, imInfo[6]);
        //12
        CalcIntermediateTileBits(tls[12], 4, imInfo[6]);

        //13
        CalcIntermediateTileBits(tls[13], 6, imInfo[6]);
        //14
        CalcIntermediateTileBits(tls[14], 6, imInfo[7]);
        //15
        CalcIntermediateTileBits(tls[15], 6, imInfo[0]);
    }
Exemple #5
0
    //bool IsFullMix(PATile[] nTiles)
    //{
    //    bool result = true;
    //    foreach(var nTile in nTiles)
    //    {
    //        result &= PATile.IsMultiElement(nTile);
    //        if (!result)
    //            return false;
    //    }
    //    return true;
    //}

    void PaintAMultiElementTile(PATile tile, List <PATile> postProcessMultiElementTiles = null)
    {
        //if (tile.element.IsSingleElement())
        //    return;

        PATile[] nTiles = GetNeighboringTilesNxN(tile, 1);

        PATile leftBottomTile  = nTiles[0];
        PATile leftTile        = nTiles[1];
        PATile leftTopTile     = nTiles[2];
        PATile topTile         = nTiles[3];
        PATile rightTopTile    = nTiles[4];
        PATile rightTile       = nTiles[5];
        PATile rightBottomTile = nTiles[6];
        PATile bottomTile      = nTiles[7];

        int fromType = 0;
        int toType   = 0;
        //QtrTileElementType qtrTileElementType = QtrTileElementType.None;
        QtrTileElementType qtrTileElementType   = GetQtrTileElementType(nTiles);
        QtrTileElementType toQtrTileElementType = QtrTileElementType.None;

        if (qtrTileElementType == QtrTileElementType.Fire)
        {
            fromType             = FireLevel1Brush;
            toType               = WoodLevel1Brush;
            toQtrTileElementType = QtrTileElementType.Wood;
        }
        else if (qtrTileElementType == QtrTileElementType.Wood)
        {
            fromType             = WoodLevel1Brush;
            toType               = FireLevel1Brush;
            toQtrTileElementType = QtrTileElementType.Fire;
        }

        //TileElementState leftTopElementState = GetTileElementState(leftTopTile);
        //TileElementState leftBottomElementState = GetTileElementState(leftBottomTile);
        //TileElementState rightTopElementState = GetTileElementState(rightTopTile);
        //TileElementState rightBottomElementState = GetTileElementState(rightBottomTile);

        TileElementType leftTopElementType     = PATileElement.GetTileElementType(leftTopTile);
        TileElementType leftBottomElementType  = PATileElement.GetTileElementType(leftBottomTile);
        TileElementType rightTopElementType    = PATileElement.GetTileElementType(rightTopTile);
        TileElementType rightBottomElementType = PATileElement.GetTileElementType(rightBottomTile);


        if (PATile.IsSingleElement(leftTopTile) &&
            PATile.IsSingleElement(leftTile) &&
            PATile.IsSingleElement(topTile) &&
            PATile.IsMultiElement(rightBottomTile) &&
            PATile.IsTileSetType(leftTopTile, TileSetType.Full) &&
            PATile.IsTileSetType(leftTile, TileSetType.Full) &&
            PATile.IsTileSetType(topTile, TileSetType.Full))
        {
            if (leftTopElementType == TileElementType.Fire)
            {
                qtrTileElementType   = QtrTileElementType.Fire;
                toQtrTileElementType = QtrTileElementType.Wood;
                fromType             = FireLevel1Brush;
                toType = WoodLevel1Brush;
            }
            else if (leftTopElementType == TileElementType.Wood)
            {
                qtrTileElementType   = QtrTileElementType.Wood;
                toQtrTileElementType = QtrTileElementType.Fire;
                fromType             = WoodLevel1Brush;
                toType = FireLevel1Brush;
            }

            tile.SetTileProp(fromType, toType, 14);
            tile.SetQtrTiles(qtrTileElementType, qtrTileElementType, qtrTileElementType, toQtrTileElementType);
            tile.tileSetType = TileSetType.BigCorner;
        }
        else if (PATile.IsSingleElement(rightTopTile) &&
                 PATile.IsSingleElement(rightTile) &&
                 PATile.IsSingleElement(topTile) &&
                 PATile.IsMultiElement(leftBottomTile) &&
                 PATile.IsTileSetType(rightTopTile, TileSetType.Full) &&
                 PATile.IsTileSetType(rightTile, TileSetType.Full) &&
                 PATile.IsTileSetType(topTile, TileSetType.Full))
        {
            if (rightTopElementType == TileElementType.Fire)
            {
                qtrTileElementType   = QtrTileElementType.Fire;
                toQtrTileElementType = QtrTileElementType.Wood;
                fromType             = FireLevel1Brush;
                toType = WoodLevel1Brush;
            }
            else if (rightTopElementType == TileElementType.Wood)
            {
                qtrTileElementType   = QtrTileElementType.Wood;
                toQtrTileElementType = QtrTileElementType.Fire;
                fromType             = WoodLevel1Brush;
                toType = FireLevel1Brush;
            }

            tile.SetTileProp(fromType, toType, 7);
            tile.SetQtrTiles(toQtrTileElementType, qtrTileElementType, qtrTileElementType, qtrTileElementType);
            tile.tileSetType = TileSetType.BigCorner;
        }
        else if (PATile.IsSingleElement(leftBottomTile) &&
                 PATile.IsSingleElement(leftTile) &&
                 PATile.IsSingleElement(bottomTile) &&
                 PATile.IsMultiElement(rightTopTile) &&
                 PATile.IsTileSetType(leftBottomTile, TileSetType.Full) &&
                 PATile.IsTileSetType(leftTile, TileSetType.Full) &&
                 PATile.IsTileSetType(bottomTile, TileSetType.Full))
        {
            if (leftBottomElementType == TileElementType.Fire)
            {
                qtrTileElementType   = QtrTileElementType.Fire;
                toQtrTileElementType = QtrTileElementType.Wood;
                fromType             = FireLevel1Brush;
                toType = WoodLevel1Brush;
            }
            else if (leftBottomElementType == TileElementType.Wood)
            {
                qtrTileElementType   = QtrTileElementType.Wood;
                toQtrTileElementType = QtrTileElementType.Fire;
                fromType             = WoodLevel1Brush;
                toType = FireLevel1Brush;
            }

            tile.SetTileProp(fromType, toType, 13);
            tile.SetQtrTiles(qtrTileElementType, qtrTileElementType, toQtrTileElementType, qtrTileElementType);
            tile.tileSetType = TileSetType.BigCorner;
        }
        else if (PATile.IsSingleElement(rightBottomTile) &&
                 PATile.IsSingleElement(rightTile) &&
                 PATile.IsSingleElement(bottomTile) &&
                 PATile.IsMultiElement(leftTopTile) &&
                 PATile.IsTileSetType(rightBottomTile, TileSetType.Full) &&
                 PATile.IsTileSetType(rightTile, TileSetType.Full) &&
                 PATile.IsTileSetType(bottomTile, TileSetType.Full))
        {
            if (rightBottomElementType == TileElementType.Fire)
            {
                qtrTileElementType   = QtrTileElementType.Fire;
                toQtrTileElementType = QtrTileElementType.Wood;
                fromType             = FireLevel1Brush;
                toType = WoodLevel1Brush;
            }
            else if (rightBottomElementType == TileElementType.Wood)
            {
                qtrTileElementType   = QtrTileElementType.Wood;
                toQtrTileElementType = QtrTileElementType.Fire;
                fromType             = WoodLevel1Brush;
                toType = FireLevel1Brush;
            }

            tile.SetTileProp(fromType, toType, 11);
            tile.SetQtrTiles(qtrTileElementType, toQtrTileElementType, qtrTileElementType, qtrTileElementType);
            tile.tileSetType = TileSetType.BigCorner;
        }

        //else if (IsFullMix(nTiles))
        //{
        //    tile.SetTileProp(SandBrush, SandBrush, 0);
        //    tile.SetQtrTiles(QtrTileElementType.Sand);
        //    tile.tileSetType = TileSetType.Full;
        //}

        else if (IsCornerMix(nTiles, 0))
        {
            tile.SetTileProp(fromType, toType, 8);
            tile.SetQtrTiles(qtrTileElementType, toQtrTileElementType, toQtrTileElementType, toQtrTileElementType);
            tile.tileSetType = TileSetType.Corner;
        }
        else if (IsCornerMix(nTiles, 2))
        {
            tile.SetTileProp(fromType, toType, 4);
            tile.SetQtrTiles(toQtrTileElementType, qtrTileElementType, toQtrTileElementType, toQtrTileElementType);
            tile.tileSetType = TileSetType.Corner;
        }
        else if (IsCornerMix(nTiles, 4))
        {
            tile.SetTileProp(fromType, toType, 2);
            tile.SetQtrTiles(toQtrTileElementType, toQtrTileElementType, qtrTileElementType, toQtrTileElementType);
            tile.tileSetType = TileSetType.Corner;
        }
        else if (IsCornerMix(nTiles, 6))
        {
            tile.SetTileProp(fromType, toType, 1);
            tile.SetQtrTiles(toQtrTileElementType, toQtrTileElementType, toQtrTileElementType, qtrTileElementType);
            tile.tileSetType = TileSetType.Corner;
        }

        else
        {
            postProcessMultiElementTiles.Add(tile);
            tile.SetQtrTiles(QtrTileElementType.None);
            return;
        }

        UpdateTileUV(tile);
    }