Esempio n. 1
0
        /// <summary>
        /// Colors a cell and fades it out during "duration" in seconds.
        /// </summary>
        public void CellFadeOut(int cellIndex, Color color, float duration)
        {
            if (cellIndex < 0 || cellIndex >= cells.Count)
            {
                return;
            }
            CellToggleRegionSurface(cellIndex, true, color, false);
            int cacheIndex = GetCacheIndexForCellRegion(cellIndex);

            if (surfaces.ContainsKey(cacheIndex))
            {
                GameObject cellSurface = surfaces[cacheIndex];
                Material   mat         = Instantiate(cellSurface.GetComponent <Renderer>().sharedMaterial);
                mat.color     = color;
                mat.hideFlags = HideFlags.DontSave;
                cellSurface.GetComponent <Renderer>().sharedMaterial = mat;
                cells[cellIndex].region.customMaterial = mat;
                SurfaceFader.FadeOut(this, cellSurface, cells[cellIndex].region, color, duration);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Colors a territory and fades it out during "duration" in seconds.
        /// </summary>
        public void TerritoryFadeOut(int territoryIndex, Color color, float duration)
        {
            if (_territoryHighlightedIndex == territoryIndex)
            {
                return;
            }
            TerritoryToggleRegionSurface(territoryIndex, true, color);
            int cacheIndex = GetCacheIndexForTerritoryRegion(territoryIndex);

            if (surfaces.ContainsKey(cacheIndex))
            {
                GameObject territorySurface = surfaces[cacheIndex];
                Material   mat = Instantiate(territorySurface.GetComponent <Renderer>().sharedMaterial);
                mat.color     = color;
                mat.hideFlags = HideFlags.DontSave;
                territorySurface.GetComponent <Renderer>().sharedMaterial = mat;
                territories[territoryIndex].region.customMaterial         = mat;
                SurfaceFader.FadeOut(this, territorySurface, territories[territoryIndex].region, color, duration);                 // fader = territorySurface.GetComponent<SurfaceFader>() ?? territorySurface.AddComponent<SurfaceFader>();
            }
        }