public void init(BoardManager _board, float x, float y) { board = _board; transform.localPosition = new Vector3(x, y); showArrow = true; moving = false; Color c = levelManager.GetLevelColor(); playerSprite.color = c; NArrowSprite.color = c; DArrowSprite.color = c; RArrowSprite.color = c; LArrowSprite.color = c; goal = false; onPause = false; Movements = new Stack <TraceInfo>(); }
public void SetMap(Map map) { if (levelManager != null) { color = levelManager.GetLevelColor(); } else { color = Color.white; } this.map = map; tiles = new Tile[map.GetHeight() + 1, map.GetWidth() + 1]; List <Point> mapIce; mapIce = map.GetIceTiles(); List <Wall> mapWalls; mapWalls = map.GetWalls(); float xOffset = -(map.GetWidth() + 1) / 2.0f; float yOffset = -(map.GetHeight() + 1) / 2.0f; Vector3 scale = new Vector3(map.GetWidth(), map.GetHeight()); scale.x = (7.0f / scale.x) * transform.localScale.x * 1.5f; scale.y = (9.0f / scale.y) * transform.localScale.y * 1.5f; this.transform.localScale = scale; // Instancia las tiles del nivel for (int r = 0; r < map.GetHeight() + 1; r++) { for (int c = 0; c < map.GetWidth() + 1; c++) { Tile tile = CreateTile(c + xOffset, r + yOffset); tiles[r, c] = tile; tile.setColor(color); // Propiedades del tile if (map.GetGoal().x + 1 == c && map.GetGoal().y + 1 == r) { tile.EnableGoal(); } if (c == 0 && r != 0) { tile.EnableRightWall(); } if (r == 0 && c != 0) { tile.EnableTopWall(); } Point pos; pos.x = c - 0.5f; pos.y = r - 0.5f; if (mapIce.Contains(pos)) { tile.EnableIce(); } Point originX; originX.x = c - 1; originX.y = r; Point destinyX; destinyX.x = c; destinyX.y = r; Point destiny; destiny.x = c; destiny.y = r; Wall helpX; helpX.o = originX; helpX.d = destinyX; if (mapWalls.Contains(helpX)) { tile.EnableTopWall(); } else { helpX.o = destinyX; helpX.d = originX; if (mapWalls.Contains(helpX)) { tile.EnableTopWall(); } } Point originY; originY.x = c; originY.y = r - 1; Wall helpY; helpY.o = destiny; helpY.d = originY; if (mapWalls.Contains(helpY)) { tile.EnableRightWall(); } else { helpY.o = originY; helpY.d = destiny; if (mapWalls.Contains(helpY)) { tile.EnableRightWall(); } } } } Point playerStart = map.GetStart(); player.init(this, playerStart.x + xOffset + 1, playerStart.y + yOffset + 1); }