コード例 #1
0
        private void FindLinkOnTypedElement(int x, int y)
        {
            var      element = _board.GetAt(x, y);
            PathNode node;

            if (_pointToNode.ContainsKey(BoardPointStringPosition.Get(x, y)))
            {
                node = _pointToNode[BoardPointStringPosition.Get(x, y)];
            }
            else
            {
                return;
            }

            if (_board.HasElementAt(x, y, BoardElement.Brick))
            {
                FindNeighborsBrick(ref node, x, y);
                return;
            }

            if (_board.HasLadderAt(x, y))
            {
                FindNeighborsLadder(ref node, x, y);
                return;
            }

            if (_board.HasPipeAt(x, y))
            {
                FindNeighborsPipe(ref node, x, y);
                return;
            }

            FindNeighborsNone(ref node, x, y);
        }
コード例 #2
0
        /// <summary>
        /// Получить ноду по координате игрового поля
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public PathNode GetNode(int x, int y)
        {
            if (PointToNode.ContainsKey(BoardPointStringPosition.Get(x, y)))
            {
                return(PointToNode[BoardPointStringPosition.Get(x, y)]);
            }

            return(null);
        }
コード例 #3
0
 private void LinkNodeDirectionNotWall(ref PathNode node, int x, int y, PathNode.DirectionNode direction)
 {
     if (!_board.HasWallAt(x, y))
     {
         var hash = BoardPointStringPosition.Get(x, y);
         if (_pointToNode.ContainsKey(hash))
         {
             node.Link(_pointToNode[hash], direction);
         }
     }
 }
コード例 #4
0
        private void LinkNodeDiagonalDirectionWall(ref PathNode node, int x, int y, PathNode.DirectionNode direction)
        {
            if (!_board.IsOutOfBoard(x, y))
            {
                var element = _board.GetAt(x, y);
                switch (element)
                {
                case BoardElement.Brick:
                    var hash = BoardPointStringPosition.Get(x, y);
                    if (_pointToNode.ContainsKey(hash))
                    {
                        node.Link(_pointToNode[hash], direction);
                    }
                    break;

                default:
                    return;
                }
            }
        }
コード例 #5
0
        private void MarkerTheBoard()
        {
            for (int i = -_deepFind; i < _deepFind; i++)
            {
                for (int j = -_deepFind; j < _deepFind; j++)
                {
                    _posX = _root.X + i;
                    _posY = _root.Y + j;

                    if (_board.IsOutOfBoard(_posX, _posY))
                    {
                        continue;
                    }

                    var node = new PathNode();
                    node.SetCost(CalculateCost(_posX, _posY));
                    node.SetScore(CalculateScore(_posX, _posY));
                    node.SetName($"{_posX}:{_posY}");

                    _pointToNode.Add(BoardPointStringPosition.Get(_posX, _posY), node);
                    TryAddGoldToList(ref node, _posX, _posY);
                }
            }
        }