コード例 #1
0
    public void Start()
    {
        GameObject          GameController      = GameObject.Find("GameController").gameObject;
        MainStageController MainStageController = GameController.GetComponent <MainStageController>();

        timer     = MainStageController.yearTimer;
        TimerText = transform.FindChild("TimerText").GetComponent <Text>();
    }
コード例 #2
0
    public void OnClick()
    {
        if (name == "YesButton")
        {
            Message msg = new Message();

            //check
            int busyoDama = PlayerPrefs.GetInt("busyoDama");
            if (busyoDama >= 100)
            {
                AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
                audioSources [3].Play();

                int newHyourou = 100;
                if (Application.loadedLevelName != "shisya")
                {
                    GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString();
                }
                else
                {
                    GameObject.Find("Hyourou").transform.FindChild("Value").GetComponent <Text>().text = newHyourou.ToString();
                }

                int newBusyoDama = busyoDama - 100;
                if (Application.loadedLevelName != "naisei")
                {
                    GameObject.Find("BusyoDamaValue").GetComponent <Text> ().text = newBusyoDama.ToString();
                }

                PlayerPrefs.SetInt("busyoDama", newBusyoDama);
                PlayerPrefs.SetInt("hyourou", newHyourou);

                if (Application.loadedLevelName != "shisya" && Application.loadedLevelName != "naisei" && Application.loadedLevelName != "pvp")
                {
                    MainStageController mainScript = GameObject.Find("GameController").GetComponent <MainStageController> ();
                    mainScript.hyourouFull = true;
                    mainScript.nowHyourou  = 100;
                    mainScript.timer       = 180;
                    GameObject.Find("TimerValue").GetComponent <Text> ().text = "180";
                }
                PlayerPrefs.SetBool("questDailyFlg37", true);
                PlayerPrefs.Flush();

                //Extension Mark Handling
                MainStageController main = new MainStageController();
                main.questExtension();

                msg.makeMessage(msg.getMessage(4));
            }
            else
            {
                msg.makeMessage(msg.getMessage(2));
            }
        }

        touchBackObj.GetComponent <CloseOneBoard> ().OnClick();
    }
コード例 #3
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        if (name == "YesButton")
        {
            Message msg = new Message();

            //check
            int meiseiItem = PlayerPrefs.GetInt("meisei");
            if (meiseiItem >= 1)
            {
                audioSources [3].Play();

                meiseiItem = meiseiItem - 1;
                PlayerPrefs.SetInt("meisei", meiseiItem);

                NaiseiController script = GameObject.Find("NaiseiController").GetComponent <NaiseiController> ();
                int    kuniId           = script.activeKuniId;
                string tmp1             = "naiseiLoginDate" + kuniId.ToString();
                string tmp2             = "naiseiTabibitoCounter" + kuniId.ToString();

                PlayerPrefs.DeleteKey(tmp1);
                PlayerPrefs.DeleteKey(tmp2);

                int tabibitoMaxNo = int.Parse(GameObject.Find("TabibitoMaxValue").GetComponent <Text> ().text);
                GameObject.Find("TabibitoCountDownValue").GetComponent <Text> ().text = tabibitoMaxNo.ToString();
                script.remain = tabibitoMaxNo;
                float specialRatio = script.specialRatio;
                //specialRatio = specialRatio * 2;
                specialRatio        = 20;
                script.specialRatio = specialRatio;

                PlayerPrefs.SetBool("questDailyFlg151", true);
                PlayerPrefs.Flush();

                //Extension Mark Handling
                MainStageController main = new MainStageController();
                main.questExtension();

                msg.makeMessage(msg.getMessage(121));
            }
            else
            {
                audioSources [4].Play();
                msg.makeMessage(msg.getMessage(120));
            }
        }
        else
        {
            audioSources [1].Play();
        }

        touchBackObj.GetComponent <CloseOneBoard> ().OnClick();
    }
コード例 #4
0
    public void OnClick()
    {
        if (name == "YesButton")
        {
            Message msg = new Message();

            //check
            int busyoDama = PlayerPrefs.GetInt("busyoDama");
            if (busyoDama >= 100)
            {
                AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
                audioSources [3].Play();

                int currentMoney = PlayerPrefs.GetInt("money");
                currentMoney = currentMoney + 30000;
                if (currentMoney < 0)
                {
                    currentMoney = int.MaxValue;
                }
                GameObject.Find("MoneyValue").GetComponent <Text> ().text = currentMoney.ToString();
                PlayerPrefs.SetInt("money", currentMoney);

                int newBusyoDama = busyoDama - 100;
                GameObject.Find("BusyoDamaValue").GetComponent <Text> ().text = newBusyoDama.ToString();
                PlayerPrefs.SetInt("busyoDama", newBusyoDama);


                PlayerPrefs.SetBool("questDailyFlg150", true);
                PlayerPrefs.Flush();

                //Extension Mark Handling
                MainStageController main = new MainStageController();
                main.questExtension();

                msg.makeMessage(msg.getMessage(3));
            }
            else
            {
                msg.makeMessage(msg.getMessage(2));
            }
        }

        touchBackObj.GetComponent <CloseOneBoard> ().OnClick();
    }
コード例 #5
0
    public void PushAdsense()
    {
        // topに戻るのを伏せぐためのフラグ変更

        if (SceneManager.GetActiveScene().name == "mainStage")
        {
            GameObject          ob = GameObject.Find("GameController");
            MainStageController mc = ob.GetComponent <MainStageController>();
            if (!mc.adRunFlg)
            {
                StartCoroutine(PlayAdsense());
                mc.adRunFlg = true;
            }
        }
        else
        {
            StartCoroutine(PlayAdsense());
        }
    }
コード例 #6
0
ファイル: SeasonTimer.cs プロジェクト: pratikxman/Sengoku2d
    public void OnClick()
    {
        Message             msg                 = new Message();
        GameObject          GameController      = GameObject.Find("GameController").gameObject;
        MainStageController MainStageController = GameController.GetComponent <MainStageController>();

        timer = MainStageController.yearTimer;
        string hms     = "";
        string msgText = "";

        if (timer > 0)
        {
            TimeSpan ts = new TimeSpan(0, 0, (int)timer);
            hms = ts.ToString();

            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                msgText = "Next season will come after " + hms;
            }
            else
            {
                msgText = "次の季節まであと" + hms + "ですぞ。";
            }
        }
        else
        {
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                msgText = "Next season has come.";
            }
            else
            {
                msgText = "次の季節はもう来ておりますぞ";
            }
        }
        msg.makeMessage(msgText);
    }
コード例 #7
0
ファイル: DoBouryaku.cs プロジェクト: pratikxman/Sengoku2d
    public void OnClick()
    {
        Message    msg            = new Message();
        Gaikou     gaikou         = new Gaikou();
        DoGaikou   yukouChange    = new DoGaikou();
        int        nowHyourou     = PlayerPrefs.GetInt("hyourou");
        CloseBoard closeScript    = GameObject.Find("close").GetComponent <CloseBoard> ();
        int        daimyoBusyoAtk = closeScript.daimyoBusyoAtk;
        int        daimyoBusyoDfc = closeScript.daimyoBusyoDfc;
        int        daimyoId       = closeScript.daimyoId;
        int        kuniId         = closeScript.kuniId;

        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        if (nowHyourou >= 5)
        {
            //Track
            int TrackBouryakuNo = PlayerPrefs.GetInt("TrackBouryakuNo", 0);
            TrackBouryakuNo = TrackBouryakuNo + 1;
            PlayerPrefs.SetInt("TrackBouryakuNo", TrackBouryakuNo);

            if (name == "DoGihouBtn")
            {
                //Reduce Hyourou
                reduceHyourou();

                //Reduce Shinobi
                //Ratio
                //Ge 5-15%, Cyu 15-30%, Jyo 30-50%
                int randomPercent = 0;
                int newQty        = itemQty - 1;

                if (itemRank == "Ge")
                {
                    randomPercent = UnityEngine.Random.Range(5, 15);
                    PlayerPrefs.SetInt("shinobiGe", newQty);
                }
                else if (itemRank == "Cyu")
                {
                    randomPercent = UnityEngine.Random.Range(15, 30);
                    PlayerPrefs.SetInt("shinobiCyu", newQty);
                }
                else if (itemRank == "Jyo")
                {
                    randomPercent = UnityEngine.Random.Range(30, 50);
                    PlayerPrefs.SetInt("shinobiJyo", newQty);
                }

                float ratio   = (float)randomPercent;
                float percent = Random.value;
                percent = percent * 100;

                if (percent <= ratio)
                {
                    //OK
                    audioSources [3].Play();

                    //Track
                    int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0);
                    TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1;
                    PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo);

                    //Delete Gunzei
                    Destroy(Gunzei);

                    //Delete Key
                    string gunzeiKey = Gunzei.name;
                    PlayerPrefs.DeleteKey(gunzeiKey);

                    //Delete Key History
                    char[]        delimiterChars = { ',' };
                    string        keyHistory     = PlayerPrefs.GetString("keyHistory");
                    List <string> keyHistoryList = new List <string>();
                    if (keyHistory != null && keyHistory != "")
                    {
                        if (keyHistory.Contains(","))
                        {
                            keyHistoryList = new List <string> (keyHistory.Split(delimiterChars));
                        }
                        else
                        {
                            keyHistoryList.Add(keyHistory);
                        }
                    }
                    keyHistoryList.Remove(gunzeiKey);
                    string newKeyHistory = "";
                    for (int i = 0; i < keyHistoryList.Count; i++)
                    {
                        if (i == 0)
                        {
                            newKeyHistory = keyHistoryList[i];
                        }
                        else
                        {
                            newKeyHistory = newKeyHistory + "," + keyHistoryList[i];
                        }
                    }
                    PlayerPrefs.SetString("keyHistory", newKeyHistory);

                    //Message
                    PlayerPrefs.SetBool("questDailyFlg33", true);

                    //Extension Mark Handling
                    MainStageController main = new MainStageController();
                    main.questExtension();


                    int TrackGihouHei = PlayerPrefs.GetInt("TrackGihouHei", 0);
                    int hei           = Gunzei.GetComponent <Gunzei> ().myHei;
                    TrackGihouHei = TrackGihouHei + hei;
                    PlayerPrefs.SetInt("TrackGihouHei", TrackGihouHei);

                    string daimyoName = Gunzei.GetComponent <Gunzei>().srcDaimyoName;
                    string OKtext     = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        OKtext = "My lord, misreport was successful. \n" + daimyoName + " army withdrawn.";
                    }
                    else
                    {
                        OKtext = "御屋形様、偽報に成功しましたぞ。\n" + daimyoName + "の軍勢が退却します。";
                    }
                    msg.makeMessage(OKtext);
                }
                else
                {
                    //NG
                    audioSources [4].Play();

                    int nowYukoudo    = gaikou.getMyGaikou(daimyoId);
                    int newYukoudo    = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue);
                    int reduceYukoudo = nowYukoudo - newYukoudo;
                    GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();

                    //Message
                    string NGtext = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        NGtext = "My lord, I'm sorry. failed misreport. \n Friendship decreased " + reduceYukoudo + " point";
                    }
                    else
                    {
                        NGtext = "申し訳御座りませぬ。偽報に失敗しましたぞ。\n友好度が" + reduceYukoudo + "下がりますぞ。";
                    }

                    msg.makeMessage(NGtext);

                    yukouChange.downYukouOnIcon(daimyoId, newYukoudo);
                }
                PlayerPrefs.Flush();

                //Back
                GameObject.Find("return").GetComponent <MenuReturn> ().OnClick();
            }
            else if (name == "DoRyugenBtn")
            {
                //Reduce Hyourou
                reduceHyourou();

                //Ratio
                //Ge 10-20%, Cyu 20-40%, Jyo 40-70%
                float randomPercent = 0;
                int   newQty        = itemQty - 1;

                if (itemRank == "Ge")
                {
                    float tempRandomPercent = (200 - daimyoBusyoDfc) / 4;
                    float tempValue         = UnityEngine.Random.Range(0.5f, 1.5f);
                    randomPercent = tempRandomPercent * tempValue;
                    PlayerPrefs.SetInt("shinobiGe", newQty);
                }
                else if (itemRank == "Cyu")
                {
                    float tempRandomPercent = (200 - daimyoBusyoDfc) / 2;
                    float tempValue         = UnityEngine.Random.Range(0.8f, 1.2f);
                    randomPercent = tempRandomPercent * tempValue;
                    PlayerPrefs.SetInt("shinobiCyu", newQty);
                }
                else if (itemRank == "Jyo")
                {
                    float tempRandomPercent = (200 - daimyoBusyoDfc);
                    float tempValue         = UnityEngine.Random.Range(0.9f, 1.1f);
                    randomPercent = tempRandomPercent * tempValue;
                    PlayerPrefs.SetInt("shinobiJyo", newQty);
                }

                float percent = Random.value;
                percent = percent * 100;

                if (percent <= randomPercent)
                {
                    //Success
                    audioSources [3].Play();

                    //Track
                    int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0);
                    TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1;
                    PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo);

                    int TrackRyugenNo = PlayerPrefs.GetInt("TrackRyugenNo", 0);
                    TrackRyugenNo = TrackRyugenNo + 1;
                    PlayerPrefs.SetInt("TrackRyugenNo", TrackRyugenNo);

                    //Daimyo Id
                    int srcDaimyoId = GameObject.Find("close").GetComponent <CloseBoard> ().daimyoId;

                    //Seiryoku List
                    string        seiryoku       = PlayerPrefs.GetString("seiryoku");
                    List <string> seiryokuList   = new List <string> ();
                    char[]        delimiterChars = { ',' };
                    seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

                    //src daimyo kuni list
                    List <string> srcDaimyoKuniList = new List <string> ();
                    for (int i = 0; i < seiryokuList.Count; i++)
                    {
                        string tempDaimyoId = seiryokuList[i];

                        if (tempDaimyoId == srcDaimyoId.ToString())
                        {
                            int temp = i + 1;
                            srcDaimyoKuniList.Add(temp.ToString());
                        }
                    }

                    //src daimyo open kuni list
                    KuniInfo   kuni         = new KuniInfo();
                    List <int> openKuniList = new List <int>();
                    for (int j = 0; j < srcDaimyoKuniList.Count; j++)
                    {
                        openKuniList.AddRange(kuni.getMappingKuni(int.Parse(srcDaimyoKuniList[j])));
                    }

                    //Target Daimyo (exculde this src daimyo & mydaimyo)
                    int        myDaimyo      = PlayerPrefs.GetInt("myDaimyo");
                    List <int> dstDaimyoList = new List <int>();

                    for (int k = 0; k < openKuniList.Count; k++)
                    {
                        int temp         = openKuniList[k] - 1;
                        int tempDaimyoId = int.Parse(seiryokuList[temp]);
                        if (tempDaimyoId != myDaimyo && tempDaimyoId != srcDaimyoId)
                        {
                            if (!dstDaimyoList.Contains(tempDaimyoId))
                            {
                                dstDaimyoList.Add(tempDaimyoId);
                            }
                        }
                    }


                    //Reduce Yukoudo
                    MainEventHandler main       = new MainEventHandler();
                    Daimyo           daimyo     = new Daimyo();
                    string           ryugenText = "";
                    for (int l = 0; l < dstDaimyoList.Count; l++)
                    {
                        int    dstDaimyoId   = dstDaimyoList[l];
                        string dstDaimyoName = daimyo.getName(dstDaimyoId);
                        int    reduceYukoudo = main.DownYukouValueWithOther(srcDaimyoId, dstDaimyoId);
                        reduceYukoudo = reduceYukoudo / 2;
                        if (reduceYukoudo == 0)
                        {
                            reduceYukoudo = 1;
                        }

                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            ryugenText = ryugenText + dstDaimyoName + " friendship decreased " + reduceYukoudo + " point \n";
                        }
                        else
                        {
                            ryugenText = ryugenText + dstDaimyoName + "との友好度が" + reduceYukoudo + "下がりました。\n";
                        }
                    }

                    //Message
                    PlayerPrefs.SetBool("questDailyFlg31", true);

                    //Extension Mark Handling
                    MainStageController mainStage = new MainStageController();
                    mainStage.questExtension();

                    string OKtext = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        OKtext = "My lord, bad rumor was successful. \n" + ryugenText;
                    }
                    else
                    {
                        OKtext = "御屋形様、流言に成功しましたぞ。\n " + ryugenText;
                    }
                    msg.makeMessage(OKtext);
                }
                else
                {
                    //Failed
                    audioSources [4].Play();

                    //Message
                    int nowYukoudo    = gaikou.getMyGaikou(daimyoId);
                    int newYukoudo    = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue);
                    int reduceYukoudo = nowYukoudo - newYukoudo;
                    GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();


                    //Message
                    string NGtext = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        NGtext = "My lord, I'm sorry. failed misreport. \n Friendship decreased " + reduceYukoudo + " point";
                    }
                    else
                    {
                        NGtext = "申し訳御座りませぬ。流言に失敗しましたぞ。\n友好度が" + reduceYukoudo + "下がりますぞ。";
                    }

                    yukouChange.downYukouOnIcon(daimyoId, newYukoudo);

                    msg.makeMessage(NGtext);
                }
                PlayerPrefs.Flush();

                //Back
                GameObject.Find("return").GetComponent <MenuReturn> ().OnClick();
            }
            else if (name == "DoGoudatsuBtn")
            {
                reduceHyourou();

                //Ratio
                //Ge 10-20%, Cyu 20-40%, Jyo 40-70%
                float randomPercent = 0;
                int   newQty        = itemQty - 1;

                if (itemRank == "Ge")
                {
                    float tempRandomPercent = (200 - daimyoBusyoDfc) / 4;
                    float tempValue         = UnityEngine.Random.Range(0.5f, 1.5f);
                    randomPercent = tempRandomPercent * tempValue;
                    PlayerPrefs.SetInt("shinobiGe", newQty);
                }
                else if (itemRank == "Cyu")
                {
                    float tempRandomPercent = (200 - daimyoBusyoDfc) / 2;
                    float tempValue         = UnityEngine.Random.Range(0.8f, 1.2f);
                    randomPercent = tempRandomPercent * tempValue;
                    PlayerPrefs.SetInt("shinobiCyu", newQty);
                }
                else if (itemRank == "Jyo")
                {
                    float tempRandomPercent = (200 - daimyoBusyoDfc);
                    float tempValue         = UnityEngine.Random.Range(0.9f, 1.1f);
                    randomPercent = tempRandomPercent * tempValue;
                    PlayerPrefs.SetInt("shinobiJyo", newQty);
                }

                float percent = Random.value;
                percent = percent * 100;

                if (percent <= randomPercent)
                {
                    audioSources [3].Play();

                    //Track
                    int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0);
                    TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1;
                    PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo);

                    //Success
                    int kuniQty  = GameObject.Find("close").GetComponent <CloseBoard>().kuniQty;
                    int getMoney = 0;
                    //Money or Item 0:money, 1:item
                    int moneyOrItem = UnityEngine.Random.Range(0, 2);
                    //Kahou or Shizai 0:kahou, 1:shizai
                    int    kahouOrShizai = UnityEngine.Random.Range(0, 2);
                    string kahouName     = "";
                    string shigenName    = "";
                    int    addQty        = 0;
                    int    kahouRank     = 0;              //kahouRank S,A,B,C=1,2,3,4
                    //shigen Type
                    int shigenType = 0;                    //KB,YR,TP,YM=1,2,3,4

                    if (moneyOrItem == 0)
                    {
                        //money
                        int temGetMoney = UnityEngine.Random.Range(1000, 1501);
                        getMoney = temGetMoney * kuniQty;
                        int nowMoney = PlayerPrefs.GetInt("money");
                        nowMoney = nowMoney + getMoney;
                        if (nowMoney < 0)
                        {
                            nowMoney = int.MaxValue;
                        }
                        PlayerPrefs.SetInt("money", nowMoney);
                        PlayerPrefs.Flush();
                    }
                    else
                    {
                        //item
                        //Kahou or Shizai 0:kahou, 1:shizai
                        kahouOrShizai = UnityEngine.Random.Range(0, 2);
                        if (kahouOrShizai == 0)
                        {
                            //kahou
                            Kahou kahou = new Kahou();
                            ////Bugu, Gusoku, Kabuto, Meiba, Heihousyo, Cyadougu, Chishikisyo(1,2,3,4,5,6)
                            int kahouType = UnityEngine.Random.Range(1, 7);

                            float khPercent = Random.value;
                            khPercent = khPercent * 100;
                            if (5 <= kuniQty)
                            {
                                //(S,A,B  5,35,60%)
                                if (khPercent <= 5)
                                {
                                    //S
                                    kahouRank = 1;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                                else if (5 < khPercent && khPercent <= 41)
                                {
                                    //A
                                    kahouRank = 2;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                                else if (41 < khPercent)
                                {
                                    //B
                                    kahouRank = 3;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                            }
                            else if (3 <= kuniQty && kuniQty < 5)
                            {
                                //(S,A,B,C : 1,15,25,59%)
                                if (khPercent <= 1)
                                {
                                    //S
                                    kahouRank = 1;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                                else if (1 < khPercent && khPercent <= 16)
                                {
                                    //A
                                    kahouRank = 2;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                                else if (16 < khPercent && khPercent <= 41)
                                {
                                    //B
                                    kahouRank = 3;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                                else if (41 < khPercent)
                                {
                                    //C
                                    kahouRank = 4;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                            }
                            else if (kuniQty < 3)
                            {
                                //(A,B,C : 5, 35, 60%)
                                if (khPercent <= 5)
                                {
                                    //A
                                    kahouRank = 2;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                                else if (5 < khPercent && khPercent <= 41)
                                {
                                    //B
                                    kahouRank = 3;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                                else if (41 < khPercent)
                                {
                                    //C
                                    kahouRank = 3;
                                    kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                }
                            }
                        }
                        else
                        {
                            //shizai
                            shigenType = UnityEngine.Random.Range(1, 5);
                            float sgPercent = Random.value;
                            sgPercent = sgPercent * 100;
                            addQty    = UnityEngine.Random.Range(1, 6);
                            Item item       = new Item();
                            int  shigenRank = 0;                           //下、中、上=1,2,3

                            if (5 <= kuniQty)
                            {
                                //(上,中,下  40,40, 20%)
                                if (sgPercent <= 40)
                                {
                                    shigenRank = 3;
                                }
                                else if (40 < sgPercent && sgPercent <= 81)
                                {
                                    shigenRank = 2;
                                }
                                else if (81 < sgPercent)
                                {
                                    shigenRank = 1;
                                }
                                shigenName = item.getRandomShigen(shigenType, shigenRank, addQty);
                            }
                            else if (3 <= kuniQty && kuniQty < 5)
                            {
                                //(上,中,下  20,50,30%)
                                if (sgPercent <= 20)
                                {
                                    shigenRank = 3;
                                }
                                else if (20 < sgPercent && sgPercent <= 51)
                                {
                                    shigenRank = 2;
                                }
                                else if (51 < sgPercent)
                                {
                                    shigenRank = 1;
                                }
                                shigenName = item.getRandomShigen(shigenType, shigenRank, addQty);
                            }
                            else if (kuniQty < 3)
                            {
                                //(上,中,下  5,25,70%)
                                if (sgPercent <= 5)
                                {
                                    shigenRank = 3;
                                }
                                else if (5 < sgPercent && sgPercent <= 26)
                                {
                                    shigenRank = 2;
                                }
                                else if (26 < sgPercent)
                                {
                                    shigenRank = 1;
                                }
                                shigenName = item.getRandomShigen(shigenType, shigenRank, addQty);
                            }
                        }
                    }


                    //Message
                    PlayerPrefs.SetBool("questDailyFlg32", true);

                    MainStageController mainStage = new MainStageController();
                    mainStage.questExtension();

                    string OKtext = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        OKtext = "My lord, successed to rob.\n";
                    }
                    else
                    {
                        OKtext = "御屋形様、強奪に成功しましたぞ。\n";
                    }


                    string addText = "";
                    if (moneyOrItem == 0)
                    {
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            addText = "got " + getMoney + " money.";
                        }
                        else
                        {
                            addText = "金を" + getMoney + "奪って参りました。";
                        }
                    }
                    else
                    {
                        if (kahouOrShizai == 0)
                        {
                            //kahou

                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                addText = " got treasure " + kahouName + ".";
                            }
                            else
                            {
                                addText = "家宝、" + kahouName + "を奪って参りました。";
                            }
                        }
                        else
                        {
                            //shizai+

                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                addText = " got " + addQty + " " + shigenName + ".";
                            }
                            else
                            {
                                addText = shigenName + "を" + addQty + "個奪って参りました。";
                            }
                        }
                    }

                    OKtext = OKtext + addText;
                    msg.makeMessage(OKtext);
                }
                else
                {
                    //Failed
                    audioSources [4].Play();

                    int nowYukoudo    = gaikou.getMyGaikou(daimyoId);
                    int newYukoudo    = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue);
                    int reduceYukoudo = nowYukoudo - newYukoudo;
                    GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();

                    //Message
                    string NGtext = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        NGtext = "My lord, I'm sorry. failed to rob. \n Friendship decreased " + reduceYukoudo + " point";
                    }
                    else
                    {
                        NGtext = "申し訳御座りませぬ。強奪に失敗しましたぞ。\n友好度が" + reduceYukoudo + "下がりますぞ。";
                    }
                    msg.makeMessage(NGtext);

                    yukouChange.downYukouOnIcon(daimyoId, newYukoudo);
                }

                PlayerPrefs.Flush();

                //Back
                GameObject.Find("return").GetComponent <MenuReturn> ().OnClick();
            }
            else if (name == "DoCyouhouBtn")
            {
                reduceHyourou();

                //Set Value & REduce Qty
                float missPercent = 0;
                int   newQty      = itemQty - 1;
                int   snbValue    = 0;

                if (itemRank == "Ge")
                {
                    missPercent = 30;
                    PlayerPrefs.SetInt("shinobiGe", newQty);
                    snbValue = 1;
                }
                else if (itemRank == "Cyu")
                {
                    missPercent = 15;
                    PlayerPrefs.SetInt("shinobiCyu", newQty);
                    snbValue = 2;
                }
                else if (itemRank == "Jyo")
                {
                    missPercent = 5;
                    PlayerPrefs.SetInt("shinobiJyo", newQty);
                    snbValue = 3;
                }


                //Random Check
                float percent = Random.value;
                percent = percent * 100;

                if (percent >= missPercent)
                {
                    //Success
                    audioSources [3].Play();

                    //Track
                    int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0);
                    TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1;
                    PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo);

                    int TrackCyouhouNo = PlayerPrefs.GetInt("TrackCyouhouNo", 0);
                    TrackCyouhouNo = TrackCyouhouNo + 1;
                    PlayerPrefs.SetInt("TrackCyouhouNo", TrackCyouhouNo);

                    string        cyouhouHist     = PlayerPrefs.GetString("cyouhou");
                    char[]        delimiterChars  = { ',' };
                    List <string> cyouhouHistList = new List <string> ();
                    if (cyouhouHist != null && cyouhouHist != "")
                    {
                        if (cyouhouHist.Contains(","))
                        {
                            cyouhouHistList = new List <string> (cyouhouHist.Split(delimiterChars));
                        }
                        else
                        {
                            cyouhouHistList.Add(cyouhouHist);
                        }
                    }

                    //Add new kuni
                    if (!cyouhouHistList.Contains(kuniId.ToString()))
                    {
                        cyouhouHistList.Add(kuniId.ToString());
                    }

                    string newCyouhouHist = "";
                    for (int i = 0; i < cyouhouHistList.Count; i++)
                    {
                        string tmpCyouhouKuniId = cyouhouHistList [i];

                        if (i == 0)
                        {
                            newCyouhouHist = tmpCyouhouKuniId;
                        }
                        else
                        {
                            newCyouhouHist = newCyouhouHist + "," + tmpCyouhouKuniId;
                        }
                    }

                    PlayerPrefs.SetString("cyouhou", newCyouhouHist);

                    string cyouhouKuni = "cyouhou" + kuniId.ToString();
                    PlayerPrefs.SetInt(cyouhouKuni, snbValue);

                    bool cyouhouFlg = closeScript.cyouhouFlg;

                    if (cyouhouFlg)
                    {
                        //Change Icon
                        GameObject shinobi = GameObject.Find("shinobi").gameObject;

                        if (snbValue == 1)
                        {
                            Color lowColor = new Color(0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f);
                            shinobi.GetComponent <Image> ().color = lowColor;
                            shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "下";
                        }
                        else if (snbValue == 2)
                        {
                            Color midColor = new Color(94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
                            shinobi.GetComponent <Image> ().color = midColor;
                            shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "中";
                        }
                        else if (snbValue == 3)
                        {
                            Color highColor = new Color(84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f);
                            shinobi.GetComponent <Image> ().color = highColor;
                            shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "上";
                        }
                    }
                    else
                    {
                        GameObject smallBoardObj = GameObject.Find("smallBoard(Clone)").gameObject;

                        //new Icon
                        string     shinobiItemPath = "Prefabs/Item/Shinobi/Shinobi";
                        GameObject shinobi         = Instantiate(Resources.Load(shinobiItemPath)) as GameObject;
                        shinobi.transform.SetParent(smallBoardObj.transform);
                        shinobi.transform.localScale = new Vector2(0.25f, 0.31f);
                        shinobi.name = "shinobi";
                        RectTransform snbTransform = shinobi.GetComponent <RectTransform> ();
                        snbTransform.anchoredPosition            = new Vector3(-251, 250, 0);
                        shinobi.GetComponent <Button> ().enabled = false;

                        if (snbValue == 1)
                        {
                            Color lowColor = new Color(0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f);
                            shinobi.GetComponent <Image>().color = lowColor;
                            shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "下";
                        }
                        else if (snbValue == 2)
                        {
                            Color midColor = new Color(94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
                            shinobi.GetComponent <Image>().color = midColor;
                            shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "中";
                        }
                        else if (snbValue == 3)
                        {
                            Color highColor = new Color(84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f);
                            shinobi.GetComponent <Image>().color = highColor;
                            shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "上";
                        }

                        //Set Flg
                        closeScript.cyouhouFlg       = true;
                        closeScript.cyouhouSnbRankId = snbValue;
                    }

                    GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject;
                    kuniIconView.transform.FindChild(kuniId.ToString()).GetComponent <SendParam> ().cyouhouSnbRankId = snbValue;


                    KuniInfo kuni     = new KuniInfo();
                    string   kuniName = kuni.getKuniName(kuniId);
                    PlayerPrefs.SetBool("questDailyFlg30", true);

                    MainStageController mainStage = new MainStageController();
                    mainStage.questExtension();


                    string OKtext = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        OKtext = "Ninja hided in " + kuniName + " well. \n Please check spy report.";
                    }
                    else
                    {
                        OKtext = "忍が上手く" + kuniName + "に潜伏しましたぞ。\n諜報内容をご確認下され。";
                    }
                    msg.makeMessage(OKtext);
                }
                else
                {
                    //Fail
                    audioSources [4].Play();

                    int nowYukoudo    = gaikou.getMyGaikou(daimyoId);
                    int newYukoudo    = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue);
                    int reduceYukoudo = nowYukoudo - newYukoudo;
                    GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();
                    string NGtext = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        NGtext = "Ninja was caught. \n Friendship decreased " + reduceYukoudo + " point";
                    }
                    else
                    {
                        NGtext = "忍が捕まってしまったようです。\n友好度が" + reduceYukoudo + "下がりますぞ。";
                    }

                    msg.makeMessage(NGtext);

                    yukouChange.downYukouOnIcon(daimyoId, newYukoudo);
                }


                PlayerPrefs.Flush();

                //Back
                GameObject.Find("return").GetComponent <MenuReturn> ().OnClick();
            }
        }
        else
        {
            audioSources [4].Play();
            msg.hyourouMovieMessage();
            //msg.makeMessage (msg.getMessage(7));
        }
    }
