示例#1
0
    //public enum TileElementState
    //{
    //    None,
    //    TotalFire,// 完全火属性
    //    TotalWood,// 完全木属性
    //    //FireMax,//  火属性最大
    //    //WoodMax,// 木属性最大
    //    //FireWoodEqual,// 火木属性相等
    //    //Zero,// 无属性
    //}

    //TileElementState GetTileElementState(PATile tile)
    //{
    //    if (tile == null)
    //        return TileElementState.None;
    //    TileElementState state = TileElementState.None;
    //    //if (tile.element.FireValue == tile.element.WoodValue && tile.element.FireValue == 0)
    //    //    state = TileElementState.Zero;
    //    //else
    //    if (tile.element.FireValue > 0 && tile.element.WoodValue == 0)
    //        state = TileElementState.TotalFire;
    //    else if (tile.element.WoodValue > 0 && tile.element.FireValue == 0)
    //        state = TileElementState.TotalWood;
    //    //else if (tile.element.FireValue > tile.element.WoodValue)
    //    //    state = TileElementState.FireMax;
    //    //else if (tile.element.WoodValue > tile.element.FireValue)
    //    //    state = TileElementState.WoodMax;
    //    //else if (tile.element.WoodValue == tile.element.FireValue)
    //    //    state = TileElementState.FireWoodEqual;
    //    return state;
    //}

    //通过周围8格计算当前格子该使用哪种属性进行融合
    QtrTileElementType GetQtrTileElementType(PATile[] nTiles)
    {
        //int index = 0;
        foreach (var tile in nTiles)
        {
            if (tile == null)
            {
                continue;
            }
            if (tile.element.IsSingleElement())
            {
                //if (index++ % 2 == 0)
                //    continue;

                //TileElementState tileElementState = GetTileElementState(tile);
                TileElementType tileElementType = tile.element.GetTileElementType();
                if (tileElementType == TileElementType.Fire)
                {
                    return(QtrTileElementType.Fire);
                }
                else if (tileElementType == TileElementType.Wood)
                {
                    return(QtrTileElementType.Wood);
                }
            }
        }
        return(QtrTileElementType.Base);
    }
示例#2
0
 public virtual void FromJson(JSONNode jsnode)
 {
     id               = jsnode["id"].AsInt;
     elementType      = (TileElementType)(jsnode["elementType"].AsInt);
     prefabName       = jsnode["prefabName"];
     belongShuijingId = jsnode["belongShuijingId"].AsInt;
 }
示例#3
0
 public int GetElementValue(TileElementType elementType)
 {
     if (intElements[(int)elementType] == -1)
     {
         intElements[(int)elementType] = Mathf.CeilToInt(elements[(int)elementType]);
     }
     return(intElements[(int)elementType]);
     //return elementsDic[elementType].GetIntValue();
 }
示例#4
0
 public int GetSingleElementPaintBrushType(TileElementType elementType)
 {
     if (element.IsSingleElement())
     {
         return(element.GetElementPaintBrushType(elementType));
     }
     else if (element.IsMultiElement())
     {
         if (elementType == TileElementType.Fire)
         {
             return(FireLevel1Brush);
         }
         else if (elementType == TileElementType.Wood)
         {
             return(WoodLevel1Brush);
         }
     }
     return(-1);
 }
示例#5
0
        //public TileElementType GetMaxElementType()
        //{
        //    if(maxElementType == TileElementType.None)
        //    {
        //        foreach (var elementType in elementsDic.Keys)
        //        {
        //            if (!elementsDic.ContainsKey(maxElementType) ||
        //                elementsDic[elementType].GetIntValue() >= elementsDic[maxElementType].GetIntValue())
        //                maxElementType = elementType;
        //        }
        //    }
        //    return maxElementType;
        //}

        public int GetBrushFromConfig(TileElementType elementType)
        {
            if (elementType == TileElementType.Fire)
            {
                if (fireBrush == -1)
                {
                    TileBrushConfigAsset tileBrushConfigAsset = ConfigDataBase.instance.TileBrushConfigAsset;
                    for (int i = 0; i < tileBrushConfigAsset.configs.Count; i++)
                    {
                        if (tileBrushConfigAsset.configs[i].elementType == (int)elementType &&
                            tileBrushConfigAsset.configs[i].level == FireValue)
                        {
                            fireBrush = tileBrushConfigAsset.configs[i].brush;
                        }
                    }
                }
                return(fireBrush);
            }
            else if (elementType == TileElementType.Wood)
            {
                if (woodBrush == -1)
                {
                    TileBrushConfigAsset tileBrushConfigAsset = ConfigDataBase.instance.TileBrushConfigAsset;
                    for (int i = 0; i < tileBrushConfigAsset.configs.Count; i++)
                    {
                        if (tileBrushConfigAsset.configs[i].elementType == (int)elementType &&
                            tileBrushConfigAsset.configs[i].level == WoodValue)
                        {
                            woodBrush = tileBrushConfigAsset.configs[i].brush;
                        }
                    }
                }
                return(woodBrush);
            }
            return(-1);
        }
示例#6
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);
        }
    }
示例#7
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);
    }
示例#8
0
 public int GetElementPaintBrushType(TileElementType elementType)
 {
     return(GetBrushFromConfig(elementType));
 }
示例#9
0
 public void AddElement(TileElementType elementType, float addValue)
 {
     //elementsDic[elementType].AddValue(addValue);
     elements[(int)elementType] += addValue;
     InvalidCache();
 }
示例#10
0
        ////获取第二大的元素属性的类型
        //public TileElementType GetSecondTileElementType()
        //{

        //}

        public float GetElementValueFloat(TileElementType elementType)
        {
            return(elements[(int)elementType]);
        }
示例#11
0
 public PACrystalBuilding(int id, int level, TileElementType elementType, string prefabName, int randomSeed)
     : base(id, elementType, prefabName)
 {
     this.level      = level;
     this.randomSeed = randomSeed;
 }
示例#12
0
 public PABuilding(int id, TileElementType elementType, string prefabName)
 {
     this.id          = id;
     this.elementType = elementType;
     this.prefabName  = prefabName;
 }