Ejemplo n.º 1
0
    private Hex FindNewHabitat(Hex habitat)
    {
        float score = 0;
        float winnerScore = 0;
        Hex newHabitat = null;

        foreach(GameObject neighbor in habitat.GetNeighborList()){
            if(neighbor != null){
                Hex Candidate = neighbor.GetComponent<Hex>();

                score = CritterSurvivalCheck(Candidate);

                if(score > winnerScore && Candidate.localCritters.Count <= 11 && IsValideMigrationTarget(Candidate)){
                    if(!habitats.Contains(newHabitat))
                    {
                        if (score >= 0 || score >= (CritterSurvivalCheck(habitat)))
                        {
                            newHabitat = Candidate;
                            winnerScore = score;
                        }
                        else if (diet.Contains(dietType.CARNO) && habitat.localCritters.Count > 1)
                        {
                            newHabitat = Candidate;
                            winnerScore = score;
                        }
                        else
                        {
                            newHabitat = null;
                        }
                    }
                }
            }
        }

        return newHabitat;
    }