コード例 #8
0
ファイル: HPCounter.cs プロジェクト: zeimoter/sengoku2d
	// Update is called once per frame
	void Update () {
		life = getTotalHp (targetTag);

		//Show Heiryoku
		if (life >= 0) {
			gameObject.transform.FindChild("HpText").GetComponent<Text>().text = life.ToString();
		}

		if (!flag) {
			if (life == 0) {
				flag = true;

				GameObject.Find ("ScrollView").SetActive (false);
				GameObject canvas = GameObject.Find ("Canvas").gameObject;

				if (targetTag == "Player") {
					//Game Over
					string backPath = "Prefabs/PostKassen/back";
					GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject;
					backObj.transform.SetParent (canvas.transform);
					backObj.transform.localScale = new Vector2(70,63);
					backObj.transform.localPosition = new Vector2 (0,0);

					//Chane word
					Color color = Color.blue;
					GameObject.Find ("winlose").GetComponent<TextMesh>().text = "敗北";
					GameObject.Find ("winlose").GetComponent<TextMesh>().color = color;
					
					string blackPath = "Prefabs/PostKassen/black";
					GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject;
					blackObj.transform.SetParent (canvas.transform);
					blackObj.transform.localScale = new Vector2(330,300);
					blackObj.transform.localPosition = new Vector2 (0,0);

					string makimonoPath = "Prefabs/PostKassen/makimono";
					GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject;
					makimonoObj.transform.SetParent (canvas.transform);
					makimonoObj.transform.localScale = new Vector2(1,1);
					makimonoObj.transform.localPosition = new Vector2(0,-135);

					//Button List
					string nextbtnPath = "Prefabs/PostKassen/bttnList";
					GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject;
					bttnListObj.transform.SetParent (canvas.transform);
					bttnListObj.transform.localScale = new Vector2(1,1);		
					bttnListObj.transform.localPosition = new Vector2 (0,0);

					//Time Stop
					GameObject.Find ("timer").GetComponent<Timer>().enabled = false;


					//lose Stage Name
					string stageNamePath = "Prefabs/PostKassen/loseStageName";
					GameObject stageNameObj = Instantiate(Resources.Load (stageNamePath)) as GameObject;
					stageNameObj.transform.SetParent (canvas.transform);
					stageNameObj.transform.localScale = new Vector2(1,1);
					stageNameObj.transform.localPosition = new Vector2 (0,-102);
					string stageName = PlayerPrefs.GetString("activeStageName");

					//Check is attacked flag
					if (isAttackedFlg == true) {

						stageNameObj.transform.FindChild ("stageNameValue").GetComponent<Text> ().text = stageName + "失敗";

						//My Daimyo Lose 
						Gunzei lose = new Gunzei ();
						string tKey = PlayerPrefs.GetString ("activeKey");
						int tSrcDaimyoId = PlayerPrefs.GetInt ("activeSrcDaimyoId");
						int tDstDaimyoId = PlayerPrefs.GetInt ("activeDstDaimyoId");
						bool noGunzeiFlg = true;
						PlayerPrefs.DeleteKey ("isAttacked");
						lose.win (tKey, tSrcDaimyoId, tDstDaimyoId, noGunzeiFlg);


						//Delete Cleared Kuni
						int activeKuniId = PlayerPrefs.GetInt ("activeKuniId");
						string clearedKuni = PlayerPrefs.GetString ("clearedKuni");

						char[] delimiterChars = { ',' };
						List<string> clearedKuniList = new List<string> ();
						
						if (clearedKuni != null && clearedKuni != "") {
							if (clearedKuni.Contains (",")) {
								clearedKuniList = new List<string> (clearedKuni.Split (delimiterChars));
							} else {
								clearedKuniList.Add (clearedKuni);
							}
						}

						string tempActiveKuni = activeKuniId.ToString ();
						clearedKuniList.Remove (tempActiveKuni);
						string newClearedKuni = "";
						for (int i = 0; i < clearedKuniList.Count; i++) {
							if (i == 0) {
								newClearedKuni = clearedKuniList [i];
							} else {
								newClearedKuni = newClearedKuni + "," + clearedKuniList [i];
							}
						}
						PlayerPrefs.SetString ("clearedKuni", newClearedKuni);

						if (newClearedKuni == null || newClearedKuni == "") {
							PlayerPrefs.SetBool ("gameOverFlg", true);

						}

						//Delete Naisei
						//string tempNaisei = "naisei" + activeKuniId.ToString();
						//PlayerPrefs.DeleteKey(tempNaisei);

						//Delete Jyosyu
						string tempJyosyu = "jyosyu" + activeKuniId.ToString ();
						PlayerPrefs.DeleteKey (tempJyosyu);

						//Delete Stage Clear
						string tempKuni = "kuni" + activeKuniId.ToString ();
						PlayerPrefs.DeleteKey (tempKuni);

						//Delete open
						KuniInfo kuni = new KuniInfo ();
						kuni.updateOpenKuni ();
						PlayerPrefs.Flush ();
					
					} else {
						stageNameObj.transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "攻略失敗";
					}

				} else if (targetTag == "Enemy") {
					//Win
					if(isAttackedFlg == true){
						//history
						string tKey = PlayerPrefs.GetString("activeKey");
						MainStageController main = new MainStageController();
						main.deleteKeyHistory(tKey);
						PlayerPrefs.DeleteKey("isAttacked");
						PlayerPrefs.Flush();
					}

					string backPath = "Prefabs/PostKassen/back";
					GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject;
					backObj.transform.SetParent (canvas.transform);
					backObj.transform.localScale = new Vector2(70,63);
					backObj.transform.localPosition = new Vector2 (0,0);

					string particlePath = "Prefabs/PostKassen/particle";
					GameObject particleObj = Instantiate(Resources.Load (particlePath)) as GameObject;
					particleObj.transform.SetParent (canvas.transform);
					particleObj.transform.localPosition = new Vector2(0,60);

					string blackPath = "Prefabs/PostKassen/black";
					GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject;
					blackObj.transform.SetParent (canvas.transform);
					blackObj.transform.localScale = new Vector2(330,300);
					blackObj.transform.localPosition = new Vector2 (0,0);

					string makimonoPath = "Prefabs/PostKassen/makimono";
					GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject;
					makimonoObj.transform.SetParent (canvas.transform);
					makimonoObj.transform.localScale = new Vector2(1,1);
					makimonoObj.transform.localPosition = new Vector2(0,-135);

					string stageName = PlayerPrefs.GetString("activeStageName");


					//Item List
					string itemListPath = "Prefabs/PostKassen/itemList";
					GameObject itemListObj = Instantiate(Resources.Load (itemListPath)) as GameObject;
					itemListObj.transform.SetParent (canvas.transform);
					itemListObj.transform.localScale = new Vector2(1,1);
					itemListObj.transform.localPosition = new Vector2 (0,-136);

					if (!isAttackedFlg) {

						itemListObj.transform.FindChild ("stageName").transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "攻略";

						/*Item or Kahou*/
						string activeItemGrp = PlayerPrefs.GetString ("activeItemGrp");

						if (activeItemGrp != "no") {
								
							string activeItemType = PlayerPrefs.GetString ("activeItemType");
							Debug.Log (activeItemType);
							int activeItemId = PlayerPrefs.GetInt ("activeItemId");
							Debug.Log (activeItemId);
							int activeItemQty = PlayerPrefs.GetInt ("activeItemQty");
							Debug.Log (activeItemQty);

							//Get Item
							string cyouheiPath = "Prefabs/Item/Cyouhei/" + activeItemType;
							string kanjyoPath = "Prefabs/Item/Kanjyo/Kanjyo";
							string hidensyoPath = "Prefabs/Item/Hidensyo/Hidensyo";
							string shinobiPath = "Prefabs/Item/Shinobi/Shinobi";
							char[] delimiterChars = { ',' };

							if (activeItemGrp == "item") {

								//Cyouhei
								if (activeItemType.Contains ("Cyouhei") == true) {
									string newCyouheiString = "";

									makeItemIcon (cyouheiPath, activeItemId.ToString (), itemListObj);
									if (activeItemType.Contains ("YR") == true) {
										string cyouheiString = PlayerPrefs.GetString ("cyouheiYR");
										string[] cyouheiList = cyouheiString.Split (delimiterChars);
										if (activeItemId == 1) {
											int tempQty = int.Parse (cyouheiList [0]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2];

										} else if (activeItemId == 2) {
											int tempQty = int.Parse (cyouheiList [1]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2];

										} else if (activeItemId == 3) {
											int tempQty = int.Parse (cyouheiList [2]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString ();
										}

										PlayerPrefs.SetString ("cyouheiYR", newCyouheiString);

									} else if (activeItemType.Contains ("KB") == true) {
										string cyouheiString = PlayerPrefs.GetString ("cyouheiKB");
										string[] cyouheiList = cyouheiString.Split (delimiterChars);
										if (activeItemId == 1) {
											int tempQty = int.Parse (cyouheiList [0]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2];
											
										} else if (activeItemId == 2) {
											int tempQty = int.Parse (cyouheiList [1]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2];
											
										} else if (activeItemId == 3) {
											int tempQty = int.Parse (cyouheiList [2]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString ();
										}
										
										PlayerPrefs.SetString ("cyouheiKB", newCyouheiString);

									} else if (activeItemType.Contains ("TP") == true) {
										string cyouheiString = PlayerPrefs.GetString ("cyouheiTP");
										string[] cyouheiList = cyouheiString.Split (delimiterChars);
										if (activeItemId == 1) {
											int tempQty = int.Parse (cyouheiList [0]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2];
											
										} else if (activeItemId == 2) {
											int tempQty = int.Parse (cyouheiList [1]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2];
											
										} else if (activeItemId == 3) {
											int tempQty = int.Parse (cyouheiList [2]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString ();
										}
										
										PlayerPrefs.SetString ("cyouheiTP", newCyouheiString);

									} else if (activeItemType.Contains ("YM") == true) {
										string cyouheiString = PlayerPrefs.GetString ("cyouheiYM");
										string[] cyouheiList = cyouheiString.Split (delimiterChars);
										if (activeItemId == 1) {
											int tempQty = int.Parse (cyouheiList [0]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2];
											
										} else if (activeItemId == 2) {
											int tempQty = int.Parse (cyouheiList [1]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2];
											
										} else if (activeItemId == 3) {
											int tempQty = int.Parse (cyouheiList [2]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString ();
										}
										
										PlayerPrefs.SetString ("cyouheiYM", newCyouheiString);
									}


									//Kanjyo
								} else if (activeItemType == "Kanjyo") {
									makeItemIcon (kanjyoPath, activeItemId.ToString (), itemListObj);

									string newKanjyoString = "";
									string kanjyoString = PlayerPrefs.GetString ("kanjyo");
									string[] kanjyoList = kanjyoString.Split (delimiterChars);

									if (activeItemId == 1) {
										int tempQty = int.Parse (kanjyoList [0]);
										tempQty = tempQty + activeItemQty;
										newKanjyoString = tempQty.ToString () + "," + kanjyoList [1] + "," + kanjyoList [2];
										
									} else if (activeItemId == 2) {
										int tempQty = int.Parse (kanjyoList [1]);
										tempQty = tempQty + activeItemQty;
										newKanjyoString = kanjyoList [0] + "," + tempQty.ToString () + "," + kanjyoList [2];
										
									} else if (activeItemId == 3) {
										int tempQty = int.Parse (kanjyoList [2]);
										tempQty = tempQty + activeItemQty;
										newKanjyoString = kanjyoList [0] + "," + kanjyoList [1] + "," + tempQty.ToString ();
									}
									PlayerPrefs.SetString ("kanjyo", newKanjyoString);
								
									//Hidensyo
								} else if (activeItemType == "Hidensyo") {
									makeItemIcon (hidensyoPath, activeItemId.ToString (), itemListObj);

									if (activeItemId == 1) {
										int hidensyoQty = PlayerPrefs.GetInt ("hidensyoGe");
										hidensyoQty = hidensyoQty + activeItemQty;
										PlayerPrefs.SetInt ("hidensyoGe", hidensyoQty);

									} else if (activeItemId == 2) {
										int hidensyoQty = PlayerPrefs.GetInt ("hidensyoCyu");
										hidensyoQty = hidensyoQty + activeItemQty;
										PlayerPrefs.SetInt ("hidensyoCyu", hidensyoQty);

									} else if (activeItemId == 3) {
										int hidensyoQty = PlayerPrefs.GetInt ("hidensyoJyo");
										hidensyoQty = hidensyoQty + activeItemQty;
										PlayerPrefs.SetInt ("hidensyoJyo", hidensyoQty);
									}

									//Shinobi
								} else if (activeItemType == "Shinobi") {
									makeItemIcon (shinobiPath, activeItemId.ToString (), itemListObj);
									RectTransform rect = itemListObj.transform.FindChild ("itemIcon").transform.FindChild ("Shinobi").GetComponent<RectTransform> ();
									rect.sizeDelta = new Vector2 (100, 100);


									if (activeItemId == 1) {
										int newQty = 0;
										int shinobiQty = PlayerPrefs.GetInt ("shinobiGe");
										newQty = shinobiQty + activeItemQty;
										PlayerPrefs.SetInt ("shinobiGe", newQty);

									} else if (activeItemId == 2) {
										int newQty = 0;
										int shinobiQty = PlayerPrefs.GetInt ("shinobiCyu");
										newQty = shinobiQty + activeItemQty;
										PlayerPrefs.SetInt ("shinobiCyu", newQty);

									} else if (activeItemId == 3) {
										int newQty = 0;
										int shinobiQty = PlayerPrefs.GetInt ("shinobiJyo");
										newQty = shinobiQty + activeItemQty;
										PlayerPrefs.SetInt ("shinobiJyo", newQty);

									}								
								
									//tech
								} else if (activeItemType == "tech") {
									string path = "Prefabs/Item/Tech/Tech";
									GameObject tech = Instantiate (Resources.Load (path)) as GameObject;
									tech.transform.SetParent (itemListObj.transform);
									tech.transform.localScale = new Vector2 (0.4f, 0.4f);
									RectTransform techTransform = tech.GetComponent<RectTransform> ();
									techTransform.sizeDelta = new Vector2 (100, 100);
									techTransform.anchoredPosition3D = new Vector3 (650, 110, 0);
									tech.GetComponent<Button> ().enabled = false;

									string spritePath = "";
									if (activeItemId == 1) {
										//TP
										int qty = PlayerPrefs.GetInt ("transferTP", 0);
										int newQty = qty + activeItemQty;
										PlayerPrefs.SetInt ("transferTP", newQty);
										spritePath = "Prefabs/Item/Tech/Sprite/tp";

									} else if (activeItemId == 2) {
										int qty = PlayerPrefs.GetInt ("transferKB", 0);
										int newQty = qty + activeItemQty;
										PlayerPrefs.SetInt ("transferKB", newQty);
										spritePath = "Prefabs/Item/Tech/Sprite/kb";

									} else if (activeItemId == 3) {
										int qty = PlayerPrefs.GetInt ("transferSNB", 0);
										int newQty = qty + activeItemQty;
										PlayerPrefs.SetInt ("transferSNB", newQty);
										spritePath = "Prefabs/Item/Tech/Sprite/snb";
									}
										
									tech.GetComponent<Image> ().sprite = 
										Resources.Load (spritePath, typeof(Sprite)) as Sprite;
									
								
									//cyoutei or koueki
								} else if (activeItemType == "cyoutei" || activeItemType == "koueki") {

									if (activeItemType == "cyoutei") {
										string syoukaijyoPath = "Prefabs/Item/cyoutei";
										GameObject icon = Instantiate (Resources.Load (syoukaijyoPath)) as GameObject;
										icon.transform.SetParent (itemListObj.transform);
										icon.transform.localPosition = new Vector3 (250, 35, 0);
										icon.transform.localScale = new Vector2 (0.4f, 0.4f);
										icon.GetComponent<Button> ().enabled = false;

										if (activeItemId == 1) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "山科言継";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "下";
										} else if (activeItemId == 2) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "三条西実枝";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "中";
										} else if (activeItemId == 3) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "近衛前久";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "上";
										}

									} else if (activeItemType == "koueki") {
										string syoukaijyoPath = "Prefabs/Item/koueki";
										GameObject icon = Instantiate (Resources.Load (syoukaijyoPath)) as GameObject;
										icon.transform.SetParent (itemListObj.transform);
										icon.transform.localPosition = new Vector3 (250, 35, 0);
										icon.transform.localScale = new Vector2 (0.4f, 0.4f);
										icon.GetComponent<Button> ().enabled = false;

										if (activeItemId == 1) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "加藤浄与";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "下";
										} else if (activeItemId == 2) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "島井宗室";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "中";
										} else if (activeItemId == 3) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "茶屋四郎次郎";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "上";
										}
									}

									TabibitoItemGetter syoukaijyo = new TabibitoItemGetter ();
									syoukaijyo.registerKouekiOrCyoutei (activeItemType, activeItemId);
								
								} else if (activeItemType == "Tama") {

									string path = "Prefabs/Item/Tama";
									GameObject icon = Instantiate (Resources.Load (path)) as GameObject;
									icon.transform.SetParent (itemListObj.transform);
									icon.transform.localPosition = new Vector3 (250, 35, 0);
									icon.transform.localScale = new Vector2 (0.4f, 0.4f);
									icon.GetComponent<Button> ().enabled = false;
								
									int nowQty = PlayerPrefs.GetInt ("busyoDama");
									int newQty = nowQty + activeItemQty;
									PlayerPrefs.SetInt ("busyoDama", newQty);

								}


							} else if (activeItemGrp == "kahou") {
								//Kahou
								string kahouIconPath = "Prefabs/Item/Kahou/" + activeItemType + activeItemId;
								GameObject kahouIcon = Instantiate (Resources.Load (kahouIconPath)) as GameObject;
								kahouIcon.transform.SetParent (itemListObj.transform);
								kahouIcon.name = "itemIcon";
								kahouIcon.transform.localPosition = new Vector3 (250, 35, 0);
								kahouIcon.transform.localScale = new Vector2 (0.4f, 0.4f);
								RectTransform kahouTransform = kahouIcon.GetComponent<RectTransform> ();
								kahouTransform.sizeDelta = new Vector2 (100, 100);

								GameObject rank = kahouIcon.transform.FindChild ("Rank").gameObject;
								rank.transform.localScale = new Vector2 (0.3f, 0.3f);
								rank.transform.localPosition = new Vector2 (20, -20);

								//Register
								addKahou (activeItemType, activeItemId);
							}

							//Qty
							string itemQtyPath = "Prefabs/PostKassen/itemQty";
							GameObject itemQtyObj = Instantiate (Resources.Load (itemQtyPath)) as GameObject;
							itemQtyObj.transform.SetParent (itemListObj.transform);
							itemQtyObj.transform.localScale = new Vector2 (0.09f, 0.09f);
							itemQtyObj.transform.localPosition = new Vector2 (290, 35);
							itemQtyObj.GetComponent<Text> ().text = "x " + activeItemQty.ToString ();

							
							PlayerPrefs.Flush ();
						}

					} else {
						itemListObj.transform.FindChild ("stageName").transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "成功";
					}
					
					//Money
					int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney",0);
					GameObject.Find ("moneyAmt").GetComponent<Text>().text = activeStageMoney.ToString();
					int currentMoney = PlayerPrefs.GetInt("money");
					currentMoney = currentMoney + activeStageMoney;
					PlayerPrefs.SetInt("money",currentMoney);

					//kuniExp
					int activeStageExp = PlayerPrefs.GetInt("activeStageExp",0);
					GameObject.Find ("expAmt").GetComponent<Text>().text = activeStageExp.ToString();
					int currentKuniExp = PlayerPrefs.GetInt ("kuniExp");
					currentKuniExp = currentKuniExp + activeStageExp;
					int kuniLv = PlayerPrefs.GetInt ("kuniLv");
					Exp kuniExp = new Exp();
					int newKuniLv = kuniExp.getKuniLv(kuniLv,currentKuniExp);

					if(newKuniLv>kuniLv){
						//lv up
						int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv);
						int stockLimit = kuniExp.getStockLimit(newKuniLv);
						PlayerPrefs.SetInt("jinkeiLimit",jinkeiLimit);
						PlayerPrefs.SetInt("stockLimit",stockLimit);


					}else{
						Debug.Log ("No level up");
					}

					/*Cleared Flag*/
					if(!isAttackedFlg){
						int activeKuniId  = PlayerPrefs.GetInt("activeKuniId");
						int activeStageId = PlayerPrefs.GetInt("activeStageId");
						string temp = "kuni" + activeKuniId.ToString();

						List<string> clearedStageList = new List<string>();
						string clearedStageString  = PlayerPrefs.GetString(temp);

						if(clearedStageString !=null && clearedStageString !=""){
							//after 1st time
							char[] delimiterChars = {','};
							clearedStageList = new List<string>(clearedStageString.Split (delimiterChars));
							if(clearedStageList.Contains(activeStageId.ToString()) == false){
								clearedStageString = clearedStageString + "," + activeStageId.ToString();

								//1st Kuni Clear Check
								string[] commaCounter = clearedStageString.Split(delimiterChars);
								int counter = commaCounter.Length;

								if(counter == 10){
									//1st time
									string clearedKuni = PlayerPrefs.GetString("clearedKuni");
									if(clearedKuni !=null && clearedKuni !=""){
										clearedKuni = clearedKuni + "," + activeKuniId.ToString();
									}else{
										clearedKuni = activeKuniId.ToString();
									}
									PlayerPrefs.SetString("clearedKuni",clearedKuni);
									//Give 1st cleared revenue 
									PlayerPrefs.SetBool("kuniClearedFlg",true);

									//Open Kuni
									KuniInfo kuni = new KuniInfo();
									kuni.registerOpenKuni(activeKuniId);

									//Seiryoku Change
									string seiryoku = PlayerPrefs.GetString ("seiryoku");
									List<string> seiryokuList = new List<string>();
									seiryokuList = new List<string> (seiryoku.Split (delimiterChars));

									int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
									seiryokuList[activeKuniId-1] = myDaimyo.ToString();
									string newSeiryoku = "";
									bool gameClearFlg = true;
									for(int i=0; i<seiryokuList.Count; i++){
										if(i==0){
											newSeiryoku = seiryokuList[i];
										}else{
											newSeiryoku = newSeiryoku + "," + seiryokuList[i];
										}

										//game clear check
										if(gameClearFlg){
											if(seiryokuList[i] != myDaimyo.ToString()){
												gameClearFlg = false;
											}
										}
									}
									PlayerPrefs.SetBool("gameClearFlg",gameClearFlg);
									PlayerPrefs.SetString("seiryoku",newSeiryoku);


									//Cyouhou Delete
									string cyouhouTmp = "cyouhou" + activeKuniId;
									if (PlayerPrefs.HasKey (cyouhouTmp)) {
										PlayerPrefs.DeleteKey(cyouhouTmp);

										string cyouhou = PlayerPrefs.GetString("cyouhou");
										List<string> cyouhouList = new List<string> ();
										if (cyouhou != null && cyouhou != "") {
											if(cyouhou.Contains(",")){
												cyouhouList = new List<string> (cyouhou.Split (delimiterChars));
											}else{
												cyouhouList.Add(cyouhou);
											}
										}

										cyouhouList.Remove (activeKuniId.ToString());
										string newCyouhou = "";
										for(int j=0;j<cyouhouList.Count;j++){
											if (j == 0) {
												newCyouhou = cyouhouList[j];
											} else {
												newCyouhou = newCyouhou + "," + cyouhouList[j];
											}
										}
										PlayerPrefs.SetString ("cyouhou",newCyouhou);

									}
								}
							}
						}else{
							//1st time
							clearedStageString = activeStageId.ToString();
						}
						PlayerPrefs.SetString(temp,clearedStageString);

						PlayerPrefs.SetInt("kuniLv",newKuniLv);
						PlayerPrefs.SetInt("kuniExp",currentKuniExp);
						PlayerPrefs.Flush();
					}

					//Button List
					string nextbtnPath = "Prefabs/PostKassen/bttnList";
					GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject;
					bttnListObj.transform.SetParent (canvas.transform);
					bttnListObj.transform.localScale = new Vector2(1,1);
					bttnListObj.transform.localPosition = new Vector2 (0,0);

					//Time Stop
					GameObject.Find ("timer").GetComponent<Timer>().enabled = false;


					//Get Exp
					SenkouButton senkou = new SenkouButton();
					List<BusyoSenkou> senkouList = new List<BusyoSenkou>();
					senkouList=senkou.getSenkou ();
					for(int i=0;i<senkouList.Count;i++){

						int busyoId = senkouList[i].id;
						int senkouAmt = senkouList[i].senkou;
						Exp exp = new Exp();

						//Modify by Cyadougu Kahou
						senkouAmt = exp.getExpbyCyadougu(busyoId,senkouAmt);

						//Busyo Exp
						string tempExp = "exp" + busyoId;
						int nowExp = PlayerPrefs.GetInt(tempExp);
						int newExp = nowExp + senkouAmt;
						PlayerPrefs.SetInt(tempExp, newExp);

						//Busyo Lv
						int nowLv = PlayerPrefs.GetInt(busyoId.ToString());
						int newLv = exp.getLvbyTotalExp(nowLv,newExp);
						PlayerPrefs.SetInt(busyoId.ToString(), newLv);

						PlayerPrefs.Flush();
					}
				}
			}
		}
	}
コード例 #9
0
    public void OnClick()
    {
        int     nowHyourou = PlayerPrefs.GetInt("hyourou");
        Message msg        = new Message();

        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        if (name == "Back")
        {
            scrollObj.SetActive(false);
            audioSources [1].Play();
        }
        else
        {
            if (nowHyourou < 2)
            {
                msg.makeUpperMessageOnBoard(msg.getMessage(7));
            }
            else
            {
                //Track
                int TrackBouryakuNo = PlayerPrefs.GetInt("TrackBouryakuNo", 0);
                TrackBouryakuNo = TrackBouryakuNo + 1;
                PlayerPrefs.SetInt("TrackBouryakuNo", TrackBouryakuNo);


                nowHyourou = nowHyourou - 2;
                PlayerPrefs.SetInt("hyourou", nowHyourou);
                GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = nowHyourou.ToString();

                //Do
                StartKassen script = GameObject.Find("BattleButton").GetComponent <StartKassen> ();
                activeKuniId  = script.activeKuniId;
                activeStageId = script.activeStageId;

                DoGaikou addUsedBusyo = new DoGaikou();


                if (linkCutFlg)
                {
                    //link cut

                    //Make target list
                    string     temp    = "kuniMap" + activeKuniId;
                    GameObject kuniMap = GameObject.Find(temp).gameObject;

                    List <string> targetList = new List <string> ();
                    foreach (Transform obj in kuniMap.transform)
                    {
                        if (obj.tag == "Link")
                        {
                            string objName = obj.name;
                            objName = objName.Replace("link", "");

                            List <string> linkList       = new List <string> ();
                            char[]        delimiterChars = { '-' };
                            linkList = new List <string> (objName.Split(delimiterChars));

                            if (int.Parse(linkList [0]) == activeStageId)
                            {
                                targetList.Add(objName);
                            }
                            else if (int.Parse(linkList [1]) == activeStageId)
                            {
                                targetList.Add(objName);
                            }
                        }
                    }



                    okRatio = ((float)cyouhouSnbRankId * (float)dfc) / 8;
                    if (targetList.Count != 0)
                    {
                        int  okCount  = 0;
                        bool okMsgFlg = false;
                        for (int i = 0; i < targetList.Count; i++)
                        {
                            //success or not
                            float percent = UnityEngine.Random.value;
                            percent = percent * 100;

                            if (percent <= okRatio)
                            {
                                //Track
                                int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0);
                                TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1;
                                PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo);

                                //OK Cut
                                okMsgFlg = true;
                                string     target    = "link" + targetList [i];
                                GameObject targetObj = kuniMap.transform.FindChild(target).gameObject;
                                Destroy(targetObj.gameObject);


                                //Register Data
                                string tempLinkuct = "linkcut" + activeKuniId;
                                string linkcut     = PlayerPrefs.GetString(tempLinkuct);
                                string newLinkcut  = "";
                                if (linkcut != null && linkcut != "")
                                {
                                    newLinkcut = linkcut + "," + targetList [i];
                                }
                                else
                                {
                                    newLinkcut = targetList [i];
                                }
                                PlayerPrefs.SetString(tempLinkuct, newLinkcut);

                                PlayerPrefs.SetBool("questDailyFlg34", true);
                                PlayerPrefs.Flush();

                                MainStageController mainStage = new MainStageController();
                                mainStage.questExtension();

                                //Reduce Cut No.
                                List <string> linkList       = new List <string> ();
                                char[]        delimiterChars = { '-' };
                                linkList = new List <string> (targetList [i].Split(delimiterChars));

                                string stage1 = "stage" + linkList [0];
                                string stage2 = "stage" + linkList [1];

                                foreach (Transform obj in kuniMap.transform)
                                {
                                    if (obj.tag != "Link")
                                    {
                                        if (obj.name == stage1 || obj.name == stage2)
                                        {
                                            obj.GetComponent <ShowStageDtl> ().linkNo = obj.GetComponent <ShowStageDtl> ().linkNo - 1;
                                        }
                                    }
                                }

                                okCount = okCount + 1;
                            }
                        }
                        if (okMsgFlg)
                        {
                            int TrackLinkCutNo = PlayerPrefs.GetInt("TrackLinkCutNo", 0);
                            TrackLinkCutNo = TrackLinkCutNo + okCount;
                            PlayerPrefs.SetInt("TrackLinkCutNo", TrackLinkCutNo);
                            PlayerPrefs.Flush();
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                msg.makeUpperMessageOnBoard("You cut " + okCount + " line. \n Enemy power keep be down in this season.");
                            }
                            else
                            {
                                msg.makeUpperMessageOnBoard("連絡線を" + okCount + "本遮断しました。\n今季節中は敵戦力が減りますぞ。");
                            }
                            addUsedBusyo.addUsedBusyo(busyoId);
                        }
                        else
                        {
                            msg.makeUpperMessageOnBoard(msg.getMessage(126));
                        }
                    }
                    else
                    {
                        msg.makeUpperMessageOnBoard(msg.getMessage(127));
                    }
                }
                else
                {
                    //cyouryaku
                    okRatio = ((float)cyouhouSnbRankId * (float)dfc) / 8;

                    float percent = UnityEngine.Random.value;
                    percent = percent * 100;

                    if (percent <= okRatio)
                    {
                        //OK
                        //Track
                        int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0);
                        TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1;
                        PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo);

                        string cyouryaku    = PlayerPrefs.GetString("cyouryaku");
                        string cyouryakuTmp = activeKuniId.ToString() + "cyouryaku" + activeStageId.ToString();
                        if (cyouryaku != null && cyouryaku != "")
                        {
                            cyouryaku = cyouryaku + "," + cyouryakuTmp;
                        }
                        else
                        {
                            cyouryaku = cyouryakuTmp;
                        }
                        PlayerPrefs.SetString("cyouryaku", cyouryaku);


                        int cyouryakuHeiQty = 0;
                        if (cyouhouSnbRankId == 1)
                        {
                            cyouryakuHeiQty = UnityEngine.Random.Range(1, 3);
                        }
                        else if (cyouhouSnbRankId == 2)
                        {
                            cyouryakuHeiQty = UnityEngine.Random.Range(1, 4);
                        }
                        else if (cyouhouSnbRankId == 3)
                        {
                            cyouryakuHeiQty = UnityEngine.Random.Range(1, 6);
                        }

                        PlayerPrefs.SetInt(cyouryakuTmp, cyouryakuHeiQty);
                        PlayerPrefs.SetBool("questDailyFlg35", true);

                        int TrackCyouryakuNo = PlayerPrefs.GetInt("TrackCyouryakuNo", 0);
                        TrackCyouryakuNo = TrackCyouryakuNo + cyouryakuHeiQty;
                        PlayerPrefs.SetInt("TrackCyouryakuNo", TrackCyouryakuNo);
                        PlayerPrefs.Flush();

                        MainStageController mainStage = new MainStageController();
                        mainStage.questExtension();
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            msg.makeUpperMessageOnBoard("You are succeed to win over. \n Enemy " + cyouryakuHeiQty.ToString() + " unit will change to player unit in a battle.");
                        }
                        else
                        {
                            msg.makeUpperMessageOnBoard("調略に成功しましたぞ。\n合戦にて" + cyouryakuHeiQty.ToString() + "部隊が寝返ります。");
                        }
                        addUsedBusyo.addUsedBusyo(busyoId);
                    }
                    else
                    {
                        msg.makeUpperMessageOnBoard(msg.getMessage(128));
                    }
                }

                //Push Back Button
                scrollObj.SetActive(false);
            }
        }
    }
