Beispiel #1
0
    // Use this for initialization
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        audioSources [2].Play();

        //Change Color
        Color Select   = new Color(76f / 255f, 50f / 255f, 18f / 255f, 80f / 255f);
        Color unSelect = new Color(255f / 255f, 255f / 255f, 255f / 255f, 100f / 255f);


        foreach (Transform obj in Content.transform)
        {
            obj.GetComponent <Image>().color = unSelect;
        }
        GetComponent <Image> ().color = Select;

        //Seikoudo
        //成功確率 = (((友好度/10) * 知略/50)*国力差)*((100-他大名間友好度)/100)
        if (Btn.name == "DoKyoutouBtn")
        {
            float tempResult = (myYukoudo / 10 * chiryaku / 5) * kuniDiff;
            float tempCalc3  = (100 - theirYukoudo);
            float tempCalc4  = tempCalc3 / 100;
            float ratio      = (tempResult * tempCalc4);

            int ratioInt = 0;
            if (ratio > 100)
            {
                ratioInt = 100;
            }
            else
            {
                ratioInt = (int)ratio;
            }

            GameObject.Find("KyoutouRatio").transform.FindChild("Value").GetComponent <Text> ().text = ratioInt.ToString() + "%";
            GameObject.Find("DoKyoutouBtn").GetComponent <DoGaikou> ().kyoutouRatio = ratioInt;
            GameObject.Find("DoKyoutouBtn").GetComponent <DoGaikou> ().myYukoudo    = myYukoudo;
            GameObject.Find("DoKyoutouBtn").GetComponent <DoGaikou> ().kuniName     = kuniName;
            GameObject.Find("DoKyoutouBtn").GetComponent <DoGaikou> ().targetKuniId = targetKuniId;
        }
        else if (Btn.name == "DoSyuppeiBtn")
        {
            //Ratio = (((My Yukoudo/10) *DFC/50)*Diff)*((100-their Yukoudo)/100)
            float tempResult = (myYukoudo / 10 * chiryaku / 5) * kuniDiff;
            float tempCalc3  = (100 - theirYukoudo);
            float tempCalc4  = tempCalc3 / 100;
            float ratio      = (tempResult * tempCalc4);

            int ratioInt = 0;
            if (ratio > 100)
            {
                ratioInt = 100;
            }
            else
            {
                ratioInt = (int)ratio;
            }

            GameObject.Find("KyoutouRatio").transform.FindChild("Value").GetComponent <Text> ().text = ratioInt.ToString() + "%";
            DoGaikou DoSyuppeiBtnScript = GameObject.Find("DoSyuppeiBtn").GetComponent <DoGaikou>();
            DoSyuppeiBtnScript.kyoutouRatio     = ratioInt;
            DoSyuppeiBtnScript.myYukoudo        = myYukoudo;
            DoSyuppeiBtnScript.kuniName         = kuniName;
            DoSyuppeiBtnScript.targetKuniId     = targetKuniId;
            DoSyuppeiBtnScript.srcKuniId        = srcKuniId;
            DoSyuppeiBtnScript.srcDaimyoId      = srcDaimyoId;
            DoSyuppeiBtnScript.srcDaimyoName    = srcDaimyoName;
            DoSyuppeiBtnScript.targetDaimyoId   = targetDaimyoId;
            DoSyuppeiBtnScript.targetDaimyoName = targetDaimyoName;
        }
    }
