当前位置: 首页>>代码示例>>C#>>正文


C# Map.GetTile方法代码示例

本文整理汇总了C#中Map.GetTile方法的典型用法代码示例。如果您正苦于以下问题:C# Map.GetTile方法的具体用法?C# Map.GetTile怎么用?C# Map.GetTile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map.GetTile方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SquareAtCoordinate_OutOfBounds_ReturnsNull

        public void SquareAtCoordinate_OutOfBounds_ReturnsNull()
        {
            // Arrange
            var squares = new List<List<ITile>> { new List<ITile> { new Wrench() } };
            var map = new Map { Squares = squares };

            // Act
            ITile tile = map.GetTile(new Coordinate {X = 1, Y = 0});

            // Assert
            Assert.IsNull(tile);
        }
开发者ID:damirault,项目名称:roborally-wirk,代码行数:12,代码来源:MapUnitTests.cs

示例2: StampCommand

 public StampCommand(Map map, List<Tile> selectionList, ushort selectedTileId, ImageSource[] images)
 {
     _newList = new List<Tile>(selectionList.Count);
     _newList.AddRange(selectionList);
     _map = map;
     _oldList = new List<Tile>();
     _images = images;
     _tileId = selectedTileId;
     foreach (Tile t in _newList)
     {
         _oldList.Add(map.GetTile(t.Position));
     }
     if(_newList.Count == 0)
     {
         _newList.Add(new Tile(null, EditorWindow.MousePosition));
     }
 }
开发者ID:eivhyl,项目名称:PG5200_Innlevering2,代码行数:17,代码来源:StampCommand.cs

示例3: GetBestSetting

            /// <summary>
            /// Attempts to get the best setting for this target. Also sets CurrentSettingIndex. Returns null if unsuccessful.
            /// </summary>
            /// <param name="creaturesOnScreen">A collection of creatures visible on screen.</param>
            /// <param name="playersOnScreen">A collection of players visible on screen.</param>
            /// <param name="tileCollection">A collection of tiles visible on screen.</param>
            /// <param name="setCreature">Whether to set this target's Creature.</param>
            /// <returns></returns>
            public Target.Setting GetBestSetting(IEnumerable<Objects.Creature> creaturesOnScreen,
                IEnumerable<Objects.Creature> playersOnScreen, Map.TileCollection tileCollection,
                bool setCreature)
            {
                // check if there are any settings to use
                bool found = false;
                foreach (Target.Setting s in this.GetSettings())
                {
                    if (s.UseThisSetting)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found) return null;

                // set up the player's tile and other variables
                Map.Tile playerTile = tileCollection.GetTile(count: this.Parent.Client.Player.ID);
                if (playerTile == null) return null;
                List<Objects.Creature> creatures = new List<Objects.Creature>(),
                    players = new List<Objects.Creature>();
                foreach (Objects.Creature c in creaturesOnScreen)
                {
                    if (c.Name.ToLower() == this.Name.ToLower()) creatures.Add(c);
                }
                foreach (Objects.Creature p in playersOnScreen.ToArray())
                {
                    if (p.ID != this.Parent.Client.Player.ID) players.Add(p);
                }

                // calculate best setting
                int bestCount = 0, bestIndex = 0, index = 0;
                Target.Setting bestSetting = null;
                Objects.Creature bestCreature = null;
                foreach (Target.Setting setting in this.GetSettings())
                {
                    if (!setting.UseThisSetting) continue;
                    int count = 0,
                        bestCreatureDistance = setting.Range + 1;
                    Objects.Creature tempCreature = null;
                    foreach (Objects.Creature c in creatures)
                    {
                        if (!c.IsVisible) continue;
                        Map.Tile creatureTile = tileCollection.GetTile(count: c.ID);
                        if (creatureTile == null) continue;
                        if (!playerTile.WorldLocation.IsOnScreen(creatureTile.WorldLocation)) continue;
                        if (this.Parent.CurrentSettings.FriendlyMode && players.Count > 0 && !c.HasAttackedMeRecently(4000)) continue;
                        if (setting.MustBeShootable && !c.IsShootable(tileCollection)) continue;
                        var pfNodes = c.GetTilesToCreature(tileCollection, this.Parent.PathFinder)
                            .ToList<Objects.PathFinder.Node>();
                        if (setting.MustBeReachable && pfNodes.Count == 0) continue;
                        if ((pfNodes.Count > 0 ? pfNodes.Count : playerTile.WorldLocation.DistanceTo(creatureTile.WorldLocation)) > setting.Range) continue;
                        count++;

                        if (setCreature)
                        {
                            int distance = pfNodes.Count > 0 ?
                                pfNodes.Count :
                                (int)playerTile.WorldLocation.DistanceTo(creatureTile.WorldLocation);
                            if (distance < bestCreatureDistance)
                            {
                                bestCreatureDistance = distance;
                                tempCreature = c;
                            }
                        }
                    }

                    if (count == 0 || count < setting.Count) continue;
                    if (count > bestCount)
                    {
                        bestCount = count;
                        bestSetting = setting;
                        bestIndex = index;
                        bestCreature = tempCreature;
                    }

                    index++;
                }
                this.CurrentSettingIndex = bestSetting != null ? bestIndex : -1;
                if (bestSetting != null && bestCreature != null) this.Creature = bestCreature;
                return bestSetting;
            }
