示例#1
0
    public FrameStructure GetShema(short[,] map, TileInfoStructure info)
    {
        FrameStructure rez = new FrameStructure();

        currentTileInfo = info;


        // GetTop();
        if (mapTop == null)
        {
            mapTop = new short[, ] {
                { -2, -1, -2 },
                { -2, -2, -2 },
                { -2, -2, -2 }
            }
        }
        ;
        if (ChackMap(mapTop, map, info))
        {
            return(GetTop());
        }

        // GetBottom();
        if (mapBottom == null)
        {
            mapBottom = new short[, ] {
                { -2, -2, -2 },
                { -2, -2, -2 },
                { -2, -1, -2 }
            }
        }
        ;
        if (ChackMap(mapBottom, map, info))
        {
            return(GetBottom());
        }

        return(rez);
    }
}
示例#2
0
    public FrameStructure GetFrameStructurenew(float x, float y, TileInfoStructure tileStructure, LayerData layerData)
    {
        if (frameBuffer[layerData.Id] == null)
        {
            //   if (!MapFrameStructure.ContainsKey(layerData)) {
            frameBuffer[layerData.Id] = new FrameStructure[mapGenerator.SizeX - 1, mapGenerator.SizeY - 1];


            for (int xx = 0; xx < mapSizeX; xx++)
            {
                for (int yy = 0; yy < mapSizeY; yy++)
                {
                    frameBuffer[layerData.Id][xx, yy] = GetFrameStructure(xx * tileSize - 1, yy * tileSize - 1, Map[xx, yy], layerData);
                }
            }
        }

        int offsetX = Mathf.CeilToInt(x / tileSize);
        int offsetY = Mathf.CeilToInt(y / tileSize);

        return(frameBuffer[layerData.Id][offsetX, offsetY]);
    }
