예제 #1
0
 void finished()
 {
     Hpeffect.SetActive(false);
 }
예제 #2
0
    void OnTriggerEnter(Collider collision)
    {
        // Debug.Log(collision.gameObject.name);
        if (collision.gameObject.name == "Coin(Clone)")
        {
            Destroy(collision.gameObject);
            Instantiate(coinsound, UnityChanPosition, Quaternion.identity);
            coins_number++;

            Coin_save++;
            RealGold.GetComponent <Text>().text = Convert.ToString(Coin_save);
        }
        if (collision.gameObject.name == "MobileMaleFree1") //character boy
        {
            if (Time.timeScale == 1)
            {
                dialog.SetActive(true);
                Time.timeScale = 0;
                Debug.Log("8787878787777");
            }
        }
        else if (collision.gameObject.name == "Boxshelf" && SceneManager.GetActiveScene().name == "SceneMap")
        {
            PlayerPrefs.SetString("step", "1");

            SceneManager.LoadScene("SceneMap2");
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            this.transform.position = new Vector3(-11.77f, UnityChanPosition.y, -27.7f);
            this.transform.rotation = Quaternion.Euler(0f, 96.5f, 0f);
            MainCamera.GetComponent <Transform>().rotation    = this.transform.rotation;
            MainCamera.GetComponent <Transform>().eulerAngles = new Vector3(20.0f, MainCamera.GetComponent <Transform>().eulerAngles.y, MainCamera.GetComponent <Transform>().eulerAngles.z);

            UnityChanPosition  = this.GetComponent <Transform>().position;
            CameraFollowVector = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (collision.gameObject.name == "Boxshelf2" && SceneManager.GetActiveScene().name == "SceneMap")
        {
            PlayerPrefs.SetString("step", "1");

            SceneManager.LoadScene("SceneMap2");
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            this.transform.position = new Vector3(-13.5f, UnityChanPosition.y, 105.66f);
            this.transform.rotation = Quaternion.Euler(0f, 71f, 0f);
            MainCamera.GetComponent <Transform>().rotation    = this.transform.rotation;
            MainCamera.GetComponent <Transform>().eulerAngles = new Vector3(20.0f, MainCamera.GetComponent <Transform>().eulerAngles.y, MainCamera.GetComponent <Transform>().eulerAngles.z);

            UnityChanPosition  = this.GetComponent <Transform>().position;
            CameraFollowVector = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (collision.gameObject.name == "Boxshelf" && SceneManager.GetActiveScene().name == "SceneMap2")
        {
            PlayerPrefs.SetString("step", "1");
            SceneManager.LoadScene("SceneMap");
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            this.transform.position = new Vector3(-11.77f, UnityChanPosition.y, -27.7f);
            this.transform.rotation = Quaternion.Euler(0f, 96.5f, 0f);
            MainCamera.GetComponent <Transform>().rotation    = this.transform.rotation;
            MainCamera.GetComponent <Transform>().eulerAngles = new Vector3(20.0f, MainCamera.GetComponent <Transform>().eulerAngles.y, MainCamera.GetComponent <Transform>().eulerAngles.z);

            UnityChanPosition  = this.GetComponent <Transform>().position;
            CameraFollowVector = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (collision.gameObject.name == "Boxshelf2" && SceneManager.GetActiveScene().name == "SceneMap2")
        {
            PlayerPrefs.SetString("step", "1");
            SceneManager.LoadScene("SceneMap");
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            this.transform.position = new Vector3(-20.72f, UnityChanPosition.y, 109.82f);
            this.transform.rotation = Quaternion.Euler(0f, 144.77f, 0f);
            MainCamera.GetComponent <Transform>().rotation    = this.transform.rotation;
            MainCamera.GetComponent <Transform>().eulerAngles = new Vector3(20.0f, MainCamera.GetComponent <Transform>().eulerAngles.y, MainCamera.GetComponent <Transform>().eulerAngles.z);

            UnityChanPosition  = this.GetComponent <Transform>().position;
            CameraFollowVector = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (collision.gameObject.name == "goal1" || collision.gameObject.name == "goal2" || collision.gameObject.name == "goal3")
        {
            Success.SetActive(true);
            GetComponent <Animator>().Play("WIN00");
            WinSound.GetComponent <AudioSource>().Play();
            GameControl.GetComponent <AudioSource>().Stop();
            Time.timeScale = 0;
            CoinText.GetComponent <Text>().text = Convert.ToString(coins_number);

            double time = Time.realtimeSinceStartup - timeInit;
            if (time >= 60)
            {
                Debug.Log("Time: " + Math.Floor(time / 60) + "min" + Math.Floor(time % 60) + "sec");
                TimeText.GetComponent <Text>().text = Math.Floor(time / 60) + "min" + Math.Floor(time % 60) + "sec";
            }
            else
            {
                Debug.Log("Time: " + Math.Floor(time) + "sec");
                TimeText.GetComponent <Text>().text = Math.Floor(time) + "sec";
            }
        }
        else if (fireCollideDelay == -1 && (collision.gameObject.name == "Fire" || collision.gameObject.name == "Fire(Clone)"))
        {
            fireCollideDelay = fireImmuneFrame;
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            Debug.Log("on Fire!");
            if (hpcnt != -1)
            {
                hp[hpcnt--].gameObject.SetActive(false);
                Hpeffect.SetActive(true);
                this.Invoke("finished", 0.3f);
                FireAttackSound.GetComponent <AudioSource>().Play();
                GetComponent <Animator>().Play("DAMAGED00");
            }

            Vector3 firePosition = collision.gameObject.GetComponent <Transform>().position;
            Vector3 nextPosition = Vector3.LerpUnclamped(firePosition, this.transform.position, fireBounceDistance);
            //nextPosition.y = new Vector3(nextPosition.x, UnityChanPosition.y, nextPosition.z);
            nextPosition.y = UnityChanPosition.y;
            RaycastHit hitInfo;
            if (Physics.Linecast(this.transform.position, nextPosition, out hitInfo))
            {
                nextPosition = Vector3.LerpUnclamped(hitInfo.point, this.transform.position, fireWallMedium);
            }
            //this.transform.position = Vector3.LerpUnclamped(firePosition, this.transform.position, 2.5f);
            if (hpcnt == -1)
            {
                GetComponent <Animator>().Play("DAMAGED01");
                LoseSound.GetComponent <AudioSource>().Play();
                PlayerPrefs.SetString("step", "0");
                GameObject.Find("goal1").GetComponent <BoxCollider>().isTrigger = false;
                GameObject.Find("goal2").GetComponent <BoxCollider>().isTrigger = false;
                GameObject.Find("goal3").GetComponent <BoxCollider>().isTrigger = false;
                //string scene = SceneManager.GetActiveScene().name;
                GameObject.Destroy(GameObject.Find("Camera2"));
                GameObject.Destroy(GameObject.Find("VirtualJoystick"));
                GameObject.Destroy(GameObject.Find("VirtualJoystick (1)"));
                GameObject.Destroy(GameObject.Find("Coin"));
                GameObject.Destroy(GameObject.Find("FB"));
                GameObject.Destroy(GameObject.Find("unitychan"));
                GameObject.Destroy(GameObject.Find("Setting"));
                GameObject.Destroy(GameObject.Find("Pause"));
                GameObject.Destroy(GameObject.Find("GameController"));
                GameObject.Destroy(GameObject.Find("Cube"));
                GameObject.Destroy(GameObject.Find("Cube (1)"));
                SceneManager.LoadScene("SceneMenu");

                restart = true;
                hp[0].gameObject.SetActive(true);
                hp[1].gameObject.SetActive(true);
                hp[2].gameObject.SetActive(true);
                hpcnt          = 2;
                isStageStarted = false;
            }

            //this.transform.position = new Vector3(this.transform.position.x, UnityChanPosition.y, this.transform.position.z);
            this.transform.position = nextPosition;
            UnityChanPosition       = this.GetComponent <Transform>().position;
            CameraFollowVector      = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (!isStageStarted && collision.gameObject.name == "Stage1")
        {
            isStageStarted = true;
            Debug.Log("Stage 1 Start!!");
            coins_number = 0;
            GameControl.GetComponent <AudioSource>().clip = audios[1];
            GameControl.GetComponent <AudioSource>().Play();
            GameObject.Find("goal1").GetComponent <BoxCollider>().isTrigger = true;
            GameObject.Find("goal2").GetComponent <BoxCollider>().isTrigger = true;
            GameObject.Find("goal3").GetComponent <BoxCollider>().isTrigger = true;
            Vector3    fire1Position = new Vector3(46.77003f, -1.98f, 117.75f);
            GameObject fire1         = Instantiate(GameObject.Find("Fire"), fire1Position, GameObject.Find("Fire").GetComponent <Transform>().rotation);
            fire1.GetComponent <FireSpread>().spreadTimeSec = 5;
            fire1.GetComponent <FireSpread>().gapPixel      = 3;
            fire1.GetComponent <FireSpread>().setTime(Time.realtimeSinceStartup);
            fire1.GetComponent <FireSpread>().isTemplate = false;
            fire1.GetComponent <FireSpread>().isActive   = true;

            Vector3    fire2Position = new Vector3(-11.7f, -21.98f, 102.1f);
            GameObject fire2         = Instantiate(GameObject.Find("Fire"), fire2Position, GameObject.Find("Fire").GetComponent <Transform>().rotation);
            fire2.GetComponent <FireSpread>().spreadTimeSec = 5;
            fire2.GetComponent <FireSpread>().gapPixel      = 3;
            fire2.GetComponent <FireSpread>().setTime(Time.realtimeSinceStartup);
            fire2.GetComponent <FireSpread>().isTemplate = false;
            fire2.GetComponent <FireSpread>().isActive   = false;
            //GameObject.Find("Stage1").SetActive(false);
            timeInit = Time.realtimeSinceStartup;
        }
    }