private void StopBlinking()
    {
        int sizeOfDictionary = distractionTiles.Count;

        for (int i = 0; i < sizeOfDictionary; i++)
        {
            if (distractionTiles.TryGetValue(i, out List <Hexagon> hexagonList)) // if the key is available, then just procceed
            {
                for (int j = 0; j < hexagonList.Count; j++)
                {
                    HexagonDistraction hexagon = hexagonList[j].GetComponent <HexagonDistraction>();
                    if (hexagonList[j].GetDistractionNumber() == BLINKING_START)
                    {
                        hexagon.SetBlinking(false);
                    }
                }
            }
            else
            {
                sizeOfDictionary++;
            }
        }
    }
Exemple #2
0
    /*
     *  Rename all non-standard tiles, so it's easier to navigate in the hierarchy
     */
    public static void UpdateNames(List<Platform> platforms)
    {
        string name;
        string nameSeparator = " || ";
        int sizeOfNameSeparator =  nameSeparator.Length;

        for(int i = 0; i < platforms.Count; i++)
        {            
            List<Hexagon> platformTiles = platforms[i].GetTilesList();
            // int numberOfCrackedTiles = 0;
            // int numberOfPathTiles = 0;
            // ...
            for(int h = 0; h + sizeOfNameSeparator - 1 < platforms[i].name.Length; h++)
            {
                string namePart = platforms[i].name.Substring(h, sizeOfNameSeparator);
                if(namePart == nameSeparator)
                {
                    string standardName = platforms[i].name.Substring(0, h);
                    platforms[i].name = standardName;
                }
            }          


            for(int j = 0; j < platformTiles.Count; j++)
            {
                Hexagon hexagon = platformTiles[j];
                
                
                for(int k = 0; k + sizeOfNameSeparator - 1 < hexagon.name.Length; k++)
                {
                    string namePart = hexagon.name.Substring(k, sizeOfNameSeparator);
                    if(namePart == nameSeparator)
                    {
                        string standardName = hexagon.name.Substring(0, k);
                        hexagon.name = standardName;
                    }
                }

                name = hexagon.name + nameSeparator;
                
                if(hexagon.IsCrackedTile())
                {
                    int number = hexagon.GetCrackedNumber();
                    name += "Cracked " + number + " -> Time: " + hexagon.GetComponent<HexagonBehaviour>().GetCrackedTileBreaksInTime() + nameSeparator;
                }

                if(hexagon.IsPathTile())
                {
                    int number = hexagon.GetPathNumber();
                    name += "Path " + number + nameSeparator;
                }

                if(hexagon.IsDistractionTile())
                {
                    HexagonDistraction distractionHexagon = hexagon.GetComponent<HexagonDistraction>();
                    name += "Distraction " + distractionHexagon.GetNameOfFunction() + nameSeparator;
                }

                if(hexagon.IsCheckpointTile())
                {
                    int number = hexagon.GetCheckpointNumber();
                    name += "Checkpoint " + number + nameSeparator;
                }

                if(hexagon.IsSpecialTile())
                {
                    HexagonSpecial specialHexagon = hexagon.GetComponent<HexagonSpecial>();
                    name += "Special " + specialHexagon.GetNameOfFunction() + nameSeparator;
                }

                if(hexagon.IsMovingTile())
                {
                    int number = hexagon.GetMovingNumber();
                    name += "Moving " + number + nameSeparator;
                }

                if(hexagon.IsStartingTile())
                {
                    int number = hexagon.GetStartingNumber();
                    name += "Starting " + number + nameSeparator;
                }

                if(hexagon.IsWinningTile())
                {
                    int number = hexagon.GetWinningNumber();
                    name += "Winning " + number + nameSeparator;
                }  

                hexagon.name = name;                
            }

            name = platforms[i].name + nameSeparator + "Count: " + platformTiles.Count + nameSeparator;
            platforms[i].name = name;

            // same here for platforms
        }
    }
Exemple #3
0
    /*
     *  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++;
            }
        }        
    }