示例#3
0
    //private short[,] map41;
    //map12
    public FrameStructure GetShema(short[,] map, TileInfoStructure info)
    {
        // PrintMap(map);
        currentTileInfo = info;

        // 0 пусто
        // 1 тогоже типа
        // -1 не тогоже типа
        // -2 не рассматриваем
        // 2 не пусто

        //Get00()
        if (map00 == null)
        {
            map00 = new short[, ] {
                { -2, -2, -2, -2, -2 },
                { -2, -1, -1, -1, -1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 }
            };
        }
        if (ChackMap(map00, map, info))
        {
            return(Get00());
        }

        //Get10()
        if (map10 == null)
        {
            map10 = new short[, ] {
                { -2, -2, -2, -2, -2 },
                { -1, -1, -1, -1, -1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 }
            };
        }
        if (ChackMap(map10, map, info))
        {
            return(Get10());
        }

        //Get20()
        if (map20 == null)
        {
            map20 = new short[, ] {
                { -1, -1, -1, -1, -1 },
                { -1, -1, -1, -1, -1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 }
            };
        }
        if (ChackMap(map20, map, info))
        {
            return(Get20());
        }

        //Get30()
        if (map30 == null)
        {
            map30 = new short[, ] {
                { -2, -2, -2, -2, -2 },
                { -1, -1, -1, -1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 }
            };
        }
        if (ChackMap(map30, map, info))
        {
            return(Get30());
        }

        //Get40()
        if (map40 == null)
        {
            map40 = new short[, ] {
                { -2, -2, -2, -2, -2 },
                { -1, -1, -1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 }
            };
        }
        if (ChackMap(map40, map, info))
        {
            return(Get40());
        }


        //Get01()
        if (map01 == null)
        {
            map01 = new short[, ] {
                { -2, -1, -1, -1, -1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 }
            };
        }
        if (ChackMap(map01, map, info))
        {
            return(Get01());
        }

        //Get11()
        if (map11 == null)
        {
            map11 = new short[, ] {
                { -1, -1, -1, -1, -1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 }
            };
        }
        if (ChackMap(map11, map, info))
        {
            return(Get11());
        }

        //Get21()
        if (map21 == null)
        {
            map21 = new short[, ] {
                { -1, -1, -1, -1, -1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 }
            };
        }
        if (ChackMap(map21, map, info))
        {
            return(Get21());
        }

        //Get31()
        if (map31 == null)
        {
            map31 = new short[, ] {
                { -1, -1, -1, -1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 }
            };
        }
        if (ChackMap(map31, map, info))
        {
            return(Get31());
        }

        //Get41()
        if (map41 == null)
        {
            map41 = new short[, ] {
                { -1, -1, -1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 }
            };
        }
        if (ChackMap(map41, map, info))
        {
            return(Get41());
        }

        //Get02()
        if (map02 == null)
        {
            map02 = new short[, ] {
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 }
            };
        }
        if (ChackMap(map02, map, info))
        {
            return(Get02());
        }

        //Get12()
        if (map12 == null)
        {
            map12 = new short[, ] {
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 }
            };
        }
        if (ChackMap(map12, map, info))
        {
            return(Get12());
        }

        //Get22()
        if (map22 == null)
        {
            map22 = new short[, ] {
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 }
            };
        }
        if (ChackMap(map22, map, info))
        {
            return(Get22());
        }

        //Get32()
        if (map32 == null)
        {
            map32 = new short[, ] {
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 }
            };
        }
        if (ChackMap(map32, map, info))
        {
            return(Get32());
        }

        //Get42()
        if (map42 == null)
        {
            map42 = new short[, ] {
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 }
            };
        }
        if (ChackMap(map42, map, info))
        {
            return(Get42());
        }

        //Get03()
        if (map03 == null)
        {
            map03 = new short[, ] {
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, -1, -1, -1 }
            };
        }
        if (ChackMap(map03, map, info))
        {
            return(Get03());
        }

        //Get13()
        if (map13 == null)
        {
            map13 = new short[, ] {
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, -1, -1, -1, -1 }
            };
        }
        if (ChackMap(map13, map, info))
        {
            return(Get13());
        }

        //Get23()
        if (map23 == null)
        {
            map23 = new short[, ] {
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { -1, -1, -1, -1, -1 }
            };
        }
        if (ChackMap(map23, map, info))
        {
            return(Get23());
        }

        //Get33()
        if (map33 == null)
        {
            map33 = new short[, ] {
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { -1, -1, -1, -1, -1 }
            };
        }
        if (ChackMap(map33, map, info))
        {
            return(Get33());
        }

        //Get43()
        if (map43 == null)
        {
            map43 = new short[, ] {
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { -1, -1, -1, -1, -2 }
            };
        }
        if (ChackMap(map43, map, info))
        {
            return(Get43());
        }

        //Get04()
        if (map04 == null)
        {
            map04 = new short[, ] {
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, 1, 1, 1 },
                { -2, -1, -1, -1, -1 },
                { -2, -2, -2, -2, -2 }
            };
        }
        if (ChackMap(map04, map, info))
        {
            return(Get04());
        }

        //Get14()
        if (map14 == null)
        {
            map14 = new short[, ] {
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, 1, 1, 1, 1 },
                { -1, -1, -1, -1, -1 },
                { -2, -2, -2, -2, -2 }
            };
        }
        if (ChackMap(map14, map, info))
        {
            return(Get14());
        }

        //Get24()
        if (map24 == null)
        {
            map24 = new short[, ] {
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1 },
                { -1, -1, -1, -1, -1 },
                { -2, -2, -2, -2, -2 }
            };
        }
        if (ChackMap(map24, map, info))
        {
            return(Get24());
        }

        //Get34()
        if (map34 == null)
        {
            map34 = new short[, ] {
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { 1, 1, 1, 1, -1 },
                { -1, -1, -1, -1, -1 },
                { -2, -2, -2, -2, -2 }
            };
        }
        if (ChackMap(map34, map, info))
        {
            return(Get34());
        }

        //Get44()
        if (map44 == null)
        {
            map44 = new short[, ] {
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { 1, 1, 1, -1, -2 },
                { -1, -1, -1, -1, -2 },
                { -2, -2, -2, -2, -2 }
            };
        }
        if (ChackMap(map44, map, info))
        {
            return(Get44());
        }

        return(Get22());
    }