开发者ID:KyLuaa,项目名称:bot,代码行数:90,代码来源:Cavebot.Target.cs

示例4: GetBestLocation

            /// <summary>
            /// Attempts to get the best location to move to. Returns Objects.Location.Invalid if unsuccessful.
            /// </summary>
            /// <param name="setting">The setting to use.</param>
            /// <param name="tileCollection">The tiles that are visible on screen.</param>
            /// <param name="creaturesOnScreen">The creatures that are visible on screen.</param>
            /// <returns></returns>
            public Objects.Location GetBestLocation(Target.Setting setting, Map.TileCollection tileCollection,
                IEnumerable<Objects.Creature> creaturesOnScreen, Stack<Objects.Location> backtrackedLocations = null)
            {
                if (this.Creature == null) return null;
                Map.Tile playerTile = tileCollection.GetTile(count: this.Parent.Client.Player.ID),
                    targetTile = tileCollection.GetTile(count: this.Creature.ID);
                if (playerTile == null || targetTile == null) return null;
                Map.TileCollection adjacentTiles = tileCollection.GetAdjacentTileCollection(targetTile);
                List<Objects.PathFinder.Node> pfNodes = null;
                int closest = 15;
                Objects.Location bestLocation = Objects.Location.Invalid;
                switch (setting.FightStance)
                {
                    case Enums.FightStance.FollowDiagonalOnly:
                        if (playerTile.WorldLocation.IsAdjacentDiagonalOnly(targetTile.WorldLocation)) break;
                        int closestNonDiagonal = 15;
                        Objects.Location bestNonDiagonalLocation = Objects.Location.Invalid;
                        foreach (Map.Tile tile in adjacentTiles.GetTiles())
                        {
                            if (!tile.IsWalkable()) continue;
                            //if (!tile.WorldLocation.IsAdjacentDiagonalOnly(targetTile.WorldLocation)) continue;
                            pfNodes = playerTile.WorldLocation.GetTilesToLocation(this.Parent.Client,
                                tile.WorldLocation, tileCollection, this.Parent.PathFinder, true).ToList<Objects.PathFinder.Node>();
                            if (pfNodes.Count > 0)
                            {
                                if (this.Parent.CurrentSettings.AllowDiagonalMovement &&
                                    playerTile.WorldLocation.IsAdjacentDiagonalOnly(targetTile.WorldLocation))
                                {
                                    continue;
                                }

                                if (pfNodes.Count - 1 < closest &&
                                    tile.WorldLocation.IsAdjacentDiagonalOnly(targetTile.WorldLocation))
                                {
                                    closest = pfNodes.Count - 1;
                                    bestLocation = tile.WorldLocation;
                                }
                                else if (pfNodes.Count - 1 < closestNonDiagonal &&
                                    tile.WorldLocation.IsAdjacentNonDiagonalOnly(targetTile.WorldLocation))
                                {
                                    closestNonDiagonal = pfNodes.Count - 1;
                                    bestNonDiagonalLocation = tile.WorldLocation;
                                }
                            }
                        }
                        if (!bestLocation.IsValid()) bestLocation = bestNonDiagonalLocation;
                        break;
                    case Enums.FightStance.FollowStrike:
                        if (playerTile.WorldLocation.IsAdjacentNonDiagonalOnly(targetTile.WorldLocation)) break;
                        foreach (Map.Tile tile in adjacentTiles.GetTiles())
                        {
                            if (!tile.WorldLocation.IsAdjacentNonDiagonalOnly(targetTile.WorldLocation)) continue;
                            pfNodes = playerTile.WorldLocation.GetTilesToLocation(this.Parent.Client,
                                tile.WorldLocation, tileCollection, this.Parent.PathFinder, true).ToList<Objects.PathFinder.Node>();
                            if (pfNodes.Count > 0 && pfNodes.Count - 1 < closest &&
                                (!this.Parent.CurrentSettings.AllowDiagonalMovement ||
                                 playerTile.WorldLocation.IsAdjacentDiagonalOnly(targetTile.WorldLocation)))
                            {
                                closest = pfNodes.Count - 1;
                                bestLocation = tile.WorldLocation;
                            }
                        }
                        break;
                    case Enums.FightStance.DistanceFollow:
                    case Enums.FightStance.DistanceWait:
                        // map creature tiles and the path nodes to them from the player
                        Dictionary<Map.Tile, List<Objects.PathFinder.Node>> creatureTiles =
                            new Dictionary<Map.Tile, List<Objects.PathFinder.Node>>();
                        // add the current target
                        creatureTiles.Add(targetTile,
                            this.Creature.GetTilesToCreature(tileCollection, this.Parent.PathFinder).ToList<Objects.PathFinder.Node>());
                        // check whether to add other monsters as well
                        if (this.Parent.CurrentSettings.ConsiderAllMonstersWhenKeepingAway)
                        {
                            foreach (Objects.Creature c in creaturesOnScreen)
                            {
                                Map.Tile t = tileCollection.GetTile(count: c.ID);
                                if (t != null && !creatureTiles.ContainsKey(t))
                                {
                                    creatureTiles.Add(t,
                                        c.GetTilesToCreature(tileCollection, this.Parent.PathFinder).ToList<Objects.PathFinder.Node>());
                                }
                            }
                        }

                        // check if the player needs to move
                        // also set the player's location as default location to return
                        bool needToMove = false;
                        bestLocation = playerTile.WorldLocation;
                        foreach (var keypair in creatureTiles)
                        {
                            // check if creature can reach the player
                            if (keypair.Value.Count == 0) continue;
//.........这里部分代码省略.........
开发者ID:KyLuaa,项目名称:bot,代码行数:101,代码来源:Cavebot.Target.cs

示例5: GetTileUrl

        public override string GetTileUrl(int x, int y, double resolution)
        {
            Map map = new Map(Url);
            TileInfo iserverTileInfo = new TileInfo();
            iserverTileInfo.Height = Convert.ToUInt32(this.TileSize);
            iserverTileInfo.Width = Convert.ToUInt32(this.TileSize); ;
            iserverTileInfo.TileIndex = new SuperMap.Connector.Utility.TileIndex();
            iserverTileInfo.TileIndex.ColIndex = x;
            iserverTileInfo.TileIndex.RowIndex = y;

            double scale = this._referScale * _referResolution / resolution;
            iserverTileInfo.Scale = scale;
            SuperMap.Connector.Utility.ImageOutputOption option = new SuperMap.Connector.Utility.ImageOutputOption();
            option.ImageReturnType = SuperMap.Connector.Utility.ImageReturnType.URL;
            option.ImageOutputFormat = SuperMap.Connector.Utility.ImageOutputFormat.PNG;
            option.Transparent = false;

            MapImage img = map.GetTile(MapName, iserverTileInfo, option);
            System.Diagnostics.Debug.WriteLine(img.ImageUrl);
            return img.ImageUrl;
        }
开发者ID:SuperMap,项目名称:iClient-for-DotNet,代码行数:21,代码来源:TilediServerLayer.cs

示例6: SetMap

        public void SetMap(Map map, GamePlayState _state)
        {
            currentGameMode = _state.CurrentGameMode;
            flags = _state.Flags;
            utilities = _state.Utilities;
            bases = _state.Bases;
            try
            {
                GraphicsDevice device = Renderer.GraphicOptions.graphics.GraphicsDevice;
                PresentationParameters pp = device.PresentationParameters;
                renderTarget = new RenderTarget2D(device, (int)map.Width * miniMapScaleFactor + 2 * miniMapBorderBuffer,
                             (int)map.Height * miniMapScaleFactor + 2 * miniMapBorderBuffer, 1, SurfaceFormat.Color,
                             pp.MultiSampleType,
                             pp.MultiSampleQuality, RenderTargetUsage.PreserveContents);

                DepthStencilBuffer previousDepth = device.DepthStencilBuffer;
                device.DepthStencilBuffer = null;
                device.SetRenderTarget(0, renderTarget);
                device.Clear(Color.Black);
                ServiceManager.Game.Batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
                Texture2D miniMapDrawer = ServiceManager.Resources.GetTexture2D("textures\\misc\\MiniMap\\wallandbackground");

                for (uint x = 0; x < map.Width; x++)
                {
                    for (uint y = 0; y < map.Height; y++)
                    {
                        Tile tmpTile = map.GetTile(x, y);

                        if (!tmpTile.IsPassable)
                            ServiceManager.Game.Batch.Draw(miniMapDrawer,
                                new Vector2(x * miniMapScaleFactor + miniMapBorderBuffer, y * miniMapScaleFactor + miniMapBorderBuffer),
                                new Rectangle(0, 0, miniMapScaleFactor, miniMapScaleFactor), Color.White);
                    }
                }

                ServiceManager.Game.Batch.End();
                device.DepthStencilBuffer = previousDepth;
                device.SetRenderTarget(0, null);
                texture = renderTarget.GetTexture();

                renderTarget = new RenderTarget2D(device, 235, 235,
                     1, SurfaceFormat.Color,
                     pp.MultiSampleType,
                     pp.MultiSampleQuality, RenderTargetUsage.PreserveContents);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
            }
        }
开发者ID:summer-of-software,项目名称:vtank,代码行数:50,代码来源:Minimap.cs

示例7: GetAreaEffectTile

        /// <summary>
        /// Attempts to get the optimal tile for an AoE rune or spell.
        /// <para></para>
        /// Returns null if no tile is found.
        /// </summary>
        /// <param name="areaEffect">The area effect that is going to be used.</param>
        /// <param name="tilesOnScreen">A collection of the current tiles visible on screen.</param>
        /// <param name="target">The target that must be hit. Can be null if no target is present.</param>
        /// <returns></returns>
        public Map.Tile GetAreaEffectTile(Objects.AreaEffect areaEffect, Map.TileCollection tilesOnScreen,
            Objects.Creature target)
        {
            List<Map.Tile> bestTiles = new List<Map.Tile>();
            int bestCount = -1;
            uint playerID = this.Client.Player.ID;
            Map.Tile playerTile = tilesOnScreen.GetTile(count: this.Client.Player.ID);
            if (playerTile == null) return null;
            Objects.Location playerLoc = playerTile.WorldLocation;
            uint targetID = target == null ? 0 : target.ID;

            // store the locations of creatures
            List<Map.Tile> creaturesOnScreen = new List<Map.Tile>();
            foreach (Map.Tile tile in tilesOnScreen.GetTiles())
            {
                if (tile.ContainsCreature() && !tile.ContainsCreature(playerID)) creaturesOnScreen.Add(tile);
            }

            foreach (Map.Tile tile in creaturesOnScreen)
            {
                if (playerLoc.CanShootLocation(this.Client, tile.WorldLocation, tilesOnScreen))
                {
                    ushort count = 0;
                    bool foundTarget = target == null ? true : false;
                    foreach (Map.Tile creatureTile in creaturesOnScreen)
                    {
                        if (creatureTile.WorldLocation.IsInAreaEffect(areaEffect, tile.WorldLocation,
                            (Enums.Direction)this.Client.Player.Direction))
                        {
                            count++;

                            if (!foundTarget && creatureTile.ContainsCreature(targetID)) foundTarget = true;
                        }
                    }
                    if (count == 0 || !foundTarget) continue;

                    if (count == bestCount) bestTiles.Add(tile);
                    else if (count > bestCount)
                    {
                        bestTiles.Clear();
                        bestTiles.Add(tile);
                        bestCount = count;
                    }
                }
            }
            if (bestTiles.Count == 0) return null;
            return bestTiles[new Random().Next(bestTiles.Count)];
        }
开发者ID:KyLuaa,项目名称:bot,代码行数:57,代码来源:Cavebot.cs

示例8: BuildInternal

    public IEnumerator BuildInternal(Map map, bool animate = true)
    {
        if (displayObjects == null) {
            displayObjects = new GameObject[map.sx, map.sy];
            mapParent = new GameObject ("map parent");
            mapParent.transform.parent = transform;
        } else if(animate) {
            for (int x = 0; x < map.sx; x++) {
                for (int y = 0; y < map.sy; y++) {
                    StartCoroutine (ScaleInTime ((x + y) * 0.05f, displayObjects [x, y], 0));
                }
            }
            yield return new WaitForSeconds (1);
        }

        for (int x = 0; x < map.sx; x++) {
            for (int y = 0; y < map.sy; y++) {
                // if the map doesn't exist yet
                if (displayObjects [x, y] == null) {
                    displayObjects [x, y] = new GameObject ();
                    displayObjects [x, y].AddComponent<SpriteRenderer> ();
                    displayObjects[x,y].transform.localScale = Vector3.zero;
                    displayObjects[x,y].transform.localPosition = new Vector3 (x, y, 0);
                    displayObjects[x,y].transform.parent = mapParent.transform;
                }
                // assign the shortcut and the order
                SpriteRenderer s = displayObjects [x, y].GetComponent<SpriteRenderer> ();
                s.sortingOrder = 0;
                s.color = Color.white;
                //put in the correct tiles
                switch(map.GetTile (x, y)) {
                case RL.TileType.WALL:
                case RL.TileType.HARD_WALL:
                    s.sprite = GetSpriteWithName ("og_wallset_"+(calcIndexOryx(x, y, map)+6));
                    break;
                case RL.TileType.STAIRS_DOWN:
                    s.sprite = GetSpriteWithName ("stairsdown");
                    break;
                case RL.TileType.GOBLET:
                    s.sprite = GetSpriteWithName ("goblet");
                    break;
                case RL.TileType.ACID:
                    s.sprite = GetSpriteWithName ("acid");
                    break;
                case RL.TileType.LAVA:
                    s.sprite = GetSpriteWithName ("lava");
                    break;
                default:
                    s.sprite = GetSpriteWithName ("floor_0");
                    if ((x + y) % 2 == 0)
                        s.color = Color.white * 0.9f;
                    break;
                }
                // make the screen layout good, and animate everything in
                if (animate) {
                    StartCoroutine (ScaleInTime ((x + y) * 0.05f, displayObjects [x, y], 1));
                }else{
                    displayObjects [x, y].transform.localScale = Vector3.one;
                }
            }
        }
        if (animate) {
            yield return new WaitForSeconds((map.sx+map.sy)*0.05f);
        }
    }
开发者ID:jonbro,项目名称:nightmare_cooperative,代码行数:65,代码来源:MapDisplay.cs

示例9: LootItems

            private void LootItems(Objects.Container lootContainer, IEnumerable<Loot> loots,
                Map.TileCollection tiles)
            {
                Random rand = new Random();
                if (!this.Parent.StopwatchFoodEater.IsRunning) this.Parent.StopwatchFoodEater.Start();
                int index = lootContainer.ItemsAmount - 1, retryCount = 0;
                while (index >= 0 && !this.Cancel)
                {
                    // sanity checks
                    if (lootContainer.ItemsAmount == 0 || !lootContainer.IsOpen) break;
                    if (retryCount >= 3)
                    {
                        retryCount = 0;
                        index--;
                        continue;
                    }

                    // get item
                    Objects.Item item = lootContainer.GetItemInSlot((byte)index);
                    if (item == null)
                    {
                        index--;
                        retryCount = 0;
                        continue;
                    }

                    // check if it's food, eat it if so
                    if (this.Parent.CurrentSettings.EatFood &&
                        this.Parent.StopwatchFoodEater.Elapsed.TotalSeconds > 20 &&
                        this.Parent.Client.ItemList.Food.All.Contains(item.ID))
                    {
                        if (item.Count <= 1) item.Use();
                        else
                        {
                            for (int i = 0; i < Math.Min(item.Count, (ushort)3); i++)
                            {
                                item.Use();
                                Thread.Sleep(rand.Next(200, 325));
                            }
                        }
                        this.Parent.StopwatchFoodEater.Restart();
                        Thread.Sleep(rand.Next(200, 350));
                        index--;
                        continue;
                    }

                    // check if we want to loot this item
                    Loot loot = null;
                    foreach (Loot l in loots)
                    {
                        if (l.ID == item.ID)
                        {
                            loot = l;
                            break;
                        }
                    }
                    if (loot == null)
                    {
                        index--;
                        continue;
                    }

                    // loot this item
                    bool successful = false;
                    switch (loot.Destination)
                    {
                        case Loot.Destinations.Ground:
                            Objects.Map.Tile playerTile = tiles.GetTile(count: this.Parent.Client.Player.ID);
                            if (playerTile == null) break;
                            List<Map.Tile> adjacentTiles = tiles.GetAdjacentTileCollection(playerTile).GetTiles().ToList();
                            adjacentTiles.Shuffle();
                            foreach (Objects.Map.Tile tile in adjacentTiles)
                            {
                                if (!tile.IsWalkable()) continue;

                                item.Move(new Objects.ItemLocation(tile.WorldLocation));
                                successful = true;
                                break;
                            }
                            break;
                        case Loot.Destinations.EmptyContainer:
                            Objects.ItemLocation toItem = this.Parent.Client.Inventory.GetFirstSuitableSlot(item, loot.Index);
                            if (toItem == null) break;
                            item.Move(toItem);
                            successful = true;
                            break;
                    }

                    // if successful, check if it's looted
                    // if it wasn't looted, try again
                    if (successful)
                    {
                        if (!item.WaitForInteraction(800))
                        {
                            retryCount++;
                            continue;
                        }
                        if (this.Parent.ItemLooted != null) this.Parent.ItemLooted(item);
                        if (!this.Parent.CurrentSettings.FastLooting) Thread.Sleep(rand.Next(400, 700));
                    }
//.........这里部分代码省略.........
开发者ID:KyLuaa,项目名称:bot,代码行数:101,代码来源:Cavebot.Looter.cs

示例10: GetTilesToLocation

        /// <summary>
        /// Gets a collection of pathfinder nodes to a given location. Returns 0 elements if unsuccessful.
        /// </summary>
        /// <param name="c">The client to perform the operation on.</param>
        /// <param name="loc">The location to reach.</param>
        /// <param name="tiles">A list of tiles to use for pathfinding.</param>
        /// <param name="pathFinder">The pathfinder to use.</param>
        /// <param name="considerPlayerWalkable">Whether to consider the player as walkable.</param>
        /// <param name="considerCreatureOnLocationWalkable">Whether to consider any creatures on the target location as walkable.</param>
        /// <returns></returns>
        public IEnumerable<Objects.PathFinder.Node> GetTilesToLocation(Objects.Client c,
            Location loc, Map.TileCollection tiles, Objects.PathFinder pathFinder,
            bool considerPlayerWalkable = false, bool considerCreatureOnLocationWalkable = false)
        {
            if (pathFinder == null) return Enumerable.Empty<Objects.PathFinder.Node>();
            //return pathFinder.

            if (!this.IsOnScreen(c.Player.Location)) return Enumerable.Empty<Objects.PathFinder.Node>();

            uint playerId = c.Player.ID;
            Map.Tile playerTile = tiles.GetTile(count: playerId);
            Map.Tile fromTile = tiles.GetTile(this);
            Map.Tile targetTile = tiles.GetTile(loc);
            if (playerTile == null || fromTile == null || targetTile == null) return Enumerable.Empty<Objects.PathFinder.Node>();

            // check if target tile is walkable
            if (!targetTile.IsWalkable() && (!considerPlayerWalkable || targetTile != playerTile)) return Enumerable.Empty<Objects.PathFinder.Node>();
            if (fromTile == targetTile) return Enumerable.AsEnumerable(new Objects.PathFinder.Node[] { new Objects.PathFinder.Node() });
            lock (pathFinder)
            {
                pathFinder.ResetGrid();
                foreach (Map.Tile tile in tiles.GetTiles())
                {
                    if (tile == null) continue;

                    if ((considerPlayerWalkable && tile == playerTile) || tile.IsWalkable()) pathFinder.Grid[tile.MemoryLocation.X, tile.MemoryLocation.Y] = 1;
                    else pathFinder.Grid[tile.MemoryLocation.X, tile.MemoryLocation.Y] = (byte)Enums.MiniMapSpeedValues.Unwalkable;
                }
                pathFinder.Grid[fromTile.MemoryLocation.X, fromTile.MemoryLocation.Y] = 1;
                return pathFinder.FindPath(fromTile.MemoryLocation, targetTile.MemoryLocation);
            }
        }
开发者ID:KyLuaa,项目名称:bot,代码行数:42,代码来源:Location.cs

示例11: CanShootLocation

        /// <summary>
        /// Checks whether this location can shoot another location.
        /// </summary>
        /// <param name="c">The client to perform the operation on.</param>
        /// <param name="loc">The location to shoot at.</param>
        /// <param name="tileCollection">The tiles on screen to use for pathfinding.</param>
        /// <returns></returns>
        public bool CanShootLocation(Objects.Client c, Objects.Location loc, Map.TileCollection tileCollection)
        {
            if (!this.IsOnScreen(loc)) return false;

            Map.Tile playerTile = tileCollection.GetTile(count: c.Player.ID);
            if (playerTile == null) return false;
            Location playerLocation = playerTile.WorldLocation;
            if (playerLocation == loc) return true;
            if (!playerLocation.IsOnScreen(this) || !playerLocation.IsOnScreen(loc)) return false;

            int XSign = (this.X > loc.X) ? 1 : -1;
            int YSign = (this.Y > loc.Y) ? 1 : -1;
            double XDistance = Math.Abs(this.X - loc.X);
            double YDistance = Math.Abs(this.Y - loc.Y);
            double max = this.DistanceTo(loc);

            for (int i = 0; i <= max; i++)
            {
                Location check = this.Offset((int)Math.Ceiling(i * XDistance / max) * XSign,
                    (int)Math.Ceiling(i * YDistance / max) * YSign);
                Map.Tile tile = tileCollection.GetTile(check);
                if (tile == null) return false;
                if (tile.ContainsObjectProperty(Enums.ObjectPropertiesFlags.IsMissileBlocking)) return false;
            }
            return true;
        }
开发者ID:KyLuaa,项目名称:bot,代码行数:33,代码来源:Location.cs

示例12: HandleMapData

        private void HandleMapData(PacketReceivedEventArgs args)
        {
            var map = new Map
            {
                Name = args.Message.ReadString(),
                Version = args.Message.ReadInt32()
            };

            map.ResizeMap(args.Message.ReadInt32(), args.Message.ReadInt32());

            for (int x = 0; x < map.Width; x++)
            {
                for (int y = 0; y < map.Height; y++)
                {
                    map.SetTile(x, y, new Map.Tile());

                    map.GetTile(x, y).Blocked = args.Message.ReadBoolean();

                    foreach (Map.Layers layer in Enum.GetValues(typeof(Map.Layers)))
                    {
                        if (!args.Message.ReadBoolean()) continue;

                        var textureNumber = args.Message.ReadInt32();
                        var left = args.Message.ReadInt32();
                        var top = args.Message.ReadInt32();
                        var width = args.Message.ReadInt32();
                        var height = args.Message.ReadInt32();

                        var textureRect = new IntRect(left, top, width, height);

                        var tileSprite = new Sprite(ServiceLocator.ScreenManager.ActiveScreen.TextureManager.GetTexture("tileset" + textureNumber.ToString()))
                        {
                            TextureRect = textureRect
                        };

                        map.GetTile(x, y).SetLayer(layer, new Map.Tile.Layer(tileSprite, x, y));
                    }
                }
            }

            var mapNpcCount = args.Message.ReadInt32();

            for (int i = 0; i < mapNpcCount; i++)
            {
                var npc = new Npc()
                {
                    Name = args.Message.ReadString(),
                    Level = args.Message.ReadInt32(),
                    Sprite = new Sprite(ServiceLocator.ScreenManager.ActiveScreen.TextureManager.GetTexture("npc" + args.Message.ReadInt32())),
                };
                var position = args.Message.ReadVector();
                npc.Position = new SFML.System.Vector2i(position.X, position.Y);
            }

            map.CacheMap();
            this.Map = map;

            // Notify the server that we're now in the game.
            var net = ServiceLocator.NetManager;
            var packet = new Packet(PacketType.MapCheckPacket);
            packet.Message.Write(true);
            net.SendMessage(packet.Message, Lidgren.Network.NetDeliveryMethod.ReliableOrdered, ChannelTypes.WORLD);
        }
开发者ID:JohnLamontagne,项目名称:CEngineSharp,代码行数:63,代码来源:MapManager.cs


注:本文中的Map.GetTile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。