Exemplo n.º 1
0
    // The OnTriggerEnter function is called when the collider attached to this game object (whatever object the script is attached to) overlaps another collider set to be a "trigger"
    void OnTriggerEnter(Collider collider)
    {
        //Debug.Log(collider.name);

        // We want to check if the thing we're colliding with is a collectable, this will differentiate it from other trigger objects which we might add in the future
        if (collider.GetComponent <Key>() == key)
        {
            GameObject.Find("CenterLight(Clone)").GetComponent <Light>().intensity = 0.2f;
            mazeStruct.RemoveDoor();
            collider.gameObject.SetActive(false);
            lights.keyTime = 0;
            //print(skyboxMaterial.GetColor("_Tint"));
            skyboxMaterial.SetColor("_Tint", new Color32((byte)44, (byte)28, (byte)53, (byte)128));
            //gameObject.GetComponent<OVRPlayerController>().Acceleration = 0.3f;
            //gameObject.GetComponentInChildren<Light>().enabled = true;
            //gameObject.GetComponentInChildren<LightFlicker>().enabled = true;
            this.lamp.gameObject.SetActive(true);
            monster.Init(mazeStruct, cells, transform, mazeStruct.GetStartSphere());

            GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            sphere.transform.localScale    = new Vector3(96.8f, 96.8f, 96.8f);
            sphere.renderer.material       = new Material(Shader.Find("Transparent/Diffuse"));
            sphere.renderer.material.color = new Color(1, 1, 1, 0.8f);
        }
        if (collider.GetComponent <Lamp>() == lamp)
        {
            GameObject.Find("CenterLight(Clone)").GetComponent <Light>().intensity = 0.0f;
            collider.gameObject.SetActive(false);
            this.lantern.SetActive(true);
            Light[] l = this.lantern.GetComponentsInChildren <Light>();

            GameObject.Find("Sphere").renderer.material.color = new Color(0, 0, 0, .8f);

            foreach (Light light in l)
            {
                if (light.enabled == false)
                {
                    light.enabled = true;
                }
                if (light.type == LightType.Directional)
                {
                    light.transform.rotation = gameObject.transform.rotation;
                }
            }
        }
    }