Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f);
            for (var r = 0; r < hitInfo.Length; r++)
            {
                if (hitInfo[r].collider != null)
                {
                    if (hitInfo[r].collider.gameObject.name == "sOn")

                    {
                        GameVar.sound = true;
                        GameVar.SaveOptions();
                    }
                    if (hitInfo[r].collider.gameObject.name == "sOff")

                    {
                        GameVar.sound = false;
                        GameVar.SaveOptions();
                    }
                    if (hitInfo[r].collider.gameObject.name == "mOn")

                    {
                        GameVar.music = true;
                        GameVar.SaveOptions();
                    }
                    if (hitInfo[r].collider.gameObject.name == "mOff")

                    {
                        GameVar.music = false;
                        GameVar.SaveOptions();
                    }
                }

                ChangeOpacity();
            }
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f);
            for (var r = 0; r < hitInfo.Length; r++)
            {
                if (hitInfo[r].collider != null)
                {
                    if (hitInfo[r].collider.gameObject.name == "ResumeGame")
                    {
                        goBack();
                    }
                    if (hitInfo[r].collider.gameObject.name == "RestartLevel")
                    {
                        GameObject   instance = Instantiate(Resources.Load("WeaponSelectPrefab", typeof(GameObject))) as GameObject;
                        WeaponSelect ws       = instance.gameObject.GetComponentInChildren <WeaponSelect>();
                        ws.map = false;
                        Destroy(gameObject);
                        //SceneManager.LoadScene(1);
                    }
                    if (hitInfo[r].collider.gameObject.name == "ReturnToMap")
                    {
                        SceneManager.LoadScene(2);
                        MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>();
                        mp.ChangeSong = true;
                        mp.nextSong   = 0;
                    }
                    if (hitInfo[r].collider.gameObject.name == "gOn")

                    {
                        GameVar.graphics = true;
                    }
                    else if (hitInfo[r].collider.gameObject.name == "gOff")

                    {
                        GameVar.graphics = false;
                    }
                    if (hitInfo[r].collider.gameObject.name == "sOn")

                    {
                        GameVar.sound = true;
                        GameVar.SaveOptions();
                    }
                    if (hitInfo[r].collider.gameObject.name == "sOff")

                    {
                        GameVar.sound = false;
                        GameVar.SaveOptions();
                    }
                    if (hitInfo[r].collider.gameObject.name == "mOn")

                    {
                        MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>();
                        mp.MusicOn();
                        GameVar.music = true;
                        GameVar.SaveOptions();
                    }
                    if (hitInfo[r].collider.gameObject.name == "mOff")

                    {
                        MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>();
                        mp.MusicOff();
                        GameVar.music = false;
                        GameVar.SaveOptions();
                    }
                    if (hitInfo[r].collider.gameObject.name == "Back")

                    {
                        goBack();
                    }
                }
                ChangeOpacity();
            }
        }
    }