예제 #1
0
	public void wasAttacked(string key, int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId, bool dstEngunFlg, string dstEngunDaimyoId, string dstEngunSts){

		//In the case of My Damyo was Attacked

		//For Dramatic Enemy Creation
		GameObject kuniView = GameObject.Find("KuniIconView");
		SendParam param = kuniView.transform.FindChild(srcKuni.ToString()).GetComponent<SendParam>();
		int busyoQty = param.busyoQty;
		int busyoLv = param.busyoLv;
		int butaiQty = param.butaiQty;
		int butaiLv = param.butaiLv;

		//Dummy
		PlayerPrefs.SetInt("activeStageId", 0);
		PlayerPrefs.SetInt("activeStageMoney", busyoQty*busyoLv*100);
		PlayerPrefs.SetInt("activeStageExp", busyoQty*busyoLv*10);
		PlayerPrefs.SetString("activeItemType", "");
		PlayerPrefs.SetInt("activeItemId", 0);
		PlayerPrefs.SetFloat("activeItemRatio", 0);
		PlayerPrefs.SetInt("activeItemQty", 0);
		
		//Actual
		PlayerPrefs.SetInt("activeKuniId", dstKuni);
		PlayerPrefs.SetInt("activeDaimyoId", srcDaimyoId);
		PlayerPrefs.SetInt ("activeBusyoQty", busyoQty);
		PlayerPrefs.SetInt ("activeBusyoLv", busyoLv);
		PlayerPrefs.SetInt ("activeButaiQty", butaiQty);
		PlayerPrefs.SetInt ("activeButaiLv", butaiLv);

		//Passive only
		PlayerPrefs.SetBool ("isAttackedFlg", true);
		PlayerPrefs.SetString("activeKey", key);
		PlayerPrefs.SetInt("activeSrcDaimyoId", srcDaimyoId);
		PlayerPrefs.SetInt("activeDstDaimyoId", dstDaimyoId);

		//Engun
		if (dstEngunFlg) {

			PlayerPrefs.SetString("playerEngunList", dstEngunSts);
			PlayerPrefs.DeleteKey("enemyEngunList");

		} else {
			PlayerPrefs.DeleteKey("playerEngunList");
			PlayerPrefs.DeleteKey("enemyEngunList");
		}

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

		PlayerPrefs.Flush();
		Application.LoadLevel("kassen");


	}
예제 #2
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));
        }
    }
예제 #3
0
	public void makeInitData () {

		/*******************************/
		/***** MainStageController *****/
		/*******************************/

		//Basic status
		System.DateTime now = System.DateTime.Now;
		PlayerPrefs.SetString ("lasttime", now.ToString ());
		PlayerPrefs.SetInt ("kuniLv",1);
		PlayerPrefs.SetInt ("kuniExp",0);
		PlayerPrefs.SetInt ("money",10000);
		PlayerPrefs.SetInt ("busyoDama",0);
		PlayerPrefs.SetInt ("hyourouMax",100);
		PlayerPrefs.SetInt ("hyourou",100);
		PlayerPrefs.SetInt ("myBusyoQty",1);

		//Busyo
		int myDaimyo = 1; //Oda Nobunaga
		PlayerPrefs.SetInt("myDaimyo",myDaimyo);
		PlayerPrefs.SetInt("myDaimyoBusyo",19);

		//Open Kuni
		PlayerPrefs.SetString("openKuni","1,2,3,4");
		PlayerPrefs.SetString("kuni1","1,2,3,4,5,6,7,8,9,10"); //Owari
		PlayerPrefs.SetString ("clearedKuni","1");

		//Seiryoku
		PlayerPrefs.SetString ("seiryoku","1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46");

		//Year & Season
		string newYearSeason = "1560,1";
		PlayerPrefs.SetString ("yearSeason", newYearSeason);

		/*******************************/
		/*****     JinkeiScene     *****/
		/*******************************/
		PlayerPrefs.SetInt ("jinkei",1);
		PlayerPrefs.SetString ("myBusyo","19");
		PlayerPrefs.SetInt ("jinkeiLimit",3);
		PlayerPrefs.SetInt ("map12", 19);
		PlayerPrefs.SetInt ("1map12", 19);
		PlayerPrefs.SetInt ("jinkeiBusyoQty", 1);
		PlayerPrefs.SetInt ("jinkeiAveLv", 1);
		PlayerPrefs.SetInt ("jinkeiAveChLv", 1);
		PlayerPrefs.SetInt ("jinkeiHeiryoku", 1100);


		/*******************************/
		/*****     Busyo Scene     *****/
		/*******************************/
		PlayerPrefs.SetInt ("stockLimit",10);
		PlayerPrefs.SetInt ("19",1);
		PlayerPrefs.SetString ("hei19","TP:1:1:10");
		PlayerPrefs.SetInt ("senpou19",1);
		PlayerPrefs.SetString ("koudou19","1");
		PlayerPrefs.SetString ("kahou19","0,0,0,0,0,0,0,0");
		PlayerPrefs.SetInt ("exp19",0);


		/*******************************/
		/*****    Cyouhei Scene    *****/
		/*******************************/
		PlayerPrefs.SetString ("cyouheiYR","0,0,0");
		PlayerPrefs.SetString ("cyouheiKB","0,0,0");
		PlayerPrefs.SetString ("cyouheiTP","0,0,0");
		PlayerPrefs.SetString ("cyouheiYM","0,0,0");
		PlayerPrefs.SetString ("kanjyo","0,0,0");


		/*******************************/
		/*****    Naisei Scene    *****/
		/*******************************/
		PlayerPrefs.SetString("naisei1","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");
		PlayerPrefs.SetString("naisei2","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");
		PlayerPrefs.SetString("naisei3","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");
		PlayerPrefs.SetString("naisei4","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");

		/*******************************/
		/*****     Gaikou Value    *****/
		/*******************************/
		Gaikou gaikou = new Gaikou ();
		for(int l=2; l<47; l++){
			int value = gaikou.getGaikouValue(myDaimyo,l);
			string temp = "gaikou" + l.ToString();
			PlayerPrefs.SetInt (temp, value);
		}

		/*******************************/
		/*****       Doumei        *****/
		/*******************************/
		PlayerPrefs.SetString ("doumei2","9");
		PlayerPrefs.SetString ("doumei9","2");
		PlayerPrefs.SetString ("doumei3","8,19");
		PlayerPrefs.SetString ("doumei8","3,19,26");
		PlayerPrefs.SetString ("doumei19","3,8,26");
		PlayerPrefs.SetString ("doumei26","8,19");
		PlayerPrefs.SetString ("doumei38","36,37,39");
		PlayerPrefs.SetString ("doumei36","38");
		PlayerPrefs.SetString ("doumei37","38");
		PlayerPrefs.SetString ("doumei39","38");
		PlayerPrefs.SetString ("doumei5","6");
		PlayerPrefs.SetString ("doumei6","5");

		/*******************************/
		/*****      For Test       *****/
		/*******************************/
		PlayerPrefs.SetInt ("money",9999999);
		PlayerPrefs.SetInt ("shinobiGe",99);
		PlayerPrefs.SetInt ("shinobiCyu",99);
		PlayerPrefs.SetInt ("shinobiJyo",99);


		/*******************************/
		/***** Init Common Process *****/
		/*******************************/
		//Change initDataFlg
		PlayerPrefs.SetBool ("initDataFlg",true);
		PlayerPrefs.Flush();
	}	
예제 #4
0
    public void makeInitData()
    {
        //Check
        if (!PlayerPrefs.HasKey("lasttime"))
        {
            initDataInt = PlayerPrefs.GetInt("initDataInt");
            if (initDataInt == 0)
            {
                /*******************************/
                /***** MainStageController *****/
                /*******************************/

                //Basic status
                System.DateTime now = System.DateTime.Now;
                PlayerPrefs.SetString("lasttime", now.ToString());
                PlayerPrefs.SetInt("kuniLv", 1);
                PlayerPrefs.SetInt("kuniExp", 0);
                PlayerPrefs.SetInt("money", 10000);
                PlayerPrefs.SetInt("busyoDama", 0);
                PlayerPrefs.SetInt("hyourouMax", 100);
                PlayerPrefs.SetInt("hyourou", 100);
                PlayerPrefs.SetInt("myBusyoQty", 1);
                PlayerPrefs.SetInt("syogunDaimyoId", 14);

                //Busyo
                int myDaimyo = 1;         //Oda Nobunaga
                PlayerPrefs.SetInt("myDaimyo", myDaimyo);
                PlayerPrefs.SetInt("myDaimyoBusyo", 19);

                //Open Kuni
                PlayerPrefs.SetString("openKuni", "1,2,3,4");
                PlayerPrefs.SetString("kuni1", "1,2,3,4,5,6,7,8,9,10");        //Owari
                PlayerPrefs.SetString("clearedKuni", "1");

                //Seiryoku
                PlayerPrefs.SetString("seiryoku", "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46");

                //Year & Season
                string newYearSeason = "1560,1";
                PlayerPrefs.SetString("yearSeason", newYearSeason);

                /*******************************/
                /*****     JinkeiScene     *****/
                /*******************************/
                PlayerPrefs.SetInt("jinkei", 1);
                PlayerPrefs.SetString("myBusyo", "19");
                PlayerPrefs.SetInt("jinkeiLimit", 3);
                PlayerPrefs.SetInt("map12", 19);
                PlayerPrefs.SetInt("1map12", 19);
                PlayerPrefs.SetInt("jinkeiBusyoQty", 1);
                PlayerPrefs.SetInt("jinkeiAveLv", 1);
                PlayerPrefs.SetInt("jinkeiAveChLv", 1);
                PlayerPrefs.SetInt("jinkeiHeiryoku", 1100);
                PlayerPrefs.SetInt("soudaisyo1", 19);


                /*******************************/
                /*****     Busyo Scene     *****/
                /*******************************/
                PlayerPrefs.SetInt("stockLimit", 10);
                PlayerPrefs.SetInt("19", 1);
                PlayerPrefs.SetString("hei19", "TP:1:1:1");
                PlayerPrefs.SetInt("senpou19", 1);
                PlayerPrefs.SetInt("saku19", 1);
                PlayerPrefs.SetString("kahou19", "0,0,0,0,0,0,0,0");
                PlayerPrefs.SetInt("exp19", 0);


                /*******************************/
                /*****    Cyouhei Scene    *****/
                /*******************************/
                PlayerPrefs.SetString("cyouheiYR", "0,0,0");
                PlayerPrefs.SetString("cyouheiKB", "0,0,0");
                PlayerPrefs.SetString("cyouheiTP", "0,0,0");
                PlayerPrefs.SetString("cyouheiYM", "0,0,0");
                PlayerPrefs.SetString("kanjyo", "0,0,0");


                /*******************************/
                /*****    Naisei Scene    *****/
                /*******************************/
                PlayerPrefs.SetString("naisei1", "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");
                PlayerPrefs.SetString("naisei2", "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");
                PlayerPrefs.SetString("naisei3", "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");
                PlayerPrefs.SetString("naisei4", "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");
                PlayerPrefs.SetInt("transferTP", 0);
                PlayerPrefs.SetInt("transferKB", 0);
                PlayerPrefs.SetInt("transferSNB", 0);


                /*******************************/
                /*****        Item         *****/
                /*******************************/
                PlayerPrefs.SetString("gokuiItem", "0,0,0,0,0");
                PlayerPrefs.SetString("kengouItem", "0,0,0,0,0,0,0,0,0,0");
                PlayerPrefs.SetString("nanbanItem", "0,0,0");
                PlayerPrefs.SetString("cyoutei", "0,0,0");
                PlayerPrefs.SetString("koueki", "0,0,0");


                /*******************************/
                /*****     Gaikou Value    *****/
                /*******************************/
                Gaikou gaikou = new Gaikou();
                for (int l = 2; l < 47; l++)
                {
                    int    value = gaikou.getGaikouValue(myDaimyo, l);
                    string temp  = "gaikou" + l.ToString();
                    PlayerPrefs.SetInt(temp, value);
                }

                /*******************************/
                /*****       Doumei        *****/
                /*******************************/
                PlayerPrefs.SetString("doumei2", "9");
                PlayerPrefs.SetString("doumei9", "2");
                PlayerPrefs.SetString("doumei3", "8,19");
                PlayerPrefs.SetString("doumei8", "3,19,26");
                PlayerPrefs.SetString("doumei19", "3,8,26");
                PlayerPrefs.SetString("doumei26", "8,19");
                PlayerPrefs.SetString("doumei38", "36,37,39");
                PlayerPrefs.SetString("doumei36", "38");
                PlayerPrefs.SetString("doumei37", "38");
                PlayerPrefs.SetString("doumei39", "38");
                PlayerPrefs.SetString("doumei5", "6");
                PlayerPrefs.SetString("doumei6", "5");

                /*******************************/
                /*****       Tutorial      *****/
                /*******************************/
                PlayerPrefs.SetInt("tutorialId", 1);

                /*******************************/
                /***** Init Common Process *****/
                /*******************************/
                //Change initDataFlg
                PlayerPrefs.SetBool("initDataFlg", true);
                PlayerPrefs.SetInt("initDataInt", 1);
                PlayerPrefs.Flush();
            }
        }
    }
예제 #5
0
	public void wasAttacked(string key, int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId, bool dstEngunFlg, string dstEngunDaimyoId, string dstEngunSts){

		//In the case of My Damyo was Attacked

		//For Dramatic Enemy Creation
		GameObject kuniView = GameObject.Find("KuniIconView");
		SendParam param = kuniView.transform.FindChild(srcKuni.ToString()).GetComponent<SendParam>();
		int busyoQty = param.busyoQty;
		int busyoLv = param.busyoLv;
		int butaiQty = param.butaiQty;
		int butaiLv = param.butaiLv;

		//Dummy
		PlayerPrefs.SetInt("activeStageId", 0);
		PlayerPrefs.SetInt("activeStageMoney", busyoQty*busyoLv*100);
		PlayerPrefs.SetInt("activeStageExp", busyoQty*busyoLv*10);
		PlayerPrefs.SetString("activeItemType", "");
		PlayerPrefs.SetInt("activeItemId", 0);
		PlayerPrefs.SetFloat("activeItemRatio", 0);
		PlayerPrefs.SetInt("activeItemQty", 0);
		
		//Actual
		PlayerPrefs.SetInt("activeKuniId", dstKuni);
		KuniInfo kuni = new KuniInfo ();
		string kuniName = kuni.getKuniName (dstKuni);
		string kassenName = kuniName + "防衛";
		PlayerPrefs.SetString("activeStageName", kassenName);

		PlayerPrefs.SetInt("activeDaimyoId", srcDaimyoId);
		PlayerPrefs.SetInt ("activeBusyoQty", busyoQty);
		PlayerPrefs.SetInt ("activeBusyoLv", busyoLv);
		PlayerPrefs.SetInt ("activeButaiQty", butaiQty);
		PlayerPrefs.SetInt ("activeButaiLv", butaiLv);

		//Passive only
		PlayerPrefs.SetBool ("isAttackedFlg", true);
		PlayerPrefs.SetString("activeKey", key);
		PlayerPrefs.SetInt("activeSrcDaimyoId", srcDaimyoId);
		PlayerPrefs.SetInt("activeDstDaimyoId", dstDaimyoId);

		//Engun
		if (dstEngunFlg) {
			PlayerPrefs.SetString("playerEngunList", dstEngunSts);
			PlayerPrefs.DeleteKey("enemyEngunList");

		} else {
			PlayerPrefs.DeleteKey("playerEngunList");
			PlayerPrefs.DeleteKey("enemyEngunList");
		}

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

		//Delete "Start Kassen Flg"
		PlayerPrefs.DeleteKey("activeLink");
		PlayerPrefs.DeleteKey("activePowerType");

		List<int> powerTypeList = new List<int> (){1,2,3};
		int random = UnityEngine.Random.Range(1,powerTypeList.Count + 1);
		PlayerPrefs.SetInt("activePowerType",random);


		//Boubi effect
		string boubiTmp = "boubi" + dstKuni.ToString();
		int boubi = PlayerPrefs.GetInt (boubiTmp,0);
		boubi = boubi / 10;
		PlayerPrefs.SetInt("activeBoubi", boubi);



		PlayerPrefs.Flush();
		Application.LoadLevel("preKassen");


	}