コード例 #10
0
    public void OnClick()
    {
        audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        audioSources [5].Play();

        //Hyourou
        int hyourou    = PlayerPrefs.GetInt("hyourou");
        int newHyourou = hyourou - 10;

        PlayerPrefs.SetInt("hyourou", newHyourou);
        GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString();

        //Track
        int TrackToubatsuNo = PlayerPrefs.GetInt("TrackToubatsuNo", 0);

        TrackToubatsuNo = TrackToubatsuNo + 1;
        PlayerPrefs.SetInt("TrackToubatsuNo", TrackToubatsuNo);

        MainStageController script = GameObject.Find("GameController").GetComponent <MainStageController> ();

        myKuniQty             = script.myKuniQty;
        myDaimyo              = script.myDaimyo;
        myKuniQtyIsBiggestFlg = GameObject.Find("bakuhuReturn").GetComponent <BakuhuMenuReturn> ().myKuniQtyIsBiggestFlg;
        List <string> messageList = new List <string> ();

        //reduce yukoudo
        Gaikou   gaikou   = new Gaikou();
        DoGaikou doGaikou = new DoGaikou();
        int      myGaikouValueWithTarget = gaikou.getMyGaikou(targetDaimyoId);
        int      newYukoudoWithTarget    = gaikou.downMyGaikou(targetDaimyoId, myGaikouValueWithTarget, 50);
        int      reducedValueWithTarget  = myGaikouValueWithTarget - newYukoudoWithTarget;
        string   firstKassenText         = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            firstKassenText = "Declared " + targetDaimyoName + " attack order. \n Friendship reduced " + reducedValueWithTarget + " point.";
        }
        else
        {
            firstKassenText = targetDaimyoName + "討伐を宣言しました。\n当家との友好度が" + reducedValueWithTarget + "下がります。";
        }
        doGaikou.downYukouOnIcon(targetDaimyoId, newYukoudoWithTarget);
        messageList.Add(firstKassenText);

        //doumei check
        Doumei   doumei         = new Doumei();
        KuniInfo kuni           = new KuniInfo();
        bool     doumeiExistFlg = doumei.myDoumeiExistCheck(targetDaimyoId);

        if (doumeiExistFlg)
        {
            doumei.deleteDoumei(myDaimyo.ToString(), targetDaimyoId.ToString());

            //Change Map & Yukoudo
            kuni.deleteDoumeiKuniIcon(targetDaimyoId);
        }
        PlayerPrefs.Flush();


        //Listup Target kuni Id
        string        seiryoku     = PlayerPrefs.GetString("seiryoku");
        List <string> seiryokuList = new List <string> ();

        char[] delimiterChars = { ',' };
        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));
        List <int> targetKuniList = new List <int> ();

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            if (int.Parse(seiryokuList [i]) == targetDaimyoId)
            {
                int kuniId = i + 1;
                targetKuniList.Add(kuniId);
            }
        }

        //Listup Available Open kuni
        List <string>           srcDstKuniList = new List <string> ();
        Entity_kuni_mapping_mst kuniMapMst     = Resources.Load("Data/kuni_mapping_mst") as Entity_kuni_mapping_mst;

        for (int j = 0; j < targetKuniList.Count; j++)
        {
            int tmpTargetKuniId = targetKuniList [j];

            for (int i = 0; i < kuniMapMst.param.Count; i++)
            {
                int temClearedKuniId = kuniMapMst.param[i].Souce;
                if (temClearedKuniId == tmpTargetKuniId)
                {
                    int openKuniId = kuniMapMst.param [i].Open;

                    if (int.Parse(seiryokuList [openKuniId - 1]) != targetDaimyoId &&
                        int.Parse(seiryokuList [openKuniId - 1]) != myDaimyo)
                    {
                        srcDstKuniList.Add(openKuniId.ToString() + "-" + tmpTargetKuniId.ToString());
                    }
                }
            }
        }

        //Shuffule
        for (int i = 0; i < srcDstKuniList.Count; i++)
        {
            string temp        = srcDstKuniList[i];
            int    randomIndex = Random.Range(i, srcDstKuniList.Count);
            srcDstKuniList[i]           = srcDstKuniList[randomIndex];
            srcDstKuniList[randomIndex] = temp;
        }

        /*Condition of succesful*/
        //1. number of own kuni is more thab twice as number as target ... 20%
        //2. number of own kuni is the largest ... 30%
        //3. relathionship btwn my party and src kuni is 100% ... 20%
        //4. relathionship btwn the other countiries each other is 0% ... 20%
        //5. attacker keep kuni number more than country receiving attack ... 10%

        //1.
        if (myKuniQty > 2 * kuniQty)
        {
            baseRatio = 20;
        }

        //2.
        if (myKuniQtyIsBiggestFlg)
        {
            baseRatio = baseRatio + 30;
        }

        //Make Gunzei
        char[]           delimiterChars2    = { '-' };
        GameObject       BakuhuKuniIconView = GameObject.Find("BakuhuKuniIconView").gameObject;
        string           path              = "Prefabs/Map/Gunzei";
        string           visualizePath     = "Prefabs/Bakuhu/ToubatsuSrcBusyo";
        GameObject       panel             = GameObject.Find("Panel").gameObject;
        Gunzei           gunzei            = new Gunzei();
        Daimyo           daimyo            = new Daimyo();
        MainEventHandler mEvent            = new MainEventHandler();
        List <int>       doneSrcDaimyoList = new List <int> ();

        for (int k = 0; k < srcDstKuniList.Count; k++)
        {
            float indvRatio = 0;

            string        key        = srcDstKuniList[k];
            List <string> srcDstList = new List <string> ();
            srcDstList = new List <string> (key.Split(delimiterChars2));

            //3
            int srcKuniId = int.Parse(srcDstList[0]);
            int srcDaimyo = int.Parse(seiryokuList[srcKuniId - 1]);

            if (!doneSrcDaimyoList.Contains(srcDaimyo))
            {
                doneSrcDaimyoList.Add(srcDaimyo);
                bool ExistFlg = false;
                foreach (GameObject obs in  GameObject.FindGameObjectsWithTag("Gunzei"))
                {
                    int gunzeiSrcDaimyoId = obs.GetComponent <Gunzei>().srcDaimyoId;

                    if (srcDaimyo == gunzeiSrcDaimyoId)
                    {
                        ExistFlg = true;
                    }
                }

                if (!ExistFlg)
                {
                    int myGaikouValue = gaikou.getMyGaikou(srcDaimyo);
                    indvRatio = baseRatio + (float)myGaikouValue / 5;

                    //4.
                    int dstKuniId        = int.Parse(srcDstList [1]);
                    int dstDaimyo        = int.Parse(seiryokuList [dstKuniId - 1]);
                    int otherGaikouValue = gaikou.getOtherGaikouValue(srcDaimyo, dstDaimyo);
                    indvRatio = indvRatio + (float)((100 - otherGaikouValue) / 5);

                    //5.
                    int   srcKuniQty = BakuhuKuniIconView.transform.FindChild(srcDstList [0]).GetComponent <SendParam> ().kuniQty;
                    float addRatio   = 0;
                    if (srcKuniQty >= kuniQty)
                    {
                        addRatio  = 10;
                        indvRatio = indvRatio + addRatio;
                    }

                    //Success Check
                    float percent = UnityEngine.Random.value;
                    percent = percent * 100;
                    if (percent <= indvRatio)
                    {
                        //OK
                        toubatsuFlg = true;
                        GameObject Gunzei = Instantiate(Resources.Load(path)) as GameObject;
                        Gunzei.transform.SetParent(panel.transform);
                        Gunzei.transform.localScale = new Vector2(1, 1);

                        GameObject minGunzei = Instantiate(Resources.Load(visualizePath)) as GameObject;
                        minGunzei.transform.SetParent(BakuhuKuniIconView.transform);
                        int    daimyoBusyoId = daimyo.getDaimyoBusyoId(srcDaimyo);
                        string daimyoPath    = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString();
                        minGunzei.GetComponent <SpriteRenderer> ().sprite =
                            Resources.Load(daimyoPath, typeof(Sprite)) as Sprite;

                        //Location
                        int    srcX      = kuni.getKuniLocationX(srcKuniId);
                        int    srcY      = kuni.getKuniLocationY(srcKuniId);
                        int    dstX      = kuni.getKuniLocationX(dstKuniId);
                        int    dstY      = kuni.getKuniLocationY(dstKuniId);
                        string direction = "";

                        if (srcX < dstX)
                        {
                            Gunzei.transform.localScale    = new Vector2(1, 1);
                            minGunzei.transform.localScale = new Vector2(60, 72);
                            direction = "right";
                        }
                        else
                        {
                            Gunzei.transform.localScale    = new Vector2(-1, 1);
                            minGunzei.transform.localScale = new Vector2(-60, 72);
                            direction = "left";
                            Gunzei.GetComponent <Gunzei> ().leftFlg = true;
                        }

                        int           aveX            = (srcX + dstX) / 2;
                        int           aveY            = (srcY + dstY) / 2;
                        RectTransform GunzeiTransform = Gunzei.GetComponent <RectTransform> ();
                        GunzeiTransform.anchoredPosition = new Vector3(aveX, aveY, 0);

                        RectTransform minGunzeiTransform = minGunzei.GetComponent <RectTransform> ();
                        float         minAveX            = (float)aveX * 0.8f;
                        float         minAveY            = (float)aveY * 0.65f;
                        minGunzeiTransform.anchoredPosition = new Vector3((int)minAveX, (int)minAveY, 0);


                        Gunzei.GetComponent <Gunzei> ().key         = key;
                        Gunzei.GetComponent <Gunzei> ().srcKuni     = srcKuniId;
                        Gunzei.GetComponent <Gunzei> ().srcDaimyoId = srcDaimyo;
                        string srcDaimyoName = daimyo.getName(srcDaimyo);
                        Gunzei.GetComponent <Gunzei> ().srcDaimyoName = srcDaimyoName;
                        Gunzei.GetComponent <Gunzei> ().dstKuni       = dstKuniId;
                        Gunzei.GetComponent <Gunzei> ().dstDaimyoId   = dstDaimyo;
                        string dstDaimyoName = daimyo.getName(dstDaimyo);
                        Gunzei.GetComponent <Gunzei> ().dstDaimyoName = dstDaimyoName;
                        int myHei = gunzei.heiryokuCalc(srcKuniId);

                        //random myHei from -50%-myHei
                        List <float> randomPercent = new List <float> {
                            0.8f, 0.9f, 1.0f
                        };
                        int   rmd = UnityEngine.Random.Range(0, randomPercent.Count);
                        float per = randomPercent [rmd];
                        myHei = Mathf.CeilToInt(myHei * per);

                        Gunzei.GetComponent <Gunzei> ().myHei = myHei;
                        Gunzei.name = key;

                        //Engun from Doumei
                        List <string> doumeiDaimyoList = new List <string> ();
                        bool          dstEngunFlg      = false;
                        string        dstEngunDaimyoId = "";             //2:3:5
                        string        dstEngunHei      = "";
                        string        dstEngunSts      = "";             //BusyoId-BusyoLv-ButaiQty-ButaiLv:
                        int           totalEngunHei    = 0;

                        //Doumei Check
                        doumeiDaimyoList = doumei.doumeiExistCheck(dstDaimyo, srcDaimyo.ToString());
                        string doumeiCheck = "doumei" + srcDaimyo;
                        if (PlayerPrefs.HasKey(doumeiCheck))
                        {
                            string        cDoumei     = PlayerPrefs.GetString(doumeiCheck);
                            List <string> cDoumeiList = new List <string>();
                            if (cDoumei.Contains(","))
                            {
                                cDoumeiList = new List <string> (cDoumei.Split(delimiterChars));
                            }
                            else
                            {
                                cDoumeiList.Add(cDoumei);
                            }

                            //If Doumei Daimyo -> Delete
                            if (cDoumeiList.Contains(dstDaimyo.ToString()))
                            {
                                doumei.deleteDoumei(srcDaimyo.ToString(), dstDaimyo.ToString());
                            }
                        }

                        if (doumeiDaimyoList.Count != 0)
                        {
                            //Doumei Exist

                            //Trace Check
                            List <string> okDaimyoList = new List <string> ();
                            List <string> checkList    = new List <string> ();
                            okDaimyoList = doumei.traceNeighborDaimyo(dstKuniId, dstDaimyo, doumeiDaimyoList, seiryokuList, checkList, okDaimyoList);

                            if (okDaimyoList.Count != 0)
                            {
                                //Doumei & Neghbor Daimyo Exist

                                for (int h = 0; h < okDaimyoList.Count; h++)
                                {
                                    string engunDaimyo = okDaimyoList[h];
                                    int    yukoudo     = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), dstDaimyo);

                                    //engun check

                                    dstEngunFlg = mEvent.CheckByProbability(yukoudo);
                                    if (dstEngunFlg)
                                    {
                                        //Engun OK
                                        dstEngunFlg = true;
                                        if (dstEngunDaimyoId != null && dstEngunDaimyoId != "")
                                        {
                                            dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo;
                                            string tempEngunSts = engunDaimyo + "-" + mEvent.getEngunSts(engunDaimyo);
                                            int    tempEngunHei = mEvent.getEngunHei(tempEngunSts);
                                            dstEngunHei   = dstEngunHei + ":" + tempEngunHei.ToString();
                                            totalEngunHei = totalEngunHei + tempEngunHei;
                                            dstEngunSts   = dstEngunSts + ":" + tempEngunSts;
                                        }
                                        else
                                        {
                                            dstEngunDaimyoId = engunDaimyo;
                                            string tempEngunSts = engunDaimyo + "-" + mEvent.getEngunSts(engunDaimyo);
                                            int    tempEngunHei = mEvent.getEngunHei(tempEngunSts);
                                            dstEngunHei   = tempEngunHei.ToString();
                                            totalEngunHei = tempEngunHei;
                                            dstEngunSts   = tempEngunSts;
                                        }
                                    }
                                }
                                Gunzei.GetComponent <Gunzei> ().dstEngunFlg      = dstEngunFlg;
                                Gunzei.GetComponent <Gunzei> ().dstEngunDaimyoId = dstEngunDaimyoId;
                                Gunzei.GetComponent <Gunzei> ().dstEngunHei      = dstEngunHei;
                                Gunzei.GetComponent <Gunzei> ().dstEngunSts      = dstEngunSts;
                            }
                        }

                        //Set Value
                        //CreateTime,srcDaimyoId,dstDaimyoId,srcDaimyoName,dstDaimyoName, srcHei,locationX,locationY,left or right, engunFlg, engunDaimyoId(A:B:C), dstEngunHei(1000:2000:3000), dstEngunSts
                        string keyValue   = "";
                        string createTime = System.DateTime.Now.ToString();
                        keyValue = createTime + "," + srcDaimyo + "," + dstDaimyo + "," + srcDaimyoName + "," + dstDaimyoName + "," + myHei + "," + aveX + "," + aveY + "," + direction + "," + dstEngunFlg + "," + dstEngunDaimyoId + "," + dstEngunHei + "," + dstEngunSts;
                        PlayerPrefs.SetString(key, keyValue);
                        string keyHistory = PlayerPrefs.GetString("keyHistory");
                        if (keyHistory == null || keyHistory == "")
                        {
                            keyHistory = key;
                        }
                        else
                        {
                            keyHistory = keyHistory + "," + key;
                        }
                        PlayerPrefs.SetString("keyHistory", keyHistory);
                        PlayerPrefs.SetInt("bakuhuTobatsuDaimyoId", dstDaimyo);
                        PlayerPrefs.Flush();

                        string kassenText = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            if (!dstEngunFlg)
                            {
                                kassenText = srcDaimyoName + " is attacking " + dstDaimyoName + " with " + myHei + " soldiers.";
                            }
                            else
                            {
                                kassenText = srcDaimyoName + " is attacking " + dstDaimyoName + " with " + myHei + " soldiers.\n Defender's allianced country sent " + totalEngunHei + " soldiers.";
                            }
                        }
                        else
                        {
                            if (!dstEngunFlg)
                            {
                                kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。";
                            }
                            else
                            {
                                kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。\n防衛側の同盟国が援軍" + totalEngunHei + "人を派兵しました。";
                            }
                        }
                        messageList.Add(kassenText);
                    }
                    else
                    {
                        //NG
                        string kassenText    = "";
                        string srcDaimyoName = daimyo.getName(srcDaimyo);
                        int    newYukoudo    = gaikou.downMyGaikou(srcDaimyo, myGaikouValue, 15);
                        int    reducedValue  = myGaikouValue - newYukoudo;
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            kassenText = srcDaimyoName + " rejected our attack order. Friendship reduced " + reducedValue + " point.";
                        }
                        else
                        {
                            kassenText = srcDaimyoName + "が討伐令を黙殺しました。当家との友好度が" + reducedValue + "下がります。";
                        }
                        doGaikou.downYukouOnIcon(srcDaimyo, newYukoudo);
                        messageList.Add(kassenText);
                    }
                }
            }
        }


        //Disabled
        foreach (Transform obj in BakuhuKuniIconView.transform)
        {
            if (obj.GetComponent <Button> ())
            {
                obj.GetComponent <Button> ().enabled = false;
            }
        }

        GameObject toubatsuSelect = GameObject.Find("ToubatsuSelect").gameObject;

        toubatsuSelect.transform.FindChild("ToubatsuBtn").gameObject.SetActive(false);
        if (toubatsuFlg)
        {
            audioSources [3].Play();
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                toubatsuSelect.transform.FindChild("Exp").GetComponent <Text> ().text = "Declared " + targetDaimyoName + " attack order. Other family responded to it.";
            }
            else
            {
                toubatsuSelect.transform.FindChild("Exp").GetComponent <Text>().text = targetDaimyoName + "の討伐令を出しました。諸大名が呼応したようです。";
            }
        }
        else
        {
            audioSources [4].Play();
            if (srcDstKuniList.Count == 0)
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    toubatsuSelect.transform.FindChild("Exp").GetComponent <Text> ().text = "There is no family who can respond to " + targetDaimyoName + " attack order.";
                }
                else
                {
                    toubatsuSelect.transform.FindChild("Exp").GetComponent <Text>().text = "現在" + targetDaimyoName + "の討伐に呼応可能な大名はおりません。";
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    toubatsuSelect.transform.FindChild("Exp").GetComponent <Text> ().text = "No family responded to our attack order because of fear for " + targetDaimyoName + ".";
                }
                else
                {
                    toubatsuSelect.transform.FindChild("Exp").GetComponent <Text>().text = targetDaimyoName + "を恐れてか、討伐令にどの大名も呼応しませんでした。";
                }
            }
        }

        Message msg = new Message();

        msg.makeSlotMessage(messageList);
    }
コード例 #11
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        Message       msg          = new Message();

        if (name != "PassButton")
        {
            //Syoukaijyo Confirm Pop
            audioSources [0].Play();

            //Back
            string     pathOfBack = "Prefabs/Cyoutei/TouchBackLayer";
            GameObject back       = Instantiate(Resources.Load(pathOfBack)) as GameObject;
            back.transform.parent        = GameObject.Find("Panel").transform;
            back.transform.localScale    = new Vector2(1, 1);
            back.transform.localPosition = new Vector2(0, 0);

            //Cyoutei Pop
            string     pathOfPop = "Prefabs/Cyoutei/SelectSyoukaijyoBoard";
            GameObject pop       = Instantiate(Resources.Load(pathOfPop)) as GameObject;
            pop.transform.parent        = GameObject.Find("Panel").transform;
            pop.transform.localScale    = new Vector2(1, 1);
            pop.transform.localPosition = new Vector2(0, 0);
            pop.name = "SelectSyoukaijyoBoard";
            back.GetComponent <CloseLayer> ().closeTargetObj  = pop;
            back.GetComponent <CloseLayer> ().closeTargetBack = back;
            pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetObj  = pop;
            pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetBack = back;

            //Check Syoukaijyo
            string nowQty = PlayerPrefs.GetString("cyoutei");
            //string nowQty = "0,0,0";
            List <string> nowQtyList     = new List <string> ();
            char[]        delimiterChars = { ',' };
            nowQtyList = new List <string> (nowQty.Split(delimiterChars));

            GameObject scrollView = pop.transform.FindChild("ScrollView").gameObject;
            GameObject content    = scrollView.transform.FindChild("Content").gameObject;
            bool       notZeroflg = false;
            //Jyo
            if (nowQtyList [2] == "0")
            {
                content.transform.FindChild("Jyo").gameObject.SetActive(false);
            }
            else
            {
                notZeroflg = true;
                content.transform.FindChild("Jyo").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [2];
                content.transform.FindChild("Jyo").GetComponent <SyoukaijyoSelect>().OnClick();
            }

            //Cyu
            if (nowQtyList [1] == "0")
            {
                content.transform.FindChild("Cyu").gameObject.SetActive(false);
            }
            else
            {
                notZeroflg = true;
                content.transform.FindChild("Cyu").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [1];
                content.transform.FindChild("Cyu").GetComponent <SyoukaijyoSelect>().OnClick();
            }

            //Ge
            if (nowQtyList [0] == "0")
            {
                content.transform.FindChild("Ge").gameObject.SetActive(false);
            }
            else
            {
                notZeroflg = true;
                content.transform.FindChild("Ge").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [0];
                content.transform.FindChild("Ge").GetComponent <SyoukaijyoSelect>().OnClick();
            }


            if (!notZeroflg)
            {
                scrollView.transform.FindChild("NoSyoukaijyo").GetComponent <Text> ().enabled             = true;
                pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = msg.getMessage(16);
                pop.transform.FindChild("PassButton").gameObject.SetActive(false);
            }

            pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().SelectSyoukaijyoBoard = pop;
            pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().myDaimyoFlg           = myDaimyoFlg;
            pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().occupiedDaimyoId      = occupiedDaimyoId;
            pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().occupiedDaimyoName    = occupiedDaimyoName;
            pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().yukoudo = yukoudo;
        }
        else
        {
            //Cyoutei Main Pop

            int hyourou = PlayerPrefs.GetInt("hyourou");
            if (hyourou >= 5)
            {
                int newHyourou = hyourou - 5;
                PlayerPrefs.SetInt("hyourou", newHyourou);
                GameObject.Find("HyourouCurrentValue").GetComponent <Text>().text = newHyourou.ToString();

                //Check Yukoudo
                int ratio = 100 - yukoudo;
                if (myDaimyoFlg)
                {
                    ratio = 0;
                }
                float percent = Random.value;
                percent = percent * 100;

                if (percent > ratio)
                {
                    //Stop Timer
                    stopGunzei();
                    GameObject.Find("GameController").GetComponent <MainStageController>().eventStopFlg = true;

                    audioSources [3].Play();
                    SelectSyoukaijyoBoard.transform.FindChild("CloseBtn").GetComponent <CloseLayer>().OnClick();

                    string     pathOfBack = "Prefabs/Cyoutei/CyouteiBack";
                    GameObject back       = Instantiate(Resources.Load(pathOfBack)) as GameObject;
                    back.transform.parent        = GameObject.Find("Panel").transform;
                    back.transform.localScale    = new Vector2(1, 1);
                    back.transform.localPosition = new Vector2(0, 0);

                    string     pathOfPop = "Prefabs/Cyoutei/CyouteiBoard";
                    GameObject pop       = Instantiate(Resources.Load(pathOfPop)) as GameObject;
                    pop.transform.parent        = GameObject.Find("Panel").transform;
                    pop.transform.localScale    = new Vector2(1, 1);
                    pop.transform.localPosition = new Vector2(0, 0);
                    pop.name = "CyouteiBoard";

                    CloseLayer CloseLayerScript = pop.transform.FindChild("CloseSyoukaijyo").GetComponent <CloseLayer>();
                    CloseLayerScript.closeTargetBack   = back;
                    CloseLayerScript.closeTargetObj    = pop;
                    CloseLayerScript.syoukaijyoRank    = syoukaijyoRank;
                    CloseLayerScript.occupiedFlg       = myDaimyoFlg;
                    CloseLayerScript.syouninCyouteiFlg = true;

                    //RandomValue
                    int yukouAddValue    = 0;
                    int yukouReducePoint = Random.Range(2, 10);

                    int stopBattleRatio       = 0;
                    int stopBattleReducePoint = Random.Range(2, 10);

                    int kanniRatio       = 0;
                    int kanniReducePoint = Random.Range(20, 100);
                    int syoukaijyoRankId = 0;

                    int cyoutekiReducePoint = Random.Range(80, 100);

                    //Change Menu by syoukaijyo rank
                    GameObject action = pop.transform.FindChild("Action").gameObject;
                    if (syoukaijyoRank == "Ge")
                    {
                        List <string> btnNameList = new List <string> ()
                        {
                            "Bakuhu", "Cyouteki"
                        };
                        enableButton(pop, btnNameList);
                        yukouAddValue    = Random.Range(1, 3);
                        stopBattleRatio  = Random.Range(10, 30);
                        kanniRatio       = Random.Range(20, 60);
                        syoukaijyoRankId = 1;
                        action.transform.FindChild("ActionValue").GetComponent <Text>().text    = "1";
                        action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "1";
                    }
                    else if (syoukaijyoRank == "Cyu")
                    {
                        List <string> btnNameList = new List <string> ()
                        {
                            "Bakuhu", "Cyouteki"
                        };
                        enableButton(pop, btnNameList);
                        yukouAddValue    = Random.Range(3, 8);
                        stopBattleRatio  = Random.Range(30, 80);
                        kanniRatio       = Random.Range(40, 80);
                        syoukaijyoRankId = 2;
                        action.transform.FindChild("ActionValue").GetComponent <Text>().text    = "2";
                        action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "2";
                    }
                    else if (syoukaijyoRank == "Jyo")
                    {
                        yukouAddValue    = Random.Range(8, 15);
                        stopBattleRatio  = 100;
                        kanniRatio       = Random.Range(60, 100);
                        syoukaijyoRankId = 3;
                        action.transform.FindChild("ActionValue").GetComponent <Text>().text    = "3";
                        action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "3";
                    }

                    //TargetKanni
                    Kanni kanni   = new Kanni();
                    int   kuniQty = GameObject.Find("GameController").GetComponent <MainStageController>().myKuniQty;
                    int   kanniId = kanni.getRandomKanni(syoukaijyoRankId, kuniQty);

                    //TargetCyouteki
                    string        seiryoku       = PlayerPrefs.GetString("seiryoku");
                    List <string> seiryokuList   = new List <string> ();
                    char[]        delimiterChars = { ',' };
                    seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

                    string        openKuni     = PlayerPrefs.GetString("openKuni");
                    List <string> openKuniList = new List <string> ();
                    openKuniList = new List <string> (openKuni.Split(delimiterChars));

                    int myDaimyo         = PlayerPrefs.GetInt("myDaimyo");
                    int cyoutekiDaimyoId = CloseLayerScript.cyoutekiDaimyo;
                    //openKuniList.RemoveAll (x => x == occupiedDaimyoId.ToString());

                    //my kuni
                    List <string> myKuniList             = new List <string>();
                    List <string> occupiedDaimyoKuniList = new List <string>();
                    for (int i = 0; i < seiryokuList.Count; i++)
                    {
                        int tmpDaimyoId = int.Parse(seiryokuList [i]);
                        if (tmpDaimyoId == myDaimyo)
                        {
                            int kuniId = i + 1;
                            myKuniList.Add(kuniId.ToString());
                        }
                        else if (tmpDaimyoId == occupiedDaimyoId)
                        {
                            int kuniId = i + 1;
                            occupiedDaimyoKuniList.Add(kuniId.ToString());
                        }
                    }
                    openKuniList.RemoveAll(myKuniList.Contains);
                    openKuniList.RemoveAll(occupiedDaimyoKuniList.Contains);


                    int rdmId          = UnityEngine.Random.Range(0, openKuniList.Count);
                    int targetKuniId   = int.Parse(openKuniList[rdmId]);
                    int cyoutekiDaimyo = int.Parse(seiryokuList[targetKuniId - 1]);


                    //reduce cyoutei syoukaijyo
                    DoSell script = new DoSell();
                    script.deleteKouekiOrCyoutei(syoukaijyoRankId, "cyoutei", 1);


                    //Set Parametor
                    CloseLayerScript.yukouAddValue         = yukouAddValue;
                    CloseLayerScript.yukouReducePoint      = yukouReducePoint;
                    CloseLayerScript.stopBattleRatio       = stopBattleRatio;
                    CloseLayerScript.stopBattleReducePoint = stopBattleReducePoint;
                    CloseLayerScript.kanniId = kanniId;
                    if (kanniId != 0)
                    {
                        CloseLayerScript.kanniName        = kanni.getKanniName(kanniId);
                        CloseLayerScript.kanniRatio       = kanniRatio;
                        CloseLayerScript.kanniReducePoint = kanniReducePoint;
                    }
                    CloseLayerScript.cyoutekiDaimyo      = cyoutekiDaimyo;
                    CloseLayerScript.cyoutekiReducePoint = cyoutekiReducePoint;


                    //Cyoutei Point
                    int cyouteiPoint = PlayerPrefs.GetInt("cyouteiPoint");
                    pop.transform.FindChild("CyouteiPoint").transform.FindChild("CyouteiValue").GetComponent <Text>().text = cyouteiPoint.ToString() + "%";


                    bool   doneFirstCyouteiFlg = PlayerPrefs.GetBool("doneFirstCyouteiFlg");
                    Daimyo daimyo = new Daimyo();

                    if (!doneFirstCyouteiFlg)
                    {
                        //1st time
                        PlayerPrefs.SetBool("questSpecialFlg5", true);

                        PlayerPrefs.SetBool("doneFirstCyouteiFlg", true);

                        KuniInfo kuni           = new KuniInfo();
                        int      kuniId         = kuni.getOneKuniId(myDaimyo);
                        int      firstKanniId   = kanni.getKuniKanni(kuniId);
                        string   firstKanniName = kanni.getKanniName(firstKanniId);

                        string myKanni = PlayerPrefs.GetString("myKanni");
                        if (myKanni != null && myKanni != "")
                        {
                            myKanni = myKanni + "," + firstKanniId.ToString();
                        }
                        else
                        {
                            myKanni = firstKanniId.ToString();
                        }
                        PlayerPrefs.SetString("myKanni", myKanni);
                        PlayerPrefs.Flush();

                        MainStageController mainStage = new MainStageController();
                        mainStage.questExtension();
                        string serihu = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            serihu = "Your good rumor has arrived to the Imperial court. Please lend me your power for the world.\n I assigned you as " + firstKanniName + ".";
                        }
                        else
                        {
                            serihu = "天下静謐のため力を貸してくれ。\n" + firstKanniName + "に任ずるぞ。";
                        }
                        pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text>().text = serihu;
                    }
                    else
                    {
                        //2nd time

                        //Serihu
                        string daimyoName = daimyo.getName(myDaimyo);
                        string serihu     = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            serihu = "Lord " + daimyoName + ".\n What do you want?";
                        }
                        else
                        {
                            serihu = "おお、" + daimyoName + "殿。\n此度は何用か。";
                        }
                        pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text>().text = serihu;
                    }
                }
                else
                {
                    audioSources [4].Play();
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        msg.makeMessage("My lord " + occupiedDaimyoName + " disturbed us to visit coart.");
                    }
                    else
                    {
                        msg.makeMessage("御屋形様、" + occupiedDaimyoName + "めに参内を邪魔されました。");
                    }
                }
            }
            else
            {
                audioSources [4].Play();

                //string NGtext = msg.getMessage(7);
                //msg.makeMessage (NGtext);
                msg.hyourouMovieMessage();
            }
        }
    }
