Ejemplo n.º 1
0
    public TxAutotrophChrome2Stats Add(TxAutotrophChrome2AB other)
    {
        var result = new TxAutotrophChrome2Stats();

        for (int i = 0; i < TxAutotrophChrome2.LENGTH; i++)
        {
            result.total[i] = (total[i] + other.ValueA[i] + other.ValueB[i]);
        }
        return(result);
    }
Ejemplo n.º 2
0
    public TxAutotrophChrome2AB Copy()
    {
        var result = new TxAutotrophChrome2AB();

        for (int i = 0; i < TxAutotrophChrome2.LENGTH; i++)
        {
            result.ValueA[i] = ValueA[i];
            result.ValueB[i] = ValueB[i];
        }
        return(result);
    }
Ejemplo n.º 3
0
    public float DistanceSq(TxAutotrophChrome2AB other, float maxDistanceSq)
    {
        float sum = 0;

        for (int i = 0; i < TxAutotrophChrome2.LENGTH; i++)
        {
            var t = (ValueA[i] + ValueB[i]) - (other.ValueA[i] + other.ValueB[i]);
            sum += t * t;
        }
        var d = math.min(1, math.max(0, sum / maxDistanceSq));

        return(d);
    }
Ejemplo n.º 4
0
    public void InitialPlants(EntityManager em)
    {
        var bounds = environmentSettings[0].environmentConsts.bounds;
        var incrX  = (bounds.z - bounds.x - 1f) / initialGridSize.x;
        var incrY  = (bounds.w - bounds.y - 1f) / initialGridSize.x;

        for (float x = bounds.x + 0.5f; x < bounds.z - 0.5f; x += incrX)
        {
            for (float y = bounds.y + 0.5f; y < bounds.w - 0.5f; y += incrY)
            {
                var position = new Vector3(x, 0, y);
                position.y = TerrainValue(position, terrainHeight, environmentSettings[0].environmentConsts.bounds,
                                          environmentSettings[0].environmentConsts.terrainScale
                                          );

                var entity = em.CreateEntity();
                em.AddComponentData(entity, new RandomComponent {
                    random = new Random(random.NextUInt())
                });
                em.AddComponentData(entity, new TxAutotrophSprout {
                    location = position, energy = 5
                });

                var chrome1AB = txAutotrophChrome1Ab.RandomRange(ref random);
                em.AddComponentData(entity, chrome1AB);
                em.AddComponentData(entity, chrome1AB.GetChrome1W());
                var chrome2AB = new TxAutotrophChrome2AB();
                for (int j = 0; j < TxAutotrophChrome2.LENGTH; j++)
                {
                    chrome2AB.ValueA[j] = 50;
                    chrome2AB.ValueB[j] = 50;
                }
                em.AddComponentData(entity, chrome2AB);
                em.AddComponentData(entity,
                                    new TxAutotrophGamete {
                    isFertilized         = true,
                    txAutotrophChrome1AB = chrome1AB,
                    txAutotrophChrome2AB = chrome2AB
                });
            }
        }
    }