Пример #1
0
    public ITargettable GetBestTarget()
    {
        IListConverter <ITargettable> allTargets = GetAllPotentialTargets();

        ITargettable currentBest = null;
        float        bestValue   = 0f;

        for (int i = 0; i < allTargets.Count; i++)
        {
            if (IsTargettable(allTargets[i]))
            {
                float value = GetTargetScore(allTargets[i]);
                if (value > bestValue)
                {
                    currentBest = allTargets[i];
                    bestValue   = value;
                }
            }
        }

        return(currentBest);

        //List<Carrot> carrots = AnimalMap.animalMap.carrots;

        /*IListConverter<ITargettable> potentialFood = null;
         * if (!target.predator)
         * {
         *  potentialFood = new ListConverter<Carrot, ITargettable>(AnimalMap.animalMap.carrots);
         * }
         * else
         * {
         *  potentialFood = new ListConverter<Animal, ITargettable>(AnimalMap.animalMap.animals);
         * }
         *
         *
         * ITargettable closestCarrot = null;
         * float shortestDistance = float.MaxValue;
         *
         * for (int i = 0; i < potentialFood.Count; i++)
         * {
         *  if (!potentialFood[i].CanBeTargetted(target))
         *  {
         *      continue;
         *  }
         *
         *  float distance = (potentialFood[i].GetPosition() - target.transform.position).sqrMagnitude;
         *  if (distance < shortestDistance)
         *  {
         *      shortestDistance = distance;
         *      closestCarrot = potentialFood[i];
         *  }
         * }
         *
         * return closestCarrot;*/
    }
Пример #2
0
    public float GetUtility()
    {
        // returns a range of 0 - 1 based upon the proximity of a target & how much we hate them.
        CacheHatedTypes();

        IListConverter <ITargettable> allTargets = GetAllPotentialTargets();

        float   highestScore = float.MinValue;
        Vector3 ourPosition  = target.GetPosition();

        for (int i = 0; i < allTargets.Count; i++)
        {
            if (IsTargettable(allTargets[i]))
            {
                float score = GetTargetScore(allTargets[i]);
                if (score > highestScore)
                {
                    highestScore = score;
                }
            }
        }

        return(highestScore);
    }
Пример #3
0
 public SaveListToTxt(IListConverter converter, List <Job> jobList)
 {
     _converter = converter;
     _jobList   = jobList;
 }