Пример #1
0
        private Node GetMinInfluenceNode()
        {
            InfluenceMapComponent influenceMapComponent = Object.FindObjectOfType <InfluenceMapComponent>();
            float       minInfluence       = int.MaxValue;
            Node        minInfluenceNode   = null;
            List <Node> sameInfluencesNode = new List <Node>();

            foreach (var possibleMovement in troopToMove.GetComponent <Troop>().possibleMovements)
            {
                float tempInfluence = influenceMapComponent.GetNodeAtLocation(possibleMovement.WorldPosition)
                                      .GetTotalInfluenceAtNode();

                //intentamos movernos al de menor influencia y que no lo haya elegido otro.
                if (tempInfluence < minInfluence && !(_levelController.chosenNodesToMoveIA.Contains(possibleMovement)))
                {
                    minInfluenceNode = possibleMovement;
                    minInfluence     = tempInfluence;
                }
                else if (tempInfluence == minInfluence && !(_levelController.chosenNodesToMoveIA.Contains(possibleMovement)))
                {
                    sameInfluencesNode.Add(possibleMovement);
                }
            }

            if (sameInfluencesNode.Count > 0)
            {
                return(sameInfluencesNode[Random.Range(0, sameInfluencesNode.Count)]);
            }

            return(minInfluenceNode);
        }
Пример #2
0
    // Use this for initialization
    private void Awake()
    {
        _influenceMapComponent = FindObjectOfType <InfluenceMapComponent>();
        _levelController       = FindObjectOfType <LevelController>();
        _pathfindingGrid       = FindObjectOfType <PathfindingGrid>();
        _influenceTexture      = GameObject.FindGameObjectWithTag("InfluenceTexture").GetComponent <RawImage>();

        Assert.IsNotNull(_influenceTexture);
        Assert.IsNotNull(_influenceMapComponent);
        Assert.IsNotNull(_levelController);
        Assert.IsNotNull(_pathfindingGrid);
    }
Пример #3
0
 public GameBoardAnalyzer(TasksAllocator tasksAllocator, InfluenceMapComponent influenceMapComponent)
 {
     _tasksAllocator        = tasksAllocator;
     _influenceMapComponent = influenceMapComponent;
 }