コード例 #12
0
    public void changeKuniIconAndParam(int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId)
    {
        //Change Icon
        string     imagePath    = "Prefabs/Kamon/" + srcDaimyoId.ToString();
        GameObject kuniIconView = GameObject.Find("KuniIconView");
        GameObject targetKuni   = kuniIconView.transform.FindChild(dstKuni.ToString()).gameObject;

        targetKuni.GetComponent <Image> ().sprite =
            Resources.Load(imagePath, typeof(Sprite)) as Sprite;

        //Change Tochi Color
        GameObject KuniMap      = GameObject.Find("KuniMap");
        Daimyo     daimyoScript = new Daimyo();
        float      colorR       = daimyoScript.getColorR(srcDaimyoId);
        float      colorG       = daimyoScript.getColorG(srcDaimyoId);
        float      colorB       = daimyoScript.getColorB(srcDaimyoId);
        Color      kuniColor    = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);

        KuniMap.transform.FindChild(dstKuni.ToString()).GetComponent <Image> ().color = kuniColor;

        //Change Yukoudo
        string tmp     = "gaikou" + srcDaimyoId;
        int    yukoudo = PlayerPrefs.GetInt(tmp);

        targetKuni.GetComponent <SendParam> ().myYukouValue = yukoudo;

        /*Change Param*/
        //Set Senryoku
        string        seiryoku     = PlayerPrefs.GetString("seiryoku");
        List <string> seiryokuList = new List <string> ();

        char[] delimiterChars = { ',' };
        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));


        /*Get Winner Kuni Qty*/
        EnemySenryokuCalc calc = new EnemySenryokuCalc();
        int myKuniQty          = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQty;
        //int enemyKuniQty = kuniIconView.transform.FindChild (srcKuni.ToString ()).GetComponent<SendParam> ().kuniQty;
        //int newEnemyKuniQty = enemyKuniQty + 1;

        MainStageController main = new MainStageController();

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            int tmpDaimyoId = int.Parse(seiryokuList [i]);

            if (tmpDaimyoId == srcDaimyoId)
            {
                List <string> checkedKuniList  = new List <string> ();
                int           tmpKuniId        = i + 1;
                int           newWinnerKuniQty = main.countLinkedKuniQty(1, tmpKuniId, tmpDaimyoId, seiryokuList, checkedKuniList);

                //Get New Senryoku
                int busyoQty      = calc.EnemyBusyoQtyCalc(myKuniQty, newWinnerKuniQty, 0);
                int senryokuRatio = daimyoScript.getSenryoku(srcDaimyoId);
                int busyoLv       = calc.EnemyBusyoLvCalc(senryokuRatio);
                int butaiQty      = calc.EnemyButaiQtyCalc(newWinnerKuniQty, myKuniQty);
                int butaiLv       = calc.EnemyButaiLvCalc(senryokuRatio);

                //Change Name of target Kuni by daimyo info
                targetKuni.GetComponent <SendParam> ().daimyoId     = srcDaimyoId;
                targetKuni.GetComponent <SendParam>().daimyoName    = daimyoScript.getName(srcDaimyoId);          //daimyoMst.param [srcDaimyoId - 1].daimyoName;
                targetKuni.GetComponent <SendParam>().daimyoBusyoId = daimyoScript.getDaimyoBusyoId(srcDaimyoId); //daimyoMst.param [srcDaimyoId - 1].busyoId;

                SendParam winnerParam = kuniIconView.transform.FindChild(tmpKuniId.ToString()).GetComponent <SendParam> ();
                winnerParam.busyoQty = busyoQty;
                winnerParam.busyoLv  = busyoLv;
                winnerParam.butaiQty = butaiQty;
                winnerParam.butaiLv  = butaiLv;
                winnerParam.kuniQty  = newWinnerKuniQty;
            }
            else if (tmpDaimyoId == dstDaimyoId)
            {
                List <string> checkedKuniList = new List <string> ();
                int           tmpKuniId       = i + 1;
                int           newLoserKuniQty = main.countLinkedKuniQty(1, tmpKuniId, tmpDaimyoId, seiryokuList, checkedKuniList);

                //Get New Senryoku
                int busyoQty      = calc.EnemyBusyoQtyCalc(myKuniQty, newLoserKuniQty, 0);
                int senryokuRatio = daimyoScript.getSenryoku(dstDaimyoId);//daimyoMst.param [dstDaimyoId - 1].senryoku;
                int busyoLv       = calc.EnemyBusyoLvCalc(senryokuRatio);
                int butaiQty      = calc.EnemyButaiQtyCalc(newLoserKuniQty, myKuniQty);
                int butaiLv       = calc.EnemyButaiLvCalc(senryokuRatio);

                SendParam loserParam = kuniIconView.transform.FindChild(tmpKuniId.ToString()).GetComponent <SendParam> ();
                loserParam.busyoQty = busyoQty;
                loserParam.busyoLv  = busyoLv;
                loserParam.butaiQty = butaiQty;
                loserParam.butaiLv  = butaiLv;
                loserParam.kuniQty  = newLoserKuniQty;
            }
        }



        //Icon Color Change by Doumei Situation
        List <string> myDoumeiList = new List <string> ();
        string        doumeiString = PlayerPrefs.GetString("doumei");

        if (doumeiString != null && doumeiString != "")
        {
            if (doumeiString.Contains(","))
            {
                myDoumeiList = new List <string> (doumeiString.Split(delimiterChars));
            }
            else
            {
                myDoumeiList.Add(doumeiString);
            }
        }
        if (myDoumeiList.Contains(srcDaimyoId.ToString()))
        {
            Color doumeiColor = new Color(100f / 255f, 130f / 255f, 255f / 255f, 255f / 255f);
            targetKuni.GetComponent <SendParam> ().doumeiFlg = true;
            targetKuni.GetComponent <Image>().color          = doumeiColor;
        }

        if (!myDoumeiList.Contains(srcDaimyoId.ToString()) && myDoumeiList.Contains(dstDaimyoId.ToString()))
        {
            Color unDoumeiColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f);
            targetKuni.GetComponent <SendParam> ().doumeiFlg = false;
            targetKuni.GetComponent <Image>().color          = unDoumeiColor;
        }
    }
コード例 #13
0
ファイル: Gunzei.cs プロジェクト: zeimoter/sengoku2d
	public void changeKuniIconAndParam(int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId){

		//Change Icon
		string imagePath = "Prefabs/Kamon/" + srcDaimyoId.ToString ();
		GameObject kuniIconView = GameObject.Find ("KuniIconView");
		GameObject targetKuni = kuniIconView.transform.FindChild(dstKuni.ToString()).gameObject;

		targetKuni.GetComponent<Image> ().sprite = 
			Resources.Load (imagePath, typeof(Sprite)) as Sprite;	

		//Change Tochi Color
		GameObject KuniMap = GameObject.Find ("KuniMap");
		GameObject targetKuniMap = kuniIconView.transform.FindChild(dstKuni.ToString()).gameObject;
		float colorR = (float)daimyoMst.param [srcDaimyoId - 1].colorR;
		float colorG = (float)daimyoMst.param [srcDaimyoId - 1].colorG;
		float colorB = (float)daimyoMst.param [srcDaimyoId - 1].colorB;
		Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);
		KuniMap.transform.FindChild (dstKuni.ToString()).GetComponent<Image> ().color = kuniColor;


		/*Change Param*/
		//Set Senryoku
		string seiryoku = PlayerPrefs.GetString ("seiryoku");
		List<string> seiryokuList = new List<string> ();
		char[] delimiterChars = {','};
		seiryokuList = new List<string> (seiryoku.Split (delimiterChars));


		/*Get Winner Kuni Qty*/
		EnemySenryokuCalc calc = new EnemySenryokuCalc ();
		int myKuniQty = GameObject.Find ("GameController").GetComponent<MainStageController> ().myKuniQty;
		//int enemyKuniQty = kuniIconView.transform.FindChild (srcKuni.ToString ()).GetComponent<SendParam> ().kuniQty;
		//int newEnemyKuniQty = enemyKuniQty + 1;

		MainStageController main = new MainStageController ();

		for (int i = 0; i < seiryokuList.Count; i++) {
			int tmpDaimyoId = int.Parse(seiryokuList [i]);

			if(tmpDaimyoId == srcDaimyoId){
				List<string> checkedKuniList = new List<string> ();
				int tmpKuniId = i + 1;
				int newWinnerKuniQty = main.countLinkedKuniQty(1, tmpKuniId, tmpDaimyoId, seiryokuList, checkedKuniList);

				//Get New Senryoku
				int busyoQty = calc.EnemyBusyoQtyCalc (myKuniQty, newWinnerKuniQty);
				int senryokuRatio = daimyoMst.param [srcDaimyoId - 1].senryoku;
				int busyoLv = calc.EnemyBusyoLvCalc (senryokuRatio);
				int butaiQty = calc.EnemyButaiQtyCalc (newWinnerKuniQty);
				int butaiLv = calc.EnemyButaiLvCalc (senryokuRatio);

				//Change Name of target Kuni by daimyo info
				targetKuni.GetComponent<SendParam> ().daimyoId = srcDaimyoId;
				targetKuni.GetComponent<SendParam> ().daimyoName = daimyoMst.param [srcDaimyoId - 1].daimyoName;
				targetKuni.GetComponent<SendParam> ().daimyoBusyoId = daimyoMst.param [srcDaimyoId - 1].busyoId;

				SendParam winnerParam = kuniIconView.transform.FindChild (tmpKuniId.ToString ()).GetComponent<SendParam> ();
				winnerParam.busyoQty = busyoQty;
				winnerParam.busyoLv = busyoLv;
				winnerParam.butaiQty = butaiQty;
				winnerParam.butaiLv = butaiLv;
				winnerParam.kuniQty = newWinnerKuniQty;

			}else if(tmpDaimyoId == dstDaimyoId){
				List<string> checkedKuniList = new List<string> ();
				int tmpKuniId = i + 1;
				int newLoserKuniQty = main.countLinkedKuniQty(1, tmpKuniId, tmpDaimyoId, seiryokuList, checkedKuniList);

				//Get New Senryoku
				int busyoQty = calc.EnemyBusyoQtyCalc (myKuniQty, newLoserKuniQty);
				int senryokuRatio = daimyoMst.param [dstDaimyoId - 1].senryoku;
				int busyoLv = calc.EnemyBusyoLvCalc (senryokuRatio);
				int butaiQty = calc.EnemyButaiQtyCalc (newLoserKuniQty);
				int butaiLv = calc.EnemyButaiLvCalc (senryokuRatio);

				SendParam loserParam = kuniIconView.transform.FindChild (tmpKuniId.ToString ()).GetComponent<SendParam> ();
				loserParam.busyoQty = busyoQty;
				loserParam.busyoLv = busyoLv;
				loserParam.butaiQty = butaiQty;
				loserParam.butaiLv = butaiLv;
				loserParam.kuniQty = newLoserKuniQty;
			}
		}







		//Icon Color Change by Doumei Situation
		List<string> myDoumeiList = new List<string> ();
		string doumeiString = PlayerPrefs.GetString ("doumei");
		if (doumeiString != null && doumeiString != "") {
			if (doumeiString.Contains (",")) {
				myDoumeiList = new List<string> (doumeiString.Split (delimiterChars));
			} else {
				myDoumeiList.Add (doumeiString);
			}
		}
		if (myDoumeiList.Contains (srcDaimyoId.ToString())) {
			Color doumeiColor = new Color (100f / 255f, 130f / 255f, 255f / 255f, 255f / 255f);
			targetKuni.GetComponent<SendParam> ().doumeiFlg = true;
			targetKuni.GetComponent<Image>().color = doumeiColor;

		}

		if (!myDoumeiList.Contains (srcDaimyoId.ToString()) && myDoumeiList.Contains (dstDaimyoId.ToString())) {
			Color unDoumeiColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f);
			targetKuni.GetComponent<SendParam> ().doumeiFlg = false;
			targetKuni.GetComponent<Image>().color = unDoumeiColor;

		}



	}
