Esempio n. 1
0
        public MovingGlowCells GenerateBaseCells(float radius, int mapXSize, int baseIndex)
        {
            var result   = new MovingGlowCells(radius, mapXSize);
            int intRad   = Mathf.RoundToInt(radius * 100);
            int maxCount = intRad / 100;

            for (int x = 0; x <= maxCount; x++)
            {
                int distAlongDiag = baseDist + (x * diagDist);
                for (int z = x; z <= maxCount; z++)
                {
                    int sumDist = distAlongDiag + (strDist * (z - x));

                    if (sumDist <= intRad)
                    {
                        if (x == 0 && z == 0)
                        {
                            result.AddNew(baseIndex, sumDist);
                        }
                        else if (x == 0)
                        {
                            result.AddNew((z * mapXSize) + baseIndex, sumDist);
                            result.AddNew(z + baseIndex, sumDist);
                            result.AddNew((-z * mapXSize) + baseIndex, sumDist);
                            result.AddNew(-z + baseIndex, sumDist);
                        }
                        else if (x == z)
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                result.AddNew((rotT[i, 0] * x) + (rotT[i, 1] * z * mapXSize) + baseIndex, sumDist);
                            }
                        }
                        else
                        {
                            for (int i = 0; i < 4; i++)
                            {
                                result.AddNew((rotT[i, 0] * x) + (rotT[i, 1] * z * mapXSize) + baseIndex, sumDist);
                                result.AddNew((rotT[i, 0] * z) + (rotT[i, 1] * x * mapXSize) + baseIndex, sumDist);
                            }
                        }
                    }
                }
            }

            result.Sort();

            return(result);
        }
Esempio n. 2
0
        public void InitialiseGlow()
        {
            edifices = map.edificeGrid.InnerArray;

            int intRad = Mathf.RoundToInt(glowRadius);

            CellIndices = map.cellIndices;

            int locIndex = CellIndices.CellToIndex(position);

            movingCells = GenerateBaseCells(glowRadius, mapSizeX, locIndex);

            movingCells.Sort();
            SetUpGlowCells();
            Log.Message($"movingCells = {movingCells.ToStringColour()}");
            //map.mapDrawer.MapMeshDirty(position, MapMeshFlag.GroundGlow);
            mesh = DynamicLightingOverlay.MakeNewMesh(movingCells, locIndex, intRad, glowColor, offset: out offset);

            //mesh = DynamicLightingOverlay.MakeTestCircle(out offset, mat);
        }