//---------------CONSTRUCCIÓN TILES------------------------ //Pasa la representación lógica del tablero (matriz) a la representación física (gameobjects) void colocaTablero() { GameObject GOTablero = new GameObject("Tablero"); for (int y = 0; y < 10; y++) { for (int x = 0; x < 10; x++) { //Creamos gameObject GameObject GOTileAux = Instantiate(tilePrefab, new Vector3(x * Distancia, -y * Distancia, 0), Quaternion.identity, GOTablero.transform); LogicaTile tileAux = _logicaTablero.GetLogicaTile(x, y); //SpriteRenderer switch (tileAux.GetTerreno()) { case Terreno.agua: GOTileAux.GetComponent <SpriteRenderer>().sprite = spriteAgua; break; case Terreno.aguaProfunda: GOTileAux.GetComponent <SpriteRenderer>().sprite = spriteAguaProfunda; break; case Terreno.muro: GOTileAux.GetComponent <SpriteRenderer>().sprite = spriteMuro; break; } //Casilla GOTileAux.GetComponent <Tile>().ConstruyeCasilla(tileAux); } } }
private void OnMouseDown() { if (GameManager.instance.GetSeleccionado() == ColorUnidad.ninguno) { SpriteRenderer render = GetComponent <SpriteRenderer>(); switch (_logicaTile.GetTerreno()) { case Terreno.libre: _logicaTile.SetTerreno(Terreno.agua); render.sprite = GameManager.instance.spriteAgua; break; case Terreno.agua: _logicaTile.SetTerreno(Terreno.cienaga); render.sprite = GameManager.instance.spriteCienaga; break; case Terreno.cienaga: _logicaTile.SetTerreno(Terreno.muro); render.sprite = GameManager.instance.spriteMuro; break; case Terreno.muro: _logicaTile.SetTerreno(Terreno.libre); render.sprite = GameManager.instance.spriteLibre; break; } } else if (_logicaTile.GetTerreno() == Terreno.muro) { GameManager.instance.Deselecciona(); } //Mover else { GameManager.instance.MoverPJ(_logicaTile.GetPos()); } }