예제 #6
0
	public void OnClick () {

		//Hyourou Check
		int nowHyourou = PlayerPrefs.GetInt ("hyourou");

		if(nowHyourou >=5 ){

			//Now on Kuni & Stage
			PlayerPrefs.SetInt("activeKuniId", activeKuniId);
			PlayerPrefs.SetInt("activeStageId", activeStageId);

			//What we can get
			PlayerPrefs.SetInt("activeStageMoney", activeStageMoney);
			PlayerPrefs.SetInt("activeStageExp", activeStageExp);
			PlayerPrefs.SetString("activeItemType", activeItemType);
			PlayerPrefs.SetInt("activeItemId", activeItemId);
			PlayerPrefs.SetFloat("activeItemRatio", activeItemRatio);
			PlayerPrefs.SetInt("activeItemQty", activeItemQty);

			//For Dramatic Enemy Creation
			PlayerPrefs.SetInt("activeDaimyoId", activeDaimyoId);
			PlayerPrefs.SetInt ("activeBusyoQty", activeBusyoQty);
			PlayerPrefs.SetInt ("activeBusyoLv", activeBusyoLv);
			PlayerPrefs.SetInt ("activeButaiQty", activeButaiQty);
			PlayerPrefs.SetInt ("activeButaiLv", activeButaiLv);

			//Hyourou
			int newHyourou = nowHyourou - 5;
			PlayerPrefs.SetInt("hyourou", newHyourou);

			//Gaikou
			int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
			Gaikou gaikou = new Gaikou ();
			gaikou.downGaikouByAttack (myDaimyo, activeDaimyoId);

			//Reverse Flag
			PlayerPrefs.DeleteKey ("isAttackedFlg");

			//Player Doumei Flg
			PlayerPrefs.DeleteKey("playerEngunList");

			//Enemy Doumei Handling
			string doumeiTemp = "doumei" + activeDaimyoId;
			string enemyDoumeiString = PlayerPrefs.GetString (doumeiTemp);
			char[] delimiterChars = {','};
			List<string> doumeiList = new List<string>();
			if(enemyDoumeiString != null && enemyDoumeiString !=""){
				if(enemyDoumeiString.Contains(",")){
					doumeiList = new List<string> (enemyDoumeiString.Split (delimiterChars));
				}else{
					doumeiList.Add(enemyDoumeiString);
				}
			}
			string seiryoku = PlayerPrefs.GetString ("seiryoku");
			List<string> seiryokuList = new List<string> ();
			seiryokuList = new List<string> (seiryoku.Split (delimiterChars));

			Doumei doumei = new Doumei();
			List<string> okDaimyoList = new List<string> ();
			List<string> checkedList = new List<string> ();
			string dstEngunDaimyoId = "";
			string dstEngunSts = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv:

			okDaimyoList = doumei.traceNeighborDaimyo(activeKuniId, activeDaimyoId, doumeiList, seiryokuList, checkedList, okDaimyoList);
			if(okDaimyoList.Count !=0){
				for(int k=0; k<okDaimyoList.Count; k++){
					string engunDaimyo = okDaimyoList[k];
					int yukoudo = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), activeDaimyoId);
					
					//engun check
					MainEventHandler main = new MainEventHandler();
					bool dstEngunFlg = main.CheckByProbability (yukoudo);
					if(dstEngunFlg){
						//Engun OK
						dstEngunFlg = true;
						if(dstEngunDaimyoId !=null && dstEngunDaimyoId !=""){
							dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo;
							string tempEngunSts = main.getEngunSts(engunDaimyo);
							dstEngunSts = dstEngunSts + ":" + tempEngunSts;
							
						}else{
							dstEngunDaimyoId = engunDaimyo;
							string tempEngunSts = main.getEngunSts(engunDaimyo);
							dstEngunSts = tempEngunSts;
							
						}
					}
				}
				PlayerPrefs.SetString("enemyEngunList", dstEngunSts);

			}


			//Kyoutou Handling

			PlayerPrefs.DeleteKey("tempKyoutouList");
			string tempKyoutouList = "";

			char[] delimiterChars2 = {':'};
			char[] delimiterChars3 = {'-'};
			List<string> unitList = new List<string> ();
			string nextKyoutouList = "";
			string playerKyoutouList = PlayerPrefs.GetString("playerKyoutouList","");
			if(playerKyoutouList !=null && playerKyoutouList != ""){
				if(playerKyoutouList.Contains(":")){
					unitList = new List<string> (playerKyoutouList.Split (delimiterChars2));
				}else{
					unitList.Add(playerKyoutouList);
				}
				List<string> unit2List = new List<string> ();
				for(int i=0; i<unitList.Count; i++){
					string playerKyoutouList2 = unitList[i];
					unit2List = new List<string> (playerKyoutouList2.Split (delimiterChars3));

					string tempString = unit2List[1] + "-" + unit2List[2]+ "-" + unit2List[3]+ "-" + unit2List[4];
					if(unit2List[0] == activeKuniId.ToString()){
						if(tempKyoutouList != null && tempKyoutouList != ""){
							tempKyoutouList = tempKyoutouList + ":" + tempString;
						}else{
							tempKyoutouList = tempString;
						}
					}else{
						if(nextKyoutouList != "" && nextKyoutouList != null){
							nextKyoutouList = nextKyoutouList + ":" + tempString;
						}else{
							nextKyoutouList = tempString;
						}
					}
				}
			}

			PlayerPrefs.SetString("tempKyoutouList",tempKyoutouList);
			PlayerPrefs.SetString("playerKyoutouList",nextKyoutouList);

			PlayerPrefs.Flush();
			Application.LoadLevel("kassen");


		}else{

			//Error Message
			Message msg = new Message();
			string Text = "兵糧が不足しておりますぞ。";
			msg.makeMessageOnBoard(Text);

		}
	}
예제 #7
0
	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);
		}
	}
예제 #8
0
	public void OnClick(){
		
		Message msg = new Message();
		Gaikou gaikou = new Gaikou ();
		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;

		if(nowHyourou >= 5){
			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
					//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
					string daimyoName = Gunzei.GetComponent<Gunzei>().srcDaimyoName;
					string OKtext = "御屋形様、偽報に成功しましたぞ。\t " + daimyoName + "の軍勢が退却します。";
					msg.makeMessage (OKtext);

				}else{
					//NG
					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 = "申し訳御座りませぬ。偽報に失敗しましたぞ。\t友好度が" + reduceYukoudo +  "下がりますぞ。";
					msg.makeMessage (NGtext);

				}
				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 = (150 - daimyoBusyoDfc)/4;
					float tempValue = UnityEngine.Random.Range(0.5f,1.5f);
					randomPercent = tempRandomPercent * tempValue;
					PlayerPrefs.SetInt ("shinobiGe",newQty);

				}else if(itemRank == "Cyu"){
					float tempRandomPercent = (150 - daimyoBusyoDfc)/2;
					float tempValue = UnityEngine.Random.Range(0.8f,1.2f);
					randomPercent = tempRandomPercent * tempValue;
					PlayerPrefs.SetInt ("shinobiCyu",newQty);

					
				}else if(itemRank == "Jyo"){
					float tempRandomPercent = (150 - 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
					//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;
						}
						ryugenText = ryugenText + dstDaimyoName + "との友好度が" + reduceYukoudo + "下がりました。\t";
					}

					//Message
					string OKtext = "御屋形様、流言に成功しましたぞ。\t " + ryugenText;
					msg.makeMessage (OKtext);

				}else{
					//Failed
					//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 = "申し訳御座りませぬ。流言に失敗しましたぞ。\t友好度が" + reduceYukoudo +  "下がりますぞ。";
					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 = (150 - daimyoBusyoDfc)/4;
					float tempValue = UnityEngine.Random.Range(0.5f,1.5f);
					randomPercent = tempRandomPercent * tempValue;
					PlayerPrefs.SetInt ("shinobiGe",newQty);
					
				}else if(itemRank == "Cyu"){
					float tempRandomPercent = (150 - daimyoBusyoDfc)/2;
					float tempValue = UnityEngine.Random.Range(0.8f,1.2f);
					randomPercent = tempRandomPercent * tempValue;
					PlayerPrefs.SetInt ("shinobiCyu",newQty);
					
					
				}else if(itemRank == "Jyo"){
					float tempRandomPercent = (150 - 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
					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;
						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
					string OKtext = "御屋形様、強奪に成功しましたぞ。\t ";
					string addText = "";
					if(moneyOrItem==0){
						addText = "金を" + getMoney + "奪って参りました。";
					}else{
						if(kahouOrShizai==0){
							//kahou
							addText = "家宝、" + kahouName + "を奪って参りました。";
						}else{
							//shizai+
							addText = shigenName + "を" + addQty + "個奪って参りました。";
						}
					}

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

				}else{
					//Failed
					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 = "申し訳御座りませぬ。強奪に失敗しましたぞ。\t友好度が" + reduceYukoudo +  "下がりますぞ。";
					msg.makeMessage (NGtext);
				}

				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

					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 = "上";
						}

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

					KuniInfo kuni = new KuniInfo();
					string kuniName = kuni.getKuniName (kuniId);
					string OKtext = "忍が上手く"+kuniName+"に潜伏しましたぞ。\n諜報内容をご確認下され。";
					msg.makeMessage (OKtext);

				} else {
					//Fail
					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 = "忍が捕まってしまったようです。\t友好度が" + reduceYukoudo +  "下がりますぞ。";
					msg.makeMessage (NGtext);
				}


				PlayerPrefs.Flush();

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





		
		} else {

			string NGtext = "御屋形様、兵糧が不足しておりますぞ。";
			msg.makeMessage (NGtext);

		}

	}
예제 #9
0
	public int getGaikouTargetKuni(int srcKuniId, int srcDaimyoId, List<int> targetKuniList, GameObject kuniIconView, bool aggressiveFlg, List<string> seiryokuList, int myDaimyoId){
			

		//Yukoudo Check
		int bestGaikouDaimyo = 0;
		int bestGaikouValue = 0;
		int bestGaikouKuni = 0;
		int bestHeiryokuValue = 0;
		Gaikou gaikou = new Gaikou ();

		for (int k=0; k<targetKuniList.Count; k++) {

			SendParam sendParam = kuniIconView.transform.FindChild (targetKuniList [k].ToString ()).GetComponent<SendParam> ();

			if (aggressiveFlg) {
				//Find best gaikou daimyo

				int dstDaimyoId = int.Parse (seiryokuList [targetKuniList [k] - 1]);
				int gaikouValue = 0;

				if (srcDaimyoId != dstDaimyoId) {
					if (dstDaimyoId == myDaimyoId) {
						//Get Gaikou Value

						string eGaikouM = "gaikou" + srcDaimyoId;
						gaikouValue = PlayerPrefs.GetInt (eGaikouM);

					} else {
						//Gaikou Data Check
						string gaikouTemp = "";
						if (srcDaimyoId < dstDaimyoId) {
							gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId;
						} else {
							gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId;
						}

						if (PlayerPrefs.HasKey (gaikouTemp)) {
							//exsit
							gaikouValue = PlayerPrefs.GetInt (gaikouTemp);

						} else {
							//non exist
							//gaikou check
							gaikouValue = gaikou.getGaikouValue (srcDaimyoId, dstDaimyoId);

						}
					}

					//Compare with Previous one
					//Best one
					if (gaikouValue >= bestGaikouValue) {
						bestGaikouValue = gaikouValue;
						bestGaikouDaimyo = dstDaimyoId;
						bestGaikouKuni = targetKuniList [k];

					}
				}


			} else {
				//Find best heiryoku daimyo
				int dstDaimyoId = int.Parse (seiryokuList [targetKuniList [k] - 1]);

				if (srcDaimyoId != dstDaimyoId) {								
					//Heiryoku Check
					int heiryoku = sendParam.heiryoku;

					//Compare with Previous one
					if (heiryoku >= bestHeiryokuValue) {
						bestHeiryokuValue = heiryoku;

						int gaikouValue = 0;
						if (dstDaimyoId == myDaimyoId) {
							//Get Gaikou Value
							string eGaikouM = "gaikou" + srcDaimyoId;
							gaikouValue = PlayerPrefs.GetInt (eGaikouM);

						} else {
							//Gaikou Data Check
							string gaikouTemp = "";
							if (srcDaimyoId < dstDaimyoId) {
								gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId;
							} else {
								gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId;
							}
							if (PlayerPrefs.HasKey (gaikouTemp)) {
								//exsit
								gaikouValue = PlayerPrefs.GetInt (gaikouTemp);
							} else {
								//non exist
								gaikouValue = gaikou.getGaikouValue (srcDaimyoId, dstDaimyoId);
							}
						}
						bestGaikouValue = gaikouValue;
						bestGaikouDaimyo = dstDaimyoId;
						bestGaikouKuni = targetKuniList [k];
					}


				}

			}

		}//Loop End

		return bestGaikouKuni;
	}
