Example #1
0
 // Use this for initialization
 void Start()
 {
     isOpened    = false;
     endingStart = GameObject.FindGameObjectWithTag("Ending").GetComponent <EndGameScript>();
 }
Example #2
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (m_disable)
        {
            return;
        }

        m_currentTransition += Time.deltaTime;

        if (m_currentTransition > m_transitionSpeed)
        {
            m_currentIndex      = m_nextIndex;
            m_nextIndex         = GetRandomIndex();
            m_currentTransition = 0.0f;

            if (m_nextIndex == m_currentIndex)
            {
                m_nextIndex++;
                if (m_nextIndex >= m_setOne.Count)
                {
                    m_nextIndex = 0;
                }
            }
        }

        m_currentPulse += Time.deltaTime * m_pulseSpeed;
        if (m_currentPulse > 1)
        {
            m_currentPulse = -1;
        }

        float lerpAmount = m_currentTransition / m_transitionSpeed;

        Color color1 = Color.Lerp(m_setOne[m_currentIndex], m_setOne[m_nextIndex], lerpAmount);
        Color color2 = Color.Lerp(m_setTwo[m_currentIndex], m_setTwo[m_nextIndex], lerpAmount);
        Color color3 = Color.Lerp(m_setThree[m_currentIndex], m_setThree[m_nextIndex], lerpAmount);


        RenderTexture temp1 = RenderTexture.GetTemporary(source.width, source.height);
        RenderTexture temp2 = RenderTexture.GetTemporary(source.width, source.height);

        Material mainScreenMaterial = passThroughMaterial;

        //Power level check
        if (m_power.CorePower.PowerLevel == 0)
        {
            mainScreenMaterial = blackMaterial;
        }
        else if (m_power.CorePower.PowerLevel == 1)
        {
            mainScreenMaterial = blackAndWhiteMaterial;
        }
        else if (m_power.CorePower.PowerLevel == 3)
        {
            mainScreenMaterial = funkyMaterial;
            funkyMaterial.SetColor("_Colour_One", color1);
            funkyMaterial.SetColor("_Colour_Two", color2);
            funkyMaterial.SetColor("_Colour_Three", color3);
        }
        Graphics.Blit(source, temp1, mainScreenMaterial);

        RenderTexture from = temp1;
        RenderTexture to   = temp2;

        Vector2 endPos = new Vector2();

        foreach (var point in m_effectPoints)
        {
            float radius = 0.15f;

            EndGameScript endGame = point.GetComponent <EndGameScript>();
            Powerball     ball    = point.GetComponent <Powerball>();
            if (endGame)
            {
                radius = 0.7f;

                //if (!m_endGame)
                //{
                //    continue;
                //}
            }
            else if (m_power.CorePower.PowerLevel == 0)
            {
                if (/*m_endGame || */ !ball || ball.Type != PowerType.Core || ball.State == BallState.Free)
                {
                    continue;
                }
            }

            Vector2 pos = Camera.main.WorldToScreenPoint(point.gameObject.transform.position);
            pos.x = pos.x / source.width;
            pos.y = pos.y / source.height;

            if (endGame)
            {
                endPos = pos;
            }

            if ((pos.x > -1 || pos.x < 2) && (pos.y > -1 || pos.y < 2))
            {
                radius = radius * Mathf.Abs(m_currentPulse);

                Material mat = pointMultiColourMaterial;
                if (endGame || ball.Type == PowerType.Core)
                {
                    mat = pointMultiColourFunkyMaterial;
                    mat.SetColor("_Colour_One", color2);
                    mat.SetColor("_Colour_Two", color3);
                    mat.SetColor("_Colour_Three", color1);
                }

                mat.SetTexture("_OriginalTex", source);
                mat.SetFloat("_radius", radius);
                mat.SetVector("_point", pos);
                Graphics.Blit(from, to, mat);
                RenderTexture t = to;
                to   = from;
                from = t;
            }
        }



        if (m_finished)
        {
            m_power.gameObject.SetActive(false);
            m_finishedTime += Time.deltaTime;
            finishedMaterial.SetTexture("_OriginalTex", source);
            finishedMaterial.SetFloat("_time", m_finishedTime);
            finishedMaterial.SetVector("_point", endPos);
            Graphics.Blit(from, to, finishedMaterial);
            RenderTexture t = to;
            to   = from;
            from = t;

            if (m_finishedTime > 25.0f)
            {
                SceneManager.LoadScene("End", LoadSceneMode.Single);
            }
        }



        Graphics.Blit(from, destination, passThroughMaterial);

        RenderTexture.ReleaseTemporary(temp1);
        RenderTexture.ReleaseTemporary(temp2);
    }
Example #3
0
 public void Setup(string currentItem, EndGameScript currentAnswerScrollList)
 {
     item             = currentItem;
     text.text        = item;
     answerScrollList = currentAnswerScrollList;
 }