Ejemplo n.º 1
0
        void ShowLineOfSight(int targetCellIndex)
        {
            if (isSelectingStart || automate)
            {
                return;
            }

            // Destroys markers of a previous LOS
            DestroyLOSMarkers();

            // Compute LOS and get list of cell indices and world positions
            bool isLOS = grid.CellGetLineOfSight(cellStartIndex, targetCellIndex, ref cellIndices, ref worldPositions, CELLS_ALL_NAVIGATABLE, 1, true);

            // Add small dots (spheres) along the LOS
            worldPositions.ForEach((Vector3 obj) => {
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                LOSMarkers.Add(sphere);
                sphere.transform.position   = obj;
                sphere.transform.localScale = Vector3.one * 5f;
                sphere.GetComponent <Renderer> ().material.color = isLOS ? Color.green : Color.red;
            });
        }