IEnumerator Start()
    {
        light2d = GetComponent <DynamicLight2D.DynamicLight>();
        if (light2d)
        {
            lastOffset = light2d.LightRadius;
        }

        if (pointLight)
        {
            lastRange = pointLight.range;
        }

        if (normalScalarObj)
        {
            lastScale = normalScalarObj.transform.localScale;
        }


        yield return(null);

        if (fireGO)
        {
            fireScale = fireGO.transform.localScale;
        }

        StartCoroutine(updateLoop());
    }
Ejemplo n.º 2
0
    void iSawAGhost(GameObject[] g, DynamicLight2D.DynamicLight light)
    {
        bool found = false;

        foreach (GameObject gs in g)
        {
            foreach (GameObject ghost in ghostInScene)
            {
                if (ghost.GetInstanceID() == gs.GetInstanceID())
                {
                    if (ghost.tag == "ghost")
                    {
                        //Debug.Log("find");
                        found = true;
                        shot(ghost);
                        break;
                    }
                }
            }
        }


        if (found == true)
        {
            vehicle.GetComponent <Renderer>().material.color = Color.red;
        }
    }
Ejemplo n.º 3
0
    IEnumerator convertToStaticLights()
    {
        GameObject[] lights = GameObject.FindGameObjectsWithTag("2ddl");

        for (int i = 1; i < casters.Length; i++)
        {
            // WARNING ! : First wait for render process
            // because _casters arrays is unfilled yet.
            yield return(new WaitForEndOfFrame());

            for (int j = 0; j < lights.Length; j++)
            {
                DynamicLight2D.DynamicLight dyn = lights[j].GetComponent <DynamicLight2D.DynamicLight>();


                //Push collider to the main array or vertices
                dyn.addColliderToScene(casters[i].GetComponent <BoxCollider2D>());
            }
        }

        yield return(null);

        //Rebuild Lights
        for (int j = 0; j < lights.Length; j++)
        {
            lights[j].GetComponent <DynamicLight2D.DynamicLight>().Rebuild();
        }

        yield return(null);

        StartCoroutine(FrameUpdate());
    }
Ejemplo n.º 4
0
    internal void OnEnable()
    {
        //serialtarget = new SerializedObject(target);
        light = target as DynamicLight2D.DynamicLight;

        version             = serializedObject.FindProperty("Version");
        lmaterial           = serializedObject.FindProperty("LightMaterial");
        lUseSolidColor      = serializedObject.FindProperty("SolidColor");
        lColor              = serializedObject.FindProperty("LightColor");
        radius              = serializedObject.FindProperty("LightRadius");
        segments            = serializedObject.FindProperty("Segments");
        range               = serializedObject.FindProperty("RangeAngle");
        layerm              = serializedObject.FindProperty("Layer");
        useEvents           = serializedObject.FindProperty("notifyGameObjectsReached");
        usePersistFOV       = serializedObject.FindProperty("objectsWithinSight");
        intelliderConvex    = serializedObject.FindProperty("intelliderConvex");
        staticScene         = serializedObject.FindProperty("staticScene");
        recalcNorms         = serializedObject.FindProperty("recalculateNormals");
        strokeRender        = serializedObject.FindProperty("strokeRender");
        debugLines          = serializedObject.FindProperty("debugLines");
        DDLEvent_OnEnterFOV = serializedObject.FindProperty("DDLEvent_OnEnterFOV");
        DDLEvent_OnExitFOV  = serializedObject.FindProperty("DDLEvent_OnExitFOV");
        DDLEvent_InsideFOV  = serializedObject.FindProperty("DDLEvent_InsideFOV");


        // Bounds
        getLightBounds();

        Undo.undoRedoPerformed += refreshLightObject;

        _path = EditorUtils.getMainRelativepath();
    }
