bool HasQtrTileType(QtrTileElementType theQtr) { foreach (var qtrTile in qtrTiles) { if (qtrTile == theQtr) { return(true); } } return(false); }
// 融合时只考虑一级属性的情况 二级及以上都当作一级处理 static QtrTileElementType GetMixQtrTileElementType(QtrTileElementType qtet) { if (qtet == QtrTileElementType.Fire2 || qtet == QtrTileElementType.Fire3) { return(QtrTileElementType.Fire); } else if (qtet == QtrTileElementType.Wood2 || qtet == QtrTileElementType.Wood3) { return(QtrTileElementType.Wood); } return(qtet); }
public TilePaintSample(QtrTileElementType lb, QtrTileElementType lt, QtrTileElementType rt, QtrTileElementType rb, int type, int toType, byte bits) { qtrTiles = new QtrTileElementType[4]; qtrTiles[0] = lb; qtrTiles[1] = lt; qtrTiles[2] = rt; qtrTiles[3] = rb; this.type = type; this.toType = toType; this.bits = bits; }
//lb=leftBottom lt=leftTop rt=rightTop rb=rightBottom public void SetQtrTiles(QtrTileElementType lb, QtrTileElementType lt, QtrTileElementType rt, QtrTileElementType rb) { if (qtrTiles == null || qtrTiles.Length != 4) { Debug.LogError("qtrTiles == null || qtrTiles.Length != 4"); return; } qtrTiles[0] = lb; qtrTiles[1] = lt; qtrTiles[2] = rt; qtrTiles[3] = rb; }
//fire fire2 fire2 认为是相同的 wood wood2 wood3 认为是相同的 bool IsQtrElementEqual(QtrTileElementType qte0, QtrTileElementType qte1) { if (qte0 == qte1) { return(true); } else if ((qte0 == QtrTileElementType.Fire || qte0 == QtrTileElementType.Fire2 || qte0 == QtrTileElementType.Fire3) && (qte1 == QtrTileElementType.Fire || qte1 == QtrTileElementType.Fire2 || qte1 == QtrTileElementType.Fire3)) { return(true); } else if ((qte0 == QtrTileElementType.Wood || qte0 == QtrTileElementType.Wood2 || qte0 == QtrTileElementType.Wood3) && (qte1 == QtrTileElementType.Wood || qte1 == QtrTileElementType.Wood2 || qte1 == QtrTileElementType.Wood3)) { return(true); } return(false); }
// 根据qtrtile推算bits byte GetBits(QtrTileElementType theQtr) { byte bits = 0; if (qtrTiles[0] == theQtr) { bits += 8; } if (qtrTiles[1] == theQtr) { bits += 4; } if (qtrTiles[2] == theQtr) { bits += 2; } if (qtrTiles[3] == theQtr) { bits += 1; } return(bits); }
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); } }
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; } }
////如果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; } } }
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); } }
//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); }
//将没有完美融合的qtrtile设置成none public bool ProcessMixPerfect(PATileTerrain tileTerrain) { PATile[] nTiles = tileTerrain.GetNeighboringTilesNxN(this, 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]; bool isPerfect = true; QtrTileElementType qte0 = GetQtrTileElementType(bottomTile, 1); QtrTileElementType qte1 = GetQtrTileElementType(leftBottomTile, 2); QtrTileElementType qte2 = GetQtrTileElementType(leftTile, 3); QtrTileElementType qte = qtrTiles[0]; if (qte == qte0 && qte == qte1 && qte == qte2) { } else { isPerfect = false; qtrTiles[0] = QtrTileElementType.None; } qte0 = GetQtrTileElementType(leftTile, 2); qte1 = GetQtrTileElementType(leftTopTile, 3); qte2 = GetQtrTileElementType(topTile, 0); qte = qtrTiles[1]; if (qte == qte0 && qte == qte1 && qte == qte2) { } else { isPerfect = false; qtrTiles[1] = QtrTileElementType.None; } qte0 = GetQtrTileElementType(topTile, 3); qte1 = GetQtrTileElementType(rightTopTile, 0); qte2 = GetQtrTileElementType(rightTile, 1); qte = qtrTiles[2]; if (qte == qte0 && qte == qte1 && qte == qte2) { } else { isPerfect = false; qtrTiles[2] = QtrTileElementType.None; } qte0 = GetQtrTileElementType(rightTile, 0); qte1 = GetQtrTileElementType(rightBottomTile, 1); qte2 = GetQtrTileElementType(bottomTile, 2); qte = qtrTiles[3]; if (qte == qte0 && qte == qte1 && qte == qte2) { } else { isPerfect = false; qtrTiles[3] = QtrTileElementType.None; } return(isPerfect); }
public void SetQtrTiles(QtrTileElementType theSameType) { SetQtrTiles(theSameType, theSameType, theSameType, theSameType); }