//função que atribui comportamentos aos elementos da dropdown list de diferentes peças void InstantiatePrimitive(activeTile at) { switch (at) { case activeTile.elephant: GetComponent <MeshRenderer>().material = elephantTile; currentTileValue = 0; break; case activeTile.giraffe: GetComponent <MeshRenderer>().material = giraffeTile; currentTileValue = 1; break; case activeTile.hippo: GetComponent <MeshRenderer>().material = hippoTile; currentTileValue = 2; break; case activeTile.monkey: GetComponent <MeshRenderer>().material = monkeyTile; currentTileValue = 3; break; case activeTile.panda: GetComponent <MeshRenderer>().material = pandaTile; currentTileValue = 4; break; case activeTile.parrot: GetComponent <MeshRenderer>().material = parrotTile; currentTileValue = 5; break; case activeTile.penguin: GetComponent <MeshRenderer>().material = penguinTile; currentTileValue = 6; break; case activeTile.pig: GetComponent <MeshRenderer>().material = pigTile; currentTileValue = 7; break; case activeTile.rabbit: GetComponent <MeshRenderer>().material = rabbitTile; currentTileValue = 8; break; case activeTile.snake: GetComponent <MeshRenderer>().material = snakeTile; currentTileValue = 9; break; } }
public static void setActiveTile(HexaPos pos, HexaPos oldPos) { GameObject parent = landscape[oldPos.x, oldPos.y]; if (pos != oldPos) { GameObject actmap = parent.transform.FindChild("actualTile").gameObject; Tile oldTile = parent.GetComponent <Tile>(); GameObject restore; if (oldTile.tile_type == tileType.Desert) { if (oldTile.genField == 1) { restore = (GameObject)Instantiate(Initialisation.sandTile_1); } else if (oldTile.genField == 2) { restore = (GameObject)Instantiate(Initialisation.sandTile_2); } else { restore = (GameObject)Instantiate(Initialisation.sandTile_3); } } else if (oldTile.tile_type == tileType.Forrest) { if (oldTile.genField == 1) { restore = (GameObject)Instantiate(Initialisation.forrestTile_1); } else if (oldTile.genField == 2) { restore = (GameObject)Instantiate(Initialisation.forrestTile_2); } else { restore = (GameObject)Instantiate(Initialisation.forrestTile_3); } } else if (oldTile.tile_type == tileType.Mountain) { if (oldTile.genField == 1) { restore = (GameObject)Instantiate(Initialisation.mountainTile_1); } else if (oldTile.genField == 2) { restore = (GameObject)Instantiate(Initialisation.mountainTile_2); } else { restore = (GameObject)Instantiate(Initialisation.mountainTile_3); } } else { if (oldTile.genField == 1) { restore = (GameObject)Instantiate(Initialisation.oasisTile_1); } else if (oldTile.genField == 2) { restore = (GameObject)Instantiate(Initialisation.oasisTile_2); } else { restore = (GameObject)Instantiate(Initialisation.oasisTile_3); } } discoveredTile dt = restore.AddComponent <discoveredTile>(); dt.position = oldPos; restore.AddComponent <MeshCollider>(); restore.transform.position = actmap.transform.position; restore.transform.localScale = actmap.transform.lossyScale; restore.transform.parent = parent.transform; restore.transform.name = "actualTile"; Destroy(actmap); } //SET new active Tile here parent = landscape[pos.x, pos.y]; GameObject newTile = parent.transform.FindChild("actualTile").gameObject; Tile oldTileq = parent.GetComponent <Tile>(); GameObject activeTile; if (oldTileq.tile_type == tileType.Desert) { activeTile = (GameObject)Instantiate(Initialisation.sandTile_active); } else if (oldTileq.tile_type == tileType.Forrest) { activeTile = (GameObject)Instantiate(Initialisation.forrestTile_active); } else if (oldTileq.tile_type == tileType.Mountain) { activeTile = (GameObject)Instantiate(Initialisation.mountainTile_active); } else { activeTile = (GameObject)Instantiate(Initialisation.oasisTile_active); } activeTile dti = activeTile.AddComponent <activeTile>(); dti.position = pos; activeTile.AddComponent <MeshCollider>(); activeTile.transform.position = newTile.transform.position; activeTile.transform.localScale = newTile.transform.lossyScale; activeTile.transform.parent = parent.transform; activeTile.transform.name = "actualTile"; Destroy(newTile); }