Ejemplo n.º 1
0
    public static Atom Create(Vector3 pos, Agent agent, Enums.Direction parent, AtomDetails details)
    {
        GameObject gameObject = CreateShape(details.shape, agent);
        Atom       atom       = gameObject.AddComponent <Atom>();
        Rigidbody  rb         = gameObject.AddComponent <Rigidbody>();

        atom.Create(agent, rb, pos, parent, details);

        return(atom);
    }
Ejemplo n.º 2
0
    private void CreateBasicAgent()
    {
        center = new Vector3(4, 4, 4);
        Atom atom = Atom.Create(center, this);

        atoms[4, 4, 4] = atom;
        atoms[4, 4, 4].AddChild(Enums.Direction.Aft);

        atoms[4, 4, 3] = Atom.CreateRandom(new Vector3(4, 4, 3), this, Enums.Direction.Fore);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Create the base atom with no motion
    /// </summary>
    /// <param name="pos">index in the atoms array of where to spawn the atom</param>
    /// <returns>The newly generated atom attached to a gameobject</returns>
    public static Atom Create(Vector3 pos, Agent agent)
    {
        Enums.Shape shape      = Enums.Shape.Cube;
        GameObject  gameObject = CreateShape(shape, agent);

        Atom      atom = gameObject.AddComponent <Atom>();
        Rigidbody rb   = gameObject.AddComponent <Rigidbody>();

        rb.useGravity = false;

        AtomDetails details = new AtomDetails(shape, Enums.Motion.None);

        atom.Create(agent, rb, pos, Enums.Direction.None, details);

        return(atom);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Create a new atom with random properties.
    /// </summary>
    /// <param name="pos">index in the atoms array of where to spawn the atom</param>
    /// <returns>The newly generated atom attached to a gameobject</returns>
    public static Atom CreateRandom(Vector3 pos, Agent agent, Enums.Direction parent)
    {
        Enums.Shape shape      = Enums.GetRandomShape();
        GameObject  gameObject = CreateShape(shape, agent);

        Enums.Motion motion = Enums.GetRandomMotion();

        Atom      atom = gameObject.AddComponent <Atom>();
        Rigidbody rb   = gameObject.AddComponent <Rigidbody>();
        //rb.useGravity = false;

        AtomDetails details = new AtomDetails(shape, motion);

        atom.Create(agent, rb, pos, parent, details);

        return(atom);
    }
Ejemplo n.º 5
0
    private void FromDetails(AtomDetails[,,] details, Vector3 here, Atom atom = null)
    {
        //Used for the initial case, creates the default starter atom
        if (atom == null)
        {
            atom = Atom.Create(here, this);
        }

        atom.details = details[(int)here.x, (int)here.y, (int)here.z];
        atoms[(int)here.x, (int)here.y, (int)here.z] = atom;
        for (int i = 0; i < atom.details.children.Length; i++) //create the children
        {
            if (atom.details.children[i])
            {
                Enums.Direction direction = (Enums.Direction)(i + 1);
                Vector3         pos       = Enums.InDirection(here, direction);
                Atom            child     = Atom.Create(pos, this, Enums.Reverse(direction), details[(int)pos.x, (int)pos.y, (int)pos.z]);
                atoms[(int)pos.x, (int)pos.y, (int)pos.z] = child;
                FromDetails(details, pos, child);
            }
        }
    }