예제 #10
0
	public void OnClick(){

		if (close.GetComponent<CloseBoard> ().kuniId != kuniId) {
			close.GetComponent<CloseBoard> ().kuniId = kuniId;

			/*Status*/
			//Common
			GameObject kuniIconView = GameObject.Find ("KuniIconView").gameObject;
			SendParam script = kuniIconView.transform.FindChild (kuniId.ToString ()).GetComponent<SendParam> ();
			KuniInfo kuni = new KuniInfo ();
			Daimyo daimyo = new Daimyo ();
			Gaikou gaikou = new Gaikou ();
			List<int> targetKuniList = new List<int> ();
			targetKuniList = kuni.getMappingKuni (kuniId);
			char[] delimiterChars = { ',' };

			//Kamon
			GameObject daimyoNameObj = status.transform.FindChild ("DaimyoName").gameObject;
			string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString ();
			daimyoNameObj.transform.FindChild ("Kamon").GetComponent<Image> ().sprite = 
			Resources.Load (imagePath, typeof(Sprite)) as Sprite;

			//Daimyo Name
			daimyoNameObj.transform.FindChild ("Value").GetComponent<Text> ().text = daimyoName;

			//Kuni Name
			GameObject kuniNameObj = status.transform.FindChild ("KuniName").gameObject;
			kuniNameObj.transform.FindChild ("Value").GetComponent<Text> ().text = kuniName;

			//Heiryoku
			status.transform.FindChild ("Heiryoku").transform.FindChild ("Value").GetComponent<Text> ().text = script.heiryoku.ToString ();

			//Yukou
			status.transform.FindChild ("Yukoudo").transform.FindChild ("Value").GetComponent<Text> ().text = script.myYukouValue.ToString ();

			//Attack Target
			bool aggressiveFlg = script.aggressiveFlg;
			int myDaimyoId = PlayerPrefs.GetInt ("myDaimyo");

			int targetKuniId = getKassenTargetKuni (kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId);
			if (targetKuniId != 0) {
				string targetKuniName = kuni.getKuniName (targetKuniId);
				int targetDaimyoId = int.Parse (seiryokuList [targetKuniId - 1]);
				string targetDaimyoName = daimyo.getName (targetDaimyoId);
				status.transform.FindChild ("Atk").transform.FindChild ("Value").GetComponent<Text> ().text = targetKuniName + "(" + targetDaimyoName + ")";
			} else {
				status.transform.FindChild ("Atk").transform.FindChild ("Value").GetComponent<Text> ().text = "無し";
			}


			int targetGaikouKuniId = 0;
			if (snbRank > 1) { //Jyo or Cyu

				//Gaikou
				targetGaikouKuniId = getGaikouTargetKuni (kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId);
				if (targetGaikouKuniId != 0) {
					string targetGaikouKuniName = kuni.getKuniName (targetGaikouKuniId);
					int targetGaikouDaimyoId = int.Parse (seiryokuList [targetGaikouKuniId - 1]);
					string targetGaikouDaimyoName = daimyo.getName (targetGaikouDaimyoId);
		
					status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = targetGaikouKuniName + "(" + targetGaikouDaimyoName + ")";
				} else {
					status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = "無し";
				}

				//Doumei
				string doumeiTmp = "doumei" + daimyoId.ToString ();
				string doumeiString = PlayerPrefs.GetString (doumeiTmp);
				List<string> doumeiList = new List<string> ();
				if (doumeiString != null && doumeiString != "") {
					if (doumeiString.Contains (",")) {
						doumeiList = new List<string> (doumeiString.Split (delimiterChars));
					} else {
						doumeiList.Add (doumeiString);
					}
				}

				string doumeiNameList = "無し";
				for (int j = 0; j < doumeiList.Count; j++) {
					if (j == 0) {
						doumeiNameList = daimyo.getName (int.Parse (doumeiList [j]));
					} else {
						doumeiNameList = doumeiNameList + "," + daimyo.getName (int.Parse (doumeiList [j]));
					}
				}

				status.transform.FindChild ("Doumei").transform.FindChild ("Value").GetComponent<Text> ().text = doumeiNameList;
			
			} else {
				//Ge
				status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = "?";
				status.transform.FindChild ("Doumei").transform.FindChild ("Value").GetComponent<Text> ().text = "?";

			}


			if (snbRank > 2) { //Jyo
				BusyoInfoGet busyo = new BusyoInfoGet();

				string qtyAndHeisyu = busyo.getDaimyoBusyoQtyHeisyu(daimyoId);
				List<string> qtyAndHeisyuiList = new List<string> ();
				qtyAndHeisyuiList = new List<string> (qtyAndHeisyu.Split (delimiterChars));

				//BusyoQty
				//Heisyu
				status.transform.FindChild ("BusyoQty").transform.FindChild ("Value").GetComponent<Text> ().text = qtyAndHeisyuiList[0];
				status.transform.FindChild ("Heisyu").transform.FindChild ("Value").GetComponent<Text> ().text = qtyAndHeisyuiList[1];
			
			} else {
				//Cyu or Ge
				status.transform.FindChild ("BusyoQty").transform.FindChild ("Value").GetComponent<Text> ().text = "?";
				status.transform.FindChild ("Heisyu").transform.FindChild ("Value").GetComponent<Text> ().text = "?";

			}


			//Main Map
			foreach(Transform obj in board.transform){
				if (obj.name != "Explanation") {
					Destroy (obj.gameObject);
				}
			}

			string kuniMapPath = "Prefabs/Map/cyouhou/kuniImage";
			GameObject mainMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject;
			mainMap.transform.SetParent(board.transform);
			mainMap.transform.localScale = new Vector2 (13, 9);
			mainMap.name = "kuniMap" + kuniId;
			string kuniImagePath = "Prefabs/Map/kuniMap/" + kuniId.ToString ();
			mainMap.GetComponent<Image> ().sprite = 
				Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite;

			int baseX = kuni.getKuniLocationX (kuniId);
			int baseY = kuni.getKuniLocationY (kuniId);
			int adjstX = baseX * -1;
			int adjustY = baseY * -1;

			float colorR = daimyo.getColorR (daimyoId);
			float colorG = daimyo.getColorG (daimyoId);
			float colorB = daimyo.getColorB (daimyoId);
			Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);
			mainMap.GetComponent<Image> ().color = kuniColor;

			RectTransform mapRect = mainMap.GetComponent<RectTransform> ();
			mapRect.anchoredPosition3D = new Vector3 (adjstX, adjustY, 0);

			//My Kuni Kamon Icon
			string kamonBackPath ="Prefabs/Map/cyouhou/KamonBack";
			GameObject kamonBack = Instantiate (Resources.Load (kamonBackPath)) as GameObject;
			kamonBack.transform.SetParent (board.transform);
			kamonBack.transform.localScale = new Vector2 (1, 1);
			kamonBack.transform.localPosition = new Vector2(0,0);

			string kamonKuniPath = "Prefabs/Map/Kuni/" + kuniId.ToString();
			GameObject kamonObj = Instantiate (Resources.Load (kamonKuniPath)) as GameObject;
			kamonObj.transform.SetParent (kamonBack.transform);
			kamonObj.transform.localScale = new Vector2 (1, 0.8f);
			kamonObj.transform.localPosition = new Vector2(0,0);
			kamonObj.GetComponent<Image> ().sprite = 
				Resources.Load (imagePath, typeof(Sprite)) as Sprite;
			kamonObj.GetComponent<Button> ().enabled = false;


			//Mapping Kuni
			Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst;
			for (int i=0; i < kuniMst.param.Count; i++) {
			//for (int i=0; i < targetKuniList.Count; i++) {
				int subKuniId = i + 1;

				GameObject subMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject;
				subMap.transform.SetParent(mainMap.transform);
				subMap.transform.localScale = new Vector2 (1, 1);
				subMap.transform.localPosition = new Vector2 (0, 0);

				subMap.name = "kuniMap" + subKuniId;
				string subKuniImagePath = "Prefabs/Map/kuniMap/" + subKuniId;
				subMap.GetComponent<Image> ().sprite = 
					Resources.Load (subKuniImagePath, typeof(Sprite)) as Sprite;


				if (targetKuniList.Contains (subKuniId)) {
					//color
					int subDaimyoId = int.Parse (seiryokuList [subKuniId - 1]);
					float subColorR = daimyo.getColorR (subDaimyoId);
					float subColorG = daimyo.getColorG (subDaimyoId);
					float subColorB = daimyo.getColorB (subDaimyoId);
					Color subKuniColor = new Color (subColorR / 255f, subColorG / 255f, subColorB / 255f, 255f / 255f);
					subMap.GetComponent<Image> ().color = subKuniColor;

					//Kamon
					string subKamonKuniPath = "Prefabs/Map/Kuni/" + subKuniId.ToString ();
					GameObject subKamonObj = Instantiate (Resources.Load (subKamonKuniPath)) as GameObject;
					subKamonObj.transform.SetParent (board.transform);
					subKamonObj.transform.localScale = new Vector2 (1, 0.8f);
					if (daimyoId != subDaimyoId) {
						string subImagePath = "Prefabs/Kamon/" + subDaimyoId.ToString ();
						subKamonObj.GetComponent<Image> ().sprite = 
							Resources.Load (subImagePath, typeof(Sprite)) as Sprite;

						//yukoudo
						int yukoudoValue = gaikou.getExistGaikouValue (daimyoId, subDaimyoId);
						string syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel";
						GameObject yukoudoObj = Instantiate (Resources.Load (syukoudoPath)) as GameObject;
						yukoudoObj.transform.SetParent (subKamonObj.transform);
						yukoudoObj.GetComponent<Text> ().text = yukoudoValue.ToString ();
						yukoudoObj.transform.localScale = new Vector2 (0.08f, 0.1f);
						yukoudoObj.transform.localPosition = new Vector2 (0, 26);

					} else {
						subKamonObj.GetComponent<Image> ().sprite = 
							Resources.Load (imagePath, typeof(Sprite)) as Sprite;
					}
					subKamonObj.GetComponent<Button> ().enabled = false;

					//Kamon adjustment
					int subBaseX = kuni.getKuniLocationX (subKuniId);
					int subBaseY = kuni.getKuniLocationY (subKuniId);
					int subAdjstX = subBaseX - baseX;
					int subAdjstY = subBaseY - baseY;

					RectTransform subMapRect = subKamonObj.GetComponent<RectTransform> ();
					subMapRect.anchoredPosition3D = new Vector3 (subAdjstX, subAdjstY, 0);

					if (targetKuniId != 0) {
						if (targetKuniId == subKuniId) {
							//kassen target
							Color atkColor = new Color (180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
							subKamonObj.GetComponent<Image> ().color = atkColor;
						}
					}

					if (snbRank > 1) {
						if (targetGaikouKuniId != 0) {
							if (targetGaikouKuniId == subKuniId) {
								//kassen target
								Color gaikouColor = new Color (80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f);
								subKamonObj.GetComponent<Image> ().color = gaikouColor;
							}
						}
					}
				} else {
					Color noSubKuniColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f);
					subMap.GetComponent<Image> ().color = noSubKuniColor;
				}

			}






		}


	}
예제 #11
0
    public void dataMake(bool busyoExitFlg, int newDaimyo, int newDaimyoBusyo, string heisyu, bool sameDaimyoFlg)
    {
        /*******************************/
        /*****      Base Value     *****/
        /*******************************/
        System.DateTime now = System.DateTime.Now;
        PlayerPrefs.SetString("lasttime", now.ToString());
        //PlayerPrefs.SetInt ("hyourou",100);
        //PlayerPrefs.SetInt ("money",10000);
        PlayerPrefs.SetString("yearSeason", "1560,1");
        PlayerPrefs.DeleteKey("gameClearFlg");
        PlayerPrefs.DeleteKey("gameClearItemGetFlg");
        PlayerPrefs.DeleteKey("gameOverFlg");
        PlayerPrefs.DeleteKey("kuniClearedFlg");


        /*******************************/
        /*****   Delete History    *****/
        /*******************************/
        PlayerPrefs.DeleteKey("TrackTotalKassenNo");
        PlayerPrefs.DeleteKey("TrackWinNo");
        PlayerPrefs.DeleteKey("TrackTettaiNo");
        PlayerPrefs.DeleteKey("TrackBiggestDaimyoId");
        PlayerPrefs.DeleteKey("TrackBiggestDaimyoHei");
        PlayerPrefs.DeleteKey("TrackMyBiggestHei");
        PlayerPrefs.DeleteKey("TrackNewBusyoHireNo");
        PlayerPrefs.DeleteKey("TrackEarnMoney");
        PlayerPrefs.DeleteKey("TrackGetMoneyNo");
        PlayerPrefs.DeleteKey("TrackGetHyourouNo");
        PlayerPrefs.DeleteKey("TrackGetSozaiNo");
        PlayerPrefs.DeleteKey("TrackBuildMoneyNo");
        PlayerPrefs.DeleteKey("TrackJyosyuNinmeiNo");
        PlayerPrefs.DeleteKey("TrackTabibitoNo");
        PlayerPrefs.DeleteKey("TrackIjinNo");
        PlayerPrefs.DeleteKey("HstNanbansen");
        PlayerPrefs.DeleteKey("TrackGaikouNo");
        PlayerPrefs.DeleteKey("TrackGaikouMoneyNo");
        PlayerPrefs.DeleteKey("TrackDoumeiNo");
        PlayerPrefs.DeleteKey("TrackCyouteiNo");
        PlayerPrefs.DeleteKey("TrackSyouninNo");
        PlayerPrefs.DeleteKey("TrackToubatsuNo");
        PlayerPrefs.DeleteKey("TrackBouryakuNo");
        PlayerPrefs.DeleteKey("TrackBouryakuSuccessNo");
        PlayerPrefs.DeleteKey("TrackCyouhouNo");
        PlayerPrefs.DeleteKey("TrackRyugenNo");
        PlayerPrefs.DeleteKey("TrackGihouHei");
        PlayerPrefs.DeleteKey("TrackCyouryakuNo");
        PlayerPrefs.DeleteKey("TrackLinkCutNo");
        PlayerPrefs.DeleteKey("TrackSyuppeiNo");


        /*******************************/
        /*****   Delete Temp Value *****/
        /*******************************/
        PlayerPrefs.DeleteKey("playerEngunList");
        PlayerPrefs.DeleteKey("enemyEngunList");
        PlayerPrefs.DeleteKey("playerKyoutouList");
        PlayerPrefs.DeleteKey("tempKyoutouList");
        PlayerPrefs.DeleteKey("keyHistory");
        PlayerPrefs.DeleteKey("metsubou");

        HPCounter deleteGunzeiScript = new HPCounter();

        for (int i = 1; i < 66; i++)
        {
            string kuniTemp = "kuni" + i.ToString();
            PlayerPrefs.DeleteKey(kuniTemp);

            string jyosyuTemp = "jyosyu" + i.ToString();
            PlayerPrefs.DeleteKey(jyosyuTemp);

            string naiseiLoginDateTemp = "naiseiLoginDate" + i.ToString();
            PlayerPrefs.DeleteKey(naiseiLoginDateTemp);

            string naiseiTabibitoCounterTemp = "naiseiTabibitoCounter" + i.ToString();
            PlayerPrefs.DeleteKey(naiseiTabibitoCounterTemp);

            string cyouhouTemp = "cyouhou" + i.ToString();
            PlayerPrefs.DeleteKey(cyouhouTemp);

            string linkuctTmp = "linkcut" + i.ToString();
            PlayerPrefs.DeleteKey(linkuctTmp);

            //Delete Enemy Gunzei
            deleteGunzeiScript.deleteEnemyGunzeiData(i);
        }

        PlayerPrefs.DeleteKey("cyouhou");
        PlayerPrefs.DeleteKey("lastSeasonChangeTime");
        PlayerPrefs.DeleteKey("doneCyosyuFlg");
        PlayerPrefs.DeleteKey("twiceHeiFlg");
        PlayerPrefs.DeleteKey("rdmEventTimer");
        PlayerPrefs.DeleteKey("fromNaiseiFlg");
        PlayerPrefs.DeleteKey("fromKassenFlg");
        PlayerPrefs.DeleteKey("kassenWinLoseFlee");
        PlayerPrefs.DeleteKey("kessenFlg");
        PlayerPrefs.DeleteKey("kessenHyourou");
        PlayerPrefs.DeleteKey("winChecker");
        PlayerPrefs.DeleteKey("isAttackedFlg");
        PlayerPrefs.DeleteKey("isKessenFlg");


        /*******************************/
        /*****      Cyoutei & Bakuhu Value    *****/
        /*******************************/
        PlayerPrefs.DeleteKey("cyoutekiDaimyo");
        PlayerPrefs.DeleteKey("cyouteiPoint");
        PlayerPrefs.SetInt("syogunDaimyoId", 14);
        PlayerPrefs.DeleteKey("bakuhuTobatsuDaimyoId");
        PlayerPrefs.DeleteKey("soubujireiFlg");


        /*******************************/
        /*****      Busyo Value    *****/
        /*******************************/

        //Jyosyu Delete
        Entity_busyo_mst busyoMst = Resources.Load("Data/busyo_mst") as Entity_busyo_mst;

        for (int i = 0; i < busyoMst.param.Count; i++)
        {
            int    busyoId     = i + 1;
            string daimyoTemp  = "jyosyuHei" + busyoId;
            string daimyoTemp2 = "jyosyuBusyo" + busyoId;
            PlayerPrefs.DeleteKey(daimyoTemp);
            PlayerPrefs.DeleteKey(daimyoTemp2);
        }
        PlayerPrefs.Flush();

        char[] delimiterChars = { ',' };
        if (!sameDaimyoFlg)
        {
            //Old Daimyo
            //Delete Previous Daimyo Busyo in the case of it has never been gotten by Gacya
            int preDaimyoBusyoId = PlayerPrefs.GetInt("myDaimyoBusyo");

            string        gacyaDaimyoHst     = PlayerPrefs.GetString("gacyaDaimyoHst");
            List <string> gacyaDaimyoHstList = new List <string> ();

            if (gacyaDaimyoHst != null && gacyaDaimyoHst != "")
            {
                if (gacyaDaimyoHst.Contains(","))
                {
                    gacyaDaimyoHstList = new List <string> (gacyaDaimyoHst.Split(delimiterChars));
                }
                else
                {
                    gacyaDaimyoHstList.Add(gacyaDaimyoHst);
                }
            }
            if (!gacyaDaimyoHstList.Contains(preDaimyoBusyoId.ToString()))
            {
                //delete daimyo

                //delete my busyo
                string        myBusyo     = PlayerPrefs.GetString("myBusyo");
                List <string> myBusyoList = new List <string> ();
                if (myBusyo.Contains(","))
                {
                    myBusyoList = new List <string> (myBusyo.Split(delimiterChars));
                }
                else
                {
                    myBusyoList.Add(myBusyo);
                }


                myBusyoList.Remove(preDaimyoBusyoId.ToString());
                string myNewBusyo = "";

                for (int i = 0; i < myBusyoList.Count; i++)
                {
                    if (i == 0)
                    {
                        myNewBusyo = myBusyoList [i];
                    }
                    else
                    {
                        myNewBusyo = myNewBusyo + "," + myBusyoList [i];
                    }
                }

                PlayerPrefs.SetString("myBusyo", myNewBusyo);
                int myBusyoQty = PlayerPrefs.GetInt("myBusyoQty");
                myBusyoQty = myBusyoQty - 1;
                PlayerPrefs.SetInt("myBusyoQty", myBusyoQty);
                PlayerPrefs.Flush();

                //delete jinkei
                int  jinkeiMaxId     = 4;
                int  slotMaxId       = 25;
                bool soudaisyoSetFlg = false;
                for (int i = 1; i <= jinkeiMaxId; i++)
                {
                    for (int j = 1; j <= slotMaxId; j++)
                    {
                        string tmp = i.ToString() + "map" + j.ToString();
                        if (PlayerPrefs.HasKey(tmp))
                        {
                            int busyoId = PlayerPrefs.GetInt(tmp);
                            if (busyoId == preDaimyoBusyoId)
                            {
                                PlayerPrefs.DeleteKey(tmp);
                            }
                            else
                            {
                                if (!soudaisyoSetFlg)
                                {
                                    string sJinkeiId = "soudaisyo" + i.ToString();
                                    PlayerPrefs.SetInt(sJinkeiId, busyoId);
                                }
                            }
                        }
                    }
                }

                //kahou check
                string   tempBusyo      = "kahou" + preDaimyoBusyoId;
                string   busyoKahou     = PlayerPrefs.GetString(tempBusyo);
                string[] busyoKahouList = busyoKahou.Split(delimiterChars);
                for (int k = 0; k < busyoKahouList.Length; k++)
                {
                    int kahouId = int.Parse(busyoKahouList[k]);
                    if (kahouId != 0)
                    {
                        //back kahou data
                        string tmp = "";
                        if (k == 0)
                        {
                            tmp = "Bugu";
                        }
                        else if (k == 1)
                        {
                            tmp = "Kabuto";
                        }
                        else if (k == 2)
                        {
                            tmp = "Gusoku";
                        }
                        else if (k == 3)
                        {
                            tmp = "Meiba";
                        }
                        else if (k == 4)
                        {
                            tmp = "Cyadougu";
                        }
                        else if (k == 5)
                        {
                            tmp = "Cyadougu";
                        }
                        else if (k == 6)
                        {
                            tmp = "Heihousyo";
                        }
                        else if (k == 7)
                        {
                            tmp = "Chishikisyo";
                        }

                        string temp           = "available" + tmp;
                        string availableKahou = PlayerPrefs.GetString(temp);
                        if (availableKahou == null || availableKahou == "")
                        {
                            availableKahou = kahouId.ToString();
                        }
                        else
                        {
                            availableKahou = availableKahou + "," + kahouId.ToString();
                        }
                        PlayerPrefs.SetString(temp, availableKahou);
                        PlayerPrefs.SetString(tempBusyo, "0,0,0,0,0,0,0,0");
                    }
                }

                PlayerPrefs.Flush();
            }

            //New Daimyo
            if (!busyoExitFlg)
            {
                //Player dosen't have this daimyo busyo

                //busyo
                int myBusyoQty = PlayerPrefs.GetInt("myBusyoQty");
                myBusyoQty = myBusyoQty + 1;
                PlayerPrefs.SetInt("myBusyoQty", myBusyoQty);

                string myBusyo = PlayerPrefs.GetString("myBusyo");
                if (myBusyo != null && myBusyo != "")
                {
                    myBusyo = myBusyo + "," + newDaimyoBusyo.ToString();
                }
                else
                {
                    myBusyo = newDaimyoBusyo.ToString();
                }

                PlayerPrefs.SetString("myBusyo", myBusyo);

                if (!PlayerPrefs.HasKey(newDaimyoBusyo.ToString()))
                {
                    PlayerPrefs.SetInt(newDaimyoBusyo.ToString(), 1);
                    string tempHei    = "hei" + newDaimyoBusyo.ToString();
                    string tempSenpou = "senpou" + newDaimyoBusyo.ToString();
                    string tempSaku   = "saku" + newDaimyoBusyo.ToString();
                    string tempKahou  = "kahou" + newDaimyoBusyo.ToString();
                    string tempExp    = "exp" + newDaimyoBusyo.ToString();

                    string valueHei = heisyu + ":1:1:1";
                    PlayerPrefs.SetString(tempHei, valueHei);
                    PlayerPrefs.SetInt(tempSenpou, 1);
                    PlayerPrefs.SetInt(tempSaku, 1);
                    PlayerPrefs.SetString(tempKahou, "0,0,0,0,0,0,0,0");
                    PlayerPrefs.SetInt(tempExp, 0);
                }

                //jinkei
                //if there is no busyo in active jinkei
                int  jinkei = PlayerPrefs.GetInt("jinkei");
                bool jinkeiBusyoExistFlg = false;
                for (int i = 1; i <= 25; i++)
                {
                    string tmp = jinkei.ToString() + "map" + i.ToString();
                    if (PlayerPrefs.HasKey(tmp))
                    {
                        jinkeiBusyoExistFlg = true;
                    }
                }
                if (!jinkeiBusyoExistFlg)
                {
                    string tmpMap = "";
                    if (jinkei == 1)
                    {
                        tmpMap = jinkei.ToString() + "map11";
                    }
                    else if (jinkei == 2)
                    {
                        tmpMap = jinkei.ToString() + "map11";
                    }
                    else if (jinkei == 3)
                    {
                        tmpMap = jinkei.ToString() + "map14";
                    }
                    else if (jinkei == 4)
                    {
                        tmpMap = jinkei.ToString() + "map12";
                    }
                    PlayerPrefs.SetInt(tmpMap, newDaimyoBusyo);
                }
            }
        }

        //My Daimyo Busyo
        PlayerPrefs.SetInt("myDaimyo", newDaimyo);
        PlayerPrefs.SetInt("myDaimyoBusyo", newDaimyoBusyo);
        PlayerPrefs.DeleteKey("usedBusyo");


        /*******************************/
        /*****        Kuni Value     *****/
        /*******************************/
        string newSeiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46";

        PlayerPrefs.SetString("seiryoku", newSeiryoku);
        List <string> seiryokuList = new List <string> ();

        seiryokuList = new List <string> (newSeiryoku.Split(delimiterChars));
        string newClearedKuni = "";

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            string tempDaimyoId = seiryokuList[i];
            if (tempDaimyoId == newDaimyo.ToString())
            {
                int kuniId = i + 1;
                if (newClearedKuni == null || newClearedKuni == "")
                {
                    newClearedKuni = kuniId.ToString();
                }
                else
                {
                    newClearedKuni = newClearedKuni + "," + kuniId.ToString();
                }
            }
        }
        PlayerPrefs.SetString("clearedKuni", newClearedKuni);

        List <string> clearedKuniList = new List <string> ();

        if (newClearedKuni.Contains(","))
        {
            clearedKuniList = new List <string> (newClearedKuni.Split(delimiterChars));
        }
        else
        {
            clearedKuniList.Add(newClearedKuni);
        }


        //New Open Kuni
        KuniInfo kuni = new KuniInfo();

        PlayerPrefs.DeleteKey("openKuni");
        PlayerPrefs.Flush();
        foreach (string kuniId in clearedKuniList)
        {
            kuni.registerOpenKuni(int.Parse(kuniId));

            string temp = "kuni" + kuniId;
            PlayerPrefs.SetString(temp, "1,2,3,4,5,6,7,8,9,10");

            string tempNaisei = "naisei" + kuniId;
            if (!PlayerPrefs.HasKey(tempNaisei))
            {
                PlayerPrefs.SetString(tempNaisei, "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");
            }
            PlayerPrefs.Flush();
        }

        //Add Cleared Kuni to OpenKuni
        string tempOpenKuni = PlayerPrefs.GetString("openKuni");

        tempOpenKuni = tempOpenKuni + "," + newClearedKuni;
        PlayerPrefs.SetString("openKuni", tempOpenKuni);
        PlayerPrefs.Flush();


        /*******************************/
        /*****     Cyouryaku Value    *****/
        /*******************************/
        string cyouryaku = PlayerPrefs.GetString("cyouryaku");

        List <string> cyouryakuList = new List <string> ();

        if (cyouryaku != null && cyouryaku != "")
        {
            if (cyouryaku.Contains(","))
            {
                cyouryakuList = new List <string> (cyouryaku.Split(delimiterChars));
            }
            else
            {
                cyouryakuList.Add(cyouryaku);
            }
        }
        for (int i = 0; i < cyouryakuList.Count; i++)
        {
            PlayerPrefs.DeleteKey(cyouryakuList[i]);
        }
        PlayerPrefs.DeleteKey("cyouryaku");


        /*******************************/
        /*****     Gaikou Value    *****/
        /*******************************/

        //My Gaikou
        Gaikou gaikou = new Gaikou();

        for (int l = 1; l < 47; l++)
        {
            int    value = gaikou.getGaikouValue(newDaimyo, l);
            string temp  = "gaikou" + l.ToString();
            PlayerPrefs.SetInt(temp, value);

            string metsubouTemp = "metsubou" + l.ToString();
            PlayerPrefs.DeleteKey(metsubouTemp);
        }

        //Other Daimyo Gaikou
        for (int x = 2; x < 47; x++)
        {
            for (int y = 2; y < 47; y++)
            {
                if (x != y)
                {
                    string temp  = x.ToString() + "gaikou" + y.ToString();
                    string temp2 = x.ToString() + "key" + y.ToString();
                    PlayerPrefs.DeleteKey(temp);
                    PlayerPrefs.DeleteKey(temp2);
                }
            }
        }
        /*******************************/
        /*****       Shisya        *****/
        /*******************************/
        PlayerPrefs.DeleteKey("shisyaFlg");
        PlayerPrefs.DeleteKey("shisya1");
        PlayerPrefs.DeleteKey("shisya2");
        PlayerPrefs.DeleteKey("shisya3");
        PlayerPrefs.DeleteKey("shisya4");
        PlayerPrefs.DeleteKey("shisya5");
        PlayerPrefs.DeleteKey("shisya6");
        PlayerPrefs.DeleteKey("shisya7");
        PlayerPrefs.DeleteKey("shisya8");
        PlayerPrefs.DeleteKey("shisya9");
        PlayerPrefs.DeleteKey("shisya10");
        PlayerPrefs.DeleteKey("shisya11");
        PlayerPrefs.DeleteKey("shisya12");
        PlayerPrefs.DeleteKey("shisya13");
        PlayerPrefs.DeleteKey("shisya14");
        PlayerPrefs.DeleteKey("shisya15");
        PlayerPrefs.DeleteKey("shisya16");
        PlayerPrefs.DeleteKey("shisya17");
        PlayerPrefs.DeleteKey("shisya18");
        PlayerPrefs.DeleteKey("shisya19");
        PlayerPrefs.DeleteKey("shisya20");
        PlayerPrefs.DeleteKey("shisya21");



        /*******************************/
        /*****       Doumei        *****/
        /*******************************/
        //Delete doumei history
        Entity_daimyo_mst daimyoMst = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst;

        for (int i = 0; i < daimyoMst.param.Count; i++)
        {
            int    daimyoId = daimyoMst.param[i].daimyoId;
            string temp     = "doumei" + daimyoId;
            PlayerPrefs.DeleteKey(temp);
        }
        PlayerPrefs.Flush();


        PlayerPrefs.DeleteKey("doumei");
        string            newMyDoumei = "";
        Entity_doumei_mst doumeiMst   = Resources.Load("Data/doumei_mst") as Entity_doumei_mst;

        for (int i = 0; i < doumeiMst.param.Count; i++)
        {
            int srcDaimyoId = doumeiMst.param[i].doumeiSrc;
            int dstDaimyoId = doumeiMst.param[i].doumeiDst;

            if (srcDaimyoId == newDaimyo)
            {
                if (newMyDoumei != null && newMyDoumei != "")
                {
                    newMyDoumei = newMyDoumei + "," + dstDaimyoId;
                }
                else
                {
                    newMyDoumei = dstDaimyoId.ToString();
                }
            }
            else
            {
                string temp     = "doumei" + srcDaimyoId;
                string previous = PlayerPrefs.GetString(temp);

                if (previous != null && previous != "")
                {
                    previous = previous + "," + dstDaimyoId;
                    PlayerPrefs.SetString(temp, previous);
                }
                else
                {
                    PlayerPrefs.SetString(temp, dstDaimyoId.ToString());
                }
            }
        }
        PlayerPrefs.SetString("doumei", newMyDoumei);
        PlayerPrefs.Flush();


        Application.LoadLevel("mainStage");
    }
예제 #12
0
    public void wasAttacked(string key, int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId, bool dstEngunFlg, string dstEngunDaimyoId, string dstEngunSts)
    {
        //In the case of My Damyo was Attacked

        //For Dramatic Enemy Creation
        GameObject kuniView = GameObject.Find("KuniIconView");

        if (kuniView.transform.FindChild(srcKuni.ToString()))
        {
            SendParam param    = kuniView.transform.FindChild(srcKuni.ToString()).GetComponent <SendParam> ();
            int       busyoQty = param.busyoQty;
            int       busyoLv  = param.busyoLv;
            int       butaiQty = param.butaiQty;
            int       butaiLv  = param.butaiLv;

            //Dummy
            PlayerPrefs.SetInt("activeStageId", 0);
            PlayerPrefs.SetInt("activeStageMoney", busyoQty * 500);
            PlayerPrefs.SetInt("activeStageExp", busyoQty * 100);
            PlayerPrefs.SetString("activeItemType", "");
            PlayerPrefs.SetInt("activeItemId", 0);
            PlayerPrefs.SetFloat("activeItemRatio", 0);
            PlayerPrefs.SetInt("activeItemQty", 0);

            //Actual
            PlayerPrefs.SetInt("activeKuniId", dstKuni);
            KuniInfo kuni       = new KuniInfo();
            string   kuniName   = kuni.getKuniName(dstKuni);
            string   kassenName = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                kassenName = kuniName + " Defence";
            }
            else
            {
                kassenName = kuniName + "防衛";
            }
            PlayerPrefs.SetString("activeStageName", kassenName);

            PlayerPrefs.SetInt("activeDaimyoId", srcDaimyoId);
            PlayerPrefs.SetInt("activeBusyoQty", busyoQty);
            PlayerPrefs.SetInt("activeBusyoLv", busyoLv);
            PlayerPrefs.SetInt("activeButaiQty", butaiQty);
            PlayerPrefs.SetInt("activeButaiLv", butaiLv);

            //Passive only
            PlayerPrefs.SetBool("isAttackedFlg", true);
            PlayerPrefs.DeleteKey("isKessenFlg");
            PlayerPrefs.SetString("activeKey", key);
            PlayerPrefs.SetInt("activeSrcDaimyoId", srcDaimyoId);
            PlayerPrefs.SetInt("activeDstDaimyoId", dstDaimyoId);

            //Engun
            if (dstEngunFlg)
            {
                PlayerPrefs.SetString("playerEngunList", dstEngunSts);
                PlayerPrefs.DeleteKey("enemyEngunList");
            }
            else
            {
                PlayerPrefs.DeleteKey("playerEngunList");
                PlayerPrefs.DeleteKey("enemyEngunList");
            }

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

            //Delete "Start Kassen Flg"
            PlayerPrefs.DeleteKey("activeLink");
            PlayerPrefs.DeleteKey("activePowerType");

            List <int> powerTypeList = new List <int> ()
            {
                1, 2, 3
            };
            int random = UnityEngine.Random.Range(1, powerTypeList.Count + 1);
            PlayerPrefs.SetInt("activePowerType", random);


            //Boubi effect
            string boubiTmp = "boubi" + dstKuni.ToString();
            int    boubi    = PlayerPrefs.GetInt(boubiTmp, 0);
            boubi = boubi / 10;
            PlayerPrefs.SetInt("activeBoubi", boubi);



            PlayerPrefs.Flush();
            Application.LoadLevel("preKassen");
        }
    }
예제 #13
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);
    }
예제 #14
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        if (name == "YesButton")
        {
            audioSources [0].Play();

            GameObject kuniView = GameObject.Find("KuniIconView");
            SendParam  param    = kuniView.transform.FindChild(kuniId.ToString()).GetComponent <SendParam>();

            //adjust
            int busyoQty       = param.busyoQty;
            int jinkeiBusyoQty = PlayerPrefs.GetInt("jinkeiBusyoQty");
            if (busyoQty < jinkeiBusyoQty)
            {
                busyoQty = jinkeiBusyoQty;
            }

            int busyoLv = param.busyoLv;

            //adjsut
            int butaiQty       = param.butaiQty;
            int jinkeiAveChQty = PlayerPrefs.GetInt("jinkeiAveChQty");
            if (butaiQty < jinkeiAveChQty)
            {
                butaiQty = jinkeiAveChQty;
            }
            int butaiLv = param.butaiLv;

            //Dummy
            PlayerPrefs.SetInt("activeStageId", 0);
            PlayerPrefs.SetInt("activeStageMoney", busyoQty * busyoLv * 100);
            PlayerPrefs.SetInt("activeStageExp", busyoQty * busyoLv * 10);
            PlayerPrefs.SetString("activeItemType", "");
            PlayerPrefs.SetInt("activeItemId", 0);
            PlayerPrefs.SetFloat("activeItemRatio", 0);
            PlayerPrefs.SetInt("activeItemQty", 0);
            PlayerPrefs.SetString("activeItemGrp", "no");

            //Actual
            KuniInfo kuni       = new KuniInfo();
            string   kassenName = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                kassenName = " Final Battle with " + daimyoName;
            }
            else
            {
                kassenName = daimyoName + "決戦";
            }
            PlayerPrefs.SetString("activeStageName", kassenName);

            PlayerPrefs.SetInt("activeDaimyoId", daimyoId);
            PlayerPrefs.SetInt("activeBusyoQty", busyoQty);
            PlayerPrefs.SetInt("activeBusyoLv", busyoLv);
            PlayerPrefs.SetInt("activeButaiQty", butaiQty);
            PlayerPrefs.SetInt("activeButaiLv", butaiLv);


            //Flag
            PlayerPrefs.DeleteKey("isAttackedFlg");
            PlayerPrefs.SetBool("isKessenFlg", true);
            PlayerPrefs.SetInt("kessenHyourou", needHyourouNo);

            //Player Doumei Flg
            PlayerPrefs.DeleteKey("playerEngunList");

            //Enemy Doumei Handling
            PlayerPrefs.DeleteKey("enemyEngunList");
            string        doumeiTemp        = "doumei" + daimyoId;
            string        enemyDoumeiString = PlayerPrefs.GetString(doumeiTemp);
            char[]        delimiterChars    = { ',' };
            List <string> doumeiList        = new List <string>();
            if (enemyDoumeiString != null && enemyDoumeiString != "")
            {
                if (enemyDoumeiString.Contains(","))
                {
                    doumeiList = new List <string> (enemyDoumeiString.Split(delimiterChars));
                }
                else
                {
                    doumeiList.Add(enemyDoumeiString);
                }
            }
            string        seiryoku     = PlayerPrefs.GetString("seiryoku");
            List <string> seiryokuList = new List <string> ();
            seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

            Doumei        doumei           = new Doumei();
            Gaikou        gaikou           = new Gaikou();
            List <string> okDaimyoList     = new List <string> ();
            List <string> checkedList      = new List <string> ();
            string        dstEngunDaimyoId = "";
            string        dstEngunSts      = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv:

            okDaimyoList = doumei.traceNeighborDaimyo(kuniId, daimyoId, doumeiList, seiryokuList, checkedList, okDaimyoList);
            if (okDaimyoList.Count != 0)
            {
                for (int k = 0; k < okDaimyoList.Count; k++)
                {
                    string engunDaimyo = okDaimyoList [k];
                    int    yukoudo     = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), daimyoId);

                    //engun check
                    MainEventHandler main        = new MainEventHandler();
                    bool             dstEngunFlg = main.CheckByProbability(yukoudo);
                    if (dstEngunFlg)
                    {
                        //Engun OK
                        dstEngunFlg = true;
                        if (dstEngunDaimyoId != null && dstEngunDaimyoId != "")
                        {
                            dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo;
                            string tempEngunSts = main.getEngunSts(engunDaimyo);
                            dstEngunSts = dstEngunSts + ":" + engunDaimyo + "-" + tempEngunSts;
                        }
                        else
                        {
                            dstEngunDaimyoId = engunDaimyo;
                            string tempEngunSts = main.getEngunSts(engunDaimyo);
                            dstEngunSts = engunDaimyo + "-" + tempEngunSts;
                        }
                    }
                }
                PlayerPrefs.SetString("enemyEngunList", dstEngunSts);
            }

            //Delete "Start Kassen Flg"
            PlayerPrefs.DeleteKey("activeLink");
            PlayerPrefs.SetInt("activePowerType", 3);

            PlayerPrefs.Flush();
            Application.LoadLevel("preKassen");
        }
        else
        {
            audioSources [1].Play();
            Destroy(confirm.gameObject);
            Destroy(back.gameObject);
        }
    }
예제 #15
0
	public void dataMake(bool busyoExitFlg, int newDaimyo, int newDaimyoBusyo, string heisyu){

		/*******************************/
		/*****      Base Value     *****/
		/*******************************/
		System.DateTime now = System.DateTime.Now;
		PlayerPrefs.SetString ("lasttime", now.ToString ());
		PlayerPrefs.SetInt ("hyourou",100);
		PlayerPrefs.SetString ("yearSeason","1560,1");
		PlayerPrefs.DeleteKey("gameClearFlg");
		PlayerPrefs.DeleteKey("gameClearItemGetFlg");
		PlayerPrefs.DeleteKey("gameOverFlg");
		PlayerPrefs.DeleteKey("kuniClearedFlg");


		/*******************************/
		/*****   Delete Temp Value *****/
		/*******************************/
		PlayerPrefs.DeleteKey("playerEngunList");
		PlayerPrefs.DeleteKey("enemyEngunList");
		PlayerPrefs.DeleteKey("playerKyoutouList");
		PlayerPrefs.DeleteKey("tempKyoutouList");
		PlayerPrefs.DeleteKey("keyHistory");
		PlayerPrefs.DeleteKey("metsubou");
		for(int i=1; i<65; i++){
			string kuniTemp = "kuni" + i.ToString();
			PlayerPrefs.DeleteKey(kuniTemp);

			string jyosyuTemp = "jyosyu" + i.ToString();
			PlayerPrefs.DeleteKey(jyosyuTemp);
			
			string naiseiLoginDateTemp = "naiseiLoginDate" + i.ToString();
			PlayerPrefs.DeleteKey(naiseiLoginDateTemp);
			
			string naiseiTabibitoCounterTemp = "naiseiTabibitoCounter" + i.ToString();
			PlayerPrefs.DeleteKey(naiseiTabibitoCounterTemp);
		}
		PlayerPrefs.DeleteKey("lastSeasonChangeTime");
		PlayerPrefs.DeleteKey("doneCyosyuFlg");



		/*******************************/
		/*****      Busyo Value    *****/
		/*******************************/
		if (!busyoExitFlg) {
			//Player dosn't have this daimyo busyo

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

			string myBusyo = PlayerPrefs.GetString ("myBusyo");
			myBusyo = myBusyo + "," + newDaimyoBusyo.ToString();
			PlayerPrefs.SetString ("myBusyo",myBusyo);

			PlayerPrefs.SetInt (newDaimyoBusyo.ToString(),1);
			string tempHei = "hei" + newDaimyoBusyo.ToString();
			string tempSenpou = "senpou" + newDaimyoBusyo.ToString();
			string tempSaku = "saku" + newDaimyoBusyo.ToString();
			string tempKahou = "kahou" + newDaimyoBusyo.ToString();
			string tempExp = "exp" + newDaimyoBusyo.ToString();

			string valueHei = heisyu + ":1:1:1";
			PlayerPrefs.SetString (tempHei,valueHei);
			PlayerPrefs.SetInt (tempSenpou,1);
			PlayerPrefs.SetInt (tempSaku,1);
			PlayerPrefs.SetString (tempKahou,"0,0,0,0,0,0,0,0");
			PlayerPrefs.SetInt (tempExp,0);
		}

		//My Daimyo Busyo
		PlayerPrefs.SetInt("myDaimyo",newDaimyo);
		PlayerPrefs.SetInt("myDaimyoBusyo",newDaimyoBusyo);



		/*******************************/
		/*****      Kuni Value     *****/
		/*******************************/
		string newSeiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46";
		PlayerPrefs.SetString ("seiryoku",newSeiryoku);
		List<string> seiryokuList = new List<string> ();
		char[] delimiterChars = {','};
		seiryokuList = new List<string> (newSeiryoku.Split (delimiterChars));
		string newClearedKuni = "";

		for (int i=0; i<seiryokuList.Count; i++) {
			string tempDaimyoId = seiryokuList[i];
			if(tempDaimyoId == newDaimyo.ToString()){
				int kuniId = i + 1;
				if(newClearedKuni==null || newClearedKuni == ""){
					newClearedKuni = kuniId.ToString();
				}else{
					newClearedKuni = newClearedKuni + "," + kuniId.ToString();
				}
			}
		}
		PlayerPrefs.SetString ("clearedKuni",newClearedKuni);

		List<string> clearedKuniList = new List<string> ();
		clearedKuniList = new List<string> (newClearedKuni.Split (delimiterChars));



		//New Open Kuni
		KuniInfo kuni = new KuniInfo ();
		PlayerPrefs.DeleteKey("openKuni");
		PlayerPrefs.Flush ();
		foreach(string kuniId in clearedKuniList){
			kuni.registerOpenKuni (int.Parse(kuniId));

			string temp = "kuni" + kuniId;
			PlayerPrefs.SetString (temp,"1,2,3,4,5,6,7,8,9,10");

			string tempNaisei = "naisei" + kuniId;
			if(!PlayerPrefs.HasKey(tempNaisei)){
				PlayerPrefs.SetString(tempNaisei,"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");
			}
			PlayerPrefs.Flush ();
		}

		//Add Cleared Kuni to OpenKuni
		string tempOpenKuni = PlayerPrefs.GetString ("openKuni");
		tempOpenKuni = tempOpenKuni + "," + newClearedKuni;
		PlayerPrefs.SetString ("openKuni",tempOpenKuni);
		PlayerPrefs.Flush ();



		/*******************************/
		/*****     Gaikou Value    *****/
		/*******************************/

		//My Gaikou
		Gaikou gaikou = new Gaikou ();
		for(int l=1; l<47; l++){
			int value = gaikou.getGaikouValue(newDaimyo,l);
			string temp = "gaikou" + l.ToString();
			PlayerPrefs.SetInt (temp, value);

			string metsubouTemp = "metsubou" + l.ToString();
			PlayerPrefs.DeleteKey (metsubouTemp);
		}

		//Other Daimyo Gaikou
		for(int x =2; x<47; x++ ){
			for(int y=2; y<47; y++){
				if(x != y){
					string temp = x.ToString() + "gaikou" + y.ToString();
					string temp2 = x.ToString() + "key" + y.ToString();
					PlayerPrefs.DeleteKey(temp);
					PlayerPrefs.DeleteKey(temp2);
				}
			}
		}




		/*******************************/
		/*****       Doumei        *****/
		/*******************************/
		PlayerPrefs.DeleteKey("doumei");
		string newMyDoumei = "";
		Entity_doumei_mst doumeiMst = Resources.Load ("Data/doumei_mst") as Entity_doumei_mst;
		for(int i=0; i < doumeiMst.param.Count; i++){
			int srcDaimyoId = doumeiMst.param[i].doumeiSrc;
			int dstDaimyoId = doumeiMst.param[i].doumeiDst;

			if(srcDaimyoId == newDaimyo){
				if(newMyDoumei != null && newMyDoumei !=""){
					newMyDoumei = newMyDoumei + "," + dstDaimyoId;
				}else{
					newMyDoumei = dstDaimyoId.ToString();
				}

			}else{
				string temp = "doumei" + srcDaimyoId;
				string previous = PlayerPrefs.GetString(temp);

				if(previous != null && previous !=""){
					previous = previous + "," + dstDaimyoId;
					PlayerPrefs.SetString (temp,previous);
				}else{
					PlayerPrefs.SetString (temp,dstDaimyoId.ToString());
				}
			}
		}
		PlayerPrefs.SetString ("doumei",newMyDoumei);
		PlayerPrefs.Flush ();


		Application.LoadLevel ("mainStage");
	}
