// 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); }
//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); }