Esempio n. 1
0
    // index=0=lb index=2=lt index=4=rt index=6=rb
    bool IsCornerMix(PATile[] nTiles, int index)
    {
        int  i      = 0;
        bool result = true;

        foreach (var nTile in nTiles)
        {
            if (i++ == index)
            {
                result &= PATile.IsSingleElement(nTile);
            }
            else
            {
                result &= PATile.IsMultiElement(nTile);
            }

            if (!result)
            {
                return(false);
            }
        }
        return(true);
    }
Esempio n. 2
0
    void PaintASingleElementTile(PATile tile, List <PATile> postProcessSingleElementTiles = null)
    {
        //if (tile.element.IsMultiElement())
        //    return;

        PATile[] nTiles = GetNeighboringTilesNxN(tile, 1);
        int      leftBottomValue = 99, leftValue = 99, leftTopValue = 99, topValue = 99,
                 rightTopValue = 99, rightValue = 99, rightBottomValue = 99, bottomValue = 99;

        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];

        bool needPostProcess = false;

        foreach (var nTile in nTiles)
        {
            if (PATile.IsMultiElement(nTile))
            {
                needPostProcess = true;
            }
        }
        if (needPostProcess)
        {
            postProcessSingleElementTiles.Add(tile);
        }

        int t            = 0;
        int elementValue = 0;
        QtrTileElementType qtrTileElementType    = QtrTileElementType.Base;
        QtrTileElementType mixQtrTileElementType = QtrTileElementType.Base;

        TileElementType elementType = tile.element.GetTileElementType();

        t = elementValue = tile.element.GetElementPaintBrushType(elementType);
        if (leftBottomTile != null)
        {
            leftBottomValue = leftBottomTile.GetSingleElementPaintBrushType(elementType);
        }
        if (leftTile != null)
        {
            leftValue = leftTile.GetSingleElementPaintBrushType(elementType);
        }
        if (leftTopTile != null)
        {
            leftTopValue = leftTopTile.GetSingleElementPaintBrushType(elementType);
        }
        if (topTile != null)
        {
            topValue = topTile.GetSingleElementPaintBrushType(elementType);
        }
        if (rightTopTile != null)
        {
            rightTopValue = rightTopTile.GetSingleElementPaintBrushType(elementType);
        }
        if (rightTile != null)
        {
            rightValue = rightTile.GetSingleElementPaintBrushType(elementType);
        }
        if (rightBottomTile != null)
        {
            rightBottomValue = rightBottomTile.GetSingleElementPaintBrushType(elementType);
        }
        if (bottomTile != null)
        {
            bottomValue = bottomTile.GetSingleElementPaintBrushType(elementType);
        }

        if (t == FireLevel1Brush)
        {
            qtrTileElementType    = QtrTileElementType.Fire;
            mixQtrTileElementType = QtrTileElementType.Base;
        }
        else if (t == FireLevel2Brush)
        {
            qtrTileElementType    = QtrTileElementType.Fire2;
            mixQtrTileElementType = QtrTileElementType.Fire;
        }
        else if (t == FireLevel3Brush)
        {
            qtrTileElementType    = QtrTileElementType.Fire3;
            mixQtrTileElementType = QtrTileElementType.Fire2;
        }
        else if (t == WoodLevel1Brush)
        {
            qtrTileElementType    = QtrTileElementType.Wood;
            mixQtrTileElementType = QtrTileElementType.Base;
        }
        else if (t == WoodLevel2Brush)
        {
            qtrTileElementType    = QtrTileElementType.Wood2;
            mixQtrTileElementType = QtrTileElementType.Wood;
        }
        else if (t == WoodLevel3Brush)
        {
            qtrTileElementType    = QtrTileElementType.Wood3;
            mixQtrTileElementType = QtrTileElementType.Wood2;
        }

        if (leftValue < elementValue && bottomValue < elementValue)
        {
            CalcTileBits(t, tile, 2);//左下角
            tile.tileSetType = TileSetType.Corner;
            tile.SetQtrTiles(mixQtrTileElementType, mixQtrTileElementType, qtrTileElementType, mixQtrTileElementType);
        }
        else if (leftValue < elementValue && topValue < elementValue)
        {
            CalcTileBits(t, tile, 1);//左上角
            tile.tileSetType = TileSetType.Corner;
            tile.SetQtrTiles(mixQtrTileElementType, mixQtrTileElementType, mixQtrTileElementType, qtrTileElementType);
        }
        else if (rightValue < elementValue && bottomValue < elementValue)
        {
            CalcTileBits(t, tile, 4);//右下角
            tile.tileSetType = TileSetType.Corner;
            tile.SetQtrTiles(mixQtrTileElementType, qtrTileElementType, mixQtrTileElementType, mixQtrTileElementType);
        }
        else if (topValue < elementValue && rightValue < elementValue)
        {
            CalcTileBits(t, tile, 8);//右上角
            tile.tileSetType = TileSetType.Corner;
            tile.SetQtrTiles(qtrTileElementType, mixQtrTileElementType, mixQtrTileElementType, mixQtrTileElementType);
        }

        else if (leftValue < elementValue)
        {
            CalcTileBits(t, tile, 3);
            tile.tileSetType = TileSetType.Edge;
            tile.SetQtrTiles(mixQtrTileElementType, mixQtrTileElementType, qtrTileElementType, qtrTileElementType);
        }
        else if (topValue < elementValue)
        {
            CalcTileBits(t, tile, 9);
            tile.tileSetType = TileSetType.Edge;
            tile.SetQtrTiles(qtrTileElementType, mixQtrTileElementType, mixQtrTileElementType, qtrTileElementType);
        }
        else if (rightValue < elementValue)
        {
            CalcTileBits(t, tile, 12);
            tile.tileSetType = TileSetType.Edge;
            tile.SetQtrTiles(qtrTileElementType, qtrTileElementType, mixQtrTileElementType, mixQtrTileElementType);
        }
        else if (bottomValue < elementValue)
        {
            CalcTileBits(t, tile, 6);
            tile.tileSetType = TileSetType.Edge;
            tile.SetQtrTiles(mixQtrTileElementType, qtrTileElementType, qtrTileElementType, mixQtrTileElementType);
        }

        else if (leftBottomValue < elementValue)
        {
            CalcTileBits(t, tile, 7);
            tile.tileSetType = TileSetType.BigCorner;
            tile.SetQtrTiles(mixQtrTileElementType, qtrTileElementType, qtrTileElementType, qtrTileElementType);
        }
        else if (leftTopValue < elementValue)
        {
            CalcTileBits(t, tile, 11);
            tile.tileSetType = TileSetType.BigCorner;
            tile.SetQtrTiles(qtrTileElementType, mixQtrTileElementType, qtrTileElementType, qtrTileElementType);
        }
        else if (rightTopValue < elementValue)
        {
            CalcTileBits(t, tile, 13);
            tile.tileSetType = TileSetType.BigCorner;
            tile.SetQtrTiles(qtrTileElementType, qtrTileElementType, mixQtrTileElementType, qtrTileElementType);
        }
        else if (rightBottomValue < elementValue)
        {
            CalcTileBits(t, tile, 14);
            tile.tileSetType = TileSetType.BigCorner;
            tile.SetQtrTiles(qtrTileElementType, qtrTileElementType, qtrTileElementType, mixQtrTileElementType);
        }
        else
        {
            PaintNormalTile(tile, t);
            tile.tileSetType = TileSetType.Full;
            tile.SetQtrTiles(qtrTileElementType);
        }
    }
Esempio n. 3
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);
    }