示例#4
0
    public FrameStructure GetShema(short[,] map, TileInfoStructure info)
    {
        //  return new FrameStructure(1, 0, "Liquid_000");
        // topRez.FrameX = currentTileInfo.randomTile;
        // topRez.DeltaHeight = 0;//CountToDeltaHeight(currentTileInfo.count);
        // return topRez;


        currentTileInfo = info;

        var rez = new FrameStructure(0, 0);

        rez.TileCollection = "Liquid_000";
        //return GetTop();
        // 0 пусто
        // 1 тогоже типа
        // -1 не тогоже типа
        // -2 не рассматриваем
        // 2 не пусто

        // GetCenter();
        if (mapCenter == null)
        {
            mapCenter = new short[, ] {
                { -2, 1, -2 },
                { 1, -2, 1 },
                { -2, 1, -2 }
            };
        }

        if (ChackMap(mapCenter, map, info))
        {
            return(GetCenter());
        }



        //GetLeftCorner();
        if (mapLeftCorner == null)
        {
            mapLeftCorner = new short[, ] {
                { -2, -1, -2 },
                { -1, -2, 1 },
                { -2, 1, -2 }
            };
        }
        if (ChackMap(mapLeftCorner, map, info))
        {
            return(GetLeftTopCorner());
        }

        //GetRightCorner();
        if (mapRightCorner == null)
        {
            mapRightCorner = new short[, ] {
                { -2, -1, -2 },
                { 1, -2, -1 },
                { -2, 1, -2 }
            };
        }
        if (ChackMap(mapRightCorner, map, info))
        {
            return(GetRightTopCorner());
        }

        //GetOneHorizontalCenter();
        if (mapOneHorizontalCenter == null)
        {
            mapOneHorizontalCenter = new short[, ] {
                { -2, -1, -2 },
                { 1, -2, 1 },
                { -2, -1, -2 }
            };
        }
        if (ChackMap(mapOneHorizontalCenter, map, info))
        {
            return(GetTop());
        }

        //GetOneVerticalCenter();
        if (mapOneVerticalCenter == null)
        {
            mapOneVerticalCenter = new short[, ] {
                { -2, 1, -2 },
                { -1, -2, -1 },
                { -2, 1, -2 }
            };
        }
        if (ChackMap(mapOneVerticalCenter, map, info))
        {
            return(GetOneVerticalCenter());
        }

        //GetOneRight();
        if (mapOneRight == null)
        {
            mapOneRight = new short[, ] {
                { -2, -1, -2 },
                { -1, -2, 1 },
                { -2, -1, -2 }
            };
        }
        if (ChackMap(mapOneRight, map, info))
        {
            return(GetTop());
        }

        //GetOneLeft();
        if (mapOneLeft == null)
        {
            mapOneLeft = new short[, ] {
                { -2, -1, -2 },
                { 1, -2, -1 },
                { -2, -1, -2 }
            };
        }
        if (ChackMap(mapOneLeft, map, info))
        {
            return(GetTop());
        }

        //GetOneTop();
        if (mapOneTop == null)
        {
            mapOneTop = new short[, ] {
                { -2, -1, -2 },
                { -1, -2, -1 },
                { -2, 1, -2 }
            };
        }
        if (ChackMap(mapOneTop, map, info))
        {
            return(GetOneTop());
        }

        //GetOneBottom();
        if (mapOneBottom == null)
        {
            mapOneBottom = new short[, ] {
                { -2, 1, -2 },
                { -1, -2, -1 },
                { -2, -1, -2 }
            };
        }
        if (ChackMap(mapOneBottom, map, info))
        {
            return(GetOneBottom());
        }

        //GetTop();
        if (mapTop == null)
        {
            mapTop = new short[, ] {
                { -2, -1, -2 },
                { 1, -2, 1 },
                { -2, 1, -2 }
            };
        }
        if (ChackMap(mapTop, map, info))
        {
            return(GetTop());
        }

        //GetBottom();
        if (mapBottom == null)
        {
            mapBottom = new short[, ] {
                { -2, 1, -2 },
                { 1, -2, 1 },
                { -2, -1, -2 }
            };
        }
        if (ChackMap(mapBottom, map, info))
        {
            return(GetBottom());
        }

        //GetLeft();
        if (mapLeft == null)
        {
            mapLeft = new short[, ] {
                { -2, 1, -2 },
                { -1, -2, 1 },
                { -2, 1, -2 }
            };
        }
        if (ChackMap(mapLeft, map, info))
        {
            return(GetLeft());
        }

        //GetRight();
        if (mapRight == null)
        {
            mapRight = new short[, ] {
                { -2, 1, -2 },
                { 1, -2, -1 },
                { -2, 1, -2 }
            };
        }
        if (ChackMap(mapRight, map, info))
        {
            return(GetRight());
        }


        //GetLeftBottomCorner();
        if (mapLeftBottomCorner == null)
        {
            mapLeftBottomCorner = new short[, ] {
                { -2, 1, -2 },
                { -1, -2, 1 },
                { -2, -1, -2 }
            };
        }
        if (ChackMap(mapLeftBottomCorner, map, info))
        {
            return(GetLeftBottomCorner());
        }

        //GetRightBottomCorner();
        if (mapmapLeftBottomCorner == null)
        {
            mapmapLeftBottomCorner = new short[, ] {
                { -2, 1, -2 },
                { 1, -2, -1 },
                { -2, -1, -2 }
            };
        }
        if (ChackMap(mapmapLeftBottomCorner, map, info))
        {
            return(GetRightBottomCorner());
        }


        return(GetOne());
    }
