Exemple #1
0
    void ProcessMultiElementTile(PATile tile)
    {
        if (tile.IsQtrTilesSet())
        {
            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];

        QtrTileElementType qte0 = GetMixQtrTileElementType(bottomTile, 1);
        QtrTileElementType qte1 = GetMixQtrTileElementType(leftBottomTile, 2);
        QtrTileElementType qte2 = GetMixQtrTileElementType(leftTile, 3);

        if (qte0 != QtrTileElementType.None && qte0 != QtrTileElementType.Base)
        {
            tile.qtrTiles[0] = qte0;
        }
        else if (qte1 != QtrTileElementType.None && qte1 != QtrTileElementType.Base)
        {
            tile.qtrTiles[0] = qte1;
        }
        else if (qte2 != QtrTileElementType.None && qte2 != QtrTileElementType.Base)
        {
            tile.qtrTiles[0] = qte2;
        }

        qte0 = GetMixQtrTileElementType(leftTile, 2);
        qte1 = GetMixQtrTileElementType(leftTopTile, 3);
        qte2 = GetMixQtrTileElementType(topTile, 0);
        if (qte0 != QtrTileElementType.None && qte0 != QtrTileElementType.Base)
        {
            tile.qtrTiles[1] = qte0;
        }
        else if (qte1 != QtrTileElementType.None && qte1 != QtrTileElementType.Base)
        {
            tile.qtrTiles[1] = qte1;
        }
        else if (qte2 != QtrTileElementType.None && qte2 != QtrTileElementType.Base)
        {
            tile.qtrTiles[1] = qte2;
        }

        qte0 = GetMixQtrTileElementType(topTile, 3);
        qte1 = GetMixQtrTileElementType(rightTopTile, 0);
        qte2 = GetMixQtrTileElementType(rightTile, 1);
        if (qte0 != QtrTileElementType.None && qte0 != QtrTileElementType.Base)
        {
            tile.qtrTiles[2] = qte0;
        }
        else if (qte1 != QtrTileElementType.None && qte1 != QtrTileElementType.Base)
        {
            tile.qtrTiles[2] = qte1;
        }
        else if (qte2 != QtrTileElementType.None && qte2 != QtrTileElementType.Base)
        {
            tile.qtrTiles[2] = qte2;
        }

        qte0 = GetMixQtrTileElementType(rightTile, 0);
        qte1 = GetMixQtrTileElementType(rightBottomTile, 1);
        qte2 = GetMixQtrTileElementType(bottomTile, 2);
        if (qte0 != QtrTileElementType.None && qte0 != QtrTileElementType.Base)
        {
            tile.qtrTiles[3] = qte0;
        }
        else if (qte1 != QtrTileElementType.None && qte1 != QtrTileElementType.Base)
        {
            tile.qtrTiles[3] = qte1;
        }
        else if (qte2 != QtrTileElementType.None && qte2 != QtrTileElementType.Base)
        {
            tile.qtrTiles[3] = qte2;
        }
    }
Exemple #2
0
    void ProcessSingleElememtTile(PATile tile)
    {
        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];

        QtrTileElementType qte0   = PATile.GetQtrTileElementType(bottomTile, 1);
        QtrTileElementType qte1   = PATile.GetQtrTileElementType(leftBottomTile, 2);
        QtrTileElementType qte2   = PATile.GetQtrTileElementType(leftTile, 3);
        QtrTileElementType preQte = tile.qtrTiles[0];

        if (qte0 != QtrTileElementType.None)
        {
            tile.qtrTiles[0] = qte0;
        }
        else if (qte1 != QtrTileElementType.None)
        {
            tile.qtrTiles[0] = qte1;
        }
        else if (qte2 != QtrTileElementType.None)
        {
            tile.qtrTiles[0] = qte2;
        }

        qte0   = PATile.GetQtrTileElementType(leftTile, 2);
        qte1   = PATile.GetQtrTileElementType(leftTopTile, 3);
        qte2   = PATile.GetQtrTileElementType(topTile, 0);
        preQte = tile.qtrTiles[1];
        if (qte0 != QtrTileElementType.None)
        {
            tile.qtrTiles[1] = qte0;
        }
        else if (qte1 != QtrTileElementType.None)
        {
            tile.qtrTiles[1] = qte1;
        }
        else if (qte2 != QtrTileElementType.None)
        {
            tile.qtrTiles[1] = qte2;
        }

        qte0   = PATile.GetQtrTileElementType(topTile, 3);
        qte1   = PATile.GetQtrTileElementType(rightTopTile, 0);
        qte2   = PATile.GetQtrTileElementType(rightTile, 1);
        preQte = tile.qtrTiles[2];
        if (qte0 != QtrTileElementType.None)
        {
            tile.qtrTiles[2] = qte0;
        }
        else if (qte1 != QtrTileElementType.None)
        {
            tile.qtrTiles[2] = qte1;
        }
        else if (qte2 != QtrTileElementType.None)
        {
            tile.qtrTiles[2] = qte2;
        }

        qte0   = PATile.GetQtrTileElementType(rightTile, 0);
        qte1   = PATile.GetQtrTileElementType(rightBottomTile, 1);
        qte2   = PATile.GetQtrTileElementType(bottomTile, 2);
        preQte = tile.qtrTiles[3];
        if (qte0 != QtrTileElementType.None)
        {
            tile.qtrTiles[3] = qte0;
        }
        else if (qte1 != QtrTileElementType.None)
        {
            tile.qtrTiles[3] = qte1;
        }
        else if (qte2 != QtrTileElementType.None)
        {
            tile.qtrTiles[3] = qte2;
        }

        if (!tile.IsQtrTilesSet())
        {
            Debug.LogWarning("ProcessSingleElememtTile !tile.IsQtrTilesSet() tile.x = " + tile.x + " tile.y " + tile.y);
        }
    }
