Пример #1
0
        ////////////////////////////////////////////////////////////////////////
        // タイルを描画
        ////////////////////////////////////////////////////////////////////////
        private static bool DrawRectWithTileType(TileType type, Rectangle rect)
        {
            switch (type)
            {
            case TileType.Walkable:
                GetGraphics().DrawRectangle(colorWorkable, rect);
                break;

            case TileType.Wall:
                GetGraphics().FillRectangle(colorWall, rect);
                break;

            case TileType.StartTile:
                GetGraphics().FillRectangle(colorStart, rect);
                break;

            case TileType.GoalTile:
                GetGraphics().FillRectangle(colorGoal, rect);
                break;

            case TileType.NullTile:
                GetGraphics().FillRectangle(colorNull, rect);
                break;

            case TileType.AnalyzedTile:
                GetGraphics().FillRectangle(colorAnalyzed, rect);
                break;

            default:
                return(false);
            }
            return(true);
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////
        // 該当タイルを更新
        ////////////////////////////////////////////////////////////////////////
        public static bool UpdateTile(Vector2 coord, TileType type)
        {
            if (!VaildCoord(coord))
            {
                return(false);
            }

            var block = GetTileBlock(new Vector2(coord.x, coord.y));

            if (block == null)
            {
                return(false);
            }

            if (block.GetTileType() != type)
            {
                block.SetTileType(type);
                var rect = GetRectangle(coord);
                DrawRectWithTileType(TileType.NullTile, rect);
                LoggerForm.WriteInfo(string.Format("Tile Updated | X: {0}, Y: {1}", coord.x, coord.y));
                return(DrawRectWithTileType(type, rect));
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
 ////////////////////////////////////////////////////////////////////////
 // タイル座標を取得
 ////////////////////////////////////////////////////////////////////////
 public static Vector2 GetTileCoordByTileType(TileType type)
 {
     for (int x = 0; x < MAX_COORD_X; x++)
     {
         for (int y = 0; y < MAX_COORD_Y; y++)
         {
             if (GetTileBlock(new Vector2(x, y)).GetTileType() == type)
             {
                 return(new Vector2(x, y));
             }
         }
     }
     LoggerForm.WriteError("GetTileCoordByTileType() Tile not found!");
     return(new Vector2(0, 0));
 }
Пример #4
0
 ////////////////////////////////////////////////////////////////////////
 // タイル属性からタイルクラスを取得
 ////////////////////////////////////////////////////////////////////////
 public static TileBlock GetTileBlockByTileType(TileType type)
 {
     for (int x = 0; x < MAX_COORD_X; x++)
     {
         for (int y = 0; y < MAX_COORD_Y; y++)
         {
             var tile = GetTileBlock(new Vector2(x, y));
             if (tile.GetTileType() == type)
             {
                 return(tile);
             }
         }
     }
     LoggerForm.WriteError("GetTileBlockByTileType() Tile not found!");
     return(null);
 }
Пример #5
0
        ////////////////////////////////////////////////////////////////////////
        // タイルを追加
        ////////////////////////////////////////////////////////////////////////
        public static bool AddTile(Vector2 coord, TileType type)
        {
            if (!VaildCoord(coord))
            {
                return(false);
            }

            var block = GetTileBlock(new Vector2(coord.x, coord.y));

            if (block != null)
            {
                if (block.GetTileType() != type)
                {
                    return(DrawRectWithTileType(type, GetRectangle(coord)));
                }
            }
            else
            {
                tileBlocks[coord.x, coord.y] = new TileBlock(coord, type);
                return(DrawRectWithTileType(type, GetRectangle(coord)));
            }

            return(false);
        }