コード例 #14
0
ファイル: HPCounter.cs プロジェクト: zeimoter/sengoku2d
	// Update is called once per frame
	void Update () {
		life = getTotalHp (targetTag);
		gameObject.transform.FindChild("HpText").GetComponent<Text>().text = life.ToString();

		if (!flag) {
			if (life == 0) {
				flag = true;

				if (targetTag == "Player") {
					//Game Over
					string backPath = "Prefabs/PostKassen/back";
					GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject;
					backObj.transform.parent = GameObject.Find ("Canvas").transform;
					backObj.transform.localScale = new Vector2(70,63);

					//Chane word
					Color color = Color.blue;
					GameObject.Find ("winlose").GetComponent<TextMesh>().text = "敗北";
					GameObject.Find ("winlose").GetComponent<TextMesh>().color = color;
					
					string blackPath = "Prefabs/PostKassen/black";
					GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject;
					blackObj.transform.parent = GameObject.Find ("Canvas").transform;
					blackObj.transform.localScale = new Vector2(330,300);

					string makimonoPath = "Prefabs/PostKassen/makimono";
					GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject;
					makimonoObj.transform.parent = GameObject.Find ("Canvas").transform;
					makimonoObj.transform.localScale = new Vector2(60,80);
					makimonoObj.transform.localPosition = new Vector2(0,-130);

					//Button List
					string nextbtnPath = "Prefabs/PostKassen/bttnList";
					GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject;
					bttnListObj.transform.parent = GameObject.Find ("Canvas").transform;
					bttnListObj.transform.localScale = new Vector2(1,1);		
					
					//Time Stop
					GameObject.Find ("timer").GetComponent<Timer>().enabled = false;

					Debug.Log (isAttackedFlg);
					//Check is attacked flag
					if(isAttackedFlg == true){
						//My Daimyo Lose 

						Gunzei lose = new Gunzei();
						string tKey = PlayerPrefs.GetString("activeKey");
						int tSrcDaimyoId = PlayerPrefs.GetInt("activeSrcDaimyoId");
						int tDstDaimyoId = PlayerPrefs.GetInt("activeDstDaimyoId");
						bool noGunzeiFlg = true;
						PlayerPrefs.DeleteKey("isAttacked");
						lose.win(tKey, tSrcDaimyoId, tDstDaimyoId,noGunzeiFlg);


						//Delete Cleared Kuni
						int activeKuniId  = PlayerPrefs.GetInt("activeKuniId");
						string clearedKuni = PlayerPrefs.GetString("clearedKuni");

						char[] delimiterChars = {','};
						List<string> clearedKuniList = new List<string>();
						
						if (clearedKuni != null && clearedKuni != "") {
							if(clearedKuni.Contains(",")){
								clearedKuniList = new List<string> (clearedKuni.Split (delimiterChars));
							}else{
								clearedKuniList.Add(clearedKuni);
							}
						}
						Debug.Log ("before:"+clearedKuniList.Count);
						string tempActiveKuni = activeKuniId.ToString();
						clearedKuniList.Remove(tempActiveKuni);
						Debug.Log ("after:"+clearedKuniList.Count);
						string newClearedKuni = "";
						for(int i=0; i<clearedKuniList.Count; i++){
							if(i==0){
								newClearedKuni = clearedKuniList[i];
							}else{
								newClearedKuni = newClearedKuni + "," + clearedKuniList[i];
							}
						}
						PlayerPrefs.SetString("clearedKuni",newClearedKuni);
						Debug.Log ("NewClearedKuni:"+newClearedKuni);

						if(newClearedKuni==null || newClearedKuni == ""){
							PlayerPrefs.SetBool("gameOverFlg",true);
							Debug.Log ("gameOverFlg");

						}

						//Delete Naisei
						string tempNaisei = "naisei" + activeKuniId.ToString();
						PlayerPrefs.DeleteKey(tempNaisei);

						//Delete Jyosyu
						string tempJyosyu = "jyosyu" + activeKuniId.ToString();
						PlayerPrefs.DeleteKey(tempJyosyu);

						//Delete Stage Clear
						string tempKuni = "kuni" + activeKuniId.ToString();
						PlayerPrefs.DeleteKey(tempKuni);

						//Delete open
						KuniInfo kuni = new KuniInfo();
						kuni.updateOpenKuni();
						PlayerPrefs.Flush();
					}

				} else if (targetTag == "Enemy") {
					//Win
					if(isAttackedFlg == true){
						//history
						string tKey = PlayerPrefs.GetString("activeKey");
						MainStageController main = new MainStageController();
						main.deleteKeyHistory(tKey);
						PlayerPrefs.DeleteKey("isAttacked");
						PlayerPrefs.Flush();
					}

					string backPath = "Prefabs/PostKassen/back";
					GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject;
					backObj.transform.parent = GameObject.Find ("Canvas").transform;
					backObj.transform.localScale = new Vector2(70,63);

					string particlePath = "Prefabs/PostKassen/particle";
					GameObject particleObj = Instantiate(Resources.Load (particlePath)) as GameObject;
					particleObj.transform.parent = GameObject.Find ("Canvas").transform;
					particleObj.transform.localPosition = new Vector2(0,60);

					string blackPath = "Prefabs/PostKassen/black";
					GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject;
					blackObj.transform.parent = GameObject.Find ("Canvas").transform;
					blackObj.transform.localScale = new Vector2(330,300);

					string makimonoPath = "Prefabs/PostKassen/makimono";
					GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject;
					makimonoObj.transform.parent = GameObject.Find ("Canvas").transform;
					makimonoObj.transform.localScale = new Vector2(60,80);
					makimonoObj.transform.localPosition = new Vector2(0,-130);

					//Item List
					string itemListPath = "Prefabs/PostKassen/itemList";
					GameObject itemListObj = Instantiate(Resources.Load (itemListPath)) as GameObject;
					itemListObj.transform.parent = GameObject.Find ("Canvas").transform;
					itemListObj.transform.localScale = new Vector2(1,1);

					if(!isAttackedFlg){

						/*Item or Kahou*/
						string activeItemType = PlayerPrefs.GetString("activeItemType");
						int activeItemId = PlayerPrefs.GetInt("activeItemId");
						float activeItemRatio = PlayerPrefs.GetFloat("activeItemRatio");
						int activeItemQty = PlayerPrefs.GetInt("activeItemQty");

						float percent = Random.value;
						percent = percent * 100;

						if(percent <= activeItemRatio){
							//if(0 <= activeItemRatio){ //Test
							//Get Item

							string cyouheiPath = "Prefabs/Item/Cyouhei/" + activeItemType;
							string kanjyoPath = "Prefabs/Item/Kanjyo/Kanjyo";
							string hidensyoPath = "Prefabs/Item/Hidensyo/Hidensyo";
							char[] delimiterChars = {','};

							ShowStageDtl itemIcon = new ShowStageDtl();
							if(activeItemType.Contains("Cyouhei")==true){
								string newCyouheiString = "";

								itemIcon.makeItemIcon(cyouheiPath, activeItemId.ToString(), itemListObj);
								if(activeItemType.Contains("YR")==true){
									string cyouheiString = PlayerPrefs.GetString("cyouheiYR");
									string[] cyouheiList = cyouheiString.Split (delimiterChars);
									if(activeItemId == 1){
										int tempQty = int.Parse(cyouheiList[0]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2];

									}else if(activeItemId == 2){
										int tempQty = int.Parse(cyouheiList[1]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2];

									}else if(activeItemId == 3){
										int tempQty = int.Parse(cyouheiList[2]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString();
									}

									PlayerPrefs.SetString("cyouheiYR", newCyouheiString);

								}else if(activeItemType.Contains("KB")==true){
									string cyouheiString = PlayerPrefs.GetString("cyouheiKB");
									string[] cyouheiList = cyouheiString.Split (delimiterChars);
									if(activeItemId == 1){
										int tempQty = int.Parse(cyouheiList[0]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2];
										
									}else if(activeItemId == 2){
										int tempQty = int.Parse(cyouheiList[1]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2];
										
									}else if(activeItemId == 3){
										int tempQty = int.Parse(cyouheiList[2]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString();
									}
									
									PlayerPrefs.SetString("cyouheiKB", newCyouheiString);

								}else if(activeItemType.Contains("TP")==true){
									string cyouheiString = PlayerPrefs.GetString("cyouheiTP");
									string[] cyouheiList = cyouheiString.Split (delimiterChars);
									if(activeItemId == 1){
										int tempQty = int.Parse(cyouheiList[0]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2];
										
									}else if(activeItemId == 2){
										int tempQty = int.Parse(cyouheiList[1]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2];
										
									}else if(activeItemId == 3){
										int tempQty = int.Parse(cyouheiList[2]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString();
									}
									
									PlayerPrefs.SetString("cyouheiTP", newCyouheiString);

								}else if(activeItemType.Contains("YM")==true){
									string cyouheiString = PlayerPrefs.GetString("cyouheiYM");
									string[] cyouheiList = cyouheiString.Split (delimiterChars);
									if(activeItemId == 1){
										int tempQty = int.Parse(cyouheiList[0]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2];
										
									}else if(activeItemId == 2){
										int tempQty = int.Parse(cyouheiList[1]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2];
										
									}else if(activeItemId == 3){
										int tempQty = int.Parse(cyouheiList[2]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString();
									}
									
									PlayerPrefs.SetString("cyouheiYM", newCyouheiString);
								}



							}else if(activeItemType == "Kanjyo"){
								itemIcon.makeItemIcon(kanjyoPath, activeItemId.ToString(), itemListObj);

								string newKanjyoString = "";
								string kanjyoString = PlayerPrefs.GetString("kanjyo");
								string[] kanjyoList = kanjyoString.Split (delimiterChars);

								if(activeItemId == 1){
									int tempQty = int.Parse(kanjyoList[0]);
									tempQty = tempQty + activeItemQty;
									newKanjyoString = tempQty.ToString() + "," + kanjyoList[1] +","+ kanjyoList[2];
									
								}else if(activeItemId == 2){
									int tempQty = int.Parse(kanjyoList[1]);
									tempQty = tempQty + activeItemQty;
									newKanjyoString = kanjyoList[0] + "," + tempQty.ToString() +","+ kanjyoList[2];
									
								}else if(activeItemId == 3){
									int tempQty = int.Parse(kanjyoList[2]);
									tempQty = tempQty + activeItemQty;
									newKanjyoString = kanjyoList[0] +","+ kanjyoList[1] + "," + tempQty.ToString();
								}
								PlayerPrefs.SetString("kanjyo", newKanjyoString);

							}else if(activeItemType == "Hidensyo"){
								itemIcon.makeItemIcon(hidensyoPath, activeItemId.ToString(), itemListObj);

								if(activeItemId == 1){
									int hidensyoQty = PlayerPrefs.GetInt("hidensyoGe");
									hidensyoQty = hidensyoQty + activeItemQty;
									PlayerPrefs.SetInt("hidensyoGe", hidensyoQty);

								}else if(activeItemId == 2){
									int hidensyoQty = PlayerPrefs.GetInt("hidensyoCyu");
									hidensyoQty = hidensyoQty + activeItemQty;
									PlayerPrefs.SetInt("hidensyoCyu", hidensyoQty);

								}else if(activeItemId == 3){
									int hidensyoQty = PlayerPrefs.GetInt("hidensyoJyo");
									hidensyoQty = hidensyoQty + activeItemQty;
									PlayerPrefs.SetInt("hidensyoJyo", hidensyoQty);
								}

							}else{
								//Kahou
								string kahouIconPath = "Prefabs/Item/Kahou/" + activeItemType + activeItemId;
								GameObject kahouIcon = Instantiate (Resources.Load (kahouIconPath)) as GameObject;
								kahouIcon.transform.SetParent(itemListObj.transform);
								kahouIcon.name = "itemIcon";
								RectTransform kahouTransform = kahouIcon.GetComponent<RectTransform> ();
								kahouTransform.sizeDelta = new Vector2 (100, 100);
								GameObject rank = kahouIcon.transform.FindChild("Rank").gameObject;
								rank.transform.localScale = new Vector2(0.3f,0.3f);
								rank.transform.localPosition = new Vector2(20,-20);

								//Register
								addKahou(activeItemType, activeItemId);
							}



							//Modfication Size & Location
							GameObject item = GameObject.Find ("itemIcon");
							item.transform.localScale = new Vector2 (0.4f, 0.42f);
							item.transform.localPosition = new Vector2(80,-105);
							item.GetComponent<Button>().enabled = false;

							//Qty
							string itemQtyPath = "Prefabs/PostKassen/itemQty";
							GameObject itemQtyObj = Instantiate(Resources.Load (itemQtyPath)) as GameObject;
							itemQtyObj.transform.SetParent(itemListObj.transform);
							itemQtyObj.transform.localScale = new Vector2(0.09f,0.09f);
							itemQtyObj.transform.localPosition = new Vector2(130,-105);
							itemQtyObj.GetComponent<Text>().text = "x " + activeItemQty.ToString();

							//
							PlayerPrefs.Flush();
						}
					}

					//Money
					int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney",0);
					GameObject.Find ("moneyAmt").GetComponent<TextMesh>().text = activeStageMoney.ToString();
					int currentMoney = PlayerPrefs.GetInt("money");
					currentMoney = currentMoney + activeStageMoney;
					PlayerPrefs.SetInt("money",currentMoney);

					//kuniExp
					int activeStageExp = PlayerPrefs.GetInt("activeStageExp",0);
					GameObject.Find ("expAmt").GetComponent<TextMesh>().text = activeStageExp.ToString();
					int currentKuniExp = PlayerPrefs.GetInt ("kuniExp");
					currentKuniExp = currentKuniExp + activeStageExp;
					int kuniLv = PlayerPrefs.GetInt ("kuniLv");
					Exp kuniExp = new Exp();
					int newKuniLv = kuniExp.getKuniLv(kuniLv,currentKuniExp);

					if(newKuniLv>kuniLv){
						//lv up
						int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv);
						int stockLimit = kuniExp.getStockLimit(newKuniLv);
						PlayerPrefs.SetInt("jinkeiLimit",jinkeiLimit);
						PlayerPrefs.SetInt("stockLimit",stockLimit);


					}else{
						Debug.Log ("No level up");
					}

					/*Cleared Flag*/
					if(!isAttackedFlg){
						int activeKuniId  = PlayerPrefs.GetInt("activeKuniId");
						int activeStageId = PlayerPrefs.GetInt("activeStageId");
						string temp = "kuni" + activeKuniId.ToString();

						List<string> clearedStageList = new List<string>();
						string clearedStageString  = PlayerPrefs.GetString(temp);

						if(clearedStageString !=null && clearedStageString !=""){
							//after 1st time
							char[] delimiterChars = {','};
							clearedStageList = new List<string>(clearedStageString.Split (delimiterChars));
							if(clearedStageList.Contains(activeStageId.ToString()) == false){
								clearedStageString = clearedStageString + "," + activeStageId.ToString();

								//1st Kuni Clear Check
								string[] commaCounter = clearedStageString.Split(delimiterChars);
								int counter = commaCounter.Length;

								if(counter == 10){
									//1st time
									string clearedKuni = PlayerPrefs.GetString("clearedKuni");
									if(clearedKuni !=null && clearedKuni !=""){
										clearedKuni = clearedKuni + "," + activeKuniId.ToString();
									}else{
										clearedKuni = activeKuniId.ToString();
									}
									PlayerPrefs.SetString("clearedKuni",clearedKuni);
									//Give 1st cleared revenue 
									PlayerPrefs.SetBool("kuniClearedFlg",true);

									//Open Kuni
									KuniInfo kuni = new KuniInfo();
									kuni.registerOpenKuni(activeKuniId);

									//Seiryoku Change
									string seiryoku = PlayerPrefs.GetString ("seiryoku");
									List<string> seiryokuList = new List<string>();
									seiryokuList = new List<string> (seiryoku.Split (delimiterChars));

									int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
									seiryokuList[activeKuniId-1] = myDaimyo.ToString();
									string newSeiryoku = "";
									for(int i=0; i<seiryokuList.Count; i++){
										if(i==0){
											newSeiryoku = seiryokuList[i];
										}else{
											newSeiryoku = newSeiryoku + "," + seiryokuList[i];
										}
									}
									PlayerPrefs.SetString("seiryoku",newSeiryoku);

								}
							}
						}else{
							//1st time
							clearedStageString = activeStageId.ToString();
							Debug.Log (clearedStageString);
						}
						PlayerPrefs.SetString(temp,clearedStageString);

						PlayerPrefs.SetInt("kuniLv",newKuniLv);
						PlayerPrefs.SetInt("kuniExp",currentKuniExp);
						PlayerPrefs.Flush();
					}

					//Button List
					string nextbtnPath = "Prefabs/PostKassen/bttnList";
					GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject;
					bttnListObj.transform.parent = GameObject.Find ("Canvas").transform;
					bttnListObj.transform.localScale = new Vector2(1,1);


					//Time Stop
					GameObject.Find ("timer").GetComponent<Timer>().enabled = false;


					//Get Exp
					SenkouButton senkou = new SenkouButton();
					List<BusyoSenkou> senkouList = new List<BusyoSenkou>();
					senkouList=senkou.getSenkou ();
					for(int i=0;i<senkouList.Count;i++){

						int busyoId = senkouList[i].id;
						int senkouAmt = senkouList[i].senkou;
						Exp exp = new Exp();

						//Modify by Cyadougu Kahou
						senkouAmt = exp.getExpbyCyadougu(busyoId,senkouAmt);

						//Busyo Exp
						string tempExp = "exp" + busyoId;
						int nowExp = PlayerPrefs.GetInt(tempExp);
						int newExp = nowExp + senkouAmt;
						PlayerPrefs.SetInt(tempExp, newExp);

						//Busyo Lv
						int nowLv = PlayerPrefs.GetInt(busyoId.ToString());
						int newLv = exp.getLvbyTotalExp(nowLv,newExp);
						PlayerPrefs.SetInt(busyoId.ToString(), newLv);

						PlayerPrefs.Flush();
					}
				}
			}
		}
	}
コード例 #15
0
ファイル: GetAllShigen.cs プロジェクト: zeimoter/zeimoter
    public void OnClick()
    {
        if (cyosyuFlg == true) {
            cyosyuFlg = false;
            MainStageController main = new MainStageController();
            string yearSeason = PlayerPrefs.GetString ("yearSeason");
            char[] delimiterChars = {','};
            string[] yearSeasonList = yearSeason.Split (delimiterChars);

            //Season Change
            int seasonId = int.Parse(yearSeasonList[1]);
            int year = int.Parse(yearSeasonList[0]);

            if(seasonId != 4){
                seasonId = seasonId + 1;
                main.SetSeason(seasonId);
            }else{
                seasonId = 1;
                main.SetSeason(seasonId);
                year = year + 1;
                GameObject.Find ("YearValue").GetComponent<Text> ().text = year.ToString();

            }

            string newYearSeason = year.ToString() + "," + seasonId.ToString();
            PlayerPrefs.SetString ("yearSeason", newYearSeason);

            //Base Time Change
            string lastGetTime = System.DateTime.Now.ToString ();
            PlayerPrefs.SetString ("lastGetTime", lastGetTime);
            PlayerPrefs.SetBool("cyosyuFlg", false);
            string targetName = "";

            //Cyosyu Handling
            if(cyosyuTarget == "money"){
                int nowMoney = PlayerPrefs.GetInt ("money");
                int resultMoney = nowMoney + totalMoney;
                PlayerPrefs.SetInt("money",resultMoney);
                targetName = "金";

            }else if(cyosyuTarget == "hyourou"){
                int nowHyourou = PlayerPrefs.GetInt ("hyourou");
                int maxHyourou = PlayerPrefs.GetInt ("hyourouMax");
                int resultHyourou = nowHyourou + totalHyourou;
                if(resultHyourou > maxHyourou) resultHyourou = maxHyourou;
                PlayerPrefs.SetInt("hyourou",resultHyourou);
                targetName = "兵糧";

            }else if(cyosyuTarget == "gunjyu"){
                targetName = "軍需物資";

                //YR
                if(totalYRL !=0 || totalYRM !=0 || totalYRH !=0 ){
                    string cyoheiYRString = PlayerPrefs.GetString ("cyouheiYR");
                    List<string> cyoheiYRList = new List<string>();
                    cyoheiYRList = new List<string> (cyoheiYRString.Split (delimiterChars));

                    int newYRL = totalYRL;
                    int newYRM = totalYRM;
                    int newYRH = totalYRH;

                    newYRL = newYRL + int.Parse(cyoheiYRList[0]);
                    newYRM = newYRM + int.Parse(cyoheiYRList[1]);
                    newYRH = newYRH + int.Parse(cyoheiYRList[2]);

                    string newCyoheiYR = newYRL + "," + newYRM + "," + newYRH;
                    PlayerPrefs.SetString("cyouheiYR",newCyoheiYR);
                }
                //KB
                if(totalKBL !=0 || totalKBM !=0 || totalKBH !=0 ){
                    string cyoheiKBString = PlayerPrefs.GetString ("cyouheiKB");
                    List<string> cyoheiKBList = new List<string>();
                    cyoheiKBList = new List<string> (cyoheiKBString.Split (delimiterChars));
                    int newKBL = totalKBL;
                    int newKBM = totalKBM;
                    int newKBH = totalKBH;

                    newKBL = newKBL + int.Parse(cyoheiKBList[0]);
                    newKBM = newKBM + int.Parse(cyoheiKBList[1]);
                    newKBH = newKBH + int.Parse(cyoheiKBList[2]);

                    string newCyoheiKB = newKBL + "," + newKBM + "," + newKBH;
                    PlayerPrefs.SetString("cyouheiKB",newCyoheiKB);
                }
                //YM
                if(totalYML !=0 || totalYMM !=0 || totalYMH !=0 ){
                    string cyoheiYMString = PlayerPrefs.GetString ("cyouheiYM");
                    List<string> cyoheiYMList = new List<string>();
                    cyoheiYMList = new List<string> (cyoheiYMString.Split (delimiterChars));
                    int newYML = totalYML;
                    int newYMM = totalYMM;
                    int newYMH = totalYMH;

                    newYML = newYML + int.Parse(cyoheiYMList[0]);
                    newYMM = newYMM + int.Parse(cyoheiYMList[1]);
                    newYMH = newYMH + int.Parse(cyoheiYMList[2]);

                    string newCyoheiYM = newYML + "," + newYMM + "," + newYMH;
                    PlayerPrefs.SetString("cyouheiYM",newCyoheiYM);
                }
                //TP
                if(totalTPL !=0 || totalTPM !=0 || totalTPH !=0 ){
                    string cyoheiTPString = PlayerPrefs.GetString ("cyouheiTP");
                    List<string> cyoheiTPList = new List<string>();
                    cyoheiTPList = new List<string> (cyoheiTPString.Split (delimiterChars));
                    int newTPL = totalTPL;
                    int newTPM = totalTPM;
                    int newTPH = totalTPH;

                    newTPL = newTPL + int.Parse(cyoheiTPList[0]);
                    newTPM = newTPM + int.Parse(cyoheiTPList[1]);
                    newTPH = newTPH + int.Parse(cyoheiTPList[2]);

                    string newCyoheiTP = newTPL + "," + newTPM + "," + newTPH;
                    PlayerPrefs.SetString("cyouheiTP",newCyoheiTP);
                }
            }

            //PlayerPrefs.Flush();

            //Message
            Message msg = new Message();
            string text =  targetName + "を徴収しましたぞ。\n季節が変わりますな。";
            msg.makeMessageOnBoard(text);

            //Change Stop Flg to run again
            GameObject.Find ("GetTargetBack").transform.FindChild("GetTimer").GetComponent<GetNaiseiTimer>().stopFlg = false;

            //Restart
            GameObject.Find("GetTimer").GetComponent<GetNaiseiTimer>().Start();

            //Change Flg
            GameObject.Find ("SeiryokuInfo").transform.FindChild("Ex").GetComponent<Image>().enabled = false;
            GameObject.Find ("GameController").GetComponent<MainStageController>().cyosyuFlg = false;
            GameObject.Find ("GameController").GetComponent<MainStageController>().cyosyuTimer = GameObject.Find ("GameController").GetComponent<MainStageController>().cyosyuMstTime;

        } else {
            Message msg = new Message();
            string text =   "まだ季節は変わっておりませぬぞ。\n徴収は今しばらくお待ち下さいませ。";
            msg.makeMessageOnBoard(text);
        }
    }
コード例 #16
0
ファイル: GetAllShigen.cs プロジェクト: zeimoter/sengoku2d
	public void OnClick () {

		if (!doneCyosyuFlg) {
			doneCyosyuFlg = true;
			MainStageController main = new MainStageController();

			PlayerPrefs.SetBool("doneCyosyuFlg", doneCyosyuFlg);
			string targetName = "";
			char[] delimiterChars = {','};

			//Cyosyu Handling
			if(cyosyuTarget == "money"){
				int nowMoney = PlayerPrefs.GetInt ("money");
				int resultMoney = nowMoney + totalMoney;
				PlayerPrefs.SetInt("money",resultMoney);
				targetName = "金";

			}else if(cyosyuTarget == "hyourou"){
				int nowHyourou = PlayerPrefs.GetInt ("hyourou");
				int maxHyourou = PlayerPrefs.GetInt ("hyourouMax");
				int resultHyourou = nowHyourou + totalHyourou;
				if(resultHyourou > maxHyourou) resultHyourou = maxHyourou;
				PlayerPrefs.SetInt("hyourou",resultHyourou);
				targetName = "兵糧";


			}else if(cyosyuTarget == "gunjyu"){
				targetName = "軍需物資";

				//YR
				if(totalYRL !=0 || totalYRM !=0 || totalYRH !=0 ){
					string cyoheiYRString = PlayerPrefs.GetString ("cyouheiYR");
					List<string> cyoheiYRList = new List<string>();
					cyoheiYRList = new List<string> (cyoheiYRString.Split (delimiterChars));

					int newYRL = totalYRL;
					int newYRM = totalYRM;
					int newYRH = totalYRH;

					newYRL = newYRL + int.Parse(cyoheiYRList[0]);
					newYRM = newYRM + int.Parse(cyoheiYRList[1]);
					newYRH = newYRH + int.Parse(cyoheiYRList[2]);

					string newCyoheiYR = newYRL + "," + newYRM + "," + newYRH;
					PlayerPrefs.SetString("cyouheiYR",newCyoheiYR);
				}
				//KB
				if(totalKBL !=0 || totalKBM !=0 || totalKBH !=0 ){
					string cyoheiKBString = PlayerPrefs.GetString ("cyouheiKB");
					List<string> cyoheiKBList = new List<string>();
					cyoheiKBList = new List<string> (cyoheiKBString.Split (delimiterChars));
					int newKBL = totalKBL;
					int newKBM = totalKBM;
					int newKBH = totalKBH;
					
					newKBL = newKBL + int.Parse(cyoheiKBList[0]);
					newKBM = newKBM + int.Parse(cyoheiKBList[1]);
					newKBH = newKBH + int.Parse(cyoheiKBList[2]);

					string newCyoheiKB = newKBL + "," + newKBM + "," + newKBH;
					PlayerPrefs.SetString("cyouheiKB",newCyoheiKB);
				}
				//YM
				if(totalYML !=0 || totalYMM !=0 || totalYMH !=0 ){
					string cyoheiYMString = PlayerPrefs.GetString ("cyouheiYM");
					List<string> cyoheiYMList = new List<string>();
					cyoheiYMList = new List<string> (cyoheiYMString.Split (delimiterChars));
					int newYML = totalYML;
					int newYMM = totalYMM;
					int newYMH = totalYMH;

					newYML = newYML + int.Parse(cyoheiYMList[0]);
					newYMM = newYMM + int.Parse(cyoheiYMList[1]);
					newYMH = newYMH + int.Parse(cyoheiYMList[2]);

					string newCyoheiYM = newYML + "," + newYMM + "," + newYMH;
					PlayerPrefs.SetString("cyouheiYM",newCyoheiYM);
				}
				//TP
				if(totalTPL !=0 || totalTPM !=0 || totalTPH !=0 ){
					string cyoheiTPString = PlayerPrefs.GetString ("cyouheiTP");
					List<string> cyoheiTPList = new List<string>();
					cyoheiTPList = new List<string> (cyoheiTPString.Split (delimiterChars));
					int newTPL = totalTPL;
					int newTPM = totalTPM;
					int newTPH = totalTPH;
					
					newTPL = newTPL + int.Parse(cyoheiTPList[0]);
					newTPM = newTPM + int.Parse(cyoheiTPList[1]);
					newTPH = newTPH + int.Parse(cyoheiTPList[2]);

					string newCyoheiTP = newTPL + "," + newTPM + "," + newTPH;
					PlayerPrefs.SetString("cyouheiTP",newCyoheiTP);
				}
				//SNB
				if(totalSNBL !=0 || totalSNBM !=0 || totalSNBH !=0 ){
					if(totalSNBL !=0){
						int SNBQty = PlayerPrefs.GetInt("shinobiGe");
						int newQty = SNBQty + totalSNBL;

						PlayerPrefs.SetInt("shinobiGe",newQty);
					}
					if(totalSNBM !=0){
						int SNBQty = PlayerPrefs.GetInt("shinobiCyu");
						int newQty = SNBQty + totalSNBM;
						
						PlayerPrefs.SetInt("shinobiCyu",newQty);
					}
					if(totalSNBH !=0){
						int SNBQty = PlayerPrefs.GetInt("shinobiJyo");
						int newQty = SNBQty + totalSNBH;
						
						PlayerPrefs.SetInt("shinobiJyo",newQty);
					}

				}

			}

			PlayerPrefs.Flush();

			//Message
			Message msg = new Message(); 
			string text =  targetName + "を徴収しましたぞ。\n内政でより国を富ませましょう。";
			msg.makeMessageOnBoard(text);

			//Restart
			GameObject.Find ("GameController").GetComponent<MainStageController>().doneCyosyuFlg = true;
			GameObject.Find("GetTimer").GetComponent<GetNaiseiTimer>().Start();
			GameObject.Find("GetTimer").GetComponent<GetNaiseiTimer>().timer = GameObject.Find ("GameController").GetComponent<MainStageController>().yearTimer;


		} else {
			Message msg = new Message(); 
			string text =   "まだ季節は変わっておりませぬぞ。\n徴収は今しばらくお待ち下さいませ。";
			msg.makeMessageOnBoard(text);
		}
	}	
コード例 #17
0
ファイル: SyouninPop.cs プロジェクト: pratikxman/Sengoku2d
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        Message       msg          = new Message();

        if (name != "PassButton")
        {
            //Syoukaijyo Confirm Pop
            audioSources [0].Play();

            //Back
            string     pathOfBack = "Prefabs/Cyoutei/TouchBackLayer";
            GameObject back       = Instantiate(Resources.Load(pathOfBack)) as GameObject;
            back.transform.parent        = GameObject.Find("Panel").transform;
            back.transform.localScale    = new Vector2(1, 1);
            back.transform.localPosition = new Vector2(0, 0);

            //Cyoutei Pop
            string     pathOfPop = "Prefabs/Syounin/SelectSyoukaijyoBoard";
            GameObject pop       = Instantiate(Resources.Load(pathOfPop)) as GameObject;
            pop.transform.parent        = GameObject.Find("Panel").transform;
            pop.transform.localScale    = new Vector2(1, 1);
            pop.transform.localPosition = new Vector2(0, 0);
            pop.name = "SelectSyoukaijyoBoard";
            back.GetComponent <CloseLayer> ().closeTargetObj  = pop;
            back.GetComponent <CloseLayer> ().closeTargetBack = back;
            pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetObj  = pop;
            pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetBack = back;

            //Check Syoukaijyo
            string nowQty = PlayerPrefs.GetString("koueki");
            //string nowQty = "0,0,0";
            List <string> nowQtyList     = new List <string> ();
            char[]        delimiterChars = { ',' };
            nowQtyList = new List <string> (nowQty.Split(delimiterChars));

            GameObject scrollView = pop.transform.FindChild("ScrollView").gameObject;
            GameObject content    = scrollView.transform.FindChild("Content").gameObject;
            bool       notZeroflg = false;
            //Jyo
            if (nowQtyList [2] == "0")
            {
                content.transform.FindChild("Jyo").gameObject.SetActive(false);
            }
            else
            {
                notZeroflg = true;
                content.transform.FindChild("Jyo").transform.FindChild("syounin").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [2];
                content.transform.FindChild("Jyo").GetComponent <SyoukaijyoSelect> ().OnClick();
            }

            //Cyu
            if (nowQtyList [1] == "0")
            {
                content.transform.FindChild("Cyu").gameObject.SetActive(false);
            }
            else
            {
                notZeroflg = true;
                content.transform.FindChild("Cyu").transform.FindChild("syounin").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [1];
                content.transform.FindChild("Cyu").GetComponent <SyoukaijyoSelect> ().OnClick();
            }

            //Ge
            if (nowQtyList [0] == "0")
            {
                content.transform.FindChild("Ge").gameObject.SetActive(false);
            }
            else
            {
                notZeroflg = true;
                content.transform.FindChild("Ge").transform.FindChild("syounin").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [0];
                content.transform.FindChild("Ge").GetComponent <SyoukaijyoSelect> ().OnClick();
            }


            if (!notZeroflg)
            {
                scrollView.transform.FindChild("NoSyoukaijyo").GetComponent <Text> ().enabled             = true;
                pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = msg.getMessage(41);
                pop.transform.FindChild("PassButton").gameObject.SetActive(false);
            }

            pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().SelectSyoukaijyoBoard = pop;
            pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().myDaimyoFlg           = myDaimyoFlg;
            pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().occupiedDaimyoName    = occupiedDaimyoName;
            pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().yukoudo = yukoudo;

            //Icon Change
            if (sakaiFlg)
            {
                string imagePath = "Prefabs/Syounin/Sprite/syounin2";
                pop.transform.FindChild("Syounin").GetComponent <Image> ().sprite =
                    Resources.Load(imagePath, typeof(Sprite)) as Sprite;
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    pop.transform.FindChild("SyouninName").GetComponent <Text>().text = "Rikyu Sen";
                }
                else
                {
                    pop.transform.FindChild("SyouninName").GetComponent <Text> ().text = "千利休";
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    pop.transform.FindChild("SyouninName").GetComponent <Text>().text = "Sotan Kamiya";
                }
            }
        }
        else
        {
            //Cyoutei Main Pop


            int hyourou = PlayerPrefs.GetInt("hyourou");
            if (hyourou >= 5)
            {
                int newHyourou = hyourou - 5;
                PlayerPrefs.SetInt("hyourou", newHyourou);
                GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString();

                //Check Yukoudo
                int ratio = 100 - yukoudo;
                if (myDaimyoFlg)
                {
                    ratio = 0;
                }
                float percent = Random.value;
                percent = percent * 100;

                if (percent > ratio)
                {
                    //Stop Timer
                    CyouteiPop cyouteiPop = new CyouteiPop();
                    cyouteiPop.stopGunzei();
                    GameObject.Find("GameController").GetComponent <MainStageController>().eventStopFlg = true;

                    audioSources [3].Play();
                    SelectSyoukaijyoBoard.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().OnClick();

                    string     pathOfBack = "Prefabs/Cyoutei/CyouteiBack";
                    GameObject back       = Instantiate(Resources.Load(pathOfBack)) as GameObject;
                    back.transform.parent        = GameObject.Find("Panel").transform;
                    back.transform.localScale    = new Vector2(1, 1);
                    back.transform.localPosition = new Vector2(0, 0);

                    string     pathOfPop = "Prefabs/Syounin/SyouninBoard";
                    GameObject pop       = Instantiate(Resources.Load(pathOfPop)) as GameObject;
                    pop.transform.parent        = GameObject.Find("Panel").transform;
                    pop.transform.localScale    = new Vector2(1, 1);
                    pop.transform.localPosition = new Vector2(0, 0);
                    pop.name = "SyouninBoard";

                    CloseLayer CloseLayerScript = pop.transform.FindChild("CloseSyoukaijyo").GetComponent <CloseLayer> ();
                    CloseLayerScript.closeTargetBack   = back;
                    CloseLayerScript.closeTargetObj    = pop;
                    CloseLayerScript.syoukaijyoRank    = syoukaijyoRank;
                    CloseLayerScript.occupiedFlg       = myDaimyoFlg;
                    CloseLayerScript.syouninCyouteiFlg = true;

                    //RandomValue
                    int yukouAddValue    = 0;
                    int yukouReducePoint = Random.Range(2, 10);

                    int stopBattleRatio       = 0;
                    int stopBattleReducePoint = Random.Range(2, 10);

                    int kanniRatio       = 0;
                    int kanniReducePoint = Random.Range(20, 100);
                    int syoukaijyoRankId = 0;

                    //Change Menu by syoukaijyo rank
                    GameObject action = pop.transform.FindChild("Action").gameObject;

                    if (syoukaijyoRank == "Ge")
                    {
                        if (!myDaimyoFlg)
                        {
                            List <string> btnNameList = new List <string> ()
                            {
                                "Yasen", "Youjinbou", "Cyakai", "Gijyutsu"
                            };
                            enableButton(pop, btnNameList);
                        }
                        else
                        {
                            List <string> btnNameList = new List <string> ()
                            {
                                "Youjinbou", "Cyakai", "Gijyutsu"
                            };
                            enableButton(pop, btnNameList);
                        }
                        yukouAddValue    = Random.Range(1, 3);
                        stopBattleRatio  = Random.Range(10, 30);
                        kanniRatio       = Random.Range(20, 60);
                        syoukaijyoRankId = 1;
                        action.transform.FindChild("ActionValue").GetComponent <Text> ().text    = "1";
                        action.transform.FindChild("ActionMaxValue").GetComponent <Text> ().text = "1";
                    }
                    else if (syoukaijyoRank == "Cyu")
                    {
                        if (!myDaimyoFlg)
                        {
                            List <string> btnNameList = new List <string> ()
                            {
                                "Yasen", "Gijyutsu"
                            };
                            enableButton(pop, btnNameList);
                        }
                        else
                        {
                            List <string> btnNameList = new List <string> ()
                            {
                                "Gijyutsu"
                            };
                            enableButton(pop, btnNameList);
                        }
                        yukouAddValue    = Random.Range(3, 8);
                        stopBattleRatio  = Random.Range(30, 80);
                        kanniRatio       = Random.Range(40, 80);
                        syoukaijyoRankId = 2;
                        action.transform.FindChild("ActionValue").GetComponent <Text> ().text    = "2";
                        action.transform.FindChild("ActionMaxValue").GetComponent <Text> ().text = "2";
                    }
                    else if (syoukaijyoRank == "Jyo")
                    {
                        if (!myDaimyoFlg)
                        {
                            List <string> btnNameList = new List <string> ()
                            {
                                "Yasen", "Gijyutsu"
                            };
                            enableButton(pop, btnNameList);
                        }
                        yukouAddValue    = Random.Range(8, 15);
                        stopBattleRatio  = 100;
                        kanniRatio       = Random.Range(60, 100);
                        syoukaijyoRankId = 3;
                        action.transform.FindChild("ActionValue").GetComponent <Text> ().text    = "3";
                        action.transform.FindChild("ActionMaxValue").GetComponent <Text> ().text = "3";
                    }

                    //reduce cyoutei syoukaijyo
                    DoSell script = new DoSell();
                    script.deleteKouekiOrCyoutei(syoukaijyoRankId, "koueki", 1);

                    //TargetKahou Preparation
                    Kahou  kahou         = new Kahou();
                    string kahouCdString = "";
                    string kahouIdString = "";
                    for (int i = 1; i < 4; i++)
                    {
                        List <string> kahouRandom = new List <string> ()
                        {
                            "bugu",
                            "kabuto",
                            "gusoku",
                            "meiba",
                            "cyadougu",
                            "chishikisyo",
                            "heihousyo"
                        };
                        int    rdm       = UnityEngine.Random.Range(0, 7);
                        string kahouType = kahouRandom [rdm];

                        string kahouRank = getItemRank(syoukaijyoRankId);
                        int    kahouId   = kahou.getRamdomKahouId(kahouType, kahouRank);
                        //string targetKahou = kahouType + kahouId.ToString();

                        if (kahouCdString != null && kahouCdString != "")
                        {
                            kahouCdString = kahouCdString + "," + kahouType;
                            kahouIdString = kahouIdString + "," + kahouId.ToString();
                        }
                        else
                        {
                            kahouCdString = kahouType;
                            kahouIdString = kahouId.ToString();
                        }
                    }
                    CloseLayerScript.kahouCdString = kahouCdString;
                    CloseLayerScript.kahouIdString = kahouIdString;


                    //TargetBusshi Preparation
                    string busshiQtyString  = "";                    //Qty of busshi
                    string busshiRankString = "";                    //Rank of busshi
                    for (int l = 1; l < 6; l++)
                    {
                        int rdmQty = UnityEngine.Random.Range(1, 10);
                        int rdmRnk = UnityEngine.Random.Range(1, 4);

                        if (busshiQtyString != null && busshiQtyString != "")
                        {
                            busshiQtyString  = busshiQtyString + "," + rdmQty.ToString();
                            busshiRankString = busshiRankString + "," + rdmRnk.ToString();
                        }
                        else
                        {
                            busshiQtyString  = rdmQty.ToString();
                            busshiRankString = rdmRnk.ToString();
                        }
                    }
                    CloseLayerScript.busshiQtyString  = busshiQtyString;
                    CloseLayerScript.busshiRankString = busshiRankString;


                    //TargetYoujinbou
                    int rdmKengouId = UnityEngine.Random.Range(1, 10);
                    CloseLayerScript.rdmKengouId = rdmKengouId;


                    //Yasengaku
                    int yasenAmt = 0;
                    if (syoukaijyoRankId == 1)
                    {
                        yasenAmt = UnityEngine.Random.Range(1000, 3000);
                    }
                    else if (syoukaijyoRankId == 2)
                    {
                        yasenAmt = UnityEngine.Random.Range(2000, 5000);
                    }
                    else if (syoukaijyoRankId == 3)
                    {
                        yasenAmt = UnityEngine.Random.Range(3000, 10000);
                    }
                    CloseLayerScript.yasenAmt = yasenAmt;


                    //Gijyutsuiten
                    int techId = UnityEngine.Random.Range(1, 4);
                    CloseLayerScript.techId = techId;


                    //Discount Percent
                    float discount = UnityEngine.Random.Range(0.5f, 0.9f);
                    CloseLayerScript.discount = discount;


                    Daimyo daimyo   = new Daimyo();
                    int    myDaimyo = PlayerPrefs.GetInt("myDaimyo");

                    //Serihu
                    string daimyoName = daimyo.getName(myDaimyo);
                    string serihu     = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        serihu = "Oh, lord " + daimyoName + ".\nCan I help you?";
                    }
                    else
                    {
                        serihu = "これは" + daimyoName + "様。\n私共めに何用で御座いましょうか。";
                    }

                    pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = serihu;


                    PlayerPrefs.SetBool("questSpecialFlg4", true);
                    PlayerPrefs.Flush();

                    MainStageController mainStage = new MainStageController();
                    mainStage.questExtension();
                }
                else
                {
                    audioSources [4].Play();

                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        msg.makeMessage("My lord " + occupiedDaimyoName + " disturbed our business.");
                    }
                    else
                    {
                        msg.makeMessage("御屋形様、" + occupiedDaimyoName + "めに\n取引を邪魔されました。");
                    }
                }
            }
            else
            {
                audioSources [4].Play();
                //msg.makeMessage (msg.getMessage(7));
                msg.hyourouMovieMessage();
            }
        }
    }
コード例 #18
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();


        if (criteria == 0)
        {
            //Change Flg
            audioSources[3].Play();
            PlayerPrefs.SetBool(key, true);
            if (target == "money")
            {
                int money    = PlayerPrefs.GetInt("money");
                int newMoney = money + amnt;
                if (newMoney < 0)
                {
                    newMoney = int.MaxValue;
                }
                PlayerPrefs.SetInt("money", newMoney);
                GameObject.Find("MoneyValue").GetComponent <Text> ().text = newMoney.ToString();
            }
            else if (target == "busyoDama")
            {
                int busyoDama    = PlayerPrefs.GetInt("busyoDama");
                int newBusyoDama = busyoDama + amnt;
                PlayerPrefs.SetInt("busyoDama", newBusyoDama);
                GameObject.Find("BusyoDamaValue").GetComponent <Text> ().text = newBusyoDama.ToString();
            }
            PlayerPrefs.Flush();
            //Remove Quest
            Destroy(slot);
            deleteQuest(false, key, id);
        }
        else
        {
            if (count < criteria)
            {
                //error
                audioSources[4].Play();
                Message msg = new Message();
                msg.makeMessageOnBoard(msg.getMessage(152));
            }
            else
            {
                audioSources[3].Play();
                PlayerPrefs.SetBool(key, true);
                if (target == "busyoDama")
                {
                    int busyoDama    = PlayerPrefs.GetInt("busyoDama");
                    int newBusyoDama = busyoDama + amnt;
                    PlayerPrefs.SetInt("busyoDama", newBusyoDama);
                    GameObject.Find("BusyoDamaValue").GetComponent <Text>().text = newBusyoDama.ToString();
                }
                PlayerPrefs.Flush();
                //Remove Quest
                Destroy(slot);
                deleteQuest(true, key, id);
            }
        }
        //Extension Mark Handling
        MainStageController main = new MainStageController();

        main.questExtension();
    }
コード例 #19
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        int     hyourou = PlayerPrefs.GetInt("hyourou");
        Message msg     = new Message();

        if (hyourou >= 5)
        {
            int money    = PlayerPrefs.GetInt("money");
            int payMoney = int.Parse(GameObject.Find("MoneyAmt").GetComponent <Text>().text);
            if (money >= payMoney)
            {
                /***OK***/
                audioSources [3].Play();

                //Reduce Hyourou
                int newHyourou = hyourou - 5;
                PlayerPrefs.SetInt("hyourou", newHyourou);
                GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString();

                //Reduce Money
                int newMoney = money - payMoney;
                PlayerPrefs.SetInt("money", newMoney);
                GameObject.Find("MoneyValue").GetComponent <Text> ().text = newMoney.ToString();


                //Add Item
                char[] delimiterChars = { ',' };
                int    buyQty         = int.Parse(GameObject.Find("BuyMenu").transform.FindChild("Qty").GetComponent <Text>().text);

                if (item.Contains("Cyouhei") == true)
                {
                    if (item.Contains("YR") == true)
                    {
                        string   cyouheiYRString    = PlayerPrefs.GetString("cyouheiYR");
                        string[] cyouheiYR_list     = cyouheiYRString.Split(delimiterChars);
                        string   newCyouheiYRString = "";

                        if (item == "CyouheiYR1")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiYR_list[0]) + buyQty;
                            newCyouheiYRString = newQty.ToString() + "," + cyouheiYR_list[1] + "," + cyouheiYR_list[2];
                        }
                        else if (item == "CyouheiYR2")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiYR_list[1]) + buyQty;
                            newCyouheiYRString = cyouheiYR_list[0] + "," + newQty.ToString() + "," + cyouheiYR_list[2];
                        }
                        else if (item == "CyouheiYR3")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiYR_list[2]) + buyQty;
                            newCyouheiYRString = cyouheiYR_list[0] + "," + cyouheiYR_list[1] + "," + newQty.ToString();
                        }
                        PlayerPrefs.SetString("cyouheiYR", newCyouheiYRString);
                    }
                    else if (item.Contains("KB") == true)
                    {
                        string   cyouheiKBString    = PlayerPrefs.GetString("cyouheiKB");
                        string[] cyouheiKB_list     = cyouheiKBString.Split(delimiterChars);
                        string   newCyouheiKBString = "";

                        if (item == "CyouheiKB1")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiKB_list[0]) + buyQty;
                            newCyouheiKBString = newQty.ToString() + "," + cyouheiKB_list[1] + "," + cyouheiKB_list[2];
                        }
                        else if (item == "CyouheiKB2")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiKB_list[1]) + buyQty;
                            newCyouheiKBString = cyouheiKB_list[0] + "," + newQty.ToString() + "," + cyouheiKB_list[2];
                        }
                        else if (item == "CyouheiKB3")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiKB_list[2]) + buyQty;
                            newCyouheiKBString = cyouheiKB_list[0] + "," + cyouheiKB_list[1] + "," + newQty.ToString();
                        }
                        PlayerPrefs.SetString("cyouheiKB", newCyouheiKBString);
                    }
                    else if (item.Contains("TP") == true)
                    {
                        string   cyouheiTPString    = PlayerPrefs.GetString("cyouheiTP");
                        string[] cyouheiTP_list     = cyouheiTPString.Split(delimiterChars);
                        string   newCyouheiTPString = "";

                        if (item == "CyouheiTP1")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiTP_list[0]) + buyQty;
                            newCyouheiTPString = newQty.ToString() + "," + cyouheiTP_list[1] + "," + cyouheiTP_list[2];
                        }
                        else if (item == "CyouheiTP2")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiTP_list[1]) + buyQty;
                            newCyouheiTPString = cyouheiTP_list[0] + "," + newQty.ToString() + "," + cyouheiTP_list[2];
                        }
                        else if (item == "CyouheiTP3")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiTP_list[2]) + buyQty;
                            newCyouheiTPString = cyouheiTP_list[0] + "," + cyouheiTP_list[1] + "," + newQty.ToString();
                        }
                        PlayerPrefs.SetString("cyouheiTP", newCyouheiTPString);
                    }
                    else if (item.Contains("YM") == true)
                    {
                        string   cyouheiYMString    = PlayerPrefs.GetString("cyouheiYM");
                        string[] cyouheiYM_list     = cyouheiYMString.Split(delimiterChars);
                        string   newCyouheiYMString = "";

                        if (item == "CyouheiYM1")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiYM_list[0]) + buyQty;
                            newCyouheiYMString = newQty.ToString() + "," + cyouheiYM_list[1] + "," + cyouheiYM_list[2];
                        }
                        else if (item == "CyouheiYM2")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiYM_list[1]) + buyQty;
                            newCyouheiYMString = cyouheiYM_list[0] + "," + newQty.ToString() + "," + cyouheiYM_list[2];
                        }
                        else if (item == "CyouheiYM3")
                        {
                            int newQty = 0;
                            newQty             = int.Parse(cyouheiYM_list[2]) + buyQty;
                            newCyouheiYMString = cyouheiYM_list[0] + "," + cyouheiYM_list[1] + "," + newQty.ToString();
                        }
                        PlayerPrefs.SetString("cyouheiYM", newCyouheiYMString);
                    }
                }
                else if (item.Contains("Hidensyo") == true)
                {
                    if (item == "Hidensyo1")
                    {
                        int newQty      = 0;
                        int HidensyoQty = PlayerPrefs.GetInt("hidensyoGe");
                        newQty = HidensyoQty + buyQty;
                        PlayerPrefs.SetInt("hidensyoGe", newQty);
                    }
                    else if (item == "Hidensyo2")
                    {
                        int newQty      = 0;
                        int HidensyoQty = PlayerPrefs.GetInt("hidensyoCyu");
                        newQty = HidensyoQty + buyQty;
                        PlayerPrefs.SetInt("hidensyoCyu", newQty);
                    }
                    else if (item == "Hidensyo3")
                    {
                        int newQty      = 0;
                        int HidensyoQty = PlayerPrefs.GetInt("hidensyoJyo");
                        newQty = HidensyoQty + buyQty;
                        PlayerPrefs.SetInt("hidensyoJyo", newQty);
                    }
                }
                else if (item.Contains("Shinobi") == true)
                {
                    if (item == "Shinobi1")
                    {
                        int newQty     = 0;
                        int shinobiQty = PlayerPrefs.GetInt("shinobiGe");
                        newQty = shinobiQty + buyQty;
                        PlayerPrefs.SetInt("shinobiGe", newQty);
                    }
                    else if (item == "Shinobi2")
                    {
                        int newQty     = 0;
                        int shinobiQty = PlayerPrefs.GetInt("shinobiCyu");
                        newQty = shinobiQty + buyQty;
                        PlayerPrefs.SetInt("shinobiCyu", newQty);
                    }
                    else if (item == "Shinobi3")
                    {
                        int newQty     = 0;
                        int shinobiQty = PlayerPrefs.GetInt("shinobiJyo");
                        newQty = shinobiQty + buyQty;
                        PlayerPrefs.SetInt("shinobiJyo", newQty);
                    }
                }
                else if (item.Contains("Kanjyo") == true)
                {
                    string   kanjyoString    = PlayerPrefs.GetString("kanjyo");
                    string[] kanjyo_list     = kanjyoString.Split(delimiterChars);
                    string   newKanjyoString = "";

                    if (item == "Kanjyo1")
                    {
                        int newQty = 0;
                        newQty          = int.Parse(kanjyo_list[0]) + buyQty;
                        newKanjyoString = newQty.ToString() + "," + kanjyo_list[1] + "," + kanjyo_list[2];
                    }
                    else if (item == "Kanjyo2")
                    {
                        int newQty = 0;
                        newQty          = int.Parse(kanjyo_list[1]) + buyQty;
                        newKanjyoString = kanjyo_list[0] + "," + newQty.ToString() + "," + kanjyo_list[2];
                    }
                    else if (item == "Kanjyo3")
                    {
                        int newQty = 0;
                        newQty          = int.Parse(kanjyo_list[2]) + buyQty;
                        newKanjyoString = kanjyo_list[0] + "," + kanjyo_list[1] + "," + newQty.ToString();
                    }
                    PlayerPrefs.SetString("kanjyo", newKanjyoString);
                }
                PlayerPrefs.SetBool("questDailyFlg27", true);
                PlayerPrefs.Flush();

                MainStageController mainStage = new MainStageController();
                mainStage.questExtension();

                //Closing
                GameObject.Find("SerihuText").GetComponent <Text>().text = msg.getMessage(11);

                //Message
                msg.makeMessage(msg.getMessage(12));
            }
            else
            {
                //Message
                audioSources [4].Play();
                msg.makeMessage(msg.getMessage(6));
            }
        }
        else
        {
            //Message
            audioSources [4].Play();
            //msg.makeMessage (msg.getMessage(7));
            msg.hyourouMovieMessage();
        }
    }