Beispiel #2
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        //Check
        if (GameObject.Find(key))
        {
            //OK

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

            //1.My Kuni is the biggiest ... 30%
            //2.My Yukoudo ... 50%
            //3.Other Yukoudo ... 20%
            float ratio = 0;

            //1
            bool myKuniQtyIsBiggestFlg = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQtyIsBiggestFlg;
            if (myKuniQtyIsBiggestFlg)
            {
                ratio = 30;
            }

            //2
            Gaikou gaikou        = new Gaikou();
            int    myGaikouValue = gaikou.getMyGaikou(engunDaimyoId);
            ratio = ratio + (float)myGaikouValue / 2;

            //3
            int otherGaikouValue = gaikou.getOtherGaikouValue(engunDaimyoId, dfcDaimyoId);
            ratio = ratio + (float)otherGaikouValue / 5;

            float percent = UnityEngine.Random.value;
            percent = percent * 100;
            if (percent <= ratio)
            {
                //OK
                audioSources [3].Play();

                MainEventHandler mEvent   = new MainEventHandler();
                string           engunSts = engunDaimyoId + "-" + mEvent.getEngunSts(engunDaimyoId.ToString());
                int engunHei = mEvent.getEngunHei(engunSts);

                GameObject gunzei = GameObject.Find(key).gameObject;
                string     tmp    = gunzei.GetComponent <Gunzei>().dstEngunSts;

                //Set Param

                string        keyValue       = PlayerPrefs.GetString(key);
                List <string> keyValueList   = new List <string> ();
                char[]        delimiterChars = { ',' };
                if (keyValue.Contains(","))
                {
                    keyValueList = new List <string> (keyValue.Split(delimiterChars));
                }
                else
                {
                    keyValueList.Add(keyValue);
                }

                gunzei.GetComponent <Gunzei> ().dstEngunFlg = true;
                if (tmp != null && tmp != "")
                {
                    string newDstEngunSts = tmp + ":" + engunSts;
                    gunzei.GetComponent <Gunzei> ().dstEngunSts = newDstEngunSts;

                    string tmpEngunHei    = gunzei.GetComponent <Gunzei>().dstEngunHei;
                    string newDstEngunHei = tmpEngunHei + ":" + engunHei.ToString();
                    gunzei.GetComponent <Gunzei> ().dstEngunHei = newDstEngunHei;

                    string tmpDstEngunDaimyoId = gunzei.GetComponent <Gunzei>().dstEngunDaimyoId;
                    string newDstEngunDaimyoId = tmpDstEngunDaimyoId.ToString() + ":" + engunDaimyoId.ToString();
                    gunzei.GetComponent <Gunzei> ().dstEngunDaimyoId = newDstEngunDaimyoId;

                    //Set Data
                    keyValue = keyValueList[0] + "," + keyValueList[1] + "," + keyValueList[2] + "," + keyValueList[3] + "," + keyValueList[4] + "," + keyValueList[5] + "," + keyValueList[6] + "," + keyValueList[7] + "," + keyValueList[8] + "," + keyValueList[9] + "," + newDstEngunDaimyoId + "," + newDstEngunHei + "," + newDstEngunSts;
                }
                else
                {
                    gunzei.GetComponent <Gunzei> ().dstEngunSts      = engunSts;
                    gunzei.GetComponent <Gunzei> ().dstEngunHei      = engunHei.ToString();
                    gunzei.GetComponent <Gunzei> ().dstEngunDaimyoId = engunDaimyoId.ToString();

                    //Set Data
                    keyValue = keyValueList[0] + "," + keyValueList[1] + "," + keyValueList[2] + "," + keyValueList[3] + "," + keyValueList[4] + "," + keyValueList[5] + "," + keyValueList[6] + "," + keyValueList[7] + "," + keyValueList[8] + "," + true + "," + engunDaimyoId.ToString() + "," + engunHei.ToString() + "," + engunSts;
                }
                PlayerPrefs.SetString(key, keyValue);
                PlayerPrefs.Flush();


                //Return & Message
                GameObject.Find("bakuhuReturn").GetComponent <BakuhuMenuReturn>().OnClick();
                Message msg    = new Message();
                string  OKtext = "";
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    OKtext = engunDaimyoName + " sent " + engunHei.ToString() + " soldiers to \n" + kuniName + " to support.";
                }
                else
                {
                    OKtext = engunDaimyoName + "殿が" + engunHei.ToString() + "の兵を\n" + kuniName + "救援に差し向けましたぞ。";
                }
                msg.makeMessageOnBoard(OKtext);
            }
            else
            {
                //NG
                audioSources [4].Play();

                GameObject.Find("bakuhuReturn").GetComponent <BakuhuMenuReturn>().OnClick();
                int     newYukoudo   = gaikou.downMyGaikou(engunDaimyoId, myGaikouValue, 15);
                int     reducedValue = myGaikouValue - newYukoudo;
                Message msg          = new Message();
                string  NGtext       = "";
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    NGtext = engunDaimyoName + " declined our defence order. \n Friendship decreased " + reducedValue + " point.";
                }
                else
                {
                    NGtext = "援軍の儀、" + engunDaimyoName + "殿に断られ申した。\n当家との友好度が" + reducedValue + "下がります。";
                }
                DoGaikou doGaikou = new DoGaikou();
                doGaikou.downYukouOnIcon(engunDaimyoId, newYukoudo);
                msg.makeMessageOnBoard(NGtext);
            }
        }
        else
        {
            //NG
            audioSources [4].Play();
            GameObject.Find("bakuhuReturn").GetComponent <BakuhuMenuReturn>().OnClick();
            Message msg    = new Message();
            string  NGtext = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                NGtext = "My lord, it was too late. Battle already finished.";
            }
            else
            {
                NGtext = "御屋形様、既に勝敗は決してしまったようですぞ。";
            }
            msg.makeMessageOnBoard(NGtext);
            Destroy(slot.gameObject);
        }
    }
Beispiel #3
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);
            }
        }
    }
Beispiel #4
0
    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));
        }
    }
Beispiel #5
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);
    }