示例#5
0
    public FrameStructure GetFrameStructure(float x, float y, TileInfoStructure tileStructure, LayerData layerData)
    {
        FrameStructure rez = FrameStructure.Empty();


        var pos = new Vector2(x, y);

        if (layerData.IsShowWater)
        {
            if (tileStructure.IsWater())
            {
                var rectWater = GetRect(3, pos, 3, layerData);
                rez = SpriteData.Liquid_0.Shema.GetShema(rectWater, tileStructure);
                return(rez);
            }
        }

        if (layerData.IsShowLight)
        {
            var rectLight = GetRectStructure(3, pos, 0);
            rez = LightShema.GetShemaStructure(rectLight, tileStructure);
            return(rez);
        }

        if (tileStructure.type == 0 && tileStructure.typeBG == 0)
        {
            return(rez);
        }

        if (layerData == LayerData.TerrainBgLayer)
        {
            if (tileStructure.typeBG == 0)
            {
                return(rez);
            }


            if (IsAllNeighborsIsNotEmpty(x, y))
            {
                return(rez);
            }



            var rectBg = GetRect(3, pos, 3, layerData);
            rez = SpriteData.Tiles_bg.Shema.GetShema(rectBg, tileStructure);
            rez.TileCollection = SpriteData.Tiles_bg.Name;
            return(rez);
        }

        if (tileStructure.type == 0)
        {
            return(rez);
        }

        if (!layerData.IsContainsTileType(tileStructure.type))
        {
            return(rez);
        }

        var data = SpriteData.SpritesByTypeId[tileStructure.type];
        var rect = GetRect(data.SquareSizeByShema, pos, tileStructure.layer, layerData);

        rez = data.Shema.GetShema(rect, tileStructure);
        rez.TileCollection = data.Name;

        return(rez);
    }
示例#6
0
 public LightInfoStructure GetLightStructure(float x, float y, TileInfoStructure tileStructure)
 {
     return(LightShema.GetLightShemaStructure(null, tileStructure));
 }