예제 #16
0
	public void mainHandler(){

		/*Basic Info*/
		//make kuni list
		string seiryoku = PlayerPrefs.GetString ("seiryoku");
		List<string> seiryokuList = new List<string> ();
		char[] delimiterChars = {','};
		seiryokuList = new List<string> (seiryoku.Split (delimiterChars));
		int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
		GameObject targetKuni = GameObject.Find ("KuniIconView");

		/*Kassen*/
		//1. Randome choice Kassen Qty between 0,1,2,3
		//2. Ratio 50% check
		//3. Random choice Kassen Souce Kuni 1-65
		//4. Destination Check by Mapping
		//		if Same Daimyo between Kassen Souce & Destination Kuni => Skip
		//      else => Make guntai Instance
		//        	 4-1. Destination == myDaimyo
		//			 4-2. Destination == has own relation or master relation  
		//

		//Message
		List<string> messageList = new List<string> ();

		//Count Kassen Qty
		int kassenQty = CountEnemyKassenAction ();

		for (int i=1; i<kassenQty+1; i++) {
			//Check Kassen or Not

			bool kassenFlg = CheckByProbability (kassenRatio);
			if (kassenFlg == true) {
				//target kuni extraction

				while (true) {
					int randomKuni = UnityEngine.Random.Range (1, 65);
					string eDaimyo = seiryokuList [randomKuni - 1];
					string tDaimyo = "";
					bool doumeiFlg = false;

					if (eDaimyo != myDaimyo.ToString ()) {
						//Check Kuni Mapping
						List<int> targetKuniList = new List<int> ();
						KuniInfo kuni = new KuniInfo ();
						targetKuniList = kuni.getMappingKuni (randomKuni);
						
						//Yukoudo Check
						int worstGaikouDaimyo = 0;
						int worstGaikouValue = 100;
						int worstGaikouKuni = 0;
						int worstHeiryokuValue = 100000000;

						SendParam srcSendParam = targetKuni.transform.FindChild (randomKuni.ToString ()).GetComponent<SendParam> ();
						bool aggressiveFlg = srcSendParam.aggressiveFlg;

						for (int k=0; k<targetKuniList.Count; k++) {						
							SendParam sendParam = targetKuni.transform.FindChild (targetKuniList [k].ToString ()).GetComponent<SendParam> ();

							if (aggressiveFlg) {
								//Find worst gaikou daimyo


								tDaimyo = seiryokuList [targetKuniList [k] - 1];
								int gaikouValue = 0;

								if (eDaimyo != tDaimyo) {
									if (tDaimyo == myDaimyo.ToString ()) {
										//Get Gaikou Value

										string eGaikouM = "gaikou" + eDaimyo;
										gaikouValue = PlayerPrefs.GetInt (eGaikouM);

									} else {
										//Gaikou Data Check
										string gaikouTemp = "";
										if (int.Parse (eDaimyo) < int.Parse (tDaimyo)) {
											gaikouTemp = eDaimyo + "gaikou" + tDaimyo;
										} else {
											gaikouTemp = tDaimyo + "gaikou" + eDaimyo;
										}

										if (PlayerPrefs.HasKey (gaikouTemp)) {
											//exsit
											gaikouValue = PlayerPrefs.GetInt (gaikouTemp);

										} else {
											//non exist
											//gaikou check
											gaikouValue = gaikou.getGaikouValue (int.Parse (eDaimyo), int.Parse (tDaimyo));

										}
									}

									//Compare with Previous one
									if (worstGaikouValue > gaikouValue) {
										worstGaikouValue = gaikouValue;
										worstGaikouDaimyo = int.Parse (tDaimyo);
										worstGaikouKuni = targetKuniList [k];
									}
								}
							
							
							} else {
								//Find worst heiryoku daimyo

								tDaimyo = seiryokuList [targetKuniList [k] - 1];

								if (eDaimyo != tDaimyo) {								
									//Heiryoku Check
									int heiryoku = sendParam.heiryoku;

									//Compare with Previous one
									if (worstHeiryokuValue > heiryoku) {
										worstHeiryokuValue = heiryoku;

										int gaikouValue = 0;
										if (tDaimyo == myDaimyo.ToString ()) {
											//Get Gaikou Value
											string eGaikouM = "gaikou" + eDaimyo;
											gaikouValue = PlayerPrefs.GetInt (eGaikouM);

										} else {
											//Gaikou Data Check
											string gaikouTemp = "";
											if (int.Parse (eDaimyo) < int.Parse (tDaimyo)) {
												gaikouTemp = eDaimyo + "gaikou" + tDaimyo;
											} else {
												gaikouTemp = tDaimyo + "gaikou" + eDaimyo;
											}
											if (PlayerPrefs.HasKey (gaikouTemp)) {
												//exsit
												gaikouValue = PlayerPrefs.GetInt (gaikouTemp);
											} else {
												//non exist
												gaikouValue = gaikou.getGaikouValue (int.Parse (eDaimyo), int.Parse (tDaimyo));
											}
										}
										worstGaikouValue = gaikouValue;
										worstGaikouDaimyo = int.Parse (tDaimyo);
										worstGaikouKuni = targetKuniList [k];

									}
								}

							}

						}//Loop End

						//Create Guntai Instance
						if (worstGaikouValue != 100) {
							int kassenRatio2 = 100 - worstGaikouValue;

							//doumei check
							string doumeiCheck = "doumei" + eDaimyo;
							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 -> Half Ratio
								if(cDoumeiList.Contains(worstGaikouDaimyo.ToString())){
									doumeiFlg = true;
									kassenRatio2 = kassenRatio2/2;
								}else{
									doumeiFlg = false;
								}
							}

							bool GaikouValueFlg = CheckByProbability (kassenRatio2);
							if (GaikouValueFlg) {
								//Make Guntai Instance
								string key = randomKuni.ToString () + "-" + worstGaikouKuni.ToString ();
								bool ExistFlg = false;

								//Exist Check Same Daimyo
								foreach (GameObject obs in  GameObject.FindGameObjectsWithTag("Gunzei")){
									int gunzeiSrcDaimyoId = obs.GetComponent<Gunzei>().srcDaimyoId;

									if(int.Parse(eDaimyo) == gunzeiSrcDaimyoId){
										ExistFlg = true;
									}
								}

								if(!ExistFlg){
									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
									int srcX = kuni.getKuniLocationX(randomKuni);
									int srcY = kuni.getKuniLocationY(randomKuni);
									int dstX = kuni.getKuniLocationX(worstGaikouKuni);
									int dstY = kuni.getKuniLocationY(worstGaikouKuni);
									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);

									Gunzei.GetComponent<Gunzei> ().key = key;
									Gunzei.GetComponent<Gunzei> ().srcKuni = randomKuni;
									Gunzei.GetComponent<Gunzei> ().srcDaimyoId = int.Parse (eDaimyo);
									string srcDaimyoName = daimyo.getName (int.Parse (eDaimyo));
									Gunzei.GetComponent<Gunzei> ().srcDaimyoName = srcDaimyoName;
									Gunzei.GetComponent<Gunzei> ().dstKuni = worstGaikouKuni;
									Gunzei.GetComponent<Gunzei> ().dstDaimyoId = worstGaikouDaimyo;
									string dstDaimyoName = daimyo.getName (worstGaikouDaimyo);
									Gunzei.GetComponent<Gunzei> ().dstDaimyoName = dstDaimyoName;
									int myHei = gunzei.heiryokuCalc (randomKuni);
									Gunzei.GetComponent<Gunzei> ().myHei = myHei;
									Gunzei.name = key;

									//Engun from Doumei
									Doumei doumei = new 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;

									doumeiDaimyoList = doumei.doumeiExistCheck(worstGaikouDaimyo,eDaimyo);

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

										//Trace Check
										List<string> okDaimyoList = new List<string> ();
										List<string> checkList = new List<string> ();
										okDaimyoList = doumei.traceNeighborDaimyo(worstGaikouKuni, worstGaikouDaimyo, 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), worstGaikouDaimyo);

												//engun check

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

													}else{
														dstEngunDaimyoId = engunDaimyo;
														string tempEngunSts = getEngunSts(engunDaimyo);
														int tempEngunHei = 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 + "," + eDaimyo + "," + worstGaikouDaimyo + "," + 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);
									flush ();

									string kassenText = "";
									if(!dstEngunFlg){
										kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。";
									}else{
										kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。\n防衛側の同盟国が援軍" + totalEngunHei + "人を派兵しました。";
									}
									messageList.Add (kassenText);


									if(doumeiFlg){
										//Delete doumei
										doumei.deleteDoumei(eDaimyo, worstGaikouDaimyo.ToString());

										//Zero Gaikou
										string tempYukou = "";
										if(tDaimyo == myDaimyo.ToString()){
											tempYukou = "gaikou" + eDaimyo;
										}else{
											if(worstGaikouDaimyo < int.Parse(eDaimyo)){
												tempYukou = worstGaikouDaimyo.ToString() + "gaikou" + eDaimyo;
											}else{
												tempYukou = eDaimyo + "gaikou" + worstGaikouDaimyo.ToString();
											}
										}
										PlayerPrefs.SetInt(tempYukou,0);


										PlayerPrefs.Flush ();

									}
								}
							}
						}
						break;
					}
				}
			}
		}
	
		/************/
		/***Gaikou***/
		/************/
		int gaikouQty = CountEnemyGaikouAction ();
		
		for (int i=1; i<gaikouQty+1; i++) {

			bool gaikouFlg = CheckByProbability (gaikouRatio);

			if (gaikouFlg == true) {
				//Do gaikou

				int randomKuni = UnityEngine.Random.Range (1, 66);
				int srcDaimyoId = int.Parse (seiryokuList [randomKuni - 1]);
				string srcDaimyoName = daimyo.getName (srcDaimyoId);

				if (srcDaimyoId != myDaimyo) {	

					List<int> targetKuniList = new List<int> ();
					KuniInfo kuni = new KuniInfo ();
					targetKuniList = kuni.getMappingKuni (randomKuni);

					//Yukoudo Check
					int bestGaikouDaimyo = 0;
					int bestGaikouValue = 0;
					int bestGaikouKuni = 0;
					int bestHeiryokuValue = 0;

					SendParam sendParamSrc = targetKuni.transform.FindChild (randomKuni.ToString ()).GetComponent<SendParam> ();
					bool aggressiveFlg = sendParamSrc.aggressiveFlg;

					for (int k=0; k<targetKuniList.Count; k++) {

						SendParam sendParam = targetKuni.transform.FindChild (targetKuniList [k].ToString ()).GetComponent<SendParam> ();

						if (aggressiveFlg) {
							//Find best gaikou daimyo

							int dstDaimyoId = int.Parse (seiryokuList [targetKuniList [k] - 1]);
							int gaikouValue = 0;

							if (srcDaimyoId != dstDaimyoId) {
								if (dstDaimyoId == myDaimyo) {
									//Get Gaikou Value

									string eGaikouM = "gaikou" + srcDaimyoId;
									gaikouValue = PlayerPrefs.GetInt (eGaikouM);

								} else {
									//Gaikou Data Check
									string gaikouTemp = "";
									if (srcDaimyoId < dstDaimyoId) {
										gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId;
									} else {
										gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId;
									}

									if (PlayerPrefs.HasKey (gaikouTemp)) {
										//exsit
										gaikouValue = PlayerPrefs.GetInt (gaikouTemp);

									} else {
										//non exist
										//gaikou check
										gaikouValue = gaikou.getGaikouValue (srcDaimyoId, dstDaimyoId);

									}
								}


								//Compare with Previous one
								//Best one
								if (gaikouValue >= bestGaikouValue) {
									bestGaikouValue = gaikouValue;
									bestGaikouDaimyo = dstDaimyoId;
									bestGaikouKuni = targetKuniList [k];

								}
							}


						} else {
							//Find best heiryoku daimyo
							int dstDaimyoId = int.Parse (seiryokuList [targetKuniList [k] - 1]);

							if (srcDaimyoId != dstDaimyoId) {								
								//Heiryoku Check
								int heiryoku = sendParam.heiryoku;

								//Compare with Previous one
								if (heiryoku >= bestHeiryokuValue) {
									bestHeiryokuValue = heiryoku;

									int gaikouValue = 0;
									if (dstDaimyoId == myDaimyo) {
										//Get Gaikou Value
										string eGaikouM = "gaikou" + srcDaimyoId;
										gaikouValue = PlayerPrefs.GetInt (eGaikouM);

									} else {
										//Gaikou Data Check
										string gaikouTemp = "";
										if (srcDaimyoId < dstDaimyoId) {
											gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId;
										} else {
											gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId;
										}
										if (PlayerPrefs.HasKey (gaikouTemp)) {
											//exsit
											gaikouValue = PlayerPrefs.GetInt (gaikouTemp);
										} else {
											//non exist
											gaikouValue = gaikou.getGaikouValue (srcDaimyoId, dstDaimyoId);
										}
									}
									bestGaikouValue = gaikouValue;
									bestGaikouDaimyo = dstDaimyoId;
									bestGaikouKuni = targetKuniList [k];
								}


							}

						}

					}//Loop End


					//Gaikou Action
					float percent = UnityEngine.Random.value;
					percent = percent * 100;

					int gaikouAction = 0;
					if (percent <= 60) {
						gaikouAction = 1; //Mitsugi
					} else if (60 < percent && percent <= 97) {
						gaikouAction = 2; //Ryugen
					} else if (97 < percent && percent <= 100) {
						gaikouAction = 3; //Doumei
					}


					if (gaikouAction == 1) {
						//1. yukoudo up(Mitsugimono) 

						bool yukoudoUpFlg = CheckByProbability (yukoudoUpMissRatio);

						if (yukoudoUpFlg == true) {
							//Choose Target Daimyo

							string dstDaimyoName = daimyo.getName (bestGaikouDaimyo);

							if (bestGaikouDaimyo == myDaimyo) {
								//In the case that MyDaimyo receive Mitsugimono
								int addYukoudo = UpYukouValueWithMyDaimyo (myDaimyo, bestGaikouDaimyo);
								int addMoney = addYukoudo * 1000;
								string yukouUpText = srcDaimyoName + "殿が御屋形様に、金" + addMoney.ToString() + "の貢物を送って参りました。\t友好度が" + addYukoudo + "上がります。";
								int myMoney = PlayerPrefs.GetInt("money");
								myMoney = myMoney + addMoney;
								PlayerPrefs.SetInt("money",myMoney);
								flush ();
								GameObject.Find ("MoneyValue").GetComponent<Text>().text = myMoney.ToString();

								messageList.Add (yukouUpText);

							} else {
								//In the case between other daimyos
								int addYukoudo = UpYukouValueWithOther (srcDaimyoId, bestGaikouDaimyo);
								string yukouUpText = srcDaimyoName + "が" + dstDaimyoName + "に貢物をしました。友好度が" + addYukoudo + "上がります。";
								messageList.Add (yukouUpText);
							}

						}

					} else if (gaikouAction == 2) {
						//2. yukoudo down(Ryugen)

						bool yukoudoDownFlg = CheckByProbability (yukoudoDownMissRatio);

						if (yukoudoDownFlg == true) {
							//Choose Target Daimyo
							int reduceYukoudo = 0;

							if (bestGaikouDaimyo != 0) {
								if (bestGaikouDaimyo == myDaimyo) {
									//My Daimyo
									string dstDaimyoName = "";
									reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, srcDaimyoId);
									dstDaimyoName = daimyo.getName (srcDaimyoId);

									string yukouDownText = "何者かが当家と" + dstDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。";
									messageList.Add (yukouDownText);
								} else {
									reduceYukoudo = DownYukouValueWithOther (srcDaimyoId, bestGaikouDaimyo);
									string dst1stDaimyoName = daimyo.getName (srcDaimyoId);
									string dst2ndDaimyoName = daimyo.getName (bestGaikouDaimyo);
									string yukouDownText = "何者かが" + dst1stDaimyoName + "と" + dst2ndDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。";
									messageList.Add (yukouDownText);

								}
							}
						}

					} else if (gaikouAction == 3) {
						//3. doumei
						Gaikou gaiko = new Gaikou();
						int yukoudo = gaikou.getExistGaikouValue(srcDaimyoId, bestGaikouDaimyo);
						bool doumeiFlg = CheckByProbability (yukoudo);

						if (doumeiFlg == true) {

							if (bestGaikouDaimyo == myDaimyo) {
								//
								//
								//
								//
								//
								//
								//
								//



							} else {
								//Exist Check
								string doumeiTmp = "doumei" + srcDaimyoId;
								string doumeiString = PlayerPrefs.GetString (doumeiTmp);
								List<string> doumeiList = new List<string> ();
								if (doumeiString != null && doumeiString != "") {
									if (doumeiString.Contains (",")) {
										doumeiList = new List<string> (doumeiString.Split (delimiterChars));
									} else {
										doumeiList.Add (doumeiString);
									}
								}

								if (!doumeiList.Contains (bestGaikouDaimyo.ToString())) {
									//Not Exist Case
									//Doumei Data Register

									string newDoumei1 = "";
									if (doumeiString != null && doumeiString != "") {
										newDoumei1 = doumeiString + "," + bestGaikouDaimyo;
									} else {
										newDoumei1 = bestGaikouDaimyo.ToString();
									}
									PlayerPrefs.SetString (doumeiTmp, newDoumei1);

									string doumeiTmp2 = "doumei" + bestGaikouDaimyo;
									string doumeiString2 = PlayerPrefs.GetString (doumeiTmp2);
									string newDoumei2 = "";
									if (doumeiString2 != null && doumeiString2 != "") {
										newDoumei2 = doumeiString2 + "," + srcDaimyoId;
									} else {
										newDoumei2 = srcDaimyoId.ToString();
									}
									PlayerPrefs.SetString (doumeiTmp2, newDoumei2);

									flush ();

									string dst1stDaimyoName = daimyo.getName (srcDaimyoId);
									string dst2ndDaimyoName = daimyo.getName (bestGaikouDaimyo);
									string doumeiText = dst1stDaimyoName + "と" + dst2ndDaimyoName + "間に同盟が成立しました。";
									messageList.Add (doumeiText);
								}

							}
						}


					} //else if (gaikouAction == 4) {
						//add here
					//}
				}
			}
		}


		//Check Shinobi Cyouhou
		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);
			}
		}
		for(int i=0; i<cyouhouList.Count; i++){
			int kuniId = int.Parse(cyouhouList [i]);
			string snbTmp = "cyouhou" + kuniId.ToString ();
			int rank = PlayerPrefs.GetInt(snbTmp);

			float missPercent = 0;
			if(rank == 1){
				missPercent = 30;

			}else if(rank == 2){
				missPercent = 15;

			}else if(rank == 3){
				missPercent = 5;

			}

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

			if (percent < missPercent) {
				//Miss
				PlayerPrefs.DeleteKey(snbTmp);
				cyouhouList.Remove (kuniId.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);


				//Reset Chouhou Id
				targetKuni.transform.FindChild(kuniId.ToString()).GetComponent<SendParam>().cyouhouSnbRankId = 0;


				//Message
				KuniInfo kuni = new KuniInfo();
				string kuniName = kuni.getKuniName(kuniId);

				int daimyoId = int.Parse(seiryokuList [kuniId - 1]);
				Daimyo daimyo = new Daimyo ();
				string daimyoName = daimyo.getName (daimyoId); 

				int reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, daimyoId);

				string cyouhouMissText =  kuniName + "に潜伏中の忍が見つかりました。\n" + daimyoName + "との友好度が"+reduceYukoudo+"下がりました。";
				messageList.Add (cyouhouMissText);

			}

		}
		PlayerPrefs.Flush();



		/*Decrease Yukou with Doumei koku*/
		string myDoumei = PlayerPrefs.GetString ("doumei");
		List<string> myDoumeiList = new List<string> ();
		if (myDoumei != null && myDoumei != "") {
			if(myDoumei.Contains(",")){
				myDoumeiList = new List<string> (myDoumei.Split (delimiterChars));
			}else{
				myDoumeiList.Add(myDoumei);
			}
		}
		for (int j=0; j<myDoumeiList.Count; j++) {
			string doumeiDaimyo = myDoumeiList[j];
			string yukouTemp = "gaikou" + doumeiDaimyo;
			int yukouWithDoumei = PlayerPrefs.GetInt (yukouTemp);
			int reduceYukou = UnityEngine.Random.Range(0,3);
			yukouWithDoumei = yukouWithDoumei - reduceYukou;

			PlayerPrefs.SetInt (yukouTemp,yukouWithDoumei);

			/*Doumei Clear Check*/
			if(yukouWithDoumei<30){
				//My Doumei Clear
				myDoumeiList.Remove(doumeiDaimyo);
				string newMyDoumei = "";
				for(int i=0; i<myDoumeiList.Count; i++){
					if(i==0){
						newMyDoumei = myDoumeiList[i];
					}else{
						newMyDoumei = newMyDoumei + "," + myDoumeiList[i];
					}
				}
				PlayerPrefs.SetString ("doumei",newMyDoumei);

				//Opposite Doumei Clear
				string otherTemp = "doumei" + doumeiDaimyo;
				string otherDoumei = PlayerPrefs.GetString (otherTemp);
				List<string> otherDoumeiList = new List<string> ();
				if (otherDoumei != null && otherDoumei != "") {
					if(otherDoumei.Contains(",")){
						otherDoumeiList = new List<string> (otherDoumei.Split (delimiterChars));
					}else{
						otherDoumeiList.Add(otherDoumei);
					}
				}
				otherDoumeiList.Remove(myDaimyo.ToString());
				string newOtherDoumei = "";
				for(int i=0; i<otherDoumeiList.Count; i++){
					if(i==0){
						newOtherDoumei = otherDoumeiList[i];
					}else{
						newOtherDoumei = newOtherDoumei + "," + otherDoumeiList[i];
					}
				}
				PlayerPrefs.SetString (otherTemp,newOtherDoumei);

				//Icon & Flg Change
				KuniInfo kuni = new KuniInfo();
				kuni.deleteDoumeiKuniIcon(int.Parse(doumeiDaimyo));


				//Message
				string dstDaimyoName = daimyo.getName (int.Parse(doumeiDaimyo));
				string doumeiClearText = "友好度悪化により、当家と" + dstDaimyoName + "間の同盟が解消しました。";
				messageList.Add (doumeiClearText);
			}

			PlayerPrefs.Flush();

		}

		/*Decrease Yukou with Doumei koku in other county*/
		List<string> activeDaimyoList = new List<string> ();
		for (int k=0; k<seiryokuList.Count; k++) {
			string daimyoId = seiryokuList[k];

			if(int.Parse(daimyoId) != myDaimyo && !activeDaimyoList.Contains(daimyoId)){
				activeDaimyoList.Add(daimyoId);
			}
		}

		for(int l=0; l<activeDaimyoList.Count; l++){
			string activeDaimyoId = activeDaimyoList[l];
			string temp = "doumei" + activeDaimyoId;
			if(PlayerPrefs.HasKey(temp)){
				string doumeiString = PlayerPrefs.GetString(temp);

				if(doumeiString != null && doumeiString != ""){

					List<string> doumeiTargetList = new List<string> ();
					if(doumeiString.Contains(",")){
						doumeiTargetList = new List<string> (doumeiString.Split (delimiterChars));
					}else{
						doumeiTargetList.Add(doumeiString);
					}

					for(int m=0; m<doumeiTargetList.Count; m++){
						string targetDaimyoId = doumeiTargetList[m];

						string gaikoTemp = "";
						if(int.Parse(activeDaimyoId)<int.Parse(targetDaimyoId)){
							gaikoTemp = activeDaimyoId + "gaikou" + targetDaimyoId;
						}else{
							gaikoTemp = targetDaimyoId + "gaikou" + activeDaimyoId;
						}
						if(PlayerPrefs.HasKey(gaikoTemp)){
							int gaikouValue = PlayerPrefs.GetInt(gaikoTemp);

							if(gaikouValue <30){
								//Doumei Clear
								//src to dst
								doumeiTargetList.Remove(targetDaimyoId);
								string newDoumei1 = "";
								for(int n=0; n<doumeiTargetList.Count; n++){
									if(n==0){
										newDoumei1 = doumeiTargetList[n];
									}else{
										newDoumei1 = newDoumei1 +"," + doumeiTargetList[n];
									}
								}
								PlayerPrefs.SetString(temp,newDoumei1);

								//dst to src
								string tgtTemp =  "doumei" + targetDaimyoId;
								string tgtDoumeiString = PlayerPrefs.GetString(tgtTemp);
								List<string> tgtDoumeiList = new List<string> ();
								if(tgtDoumeiString!=null && tgtDoumeiString != ""){
									if(tgtDoumeiString.Contains(",")){
										tgtDoumeiList = new List<string> (tgtDoumeiString.Split (delimiterChars));
									}else{
										tgtDoumeiList.Add(tgtDoumeiString);
									}
									tgtDoumeiList.Remove(activeDaimyoId);

									string newDoumei2 = "";
									for(int n=0; n<tgtDoumeiList.Count; n++){
										if(n==0){
											newDoumei2 = tgtDoumeiList[n];
										}else{
											newDoumei2 = newDoumei2 +"," + tgtDoumeiList[n];
										}
									}
									PlayerPrefs.SetString(tgtTemp,newDoumei2);
								}

								string srcDaimyoName = daimyo.getName(int.Parse(activeDaimyoId));
								string dstDaimyoName = daimyo.getName(int.Parse(targetDaimyoId));

								string doumeiClearText = "友好度悪化により、"+ srcDaimyoName+"と" + dstDaimyoName + "間の同盟が解消しました。";
								messageList.Add (doumeiClearText);
								PlayerPrefs.Flush();
							}
						}
					}
				}
			}
		}

		//Delete Cyouryaku Data
		string cyoryakuHst = PlayerPrefs.GetString("cyouryaku");
		List<string> cyoryakuHstList = new List<string> ();

		if(cyoryakuHst != null && cyoryakuHst != ""){
			if (cyoryakuHst.Contains (",")) {
				cyoryakuHstList = new List<string> (cyoryakuHst.Split (delimiterChars));
			} else {
				cyoryakuHstList.Add (cyoryakuHst);
			}

			for (int i=0; i<cyoryakuHstList.Count; i++) {
				string tmp = cyoryakuHstList [i];
				PlayerPrefs.DeleteKey (tmp);
			}
			PlayerPrefs.DeleteKey ("cyouryaku");
			PlayerPrefs.Flush ();
		}

		
		/*Message*/
		if (messageList.Count != 0) {
			/*Common Process*/
			//make back
			string pathOfBack = "Prefabs/Common/TouchBack";
			GameObject back = Instantiate(Resources.Load (pathOfBack)) as GameObject;
			back.transform.SetParent(GameObject.Find ("Panel").transform);
			back.transform.localScale = new Vector2 (1,1);
			back.transform.localPosition = new Vector2 (0,0);

			//make board
			string pathOfBoard = "Prefabs/Event/EventBoard";
			GameObject board = Instantiate(Resources.Load (pathOfBoard)) as GameObject;
			board.transform.SetParent(GameObject.Find ("Panel").transform);
			board.transform.localScale = new Vector2 (1,1);


			string pathOfScroll = "Prefabs/Event/EventScrollView";
			GameObject scroll = Instantiate(Resources.Load (pathOfScroll)) as GameObject;
			scroll.transform.SetParent(board.transform);
			scroll.transform.localScale = new Vector2 (1,1);
			RectTransform scrollTransform = scroll.GetComponent<RectTransform> ();
			scrollTransform.anchoredPosition = new Vector3 (0, -40, 0);

			string pathOfSlot = "Prefabs/Event/EventSlot";
			foreach (string text in messageList) {
				GameObject slot = Instantiate(Resources.Load (pathOfSlot)) as GameObject;
				slot.transform.SetParent(scroll.transform.FindChild("Content").transform);
				slot.transform.FindChild("EventText").GetComponent<Text>().text = text;
				slot.transform.localScale = new Vector2 (1,1);
			}
		}


	}
