/* * Goes through all the hexagons of every platform (which means going through EVERY single hexagon) and add it to the different lists * At the end, give it its individual colour settings */ private void CollectTilesForListsAndColorThem(bool inEditor) { int tilesCounter = 0; for(int i = 0; i < platforms.Count; i++) { List<Hexagon> platformTiles = platforms[i].GetTilesList(); for(int k = 0; k < platformTiles.Count; k++) { Hexagon hexagon = platformTiles[k]; HexagonBehaviour behaviour = hexagon.GetComponent<HexagonBehaviour>(); allTiles[tilesCounter] = hexagon; tileColors[hexagon] = hexagon.GetColor(); bool destroyVFX = true; hexagon.SetStandardTile(true); if(inEditor && hexagon.GetAudioSource()) { DestroyImmediate(hexagon.GetAudioSource()); } if(hexagon.IsPathTile()) { SaveHexagonInList(pathTiles, hexagon, hexagon.GetPathNumber()); hexagon.SetStandardTile(false); hexagon.SetMaterial(pathHexagons); //hexagon.SetAudio("cracked"); //GameObject child = hexagon.transform.GetChild(0).gameObject; //Material material = child.GetComponent<MeshRenderer>().material; //material.EnableKeyword("_NORMALMAP"); //material.SetTexture("_BumpMap", crackedHexagonPattern); //material.SetTextureScale("_MainTex", new Vector2(1.95f, 1.95f)); //aka tiling //material.SetTextureOffset("_MainTex", new Vector2(-0.087f, 0.013f)); // Debug.Log("texture"); } if(hexagon.IsCrackedTile()) { SaveHexagonInList(crackedTiles, hexagon, hexagon.GetCrackedNumber()); hexagon.SetStandardTile(false); hexagon.SetAudio("cracked"); hexagon.SetMaterial(crackedHexagons); } if(hexagon.IsDistractionTile()) { SaveHexagonInList(distractionTiles, hexagon, hexagon.GetDistractionNumber()); hexagon.SetStandardTile(false); hexagon.SetMaterial(distractionHexagons); if(!hexagon.GetComponent<HexagonDistraction>()) hexagon.gameObject.AddComponent<HexagonDistraction>(); hexagon.GetComponent<HexagonDistraction>().GetStarted(hexagon.GetDistractionNumber(), platforms[i].GetAllPlatformTiles(), allTiles, tileColors, distractionTiles, hexagon); } else { if(inEditor) { HexagonDistraction distractionScript = hexagon.GetComponent<HexagonDistraction>(); if(distractionScript) { DestroyImmediate(distractionScript); } } } if(hexagon.IsCheckpointTile()) { SaveHexagonInList(checkpointTiles, hexagon, hexagon.GetCheckpointNumber()); hexagon.SetStandardTile(false); hexagon.SetMaterial(checkpointHexagons); } if(hexagon.IsSpecialTile()) { SaveHexagonInList(specialTiles, hexagon, hexagon.GetSpecialNumber()); hexagon.SetStandardTile(false); switch (hexagon.GetSpecialNumber()) { case 0: { hexagon.SetMaterial(teleporterHexagons); break; } case 1: { hexagon.SetMaterial(velocityHexagons); break; } case 2: { hexagon.SetMaterial(jumpPadHexagons); break; } case 3: { hexagon.SetMaterial(loosingHexagons); break; } defaut: { hexagon.SetMaterial(standardHexagons); break; } } if(!hexagon.GetComponent<HexagonSpecial>()) hexagon.gameObject.AddComponent<HexagonSpecial>(); HexagonSpecial specialScript = hexagon.GetComponent<HexagonSpecial>(); specialScript.GetStarted(specialTiles, this, hexagon, inEditor); destroyVFX = !specialScript.HasVFX(); } else { if(inEditor) { HexagonSpecial specialScript = hexagon.GetComponent<HexagonSpecial>(); if(specialScript) { DestroyImmediate(specialScript); } } } if(hexagon.IsMovingTile()) { SaveHexagonInList(movingTiles, hexagon, hexagon.GetMovingNumber()); hexagon.SetStandardTile(false); hexagon.SetMaterial(movingHexagons); if(!hexagon.GetComponent<HexagonMovingTiles>()) hexagon.gameObject.AddComponent<HexagonMovingTiles>(); } else { if(inEditor) { HexagonMovingTiles movingTilesScript = hexagon.GetComponent<HexagonMovingTiles>(); if(movingTilesScript) { DestroyImmediate(movingTilesScript); } } } if(hexagon.IsStartingTile()) { SaveHexagonInList(startingTiles, hexagon, hexagon.GetStartingNumber()); hexagon.SetStandardTile(false); hexagon.SetMaterial(startingHexagons); hexagon.SetVisualEffect("StartingVFX", inEditor); destroyVFX = false; } if(hexagon.IsWinningTile()) { SaveHexagonInList(winningTiles, hexagon, hexagon.GetWinningNumber()); hexagon.SetStandardTile(false); hexagon.SetMaterial(winningHexagons); hexagon.SetVisualEffect("WinningVFX", inEditor); destroyVFX = false; } if(hexagon.IsStandardTile()) { standardTiles.Add(hexagon); hexagon.SetMaterial(standardHexagons); if(inEditor && hexagon.GetComponent<AudioSource>()) { DestroyImmediate(hexagon.GetComponent<AudioSource>()); } } if(inEditor && hexagon.GetComponent<AudioSource>()) { if(hexagon.GetComponent<AudioSource>().clip == null) { DestroyImmediate(hexagon.GetComponent<AudioSource>()); } } if(destroyVFX && hexagon.GetVisualEffect()) hexagon.DestroyVisualEffect(inEditor); Color[] getAllTouchingColors = this.GetComponent<TileColorsTouching>().GiveColorSet(); // get all Colors when the ball for touching and leaving a hexagon behaviour.SetColors(getAllTouchingColors); // give current hexagon the set, in order to get its individual color settings tilesCounter++; } } }