示例#7
0
    public FrameStructure GetShema(short[,] map, TileInfoStructure info)
    {
        currentTileInfo = info;

        // return GetTopL();
        // GetTopL();
        if (mapTopL == null)
        {
            mapTopL = new short[, ] {
                { -2, -2, -2 },
                { -2, 1, 1 },
                { -2, 1, 1 }
            }
        }
        ;
        if (ChackMap(mapTopL, map, info))
        {
            return(GetTopL());
        }

        // GetTopR();
        if (mapTopR == null)
        {
            mapTopR = new short[, ] {
                { -2, -2, -2 },
                { 1, 1, -2 },
                { 1, 1, -2 }
            }
        }
        ;
        if (ChackMap(mapTopR, map, info))
        {
            return(GetTopR());
        }


        // mapBottomL();
        if (mapBottomL == null)
        {
            mapBottomL = new short[, ] {
                { -2, 1, 1 },
                { -2, 1, 1 },
                { -2, -2, -2 }
            }
        }
        ;
        if (ChackMap(mapBottomL, map, info))
        {
            return(GetBottomL());
        }


        // mapBottomR();
        if (mapBottomR == null)
        {
            mapBottomR = new short[, ] {
                { 1, 1, -2 },
                { 1, 1, -2 },
                { -2, -2, -2 }
            }
        }
        ;
        if (ChackMap(mapBottomR, map, info))
        {
            return(GetBottomR());
        }


        return(new FrameStructure());
    }
}
示例#8
0
    public FrameStructure GetShema(short[,] map, TileInfoStructure info)
    {
        currentTileInfo = info;
        // return GetCenter();
        //new FrameStructure(7, 0);
        if (info.randomTile >= 100)
        {
            int y = info.randomTile % 100;
            int x = (info.randomTile - y) / 100 - 2;

            if (!buffer.ContainsKey(x) || !buffer[x].ContainsKey(y))
            {
                buffer[x]    = new Dictionary <int, FrameStructure>();
                buffer[x][y] = new FrameStructure(x, y);
            }

            return(buffer[x][y]);
        }

        //   return GetCenter();

        //GetRootBottomCenter();
        if (mapRootBottomCenter == null)
        {
            mapRootBottomCenter = new short[, ] {
                { -2, 1, -2 },
                { -2, 1, -2 },
                { -1, -1, -1 }
            };
        }
        if (ChackMap(mapRootBottomCenter, map, info))
        {
            return(GetRootBottomCenter());
        }

        //GetRootBottomLeft();
        if (mapRootBottomLeft == null)
        {
            mapRootBottomLeft = new short[, ] {
                { -1, -1, 1 },
                { -1, 1, 1 },
                { -1, -1, -1 }
            };
        }
        if (ChackMap(mapRootBottomLeft, map, info))
        {
            return(GetRootBottomLeft());
        }

        //GetRootBottomRight();
        if (mapRootBottomRight == null)
        {
            mapRootBottomRight = new short[, ] {
                { 1, -1, -1 },
                { 1, 1, -1 },
                { -1, -1, -1 }
            };
        }



        if (ChackMap(mapRootBottomRight, map, info))
        {
            return(GetRootBottomRight());
        }

        return(GetCenter());

        //GetCenter();
        if (mapCenter == null)
        {
            mapCenter = new short[, ] {
                { -2, 2, -2 },
                { 0, -2, 0 },
                { -2, 2, -2 }
            };
        }
        if (ChackMap(mapCenter, map, info))
        {
            return(GetCenter());
        }

        //GetTop();
        if (mapTop == null)
        {
            mapTop = new short[, ] {
                { 0, 0, 0 },
                { -2, -2, -2 },
                { -2, 1, -2 }
            };
        }
        if (ChackMap(mapTop, map, info))
        {
            return(GetTop());
        }



        //GetBranchLeft();
        if (mapBranchLeft == null)
        {
            mapBranchLeft = new short[, ] {
                { -2, -1, -2 },
                { -1, -2, 1 },
                { -2, -1, 1 }
            };
        }
        if (ChackMap(mapBranchLeft, map, info))
        {
            return(GetBranchLeft());
        }


        //GetBranchRight();
        if (mapBranchRight == null)
        {
            mapBranchRight = new short[, ] {
                { -2, -1, -2 },
                { 1, -2, -2 },
                { 1, -1, -2 }
            };
        }
        if (ChackMap(mapBranchRight, map, info))
        {
            return(GetBranchRight());
        }


        //GetBranchLeftCenter();
        if (mapBranchLeftCenter == null)
        {
            mapBranchLeftCenter = new short[, ] {
                { -2, -2, -2 },
                { 1, -2, -1 },
                { -2, -2, -2 }
            };
        }
        if (ChackMap(mapBranchLeftCenter, map, info))
        {
            return(GetBranchLeftCenter());
        }

        //GetBranchRightCenter();
        if (mapBranchRightCenter == null)
        {
            mapBranchRightCenter = new short[, ] {
                { -2, -2, -2 },
                { -1, -2, 1 },
                { -2, -2, -2 }
            };
        }
        if (ChackMap(mapBranchRightCenter, map, info))
        {
            return(GetBranchRightCenter());
        }


        return(GetRootBottomRight());
    }
