Пример #1
0
 private void CreateAttribute(IntPair position, Tile tile)
 {
     if (tile.HasAttribute(Type.ENGING_POINT))
     {
         CreateEndingAttribute(position);
     }
     if (tile.HasAttribute(Type.ENEMY_SPAWNING_POINT))
     {
         CreateEnemy(position);
     }
 }
Пример #2
0
 public Map(int mapSize)
 {
     this.mapArray = new Tile[mapSize][];
     for (var i = 0; i < mapSize; i++)
     {
         mapArray[i] = new Tile[mapSize];
     }
     for (var i = 0; i < mapSize; i++)
     {
         for (var j = 0; j < mapSize; j++)
         {
             mapArray[i][j] = new Tile(new Water());
         }
     }
 }
Пример #3
0
        public static Map ReadMap(string json)
        {
            List<Map.Tile> tiles = new List<Map.Tile>();
            List<Map.Town> towns = new List<Map.Town>();
            LitJson.JsonData data = LitJson.JsonMapper.ToObject(json);
            Vector2 min = new Vector2();
            Vector2 max = new Vector2();
            min.x = float.Parse(data["min"]["x"].ToString());
            min.y = float.Parse(data["min"]["y"].ToString());
            max.x = float.Parse(data["max"]["x"].ToString());
            max.y = float.Parse(data["max"]["y"].ToString());
            for (int i = 0; i < data["tiles"].Count; i++) {
                LitJson.JsonData s = data["tiles"][i];
                int x = int.Parse(s["key"]["x"].ToString());
                int y = int.Parse(s["key"]["y"].ToString());
                Map.HexCoord hc = Map.HexCoord.HexCoordXY(x, y);
                Map.TileType tt = (Map.TileType)Enum.Parse(typeof(Map.TileType), s["value"]["tileType"].ToString());
                Map.Penalty penalty = (Map.Penalty)Enum.Parse(typeof(Map.Penalty), s["value"]["penalty"].ToString());
                Map.Visibility v = (Map.Visibility)Enum.Parse(typeof(Map.Visibility), s["value"]["visibility"].ToString());

                Map.Tile tile = new Map.Tile();
                tile.hexCoord = hc;
                tile.spriteType = tt;
                tile.penalty = penalty;
                tile.visibility = v;

                tiles.Add(tile);
            }
            for (int i = 0; i < data["towns"].Count; i++) {
                LitJson.JsonData s = data["towns"][i];
                int x = int.Parse(s["key"]["x"].ToString());
                int y = int.Parse(s["key"]["y"].ToString());
                Map.HexCoord hc = Map.HexCoord.HexCoordXY(x, y);

                int team = int.Parse(s["value"]["playerSide"].ToString());

                Map.Town town = new Map.Town();
                town.hexCoord = hc;
                town.team = team;

                towns.Add(town);
            }

            return new Map(tiles, towns, min, max);
        }
Пример #4
0
 private void CreateWalls(IntPair position, Tile tile)
 {
     foreach (Direction direciton in Model.Utils.GetAllDirections())
     {
         if (tile.GetNeighbour(direciton) == null)
         {
             CreateWall(position.Move(direciton));
         }
     }
 }
 public void SetCurrentTile(Tile tile)
 {
     currentTile = tile;
 }