Example #1
0
    /*
     *  Request a new potential block. If position is occupied, it assign the new interface.
     *
     *  Returns: The Potential block
     */
    public PotentialBlock RequestPotentialBlock(Vector3 gridPosition, Block invoker, int face)
    {
        if (gridPosition.x < symmetryAxis.x)
        {
            return(null);
        }
        if (gridPosition.y < symmetryAxis.y)
        {
            return(null);
        }

        foreach (PotentialBlock p in potentialBlocks)
        {
            if (p.GridPosition == gridPosition)
            {
                Debug.Log("Found one");
                p.relativeBlocks[Complement(face)] = invoker;
                p.Interfaces[Complement(face)]     = invoker.interfaces[face];
                return(p);
            }
        }
        ;

        PotentialBlock newPotential = Instantiate(potentialPrimitive).GetComponent <PotentialBlock>();

        newPotential.transform.SetParent(transform);
        newPotential.Position = (gridPosition) * 0.16f;
        newPotential.relativeBlocks[Complement(face)] = invoker;
        newPotential.Interfaces[Complement(face)]     = invoker.interfaces[face];
        potentialBlocks.Add(newPotential);
        return(newPotential);
    }
Example #2
0
    public PotentialBlock RequestPotentialBlock(Vector3 gridPosition)
    {
        PotentialBlock newPotential = Instantiate(potentialPrimitive).GetComponent <PotentialBlock>();

        newPotential.transform.SetParent(transform);
        newPotential.Position = (gridPosition) * 0.16f;
        potentialBlocks.Add(newPotential);
        return(newPotential);
    }
Example #3
0
    public PotentialBlock RequestPotentialBlock(Vector3 gridPosition, Block[] relatedBlocks)
    {
        PotentialBlock newPotential = RequestPotentialBlock(gridPosition);

        for (int i = 0; i < 6; i++)
        {
            newPotential.relativeBlocks[i] = relatedBlocks[i];
            if (relatedBlocks[i] != null)
            {
                newPotential.interfaces[i] = relatedBlocks[i].interfaces[Complement(i)];
                relatedBlocks[i].relativePotentials[Complement(i)] = newPotential;
            }
        }

        return(newPotential);
    }
Example #4
0
 public void CloneAs(PotentialBlock potential)
 {
     Instantiate(gameObject, potential.Position, Quaternion.identity);
 }