示例#1
0
    public bool CalculateAvailableNearestTree(Villager inVillager, out TreeScript nearestTree)
    {
        if (!AreAvailableTreesInSanctuary())
        {
            nearestTree = null;
            return(false);
        }

        foreach (var tree in TreesPriorityQueue)
        {
            var distance = (inVillager.transform.position - tree.transform.position).magnitude;
            TreesPriorityQueue.UpdatePriority(tree, distance);
        }

        var treesArray = TreesPriorityQueue.ToArray();

        for (var i = 0; i < treesArray.Length; i++)
        {
            if (!treesArray[i].isOccupied)
            {
                nearestTree = treesArray[i];
                return(true);
            }
        }
        inVillager.UpdateAIText("No Available Trees");

        nearestTree = null;
        return(false);
    }
示例#2
0
 public int[] GetFrontier()
 {
     return(frontier.ToArray());
 }