Ejemplo n.º 5
0
 void Start()
 {
     // Load into array all gameobjects with '2ddl' tag
     casters = GameObject.FindGameObjectsWithTag("2ddl");
     // instantiate a dynamicLight component from SceneLight GameObject
     dl = SceneLight.GetComponent <DynamicLight2D.DynamicLight>();
 }
    void checkWaveReach(GameObject[] allObstacles, DynamicLight2D.DynamicLight light)     //zxc
    {
        found1 = false;
        found2 = false;
        found3 = false;

        foreach (GameObject gs in allObstacles)
        {
            if (traesure1.GetHashCode() == gs.GetHashCode())
            {
                found1 = true;
            }
            if (traesure2.GetHashCode() == gs.GetHashCode())
            {
                found2 = true;
            }
            if (traesure3.GetHashCode() == gs.GetHashCode())
            {
                found3 = true;
            }
        }
        if (found1 && found2 && found3 && isGateOpen == false)
        {
            OpenThisGate();
            Debug.Log("yeahh");
        }
    }
        private static void drawGizmoNow(DynamicLight dl, GizmoType gizmoType)
        {
            PostProcessMethods.checkIconTexture();

            PostProcessMethods.SyncWithPhysics2D();              // check auto sync field from Physics2D property

            Gizmos.DrawIcon(dl.transform.position, "logo2DDL_gizmos.png", false);
        }
Ejemplo n.º 8
0
 void OnExitSunLight(GameObject g, DynamicLight2D.DynamicLight light)
 {
     if (gameObject.GetInstanceID() == g.GetInstanceID())
     {
         //GetComponent<SpriteRenderer>().color = Color.white;
         m_anim.SetBool("beLighted", false);
     }
 }
 void onEnter(GameObject g, DynamicLight2D.DynamicLight light)
 {
     if (gameObject.GetInstanceID() == g.GetInstanceID())
     {
         Debug.Log("OnEnter");
         speed = 0.08f;
     }
 }
Ejemplo n.º 10
0
 private void AttackFinish(GameObject go, DynamicLight2D.DynamicLight Light)
 {
     if (go.transform.CompareTag("Player"))
     {
         mIsInside    = false;
         mIsAttacking = false;
     }
 }
Ejemplo n.º 11
0
 public void OnEnterSunLight(GameObject g, DynamicLight2D.DynamicLight light)//见到阳光
 {
     if (gameObject.GetInstanceID() == g.GetInstanceID())
     {
         //GetComponent<SpriteRenderer>().color = Color.red;
         burnTime = Time.time;//开始计时
         m_anim.SetBool("beLighted", true);
     }
 }
Ejemplo n.º 12
0
    void Start()
    {
        dl = GetComponent <DynamicLight2D.DynamicLight>();
        //lastOffset = dl.LightRadius;
        _initUVScale = dl.uv_Scale;
        _initPos     = transform.position;
        _deltaPos    = _initPos;

        StartCoroutine(updateLoop());
    }
Ejemplo n.º 13
0
    static void Create()
    {
        reloadAsset();
        //Debug.Log (tmpAsset);
        GameObject gameObject = new GameObject("2DLight");

        DynamicLight2D.DynamicLight dl = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
        dl.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
        dl.Version     = AssetUtility.LoadProperty("version", tmpAsset);
    }
Ejemplo n.º 14
0
        static void addRadialNoMat()
        {
            folderPath = DynamicLight2D.EditorUtils.getMainRelativepath();

            //Object prefab = AssetDatabase.LoadAssetAtPath(folderPath + "Prefabs/Lights/2DPointLight.prefab", typeof(GameObject));
            GameObject hex = new GameObject("Light2D");             //Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;

            light                  = hex.AddComponent <DynamicLight>();
            light.layer            = 255;
            hex.transform.position = new Vector3(0, 0, 0);
        }
Ejemplo n.º 15
0
        private static void drawGizmoNow(DynamicLight dl, GizmoType gizmoType)
        {
            PostProcessMethods.checkIconTexture();

            //Texture2D t = AssetDatabase.LoadAssetAtPath(EditorUtils.getMainRelativepath() + "2DLight/Misc/logo2DDL_gizmos.png", typeof(Texture2D)) as Texture2D;

            //Debug.Log(EditorUtils.getMainRelativepath() + "2DLight/Misc/logo2DDL_gizmos.png");
            //float v = 0.08f;// Camera.current.orthographicSize * .003f;
            Gizmos.DrawIcon(dl.transform.position, "logo2DDL_gizmos.png", false);
            //Gizmos.DrawGUITexture(new Rect(dl.transform.position.x - t.width*.5f * v, dl.transform.position.y + t.height*.5f * v, t.width * v, -1*t.height * v), t);
        }
