Example #1
0
    public void AttempCoupling()
    {
        Vector2      direction = PhysicsU.Dir2Vec(dir);
        RaycastHit2D hit       = Physics2D.Raycast(transform.position, PhysicsU.Dir2Vec(dir), 0.2f, layerMask.value);

        if (!hit)
        {
            return;
        }
        if (hit.collider.gameObject == gameObject)
        {
            return;
        }

        GameObject    Anchor        = hit.collider.gameObject;
        Anchor_script anchor_script = Anchor.GetComponent <Anchor_script>();

        //check if Raycast hit foreign organism
        if (anchor_script.cell.GetComponent <Cell_script>().GetOrganism() != cell.GetComponent <Cell_script>().GetOrganism())
        {
            return;
        }

        Couple(Anchor);
    }
Example #2
0
    private void PopulateCellMatrix(ref CellType[,] CellMatrix)
    {
        List <Gene> Genes = DNA.GetGenes();

        Point pos = BaseU.GetMatrixMid(CellMatrix);

        foreach (Gene gene in Genes)
        {
            CellType            type   = gene.GetCellType();
            PhysicsU.Directions dir    = gene.GetDirection();
            Vector2             dirVec = PhysicsU.Dir2Vec(dir);

            pos.x += (int)dirVec.x;
            pos.y += (int)dirVec.y;

            pos.x = MathU.MinMax(pos.x, 0, CellMatrix.GetLength(0) - 1);
            pos.y = MathU.MinMax(pos.y, 0, CellMatrix.GetLength(1) - 1);

            CellMatrix[pos.x, pos.y] = type;
        }
    }