Пример #1
0
        protected virtual void GetTarget()
        {
            // If the character is selected and a walkable tile is clicked, then update the character's path and move character to location.
            if (m_vipCoords != m_oldVipCoords)
            {
                //graphics.ToggleFullScreen();
                m_search.Search(m_xCoords, m_yCoords, m_vipCoords.X, m_vipCoords.Y);
                m_path     = m_search.GetPath();
                m_isMoving = true;

                while (m_path == null || m_path.Count <= 0)
                {
                    List <MapTile> walkables = new List <MapTile>();

                    for (int y = 0; y < m_map.Tiles.GetLength(1); y++)
                    {
                        if (m_map.Tiles[m_xCoords, y].IsWalkable)
                        {
                            walkables.Add(m_map.Tiles[m_xCoords, y]);
                        }
                    }

                    MapTile newTile = walkables[Game1.RNG.Next(0, walkables.Count)];

                    m_position = newTile.Position;
                    m_yCoords  = newTile.GridY;

                    m_search.Search(m_xCoords, m_yCoords, m_vipCoords.X, m_vipCoords.Y);
                    m_path     = m_search.GetPath();
                    m_isMoving = true;
                }
            }
        }
Пример #2
0
 private void GetTarget()
 {
     // If the character is selected and a walkable tile is clicked, then update the character's path and move character to location.
     if (m_vipCoords != m_oldVipCoords && !m_isShifting)
     {
         m_search.Search(m_xCoords, m_yCoords, m_vipCoords.X, m_vipCoords.Y);
         m_path     = m_search.GetPath();
         m_isMoving = true;
     }
 }
Пример #3
0
 private void GetTarget(InputManager input)
 {
     // If the character is selected and a walkable tile is clicked, then update the character's path and move character to location.
     if (input.LeftPressed && m_isSelected && (m_targetIndexX > 0 && m_targetIndexX < m_map.Tiles.GetLength(0) && m_targetIndexY > 0 && m_targetIndexY < m_map.Tiles.GetLength(1)) && m_map.Tiles[m_targetIndexX, m_targetIndexY].IsWalkable)
     {
         //graphics.ToggleFullScreen();
         m_search.Search(m_xCoords, m_yCoords, m_targetIndexX, m_targetIndexY);
         m_path     = m_search.GetPath();
         m_isMoving = true;
     }
 }