예제 #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (creators.ContainsKey(other.tag))
        {
            Vector3 position = other.gameObject.transform.position;

            GameObject creator = creators [other.tag];
            creator.GetComponent <CreatorScript> ().create(position);

            BackgroundElementScript script = other.gameObject.GetComponent <BackgroundElementScript> ();

            if (script.canBeDeleted)
            {
                Destroy(script.mirrored);
                Destroy(other.gameObject);
            }
        }
        else if (other.tag == "backgroundElement")
        {
            BackgroundElementScript script = other.gameObject.GetComponent <BackgroundElementScript> ();

            if (script.canBeDeleted)
            {
                Destroy(script.mirrored);
                Destroy(other.gameObject);
            }
        }
    }
예제 #2
0
    public static GameObject CreateMirrored(GameObject toMirror)
    {
        BackgroundElementScript backgroundElement = toMirror.GetComponent <BackgroundElementScript> ();

        GameObject patternObject = null;

        if (backgroundElement.mirrored)
        {
            patternObject = backgroundElement.mirrored;
        }
        else
        {
            patternObject = toMirror;
        }

        Vector3    mirrroredPosition = new Vector3(toMirror.transform.position.x, -toMirror.transform.position.y, toMirror.transform.position.z);
        GameObject mirrored          = cloneGameObject(patternObject, mirrroredPosition);

        mirrored.transform.localScale = new Vector3(mirrored.transform.localScale.x, -1f, mirrored.transform.localScale.z);
        toMirror.GetComponent <BackgroundElementScript> ().mirrored = mirrored;
        return(mirrored);
    }