예제 #1
0
    void Update()
    {
        timeSinceLastSearch += Time.deltaTime;
        if (timeSinceLastSearch > timeToWaitTillSearch)
        {
            GOPhantom           = GameObject.FindGameObjectsWithTag("Enemy");
            timeSinceLastSearch = 0.0f;
        }


        for (int i = 0; i < GOPhantom.Length; ++i)
        {
            EntityPhantom  = GOPhantom[i].GetComponent <Phantom>();
            VisiblePhantom = EntityPhantom.visibility;

            //CameraSettings.cullingMask = (1 << 9) | defaultCameraLayersActive;
            if (VisiblePhantom.agent > 0)
            {
                GOPhantom[i].layer = 8;
                if (VisiblePhantom.agent == Plasma.SeenBy.Agent.Translucent)
                {
                    GOPhantom[i].GetComponent <Renderer>().material = phantomMaterials.normal;
                }
                else
                {
                    GOPhantom[i].GetComponent <Renderer>().material = phantomMaterials.camera;
                }
            }
            else
            {
                GOPhantom[i].layer = 9;
            }
        }
    }
예제 #2
0
    public void OnPreRender()
    {
        //Profiling.Profiler.BeginSample ("MyPieceOfCode");
        //GOAgentMesh = GameObject.Find("agent_Mesh");

        timeSinceLastSearch += Time.deltaTime;
        if (timeSinceLastSearch > timeToWaitTillSearch)
        {
            GOAgent             = GameObject.FindGameObjectWithTag("Player");
            GOPhantom           = GameObject.FindGameObjectsWithTag("Enemy");
            timeSinceLastSearch = 0.0f;
        }

        if (GOAgent != null)
        {
            //EntityAgent = GOAgent.GetComponentInChildren<Agent>();
            //VisibleAgent = EntityAgent.visibility;
        }
        for (int i = 0; i < GOPhantom.Length; ++i)
        {
            if (GOPhantom[i] == null)
            {
                Debug.Log("Phantom is null\nRebuilding Phantom List");
                GOPhantom = GameObject.FindGameObjectsWithTag("Enemy");
            }
            //Debug.Log("Phantom #" + i + " Of " + GOPhantom.Length);
            //if(GOPhantom[i] != null && GOPhantom[i].GetComponent<Phantom>() != null)
            //{
            //
            //}
        }


        //Camera Layers

        // 08	EnemyVisible
        // 09	Enemy
        // 10	EnemyThermal
        // 11	EnemySonar

        // Default Camera Layers get added with different layer depending on camera active

        /*
         *      Set Materials for Agent and Phantom next
         */
        for (int i = 0; i < GOPhantom.Length; ++i)
        {
            VisiblePhantom = GOPhantom[i].GetComponent <Phantom>().visibility;

            if (Vision == HackerVisionMode.Normal || Vision == HackerVisionMode.Night)
            {
                if (GOAgent != null)
                {
                    Renderer[] agentRenderers = GOAgent.GetComponentsInChildren <Renderer>();           //.material = agentMaterials.camera;

                    //for (int c = 0; c < agentRenderers.Length; c++)
                    //{
                    //    if(agentRenderers[c].material != agentLaserMaterial)
                    //	    agentRenderers[c].material = agentMaterials.camera;
                    //}
                }

                CameraSettings.cullingMask = (1 << 9) | defaultCameraLayersActive;


                if (GOPhantom != null)
                {
                    if (VisiblePhantom.camera > 0)
                    {
                        GOPhantom[i].layer = 9;
                        if (VisiblePhantom.camera == Plasma.SeenBy.Camera.Translucent)
                        {
                            Renderer[] phantomRenderers = GOPhantom[i].GetComponentsInChildren <Renderer>();
                            for (int c = 0; c < phantomRenderers.Length; c++)
                            {
                                phantomRenderers[c].material = phantomMaterials.normal;
                            }
                        }
                        else
                        {
                            Renderer[] phantomRenderers = GOPhantom[i].GetComponentsInChildren <Renderer>();
                            for (int c = 0; c < phantomRenderers.Length; c++)
                            {
                                phantomRenderers[c].material = phantomMaterials.camera;
                            }
                        }
                    }
                    else
                    {
                        GOPhantom[i].layer = 12;
                    }
                }
            }
            else if (Vision == HackerVisionMode.Thermal)
            {
                if (GOAgent != null)
                {
                    //Renderer[] agentRenderers = GOAgent.GetComponentsInChildren<Renderer>();//.material = agentMaterials.camera;
                    //for(int c = 0; c < agentRenderers.Length; c++)
                    //{
                    //    if(agentRenderers[c].material != agentLaserMaterial)
                    //	    agentRenderers[c].material = agentMaterials.thermal;
                    //}
                }

                CameraSettings.cullingMask = (1 << 10) | defaultCameraLayersActive;

                if (GOPhantom != null)
                {
                    if (VisiblePhantom.thermal > 0)
                    {
                        GOPhantom[i].layer = 10;
                        if (VisiblePhantom.thermal == Plasma.SeenBy.Thermal.Visible)
                        {
                            Renderer[] phantomRenderers = GOPhantom[i].GetComponentsInChildren <Renderer>();
                            for (int c = 0; c < phantomRenderers.Length; c++)
                            {
                                phantomRenderers[c].material = phantomMaterials.thermal;
                            }
                        }
                    }
                    else
                    {
                        GOPhantom[i].layer = 12;
                    }
                }
            }
            else if (Vision == HackerVisionMode.Sonar)
            {
                if (GOAgent != null)
                {
                    //Renderer[] agentRenderers = GOAgent.GetComponentsInChildren<Renderer>();//.material = agentMaterials.camera;
                    //for(int c = 0; c < agentRenderers.Length; c++)
                    //{
                    //    if(agentRenderers[c].material != agentLaserMaterial)
                    //	    agentRenderers[c].material = agentMaterials.sonar;
                    //}
                }

                CameraSettings.cullingMask = (1 << 11) | defaultCameraLayersActive;


                if (GOPhantom != null)
                {
                    if (VisiblePhantom.sonar > 0)
                    {
                        GOPhantom[i].layer = 11;
                        if (VisiblePhantom.sonar == Plasma.SeenBy.Sonar.Visible)
                        {
                            Renderer[] phantomRenderers = GOPhantom[i].GetComponentsInChildren <Renderer>();
                            for (int c = 0; c < phantomRenderers.Length; c++)
                            {
                                phantomRenderers[c].material = phantomMaterials.sonar;
                            }
                        }
                    }
                    else
                    {
                        GOPhantom[i].layer = 12;
                    }
                }
            }
            else
            {
                GOPhantom[i].layer = 8;
            }
        }



        //_Light.enabled = true;

        if (Vision == HackerVisionMode.Night)
        {
            // If night vision is on, turn the ambient light up and store actual ambient light
            ambientLightTemp            = RenderSettings.ambientLight;
            RenderSettings.ambientLight = ambientLight;
        }

        if (Vision == HackerVisionMode.Thermal)
        {
            ambientLightTemp            = RenderSettings.ambientLight;
            RenderSettings.ambientLight = new Color(ambientLight.r * 0.135f, ambientLight.g * 0.135f, ambientLight.b * 0.135f);
        }

        if (Vision == HackerVisionMode.Normal)
        {
            Shader.SetGlobalFloat("_EmissionVisionMult", 0.0f);
        }
        else
        {
            Shader.SetGlobalFloat("_EmissionVisionMult", 10.0f);
        }

        //if (Vision == HackerVisionMode.Sonar)
        //{
        //    for (int i = 0; i < all_my_damn_lights.Length; ++i)
        //    {
        //        all_my_damn_lights[i].enabled = false;
        //    }
        //    //_Light.enabled = false;
        //}
        //else
        //{
        //    for (int i = 0; i < all_my_damn_lights.Length; ++i)
        //    {
        //        all_my_damn_lights[i].enabled = lightStatus[i];
        //    }
//
        //}

        //if (Vision == HackerVisionMode.Night)
        //{
        //    for (int i = 0; i < all_my_damn_lights.Length; ++i)
        //    {
        //        all_my_damn_lights[i].intensity = lightBrightness[i] * 4.0f;
        //    }
        //    //_Light.enabled = false;
        //}
        //else
        //{
        //    for (int i = 0; i < all_my_damn_lights.Length; ++i)
        //    {
        //        all_my_damn_lights[i].intensity = lightBrightness[i];
        //    }
//
        //}
    }