Ejemplo n.º 16
0
    void onEnter(GameObject g, DynamicLight2D.DynamicLight light)
    {
        print("GameObject onEnter :" + gameObject.name + "  " + "onEnter :" + g.name);

        if (g.transform.root.gameObject == Player || g.transform.root.gameObject == PuckBall)
        {
            GameManager._instance.ReStart();

            return;
        }
    }
Ejemplo n.º 17
0
        public void OcclusionEventsDelegate_OnInside(GameObject [] go, DynamicLight light)
        {
            text = "Boxes Revealed: ";
            for (int i = 0; i < go.Length; i++)
            {
                text = System.String.Join(" ", new string[] { text, go[i].name });
                //text += go[i].name;
            }

            status.text = text;
        }
Ejemplo n.º 18
0
        static void addPseudo()
        {
            folderPath = DynamicLight2D.EditorUtils.getMainRelativepath();

            Object     prefab = AssetDatabase.LoadAssetAtPath(folderPath + "Prefabs/Lights/2DPseudoSpotLight.prefab", typeof(GameObject));
            GameObject hex    = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;

            hex.transform.position = new Vector3(0, 0, 0);
            hex.name = "2DRadialGradientPoint";
            light    = hex.GetComponent <DynamicLight>();
            //light.layer = 255;
        }
Ejemplo n.º 19
0
        static void addRadialGradient()
        {
            folderPath = DynamicLight2D.EditorUtils.getMainRelativepath();

            Material   mate = AssetDatabase.LoadAssetAtPath(folderPath + "Materials/LightMaterialGradient.mat", typeof(Material)) as Material;
            GameObject hex  = new GameObject("Light2D");            //Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;

            light                  = hex.AddComponent <DynamicLight>();
            light.layer            = 255;
            hex.transform.position = new Vector3(0, 0, 0);
            light.lightMaterial    = mate;
        }
Ejemplo n.º 20
0
    static void addSpotIlum()
    {
        reloadAsset();
        Object     prefab = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/2DDL-Spot2DWithIlumination.prefab", typeof(GameObject));
        GameObject hex    = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;

        hex.transform.position = new Vector3(5, 0, 0);
        DynamicLight2D.DynamicLight s = hex.GetComponent <DynamicLight2D.DynamicLight>();
        s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
        s.Version     = AssetUtility.LoadProperty("version", tmpAsset);
        hex.name      = "2DDL-Point2DLightWithIlumination";
    }
Ejemplo n.º 21
0
    static void addGradient()
    {
        reloadAsset();
        Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Materials/StandardLightMaterialGradient.mat", typeof(Material)) as Material;
        GameObject gameObject = new GameObject("2DLight");

        DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
        s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
        s.Version     = AssetUtility.LoadProperty("version", tmpAsset);
        s.setMainMaterial(m);
        s.Rebuild();
    }
Ejemplo n.º 22
0
        internal void OnEnable()
        {
            light = target as DynamicLight;

            version   = serializedObject.FindProperty("version");
            lmaterial = serializedObject.FindProperty("lightMaterial");
            radius    = serializedObject.FindProperty("lightRadius");
            segments  = serializedObject.FindProperty("lightSegments");
            layer     = serializedObject.FindProperty("layer");

            adCount = Random.Range(0, 7);
        }
Ejemplo n.º 23
0
    void Start()
    {
        // Find and set 2DLight Object //
        light2d = GameObject.Find("2DLight").GetComponent <DynamicLight2D.DynamicLight>() as DynamicLight2D.DynamicLight;

        // Find and set text obj //
        text = GameObject.Find("text").GetComponent <TextMesh>();

        // Add listeners
        light2d.InsideFieldOfViewEvent += waveReach;
        light2d.OnExitFieldOfView      += onExitCaster;
        light2d.OnEnterFieldOfView     += onEnterCaster;
    }
Ejemplo n.º 24
0
    void Start()
    {
        if (HeroGO)
        {
            heroLastPos = (Vector2)HeroGO.transform.position;
        }

        if (GO2ddl)
        {
            lit = GO2ddl.transform.FindChild("2DLight").GetComponent <DynamicLight2D.DynamicLight>();
        }

        resetDelta();
    }
Ejemplo n.º 25
0
    static void addTexturized()
    {
        reloadAsset();
        Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardLightTexturizedMaterial.mat", typeof(Material)) as Material;
        GameObject gameObject = new GameObject("2DLight");

        DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
        s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
        s.SolidColor  = true;
        s.LightColor  = Color.red;
        s.setMainMaterial(m);
        s.Version = AssetUtility.LoadProperty("version", tmpAsset);
        s.Rebuild();
    }