예제 #17
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        Message       msg          = new Message();

        if (!checkJinkeiAvailable())
        {
            audioSources[4].Play();
            msg.makeUpperMessageOnBoard(msg.getMessage(133));
        }
        else
        {
            //Hyourou Check
            int nowHyourou = PlayerPrefs.GetInt("hyourou");

            if (nowHyourou >= 5)
            {
                audioSources [5].Play();

                //Now on Kuni & Stage
                PlayerPrefs.SetInt("activeKuniId", activeKuniId);
                PlayerPrefs.SetInt("activeStageId", activeStageId);
                PlayerPrefs.SetString("activeStageName", activeStageName);

                //What we can get
                PlayerPrefs.SetInt("activeStageMoney", activeStageMoney);
                PlayerPrefs.SetInt("activeStageExp", activeStageExp);
                PlayerPrefs.SetString("activeItemGrp", activeItemGrp);
                PlayerPrefs.SetString("activeItemType", activeItemType);
                PlayerPrefs.SetInt("activeItemId", activeItemId);
                PlayerPrefs.SetInt("activeItemQty", activeItemQty);

                //For Dramatic Enemy Creation
                PlayerPrefs.SetInt("activeDaimyoId", activeDaimyoId);
                PlayerPrefs.SetInt("activeBusyoQty", activeBusyoQty);
                PlayerPrefs.SetInt("activeBusyoLv", activeBusyoLv);
                PlayerPrefs.SetInt("activeButaiQty", activeButaiQty);
                PlayerPrefs.SetInt("activeButaiLv", activeButaiLv);

                //Gaikou
                int    myDaimyo = PlayerPrefs.GetInt("myDaimyo");
                Gaikou gaikou   = new Gaikou();
                gaikou.downGaikouByAttack(myDaimyo, activeDaimyoId);

                //Reverse Flag
                PlayerPrefs.DeleteKey("isAttackedFlg");
                PlayerPrefs.DeleteKey("isKessenFlg");

                //Player Doumei Flg
                PlayerPrefs.DeleteKey("playerEngunList");

                //Enemy Doumei Handling
                PlayerPrefs.DeleteKey("enemyEngunList");
                string        doumeiTemp        = "doumei" + activeDaimyoId;
                string        enemyDoumeiString = PlayerPrefs.GetString(doumeiTemp);
                char[]        delimiterChars    = { ',' };
                List <string> doumeiList        = new List <string>();
                if (enemyDoumeiString != null && enemyDoumeiString != "")
                {
                    if (enemyDoumeiString.Contains(","))
                    {
                        doumeiList = new List <string> (enemyDoumeiString.Split(delimiterChars));
                    }
                    else
                    {
                        doumeiList.Add(enemyDoumeiString);
                    }
                }
                string        seiryoku     = PlayerPrefs.GetString("seiryoku");
                List <string> seiryokuList = new List <string> ();
                seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

                Doumei        doumei           = new Doumei();
                List <string> okDaimyoList     = new List <string> ();
                List <string> checkedList      = new List <string> ();
                string        dstEngunDaimyoId = "";
                string        dstEngunSts      = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv:

                okDaimyoList = doumei.traceNeighborDaimyo(activeKuniId, activeDaimyoId, doumeiList, seiryokuList, checkedList, okDaimyoList);

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

                        //mydaimyo doumei check
                        bool myDoumeiFlg = false;
                        myDoumeiFlg = doumei.myDoumeiExistCheck(int.Parse(engunDaimyo));
                        if (myDoumeiFlg)
                        {
                            yukoudo = yukoudo / 2;
                        }

                        //engun check
                        MainEventHandler main        = new MainEventHandler();
                        bool             dstEngunFlg = main.CheckByProbability(yukoudo);
                        if (dstEngunFlg)
                        {
                            //Engun OK
                            dstEngunFlg = true;
                            if (dstEngunDaimyoId != null && dstEngunDaimyoId != "")
                            {
                                dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo;
                                string tempEngunSts = main.getEngunSts(engunDaimyo);
                                dstEngunSts = dstEngunSts + ":" + engunDaimyo + "-" + tempEngunSts;
                            }
                            else
                            {
                                dstEngunDaimyoId = engunDaimyo;
                                string tempEngunSts = main.getEngunSts(engunDaimyo);
                                dstEngunSts = engunDaimyo + "-" + tempEngunSts;
                            }
                        }
                    }
                    PlayerPrefs.SetString("enemyEngunList", dstEngunSts);
                }


                //Kyoutou Handling

                PlayerPrefs.DeleteKey("tempKyoutouList");
                string tempKyoutouList = "";

                char[]        delimiterChars2   = { ':' };
                char[]        delimiterChars3   = { '-' };
                List <string> unitList          = new List <string> ();
                string        nextKyoutouList   = "";
                string        playerKyoutouList = PlayerPrefs.GetString("playerKyoutouList", "");
                if (playerKyoutouList != null && playerKyoutouList != "")
                {
                    if (playerKyoutouList.Contains(":"))
                    {
                        unitList = new List <string> (playerKyoutouList.Split(delimiterChars2));
                    }
                    else
                    {
                        unitList.Add(playerKyoutouList);
                    }
                    List <string> unit2List = new List <string> ();
                    for (int i = 0; i < unitList.Count; i++)
                    {
                        string playerKyoutouList2 = unitList[i];
                        unit2List = new List <string> (playerKyoutouList2.Split(delimiterChars3));

                        string tempString = unit2List[0] + "-" + unit2List[1] + "-" + unit2List[2] + "-" + unit2List[3] + "-" + unit2List[4];
                        if (unit2List[0] == activeKuniId.ToString())
                        {
                            if (tempKyoutouList != null && tempKyoutouList != "")
                            {
                                tempKyoutouList = tempKyoutouList + ":" + tempString;
                            }
                            else
                            {
                                tempKyoutouList = tempString;
                            }
                        }
                        else
                        {
                            if (nextKyoutouList != "" && nextKyoutouList != null)
                            {
                                nextKyoutouList = nextKyoutouList + ":" + tempString;
                            }
                            else
                            {
                                nextKyoutouList = tempString;
                            }
                        }
                    }
                }

                PlayerPrefs.SetString("tempKyoutouList", tempKyoutouList);
                PlayerPrefs.SetString("playerKyoutouList", nextKyoutouList);


                //Power Keisu
                PlayerPrefs.DeleteKey("activeLink");
                PlayerPrefs.DeleteKey("activePowerType");
                PlayerPrefs.SetInt("activeLink", linkNo);

                //Power Type Config
                if (powerType == 1)
                {
                    int rdm = UnityEngine.Random.Range(0, 3); //1:happen, 0,2:not happen
                    if (rdm == 1)
                    {
                        powerType = 2;
                    }
                }
                else if (powerType == 2)
                {
                    int rdm = UnityEngine.Random.Range(0, 3); //1:happen, 0,2:not happen
                    if (rdm == 1)
                    {
                        powerType = 3;
                    }
                }



                PlayerPrefs.SetInt("activePowerType", powerType);

                PlayerPrefs.Flush();
                //Stop BGM
                GameObject.Find("BGMController").GetComponent <DontDestroySoundOnLoad> ().DestoryFlg = true;

                Stage stage      = new Stage();
                int   stageMapId = stage.getStageMap(activeKuniId, activeStageId);

                if (stageMapId != 4)
                {
                    Application.LoadLevel("preKassen");
                }
                else
                {
                    Application.LoadLevel("preKaisen");
                }
            }
            else
            {
                //Error Message
                audioSources [4].Play();

                msg.hyourouMovieMessage();
            }
        }
    }
예제 #18
0
    public void OnClick()
    {
        if (close.GetComponent <CloseBoard> ().kuniId != kuniId)
        {
            close.GetComponent <CloseBoard> ().kuniId = kuniId;

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

            /*Status*/
            //Common
            GameObject kuniIconView   = GameObject.Find("KuniIconView").gameObject;
            SendParam  script         = kuniIconView.transform.FindChild(kuniId.ToString()).GetComponent <SendParam> ();
            KuniInfo   kuni           = new KuniInfo();
            Daimyo     daimyo         = new Daimyo();
            Gaikou     gaikou         = new Gaikou();
            List <int> targetKuniList = new List <int> ();
            targetKuniList = kuni.getMappingKuni(kuniId);
            char[] delimiterChars = { ',' };

            //Kamon
            GameObject daimyoNameObj = status.transform.FindChild("DaimyoName").gameObject;
            string     imagePath     = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString();
            daimyoNameObj.transform.FindChild("Kamon").GetComponent <Image> ().sprite =
                Resources.Load(imagePath, typeof(Sprite)) as Sprite;

            //Daimyo Name
            daimyoNameObj.transform.FindChild("Value").GetComponent <Text> ().text = daimyoName;

            //Kuni Name
            GameObject kuniNameObj = status.transform.FindChild("KuniName").gameObject;
            kuniNameObj.transform.FindChild("Value").GetComponent <Text> ().text = kuniName;

            //Heiryoku
            status.transform.FindChild("Heiryoku").transform.FindChild("Value").GetComponent <Text> ().text = script.heiryoku.ToString();

            //Yukou
            status.transform.FindChild("Yukoudo").transform.FindChild("Value").GetComponent <Text> ().text = script.myYukouValue.ToString();

            //Attack Target
            bool aggressiveFlg = script.aggressiveFlg;
            int  myDaimyoId    = PlayerPrefs.GetInt("myDaimyo");

            int targetKuniId   = getKassenTargetKuni(kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId);
            int targetDaimyoId = 0;
            if (targetKuniId != 0)
            {
                string targetKuniName = kuni.getKuniName(targetKuniId);
                targetDaimyoId = int.Parse(seiryokuList [targetKuniId - 1]);
                string targetDaimyoName = daimyo.getName(targetDaimyoId);
                status.transform.FindChild("Atk").transform.FindChild("Value").GetComponent <Text> ().text = targetKuniName + "(" + targetDaimyoName + ")";
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    status.transform.FindChild("Atk").transform.FindChild("Value").GetComponent <Text>().text = "None";
                }
                else
                {
                    status.transform.FindChild("Atk").transform.FindChild("Value").GetComponent <Text> ().text = "無し";
                }
            }


            int targetGaikouKuniId = 0;
            if (snbRank > 1)               //Jyo or Cyu

            //Gaikou
            {
                targetGaikouKuniId = getGaikouTargetKuni(kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId);
                if (targetGaikouKuniId != 0)
                {
                    string targetGaikouKuniName   = kuni.getKuniName(targetGaikouKuniId);
                    int    targetGaikouDaimyoId   = int.Parse(seiryokuList [targetGaikouKuniId - 1]);
                    string targetGaikouDaimyoName = daimyo.getName(targetGaikouDaimyoId);

                    if (targetDaimyoId != targetGaikouDaimyoId)
                    {
                        status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text> ().text = targetGaikouKuniName + "(" + targetGaikouDaimyoName + ")";
                    }
                    else
                    {
                        sameDaimyoFlg = true;
                        if (Application.systemLanguage != SystemLanguage.Japanese)
                        {
                            status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text>().text = "None";
                        }
                        else
                        {
                            status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text> ().text = "無し";
                        }
                    }
                }
                else
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text>().text = "None";
                    }
                    else
                    {
                        status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text>().text = "無し";
                    }
                }

                //Doumei
                string        doumeiTmp    = "doumei" + daimyoId.ToString();
                string        doumeiString = PlayerPrefs.GetString(doumeiTmp);
                List <string> doumeiList   = new List <string> ();
                if (doumeiString != null && doumeiString != "")
                {
                    if (doumeiString.Contains(","))
                    {
                        doumeiList = new List <string> (doumeiString.Split(delimiterChars));
                    }
                    else
                    {
                        doumeiList.Add(doumeiString);
                    }
                }


                //Exist Check
                if (doumeiList.Count != 0)
                {
                    List <string> doumeiListTmp = new List <string> (doumeiList);
                    for (int j = 0; j < doumeiListTmp.Count; j++)
                    {
                        string doumeiDaimyoId = doumeiListTmp [j];
                        if (!seiryokuList.Contains(doumeiDaimyoId))
                        {
                            doumeiList.Remove(doumeiDaimyoId);
                        }
                    }
                }
                string doumeiNameList = "";
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    doumeiNameList = "None";
                }
                else
                {
                    doumeiNameList = "無し";
                }

                for (int j = 0; j < doumeiList.Count; j++)
                {
                    if (j == 0)
                    {
                        doumeiNameList = daimyo.getName(int.Parse(doumeiList [j]));
                    }
                    else
                    {
                        doumeiNameList = doumeiNameList + "," + daimyo.getName(int.Parse(doumeiList [j]));
                    }
                }

                status.transform.FindChild("Doumei").transform.FindChild("Value").GetComponent <Text> ().text = doumeiNameList;
            }
            else
            {
                //Ge
                status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text> ().text  = "?";
                status.transform.FindChild("Doumei").transform.FindChild("Value").GetComponent <Text> ().text = "?";
            }


            if (snbRank > 2)               //Jyo
            {
                BusyoInfoGet busyo = new BusyoInfoGet();

                string        qtyAndHeisyu      = busyo.getDaimyoBusyoQtyHeisyu(daimyoId);
                List <string> qtyAndHeisyuiList = new List <string> ();
                qtyAndHeisyuiList = new List <string> (qtyAndHeisyu.Split(delimiterChars));

                //BusyoQty
                //Heisyu
                status.transform.FindChild("BusyoQty").transform.FindChild("Value").GetComponent <Text> ().text = qtyAndHeisyuiList[0];
                status.transform.FindChild("Heisyu").transform.FindChild("Value").GetComponent <Text> ().text   = qtyAndHeisyuiList[1];
            }
            else
            {
                //Cyu or Ge
                status.transform.FindChild("BusyoQty").transform.FindChild("Value").GetComponent <Text> ().text = "?";
                status.transform.FindChild("Heisyu").transform.FindChild("Value").GetComponent <Text> ().text   = "?";
            }


            //Main Map
            foreach (Transform obj in board.transform)
            {
                if (obj.name != "Explanation")
                {
                    Destroy(obj.gameObject);
                }
            }


            //Create Map
            GameObject originalKuniMap = GameObject.Find("KuniMap");
            GameObject copiedKuniMap   = Object.Instantiate(originalKuniMap) as GameObject;
            copiedKuniMap.transform.SetParent(board.transform);
            copiedKuniMap.transform.localScale = new Vector2(1, 0.8f);
            Vector3       vect    = copiedKuniMap.transform.FindChild(kuniId.ToString()).transform.localPosition;
            float         adjstX  = vect.x * -1;
            float         adjustY = vect.y * -1;
            RectTransform mapRect = copiedKuniMap.GetComponent <RectTransform>();
            mapRect.anchoredPosition3D = new Vector3(adjstX, adjustY, 0);

            //Create Kamon
            GameObject originalKamon = GameObject.Find("KuniIconView");
            GameObject copiedKamon   = Object.Instantiate(originalKamon) as GameObject;
            copiedKamon.transform.SetParent(board.transform);
            copiedKamon.transform.localScale = new Vector2(1, 0.8f);
            RectTransform kamonRect = copiedKamon.GetComponent <RectTransform>();
            kamonRect.anchoredPosition3D = new Vector3(adjstX, adjustY, 0);

            Entity_kuni_mst kuniMst    = Resources.Load("Data/kuni_mst") as Entity_kuni_mst;
            Color           whiteColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f);
            for (int i = 0; i < kuniMst.param.Count; i++)
            {
                int subKuniId = i + 1;

                GameObject tmpKuniObj  = copiedKuniMap.transform.FindChild(subKuniId.ToString()).gameObject;
                GameObject tmpKamonObj = copiedKamon.transform.FindChild(subKuniId.ToString()).gameObject;
                tmpKamonObj.GetComponent <Image>().color = whiteColor;

                if (subKuniId == kuniId)
                {
                    tmpKamonObj.GetComponent <Button>().enabled = false;
                    tmpKamonObj.GetComponent <Image>().sprite   =
                        Resources.Load(imagePath, typeof(Sprite)) as Sprite;

                    //EFFECT
                    string     effectPath = "Prefabs/EffectAnime/point_up";
                    GameObject pointUp    = Instantiate(Resources.Load(effectPath)) as GameObject;
                    pointUp.transform.SetParent(tmpKamonObj.transform);
                    pointUp.transform.localScale             = new Vector2(70, 70);
                    pointUp.transform.localPosition          = new Vector2(0, 25);
                    pointUp.GetComponent <Fadeout>().enabled = false;
                }
                else
                {
                    if (targetKuniList.Contains(subKuniId))
                    {
                        tmpKamonObj.GetComponent <Button>().enabled = false;
                        int subDaimyoId = int.Parse(seiryokuList[subKuniId - 1]);

                        if (daimyoId != subDaimyoId)
                        {
                            //yukoudo
                            int        yukoudoValue = gaikou.getExistGaikouValue(daimyoId, subDaimyoId);
                            string     syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel";
                            GameObject yukoudoObj   = Instantiate(Resources.Load(syukoudoPath)) as GameObject;
                            yukoudoObj.transform.SetParent(tmpKamonObj.transform);
                            yukoudoObj.GetComponent <Text>().text = yukoudoValue.ToString();
                            yukoudoObj.transform.localScale       = new Vector2(0.08f, 0.1f);
                            yukoudoObj.transform.localPosition    = new Vector2(0, 26);
                        }
                        else
                        {
                            tmpKamonObj.GetComponent <Image>().sprite =
                                Resources.Load(imagePath, typeof(Sprite)) as Sprite;
                        }

                        if (targetKuniId != 0)
                        {
                            if (targetKuniId == subKuniId)
                            {
                                //kassen target
                                Color atkColor = new Color(180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
                                tmpKamonObj.GetComponent <Image>().color = atkColor;
                            }
                        }
                        if (snbRank > 1)
                        {
                            if (targetGaikouKuniId != 0)
                            {
                                if (targetGaikouKuniId == subKuniId)
                                {
                                    if (!sameDaimyoFlg)
                                    {
                                        //gaikou target
                                        Color gaikouColor = new Color(80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f);
                                        tmpKamonObj.GetComponent <Image>().color = gaikouColor;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Color noSubKuniColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f);
                        tmpKuniObj.GetComponent <Image>().color = noSubKuniColor;

                        tmpKamonObj.SetActive(false);
                    }
                }
            }

            /*
             * string kuniMapPath = "Prefabs/Map/cyouhou/kuniImage";
             * GameObject mainMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject;
             * mainMap.transform.SetParent(board.transform);
             * mainMap.transform.localScale = new Vector2 (13, 9);
             * mainMap.name = "kuniMap" + kuniId;
             * string kuniImagePath = "Prefabs/Map/kuniMap/" + kuniId.ToString ();
             * mainMap.GetComponent<Image> ().sprite =
             *  Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite;
             *
             * int baseX = kuni.getKuniLocationX (kuniId);
             * int baseY = kuni.getKuniLocationY (kuniId);
             * int adjstX = baseX * -1;
             * int adjustY = baseY * -1;
             *
             * float colorR = daimyo.getColorR (daimyoId);
             * float colorG = daimyo.getColorG (daimyoId);
             * float colorB = daimyo.getColorB (daimyoId);
             * Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f);
             * mainMap.GetComponent<Image> ().color = kuniColor;
             *
             * RectTransform mapRect = mainMap.GetComponent<RectTransform> ();
             * mapRect.anchoredPosition3D = new Vector3 (adjstX, adjustY, 0);
             *
             * //My Kuni Kamon Icon
             * string kamonBackPath ="Prefabs/Map/cyouhou/KamonBack";
             * GameObject kamonBack = Instantiate (Resources.Load (kamonBackPath)) as GameObject;
             * kamonBack.transform.SetParent (board.transform);
             * kamonBack.transform.localScale = new Vector2 (1, 1);
             * kamonBack.transform.localPosition = new Vector2(0,0);
             *
             * string kamonKuniPath = "Prefabs/Map/Kuni/" + kuniId.ToString();
             * GameObject kamonObj = Instantiate (Resources.Load (kamonKuniPath)) as GameObject;
             * kamonObj.transform.SetParent (kamonBack.transform);
             * kamonObj.transform.localScale = new Vector2 (1, 0.8f);
             * kamonObj.transform.localPosition = new Vector2(0,0);
             * kamonObj.GetComponent<Image> ().sprite =
             *  Resources.Load (imagePath, typeof(Sprite)) as Sprite;
             * kamonObj.GetComponent<Button> ().enabled = false;
             *
             *
             * //Mapping Kuni
             * Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst;
             * for (int i=0; i < kuniMst.param.Count; i++) {
             * //for (int i=0; i < targetKuniList.Count; i++) {
             *  int subKuniId = i + 1;
             *
             *  GameObject subMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject;
             *  subMap.transform.SetParent(mainMap.transform);
             *  subMap.transform.localScale = new Vector2 (1, 1);
             *  subMap.transform.localPosition = new Vector2 (0, 0);
             *
             *  subMap.name = "kuniMap" + subKuniId;
             *  string subKuniImagePath = "Prefabs/Map/kuniMap/" + subKuniId;
             *  subMap.GetComponent<Image> ().sprite =
             *      Resources.Load (subKuniImagePath, typeof(Sprite)) as Sprite;
             *
             *
             *  if (targetKuniList.Contains (subKuniId)) {
             *      //color
             *      int subDaimyoId = int.Parse (seiryokuList [subKuniId - 1]);
             *      float subColorR = daimyo.getColorR (subDaimyoId);
             *      float subColorG = daimyo.getColorG (subDaimyoId);
             *      float subColorB = daimyo.getColorB (subDaimyoId);
             *      Color subKuniColor = new Color (subColorR / 255f, subColorG / 255f, subColorB / 255f, 255f / 255f);
             *      subMap.GetComponent<Image> ().color = subKuniColor;
             *
             *      //Kamon
             *      string subKamonKuniPath = "Prefabs/Map/Kuni/" + subKuniId.ToString ();
             *      GameObject subKamonObj = Instantiate (Resources.Load (subKamonKuniPath)) as GameObject;
             *      subKamonObj.transform.SetParent (board.transform);
             *      subKamonObj.transform.localScale = new Vector2 (1, 0.8f);
             *      if (daimyoId != subDaimyoId) {
             *          string subImagePath = "Prefabs/Kamon/" + subDaimyoId.ToString ();
             *          subKamonObj.GetComponent<Image> ().sprite =
             *              Resources.Load (subImagePath, typeof(Sprite)) as Sprite;
             *
             *          //yukoudo
             *          int yukoudoValue = gaikou.getExistGaikouValue (daimyoId, subDaimyoId);
             *          string syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel";
             *          GameObject yukoudoObj = Instantiate (Resources.Load (syukoudoPath)) as GameObject;
             *          yukoudoObj.transform.SetParent (subKamonObj.transform);
             *          yukoudoObj.GetComponent<Text> ().text = yukoudoValue.ToString ();
             *          yukoudoObj.transform.localScale = new Vector2 (0.08f, 0.1f);
             *          yukoudoObj.transform.localPosition = new Vector2 (0, 26);
             *
             *      } else {
             *          subKamonObj.GetComponent<Image> ().sprite =
             *              Resources.Load (imagePath, typeof(Sprite)) as Sprite;
             *      }
             *      subKamonObj.GetComponent<Button> ().enabled = false;
             *
             *      //Kamon adjustment
             *      int subBaseX = kuni.getKuniLocationX (subKuniId);
             *      int subBaseY = kuni.getKuniLocationY (subKuniId);
             *      int subAdjstX = subBaseX - baseX;
             *      int subAdjstY = subBaseY - baseY;
             *
             *      RectTransform subMapRect = subKamonObj.GetComponent<RectTransform> ();
             *      subMapRect.anchoredPosition3D = new Vector3 (subAdjstX, subAdjstY, 0);
             *
             *      if (targetKuniId != 0) {
             *          if (targetKuniId == subKuniId) {
             *              //kassen target
             *              Color atkColor = new Color (180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
             *              subKamonObj.GetComponent<Image> ().color = atkColor;
             *          }
             *      }
             *
             *      if (snbRank > 1) {
             *          if (targetGaikouKuniId != 0) {
             *              if (targetGaikouKuniId == subKuniId) {
             *                  if (!sameDaimyoFlg) {
             *                      //gaikou target
             *                      Color gaikouColor = new Color (80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f);
             *                      subKamonObj.GetComponent<Image> ().color = gaikouColor;
             *                  }
             *              }
             *          }
             *      }
             *  } else {
             *      Color noSubKuniColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f);
             *      subMap.GetComponent<Image> ().color = noSubKuniColor;
             *  }
             *
             * }
             *
             */
        }
    }
예제 #19
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);
        }
    }
예제 #20
0
    public int getGaikouTargetKuni(int srcKuniId, int srcDaimyoId, List <int> targetKuniList, GameObject kuniIconView, bool aggressiveFlg, List <string> seiryokuList, int myDaimyoId)
    {
        //Yukoudo Check
        int    bestGaikouDaimyo  = 0;
        int    bestGaikouValue   = 0;
        int    bestGaikouKuni    = 0;
        int    bestHeiryokuValue = 0;
        Gaikou gaikou            = new Gaikou();

        for (int k = 0; k < targetKuniList.Count; k++)
        {
            SendParam sendParam = kuniIconView.transform.FindChild(targetKuniList [k].ToString()).GetComponent <SendParam> ();

            if (aggressiveFlg)
            {
                //Find best gaikou daimyo

                int dstDaimyoId = int.Parse(seiryokuList [targetKuniList [k] - 1]);
                int gaikouValue = 0;

                if (srcDaimyoId != dstDaimyoId)
                {
                    if (dstDaimyoId == myDaimyoId)
                    {
                        //Get Gaikou Value

                        string eGaikouM = "gaikou" + srcDaimyoId;
                        gaikouValue = PlayerPrefs.GetInt(eGaikouM);
                    }
                    else
                    {
                        //Gaikou Data Check
                        string gaikouTemp = "";
                        if (srcDaimyoId < dstDaimyoId)
                        {
                            gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId;
                        }
                        else
                        {
                            gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId;
                        }

                        if (PlayerPrefs.HasKey(gaikouTemp))
                        {
                            //exsit
                            gaikouValue = PlayerPrefs.GetInt(gaikouTemp);
                        }
                        else
                        {
                            //non exist
                            //gaikou check
                            gaikouValue = gaikou.getGaikouValue(srcDaimyoId, dstDaimyoId);
                        }
                    }

                    //Compare with Previous one
                    //Best one
                    if (gaikouValue >= bestGaikouValue)
                    {
                        bestGaikouValue  = gaikouValue;
                        bestGaikouDaimyo = dstDaimyoId;
                        bestGaikouKuni   = targetKuniList [k];
                    }
                }
            }
            else
            {
                //Find best heiryoku daimyo
                int dstDaimyoId = int.Parse(seiryokuList [targetKuniList [k] - 1]);

                if (srcDaimyoId != dstDaimyoId)
                {
                    //Heiryoku Check
                    int heiryoku = sendParam.heiryoku;

                    //Compare with Previous one
                    if (heiryoku >= bestHeiryokuValue)
                    {
                        bestHeiryokuValue = heiryoku;

                        int gaikouValue = 0;
                        if (dstDaimyoId == myDaimyoId)
                        {
                            //Get Gaikou Value
                            string eGaikouM = "gaikou" + srcDaimyoId;
                            gaikouValue = PlayerPrefs.GetInt(eGaikouM);
                        }
                        else
                        {
                            //Gaikou Data Check
                            string gaikouTemp = "";
                            if (srcDaimyoId < dstDaimyoId)
                            {
                                gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId;
                            }
                            else
                            {
                                gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId;
                            }
                            if (PlayerPrefs.HasKey(gaikouTemp))
                            {
                                //exsit
                                gaikouValue = PlayerPrefs.GetInt(gaikouTemp);
                            }
                            else
                            {
                                //non exist
                                gaikouValue = gaikou.getGaikouValue(srcDaimyoId, dstDaimyoId);
                            }
                        }
                        bestGaikouValue  = gaikouValue;
                        bestGaikouDaimyo = dstDaimyoId;
                        bestGaikouKuni   = targetKuniList [k];
                    }
                }
            }
        }        //Loop End

        return(bestGaikouKuni);
    }
예제 #21
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);
        }
    }
예제 #22
0
    // 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();
        }
    }
예제 #23
0
	// 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) {
				if (name == "DoMitsugiBtn") {
					reduceMoneyHyourou ();

					//Doumei
					bool doumeiFlg = closeScript.doumeiFlg;

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


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

					string tempGaikou = "gaikou" + daimyoId;
					int nowYukoudo = 0;
					if (PlayerPrefs.HasKey (tempGaikou)) {
						nowYukoudo = PlayerPrefs.GetInt (tempGaikou);
					} else {
						nowYukoudo = 50;
					}
					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;

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

					//Message
					string OKtext = daimyoName + "に金" + paiedMoney + "の貢物をしました。\n友好度が" + addYukoudo + "上がりますぞ。";
					msg.makeMessage (OKtext);

					PlayerPrefs.Flush ();

				} else if (name == "DoDoumeiBtn") {
			
					reduceMoneyHyourou ();

					//Doumei
					float percent = Random.value;
					percent = percent * 100;
					
					if(percent <= doumeiRatio){
						//Doumei Success
						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;
							}
						}

						//Msg
						string OKtext = "御目出度う存じまする。\n" + daimyoName + "殿と同盟致しました。\n戦略の幅が拡がりますな。";
						msg.makeMessage (OKtext);

						Destroy(GameObject.Find("smallBoard(Clone)"));
						Destroy(GameObject.Find("TouchBack(Clone)"));

					}else{
						//Doumie Failed
						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 = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。";
						msg.makeMessage (NGtext);

						//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){

						//Success
						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());
						}
						Debug.Log (playerKyoutouList);
						PlayerPrefs.SetString("playerKyoutouList",playerKyoutouList);

						//Msg
						string OKtext = daimyoName + "殿が" + kuniName + "攻めに加勢してくれますぞ。\n百人力ですな。";
						msg.makeMessage (OKtext);


					}else{
						//Fail

						//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 = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。";
						msg.makeMessage (NGtext);

					}

					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
						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;
							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
						string OKtext = "御屋形様、恫喝に成功しましたぞ。\n"+daimyoName + "が";
						string addText = "";
						if(moneyOrItem==0){
							addText = "金" + getMoney + "を送って参りました。\n";
						}else{
							if(kahouOrShizai==0){
								//kahou
								addText = "家宝、" + kahouName + "を送って参りました。\n";
							}else{
								//shizai+
								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 = "友好度が" + reduceYukoudo + "下がりますぞ。";

						OKtext = OKtext + addText + reducceText;
						msg.makeMessage (OKtext);
						
					}else{
						//Failed
						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 = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo +  "下がりますぞ。";
						msg.makeMessage (NGtext);
					}
					
					PlayerPrefs.Flush();
					
					//Back
					GameObject.Find ("return").GetComponent<MenuReturn> ().OnClick ();

				}

			} else {
				//Message
				string NGtext = "御屋形様、金が不足しておりますぞ。";
				msg.makeMessage (NGtext);
			
			}
		} else {
			//Message
			string NGtext = "御屋形様、兵糧が不足しておりますぞ。";
			msg.makeMessage (NGtext);
		}
	}
예제 #24
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        if (name == "YesButton")
        {
            audioSources [3].Play();

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

            Gaikou gaikou     = new Gaikou();
            int    addYukoudo = 0;
            if (GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQtyIsBiggestFlg)
            {
                addYukoudo = 10;
            }
            int upYukoudo = UnityEngine.Random.Range(5, 20) + addYukoudo;
            gaikou.upOtherGaikouValue(int.Parse(daimyoId), int.Parse(daimyoId2), upYukoudo);

            //Message & Close
            GameObject.Find("bakuhuReturn").GetComponent <BakuhuMenuReturn>().OnClick();
            Message msg    = new Message();
            string  OKtext = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                OKtext = "Friendship between " + daimyoName + " and " + daimyoName2 + " increased " + upYukoudo.ToString() + " point.";
            }
            else
            {
                OKtext = daimyoName + "殿と" + daimyoName2 + "殿の友好関係が" + upYukoudo.ToString() + "上昇しましたぞ。";
            }
            msg.makeMessageOnBoard(OKtext);
        }
        else if (name == "NoButton")
        {
            audioSources [1].Play();

            //Reset
            foreach (Transform obj in btnContent.transform)
            {
                Destroy(obj.gameObject);
            }

            Color unSelect = new Color(255f / 255f, 255f / 255f, 255f / 255f, 100f / 255f);
            foreach (Transform obj in uprContent.transform)
            {
                obj.GetComponent <Image> ().color = unSelect;
            }

            string     cyusaiTxtPath = "Prefabs/Bakuhu/CyusaiText";
            GameObject cTxt          = Instantiate(Resources.Load(cyusaiTxtPath)) as GameObject;
            cTxt.transform.SetParent(btnContent.transform);
            cTxt.transform.localScale = new Vector2(0.12f, 0.15f);
            cTxt.name = "CyusaiText";
        }

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