コード例 #20
0
ファイル: SeiryokuInfo.cs プロジェクト: pratikxman/Sengoku2d
    public void OnClick()
    {
        MainStageController MainStageController = GameObject.Find("GameController").GetComponent <MainStageController>();

        //SE
        AudioSource sound = GameObject.Find("SEController").GetComponent <AudioSource> ();

        sound.PlayOneShot(sound.clip);

        //Initialization
        totalMoney   = 0;
        kozanMoney   = 0;
        totalHyourou = 0;
        totalYRL     = 0;
        totalKBL     = 0;
        totalYML     = 0;
        totalTPL     = 0;
        totalYRM     = 0;
        totalKBM     = 0;
        totalYMM     = 0;
        totalTPM     = 0;
        totalYRH     = 0;
        totalKBH     = 0;
        totalYMH     = 0;
        totalTPH     = 0;
        totalSNBL    = 0;
        totalSNBM    = 0;
        totalSNBH    = 0;

        /*Popup*/
        string     backPath = "Prefabs/Busyo/back";
        GameObject back     = Instantiate(Resources.Load(backPath)) as GameObject;

        back.transform.SetParent(GameObject.Find("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/Busyo/board";
        GameObject popup     = Instantiate(Resources.Load(popupPath)) as GameObject;

        popup.transform.SetParent(GameObject.Find("Map").transform);
        popup.transform.localScale = new Vector2(1, 1);
        RectTransform popupTransform = popup.GetComponent <RectTransform> ();

        popupTransform.anchoredPosition = new Vector3(0, 0, 0);
        popup.name = "board";

        //qa
        string     qaPath = "Prefabs/Common/Question";
        GameObject qa     = Instantiate(Resources.Load(qaPath)) as GameObject;

        qa.transform.SetParent(popup.transform);
        qa.transform.localScale = new Vector2(1, 1);
        RectTransform qaTransform = qa.GetComponent <RectTransform> ();

        qaTransform.anchoredPosition = new Vector3(-540, 285, 0);
        qa.name = "qa";
        qa.GetComponent <QA> ().qaId = 2;


        //Pop text
        string     popTextPath = "Prefabs/Busyo/popText";
        GameObject popText     = Instantiate(Resources.Load(popTextPath)) as GameObject;

        popText.transform.SetParent(popup.transform);
        popText.transform.localScale = new Vector2(0.35f, 0.35f);
        RectTransform popTextTransform = popText.GetComponent <RectTransform> ();

        popTextTransform.anchoredPosition = new Vector3(0, 260, 0);
        popText.name = "popText";
        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            popText.GetComponent <Text>().text = "Finance";
        }
        else
        {
            popText.GetComponent <Text> ().text = "内政状況";
        }

        //Cyosyu
        string     cyosyuPath = "Prefabs/Cyosyu/CyosyuObj";
        GameObject CyosyuObj  = Instantiate(Resources.Load(cyosyuPath)) as GameObject;

        CyosyuObj.transform.SetParent(popup.transform);
        CyosyuObj.transform.localScale = new Vector2(1, 1);



        string        seiryoku       = PlayerPrefs.GetString("seiryoku");
        List <string> seiryokuList   = new List <string> ();
        List <string> mySeiryokuList = new List <string> ();

        char[] delimiterChars = { ',' };

        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));
        int myDaimyoId = PlayerPrefs.GetInt("myDaimyo");

        //Get my Kuni
        for (int i = 0; i < seiryokuList.Count; i++)
        {
            int seiryokuId = int.Parse(seiryokuList [i]);
            if (seiryokuId == myDaimyoId)
            {
                int kuniId = i + 1;
                mySeiryokuList.Add(kuniId.ToString());
            }
        }


        //Kuni Loop Start
        int naiseiBldg = 0;
        int syogyo     = 0;
        int nogyo      = 0;
        int gunjyu     = 0;
        int ashigaru   = 0;
        int boubi      = 0;
        int bukkyo     = 0;
        int kirisuto   = 0;
        int bunka      = 0;

        //seiryoku loop
        for (int i = 0; i < mySeiryokuList.Count; i++)
        {
            int kuniKozan  = 0;
            int kuniSyogyo = 0;

            int    kuniId      = int.Parse(mySeiryokuList[i]);
            string temp        = "kuni" + mySeiryokuList[i];
            string clearedKuni = PlayerPrefs.GetString(temp);
            //Shiro Qty
            if (clearedKuni != null && clearedKuni != "")
            {
                List <string> shiroList = new List <string>();
                shiroList = new List <string>(clearedKuni.Split(delimiterChars));
                shiro     = shiroList.Count;

                //Kuni Name
                Entity_kuni_mst kuniMst = Resources.Load("Data/kuni_mst") as Entity_kuni_mst;
                kuniName = kuniMst.param[kuniId - 1].kuniName;

                string naiseiTemp   = "naisei" + mySeiryokuList[i];
                string naiseiString = PlayerPrefs.GetString(naiseiTemp);
                if (PlayerPrefs.HasKey(naiseiTemp))
                {
                    List <string> naiseiList = new List <string>();
                    naiseiList = new List <string>(naiseiString.Split(delimiterChars));
                    char[]        delimiterChars2 = { ':' };
                    List <string> deletePanelList = new List <string>();


                    for (int j = 1; j < naiseiList.Count; j++)
                    {
                        List <string> naiseiContentList = new List <string>();
                        naiseiContentList = new List <string>(naiseiList[j].Split(delimiterChars2));


                        if (naiseiContentList[0] != "0")
                        {
                            //Exist
                            Entity_naisei_mst naiseiMst = Resources.Load("Data/naisei_mst") as Entity_naisei_mst;
                            string            type      = naiseiMst.param [int.Parse(naiseiContentList[0])].code;
                            naiseiBldg = naiseiBldg + 1;

                            //Effect by Level
                            List <int>       naiseiEffectList = new List <int>();
                            NaiseiController naisei           = new NaiseiController();
                            naiseiEffectList = naisei.getNaiseiList(type, int.Parse(naiseiContentList[1]));


                            //Status
                            if (type == "shop")
                            {
                                kuniSyogyo = kuniSyogyo + naiseiEffectList[0];
                            }
                            else if (type == "kzn")
                            {
                                kuniKozan = kuniKozan + naiseiEffectList[0];
                            }
                            else if (type == "ta")
                            {
                                nogyo        = nogyo + naiseiEffectList[0];
                                totalHyourou = totalHyourou + naiseiEffectList[0];
                            }
                            else if (type == "yr")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYRL = totalYRL + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYRM = totalYRM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYRH = totalYRH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "kb")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalKBL = totalKBL + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalKBM = totalKBM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalKBH = totalKBH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "ym")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYML = totalYML + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYMM = totalYMM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalYMH = totalYMH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "tp")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalTPL = totalTPL + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalTPM = totalTPM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu   = gunjyu + naiseiEffectList[0];
                                    totalTPH = totalTPH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "snb")
                            {
                                if (int.Parse(naiseiContentList[1]) < 11)
                                {
                                    //Low
                                    gunjyu    = gunjyu + naiseiEffectList[0];
                                    totalSNBL = totalSNBL + naiseiEffectList[0];
                                }
                                else if (int.Parse(naiseiContentList[1]) < 16)
                                {
                                    //Middle
                                    gunjyu    = gunjyu + naiseiEffectList[0];
                                    totalSNBM = totalSNBM + naiseiEffectList[0];
                                }
                                else if (15 <= int.Parse(naiseiContentList[1]))
                                {
                                    //High
                                    gunjyu    = gunjyu + naiseiEffectList[0];
                                    totalSNBH = totalSNBH + naiseiEffectList[0];
                                }
                            }
                            else if (type == "trd")
                            {
                                boubi = boubi + naiseiEffectList[0];
                            }
                            else if (type == "nbn")
                            {
                                kirisuto = kirisuto + naiseiEffectList[0];
                            }
                            else if (type == "kgy")
                            {
                                bunka = bunka + naiseiEffectList [0];
                            }
                            else if (type == "bky")
                            {
                                bukkyo = bukkyo + naiseiEffectList [0];
                            }
                            else if (type == "hsy")
                            {
                                ashigaru = ashigaru + naiseiEffectList [0];
                            }
                        }
                    }

                    //Shiro
                    int shiroLv            = int.Parse(naiseiList[0]);
                    NaiseiController naise = new NaiseiController();
                    List <int>       naiseiShiroEffectList = new List <int>();
                    naiseiShiroEffectList = naise.getNaiseiList("shiro", shiroLv);
                    ashigaru = ashigaru + naiseiShiroEffectList[0];
                    boubi    = boubi + naiseiShiroEffectList[0];


                    //Jyosyu Addition
                    string jyosyuTemp = "jyosyu" + kuniId;

                    if (PlayerPrefs.HasKey(jyosyuTemp))
                    {
                        int       jyosyuId  = PlayerPrefs.GetInt(jyosyuTemp);
                        StatusGet sts       = new StatusGet();
                        int       lv        = PlayerPrefs.GetInt(jyosyuId.ToString());
                        float     naiseiSts = (float)sts.getDfc(jyosyuId, lv);

                        float hpSts  = (float)sts.getHp(jyosyuId, lv);
                        float atkSts = (float)sts.getAtk(jyosyuId, lv);

                        float tempKuniSyogyo = (float)kuniSyogyo;
                        tempKuniSyogyo = tempKuniSyogyo + (tempKuniSyogyo * naiseiSts / 200);
                        kuniSyogyo     = (int)tempKuniSyogyo;

                        float tempKuniKozan = (float)kuniKozan;
                        tempKuniKozan = tempKuniKozan + (tempKuniKozan * naiseiSts / 200);
                        kuniKozan     = (int)tempKuniKozan;
                    }
                }
            }
            kozanMoney = kozanMoney + kuniKozan;
            totalMoney = totalMoney + kuniSyogyo;
            syogyo     = syogyo + (kuniKozan * 4 + kuniSyogyo);
        }//Kuni Loop Finish


        /*visualize*/
        //Upper Board
        GameObject spring = CyosyuObj.transform.FindChild("spring").gameObject;

        spring.transform.FindChild("TargetMoney").transform.FindChild("Value").GetComponent <Text>().text = (totalMoney + kozanMoney).ToString();

        GameObject summerWinter = CyosyuObj.transform.FindChild("summerWinter").gameObject;

        summerWinter.transform.FindChild("TargetMoney").transform.FindChild("Value").GetComponent <Text>().text = kozanMoney.ToString();
        GameObject TargetGunjyu = summerWinter.transform.FindChild("TargetGunjyu").gameObject;

        if (totalYRH != 0)
        {
            TargetGunjyu.transform.FindChild("YR").transform.FindChild("CyouheiYRValueH").GetComponent <Text>().text = totalYRH.ToString();
        }
        if (totalYRM != 0)
        {
            TargetGunjyu.transform.FindChild("YR").transform.FindChild("CyouheiYRValueM").GetComponent <Text>().text = totalYRM.ToString();
        }
        if (totalYRL != 0)
        {
            TargetGunjyu.transform.FindChild("YR").transform.FindChild("CyouheiYRValueL").GetComponent <Text>().text = totalYRL.ToString();
        }
        if (totalKBH != 0)
        {
            TargetGunjyu.transform.FindChild("KB").transform.FindChild("CyouheiKBValueH").GetComponent <Text>().text = totalKBH.ToString();
        }
        if (totalKBM != 0)
        {
            TargetGunjyu.transform.FindChild("KB").transform.FindChild("CyouheiKBValueM").GetComponent <Text>().text = totalKBM.ToString();
        }
        if (totalKBL != 0)
        {
            TargetGunjyu.transform.FindChild("KB").transform.FindChild("CyouheiKBValueL").GetComponent <Text>().text = totalKBL.ToString();
        }
        if (totalYMH != 0)
        {
            TargetGunjyu.transform.FindChild("YM").transform.FindChild("CyouheiYMValueH").GetComponent <Text>().text = totalYMH.ToString();
        }
        if (totalYMM != 0)
        {
            TargetGunjyu.transform.FindChild("YM").transform.FindChild("CyouheiYMValueM").GetComponent <Text>().text = totalYMM.ToString();
        }
        if (totalYML != 0)
        {
            TargetGunjyu.transform.FindChild("YM").transform.FindChild("CyouheiYMValueL").GetComponent <Text>().text = totalYML.ToString();
        }
        if (totalTPH != 0)
        {
            TargetGunjyu.transform.FindChild("TP").transform.FindChild("CyouheiTPValueH").GetComponent <Text>().text = totalTPH.ToString();
        }
        if (totalTPM != 0)
        {
            TargetGunjyu.transform.FindChild("TP").transform.FindChild("CyouheiTPValueM").GetComponent <Text>().text = totalTPM.ToString();
        }
        if (totalTPL != 0)
        {
            TargetGunjyu.transform.FindChild("TP").transform.FindChild("CyouheiTPValueL").GetComponent <Text>().text = totalTPL.ToString();
        }
        if (totalSNBH != 0)
        {
            TargetGunjyu.transform.FindChild("SNB").transform.FindChild("SNBValueH").GetComponent <Text>().text = totalSNBH.ToString();
        }
        if (totalSNBM != 0)
        {
            TargetGunjyu.transform.FindChild("SNB").transform.FindChild("SNBValueM").GetComponent <Text>().text = totalSNBM.ToString();
        }
        if (totalSNBL != 0)
        {
            TargetGunjyu.transform.FindChild("SNB").transform.FindChild("SNBValueL").GetComponent <Text>().text = totalSNBL.ToString();
        }

        GameObject autumn = CyosyuObj.transform.FindChild("autumn").gameObject;

        autumn.transform.FindChild("TargetMoney").transform.FindChild("Value").GetComponent <Text>().text   = kozanMoney.ToString();
        autumn.transform.FindChild("TargetHyourou").transform.FindChild("Value").GetComponent <Text>().text = totalHyourou.ToString();

        //Color
        int nowSeason = MainStageController.nowSeason;

        if (nowSeason == 1)
        {
            summerWinter.transform.FindChild("summer").gameObject.AddComponent <TextBlinker>();
        }
        else if (nowSeason == 2)
        {
            autumn.transform.FindChild("autumn").gameObject.AddComponent <TextBlinker>();
        }
        else if (nowSeason == 3)
        {
            summerWinter.transform.FindChild("winter").gameObject.AddComponent <TextBlinker>();
        }
        else if (nowSeason == 4)
        {
            spring.transform.FindChild("spring").gameObject.AddComponent <TextBlinker>();
        }


        //Lower Board
        GameObject status = CyosyuObj.transform.FindChild("statusBack").gameObject;

        //Kamon
        string     imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + myDaimyoId.ToString();
        GameObject kamon     = status.transform.FindChild("Kamon").gameObject;

        kamon.GetComponent <Image> ().sprite =
            Resources.Load(imagePath, typeof(Sprite)) as Sprite;
        if (Application.systemLanguage == SystemLanguage.Japanese)
        {
            kamon.transform.FindChild("Value").GetComponent <Text> ().text = GameObject.Find("DaimyoValue").GetComponent <Text> ().text + "  国状況";
        }
        else
        {
            kamon.transform.FindChild("Value").GetComponent <Text>().text = GameObject.Find("DaimyoValue").GetComponent <Text>().text + " Status";
        }
        //Kuni
        status.transform.FindChild("Shiro").transform.FindChild("No").GetComponent <Text>().text = mySeiryokuList.Count.ToString();

        //Naisei Bldg.
        status.transform.FindChild("Naisei").transform.FindChild("No").GetComponent <Text>().text = (naiseiBldg + mySeiryokuList.Count).ToString();

        //Tabibito
        int tabibitoQty = PlayerPrefs.GetInt("HstTabibito");

        status.transform.FindChild("Tabibito").transform.FindChild("No").GetComponent <Text>().text = tabibitoQty.ToString();

        //Nanbansen
        int nanbansenQty = PlayerPrefs.GetInt("HstNanbansen");

        status.transform.FindChild("Ship").transform.FindChild("No").GetComponent <Text>().text = nanbansenQty.ToString();

        //Syogyo
        status.transform.FindChild("StatusSyogyo").transform.FindChild("SyogyoValue").GetComponent <Text>().text = syogyo.ToString();

        //Nogyo
        status.transform.FindChild("StatusNougyo").transform.FindChild("NougyoValue").GetComponent <Text>().text = nogyo.ToString();

        //Gunjyu
        status.transform.FindChild("StatusGunjyu").transform.FindChild("GunjyuValue").GetComponent <Text>().text = (gunjyu * 2).ToString();

        //Ashigaru
        status.transform.FindChild("StatusAshigaru").transform.FindChild("AshigaruValue").GetComponent <Text>().text = ashigaru.ToString();

        //Boubi
        status.transform.FindChild("StatusBoubi").transform.FindChild("BoubiValue").GetComponent <Text>().text = boubi.ToString();

        //Bukkyo
        status.transform.FindChild("StatusBukkyo").transform.FindChild("BukkyoValue").GetComponent <Text>().text = bukkyo.ToString();

        //Kirisuto
        status.transform.FindChild("StatusKirisuto").transform.FindChild("KirisutoValue").GetComponent <Text>().text = kirisuto.ToString();

        //Bunka
        status.transform.FindChild("StatusBunka").transform.FindChild("BunkaValue").GetComponent <Text>().text = bunka.ToString();

        //tutorial
        if (Application.loadedLevelName == "tutorialMain")
        {
            Destroy(transform.FindChild("point_up").gameObject);
            TutorialController TutorialController = new TutorialController();
            Vector2            vect     = new Vector2(0, 50);
            GameObject         closeObj = popup.transform.FindChild("close").gameObject;
            GameObject         animObj  = TutorialController.SetPointer(closeObj, vect);
            animObj.transform.localScale = new Vector2(120, 120);

            GameObject SubButtonViewLeft = GameObject.Find("SubButtonViewLeft").gameObject;
            GameObject.Find("SeiryokuInfo").transform.SetParent(SubButtonViewLeft.transform);
        }
    }
コード例 #21
0
ファイル: Timer.cs プロジェクト: pratikxman/Sengoku2d
    private void Update()
    {
        if (!paused)
        {
            timer -= Time.deltaTime;
            if (timer > 0.0f)
            {
                //On Play
                gameObject.transform.FindChild("timerText").GetComponent <Text>().text = ((int)timer).ToString();

                //Engun Time
                if (!engunTimerflg)
                {
                    if (timer < engunTime)
                    {
                        engunTimerflg = true;

                        if (playerEngunFlg)
                        {
                            playerEngunInstance(playerEngunList, mntMinusRatio, seaMinusRatio, rainMinusRatio, snowMinusRatio);
                        }

                        if (enemyEngunFlg)
                        {
                            enemyEngunInstance(enemyEngunList, mntMinusRatio, seaMinusRatio, rainMinusRatio, snowMinusRatio);
                        }
                    }
                }

                //cyouryaku
                if (!cyouryakuFlg)
                {
                    if (timer < cyouryakuTime)
                    {
                        cyouryakuFlg = true;
                        cyouryaku(cyouryakuHeiQty, cyouryakuTmp);
                    }
                }
            }
            else
            {
                if (!flag)
                {
                    Time.timeScale = 1;
                    audioSources   = GameObject.Find("SEController").GetComponents <AudioSource> ();
                    audioSources [5].Play();

                    GameObject canvas = GameObject.Find("Canvas").gameObject;

                    //Player battle stop
                    canvas.transform.FindChild("playerHp").GetComponent <HPCounter> ().flag = true;
                    canvas.transform.FindChild("enemyHp").GetComponent <HPCounter> ().flag  = true;

                    //Enable Button
                    if (GameObject.Find("ScrollView"))
                    {
                        GameObject.Find("ScrollView").SetActive(false);
                    }
                    if (GameObject.Find("GiveupBtn"))
                    {
                        GameObject.Find("GiveupBtn").SetActive(false);
                    }

                    if (!isAttackedFlg)
                    {
                        //Player Attacked
                        //Game Over
                        string     backPath = "Prefabs/PostKassen/back";
                        GameObject backObj  = Instantiate(Resources.Load(backPath)) as GameObject;
                        backObj.transform.SetParent(canvas.transform);
                        backObj.transform.localScale    = new Vector2(70, 63);
                        backObj.transform.localPosition = new Vector2(0, 0);

                        //Chane word
                        Color color = Color.blue;
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            GameObject.Find("winlose").GetComponent <TextMesh> ().text = "Timeup";
                        }
                        else
                        {
                            GameObject.Find("winlose").GetComponent <TextMesh>().text = "時間切れ";
                        }
                        GameObject.Find("winlose").GetComponent <TextMesh> ().color = color;
                        audioSources [4].Play();
                        busouKaijyo();

                        string     blackPath = "Prefabs/PostKassen/black";
                        GameObject blackObj  = Instantiate(Resources.Load(blackPath)) as GameObject;
                        blackObj.transform.SetParent(canvas.transform);
                        blackObj.transform.localScale    = new Vector2(330, 300);
                        blackObj.transform.localPosition = new Vector2(0, 0);

                        string     makimonoPath = "Prefabs/PostKassen/makimono";
                        GameObject makimonoObj  = Instantiate(Resources.Load(makimonoPath)) as GameObject;
                        makimonoObj.transform.SetParent(canvas.transform);
                        makimonoObj.transform.localScale    = new Vector2(1, 1);
                        makimonoObj.transform.localPosition = new Vector2(0, -135);

                        //Button List
                        string     nextbtnPath = "Prefabs/PostKassen/bttnList";
                        GameObject bttnListObj = Instantiate(Resources.Load(nextbtnPath)) as GameObject;
                        bttnListObj.transform.SetParent(canvas.transform);
                        bttnListObj.transform.localScale    = new Vector2(1, 1);
                        bttnListObj.transform.localPosition = new Vector2(0, 0);

                        bool isKessenFlg = PlayerPrefs.GetBool("isKessenFlg");
                        if (isKessenFlg)
                        {
                            HPCounter kessen = new HPCounter();
                            kessen.kessenResult(false);
                        }
                    }
                    else
                    {
                        //Enemy Attacked

                        //history
                        if (Application.loadedLevelName != "tutorialKassen")
                        {
                            string tKey = PlayerPrefs.GetString("activeKey");
                            MainStageController main = new MainStageController();
                            main.deleteKeyHistory(tKey);
                            PlayerPrefs.DeleteKey("isAttacked");
                            PlayerPrefs.Flush();

                            bool twiceHeiFlg = PlayerPrefs.GetBool("twiceHeiFlg");
                            if (twiceHeiFlg)
                            {
                                PlayerPrefs.SetBool("questDailyFlg15", true);
                                PlayerPrefs.DeleteKey("twiceHeiFlg");
                                PlayerPrefs.Flush();
                            }

                            //View
                            string     backPath = "Prefabs/PostKassen/back";
                            GameObject backObj  = Instantiate(Resources.Load(backPath)) as GameObject;
                            backObj.transform.SetParent(canvas.transform);
                            backObj.transform.localScale    = new Vector2(70, 63);
                            backObj.transform.localPosition = new Vector2(0, 0);

                            string     particlePath = "Prefabs/PostKassen/particle";
                            GameObject particleObj  = Instantiate(Resources.Load(particlePath)) as GameObject;
                            particleObj.transform.SetParent(canvas.transform);
                            particleObj.transform.localPosition = new Vector2(0, 60);

                            string     blackPath = "Prefabs/PostKassen/black";
                            GameObject blackObj  = Instantiate(Resources.Load(blackPath)) as GameObject;
                            blackObj.transform.SetParent(canvas.transform);
                            blackObj.transform.localScale    = new Vector2(330, 300);
                            blackObj.transform.localPosition = new Vector2(0, 0);

                            string     makimonoPath = "Prefabs/PostKassen/makimono";
                            GameObject makimonoObj  = Instantiate(Resources.Load(makimonoPath)) as GameObject;
                            makimonoObj.transform.SetParent(canvas.transform);
                            makimonoObj.transform.localScale    = new Vector2(1, 1);
                            makimonoObj.transform.localPosition = new Vector2(0, -135);

                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                GameObject.Find("winlose").GetComponent <TextMesh> ().text = "Timeup";
                            }
                            else
                            {
                                GameObject.Find("winlose").GetComponent <TextMesh>().text = "時勝切れ";
                            }
                            string stageName = PlayerPrefs.GetString("activeStageName");
                            audioSources [3].Play();
                            audioSources [7].Play();
                            busouKaijyo();

                            //Item List
                            string     itemListPath = "Prefabs/PostKassen/itemList";
                            GameObject itemListObj  = Instantiate(Resources.Load(itemListPath)) as GameObject;
                            itemListObj.transform.SetParent(canvas.transform);
                            itemListObj.transform.localScale    = new Vector2(1, 1);
                            itemListObj.transform.localPosition = new Vector2(0, -136);

                            //Money
                            int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney", 0);
                            GameObject.Find("moneyAmt").GetComponent <Text>().text = activeStageMoney.ToString();
                            int currentMoney = PlayerPrefs.GetInt("money");
                            currentMoney = currentMoney + activeStageMoney;
                            if (currentMoney < 0)
                            {
                                currentMoney = int.MaxValue;
                            }
                            PlayerPrefs.SetInt("money", currentMoney);

                            //kuniExp
                            int activeStageExp = PlayerPrefs.GetInt("activeStageExp", 0);
                            GameObject.Find("expAmt").GetComponent <Text>().text = activeStageExp.ToString();
                            int currentKuniExp = PlayerPrefs.GetInt("kuniExp");
                            currentKuniExp = currentKuniExp + activeStageExp;
                            int kuniLv    = PlayerPrefs.GetInt("kuniLv");
                            Exp kuniExp   = new Exp();
                            int newKuniLv = kuniExp.getKuniLv(kuniLv, currentKuniExp);

                            if (newKuniLv > kuniLv)
                            {
                                //lv up
                                int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv);
                                int stockLimit  = kuniExp.getStockLimit(newKuniLv);
                                PlayerPrefs.SetInt("jinkeiLimit", jinkeiLimit);
                                PlayerPrefs.SetInt("stockLimit", stockLimit);
                            }
                            else
                            {
                                Debug.Log("No level up");
                            }



                            //Button List
                            string     nextbtnPath = "Prefabs/PostKassen/bttnList";
                            GameObject bttnListObj = Instantiate(Resources.Load(nextbtnPath)) as GameObject;
                            bttnListObj.transform.SetParent(canvas.transform);
                            bttnListObj.transform.localScale    = new Vector2(1, 1);
                            bttnListObj.transform.localPosition = new Vector2(0, 0);

                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                itemListObj.transform.FindChild("stageName").transform.FindChild("stageNameValue").GetComponent <Text> ().text = stageName + " Succeed";
                            }
                            else
                            {
                                itemListObj.transform.FindChild("stageName").transform.FindChild("stageNameValue").GetComponent <Text>().text = stageName + "成功";
                            }

                            //Get Exp
                            SenkouButton       senkou     = new SenkouButton();
                            List <BusyoSenkou> senkouList = new List <BusyoSenkou>();
                            senkouList = senkou.getSenkou();
                            for (int i = 0; i < senkouList.Count; i++)
                            {
                                int busyoId   = senkouList[i].id;
                                int senkouAmt = senkouList[i].senkou;
                                Exp exp       = new Exp();

                                //Modify by Cyadougu Kahou
                                senkouAmt = exp.getExpbyCyadougu(busyoId, senkouAmt);

                                //Busyo Exp
                                string tempExp = "exp" + busyoId;
                                int    nowExp  = PlayerPrefs.GetInt(tempExp);
                                int    newExp  = nowExp + senkouAmt;
                                PlayerPrefs.SetInt(tempExp, newExp);

                                //Busyo Lv
                                int    nowLv    = PlayerPrefs.GetInt(busyoId.ToString());
                                string addLvTmp = "addlv" + busyoId.ToString();
                                int    maxLv    = 100 + PlayerPrefs.GetInt(addLvTmp);
                                if (maxLv > 200)
                                {
                                    maxLv = 200;
                                }
                                int newLv = exp.getLvbyTotalExp(nowLv, newExp, maxLv);
                                PlayerPrefs.SetInt(busyoId.ToString(), newLv);

                                PlayerPrefs.Flush();
                            }
                        }
                        else
                        {
                            busouKaijyo();

                            string     backPath = "Prefabs/PostKassen/back";
                            GameObject backObj  = Instantiate(Resources.Load(backPath)) as GameObject;
                            backObj.transform.SetParent(canvas.transform);
                            backObj.transform.localScale    = new Vector2(70, 63);
                            backObj.transform.localPosition = new Vector2(0, 0);

                            string     blackPath = "Prefabs/PostKassen/black";
                            GameObject blackObj  = Instantiate(Resources.Load(blackPath)) as GameObject;
                            blackObj.transform.SetParent(canvas.transform);
                            blackObj.transform.localScale    = new Vector2(330, 300);
                            blackObj.transform.localPosition = new Vector2(0, 0);

                            string     nextbtnPath = "Prefabs/Tutorial/tutorialBttnList";
                            GameObject bttnListObj = Instantiate(Resources.Load(nextbtnPath)) as GameObject;
                            bttnListObj.transform.SetParent(canvas.transform);
                            bttnListObj.transform.localScale    = new Vector2(1, 1);
                            bttnListObj.transform.localPosition = new Vector2(0, 20);

                            //Win
                            audioSources[3].Play();
                            audioSources[7].Play();

                            string     particlePath = "Prefabs/PostKassen/particle";
                            GameObject particleObj  = Instantiate(Resources.Load(particlePath)) as GameObject;
                            particleObj.transform.SetParent(canvas.transform);
                            particleObj.transform.localPosition = new Vector2(0, 60);
                        }
                    }

                    //Time Stop
                    GameObject.Find("timer").GetComponent <Timer> ().enabled = false;
                    flag = true;


                    PlayerPrefs.Flush();
                }
            }
        }
    }
コード例 #22
0
ファイル: DoNextSeason.cs プロジェクト: pratikxman/Sengoku2d
    public void OnClick()
    {
        if (name == "YesButton")
        {
            Message msg = new Message();

            //check
            int busyoDama = PlayerPrefs.GetInt("busyoDama");
            if (busyoDama >= 100)
            {
                AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
                audioSources [3].Play();

                //Busyo Dama
                int newBusyoDama = busyoDama - 100;
                GameObject.Find("BusyoDamaValue").GetComponent <Text> ().text = newBusyoDama.ToString();
                PlayerPrefs.SetInt("busyoDama", newBusyoDama);


                //Season Change

                /*
                 *
                 *              string yearSeason = PlayerPrefs.GetString ("yearSeason");
                 *              char[] delimiterChars = {','};
                 *              string[] yearSeasonList = yearSeason.Split (delimiterChars);
                 *              int nowYear = int.Parse (yearSeasonList [0]);
                 *              int nowSeason = int.Parse (yearSeasonList [1]);
                 *
                 *              if(nowSeason==4){
                 *                      nowYear = nowYear + 1;
                 *                      nowSeason  = 1;
                 *              }else{
                 *                      nowSeason = nowSeason + 1;
                 *              }
                 *              string newYearSeason = nowYear.ToString() + "," + nowSeason.ToString();
                 *              PlayerPrefs.SetString ("yearSeason", newYearSeason);
                 *
                 * string lastSeasonChangeTime = System.DateTime.Now.ToString ();
                 *              PlayerPrefs.SetString ("lastSeasonChangeTime", lastSeasonChangeTime);
                 *              PlayerPrefs.SetBool ("doneCyosyuFlg", false);
                 *              mainScript.doneCyosyuFlg = false;
                 *              PlayerPrefs.DeleteKey ("usedBusyo");
                 * deleteLinkCut();
                 * deleteWinOver();
                 */

                PlayerPrefs.SetBool("questDailyFlg36", true);
                PlayerPrefs.DeleteKey("bakuhuTobatsuDaimyoId");
                PlayerPrefs.Flush();

                //Extension Mark Handling
                //MainStageController main = new MainStageController();
                //main.questExtension();

                //Change Label
                //GameObject.Find ("YearValue").GetComponent<Text> ().text = nowYear.ToString ();
                //mainScript.SetSeason(nowSeason);

                MainStageController mainScript = GameObject.Find("GameController").GetComponent <MainStageController>();
                mainScript.yearTimer = 1;

                msg.makeMessageOnBoard(msg.getMessage(1));
            }
            else
            {
                msg.makeMessageOnBoard(msg.getMessage(2));
            }
        }
        touchBackObj.GetComponent <CloseOneBoard> ().OnClick();
    }
コード例 #23
0
ファイル: Gunzei.cs プロジェクト: zeimoter/sengoku2d
	public void attack(){

		//Same Daimyo Check
		int latestDaimyoId = kuniIconView.transform.FindChild (dstKuni.ToString ()).GetComponent<SendParam> ().daimyoId;
		GameObject MsgBack = this.transform.FindChild ("MsgBack").gameObject;
		GameObject MsgText = MsgBack.transform.FindChild ("MsgText").gameObject;

		if (dstDaimyoId == latestDaimyoId) {
		
			if (dstDaimyoId != myDaimyoId) {
				int enemyHei = heiryokuCalc (dstKuni);

				//Engun
				int engunTotalHei = 0;
				if(dstEngunFlg){
					char[] delimiterChars2 = {':'};
					List<string> engunHeiList = new List<string>();
					engunHeiList = new List<string> (dstEngunHei.Split (delimiterChars2));

					for(int k=0; k<engunHeiList.Count; k++){
						engunTotalHei = engunTotalHei + int.Parse(engunHeiList[k]);
					}
				}

				enemyHei = enemyHei + engunTotalHei;

				int ratio = 0;
				if ((myHei + enemyHei) != 0) {
					ratio = 100 * myHei / (myHei + enemyHei);
					if (ratio < 1) {
						ratio = 1;
					}	
				}

				MainEventHandler kassenEvent = new MainEventHandler ();
				bool winFlg = kassenEvent.CheckByProbability (ratio);

				Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst;
				string dstKuniName = kuniMst.param [dstKuni - 1].kuniName;

				//Gaikou
				Gaikou gaikou = new Gaikou();
				gaikou.downGaikouByAttack(srcDaimyoId,dstDaimyoId);

				if (winFlg) {
					bool noGunzeiFlg = false;
					string syouhai = srcDaimyoName + "\t" + dstKuniName + "を攻略";
					MsgBack.GetComponent<Image> ().enabled = true;
					MsgText.GetComponent<Text> ().enabled = true;
					MsgText.GetComponent<Text> ().text = syouhai;
					if (leftFlg == true) {
						MsgText.transform.localScale = new Vector2 (-0.12f, 0.17f);
					}

					win (key, srcDaimyoId, dstDaimyoId, noGunzeiFlg);

				} else {
					string syouhai = dstDaimyoName + "\t" + dstKuniName + "を防衛";
					MsgBack.GetComponent<Image> ().enabled = true;
					MsgText.GetComponent<Text> ().enabled = true;
					MsgText.GetComponent<Text> ().text = syouhai;
					if (leftFlg == true) {
						MsgText.transform.localScale = new Vector2 (-0.12f, 0.17f);
					}
					gameObject.GetComponent<GunzeiFadeOut> ().enabled = true;

					MainStageController main = new MainStageController ();
					main.deleteKeyHistory (key);
				}
			
			} else {
				MyDaimyoWasAttacked atked = new MyDaimyoWasAttacked ();
				atked.wasAttacked (key, srcKuni, dstKuni, srcDaimyoId, dstDaimyoId, dstEngunFlg, dstEngunDaimyoId, dstEngunSts);
			}
		} else {

			string syouhai = srcDaimyoName + "撤退";
			MsgBack.GetComponent<Image> ().enabled = true;
			MsgText.GetComponent<Text> ().enabled = true;
			MsgText.GetComponent<Text> ().text = syouhai;
			if (leftFlg == true) {
				MsgText.transform.localScale = new Vector2 (-0.12f, 0.17f);
			}
			gameObject.GetComponent<GunzeiFadeOut> ().enabled = true;
			
			MainStageController main = new MainStageController ();
			main.deleteKeyHistory (key);
		}
	}
コード例 #24
0
    void MovieRewardCallback(ArrayList vars)
    {
        int    stateName    = (int)vars[0];
        string appID        = (string)vars[1];
        string adnetworkKey = (string)vars[2];

        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource>();
        audioSources[0].Play();
        Message msg  = new Message();
        string  text = "";


        AdfurikunMovieRewardUtility.ADF_MovieStatus state = (AdfurikunMovieRewardUtility.ADF_MovieStatus)stateName; switch (state)
        {
        case AdfurikunMovieRewardUtility.ADF_MovieStatus.PrepareSuccess:
            Debug.Log("The ad was preapred.");
            break;

        case AdfurikunMovieRewardUtility.ADF_MovieStatus.StartPlaying:
            Debug.Log("The ad was started.");
            break;

        case AdfurikunMovieRewardUtility.ADF_MovieStatus.AdClose:
            Screen.orientation = ScreenOrientation.LandscapeLeft;

            //set count data
            int movieCount = PlayerPrefs.GetInt("movieCount");
            movieCount = movieCount + 1;
            PlayerPrefs.SetInt("movieCount", movieCount);

            //stop running gunzei
            CyouteiPop CyouteiPop = new CyouteiPop();
            CyouteiPop.stopGunzei();

            if (!hyourouFlg)
            {
                int    busyoDamaQty = 0;
                string atariMsg     = "";
                float  rankPercent  = UnityEngine.Random.value;
                rankPercent = rankPercent * 100;
                if (rankPercent <= 10)
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        atariMsg = "My lord, Big Hit! \n";
                    }
                    else
                    {
                        atariMsg = "大当たりですぞ。\n";
                    }
                    busyoDamaQty = UnityEngine.Random.Range(20, 51);     //20-50
                }
                else if (10 < rankPercent && rankPercent <= 40)
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        atariMsg = "My lord, Mid Hit. \n";
                    }
                    else
                    {
                        atariMsg = "中当たりですぞ。\n";
                    }
                    busyoDamaQty = UnityEngine.Random.Range(10, 21);     //10-20
                }
                else if (40 < rankPercent)
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        atariMsg = "My lord, Low Hit. \n";
                    }
                    else
                    {
                        atariMsg = "小当たりですぞ。\n";
                    }
                    busyoDamaQty = UnityEngine.Random.Range(5, 11);     //5-10
                }

                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    text = atariMsg + "You got " + busyoDamaQty + " stone.";
                }
                else
                {
                    text = atariMsg + "武将珠を" + busyoDamaQty + "個手に入れましたぞ。";
                }
                msg.makeMessageOnBoard(text);

                int busyoDama    = PlayerPrefs.GetInt("busyoDama");
                int newBusyoDama = busyoDama + busyoDamaQty;
                PlayerPrefs.SetInt("busyoDama", newBusyoDama);
                PlayerPrefs.Flush();
                GameObject.Find("BusyoDamaValue").GetComponent <Text>().text = newBusyoDama.ToString();
            }
            else
            {
                int    hyourouQty  = 0;
                string atariMsg    = "";
                float  rankPercent = UnityEngine.Random.value;
                rankPercent = rankPercent * 100;
                if (rankPercent <= 10)
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        atariMsg = "My lord, Big Hit! \n";
                    }
                    else
                    {
                        atariMsg = "大当たりですぞ。\n";
                    }
                    hyourouQty = UnityEngine.Random.Range(30, 51);     //30-50
                }
                else if (10 < rankPercent && rankPercent <= 40)
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        atariMsg = "My lord, Mid Hit. \n";
                    }
                    else
                    {
                        atariMsg = "中当たりですぞ。\n";
                    }
                    hyourouQty = UnityEngine.Random.Range(20, 31);     //20-30
                }
                else if (40 < rankPercent)
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        atariMsg = "My lord, Low Hit. \n";
                    }
                    else
                    {
                        atariMsg = "小当たりですぞ。\n";
                    }
                    hyourouQty = UnityEngine.Random.Range(10, 21);     //10-20
                }

                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    text = atariMsg + "You got " + hyourouQty + " stamina.";
                }
                else
                {
                    text = atariMsg + "兵糧を" + hyourouQty + "個手に入れましたぞ。";
                }
                msg.makeMessageOnBoard(text);

                int hyourou    = PlayerPrefs.GetInt("hyourou");
                int newHyourou = hyourou + hyourouQty;
                if (newHyourou > 100)
                {
                    newHyourou = 100;
                }
                PlayerPrefs.SetInt("hyourou", newHyourou);
                PlayerPrefs.Flush();
                GameObject.Find("HyourouCurrentValue").GetComponent <Text>().text = newHyourou.ToString();
            }

            audioSources[3].Play();
            if (SceneManager.GetActiveScene().name == "mainStage")
            {
                GameObject          ob = GameObject.Find("GameController");
                MainStageController mc = ob.GetComponent <MainStageController>();
                mc.adRunFlg = false;
            }
            GameObject.Find("MessageStaminaObject").transform.FindChild("Close").GetComponent <CloseMessageStamina>().OnClick();

            break;

        default:
            return;

        case AdfurikunMovieRewardUtility.ADF_MovieStatus.FailedPlaying:
            audioSources[4].Play();
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                text = "There is no available video now. Please try it later.";
            }
            else
            {
                text = "再生可能な動画広告がありません。時間を置いて試してくだされ。";
            }
            msg.makeMessageOnBoard(text);
            if (SceneManager.GetActiveScene().name == "mainStage")
            {
                GameObject          ob = GameObject.Find("GameController");
                MainStageController mc = ob.GetComponent <MainStageController>();
                mc.adRunFlg = false;
            }

            break;
            //case AdfurikunMovieRewardUtility.ADF_MovieStatus.AdClose:
            //        Debug.Log("The ad was closed.");
            //break;
            //default:
            //return;
        }
    }
コード例 #25
0
    public void attack()
    {
        audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        //Same Daimyo Check
        int        latestDaimyoId = kuniIconView.transform.FindChild(dstKuni.ToString()).GetComponent <SendParam> ().daimyoId;
        GameObject MsgBack        = this.transform.FindChild("MsgBack").gameObject;
        GameObject MsgText        = MsgBack.transform.FindChild("MsgText").gameObject;

        if (dstDaimyoId == latestDaimyoId)
        {
            if (dstDaimyoId != myDaimyoId)
            {
                audioSources [7].Play();

                int enemyHei = heiryokuCalc(dstKuni);

                //Engun
                int engunTotalHei = 0;
                if (dstEngunFlg)
                {
                    char[]        delimiterChars2 = { ':' };
                    List <string> engunHeiList    = new List <string>();
                    engunHeiList = new List <string> (dstEngunHei.Split(delimiterChars2));

                    for (int k = 0; k < engunHeiList.Count; k++)
                    {
                        engunTotalHei = engunTotalHei + int.Parse(engunHeiList[k]);
                    }
                }

                enemyHei = enemyHei + engunTotalHei;

                int ratio = 0;
                if ((myHei + enemyHei) != 0)
                {
                    ratio = 100 * myHei / (myHei + enemyHei);
                    if (ratio < 1)
                    {
                        ratio = 1;
                    }
                }

                MainEventHandler kassenEvent = new MainEventHandler();
                bool             winFlg      = kassenEvent.CheckByProbability(ratio);

                //Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst;
                KuniInfo kuniScript  = new KuniInfo();
                string   dstKuniName = kuniScript.getKuniName(dstKuni);

                //Gaikou
                Gaikou gaikou = new Gaikou();
                gaikou.downGaikouByAttack(srcDaimyoId, dstDaimyoId);

                if (winFlg)
                {
                    bool   noGunzeiFlg = false;
                    string syouhai     = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        syouhai = srcDaimyoName + "\n" + "Conquered " + dstKuniName;
                    }
                    else
                    {
                        syouhai = srcDaimyoName + "\n" + dstKuniName + "を攻略";
                    }
                    MsgBack.GetComponent <Image> ().enabled = true;
                    MsgText.GetComponent <Text> ().enabled  = true;
                    MsgText.GetComponent <Text> ().text     = syouhai;

                    win(key, srcDaimyoId, dstDaimyoId, noGunzeiFlg, dstKuni);

                    fire(dstKuni);
                }
                else
                {
                    string syouhai = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        syouhai = dstDaimyoName + "\n" + "Defended " + dstKuniName;
                    }
                    else
                    {
                        syouhai = dstDaimyoName + "\n" + dstKuniName + "を防衛";
                    }
                    MsgBack.GetComponent <Image> ().enabled = true;
                    MsgText.GetComponent <Text> ().enabled  = true;
                    MsgText.GetComponent <Text> ().text     = syouhai;

                    gameObject.GetComponent <GunzeiFadeOut> ().enabled = true;

                    MainStageController main = new MainStageController();
                    main.deleteKeyHistory(key);
                }
            }
            else
            {
                MyDaimyoWasAttacked atked = new MyDaimyoWasAttacked();
                atked.wasAttacked(key, srcKuni, dstKuni, srcDaimyoId, dstDaimyoId, dstEngunFlg, dstEngunDaimyoId, dstEngunSts);
            }
        }
        else
        {
            audioSources [1].Play();
            string syouhai = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                syouhai = srcDaimyoName + " withdrawed";
            }
            else
            {
                syouhai = srcDaimyoName + "撤退";
            }
            MsgBack.GetComponent <Image> ().enabled = true;
            MsgText.GetComponent <Text> ().enabled  = true;
            MsgText.GetComponent <Text> ().text     = syouhai;

            gameObject.GetComponent <GunzeiFadeOut> ().enabled = true;

            MainStageController main = new MainStageController();
            main.deleteKeyHistory(key);
        }
    }
コード例 #26
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        if (!doneCyosyuFlg)
        {
            audioSources [3].Play();
            doneCyosyuFlg = true;
            MainStageController main = new MainStageController();

            /*** season change Start ***/
            string   yearSeason     = PlayerPrefs.GetString("yearSeason");
            char[]   delimiterChars = { ',' };
            string[] yearSeasonList = yearSeason.Split(delimiterChars);
            int      nowYear        = int.Parse(yearSeasonList[0]);
            int      nowSeason      = int.Parse(yearSeasonList[1]);

            if (nowSeason == 4)
            {
                nowYear   = nowYear + 1;
                nowSeason = 1;
            }
            else
            {
                nowSeason = nowSeason + 1;
            }

            string newYearSeason = nowYear.ToString() + "," + nowSeason.ToString();
            PlayerPrefs.DeleteKey("bakuhuTobatsuDaimyoId");
            PlayerPrefs.SetString("yearSeason", newYearSeason);

            string lastSeasonChangeTime = System.DateTime.Now.ToString();
            PlayerPrefs.SetString("lastSeasonChangeTime", lastSeasonChangeTime);
            PlayerPrefs.DeleteKey("usedBusyo");
            DoNextSeason DoNextSeason = new DoNextSeason();
            DoNextSeason.deleteLinkCut();
            DoNextSeason.deleteWinOver();
            PlayerPrefs.Flush();

            //Change Label
            GameObject.Find("YearValue").GetComponent <Text>().text = nowYear.ToString();
            main.SetSeason(nowSeason);
            /*** season change End ***/


            PlayerPrefs.SetBool("doneCyosyuFlg", doneCyosyuFlg);
            string targetName = "";

            //Cyosyu Handling
            if (cyosyuTarget == "money")
            {
                int nowMoney    = PlayerPrefs.GetInt("money");
                int resultMoney = nowMoney + totalMoney;
                if (totalKozanMoney != 0)
                {
                    resultMoney = resultMoney + totalKozanMoney;
                }
                if (resultMoney < 0)
                {
                    resultMoney = int.MaxValue;
                }
                PlayerPrefs.SetInt("money", resultMoney);
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    targetName = "Money";
                }
                else
                {
                    targetName = "金";
                }
                GameObject.Find("MoneyValue").GetComponent <Text> ().text = resultMoney.ToString();

                int TrackGetMoneyNo = PlayerPrefs.GetInt("TrackGetMoneyNo", 0);
                TrackGetMoneyNo = TrackGetMoneyNo + totalMoney + totalKozanMoney;
                PlayerPrefs.SetInt("TrackGetMoneyNo", TrackGetMoneyNo);
            }
            else if (cyosyuTarget == "hyourou")
            {
                int nowHyourou    = PlayerPrefs.GetInt("hyourou");
                int maxHyourou    = PlayerPrefs.GetInt("hyourouMax");
                int resultHyourou = nowHyourou + totalHyourou;
                if (resultHyourou > maxHyourou)
                {
                    resultHyourou = maxHyourou;
                }
                PlayerPrefs.SetInt("hyourou", resultHyourou);
                GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = resultHyourou.ToString();
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    targetName = "Stamina";
                }
                else
                {
                    targetName = "兵糧";
                }
                int TrackGetHyourouNo = PlayerPrefs.GetInt("TrackGetHyourouNo", 0);
                TrackGetHyourouNo = TrackGetHyourouNo + totalHyourou;
                PlayerPrefs.SetInt("TrackGetHyourouNo", TrackGetHyourouNo);

                if (totalKozanMoney != 0)
                {
                    int nowMoney    = PlayerPrefs.GetInt("money");
                    int resultMoney = nowMoney + totalKozanMoney;
                    if (resultMoney < 0)
                    {
                        resultMoney = int.MaxValue;
                    }
                    PlayerPrefs.SetInt("money", resultMoney);
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        targetName = targetName + " and Gold";
                    }
                    else
                    {
                        targetName = targetName + "と鉱山収入";
                    }

                    GameObject.Find("MoneyValue").GetComponent <Text> ().text = resultMoney.ToString();

                    int TrackGetMoneyNo = PlayerPrefs.GetInt("TrackGetMoneyNo", 0);
                    TrackGetMoneyNo = TrackGetMoneyNo + totalKozanMoney;
                    PlayerPrefs.SetInt("TrackGetMoneyNo", TrackGetMoneyNo);
                }
            }
            else if (cyosyuTarget == "gunjyu")
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    targetName = "Weapon";
                }
                else
                {
                    targetName = "軍需物資";
                }

                //YR
                if (totalYRL != 0 || totalYRM != 0 || totalYRH != 0)
                {
                    string        cyoheiYRString = PlayerPrefs.GetString("cyouheiYR");
                    List <string> cyoheiYRList   = new List <string>();
                    cyoheiYRList = new List <string> (cyoheiYRString.Split(delimiterChars));

                    int newYRL = totalYRL;
                    int newYRM = totalYRM;
                    int newYRH = totalYRH;

                    newYRL = newYRL + int.Parse(cyoheiYRList[0]);
                    newYRM = newYRM + int.Parse(cyoheiYRList[1]);
                    newYRH = newYRH + int.Parse(cyoheiYRList[2]);

                    string newCyoheiYR = newYRL + "," + newYRM + "," + newYRH;
                    PlayerPrefs.SetString("cyouheiYR", newCyoheiYR);
                }
                //KB
                if (totalKBL != 0 || totalKBM != 0 || totalKBH != 0)
                {
                    string        cyoheiKBString = PlayerPrefs.GetString("cyouheiKB");
                    List <string> cyoheiKBList   = new List <string>();
                    cyoheiKBList = new List <string> (cyoheiKBString.Split(delimiterChars));
                    int newKBL = totalKBL;
                    int newKBM = totalKBM;
                    int newKBH = totalKBH;

                    newKBL = newKBL + int.Parse(cyoheiKBList[0]);
                    newKBM = newKBM + int.Parse(cyoheiKBList[1]);
                    newKBH = newKBH + int.Parse(cyoheiKBList[2]);

                    string newCyoheiKB = newKBL + "," + newKBM + "," + newKBH;
                    PlayerPrefs.SetString("cyouheiKB", newCyoheiKB);
                }
                //YM
                if (totalYML != 0 || totalYMM != 0 || totalYMH != 0)
                {
                    string        cyoheiYMString = PlayerPrefs.GetString("cyouheiYM");
                    List <string> cyoheiYMList   = new List <string>();
                    cyoheiYMList = new List <string> (cyoheiYMString.Split(delimiterChars));
                    int newYML = totalYML;
                    int newYMM = totalYMM;
                    int newYMH = totalYMH;

                    newYML = newYML + int.Parse(cyoheiYMList[0]);
                    newYMM = newYMM + int.Parse(cyoheiYMList[1]);
                    newYMH = newYMH + int.Parse(cyoheiYMList[2]);

                    string newCyoheiYM = newYML + "," + newYMM + "," + newYMH;
                    PlayerPrefs.SetString("cyouheiYM", newCyoheiYM);
                }
                //TP
                if (totalTPL != 0 || totalTPM != 0 || totalTPH != 0)
                {
                    string        cyoheiTPString = PlayerPrefs.GetString("cyouheiTP");
                    List <string> cyoheiTPList   = new List <string>();
                    cyoheiTPList = new List <string> (cyoheiTPString.Split(delimiterChars));
                    int newTPL = totalTPL;
                    int newTPM = totalTPM;
                    int newTPH = totalTPH;

                    newTPL = newTPL + int.Parse(cyoheiTPList[0]);
                    newTPM = newTPM + int.Parse(cyoheiTPList[1]);
                    newTPH = newTPH + int.Parse(cyoheiTPList[2]);

                    string newCyoheiTP = newTPL + "," + newTPM + "," + newTPH;
                    PlayerPrefs.SetString("cyouheiTP", newCyoheiTP);
                }
                //SNB
                if (totalSNBL != 0 || totalSNBM != 0 || totalSNBH != 0)
                {
                    if (totalSNBL != 0)
                    {
                        int SNBQty = PlayerPrefs.GetInt("shinobiGe");
                        int newQty = SNBQty + totalSNBL;

                        PlayerPrefs.SetInt("shinobiGe", newQty);
                    }
                    if (totalSNBM != 0)
                    {
                        int SNBQty = PlayerPrefs.GetInt("shinobiCyu");
                        int newQty = SNBQty + totalSNBM;

                        PlayerPrefs.SetInt("shinobiCyu", newQty);
                    }
                    if (totalSNBH != 0)
                    {
                        int SNBQty = PlayerPrefs.GetInt("shinobiJyo");
                        int newQty = SNBQty + totalSNBH;

                        PlayerPrefs.SetInt("shinobiJyo", newQty);
                    }
                }
                int TrackGetSozaiNo = PlayerPrefs.GetInt("TrackGetSozaiNo", 0);
                TrackGetSozaiNo = TrackGetSozaiNo + totalYRL + totalKBL + totalYML + totalTPL + totalYRM + totalKBM + totalYMM + totalTPM + totalYRH + totalKBH + totalYMH + totalTPH + totalSNBL + totalSNBM + totalSNBH;
                PlayerPrefs.SetInt("TrackGetSozaiNo", TrackGetSozaiNo);


                if (totalKozanMoney != 0)
                {
                    int nowMoney    = PlayerPrefs.GetInt("money");
                    int resultMoney = nowMoney + totalKozanMoney;
                    if (resultMoney < 0)
                    {
                        resultMoney = int.MaxValue;
                    }
                    PlayerPrefs.SetInt("money", resultMoney);
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        targetName = targetName + " and Gold";
                    }
                    else
                    {
                        targetName = targetName + "と鉱山収入";
                    }

                    GameObject.Find("MoneyValue").GetComponent <Text> ().text = resultMoney.ToString();

                    int TrackGetMoneyNo = PlayerPrefs.GetInt("TrackGetMoneyNo", 0);
                    TrackGetMoneyNo = TrackGetMoneyNo + totalKozanMoney;
                    PlayerPrefs.SetInt("TrackGetMoneyNo", TrackGetMoneyNo);
                }
            }

            PlayerPrefs.SetBool("questDailyFlg38", true);
            PlayerPrefs.Flush();

            MainStageController mainStage = new MainStageController();
            mainStage.questExtension();

            //Message
            Message msg  = new Message();
            string  text = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                text = "My lord, you earned " + targetName + ".\nPlease enrich the country more by development.";
            }
            else
            {
                text = targetName + "を徴収しましたぞ。\n内政でより国を富ませましょう。";
            }
            msg.makeMessageOnBoard(text);

            //Restart
            GameObject.Find("GameController").GetComponent <MainStageController>().doneCyosyuFlg = true;
            GameObject.Find("GetTimer").GetComponent <GetNaiseiTimer>().Start();
            GameObject.Find("GetTimer").GetComponent <GetNaiseiTimer>().timer = GameObject.Find("GameController").GetComponent <MainStageController>().yearTimer;

            //tutorial
            if (Application.loadedLevelName == "tutorialMain")
            {
                Destroy(GameObject.Find("board").gameObject);
                Destroy(GameObject.Find("Back(Clone)").gameObject);
                PlayerPrefs.SetInt("tutorialId", 5);
                PlayerPrefs.Flush();

                TextController txtScript = GameObject.Find("TextBoard").transform.FindChild("Text").GetComponent <TextController>();
                txtScript.SetText(5);
                txtScript.SetNextLine();
                txtScript.tutorialId = 5;
                txtScript.actOnFlg   = false;

                GameObject SubButtonViewLeft = GameObject.Find("SubButtonViewLeft").gameObject;
                GameObject.Find("SeiryokuInfo").transform.SetParent(SubButtonViewLeft.transform);
            }
        }
        else
        {
            audioSources [4].Play();

            Message msg  = new Message();
            string  text = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                text = "Season hasn't changed.\nPlease wait a moment for collecting taxes.";
            }
            else
            {
                text = "まだ季節は変わっておりませぬぞ。\n徴収は今しばらくお待ち下さいませ。";
            }
            msg.makeMessageOnBoard(text);
        }
    }