Ejemplo n.º 26
0
    //- this function iterate on each object passed by 2DLigh script and compare if this object is the desired object Lit.
    //-- THIS SCRIPT MUST BE ATTACHED TO PLAYER GO --//

    void waveReach(GameObject g, DynamicLight2D.DynamicLight light)
    {
        bool found = false;


        if (gameObject.GetHashCode() == g.GetHashCode())
        {
            found = true;
        }
        if (found == true && isGateOpen == false)
        {
            OpenThisGate();
        }
    }
Ejemplo n.º 27
0
    IEnumerator Start()
    {
        // Find and set 2DLight Object //
        light2d = GameObject.Find("2DLight").GetComponent <DynamicLight2D.DynamicLight>() as DynamicLight2D.DynamicLight;


        // Add listeners

        light2d.OnExitFieldOfView  += onExit;
        light2d.OnEnterFieldOfView += onEnter;

        yield return(new WaitForEndOfFrame());

        StartCoroutine(loop());
    }
Ejemplo n.º 28
0
        static void addSpot()
        {
            reloadAsset();
            Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardLightMaterialGradient.mat", typeof(Material)) as Material;
            GameObject gameObject = new GameObject("2DLight");

            gameObject.transform.position = getCameraPos();
            DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
            s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
            s.Version     = AssetUtility.LoadProperty("version", tmpAsset);
            s.setMainMaterial(m);
            s.Rebuild();
            s.Segments    = 9;
            s.RangeAngle  = 90;
            s.SortOrderID = -1;
        }
Ejemplo n.º 29
0
        // Update is called once per frame
        IEnumerator LoopUpdate()
        {
            while (true)
            {
                //cLight = GameObject.Find("2DLight");
                //if(Input.GetAxis("Horizontal")){
                //light.transform.position = new Vector3 (Input.mousePosition.x -Screen.width*.5f, Input.mousePosition.y -Screen.height*.5f);
                Vector3 pos = cLight.transform.position;
                pos.x += Input.GetAxis("Horizontal") * 30f * Time.deltaTime;
                pos.y += Input.GetAxis("Vertical") * 30f * Time.deltaTime;



                if (_mouseClick)
                {
                    Vector2 p = cam.ScreenToWorldPoint(Input.mousePosition);

                    if (_ctrlDown == true)
                    {
                        _2ddl   = cLight.GetComponent <DynamicLight>();
                        __layer = _2ddl.layer;
                        Material m = new Material(_2ddl.lightMaterial as Material);


                        GameObject nLight = new GameObject();
                        nLight.transform.parent = cLight.transform;

                        _2ddl = nLight.AddComponent <DynamicLight>();
                        //m.color = new Color(Random.Range(0f,1f),Random.Range(0f,1f),Random.Range(0f,1f));
                        _2ddl.lightMaterial       = m;
                        nLight.transform.position = p;
                        _2ddl.lightRadius         = 40;
                        _2ddl.layer = __layer;

                        GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
                        quad.transform.parent        = nLight.transform;
                        quad.transform.localPosition = Vector3.zero;
                        lightCount++;
                    }
                }


                yield return(new WaitForEndOfFrame());

                cLight.transform.position = pos;
            }
        }
Ejemplo n.º 30
0
        static void addTexturized2()
        {
            reloadAsset();
            Material   m          = AssetDatabase.LoadAssetAtPath(_path + "Prefabs/Lights/Materials/StandardLightTexturizedMaterialBlend.mat", typeof(Material)) as Material;
            GameObject gameObject = new GameObject("2DDLight");

            gameObject.transform.position = getCameraPos();
            DynamicLight2D.DynamicLight s = gameObject.AddComponent <DynamicLight2D.DynamicLight>();
            s.Layer.value = AssetUtility.LoadPropertyAsInt("layerMask", tmpAsset);
            s.SolidColor  = true;
            s.LightColor  = Color.red;
            s.uv_Scale    = new Vector3(.38f, .38f);
            s.SortOrderID = -1;
            s.setMainMaterial(m);
            s.Version = AssetUtility.LoadProperty("version", tmpAsset);
            s.Rebuild();
        }