Пример #1
0
    void Start()
    {
        uiControl = FindObjectOfType<UIController>();
        hex = GetComponentInParent<Hex>();

        hexTrait = hex.GetGeography();
        hexVal = (int)hexTrait;
        icon = GetComponent<Image>();
        icon.sprite = uiControl.GetGeoSprite(hexTrait);
        icon.color = uiControl.GetGeoSpriteColor(hexTrait);
    }
Пример #2
0
    public int CalculateHabEffect(Hex habitat, Critter critter)
    {
        float climate = habitat.GetClimateVal();
        float temp = habitat.GetTempVal();
        float critterClimateFocus = critter.GetClimateFocus();
        float critterClimatePref = critter.GetClimatePref();
        float critterClimateRange = critter.GetClimateRange();
        float critterTempFocus = critter.GetTempFocus();
        float critterTempPref = critter.GetTempPref();
        float critterTempRange = critter.GetTempRange();
        Hex.BiomeType biome = habitat.GetBiomeType();
        Hex.Geography geo = habitat.GetGeography();
        int score = 0;

        //Calculates for all boon fields to create a positive score for a good habitat fit.
        foreach(BiomeAdaptition item in BiomeBoons){
            if((Hex.BiomeType)(item) == biome){
                score++;
            }
        }
        foreach(statSliderChange item in ClimateBoons){
            score += CheckStatSliderVal(item, critterClimatePref, critterClimateRange, critterClimateFocus, climate, 1);

            if (item == statSliderChange.FOCUS) { critterClimateFocus++; }
            else if (item == statSliderChange.PREF) { critterClimatePref++; }
            else if (item == statSliderChange.RANGE) { critterClimateRange++; }
        }
        foreach(GeoAdaptation item in GeoBoons){
            if((Hex.Geography)(item) == geo){
                score++;
            }
        }
        foreach(statSliderChange item in TempBoons){
            score += CheckStatSliderVal(item, critterTempPref, critterTempRange, critterTempFocus, temp, 1);

            if (item == statSliderChange.FOCUS) { critterTempFocus++; }
            else if (item == statSliderChange.PREF) { critterTempPref++; }
            else if (item == statSliderChange.RANGE) { critterTempRange++; }
        }

        //Calculates for all bane fields to create a negative score for a bad habitat fit.
        foreach(BiomeAdaptition item in BiomeBanes){
            if((Hex.BiomeType)(item) == biome){
                score--;
            }
        }
        foreach(statSliderChange item in ClimateBanes){
            score += CheckStatSliderVal(item, critterClimatePref, critterClimateRange, critterClimateFocus, climate, -1);

            if (item == statSliderChange.FOCUS) { critterClimateFocus--; }
            else if (item == statSliderChange.PREF) { critterClimatePref--; }
            else if (item == statSliderChange.RANGE) { critterClimateRange--; }
        }
        foreach(GeoAdaptation item in GeoBanes){
            if((Hex.Geography)(item) == geo){
                score--;
            }
        }
        foreach(statSliderChange item in TempBanes){
            score += CheckStatSliderVal(item, critterTempPref, critterTempRange, critterTempFocus, temp, -1);

            if (item == statSliderChange.FOCUS) { critterTempFocus--; }
            else if (item == statSliderChange.PREF) { critterTempPref--; }
            else if (item == statSliderChange.RANGE) { critterTempRange--; }
        }

        return score;
    }
Пример #3
0
    public float CritterSurvivalCheck(Hex habitat)
    {
        float score = 0;

        int biome = (int)habitat.GetBiomeType();
        int climate = (int)habitat.GetClimateVal();
        int geo = (int)habitat.GetGeography();
        int temp = (int)habitat.GetTempVal();

        score += biomePref[biome];
        score += GetClimatePref(climate);
        score += geoPref[geo];
        score += GetTempPref(temp);

        return score;
    }
Пример #4
0
    //Measures survival Score to determine Critter health in environment.
    public float SurvivalScore(Hex habitat)
    {
        float score = 0;
        int num;

        num = (int)habitat.GetBiomeType();
        score += biomePref[num];

        num = (int)habitat.GetClimate();
        score += GetClimatePref(num);

        num = (int)habitat.GetGeography();
        score += geoPref[num];

        num = (int)habitat.GetTemp();
        score += GetTempPref(num);

        return score;
    }
Пример #5
0
    private void UpdatePanel()
    {
        if(MapController.hexSelected){
            targetHex = MapController.hexSelected.GetComponent<Hex>();

            Hex.Biome hexBiome = targetHex.GetBiome();
            Hex.BiomeType hexbiomeType = targetHex.GetBiomeType();
            Hex.Geography hexGeo = targetHex.GetGeography();
            Hex.Vegetation hexVeg = targetHex.GetVegetation();
            int hexClimate = (int)targetHex.GetClimateVal();
            int hexTemp = (int)targetHex.GetTempVal();

            nameElements[0].text = hexBiome.ToString();
            nameElements[2].text = hexGeo.ToString();
            nameElements[8].text = hexVeg.ToString();

            icons[0].sprite = iconControl.GetBiomeTypeIcon(hexbiomeType);
            icons[0].color = uiControl.GetBiomeTypeSpriteColor(hexbiomeType);
            icons[1].sprite = uiControl.GetGeoSprite(hexGeo);
            icons[1].color = uiControl.GetGeoSpriteColor(hexGeo);
            icons[2].color = iconControl.GetHexVegColor(hexVeg);

            if (!critter)
            {
                critter = player.GetCritter();

                if (!critter)
                {
                    critter = GameController.CritterList[0];
                }
            }

            if (critter){
                values[0] = critter.GetBiomePref((Adaptation.BiomeAdaptition)hexbiomeType);
                values[1] = critter.GetGeoPref((Adaptation.GeoAdaptation)hexGeo);
                values[2] = critter.GetTempPref(hexTemp);
                values[3] = critter.GetClimatePref(hexClimate);

                for(int i = 0; i < 4; i++){
                    Text scoreText = nameElements[(i * 2 + 1)];

                    if(values[i] > 0){
                        scoreText.color = goodScore;
                        scoreText.text = "+" + values[i].ToString() + "%";
                    }
                    else if(values[i] < 0){
                        scoreText.color = badScore;
                        scoreText.text = values[i].ToString() + "%";
                    }
                    else{
                        scoreText.color = zeroScore;
                        scoreText.text = values[i].ToString() + "%";
                    }
                }

                UpdateSliders();
            }

            if (!critter.GetIsPlayer())
            {
                critter = null;
            }
        }
    }