コード例 #1
0
    private void OnTriggerExit(Collider other)
    {
        float      massAmount = 0;
        IHaveMass  _mass      = other.GetComponent <IHaveMass>();
        IHaveWater _water     = other.GetComponent <IHaveWater>();

        if (_mass != null)
        {
            massAmount = _mass.Mass;
        }
        IAmPlant _plant = other.GetComponent <IAmPlant>();

        if (_plant != null)
        {
            if (_mass != null)
            {
                massAmount = _mass.Mass;
            }
            if (_plant.PlantType == "Foliage")
            {
                _memory.foliageMass -= massAmount;
            }
            else
            {
                _memory.fruitMass -= massAmount;
            }
        }
        else if (other.GetComponent <IAmTree>() != null)
        {
            _memory.treeCount -= 1;
        }
        else if (other.GetComponent <IAmCreature>() != null)
        {
            Biology _bio = other.GetComponent <Biology>();
            if (_bio != null)
            {
                if (_bio.dietType == Biology.DietType.Carnivore)
                {
                    _memory.meatConsumptionMass -= other.GetComponent <IHaveFood>().MaxFood;
                    _memory.carnivoreList.Remove(other.gameObject);
                    _memory.carnivoreCount -= 1;
                    _memory.meatMass       -= massAmount;
                }
                else if (_bio.dietType == Biology.DietType.Herbivore)
                {
                    _memory.foliageConsumptionMass -= other.GetComponent <IHaveFood>().MaxFood;
                    _memory.herbivoreList.Remove(other.gameObject);
                    _memory.herbivoreCount -= 1;
                    _memory.meatMass       -= massAmount;
                }
                _memory.waterConsumption -= _water.MaxWater;
            }
        }
        else if (other.GetComponent <IAmWater>() != null)
        {
            _memory.waterMass -= massAmount;
        }
    }
コード例 #2
0
ファイル: Brain.cs プロジェクト: GrimStar/EcoSim
    public void CheckBiome(BiomeMemory _biome)
    {
        IHavePrefTemperature _temperatureStats = GetComponent <IHavePrefTemperature>();


        CreatureEvaluateBiome _evBiome = new CreatureEvaluateBiome();

        if (_temperatureStats != null)
        {
            if (_evBiome.BiomeHasSuitableTemperature(_temperatureStats.PrefTemp, _temperatureStats.TempDifTolerance, _biome.temperature))
            {
                Debug.Log("CorrectTemp");
                IHaveFood  _foodStat  = GetComponent <IHaveFood>();
                IHaveWater _waterStat = GetComponent <IHaveWater>();
                if (_foodStat != null)
                {
                    if (_evBiome.BiomeHasFood(_biome, _bio, _foodStat.MaxFood, _waterStat.MaxWater))
                    {
                        //Biome has food
                        Debug.Log("BiomeHasFood");
                        _memory.isMigrating = false;
                        _memory.isWandering = true;
                    }
                    else
                    {
                        ContinueMigrating(_biome, _temperatureStats);
                        Debug.Log("Biome Does not have food");
                    }
                }
                else
                {
                    Debug.Log("foodstats is null");
                }
            }
            else
            {
                ContinueMigrating(_biome, _temperatureStats);
                Debug.Log("WrongTemp");
            }
        }
    }
コード例 #3
0
ファイル: CreatureDrink.cs プロジェクト: GrimStar/EcoSim
 public void DrinkWater(IHaveMass source)
 {
     if (!isDrinking)
     {
         isDrinking = true;
         IHaveDrinkSize _drinkSize = GetComponent <IHaveDrinkSize>();
         IHaveWater     _water     = GetComponent <IHaveWater>();
         if (_drinkSize != null)
         {
             if (source.Mass - _drinkSize.DrinkSize >= 0)
             {
                 source.Mass -= _drinkSize.DrinkSize;
                 if (_water.Water < _water.MaxWater)
                 {
                     _water.Water += _drinkSize.DrinkSize;
                 }
             }
         }
         StartCoroutine(Interval());
     }
 }
コード例 #4
0
    private void OnTriggerEnter(Collider other)
    {
        float      massAmount = 0;
        IHaveMass  _mass      = other.GetComponent <IHaveMass>();
        IHaveWater _water     = other.GetComponent <IHaveWater>();

        if (_mass != null)
        {
            massAmount = _mass.Mass;
        }
        IAmPlant _plant = other.GetComponent <IAmPlant>();

        if (_plant != null)
        {
            other.GetComponent <CreatureMemory_Other>().CurBiome = _memory;

            if (_plant.PlantType == "Foliage")
            {
                _memory.foliageMass += massAmount;
            }
            else
            {
                _memory.fruitMass += massAmount;
            }
        }
        else if (other.GetComponent <IAmTree>() != null)
        {
            _memory.treeCount += 1;
        }
        else if (other.GetComponent <IAmCreature>() != null)
        {
            Biology _bio = other.GetComponent <Biology>();
            if (_bio != null)
            {
                if (_bio.dietType == Biology.DietType.Carnivore)
                {
                    _memory.meatConsumptionMass += other.GetComponent <IHaveFood>().MaxFood;
                    _memory.carnivoreList.Add(other.gameObject);
                    _memory.carnivoreCount += 1;
                    _memory.meatMass       += massAmount;
                    other.GetComponent <Brain>().CurBiome = _memory;
                }
                else if (_bio.dietType == Biology.DietType.Herbivore)
                {
                    _memory.foliageConsumptionMass += other.GetComponent <IHaveFood>().MaxFood;
                    _memory.herbivoreList.Add(other.gameObject);
                    _memory.herbivoreCount += 1;
                    _memory.meatMass       += massAmount;
                    other.GetComponent <Brain>().CurBiome = _memory;
                }
                _memory.waterConsumption += _water.MaxWater;
            }
        }
        else if (other.GetComponent <IAmWater>() != null)
        {
            _memory.waterMass += massAmount;
            other.GetComponent <CreatureMemory_Other>().CurBiome = _memory;
        }
        else if (other.GetComponent <IAmTile>() != null)
        {
            IAmTile _tiledata = other.GetComponent <IAmTile>();
            _tiledata.CurBiome = _memory;
        }
    }