Esempio n. 1
0
    public GameObject CloneObject( Vector3 point, ObjectInfo placedObject, bool destroyOriginal )
    {
        if( placedObject.clonable ) {
            audio.PlayOneShot( audioClone );

            // Place the object
            GameObject tempObject = Instantiate( prefab[placedObject.prefabIndex], point - placedObject.GetAnchor(), placedObject.transform.rotation ) as GameObject;

            ObjectInfo tempOI = tempObject.GetComponent<ObjectInfo>();

            tempOI.SetIteration( placedObject.GetIteration() - 1 );

            if( destroyOriginal ) {
                audio.PlayOneShot( audioDestroy );
                Destroy( placedObject.gameObject );
            }

            if( LifeParticles != null )
                Instantiate( LifeParticles, tempObject.transform.position, Quaternion.identity );

            placedObject.Select( Vector3.zero );

            return tempObject;
        }

        return null;
    }