예제 #1
0
    public static IEnumerable <Vector2i> GetAttackablePoints(Map map, Vector2i start, int minRange, int maxRange)
    {
        HashSet <Vector2i> visible = new HashSet <Vector2i>();

        ShadowCaster.ComputeFieldOfViewWithShadowCasting(start.X, start.Y, maxRange,
                                                         (x, y) => !(x == start.X && y == start.Y) && map.ContainsActor(new Vector2i(x, y)),
                                                         (x, y) => visible.Add(new Vector2i(x, y)),
                                                         (x, y, z) => x + y <= z);

        for (int ii = minRange; ii <= maxRange; ii++)
        {
            foreach (var point in GetPointsAtDistance(start, ii))
            {
                if (map.Contains(point) && visible.Contains(point))
                {
                    Actor inhabitant;
                    if (map.TryGetActor(point, out inhabitant) && !inhabitant.IsEnemy)
                    {
                        continue;
                    }

                    yield return(point);
                }
            }
        }
    }
예제 #2
0
        public void Run()
        {
            foreach (var i in Filter !)
            {
                ref var entity = ref Filter.Entities[i];

                var viewshed = entity.Get <Viewshed>();
                var position = entity.Get <Position>();

                if (!viewshed.Dirty)
                {
                    continue;
                }

                var mapMemory = entity.Get <MapMemory>();

                viewshed.Dirty = false;
                viewshed.Visible.Clear();

                ShadowCaster.ComputeFieldOfViewWithShadowCasting(position.Coordinate.X, position.Coordinate.Y, viewshed.Range, (x, y) => {
                    var c = new Coordinate(x, y, position.Coordinate.Z);
                    return(!Game.Map.Terrain.TryGetValue(c, out var terrain) || terrain.IsOpaque);
                }, (x, y) => {
                    var c = new Coordinate(x, y, position.Coordinate.Z);
                    mapMemory?.Remembered.Add(c);
                    viewshed.Visible.Add(c);
                });
            }
예제 #3
0
            private PreviewModel CreatePreviewModel(VertexPositionNormalTexture[] vertices, ushort[] indices)
            {
                AssetDatabase lfd = new LooseFileDatabase(Path.Combine(AppContext.BaseDirectory, "Assets"));
                VertexBuffer  vb  = _rc.ResourceFactory.CreateVertexBuffer(vertices.Length * VertexPositionNormalTexture.SizeInBytes, false);

                vb.SetVertexData(
                    vertices,
                    new VertexDescriptor(
                        VertexPositionNormalTexture.SizeInBytes,
                        VertexPositionNormalTexture.ElementCount,
                        IntPtr.Zero));

                IndexBuffer ib = _rc.ResourceFactory.CreateIndexBuffer(indices.Length * sizeof(ushort), false);

                ib.SetIndices(indices);

                Material shadowmapMaterial = ShadowCaster.CreateShadowPassMaterial(_rc.ResourceFactory);
                Material regularMaterial   = ShadowCaster.CreateRegularPassMaterial(_rc.ResourceFactory);

                var deviceTexture  = lfd.LoadAsset <ImageSharpMipmapChain>("Textures/CubeTexture.png").CreateDeviceTexture(_rc.ResourceFactory);
                var textureBinding = _rc.ResourceFactory.CreateShaderTextureBinding(deviceTexture);

                return(new PreviewModel(
                           vb,
                           ib,
                           indices.Length,
                           regularMaterial,
                           shadowmapMaterial,
                           _rc.ResourceFactory.CreateConstantBuffer(ShaderConstantType.Matrix4x4),
                           new DynamicDataProvider <Matrix4x4>(Matrix4x4.Identity),
                           _rc.ResourceFactory.CreateConstantBuffer(ShaderConstantType.Matrix4x4),
                           SceneBuffers,
                           textureBinding));
            }
예제 #4
0
    private void SetNewMeshInternal(MeshData newData)
    {
        var mesh = new Mesh();

        mesh.vertices  = newData.verts;
        mesh.uv        = newData.uvs;
        mesh.triangles = newData.triangles;
        gameObject.GetComponent <MeshFilter>().mesh = mesh;
        var timer = System.Diagnostics.Stopwatch.StartNew();
        PolygonCollider2D polygonCollider2D = GetComponent <PolygonCollider2D>();

        polygonCollider2D.pathCount = newData.paths.Count;
        StartCoroutine(DeleteAfterFrame(gameObject.GetComponentsInChildren <Transform>()));
        for (int i = 0; i < newData.paths.Count; i++)
        {
            polygonCollider2D.SetPath(i, newData.paths[i]);
            ShadowCaster.CreateShadowCaster(i, transform);
        }

        // update AStar map
        if (GridAStar.singleton)// && needToRecalcNavGrid)
        {
            GridAStar.singleton.RegenerateSection(transform.position, (Vector2)transform.position + new Vector2(data.densities.GetLength(0) * edgeLength, data.densities.GetLength(1) * edgeLength));
        }
    }
예제 #5
0
 void Start()
 {
     MaxHealthPoint = 100;
     healthPoint    = 100;
     attackPoint    = 1000;
     ShadowCaster.ShadowCast(localXPos, localYPos, 8);
     TurnManager.Instance.PlayerUpdateLogicAndCount += UpdatePlayerLogic;
 }
예제 #6
0
    ///////////////////////////////////////////////////////////////////////////////

    protected virtual void Start()
    {
        _transform    = transform;
        _sprite       = _transform.Find("Sprite");
        _sortingOrder = _sprite.GetComponent <SpriteRenderer>().sortingOrder;
        _shadow       = GetComponent <ShadowCaster>();

        _shadow.Setup(_sprite, _sortingOrder - 1);
    }
        private void init()
        {
            // Reveal the starting position if home map and no pawns (landing).
            if (map.IsPlayerHome && map.mapPawns.ColonistsSpawnedCount == 0)
            {
                IntVec3 playerStartSpot = MapGenerator.PlayerStartSpot;
                ShadowCaster.computeFieldOfViewWithShadowCasting(playerStartSpot.x, playerStartSpot.z, Mathf.RoundToInt(CompFieldOfViewWatcher.NON_MECH_DEFAULT_RANGE),
                                                                 viewBlockerCells, map.Size.x, map.Size.z,
                                                                 false, null, null, null, // Directly updating known cells. No need to call incrementSeen.
                                                                 knownCells, 0, 0, mapSizeX,
                                                                 null, 0, 0, 0, 0, 0);

                for (int i = 0; i < mapCellLength; i++)
                {
                    if (knownCells[i])
                    {
                        IntVec3 cell = CellIndicesUtility.IndexToCell(i, mapSizeX);
                        foreach (Thing t in map.thingGrid.ThingsListAtFast(cell))
                        {
                            CompMainComponent compMain = (CompMainComponent)t.TryGetComp(CompMainComponent.COMP_DEF);
                            if (compMain != null && compMain.compHideFromPlayer != null)
                            {
                                compMain.compHideFromPlayer.forceSeen();
                            }
                        }
                    }
                }
            }

            // Update all thing FoV and visibility.
            foreach (Thing thing in map.listerThings.AllThings)
            {
                if (thing.Spawned)
                {
                    CompMainComponent compMain = (CompMainComponent)thing.TryGetComp(CompMainComponent.COMP_DEF);
                    if (compMain != null)
                    {
                        if (compMain.compComponentsPositionTracker != null)
                        {
                            compMain.compComponentsPositionTracker.updatePosition();
                        }
                        if (compMain.compFieldOfViewWatcher != null)
                        {
                            compMain.compFieldOfViewWatcher.updateFoV();
                        }
                        if (compMain.compHideFromPlayer != null)
                        {
                            compMain.compHideFromPlayer.updateVisibility(true);
                        }
                    }
                }
            }

            // Redraw everything.
            mapDrawer.RegenerateEverythingNow();
        }
예제 #8
0
    // =====================================================
    // Vision
    // =====================================================

    public override void UpdateVision(int px, int py)
    {
        // TODO: We need to implement a 'Permissive Field of View' algorithm instead,
        // to avoid dark corners and get a better roguelike feeling

        // get lit array from shadowcaster class
        bool[,] lit = new bool[grid.width, grid.height];
        int radius = stats.visionRadius;

        ShadowCaster.ComputeFieldOfViewWithShadowCasting(
            px, py, radius,
            (x1, y1) => grid.TileIsOpaque(x1, y1),
            (x2, y2) => {
            if (grid.IsInsideBounds(x2, y2))
            {
                lit[x2, y2] = true;
            }
            else
            {
                //Debug.LogError ("ShadowCaster is out of bounds -> " + x2 + "," + y2);
            }
        });

        // iterate grid tiles and render them
        for (int y = 0; y < grid.height; y++)
        {
            for (int x = 0; x < grid.width; x++)
            {
                // render tiles
                Tile tile = grid.GetTile(x, y);
                if (tile != null)
                {
                    // render tiles (and record fov info)
                    float distance    = Mathf.Round(Vector2.Distance(new Vector2(px, py), new Vector2(x, y)) * 10) / 10;
                    float shadowValue = -0.1f + Mathf.Min((distance / radius) * 0.6f, 0.6f);

                    tile.SetVisibility(tile, lit[x, y], shadowValue);
                    tile.SetFovInfo(Game.instance.turn, distance);

                    // render entities
                    Entity entity = grid.GetEntity(x, y);
                    if (entity != null)
                    {
                        entity.SetVisibility(tile, lit[x, y], shadowValue);
                    }

                    // render creatures
                    Creature creature = grid.GetCreature(x, y);
                    if (creature != null)
                    {
                        creature.SetVisibility(tile, lit[x, y], shadowValue);
                    }
                }
            }
        }
    }
예제 #9
0
    public void PlayerMove(int TargetXPos, int TargetYPos)
    {
        RemoveMovalbeTile();
        ChangeDirection(TargetXPos);
        SetPositionData(TargetXPos, TargetYPos);
        SetMovableTile();
        ShadowCaster.ShadowCast(localXPos, localYPos, 8);

        StartCoroutine(MovePosition(TargetXPos, TargetYPos));
    }
예제 #10
0
        public void AddShadowCaster(List <ShadowLayer> shadows, Bounds shadowBounds,
                                    int physicsStartX, int physicsEndX, Position position, Position shadowOffset, bool flipX,
                                    Color color, int layer)
        {
            // NOTE: Right now we take physicsStartX/physicsEndX for character physics
            //       If we start doing shadows with heightmap physics, we'll need to take a heightmap as well

            StartEnd xBounds = flipX ?
                               new StartEnd {
                start = shadowBounds.startX, end = shadowBounds.endX
            } :
            new StartEnd {
                start = -(shadowBounds.endX - 1), end = -(shadowBounds.startX - 1)
            };

            xBounds.start += position.X + shadowOffset.X;
            xBounds.end   += position.X + shadowOffset.X;

            ShadowCaster shadowCaster = new ShadowCaster
            {
                shadows = shadows,

                physicsStartX = physicsStartX,
                physicsEndX   = physicsEndX,

                position     = position,
                shadowOffset = shadowOffset,
                flipX        = flipX,

                color = color,
            };

            if (flipX)
            {
                shadowCaster.shadowOffset.X = -shadowCaster.shadowOffset.X;
            }


            // Determine insertion point:
            int i;

            for (i = shadowLayers.Count; i > 0; --i)
            {
                if (shadowLayers[i - 1] <= layer)
                {
                    break;
                }
            }

            shadowLayers.Insert(i, layer);
            shadowCasterXBounds.Insert(i, xBounds);
            shadowCasters.Insert(i, shadowCaster);
        }
예제 #11
0
        public CShadower(SPGame mGame, CBody mCBody, bool mIsDrawn, Color mColor, int mMultiplier = 35)
        {
            _game         = mGame;
            _cBody        = mCBody;
            _isDrawn      = mIsDrawn;
            _color        = mColor;
            _vertexArrays = new List <Vertex[]>();
            ShadowCaster  = new ShadowCaster(_cBody.Position, mMultiplier);

            if (_isDrawn)
            {
                _game.AddDrawAction(Draw, -10);
            }
        }
예제 #12
0
    public static IEnumerable <Vector2i> GetTargetablePoints(
        Map map,
        Actor attacker,
        int minRange,
        int maxRange,
        bool targetsEnemies,
        bool targetsAllies)
    {
        var visible = new HashSet <Vector2i>();
        var start   = attacker.GridPosition;

        ShadowCaster.ComputeFieldOfViewWithShadowCasting(start.X, start.Y, maxRange,
                                                         (x, y) =>
                                                         map.Contains(x, y) &&
                                                         !(x == start.X && y == start.Y) &&
                                                         (map.ContainsActorAtLocation(x, y) ||
                                                          map[x, y].Properties.BlocksVision),
                                                         (x, y) => visible.Add(new Vector2i(x, y)),
                                                         (x, y, z) => x + y <= z);

        for (int ii = minRange; ii <= maxRange; ii++)
        {
            foreach (var point in GetPointsAtDistance(start, ii))
            {
                if (map.Contains(point) && visible.Contains(point))
                {
                    Actor inhabitant;
                    if (map.TryGetActor(point, out inhabitant) && (inhabitant.Team == attacker.Team))
                    {
                        bool isAlly = inhabitant.Team == attacker.Team;
                        if (isAlly && targetsAllies || !isAlly && targetsEnemies)
                        {
                            yield return(point);
                        }
                    }
                    else
                    {
                        yield return(point);
                    }
                }
            }
        }
    }
예제 #13
0
    private int[] FindPlayer()
    {
        bool[] EnemySightFlag = ShadowCaster.SetShadowFlag(localXPos, localYPos, 8);
        int[]  Destination    = new int[2];
        for (int i = 0; i < EnemySightFlag.Length; i++)
        {
            if (EnemySightFlag[i])
            {
                if ((MapManager.Instance.GetTileState(i) & eTileState.Player) == eTileState.Player)
                {
                    DDPivot = -1;
                    int TempX;
                    int TempY;
                    MapManager.Instance.ConvertIndexTo2D(i, out TempX, out TempY);
                    Destination[0] = TempX;
                    Destination[1] = TempY;
                    return(Destination);
                }
            }
        }
        Destination[0] = -1;//return Destination[0] = -1 if Can't Find Player

        return(Destination);
    }
예제 #14
0
    void Update()
    {
        RaycastHit2D[] rch = Physics2D.CircleCastAll(transform.position, radius, Vector2.right);

        foreach (RaycastHit2D t in rch)
        {
            rchList.Add(t);
        }


        for (int i = 0; i < rchList.Count; i++)
        {
            //check for presence of ShadowCaster
            ShadowCaster sc = rchList[i].collider.GetComponent <ShadowCaster>();


            if (sc != null)
            {
                caster.Add(rchList[i].collider.GetComponent <ShadowCaster>());

                caster[i].MyShadow(gameObject);
            }
        }
    }
        private void init()
        {
            // Retrieve map sections and store in a linear array.
            Section[,] mapDrawerSections = (Section[, ])Traverse.Create(mapDrawer).Field("sections").GetValue();
            sectionsSizeX = mapDrawerSections.GetLength(0);
            sectionsSizeY = mapDrawerSections.GetLength(1);

            sections = new Section[sectionsSizeX * sectionsSizeY];
            for (int y = 0; y < sectionsSizeY; y++)
            {
                for (int x = 0; x < sectionsSizeX; x++)
                {
                    sections[y * sectionsSizeX + x] = mapDrawerSections[x, y];
                }
            }

            // Initialize mining designators (add notifications intercepted by detours aren't fired on load).
            List <Designation> designations = map.designationManager.allDesignations;

            for (int i = 0; i < designations.Count; i++)
            {
                Designation des = designations[i];
                if (des.def == DesignationDefOf.Mine && !des.target.HasThing)
                {
                    registerMineDesignation(des);
                }
            }

            // Reveal the starting position if home map and no pawns (landing).
            if (map.IsPlayerHome && map.mapPawns.ColonistsSpawnedCount == 0)
            {
                IntVec3 playerStartSpot = MapGenerator.PlayerStartSpot;
                ShadowCaster.computeFieldOfViewWithShadowCasting(playerStartSpot.x, playerStartSpot.z, Mathf.RoundToInt(CompFieldOfViewWatcher.NON_MECH_DEFAULT_RANGE),
                                                                 viewBlockerCells, map.Size.x, map.Size.z,
                                                                 false, null, null, null, // Directly updating known cells. No need to call incrementSeen.
                                                                 knownCells, 0, 0, mapSizeX,
                                                                 null, 0, 0, 0, 0, 0);

                for (int i = 0; i < mapCellLength; i++)
                {
                    if (knownCells[i])
                    {
                        IntVec3 cell = CellIndicesUtility.IndexToCell(i, mapSizeX);
                        foreach (Thing t in map.thingGrid.ThingsListAtFast(cell))
                        {
                            CompMainComponent compMain = (CompMainComponent)t.TryGetComp(CompMainComponent.COMP_DEF);
                            if (compMain != null && compMain.compHideFromPlayer != null)
                            {
                                compMain.compHideFromPlayer.forceSeen();
                            }
                        }
                    }
                }
            }

            // Update all thing FoV and visibility.
            foreach (Thing thing in map.listerThings.AllThings)
            {
                if (thing.Spawned)
                {
                    CompMainComponent compMain = (CompMainComponent)thing.TryGetComp(CompMainComponent.COMP_DEF);
                    if (compMain != null)
                    {
                        if (compMain.compComponentsPositionTracker != null)
                        {
                            compMain.compComponentsPositionTracker.updatePosition();
                        }
                        if (compMain.compFieldOfViewWatcher != null)
                        {
                            compMain.compFieldOfViewWatcher.updateFoV();
                        }
                        if (compMain.compHideFromPlayer != null)
                        {
                            compMain.compHideFromPlayer.updateVisibility(true);
                        }
                    }
                }
            }

            // Redraw everything.
            mapDrawer.RegenerateEverythingNow();
        }
예제 #16
0
        private static bool fovLineOfSight(IntVec3 sourceSq, IntVec3 targetLoc, Thing thing)
        {
            // If the thing is mannable, then use the manning pawn to perform the calculation.
            CompMannable compMannable = thing.TryGetComp <CompMannable>();

            if (compMannable != null)
            {
                thing = compMannable.ManningPawn;
                // Apply interaction cell offset.
                sourceSq += (thing.Position - thing.InteractionCell);
            }

            // If not a pawn, then doesn't need a fov calculation.
            if (!(thing is Pawn))
            {
                return(true);
            }

            MapComponentSeenFog    seenFog  = thing.Map.getMapComponentSeenFog();
            CompMainComponent      compMain = (CompMainComponent)thing.TryGetComp(CompMainComponent.COMP_DEF);
            CompFieldOfViewWatcher compFoV  = compMain.compFieldOfViewWatcher;
            // If requires moving, calculate only the base sight.
            int sightRange = Mathf.RoundToInt(compFoV.calcPawnSightRange(sourceSq, true, !thing.Position.AdjacentToCardinal(sourceSq)));

            if (!sourceSq.InHorDistOf(targetLoc, sightRange))
            {
                // If out of sightRange.
                return(false);
            }


            // Limit to needed octant.
            IntVec3 dir = targetLoc - sourceSq;

            byte octant;

            if (dir.x >= 0)
            {
                if (dir.z >= 0)
                {
                    if (dir.x >= dir.z)
                    {
                        octant = 0;
                    }
                    else
                    {
                        octant = 1;
                    }
                }
                else
                {
                    if (dir.x >= -dir.z)
                    {
                        octant = 7;
                    }
                    else
                    {
                        octant = 6;
                    }
                }
            }
            else
            {
                if (dir.z >= 0)
                {
                    if (-dir.x >= dir.z)
                    {
                        octant = 3;
                    }
                    else
                    {
                        octant = 2;
                    }
                }
                else
                {
                    if (-dir.x >= -dir.z)
                    {
                        octant = 4;
                    }
                    else
                    {
                        octant = 5;
                    }
                }
            }

            Map map = thing.Map;

            bool[] targetFound = new bool[1];
            ShadowCaster.computeFieldOfViewWithShadowCasting(sourceSq.x, sourceSq.z, sightRange,
                                                             seenFog.viewBlockerCells, map.Size.x, map.Size.z,
                                                             false, null, null, null,
                                                             targetFound, 0, 0, 0,
                                                             null, 0, 0, 0, 0, 0,
                                                             octant, targetLoc.x, targetLoc.z);
            return(targetFound[0]);
        }
예제 #17
0
파일: Scene.cs 프로젝트: randomcrab/SE
        public void GenerateShadows()
        {
            MapShadows.Clear();
            shadowTemplates.Clear();
            for (int x = 0; x < TilesCount.X; x++)
            {
                for (int y = 0; y < TilesCount.Y; y++)
                {
                    MapData[x][y].ShadowTemplates.Clear();
                    for (int z = 0; z < MapData[x][y].Gos.Count; z++)
                    {
                        GameObject go = MapData[x][y].Gos[z];
                        for (int s = 0; s < go.Sprites.Count; s++)
                        {
                            SpriteBase spr = go.Sprites.Array[s];
                            if (!(spr is ILit) || ((ILit)spr).ShadowType != ShadowCasterType.Map)
                            {
                                continue;
                            }

                            Sprite    sprite       = (Sprite)go.Sprites.Array[s];
                            Rectangle shadowBounds = sprite.Shadow.Bounds;
                            MapData[x][y].ShadowTemplates.Add(new TileSpot.ShadowTemplate(new Point((int)go.Bounds.X, (int)go.Bounds.Y), shadowBounds));
                        }
                    }
                }
            }

            for (int x = 0; x < TilesCount.X; x++)
            {
                for (int y = 0; y < TilesCount.Y; y++)
                {
                    for (int z = 0; z < MapData[x][y].Gos.Count; z++)
                    {
                        for (int s = 0; s < MapData[x][y].Gos[z].Sprites.Count; s++)
                        {
                            if (((ILit)MapData[x][y].Gos[z].Sprites.Array[s]).ShadowType == ShadowCasterType.Map)
                            {
                                GenerateShadowsIteration(x, y, z, s);
                            }
                        }
                    }
                }
            }

            for (int x = 0; x < TilesCount.X; x++)
            {
                for (int y = 0; y < TilesCount.Y; y++)
                {
                    for (int i = 0; i < MapData[x][y].ShadowTemplates.Count; i++)
                    {
                        if (!shadowTemplates.Contains(MapData[x][y].ShadowTemplates[i]))
                        {
                            shadowTemplates.Add(MapData[x][y].ShadowTemplates[i]);
                        }
                    }
                }
            }

            for (int i = 0; i < shadowTemplates.Count; i++)
            {
                if (shadowTemplates.Array[i].Merged)
                {
                    continue;
                }

                ShadowCaster s = new ShadowCaster {
                    Bounds   = new Rectangle(0, 0, shadowTemplates.Array[i].MaxX, shadowTemplates.Array[i].MaxY),
                    Position = new Vector2(shadowTemplates.Array[i].MinX, shadowTemplates.Array[i].MinY)
                };
                s.CalculateHull(true);
                MapShadows.Add(s);
            }
        }
예제 #18
0
        public virtual bool[] UpdateFieldOfView(actors.Character c)
        {
            var cx = c.pos % Width;
            var cy = c.pos / Width;

            bool sighted = c.Buff <Blindness>() == null && c.Buff <Shadows>() == null && c.IsAlive;

            if (sighted)
            {
                ShadowCaster.CastShadow(cx, cy, fieldOfView, c.viewDistance);
            }
            else
            {
                Arrays.Fill(fieldOfView, false);
            }

            var sense = 1;

            if (c.IsAlive)
            {
                sense = c.Buffs <MindVision>().Select(b => b.Distance).Concat(new[] { sense }).Max();
            }

            if ((sighted && sense > 1) || !sighted)
            {
                var ax = Math.Max(0, cx - sense);
                var bx = Math.Min(cx + sense, Width - 1);
                var ay = Math.Max(0, cy - sense);
                var by = Math.Min(cy + sense, Height - 1);

                var len = bx - ax + 1;
                var pos = ax + ay * Width;
                for (var y = ay; y <= by; y++, pos += Width)
                {
                    Arrays.Fill(fieldOfView, pos, pos + len, true);
                }

                for (var i = 0; i < Length; i++)
                {
                    fieldOfView[i] &= discoverable[i];
                }
            }

            if (!c.IsAlive)
            {
                return(fieldOfView);
            }

            if (c.Buff <MindVision>() != null)
            {
                foreach (var mob in mobs)
                {
                    var p = mob.pos;
                    fieldOfView[p]             = true;
                    fieldOfView[p + 1]         = true;
                    fieldOfView[p - 1]         = true;
                    fieldOfView[p + Width + 1] = true;
                    fieldOfView[p + Width - 1] = true;
                    fieldOfView[p - Width + 1] = true;
                    fieldOfView[p - Width - 1] = true;
                    fieldOfView[p + Width]     = true;
                    fieldOfView[p - Width]     = true;
                }
            }
            else
            if (c == Dungeon.Hero && ((Hero)c).heroClass == HeroClass.Huntress)
            {
                foreach (var mob in mobs)
                {
                    var p = mob.pos;
                    if (Distance(c.pos, p) != 2)
                    {
                        continue;
                    }

                    fieldOfView[p]             = true;
                    fieldOfView[p + 1]         = true;
                    fieldOfView[p - 1]         = true;
                    fieldOfView[p + Width + 1] = true;
                    fieldOfView[p + Width - 1] = true;
                    fieldOfView[p - Width + 1] = true;
                    fieldOfView[p - Width - 1] = true;
                    fieldOfView[p + Width]     = true;
                    fieldOfView[p - Width]     = true;
                }
            }

            if (c.Buff <Awareness>() != null)
            {
                foreach (var heap in heaps.Values)
                {
                    var p = heap.Pos;
                    fieldOfView[p]             = true;
                    fieldOfView[p + 1]         = true;
                    fieldOfView[p - 1]         = true;
                    fieldOfView[p + Width + 1] = true;
                    fieldOfView[p + Width - 1] = true;
                    fieldOfView[p - Width + 1] = true;
                    fieldOfView[p - Width - 1] = true;
                    fieldOfView[p + Width]     = true;
                    fieldOfView[p - Width]     = true;
                }
            }

            return(fieldOfView);
        }
예제 #19
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ShadowCaster obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }