public override void EndState()
 {
     if (Agent.WalkPath.Count > 1)
     {
         bool         endAutoWalk = false;
         BreadthFirst enemyScan   = new BreadthFirst();
         enemyScan.Search(Agent.CurrentNode, Agent.HighlighterRadius + 1);
         if (enemyScan.Done && enemyScan.Nodes != null)
         {
             foreach (var node in enemyScan.Nodes)
             {
                 if (node.HasEnemy)
                 {
                     endAutoWalk = true;
                     break;
                 }
             }
         }
         if (endAutoWalk == false)
         {
             Agent.WalkPath.RemoveAt(0);
         }
         else
         {
             Agent.WalkPath = null;
         }
     }
     else
     {
         Agent.WalkPath = null;
     }
 }
 public void ShowHighlight(HexNode currentNode, int maxExpansion, bool freeMovement)
 {
     maxExpansion += 1;
     _breadthFirst.Search(currentNode, maxExpansion);
     if (_breadthFirst.Done)
     {
         foreach (var node in _breadthFirst.Nodes)
         {
             GameObject nodeHighlight = null;
             if (node.HasOccupant)
             {
                 if (node.HasPlayer)
                 {
                     nodeHighlight = PlayerHighlight;
                 }
                 else if (node.HasEnemy)
                 {
                     nodeHighlight = EnemyHighlight;
                 }
                 else if (node.HasNPC)
                 {
                     nodeHighlight = NpcHighlight;
                 }
                 else if (node.HasBuilding)
                 {
                     nodeHighlight = BuildingHighlight;
                 }
                 else if (node.HasProp)
                 {
                     nodeHighlight = PropHighlight;
                 }
             }
             else
             {
                 if (freeMovement)
                 {
                     nodeHighlight = WalkHighlight;
                 }
                 else
                 {
                     if (node.Expansion == 1)
                     {
                         nodeHighlight = WalkHighlight;
                     }
                     else
                     {
                         nodeHighlight = TerrainHighlight;
                     }
                 }
             }
             if (nodeHighlight != null)
             {
                 GameObject highlight = Instantiate(nodeHighlight, node.Position, _hlrot);
                 highlight.SendMessage("Create", node);
                 _highlights.Add(highlight);
             }
         }
     }
 }
示例#3
0
        public override void Start()
        {
            _exitingIdle = false;

            Manager.RemoveDeadEnemies();

            BreadthFirst enemyScan = new BreadthFirst();

            enemyScan.Search(Manager.GetPlayerAgent().CurrentNode, Manager.GetPlayerAgent().HighlighterRadius + 1); //Scan for enemies in given range
            if (enemyScan.Done && enemyScan.Nodes != null)
            {
                HashSet <EnemyAgent> currentEnemies = Manager.GetEnemyHashSet();

                foreach (var node in enemyScan.Nodes)
                {
                    if (node.HasEnemy)
                    {
                        EnemyAgent enemy = (node.Occupant as EnemyAgent);
                        if (enemy != null)
                        {
                            if (!currentEnemies.Contains(enemy))
                            {
                                Debug.Log("Enemy " + enemy.AgentName + " has been successfully added!");
                                Manager.AddEnemy(enemy);
                            }
                            else
                            {
                                Debug.Log("Enemy " + enemy.AgentName + " already was an enemy!");
                            }
                        }
                        else
                        {
                            Debug.Log("Something went wrong while adding the enemy to the gamephase");
                        }
                    }
                }
            }
        }
示例#4
0
        private (List <Position>, List <Position>) BFS(Position a, Position b)
        {
            BreadthFirst bfsSearch = new BreadthFirst();

            return(bfsSearch.Search(a, b, grid));
        }