예제 #1
0
    void Update()
    {
        // !!!!! 짧은 게임 이 기 에 performance 걱정없이 고!
        BallController playingController = null;
        BallController cameraController  = null;

        foreach (BallController controller in ballControllers)
        {
            if (controller.isPlaying)
            {
                playingController = controller;
            }
            else
            {
                cameraController = controller;
            }
        }

        if (playingController && cameraController)
        {
            //Debug.Log ("playingController");

            float clr_r = Mathf.Lerp(1f, 0f, Mathf.InverseLerp(0.6f, 1f, playingController.CheckAngle(cameraController)));
            float clr_g = Mathf.Lerp(0f, 1f, Mathf.InverseLerp(0.6f, 1f, playingController.CheckAngle(cameraController)));
            float clr_b = Mathf.Lerp(0.2f, 0.2f, Mathf.InverseLerp(0.6f, 1f, playingController.CheckAngle(cameraController)));

            //Debug.Log (Mathf.InverseLerp (-1f, 1f, playingController.CheckAngle (cameraController)));

            playingController.Lens.material.SetColor("_Color", new Color(clr_r, clr_g, clr_b));
            playingController.Lens.material.SetColor("_EmissionColor", new Color(clr_r, clr_g, clr_b));
        }
    }
예제 #2
0
    IEnumerator Coroutine_ChangeCam()
    {
        int tickCount = 0;         // 혹시 몰라서 저장

        while (true)
        {
            if (isGameOver == true)
            {
                break;
            }

            playingTime += Time.deltaTime;
            int minutes      = (int)(playingTime / 60);
            int seconds      = (int)(playingTime - minutes * 60);
            int milliseconds = (int)((playingTime - minutes * 60 - seconds) * 1000);
            if (playingTimeText != null)
            {
                playingTimeText.text = string.Format("{0:D2}:{1:D2}.{2:D3}", minutes, seconds, milliseconds);
            }

            if (playingTime > (tickCount + 1) * timer - pretimer)
            {
                StartWarningVisualFeedBack();
            }

            if (Input.GetKey(KeyCode.Space) == true)
            {
                resetTimer += Time.deltaTime;
                if (resetTimer >= 1.5f)
                {
                    if (tutoriallvl1)
                    {
                        tutoriallvl1played = true;
                        tutoriallvl1.SetActive(false);
                    }
                    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
                }
            }
            else
            {
                resetTimer = 0;
            }

            if (resetTimer > 0)
            {
                resetTimerImage.gameObject.SetActive(true);
                resetTimerImage.rectTransform.localScale = new Vector3(Mathf.Clamp01(resetTimer / 1.5f), 1, 1);
            }
            else
            {
                resetTimerImage.gameObject.SetActive(false);
            }

            if (playingTime > (tickCount + 1) * timer)
            {
                ChangeCam();
                tickCount++;
            }

            // Angle 검사
            BallController playingController = null;
            BallController cameraController  = null;
            foreach (BallController controller in ballControllers)
            {
                if (controller.isPlaying)
                {
                    playingController = controller;
                }
                else
                {
                    cameraController = controller;
                }
            }
            // 대략 0.8 이상 정도면 보인다고 생각하면 될 듯
            audioSource.volume = Mathf.Max(0, (playingController.CheckAngle(cameraController) - 0.6f) * 2.5f);

            if (cameraController.CheckAngle(playingController) < 0.7f && playingController.CheckAngle(cameraController) < 0.7f)
            {
                Instruction_ISeeYou.Instance.Show();
                recommendRestart += Time.deltaTime;
            }
            else
            {
                Instruction_ISeeYou.Instance.Hide();
                recommendRestart = 0;
            }

            yield return(null);
        }
    }