Exemplo n.º 1
0
        public void loadDefaultMapTest()
        {
            IMapTile[][] expected = new IMapTile[5][];
            expected[0] = new IMapTile[6];
            expected[1] = new IMapTile[6];
            expected[2] = new IMapTile[6];
            expected[3] = new IMapTile[6];
            expected[4] = new IMapTile[6];
            expected[0][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[0][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[0][2] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[0][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[0][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[0][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[1][0] = new RoadTile(RoadTile.RoadType.Horizontal);
            expected[1][1] = new RoadTile(RoadTile.RoadType.Horizontal);
            expected[1][2] = new RoadTile(RoadTile.RoadType.TopRight);
            expected[1][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[1][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[1][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[2][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[2][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[2][2] = new RoadTile(RoadTile.RoadType.Vertical);
            expected[2][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[2][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[2][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[3][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[3][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[3][2] = new RoadTile(RoadTile.RoadType.BottomLeft);
            expected[3][3] = new RoadTile(RoadTile.RoadType.Horizontal);
            expected[3][4] = new RoadTile(RoadTile.RoadType.Horizontal);
            expected[3][5] = new RoadTile(RoadTile.RoadType.Horizontal);
            expected[4][0] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[4][1] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[4][2] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[4][3] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[4][4] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);
            expected[4][5] = new BackgroundTile(BackgroundTile.BackgroundType.Plain);

            IMapTile[][] actual = MapLoader.loadDefaultMap();

            Assert.IsTrue(actual.Length > 0 && actual[0].Length > 0, "Map has not a valid dimension");
            Assert.AreEqual(expected.Length, actual.Length, "Constructed map has a different height");
            Assert.AreEqual(expected[0].Length, actual[0].Length, "Constructed map has a different width");

            for (int i = actual.Length; i-- > 0; )
            {
                for (int j = actual[0].Length; j-- > 0; )
                {
                    int hashA = expected[i][j].GetHashCode();
                    int hashB = actual[i][j].GetHashCode();
                    Assert.AreEqual(expected[i][j], actual[i][j], "Constructed map got a different tile at (" + i + "," + j + ")");
                }
            }
        }
Exemplo n.º 2
0
        public static Bitmap FindResource(RoadTile.RoadType type)
        {
            switch (type)
            {
                case RoadTile.RoadType.Horizontal:
                    return Properties.Resources.TileRoadHorizontal;
                case RoadTile.RoadType.Vertical:
                    return Properties.Resources.TileRoadVertical;
                case RoadTile.RoadType.TopLeft:
                    return Properties.Resources.TileRoadTopLeft;
                case RoadTile.RoadType.TopRight:
                    return Properties.Resources.TileRoadTopRight;
                case RoadTile.RoadType.BottomLeft:
                    return Properties.Resources.TileRoadBottomLeft;
                case RoadTile.RoadType.BottomRight:
                    return Properties.Resources.TileRoadBottomRight;
                case RoadTile.RoadType.TopBottomLeft:
                    return Properties.Resources.TileRoadTopBottomLeft;
                case RoadTile.RoadType.TopBottomRight:
                    return Properties.Resources.TileRoadTopBottomRight;
                case RoadTile.RoadType.TopLeftRight:
                    return Properties.Resources.TileRoadTopLeftRight;
                case RoadTile.RoadType.BottomLeftRight:
                    return Properties.Resources.TileRoadBottomLeftRight;
                case RoadTile.RoadType.TopBottomLeftRight:
                    return Properties.Resources.TileRoadTopBottomLeftRight;

                default:
                    throw new ArgumentException("Unhandled animation bitmap tile: " + type);
            }
        }
Exemplo n.º 3
0
 private static Bitmap selectTile(RoadTile.Type dir)
 {
     switch (dir)
     {
         case Type.Horizontal:
             return Resources.TileRoadHorizontal;
         case Type.Vertical:
             return Resources.TileRoadVertical;
         case Type.TopLeft:
             return Resources.TileRoadTopLeft;
         case Type.TopRight:
             return Resources.TileRoadTopRight;
         case Type.BottomLeft:
             return Resources.TileRoadBottomLeft;
         case Type.BottomRight:
             return Resources.TileRoadBottomRight;
         default:
             throw new ArgumentException("Unknown Road Direction");
     }
 }
Exemplo n.º 4
0
 public RoadTile(RoadTile.Type dir)
     : base(selectTile(dir))
 {
 }