예제 #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
 void GetWater()
 {
     if (_reach != null)
     {
         if (_nav.agent.remainingDistance <= _reach.Reach)
         {
             if (_drink != null)
             {
                 IHaveMass _water = _memory.curWaterSource.GetComponent <IHaveMass>();
                 if (_water != null)
                 {
                     _drink.DrinkWater(_water);
                 }
             }
         }
     }
 }
예제 #3
0
 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
 public void HarvestTarget(Transform target)
 {
     if (!isHarvesting)
     {
         isHarvesting = true;
         StartCoroutine(AttackCooldown());
         IHaveMass     _mass = target.GetComponent <IHaveMass>();
         IHaveBiteSize _bite = GetComponent <IHaveBiteSize>();
         if (_mass != null)
         {
             if (_bite != null)
             {
                 if (_mass.Mass - _bite.BiteSize > 0)
                 {
                     _mass.Mass -= _bite.BiteSize;
                     IConsume _consumeFood = GetComponent <IConsume>();
                     if (_consumeFood != null)
                     {
                         _consumeFood.IAddFood(_bite.BiteSize);
                     }
                 }
                 else
                 {
                     IConsume _consumeFood = GetComponent <IConsume>();
                     if (_consumeFood != null)
                     {
                         _consumeFood.IAddFood(_mass.Mass);
                         EvaluateSurroundings _surroundings = GetComponent <EvaluateSurroundings>();
                         if (_surroundings != null)
                         {
                             _surroundings.CheckDetectedCreature(target, false);
                         }
                     }
                     _mass.Mass = 0;
                 }
             }
         }
     }
 }
예제 #5
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;
        }
    }