Example #1
0
    private void ExploreNode(Node currentNode)
    {
        if (currentNode.CumulativeCost < AP)
        {
            foreach (Hex neighbor in BoardManager.GetNeighborsOfHex(currentNode.OwnedHex))
            {
                if (neighbor != null)
                {
                    if (currentNode.Source != neighbor && !neighbor.isOccupied())
                    {
                        Node neighborNode = MapNodes.Find(node => node == neighbor);

                        if (neighborNode == null)
                        {
                            Node NodeToAdd = GenerateNode(currentNode, neighbor);
                            if (NodeToAdd != null)
                            {
                                MapNodes.Add(NodeToAdd);
                            }
                        }
                        else
                        {
                            currentNode.Source  = CompareSourceNodes(currentNode, currentNode.Source, neighborNode);
                            neighborNode.Source = CompareSourceNodes(neighborNode, neighborNode.Source, currentNode);
                        }
                    }
                }
            }
        }
    }
 public void AddNodePair(string a, string b)
 {
     if (!MapNodes.ContainsKey(a))
     {
         // need to set things up
         var nodes = new List <string>();
         MapNodes.Add(a, nodes);
     }
     MapNodes[a].Add(b);
 }
Example #3
0
    public override void CreateMap(Hex origin)
    {
        EndVisualization();
        MapNodes.Clear();
        MapNodes.Add(new NavigableNode(origin, null, 0));

        int nodesExplored = 0;

        if (BattleManager.controlledCharacter == Owner)
        {
            AP = BattleManager.RemainingAP;
        }
        else
        {
            AP = Owner.ActionPoints;
        }

        while (nodesExplored < MapNodes.Count)
        {
            ExploreNode(MapNodes[nodesExplored]);
            nodesExplored++;
        }
    }
Example #4
0
    public override void CreateMap(Hex origin)
    {
        EndVisualization();
        MapNodes.Clear();

        List <Hex> hexesToCheck = new List <Hex>();

        hexesToCheck.AddRange(BoardManager.GetNeighborsOfHex(origin));

        int counter = 0;

        while (counter < hexesToCheck.Count)
        {
            Hex testingHex = hexesToCheck[counter];

            if (testingHex != null)
            {
                int distance = BoardManager.CalculateHexDistance(origin, testingHex);

                if (distance < associatedWeapon.WeaponRange)
                {
                    foreach (Hex hex in BoardManager.GetNeighborsOfHex(testingHex))
                    {
                        if (!hexesToCheck.Contains(hex) && !Contains((hex)))
                        {
                            hexesToCheck.Add(hex);
                        }
                    }
                }
                if (associatedWeapon.WeaponRange.IsInRange(distance))
                {
                    MapNodes.Add(GenerateNode(null, testingHex));
                }
            }
            counter++;
        }
    }