示例#9
0
    public FrameStructure GetShema(short[,] map, TileInfoStructure info)
    {
        currentTileInfo = info;

        //return CenterLeftRez;
        if (map[1, 1] == 0)
        {
            return(free);
        }

        //GetOneHorizontalCenter();
        if (map[topCenter.FrameX, topCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0)
        {
            return(GetOneHorizontalCenter());
        }
        //GetOneHorizontalLeft();
        if (map[topCenter.FrameX, topCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] == 0
            )
        {
            return(GetOneHorizontalLeft());
        }
        //GetOneHorizontalRight();
        if (map[topCenter.FrameX, topCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0)
        {
            return(GetOneHorizontalRight());
        }
        //GetOneVerticalCenter();
        if (map[leftCenter.FrameX, leftCenter.FrameY] == 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] == 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetOneVerticalCenter());
        }
        //GetOneVerticalTop();
        if (map[topCenter.FrameX, topCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] == 0)
        {
            //  Debug.LogError("op");

            /*
             * string s = "";
             * for (int x = 0; x < map.GetLength(0); x++) {
             *
             *  for (int y = 0; y < map.GetLength(1); y++) {
             *      s += map[x, y] + ", ";
             *  }
             *  s += "\n";
             *
             * }
             *
             * Debug.LogError(s);
             */
            return(GetOneVerticalTop());
        }

        //GetOneVerticalBottom();
        if (map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] == 0)
        {
            return(GetOneVerticalBottom());
        }

        //GetTopCenter();
        if (map[topCenter.FrameX, topCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0)
        {
            return(GetTopCenter());
        }

        //GetBottomCenter();
        if (map[bottomCenter.FrameX, bottomCenter.FrameY] == 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0)
        {
            return(GetBottomCenter());
        }

        //GetCenterLeft();
        if (map[leftCenter.FrameX, leftCenter.FrameY] == 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetCenterLeft());
        }

        //GetCenterRight();
        if (map[rightCenter.FrameX, rightCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetCenterRight());
        }

        //GetTopLeft();
        if (map[topCenter.FrameX, topCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] == 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetTopLeft());
        }

        //GetTopRight();
        if (map[topCenter.FrameX, topCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetTopRight());
        }

        //GetBottomLeft();
        if (map[leftCenter.FrameX, leftCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0)
        {
            return(GetBottomLeft());
        }

        //GetBottomRight();
        if (map[rightCenter.FrameX, rightCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0)
        {
            return(GetBottomRight());
        }

        //GetInnerCornerTopLefr()
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[topRight.FrameX, topRight.FrameY] != info.type &&
            map[topLeft.FrameX, topLeft.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == info.type &&
            map[bottomRight.FrameX, bottomRight.FrameY] != info.type &&
            map[bottomLeft.FrameX, bottomLeft.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] == info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type)
        {
            return(GetInnerCornerTopLefr());
        }

        //GetInnerCornerTopRight()
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[topRight.FrameX, topRight.FrameY] != info.type &&
            map[topLeft.FrameX, topLeft.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == info.type &&
            map[bottomRight.FrameX, bottomRight.FrameY] != info.type &&
            map[bottomLeft.FrameX, bottomLeft.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] == info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type)
        {
            return(GetInnerCornerTopRight());
        }

        //GetInnerCornerBottomLefr()
        if (map[topCenter.FrameX, topCenter.FrameY] == info.type &&
            map[topRight.FrameX, topRight.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[bottomLeft.FrameX, bottomLeft.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] != info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] == info.type)
        {
            return(GetInnerCornerBottomLefr());
        }


        //GetInnerCornerBottomRight()
        if (map[topCenter.FrameX, topCenter.FrameY] == info.type &&
            map[topLeft.FrameX, topLeft.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[bottomRight.FrameX, bottomRight.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] == info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type)
        {
            return(GetInnerCornerBottomRight());
        }

        //GetOne();
        if (map[rightCenter.FrameX, rightCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] == 0 &&
            map[topCenter.FrameX, topCenter.FrameY] == 0)
        {
            return(GetOne());
        }

        //GetCenter
        if (map[rightCenter.FrameX, rightCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0)
        {
            return(GetCenter());
        }

        return(GetOne());
    }
示例#10
0
    public FrameStructure GetShema(short[,] map, TileInfoStructure info)
    {
        currentTileInfo = info;



        //GetInnerCornerTopLefr()
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[topRight.FrameX, topRight.FrameY] != info.type &&
            map[topLeft.FrameX, topLeft.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == info.type &&
            map[bottomRight.FrameX, bottomRight.FrameY] != info.type &&
            map[bottomLeft.FrameX, bottomLeft.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] == info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type)
        {
            return(GetInnerCornerTopLefr());
        }

        //GetInnerCornerTopRight()
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[topRight.FrameX, topRight.FrameY] != info.type &&
            map[topLeft.FrameX, topLeft.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == info.type &&
            map[bottomRight.FrameX, bottomRight.FrameY] != info.type &&
            map[bottomLeft.FrameX, bottomLeft.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] == info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type)
        {
            return(GetInnerCornerTopRight());
        }

        //GetInnerCornerBottomLefr()
        if (map[topCenter.FrameX, topCenter.FrameY] == info.type &&
            map[topRight.FrameX, topRight.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[bottomLeft.FrameX, bottomLeft.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] != info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] == info.type)
        {
            return(GetInnerCornerBottomLefr());
        }


        //GetInnerCornerBottomRight()
        if (map[topCenter.FrameX, topCenter.FrameY] == info.type &&
            map[topLeft.FrameX, topLeft.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[bottomRight.FrameX, bottomRight.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] == info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type)
        {
            return(GetInnerCornerBottomRight());
        }


        //GetOneHorizontalCenter();
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0)
        {
//.            return GetOneHorizontalCenter();
            return(GetTopCenter());
        }
        //GetOneHorizontalLeft();
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != info.type
            )
        {
            return(GetOneHorizontalLeft());
        }
        //GetOneHorizontalRight();
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0)
        {
            return(GetOneHorizontalRight());
        }
        //GetOneVerticalCenter();
        if (map[leftCenter.FrameX, leftCenter.FrameY] != info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetOneVerticalCenter());
        }
        //GetOneVerticalTop();
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] != info.type)
        {
            return(GetOneVerticalTop());
        }

        //GetOneVerticalBottom();
        if (map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] != info.type)
        {
            return(GetOneVerticalBottom());
        }

        //GetTopCenter();
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0)
        {
            return(GetTopCenter());
        }

        //GetBottomCenter();
        if (map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0)
        {
            return(GetBottomCenter());
        }

        //GetCenterLeft();
        if (map[leftCenter.FrameX, leftCenter.FrameY] != info.type &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetCenterLeft());
        }

        //GetCenterRight();
        if (map[rightCenter.FrameX, rightCenter.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetCenterRight());
        }

        //GetTopLeft();
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] == 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetTopLeft());
        }

        //GetTopRight();
        if (map[topCenter.FrameX, topCenter.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0)
        {
            return(GetTopRight());
        }

        //GetBottomLeft();
        if (map[leftCenter.FrameX, leftCenter.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[topCenter.FrameX, topCenter.FrameY] != 0 &&
            map[rightCenter.FrameX, rightCenter.FrameY] != 0)
        {
            return(GetBottomLeft());
        }

        //GetBottomRight();
        if (map[rightCenter.FrameX, rightCenter.FrameY] != info.type &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != info.type &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0)
        {
            return(GetBottomRight());
        }

        //GetOne();
        if (map[rightCenter.FrameX, rightCenter.FrameY] == 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] == 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] == 0 &&
            map[topCenter.FrameX, topCenter.FrameY] == 0)
        {
            return(GetOne());
        }

        //GetCenter
        if (map[rightCenter.FrameX, rightCenter.FrameY] != 0 &&
            map[bottomCenter.FrameX, bottomCenter.FrameY] != 0 &&
            map[leftCenter.FrameX, leftCenter.FrameY] != 0 &&
            map[topCenter.FrameX, topCenter.FrameY] != 0)
        {
            return(GetCenter());
        }

        return(GetOne());
    }
