예제 #1
0
    void CheckTile()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, -transform.up, out hit, 50, mask))
        {
            _tileData = hit.transform.GetComponent <IAmTile>();
            if (_tileData != null)
            {
                if (_plantStats != null)
                {
                    if (CheckAvailability(_tileData.Moisture, _plantStats.PrefGroundMoisture, _plantStats.GroundMoistureDifTol))
                    {
                        if (CheckAvailability(_tileData.Temperature, _plantStats.PrefTemperature, _plantStats.TemperatureDifTol))
                        {
                            if (transform != null)
                            {
                                GameObject _prefab = _plantStats.Prefab;
                                Vector3    offset  = new Vector3(0, 0.25f, 0);
                                SpawnPlant(_prefab, hit.point + offset);
                            }
                        }
                        else
                        {
                            SelfDestruct();
                        }
                    }
                    else
                    {
                        SelfDestruct();
                    }
                }
                else
                {
                    SelfDestruct();
                }
            }
            else
            {
                SelfDestruct();
            }
        }
        else
        {
            SelfDestruct();
        }
    }
예제 #2
0
    void CheckTile()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, -transform.up, out hit, 1, mask))
        {
            Debug.Log("hit tile");
            IAmTile _tileData = hit.transform.GetComponent <IAmTile>();
            if (_tileData != null)
            {
                if (_plantStats != null)
                {
                    if (CheckAvailability(_tileData.Moisture, _plantStats.PrefGroundMoisture, _plantStats.GroundMoistureDifTol))
                    {
                        if (CheckAvailability(_tileData.Temperature, _plantStats.PrefTemperature, _plantStats.TemperatureDifTol))
                        {
                            _memory._tileData = _tileData;
                        }
                    }
                }
            }
        }
    }
예제 #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;
        }
    }