コード例 #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
    public void CheckDetectedCreature(Transform _creature, bool _add)
    {
        if (_creature.gameObject == transform.root.gameObject)
        {
            return;
        }
        IAmCreature _ICreature = transform.parent.GetComponent <IAmCreature>();

        if (_ICreature != null)
        {
            if (myBiology != null)
            {
                //NEED TO CHECK FOODCHAIN RANK HERE
                if (myBiology.dietType == Biology.DietType.Carnivore)
                {
                    CarnivoreCreatureCheck(_creature, _add);
                }
                else if (myBiology.dietType == Biology.DietType.Herbivore)
                {
                    IAmPlant plantType = _creature.GetComponent <IAmPlant>();
                    if (plantType != null)
                    {
                        IPrefPlantType myPrefPlant = transform.parent.GetComponent <IPrefPlantType>();
                        if (myPrefPlant != null)
                        {
                            if (myPrefPlant.PrefPlant == plantType.PlantType)
                            {
                                if (_add)
                                {
                                    //Add To Primary List
                                    _memory.primaryPotentialPrey.Add(_creature);
                                }
                                else
                                {
                                    _memory.primaryPotentialPrey.Remove(_creature);
                                    if (_memory.lastSeenPreyLocations.Count < _memory.maxPreyLocations)
                                    {
                                        _memory.lastSeenPreyLocations.Add(_creature.position);
                                    }
                                    else
                                    {
                                        _memory.lastSeenPreyLocations.RemoveAt(0);
                                        _memory.lastSeenPreyLocations.Add(_creature.position);
                                    }
                                }
                            }
                            else
                            {
                                if (_add)
                                {
                                    //Add To Secondary List
                                    _memory.secondaryPotentialPrey.Add(_creature);
                                }
                                else
                                {
                                    _memory.secondaryPotentialPrey.Remove(_creature);
                                    if (_memory.lastSeenPreyLocations.Count < _memory.maxPreyLocations)
                                    {
                                        _memory.lastSeenPreyLocations.Add(_creature.position);
                                    }
                                    else
                                    {
                                        _memory.lastSeenPreyLocations.RemoveAt(0);
                                        _memory.lastSeenPreyLocations.Add(_creature.position);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #3
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;
        }
    }