示例#11
0
 bool CanPour(TileInfoStructure tile)
 {
     return(tile.CanPourWater());
 }
示例#12
0
    public void UpdateWater()
    {
        //  Debug.Log(string.Format("active = {0}, inactive = {1}", activePointIndex.Count, inactivePointIndex.Count));
        int countUpdate = 0;

        for (int i = activePointIndex.Count - 1; i >= 0; i--)
        {
            // countUpdate++;
            //  if (Time.frameCount > 100&& countUpdate > maxWaterUpdate)
            //     break;

            posCenter = activePointIndex[i];

            if (!ChackPos(posCenter))
            {
                activePointIndex.RemoveAt(i);
                SetID(posCenter, 0);

                //   RemoveLastCountDictionary(posCenter);

                continue;
            }

            posBottom = new Vector2Int(posCenter.x, posCenter.y - 1);
            posLeft   = new Vector2Int(posCenter.x - 1, posCenter.y);
            posRight  = new Vector2Int(posCenter.x + 1, posCenter.y);


            center = GetTile(posCenter);
            left   = GetTile(posLeft);
            right  = GetTile(posRight);
            bottom = GetTile(posBottom);

            WaterRan2();
        }

        ClearPourCount();

        for (int i = activePointIndex.Count - 1; i >= 0; i--)
        {
            Vector2Int posCenter = activePointIndex[i];
            if (GetCount(posCenter) == 0 || !GetTile(posCenter).IsWater())
            {
                ChackWater(posCenter, false);
                activePointIndex.RemoveAt(i);
            }
            else    /*
                     * posBottom = new Vector2Int(posCenter.x, posCenter.y - 1);
                     * bottom = GetTile(posBottom);
                     *
                     * if (!CanPour(bottom) && GetLastCountDictionary(posCenter) == GetNCount(posCenter)) {
                     * activePointIndex.RemoveAt(i);
                     * SetID(posCenter, 0);
                     *
                     * RemoveLastCountDictionary(posCenter);
                     * IsACap(posCenter);
                     * } else {
                     * SetLastCountDictionary(posCenter, GetNCount(posCenter));
                     * }*/
            {
            }
        }

        //     activePointIndex = activePointIndex.OrderByDescending(v => v.y).ThenBy(v => v.x).ToList();
        for (int i = 0; i < activePointIndex.Count; i++)
        {
            //    Debug.Log(activePointIndex[i]);
        }
        activePointIndex = activePointIndex.OrderByDescending(x => x.y).ToList();
    }