Exemple #3
0
    ////如果tile只有一个qtrtile是未知的 那么未知的qtrtile直接设置成融合属性
    //void ProcessMiss1Tile(PATile tile)
    //{
    //    int miss1Index = IsTileMiss1(tile);
    //    if (miss1Index == -1)
    //        return;

    //    if(tile.element.IsMultiElement())
    //        tile.qtrTiles[miss1Index] = QtrTileElementType.Sand;
    //}

    void ProcessMiss1Tile(PATile tile)
    {
        if (tile.IsQtrTilesSet())
        {
            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 fireCount = 0;
        int woodCount = 0;

        for (int i = 0; i < tile.qtrTiles.Length; i++)
        {
            if (tile.qtrTiles[i] == QtrTileElementType.Fire)
            {
                fireCount++;
            }
            else if (tile.qtrTiles[i] == QtrTileElementType.Wood)
            {
                woodCount++;
            }
        }

        QtrTileElementType missedQtrTileElementType = QtrTileElementType.None;
        //if (tile.element.FireValueFloat > tile.element.WoodValueFloat)
        //{
        //    if (fireCount - woodCount > 1)
        //        missedQtrTileElementType = QtrTileElementType.Wood;
        //    else
        //        missedQtrTileElementType = QtrTileElementType.Fire;
        //}
        //else if (tile.element.WoodValueFloat > tile.element.FireValueFloat)
        //{
        //    if (woodCount - fireCount > 1)
        //        missedQtrTileElementType = QtrTileElementType.Fire;
        //    else
        //        missedQtrTileElementType = QtrTileElementType.Wood;
        //}
        //else
        //    Debug.LogError("error state");

        int randomValue = RandomManager.instance.Range(1, 3);

        missedQtrTileElementType = (QtrTileElementType)randomValue;

        int missIndex = GetTileQtrMissIndex(tile);

        tile.qtrTiles[missIndex] = missedQtrTileElementType;

        if (missIndex == 0)
        {
            if (leftTile != null && leftTile.qtrTiles[3] == QtrTileElementType.None)
            {
                leftTile.qtrTiles[3] = missedQtrTileElementType;
            }
            if (leftBottomTile != null && leftBottomTile.qtrTiles[2] == QtrTileElementType.None)
            {
                leftBottomTile.qtrTiles[2] = missedQtrTileElementType;
            }
            if (bottomTile != null && bottomTile.qtrTiles[1] == QtrTileElementType.None)
            {
                bottomTile.qtrTiles[1] = missedQtrTileElementType;
            }
        }
        else if (missIndex == 1)
        {
            if (leftTopTile != null && leftTopTile.qtrTiles[3] == QtrTileElementType.None)
            {
                leftTopTile.qtrTiles[3] = missedQtrTileElementType;
            }
            if (leftTile != null && leftTile.qtrTiles[2] == QtrTileElementType.None)
            {
                leftTile.qtrTiles[2] = missedQtrTileElementType;
            }
            if (topTile != null && topTile.qtrTiles[0] == QtrTileElementType.None)
            {
                topTile.qtrTiles[0] = missedQtrTileElementType;
            }
        }
        else if (missIndex == 2)
        {
            if (rightTopTile != null && rightTopTile.qtrTiles[0] == QtrTileElementType.None)
            {
                rightTopTile.qtrTiles[0] = missedQtrTileElementType;
            }
            if (rightTile != null && rightTile.qtrTiles[1] == QtrTileElementType.None)
            {
                rightTile.qtrTiles[1] = missedQtrTileElementType;
            }
            if (topTile != null && topTile.qtrTiles[3] == QtrTileElementType.None)
            {
                topTile.qtrTiles[3] = missedQtrTileElementType;
            }
        }
        else if (missIndex == 3)
        {
            if (rightBottomTile != null && rightBottomTile.qtrTiles[1] == QtrTileElementType.None)
            {
                rightBottomTile.qtrTiles[1] = missedQtrTileElementType;
            }
            if (rightTile != null && rightTile.qtrTiles[0] == QtrTileElementType.None)
            {
                rightTile.qtrTiles[0] = missedQtrTileElementType;
            }
            if (bottomTile != null && bottomTile.qtrTiles[2] == QtrTileElementType.None)
            {
                bottomTile.qtrTiles[2] = missedQtrTileElementType;
            }
        }
    }