public override OrigamiObject Add(OrigamiObject origamiObject)
 {
     if (origamiObject != null)
     {
         LinkedList <OrigamiObject> origamiObjectsToAdd = new LinkedList <OrigamiObject> ();
         if (origamiObject.GetType() == typeof(AssembledOrigamiObject))
         {
             foreach (OrigamiObject origObj in this.origamiObjects)
             {
                 origamiObjectsToAdd.AddLast(origObj);
             }
             this.destroy = true;
         }
         else
         {
             origamiObjectsToAdd.AddLast(origamiObject);
         }
         foreach (OrigamiObject origamiObjectToAdd in origamiObjectsToAdd)
         {
             this.origamiObjects.AddLast(origamiObjectToAdd);
             origamiObjectToAdd.transform.parent = this.transform;
             if (origamiObjectToAdd.GetBaseAnchorPoint() != null)
             {
                 this.origamiBaseObject = origamiObject;
             }
         }
     }
     return(this);
 }
Exemple #2
0
    public virtual OrigamiObject Add(OrigamiObject origamiObject)
    {
        if (origamiObject != null)
        {
            // Debug.Log (origamiObject.GetType ());
            if (origamiObject.GetType() == typeof(AssembledOrigamiObject))
            {
                return(origamiObject.Add(this));
            }
            else
            {
                Object obj = Resources.Load("AssembledOrigamiObject", typeof(GameObject));

                GameObject             gameObject             = Instantiate(obj) as GameObject;
                AssembledOrigamiObject assembledOrigamiObject = gameObject.GetComponent <AssembledOrigamiObject> ();
                assembledOrigamiObject.transform.parent = this.transform.parent;
                assembledOrigamiObject.Add(this);
                assembledOrigamiObject.Add(origamiObject);
                return(assembledOrigamiObject);
            }
        }
        return(null);
    }