コード例 #27
0
ファイル: DoGaikou.cs プロジェクト: pratikxman/Sengoku2d
    // Use this for initialization
    public void OnClick()
    {
        Message    msg         = new Message();
        Gaikou     gaikou      = new Gaikou();
        CloseBoard closeScript = GameObject.Find("close").GetComponent <CloseBoard> ();

        daimyoId = closeScript.daimyoId;

        if (hyourouOKflg)
        {
            if (moneyOKflg)
            {
                //Track
                int TrackGaikouNo = PlayerPrefs.GetInt("TrackGaikouNo", 0);
                TrackGaikouNo = TrackGaikouNo + 1;
                PlayerPrefs.SetInt("TrackGaikouNo", TrackGaikouNo);


                if (name == "DoMitsugiBtn")
                {
                    string tempGaikou = "gaikou" + daimyoId;
                    int    nowYukoudo = 0;
                    if (PlayerPrefs.HasKey(tempGaikou))
                    {
                        nowYukoudo = PlayerPrefs.GetInt(tempGaikou);
                    }
                    else
                    {
                        nowYukoudo = 50;
                    }

                    float percent = UnityEngine.Random.value;
                    percent = percent * 100;
                    float tmpYukoudo = (float)nowYukoudo;
                    if (tmpYukoudo < 5)
                    {
                        tmpYukoudo = 5;
                    }

                    if (percent <= tmpYukoudo * 2)
                    {
                        //Success
                        audioSources[3].Play();
                        reduceMoneyHyourou();
                        addUsedBusyo(busyoId);

                        //Doumei
                        bool doumeiFlg = closeScript.doumeiFlg;

                        //Add Yukoudo
                        // AddYukoudo = (Money/200)*chiryaku/500
                        int addYukoudo = (paiedMoney / 200) + (busyoChiryaku / 100);
                        if (addYukoudo <= 0)
                        {
                            addYukoudo = 1;
                        }


                        if (doumeiFlg)
                        {
                            addYukoudo = addYukoudo * 2;
                        }


                        int newYukoudo = nowYukoudo + addYukoudo;
                        if (newYukoudo > 100)
                        {
                            newYukoudo = 100;
                        }
                        PlayerPrefs.SetInt(tempGaikou, newYukoudo);
                        GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();

                        //Change new yukoudo
                        closeScript.yukoudo = newYukoudo;

                        //Message
                        string OKtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            OKtext = "Gave money " + paiedMoney + " to " + daimyoName + ".\n Friendship increased " + addYukoudo + " point";
                        }
                        else
                        {
                            OKtext = daimyoName + "に金" + paiedMoney + "の貢物をしました。\n友好度が" + addYukoudo + "上がりますぞ。";
                        }
                        msg.makeMessage(OKtext);
                        PlayerPrefs.SetBool("questDailyFlg28", true);

                        PlayerPrefs.Flush();

                        //Extension Mark Handling
                        MainStageController main = new MainStageController();
                        main.questExtension();

                        upYukouOnIcon(daimyoId, newYukoudo);
                    }
                    else
                    {
                        //Fail
                        audioSources[4].Play();
                        paiedMoney = 0;
                        reduceMoneyHyourou();

                        //Message
                        string NGtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            NGtext = daimyoName + " declined our money.\n He doesn't want to build a good relationship with us";
                        }
                        else
                        {
                            NGtext = daimyoName + "に貢物を体よく断られ申した。\n当家と関係を修復する気はないようですな。";
                        }
                        msg.makeMessage(NGtext);
                    }
                    //Back
                    GameObject.Find("return").GetComponent <MenuReturn> ().OnClick();
                }
                else if (name == "DoDoumeiBtn")
                {
                    reduceMoneyHyourou();

                    //Doumei
                    float percent = Random.value;
                    percent = percent * 100;

                    if (percent <= doumeiRatio)
                    {
                        //Doumei Success
                        audioSources [3].Play();

                        //Track
                        int TrackDoumeiNo = PlayerPrefs.GetInt("TrackDoumeiNo", 0);
                        TrackDoumeiNo = TrackDoumeiNo + 1;
                        PlayerPrefs.SetInt("TrackDoumeiNo", TrackDoumeiNo);


                        addUsedBusyo(busyoId);

                        string doumei = PlayerPrefs.GetString("doumei");
                        if (doumei == null || doumei == "")
                        {
                            doumei = daimyoId.ToString();
                        }
                        else
                        {
                            doumei = doumei + "," + daimyoId.ToString();
                        }

                        //Data
                        int    myDaimyo      = PlayerPrefs.GetInt("myDaimyo");
                        string cpuDoumeiTemp = "doumei" + daimyoId.ToString();
                        string cpuDoumei     = PlayerPrefs.GetString(cpuDoumeiTemp);
                        if (cpuDoumei != null & cpuDoumei != "")
                        {
                            cpuDoumei = cpuDoumei + "," + myDaimyo.ToString();
                        }
                        else
                        {
                            cpuDoumei = myDaimyo.ToString();
                        }
                        PlayerPrefs.SetString(cpuDoumeiTemp, cpuDoumei);
                        PlayerPrefs.SetString("doumei", doumei);

                        //Change Target Flg & Kuni Icon Color
                        string        seiryoku       = PlayerPrefs.GetString("seiryoku");
                        char[]        delimiterChars = { ',' };
                        List <string> seiryokuList   = new List <string> ();
                        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));
                        GameObject KuniIconView = GameObject.Find("KuniIconView").gameObject;

                        Color doumeiColor = new Color(100f / 255f, 130f / 255f, 255f / 255f, 255f / 255f);                          //Blue
                        for (int i = 0; i < seiryokuList.Count; i++)
                        {
                            int tempDaimyoId = int.Parse(seiryokuList [i]);

                            if (tempDaimyoId == daimyoId)
                            {
                                int        kuniId   = i + 1;
                                GameObject kuniIcon = KuniIconView.transform.FindChild(kuniId.ToString()).gameObject;
                                kuniIcon.GetComponent <Image> ().color         = doumeiColor;
                                kuniIcon.GetComponent <SendParam> ().doumeiFlg = true;
                            }
                        }

                        PlayerPrefs.SetBool("questSpecialFlg2", true);
                        //Extension Mark Handling
                        MainStageController main = new MainStageController();
                        main.questExtension();

                        //Msg
                        string OKtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            OKtext = "Congratulations.\n" + "We concluded an alliance with" + daimyoName + ".\n" + "we got some of strategic options.";
                        }
                        else
                        {
                            OKtext = "教悦至極にございます。" + daimyoName + "と同盟を結びましたぞ。\n" + "戦略の幅が広がりますな。";
                        }
                        msg.makeMessage(OKtext);

                        //If Gunzei Exist
                        foreach (GameObject obs in  GameObject.FindGameObjectsWithTag("Gunzei"))
                        {
                            int srcDaimyoId = obs.GetComponent <Gunzei>().srcDaimyoId;
                            int dstDaimyoId = obs.GetComponent <Gunzei>().dstDaimyoId;
                            if (srcDaimyoId == daimyoId && dstDaimyoId == myDaimyo)
                            {
                                Gunzei gunzeiScript = new Gunzei();
                                gunzeiScript.deleteGunzei(obs);
                            }
                        }


                        Destroy(GameObject.Find("smallBoard(Clone)"));
                        Destroy(GameObject.Find("TouchBack(Clone)"));
                    }
                    else
                    {
                        //Doumie Failed
                        audioSources [4].Play();

                        int maxReduceValue = 3;
                        int nowYukoudo     = gaikou.getMyGaikou(daimyoId);
                        int newYukoudo     = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue);
                        int reduceYukoudo  = nowYukoudo - newYukoudo;
                        closeScript.yukoudo = newYukoudo;

                        GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();
                        string NGtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            NGtext = daimyoName + " declined our proposal. \n" + "Friendship decreased " + reduceYukoudo + " point";
                        }
                        else
                        {
                            NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。";
                        }
                        msg.makeMessage(NGtext);

                        downYukouOnIcon(daimyoId, newYukoudo);

                        //Back
                        GameObject.Find("return").GetComponent <MenuReturn> ().OnClick();
                    }

                    PlayerPrefs.Flush();
                }
                else if (name == "DoKyoutouBtn")
                {
                    reduceMoneyHyourou();

                    //Kyoutou Check
                    float percent = Random.value;
                    percent = percent * 100;
                    if (percent <= kyoutouRatio)
                    {
                        audioSources [3].Play();

                        //Success
                        addUsedBusyo(busyoId);

                        string           playerKyoutouList = PlayerPrefs.GetString("playerKyoutouList", "");
                        MainEventHandler kyoutou           = new MainEventHandler();
                        if (playerKyoutouList == null || playerKyoutouList == "")
                        {
                            playerKyoutouList = targetKuniId + "-" + kyoutou.getEngunSts(daimyoId.ToString());
                        }
                        else
                        {
                            playerKyoutouList = playerKyoutouList + ":" + +targetKuniId + "-" + kyoutou.getEngunSts(daimyoId.ToString());
                        }
                        PlayerPrefs.SetString("playerKyoutouList", playerKyoutouList);

                        //Msg
                        string OKtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            OKtext = "Good. " + daimyoName + "will support our party in " + kuniName + " attack";
                        }
                        else
                        {
                            OKtext = daimyoName + "殿が" + kuniName + "攻めに\n加勢してくれますぞ。百人力ですな。";
                        }
                        msg.makeMessage(OKtext);
                    }
                    else
                    {
                        //Fail
                        audioSources [4].Play();

                        //Doumie Failed
                        int maxReduceValue = 3;
                        int nowYukoudo     = gaikou.getMyGaikou(daimyoId);
                        int newYukoudo     = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue);
                        int reduceYukoudo  = nowYukoudo - newYukoudo;
                        GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();
                        closeScript.yukoudo = newYukoudo;

                        string NGtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            NGtext = daimyoName + " declined our proposal. \n" + "Friendship decreased " + reduceYukoudo + " point";
                        }
                        else
                        {
                            NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。";
                        }
                        msg.makeMessage(NGtext);

                        downYukouOnIcon(daimyoId, newYukoudo);
                    }

                    PlayerPrefs.Flush();

                    //Back
                    GameObject.Find("return").GetComponent <MenuReturn> ().OnClick();
                }
                else if (name == "DoDoukatsuBtn")
                {
                    reduceMoneyHyourou();

                    float percent = Random.value;
                    percent = percent * 100;

                    if (percent <= doukatsuRatio)
                    {
                        //Success
                        audioSources [3].Play();
                        addUsedBusyo(busyoId);

                        int kuniQty  = closeScript.kuniQty;
                        int getMoney = 0;
                        //Money or Item 0:money, 1:item
                        int moneyOrItem = UnityEngine.Random.Range(0, 2);
                        //Kahou or Shizai 0:kahou, 1:shizai
                        int    kahouOrShizai = UnityEngine.Random.Range(0, 2);
                        string kahouName     = "";
                        string shigenName    = "";
                        int    addQty        = 0;
                        int    kahouRank     = 0;                  //kahouRank S,A,B,C=1,2,3,4
                        //shigen Type
                        int shigenType = 0;                        //KB,YR,TP,YM=1,2,3,4

                        if (moneyOrItem == 0)
                        {
                            //money
                            int temGetMoney = UnityEngine.Random.Range(1000, 1501);
                            getMoney = temGetMoney * kuniQty;
                            int nowMoney = PlayerPrefs.GetInt("money");
                            nowMoney = nowMoney + getMoney;
                            if (nowMoney < 0)
                            {
                                nowMoney = int.MaxValue;
                            }
                            PlayerPrefs.SetInt("money", nowMoney);
                            PlayerPrefs.Flush();
                        }
                        else
                        {
                            //item
                            //Kahou or Shizai 0:kahou, 1:shizai
                            kahouOrShizai = UnityEngine.Random.Range(0, 2);
                            if (kahouOrShizai == 0)
                            {
                                //kahou
                                Kahou kahou = new Kahou();
                                ////Bugu, Gusoku, Kabuto, Meiba, Heihousyo, Cyadougu, Chishikisyo(1,2,3,4,5,6)
                                int kahouType = UnityEngine.Random.Range(1, 7);

                                float khPercent = Random.value;
                                khPercent = khPercent * 100;
                                if (5 <= kuniQty)
                                {
                                    if (khPercent <= 1)
                                    {
                                        //S
                                        kahouRank = 1;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                    else if (1 < khPercent && khPercent <= 30)
                                    {
                                        //A
                                        kahouRank = 2;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                    else if (30 < khPercent)
                                    {
                                        //B
                                        kahouRank = 3;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                }
                                else if (3 <= kuniQty && kuniQty < 5)
                                {
                                    if (khPercent <= 0.5f)
                                    {
                                        //S
                                        kahouRank = 1;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                    else if (0.5f < khPercent && khPercent <= 10)
                                    {
                                        //A
                                        kahouRank = 2;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                    else if (10 < khPercent && khPercent <= 40)
                                    {
                                        //B
                                        kahouRank = 3;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                    else if (40 < khPercent)
                                    {
                                        //C
                                        kahouRank = 4;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                }
                                else if (kuniQty < 3)
                                {
                                    //(A,B,C : 5, 35, 60%)
                                    if (khPercent <= 3)
                                    {
                                        //A
                                        kahouRank = 2;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                    else if (3 < khPercent && khPercent <= 31)
                                    {
                                        //B
                                        kahouRank = 3;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                    else if (31 < khPercent)
                                    {
                                        //C
                                        kahouRank = 3;
                                        kahouName = kahou.getRamdomKahou(kahouType, kahouRank);
                                    }
                                }
                            }
                            else
                            {
                                //shizai
                                shigenType = UnityEngine.Random.Range(1, 5);
                                float sgPercent = Random.value;
                                sgPercent = sgPercent * 100;
                                addQty    = UnityEngine.Random.Range(1, 6);
                                Item item       = new Item();
                                int  shigenRank = 0;                               //下、中、上=1,2,3

                                if (5 <= kuniQty)
                                {
                                    //(上,中,下  40,40, 20%)
                                    if (sgPercent <= 40)
                                    {
                                        shigenRank = 3;
                                    }
                                    else if (40 < sgPercent && sgPercent <= 81)
                                    {
                                        shigenRank = 2;
                                    }
                                    else if (81 < sgPercent)
                                    {
                                        shigenRank = 1;
                                    }
                                    shigenName = item.getRandomShigen(shigenType, shigenRank, addQty);
                                }
                                else if (3 <= kuniQty && kuniQty < 5)
                                {
                                    //(上,中,下  20,50,30%)
                                    if (sgPercent <= 20)
                                    {
                                        shigenRank = 3;
                                    }
                                    else if (20 < sgPercent && sgPercent <= 51)
                                    {
                                        shigenRank = 2;
                                    }
                                    else if (51 < sgPercent)
                                    {
                                        shigenRank = 1;
                                    }
                                    shigenName = item.getRandomShigen(shigenType, shigenRank, addQty);
                                }
                                else if (kuniQty < 3)
                                {
                                    //(上,中,下  5,25,70%)
                                    if (sgPercent <= 5)
                                    {
                                        shigenRank = 3;
                                    }
                                    else if (5 < sgPercent && sgPercent <= 26)
                                    {
                                        shigenRank = 2;
                                    }
                                    else if (26 < sgPercent)
                                    {
                                        shigenRank = 1;
                                    }
                                    shigenName = item.getRandomShigen(shigenType, shigenRank, addQty);
                                }
                            }
                        }


                        //Message
                        PlayerPrefs.SetBool("questDailyFlg29", true);
                        //Extension Mark Handling
                        MainStageController main = new MainStageController();
                        main.questExtension();
                        string OKtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            OKtext = "My lord, successed to threat " + daimyoName;
                        }
                        else
                        {
                            OKtext = "御屋形様、恫喝に成功しましたぞ。\n" + daimyoName + "が";
                        }
                        string addText = "";
                        if (moneyOrItem == 0)
                        {
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                addText = " gave money " + getMoney + "to us.\n";
                            }
                            else
                            {
                                addText = "金" + getMoney + "を送って参りました。\n";
                            }
                        }
                        else
                        {
                            if (kahouOrShizai == 0)
                            {
                                //kahou
                                if (Application.systemLanguage != SystemLanguage.Japanese)
                                {
                                    addText = " gave treasure " + kahouName + "to us.\n";
                                }
                                else
                                {
                                    addText = "家宝、" + kahouName + "を送って参りました。\n";
                                }
                            }
                            else
                            {
                                //shizai+
                                if (Application.systemLanguage != SystemLanguage.Japanese)
                                {
                                    addText = " gave " + addQty + " " + shigenName + " to us.\n";
                                }
                                else
                                {
                                    addText = shigenName + "を" + addQty + "個送って参りました。\n";
                                }
                            }
                        }

                        int maxReduceValue = 5;
                        int nowYukoudo     = gaikou.getMyGaikou(daimyoId);
                        int newYukoudo     = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue);
                        int reduceYukoudo  = nowYukoudo - newYukoudo;
                        GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();
                        closeScript.yukoudo = newYukoudo;
                        string reducceText = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            reducceText = "Friendship decreased " + reduceYukoudo + " point";
                        }
                        else
                        {
                            reducceText = "友好度が" + reduceYukoudo + "下がりますぞ。";
                        }


                        OKtext = OKtext + addText + reducceText;
                        msg.makeMessage(OKtext);

                        downYukouOnIcon(daimyoId, newYukoudo);
                    }
                    else
                    {
                        //Failed
                        audioSources [4].Play();

                        int maxReduceValue = 10;
                        int nowYukoudo     = gaikou.getMyGaikou(daimyoId);
                        int newYukoudo     = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue);
                        int reduceYukoudo  = nowYukoudo - newYukoudo;
                        GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();
                        closeScript.yukoudo = newYukoudo;

                        //Message
                        string NGtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            NGtext = daimyoName + " declined our proposal. \n" + "Friendship decreased " + reduceYukoudo + " point";
                        }
                        else
                        {
                            NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。";
                        }
                        msg.makeMessage(NGtext);

                        downYukouOnIcon(daimyoId, newYukoudo);
                    }

                    PlayerPrefs.Flush();

                    //Back
                    GameObject.Find("return").GetComponent <MenuReturn> ().OnClick();
                }
                else if (name == "DoSyuppeiBtn")
                {
                    reduceMoneyHyourou();

                    //Syuppei Check
                    float percent = Random.value;
                    percent = percent * 100;
                    if (percent <= kyoutouRatio)
                    {
                        audioSources [3].Play();

                        //Success
                        //Track
                        int TrackSyuppeiNo = PlayerPrefs.GetInt("TrackSyuppeiNo", 0);
                        TrackSyuppeiNo = TrackSyuppeiNo + 1;
                        PlayerPrefs.SetInt("TrackSyuppeiNo", TrackSyuppeiNo);


                        //Success
                        addUsedBusyo(busyoId);

                        //Process
                        string     path   = "Prefabs/Map/Gunzei";
                        GameObject Gunzei = Instantiate(Resources.Load(path)) as GameObject;
                        Gunzei.transform.SetParent(GameObject.Find("Panel").transform);
                        Gunzei.transform.localScale = new Vector2(1, 1);

                        //Location
                        KuniInfo kuni      = new KuniInfo();
                        int      srcX      = kuni.getKuniLocationX(srcKuniId);
                        int      srcY      = kuni.getKuniLocationY(srcKuniId);
                        int      dstX      = kuni.getKuniLocationX(targetKuniId);
                        int      dstY      = kuni.getKuniLocationY(targetKuniId);
                        string   direction = "";
                        Gunzei   gunzei    = new Gunzei();

                        if (srcX < dstX)
                        {
                            Gunzei.transform.localScale = new Vector2(1, 1);
                            direction = "right";
                        }
                        else
                        {
                            Gunzei.transform.localScale = new Vector2(-1, 1);
                            direction = "left";
                            Gunzei.GetComponent <Gunzei> ().leftFlg = true;
                        }

                        int           aveX            = (srcX + dstX) / 2;
                        int           aveY            = (srcY + dstY) / 2;
                        RectTransform GunzeiTransform = Gunzei.GetComponent <RectTransform> ();
                        GunzeiTransform.anchoredPosition = new Vector3(aveX, aveY, 0);

                        string key = srcKuniId.ToString() + "-" + targetKuniId.ToString();
                        Gunzei.GetComponent <Gunzei> ().key           = key;
                        Gunzei.GetComponent <Gunzei> ().srcKuni       = srcKuniId;
                        Gunzei.GetComponent <Gunzei> ().srcDaimyoId   = srcDaimyoId;
                        Gunzei.GetComponent <Gunzei> ().srcDaimyoName = srcDaimyoName;
                        Gunzei.GetComponent <Gunzei> ().dstKuni       = targetKuniId;
                        Gunzei.GetComponent <Gunzei> ().dstDaimyoId   = targetDaimyoId;
                        Gunzei.GetComponent <Gunzei> ().dstDaimyoName = targetDaimyoName;
                        int myHei = gunzei.heiryokuCalc(srcKuniId);

                        //random myHei from -50%-myHeis
                        List <float> randomPercent = new List <float> {
                            0.8f, 0.9f, 1.0f
                        };
                        int   rmd = UnityEngine.Random.Range(0, randomPercent.Count);
                        float per = randomPercent [rmd];
                        myHei = Mathf.CeilToInt(myHei * per);

                        Gunzei.GetComponent <Gunzei> ().myHei = myHei;
                        Gunzei.name = key;

                        //Engun from Doumei
                        Doumei        doumei           = new Doumei();
                        List <string> doumeiDaimyoList = doumei.doumeiExistCheck(targetDaimyoId, srcDaimyoId.ToString());
                        bool          dstEngunFlg      = false;
                        string        dstEngunDaimyoId = "";             //2:3:5
                        string        dstEngunHei      = "";
                        string        dstEngunSts      = "";             //BusyoId-BusyoLv-ButaiQty-ButaiLv:
                        int           totalEngunHei    = 0;

                        string        seiryoku       = PlayerPrefs.GetString("seiryoku");
                        char[]        delimiterChars = { ',' };
                        List <string> seiryokuList   = new List <string>();
                        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));


                        //Trace Check
                        List <string> okDaimyoList = new List <string> ();
                        List <string> checkList    = new List <string> ();
                        okDaimyoList = doumei.traceNeighborDaimyo(targetKuniId, targetDaimyoId, doumeiDaimyoList, seiryokuList, checkList, okDaimyoList);

                        if (okDaimyoList.Count != 0)
                        {
                            //Doumei & Neghbor Daimyo Exist

                            for (int k = 0; k < okDaimyoList.Count; k++)
                            {
                                string engunDaimyo = okDaimyoList[k];
                                int    yukoudo     = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), targetDaimyoId);

                                //engun check
                                MainEventHandler mainEvent = new MainEventHandler();
                                dstEngunFlg = mainEvent.CheckByProbability(yukoudo);

                                if (dstEngunFlg)
                                {
                                    //Engun OK
                                    dstEngunFlg = true;
                                    if (dstEngunDaimyoId != null && dstEngunDaimyoId != "")
                                    {
                                        dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo;
                                        string tempEngunSts = engunDaimyo + "-" + mainEvent.getEngunSts(engunDaimyo);
                                        int    tempEngunHei = mainEvent.getEngunHei(tempEngunSts);
                                        dstEngunHei   = dstEngunHei + ":" + tempEngunHei.ToString();
                                        totalEngunHei = totalEngunHei + tempEngunHei;
                                        dstEngunSts   = dstEngunSts + ":" + tempEngunSts;
                                    }
                                    else
                                    {
                                        dstEngunDaimyoId = engunDaimyo;
                                        string tempEngunSts = engunDaimyo + "-" + mainEvent.getEngunSts(engunDaimyo);
                                        int    tempEngunHei = mainEvent.getEngunHei(tempEngunSts);
                                        dstEngunHei   = tempEngunHei.ToString();
                                        totalEngunHei = tempEngunHei;
                                        dstEngunSts   = tempEngunSts;
                                    }
                                }
                            }
                            Gunzei.GetComponent <Gunzei> ().dstEngunFlg      = dstEngunFlg;
                            Gunzei.GetComponent <Gunzei> ().dstEngunDaimyoId = dstEngunDaimyoId;
                            Gunzei.GetComponent <Gunzei> ().dstEngunHei      = dstEngunHei;
                            Gunzei.GetComponent <Gunzei> ().dstEngunSts      = dstEngunSts;
                        }

                        //Set Value
                        //CreateTime,srcDaimyoId,dstDaimyoId,srcDaimyoName,dstDaimyoName, srcHei,locationX,locationY,left or right, engunFlg, engunDaimyoId(A:B:C), dstEngunHei(1000:2000:3000), dstEngunSts
                        string keyValue   = "";
                        string createTime = System.DateTime.Now.ToString();
                        keyValue = createTime + "," + srcDaimyoId + "," + targetDaimyoId + "," + srcDaimyoName + "," + targetDaimyoName + "," + myHei + "," + aveX + "," + aveY + "," + direction + "," + dstEngunFlg + "," + dstEngunDaimyoId + "," + dstEngunHei + "," + dstEngunSts;
                        PlayerPrefs.SetString(key, keyValue);
                        string keyHistory = PlayerPrefs.GetString("keyHistory");
                        if (keyHistory == null || keyHistory == "")
                        {
                            keyHistory = key;
                        }
                        else
                        {
                            keyHistory = keyHistory + "," + key;
                        }
                        PlayerPrefs.SetString("keyHistory", keyHistory);


                        //Msg
                        string OKtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            OKtext = "Lord " + daimyoName + " is sending " + myHei + " soldiers to " + kuniName;
                        }
                        else
                        {
                            OKtext = daimyoName + "殿が" + kuniName + "攻めのため、\n" + myHei + "人の兵を起こしましたぞ。";
                        }

                        string AddText = "";
                        if (totalEngunHei != 0)
                        {
                            if (Application.systemLanguage != SystemLanguage.Japanese)
                            {
                                AddText = targetDaimyoName + " has a support army " + totalEngunHei + " soldiers";
                            }
                            else
                            {
                                AddText = targetDaimyoName + "に" + totalEngunHei + "の援軍がいるようです。";
                            }

                            OKtext = OKtext + "\n" + AddText;
                        }
                        msg.makeMessage(OKtext);
                    }
                    else
                    {
                        //Fail
                        audioSources [4].Play();

                        int maxReduceValue = 3;
                        int nowYukoudo     = gaikou.getMyGaikou(daimyoId);
                        int newYukoudo     = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue);
                        int reduceYukoudo  = nowYukoudo - newYukoudo;
                        GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString();
                        closeScript.yukoudo = newYukoudo;

                        string NGtext = "";
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            NGtext = daimyoName + " declined our proposal. \n" + "Friendship decreased " + reduceYukoudo + " point";
                        }
                        else
                        {
                            NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。";
                        }
                        msg.makeMessage(NGtext);

                        downYukouOnIcon(daimyoId, newYukoudo);
                    }

                    PlayerPrefs.Flush();

                    //Back
                    GameObject.Find("return").GetComponent <MenuReturn> ().OnClick();
                }
            }
            else
            {
                //Message
                audioSources [4].Play();

                string NGtext = msg.getMessage(6);
                msg.makeMessage(NGtext);
            }
        }
        else
        {
            //Message
            audioSources [4].Play();

            //string NGtext = msg.getMessage(7);
            //msg.makeMessage (NGtext);
            msg.hyourouMovieMessage();
        }
    }
コード例 #28
0
    public void OnClick()
    {
        Daimyo daimyo = new Daimyo();

        audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        if (name == "YesButton")
        {
            //Hyourou
            int hyourou    = PlayerPrefs.GetInt("hyourou");
            int newHyourou = hyourou - 30;
            PlayerPrefs.SetInt("hyourou", newHyourou);
            GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString();

            //Soubuji Flg
            PlayerPrefs.SetBool("soubujireiFlg", true);

            //Listup
            string        seiryoku       = PlayerPrefs.GetString("seiryoku");
            List <string> seiryokuList   = new List <string> ();
            char[]        delimiterChars = { ',' };
            seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

            MainStageController script = GameObject.Find("GameController").GetComponent <MainStageController> ();
            int myKuniQty = script.myKuniQty;
            int myDaimyo  = script.myDaimyo;

            List <int> daimyoIdList      = new List <int> ();
            List <int> mainKuniIdList    = new List <int> ();
            List <int> kuniQtyByDaimyoId = new List <int> ()
            {
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0
            };
            for (int i = 0; i < seiryokuList.Count; i++)
            {
                int daimyoId = int.Parse(seiryokuList [i]);
                if (daimyoId != myDaimyo)
                {
                    int kuniId = i + 1;

                    if (!daimyoIdList.Contains(daimyoId))
                    {
                        daimyoIdList.Add(daimyoId);
                        mainKuniIdList.Add(kuniId);
                    }
                    kuniQtyByDaimyoId [daimyoId - 1] = kuniQtyByDaimyoId [daimyoId - 1] + 1;
                }
            }


            //Do Soubujirei
            List <string> newSeiryokuList = new List <string> (seiryokuList);
            string        clearedKuni     = PlayerPrefs.GetString("clearedKuni");
            KuniInfo      kuni            = new KuniInfo();
            GameObject    kuniIconView    = GameObject.Find("KuniIconView").gameObject;
            GameObject    panel           = GameObject.Find("Panel").gameObject;
            GameObject    kuniMap         = GameObject.Find("KuniMap").gameObject;
            Doumei        doumei          = new Doumei();
            bool          allClearedFlg   = true;

            for (int k = 0; k < daimyoIdList.Count; k++)
            {
                int    daimyoId   = daimyoIdList [k];
                string daimyoName = daimyo.getName(daimyoId);
                int    kuniQty    = 0;
                kuniQty = kuniQtyByDaimyoId [daimyoId - 1];

                float ratio = 0;
                ratio = (100 - ((float)kuniQty / (float)myKuniQty * 500));

                if (ratio < 0)
                {
                    ratio = 0;
                }
                if (testMode)
                {
                    ratio = 100;
                }


                //Debug.Log (daimyoName+":"+kuniQty +"/"+myKuniQty+"="+ratio);
                float percent = UnityEngine.Random.value;
                percent = percent * 100;
                if (percent <= ratio)
                {
                    //OK
                    for (int j = 0; j < seiryokuList.Count; j++)
                    {
                        if (seiryokuList [j] == daimyoId.ToString())
                        {
                            int kuniId = j + 1;

                            //1.update seiryoku
                            newSeiryokuList [kuniId - 1] = myDaimyo.ToString();

                            //2.update cleaered kuni & kuni1,2,3
                            clearedKuni = clearedKuni + "," + kuniId.ToString();
                            string tmp = "kuni" + kuniId.ToString();
                            PlayerPrefs.SetString(tmp, "1,2,3,4,5,6,7,8,9,10");

                            //3.update openkuni
                            kuni.registerOpenKuni(kuniId);

                            //4.cyouhou delete
                            //Cyouhou Delete
                            string cyouhouTmp = "cyouhou" + kuniId;
                            if (PlayerPrefs.HasKey(cyouhouTmp))
                            {
                                PlayerPrefs.DeleteKey(cyouhouTmp);
                                string        cyouhou     = PlayerPrefs.GetString("cyouhou");
                                List <string> cyouhouList = new List <string> ();
                                if (cyouhou != null && cyouhou != "")
                                {
                                    if (cyouhou.Contains(","))
                                    {
                                        cyouhouList = new List <string> (cyouhou.Split(delimiterChars));
                                    }
                                    else
                                    {
                                        cyouhouList.Add(cyouhou);
                                    }
                                }
                                cyouhouList.Remove(kuniId.ToString());
                                string newCyouhou = "";
                                for (int a = 0; a < cyouhouList.Count; a++)
                                {
                                    if (a == 0)
                                    {
                                        newCyouhou = cyouhouList [a];
                                    }
                                    else
                                    {
                                        newCyouhou = newCyouhou + "," + cyouhouList [a];
                                    }
                                }
                                PlayerPrefs.SetString("cyouhou", newCyouhou);
                            }

                            //5. naisei
                            string naiseiTmp = "naisei" + kuniId;
                            if (!PlayerPrefs.HasKey(naiseiTmp))
                            {
                                PlayerPrefs.SetString(naiseiTmp, "1,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0");
                            }

                            //Icon Change
                            IconMapValueUpdate(kuniId, myDaimyo, kuniIconView, kuniMap, myKuniQty);
                        }
                    }
                    //Gunzei Check
                    foreach (GameObject GunzeiObj in  GameObject.FindGameObjectsWithTag("Gunzei"))
                    {
                        int gunzeiSrcDaimyoId = GunzeiObj.GetComponent <Gunzei> ().srcDaimyoId;
                        if (daimyoId == gunzeiSrcDaimyoId)
                        {
                            deleteGunzei(GunzeiObj);
                        }
                    }

                    //Message
                    int msgKuniId = mainKuniIdList [k];
                    okNgMessage(true, msgKuniId, kuniIconView, panel, daimyoName);
                }
                else
                {
                    //NG

                    allClearedFlg = false;

                    //Yukoudo 0
                    string tempGaikou = "gaikou" + daimyoId;
                    PlayerPrefs.SetInt(tempGaikou, 0);

                    //doumei clear
                    bool doumeiFlg = doumei.myDoumeiExistCheck(daimyoId);
                    if (doumeiFlg)
                    {
                        doumei.deleteDoumeiMyDaimyo(myDaimyo.ToString(), daimyoId.ToString());
                    }

                    //Icon color & value
                    kuni.deleteDoumeiKuniIcon(daimyoId);

                    //Message
                    int msgKuniId = mainKuniIdList [k];
                    okNgMessage(false, msgKuniId, kuniIconView, panel, daimyoName);
                }
            }

            string newSeiryoku = "";
            for (int l = 0; l < newSeiryokuList.Count; l++)
            {
                if (l == 0)
                {
                    newSeiryoku = newSeiryokuList [l];
                }
                else
                {
                    newSeiryoku = newSeiryoku + "," + newSeiryokuList [l];
                }
            }
            PlayerPrefs.SetString("seiryoku", newSeiryoku);
            PlayerPrefs.SetString("clearedKuni", clearedKuni);
            PlayerPrefs.Flush();


            //Update OpenKuniIcon
            kuni.updateOpenKuni(myDaimyo, newSeiryoku);

            //Close
            board.transform.FindChild("close").GetComponent <CloseBoard> ().onClick();
            soubujiFlgOn(kuniIconView);

            if (allClearedFlg)
            {
                GameObject.Find("GameController").GetComponent <MainStageController> ().gameClearFlg = true;
                PlayerPrefs.SetBool("gameClearFlg", true);
                PlayerPrefs.Flush();
            }
        }
        else
        {
            audioSources [1].Play();
        }

        Destroy(back.gameObject);
        Destroy(confirm.gameObject);
    }