Exemplo n.º 1
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource>();
        if (textScript.text == "")
        {
            audioSources[4].Play();
            Message msg = new Message();
            if (!secondTimeFlg)
            {
                msg.makeMessage(msg.getMessage(140));
            }
            else
            {
                msg.makeMessage(msg.getMessage(142));
            }
        }
        else
        {
            //Text Registeration
            audioSources[5].Play();
            DataPvP pvpScript = new DataPvP();

            if (!secondTimeFlg)
            {
                //Init Data Registration
                string userId   = PlayerPrefs.GetString("userId");
                string userName = textScript.text;
                pvpScript.InsertPvP(userId, userName);

                PlayerPrefs.SetString("PvPName", userName);
                PlayerPrefs.Flush();

                //Scene Change
                Application.LoadLevel("pvp");
            }
            else
            {
                //Second Time
                string userId   = PlayerPrefs.GetString("userId");
                string userName = textScript.text;
                pvpScript.UpdatePvPName(userId, userName);

                PlayerPrefs.SetString("PvPName", userName);
                PlayerPrefs.Flush();

                GameObject.Find("GameScene").GetComponent <PvPController>().myUserName = userName;

                GameObject.Find("myName").GetComponent <Text>().text = userName;
                touchBackObj.GetComponent <CloseOneBoard>().OnClick();

                //Change Rank
                PvPDataStore PvPDataStoreScript = GameObject.Find("PvPDataStore").GetComponent <PvPDataStore>();
                for (int i = 0; i < PvPDataStoreScript.Top10PtWeeklyUserIdList.Count; i++)
                {
                    if (userId == PvPDataStoreScript.Top10PtWeeklyUserIdList[i])
                    {
                        PvPDataStoreScript.Top10PtWeeklyNameList[i] = userName;
                    }
                }
                for (int j = 0; j < PvPDataStoreScript.Top3WinUserIdList.Count; j++)
                {
                    if (userId == PvPDataStoreScript.Top3WinUserIdList[j])
                    {
                        PvPDataStoreScript.Top3WinNameList[j] = userName;
                    }
                }
                for (int k = 0; k < PvPDataStoreScript.Top3HPUserIdList.Count; k++)
                {
                    if (userId == PvPDataStoreScript.Top3HPUserIdList[k])
                    {
                        PvPDataStoreScript.Top3HPNameList[k] = userName;
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    public void OnClick()
    {
        //SE
        sound = GameObject.Find("SEController").GetComponent <AudioSource> ();
        sound.PlayOneShot(sound.clip);

        bool tutorialDoneFlg = PlayerPrefs.GetBool("tutorialDoneFlg");

        //Under Button
        if (name == "Jinkei")
        {
            if (tutorialDoneFlg && Application.loadedLevelName != "tutorialMain")
            {
                Application.LoadLevel("hyojyo");
            }
            else
            {
                Application.LoadLevel("tutorialHyojyo");
            }
        }
        else if (name == "PvP")
        {
            /*
             * Message msg = new Message();
             * if (Application.systemLanguage != SystemLanguage.Japanese) {
             *  msg.makeMessage("PvP is Under Preparation");
             * }else {
             *  msg.makeMessage("PvP準備中");
             * }
             */


            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                //接続されていないときの処理
                Message msg = new Message();
                msg.makeMessage(msg.getMessage(5));
            }
            else
            {
                string PvPName = PlayerPrefs.GetString("PvPName");

                if (PvPName == "" || PvPName == null)
                {
                    //first time
                    GameObject panel      = GameObject.Find("Panel").gameObject;
                    string     pathOfBack = "Prefabs/Common/TouchBackForOne";
                    GameObject back       = Instantiate(Resources.Load(pathOfBack)) as GameObject;
                    back.transform.SetParent(panel.transform);
                    back.transform.localScale    = new Vector2(1, 1);
                    back.transform.localPosition = new Vector2(0, 0);
                    string     pathOfBoard = "Prefabs/PvP/FirstPvPBoard";
                    GameObject board       = Instantiate(Resources.Load(pathOfBoard)) as GameObject;
                    board.transform.SetParent(panel.transform);
                    board.transform.localScale    = new Vector2(1, 1);
                    board.transform.localPosition = new Vector2(0, 0);

                    back.GetComponent <CloseOneBoard>().deleteObj = board;
                    board.transform.FindChild("NoButton").GetComponent <AddHyourou>().touchBackObj = back;
                }
                else
                {
                    if (GameObject.Find("DataStore"))
                    {
                        DataPvP pvpScript = GameObject.Find("DataStore").GetComponent <DataPvP>();
                        pvpScript.UpdatePvP();
                    }
                    Application.LoadLevel("pvp");
                }
            }
        }
        else if (name == "Busyo")
        {
            if (tutorialDoneFlg && Application.loadedLevelName != "tutorialMain")
            {
                Application.LoadLevel("busyo");
            }
            else
            {
                Application.LoadLevel("tutorialBusyo");
            }
        }
        else if (name == "Touyou")
        {
            if (tutorialDoneFlg && Application.loadedLevelName != "tutorialMain")
            {
                Application.LoadLevel("touyou");
            }
            else
            {
                Application.LoadLevel("tutorialTouyou");
            }
        }
        else if (name == "Houmotsuko")
        {
            Application.LoadLevel("souko");
        }
        else if (name == "Zukan")
        {
            Application.LoadLevel("zukan");
        }
        else if (name == "Syounin")
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                //接続されていないときの処理
                Message msg = new Message();
                msg.makeMessage(msg.getMessage(136));
            }
            else
            {
                //接続されているときの処理
                Application.LoadLevel("purchase");

                /*
                 * //Make Purchase Pop
                 * GameObject.Find("GameController").GetComponent<MainStageController>().iapRunFlg = false;
                 *
                 * //Popup
                 * GameObject map = GameObject.Find ("Map").gameObject;
                 *
                 *              string backPath = "Prefabs/Busyo/back";
                 *              GameObject back = Instantiate (Resources.Load (backPath)) as GameObject;
                 *              back.transform.SetParent (map.transform);
                 *              back.transform.localScale = new Vector2 (1, 1);
                 *              RectTransform backTransform = back.GetComponent<RectTransform> ();
                 *              backTransform.anchoredPosition = new Vector3 (0, 0, 0);
                 *
                 *              //Popup Screen
                 *              string popupPath = "Prefabs/Purchase/PurchaseManager";
                 *              GameObject popup = Instantiate (Resources.Load (popupPath)) as GameObject;
                 *              popup.transform.SetParent (map.transform);
                 *              popup.transform.localScale = new Vector2 (1, 1);
                 *              RectTransform popupTransform = popup.GetComponent<RectTransform> ();
                 *              popupTransform.anchoredPosition = new Vector3 (0, 0, 0);
                 *              popup.name = "PurchaseManager";
                 */
            }
        }
        else if (name == "Config")
        {
            GameObject panel = GameObject.Find("Panel").gameObject;

            string     pathOfBack = "Prefabs/Common/TouchBackForOne";
            GameObject back       = Instantiate(Resources.Load(pathOfBack)) as GameObject;
            back.transform.SetParent(panel.transform);
            back.transform.localScale    = new Vector2(1, 1);
            back.transform.localPosition = new Vector2(0, 0);

            string     pathOfBoard = "Prefabs/Common/ConfigBoard";
            GameObject board       = Instantiate(Resources.Load(pathOfBoard)) as GameObject;
            board.transform.SetParent(panel.transform);
            board.transform.localScale    = new Vector2(1, 1);
            board.transform.localPosition = new Vector2(0, 0);

            //qa
            board.transform.FindChild("qa").GetComponent <QA> ().qaId = 15;
            back.GetComponent <CloseOneBoard> ().deleteObj            = board;


            //On or Off
            Color onBtnColor = new Color(85f / 255f, 85f / 255f, 85f / 255f, 160f / 255f);
            Color onTxtColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f);

            bool SEOffFlg = PlayerPrefs.GetBool("SEOffFlg");
            if (SEOffFlg)
            {
                GameObject offObj = board.transform.FindChild("SE").transform.FindChild("OffButton").gameObject;
                offObj.GetComponent <Image> ().color = onBtnColor;
                offObj.transform.FindChild("Text").GetComponent <Text> ().color = onTxtColor;
                offObj.GetComponent <Button> ().enabled = false;
            }
            else
            {
                GameObject onObj = board.transform.FindChild("SE").transform.FindChild("OnButton").gameObject;
                onObj.GetComponent <Image> ().color = onBtnColor;
                onObj.transform.FindChild("Text").GetComponent <Text> ().color = onTxtColor;
                onObj.GetComponent <Button> ().enabled = false;
            }

            bool BGMOffFlg = PlayerPrefs.GetBool("BGMOffFlg");
            if (BGMOffFlg)
            {
                GameObject offObj = board.transform.FindChild("BGM").transform.FindChild("OffButton").gameObject;
                offObj.GetComponent <Image> ().color = onBtnColor;
                offObj.transform.FindChild("Text").GetComponent <Text> ().color = onTxtColor;
                offObj.GetComponent <Button> ().enabled = false;
            }
            else
            {
                GameObject onObj = board.transform.FindChild("BGM").transform.FindChild("OnButton").gameObject;
                onObj.GetComponent <Image> ().color = onBtnColor;
                onObj.transform.FindChild("Text").GetComponent <Text> ().color = onTxtColor;
                onObj.GetComponent <Button> ().enabled = false;
            }

            //Auto
            bool Auto2Flg = PlayerPrefs.GetBool("Auto2Flg");
            if (Auto2Flg)
            {
                GameObject onObj = board.transform.FindChild("Auto").transform.FindChild("2").gameObject;
                onObj.GetComponent <Image>().color = onBtnColor;
                onObj.transform.FindChild("Text").GetComponent <Text>().color = onTxtColor;
                onObj.GetComponent <Button>().enabled = false;
            }
            else
            {
                GameObject onObj = board.transform.FindChild("Auto").transform.FindChild("4").gameObject;
                onObj.GetComponent <Image>().color = onBtnColor;
                onObj.transform.FindChild("Text").GetComponent <Text>().color = onTxtColor;
                onObj.GetComponent <Button>().enabled = false;
            }
        }
        else if (name == "Reward")
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                //接続されていないときの処理
                Message msg = new Message();
                msg.makeMessage(msg.getMessage(5));
            }
            else
            {
                Application.LoadLevel("reward");
            }
        }
        else if (name == "Tutorial")
        {
            PlayerPrefs.SetInt("tutorialId", 1);
            PlayerPrefs.Flush();
            Application.LoadLevel("tutorialMain");
        }
        else if (name == "User")
        {
            GameObject panel = GameObject.Find("Panel").gameObject;

            string     pathOfBack = "Prefabs/Common/TouchBackForOne";
            GameObject back       = Instantiate(Resources.Load(pathOfBack)) as GameObject;
            back.transform.SetParent(panel.transform);
            back.transform.localScale    = new Vector2(1, 1);
            back.transform.localPosition = new Vector2(0, 0);

            string     pathOfBoard = "Prefabs/Common/UserId";
            GameObject board       = Instantiate(Resources.Load(pathOfBoard)) as GameObject;
            board.transform.SetParent(panel.transform);
            if (Application.loadedLevelName != "top")
            {
                board.transform.localScale = new Vector2(1, 1);
            }
            else
            {
                board.transform.localScale = new Vector2(1.2f, 1);
            }
            board.transform.localPosition = new Vector2(0, 0);

            string userId = PlayerPrefs.GetString("userId");
            board.transform.FindChild("userId").GetComponent <Text>().text = userId;

            string versionNo = Application.version;
            string verTxt    = "( Ver." + versionNo + ")";
            string final     = SystemInfo.operatingSystem + verTxt;
            board.transform.FindChild("ver").GetComponent <Text>().text = final;
            back.GetComponent <CloseOneBoard>().deleteObj = board;
        }
        else if (name == "DataRecovery")
        {
            Application.LoadLevel("dataRecovery");
        }
    }