//Check whether can attacked Kuni trace to doumei Diamyo public List<string> traceNeighborDaimyo(int attackedKuniId, int attackedDaimyoId, List<string> doumeiDaimyoList, List<string>seiryokuList, List<string>checkedList, List<string> okDaimyoList){ List<int> nKuniList = new List<int>(); KuniInfo kuni = new KuniInfo (); nKuniList = kuni.getMappingKuni(attackedKuniId); for (int i=0; i<nKuniList.Count; i++) { string tempDaimyoId = seiryokuList[nKuniList[i]-1]; if(!checkedList.Contains(nKuniList[i].ToString())){ checkedList.Add(nKuniList[i].ToString()); if(doumeiDaimyoList.Contains(tempDaimyoId)){ //found if(!okDaimyoList.Contains(tempDaimyoId)){ //no duplication okDaimyoList.Add(tempDaimyoId); } }else{ //not found if(int.Parse(tempDaimyoId) == attackedDaimyoId){ okDaimyoList = traceNeighborDaimyo(nKuniList[i], attackedDaimyoId, doumeiDaimyoList, seiryokuList, checkedList,okDaimyoList); } } } } return okDaimyoList; }
//Check whether can attacked Kuni trace to doumei Diamyo public List <string> traceNeighborDaimyo(int attackedKuniId, int attackedDaimyoId, List <string> doumeiDaimyoList, List <string> seiryokuList, List <string> checkedList, List <string> okDaimyoList) { List <int> nKuniList = new List <int>(); KuniInfo kuni = new KuniInfo(); nKuniList = kuni.getMappingKuni(attackedKuniId); for (int i = 0; i < nKuniList.Count; i++) { string tempDaimyoId = seiryokuList[nKuniList[i] - 1]; if (!checkedList.Contains(nKuniList[i].ToString())) { checkedList.Add(nKuniList[i].ToString()); if (doumeiDaimyoList.Contains(tempDaimyoId)) { //found if (!okDaimyoList.Contains(tempDaimyoId)) { //no duplication okDaimyoList.Add(tempDaimyoId); } } else { //not found if (int.Parse(tempDaimyoId) == attackedDaimyoId) { okDaimyoList = traceNeighborDaimyo(nKuniList[i], attackedDaimyoId, doumeiDaimyoList, seiryokuList, checkedList, okDaimyoList); } } } } return(okDaimyoList); }
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)); } }
public void upYukoudo(int addYukoudo){ //Daimyo Id int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); //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 == myDaimyoId.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) 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 != myDaimyoId){ if(!dstDaimyoList.Contains(tempDaimyoId)){ dstDaimyoList.Add(tempDaimyoId); } } } //Add Yukoudo MainEventHandler main = new MainEventHandler(); Daimyo daimyo = new Daimyo(); string cyouteiText = ""; for(int l=0; l<dstDaimyoList.Count;l++){ int dstDaimyoId = dstDaimyoList[l]; string dstDaimyoName = daimyo.getName(dstDaimyoId); string tempGaikou = "gaikou" + dstDaimyoId; 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); cyouteiText = cyouteiText + dstDaimyoName + "との友好度が" + addYukoudo + "上がりました。\t"; } PlayerPrefs.Flush(); //Message Message msg = new Message (); string OKtext = "周辺大名との友好度が上がります。\t " + cyouteiText; msg.makeMessage (OKtext); }
public void kuniScrollView(GameObject baseObj, string targetDaimyo, GameObject btn){ GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject; string seiryoku = PlayerPrefs.GetString ("seiryoku"); char[] delimiterChars = {','}; List<string> seiryokuList = new List<string>(); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); //my kuni int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); string myKuni = PlayerPrefs.GetString ("clearedKuni"); List<int> myKuniList = new List<int>(); if (myKuni.Contains (",")) { List<string> tempMyKuniList = new List<string> (myKuni.Split (delimiterChars)); myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x)); } else { myKuniList.Add(int.Parse(myKuni)); } //doumei daimyo's opne kuni KuniInfo kuni = new KuniInfo (); List<int> doumeiOpenKuniList = new List<int>(); List<int> doumeiKuniList = new List<int>(); for(int i=0; i<seiryokuList.Count; i++){ string tempDaimyo = seiryokuList[i]; if(tempDaimyo == targetDaimyo){ int doumeiKuniId = i + 1; doumeiKuniList.Add(doumeiKuniId); doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId)); } } //"doumei daimyo's opne kuni" minus "my kuni" List<int> doumeiOpenKuniMinusMyKuniList = new List<int>(); foreach(int n in doumeiOpenKuniList){ if(!myKuniList.Contains(n)){ doumeiOpenKuniMinusMyKuniList.Add(n); } } //"doumei daimyo's doumei check string tempDoumei = "doumei" + targetDaimyo; string doumei = PlayerPrefs.GetString (tempDoumei); List<string> doumeiList = new List<string>(); if (doumei.Contains (",")) { doumeiList = new List<string> (doumei.Split (delimiterChars)); } else { doumeiList.Add(doumei); } if (doumei != null && doumei != "") { for(int t=0; t<doumeiOpenKuniMinusMyKuniList.Count; t++){ //foreach (int n in doumeiOpenKuniMinusMyKuniList) { string checkDaimyoId = seiryokuList [doumeiOpenKuniMinusMyKuniList[t] - 1]; if (doumeiList.Contains (checkDaimyoId)) { doumeiOpenKuniMinusMyKuniList.Remove (doumeiOpenKuniMinusMyKuniList[t]); } } } //Compare "doumei open" with "my open" string myOpenKuni = PlayerPrefs.GetString ("openKuni"); List<int> myOpenKuniList = new List<int>(); if (myOpenKuni.Contains (",")) { List<string> tempMyOpenKuniList = new List<string> (myOpenKuni.Split (delimiterChars)); myOpenKuniList = tempMyOpenKuniList.ConvertAll(x => int.Parse(x)); } else { myOpenKuniList.Add(int.Parse(myOpenKuni)); } List<int> sameTargetKuniList = new List<int>(); foreach(int n in myOpenKuniList){ if(doumeiOpenKuniMinusMyKuniList.Contains(n)){ if(!doumeiKuniList.Contains(n)){ sameTargetKuniList.Add(n); } } } /*Slot making*/ string temp = "gaikou" + targetDaimyo; int myYukoudo = PlayerPrefs.GetInt(temp); //Get Chiryaku Entity_daimyo_mst daimyoMst = Resources.Load ("Data/daimyo_mst") as Entity_daimyo_mst; int myDaimyoBusyoId = daimyoMst.param [myDaimyo - 1].busyoId; StatusGet sts = new StatusGet(); int lv = PlayerPrefs.GetInt (myDaimyoBusyoId.ToString()); float chiryaku = (float)sts.getDfc(myDaimyoBusyoId,lv); chiryaku = chiryaku *10; string slotPath = "Prefabs/Map/common/kuniSlot"; for (int i=0; i<sameTargetKuniList.Count; i++) { GameObject prefab = Instantiate (Resources.Load (slotPath)) as GameObject; prefab.transform.SetParent(content.transform); prefab.transform.localScale = new Vector3 (1, 1, 1); int kuniId = sameTargetKuniList[i]; int daimyoId = int.Parse (seiryokuList [kuniId - 1]); string daimyoName = daimyoMst.param [daimyoId - 1].daimyoName; string theirYukouTemp = ""; if(int.Parse(targetDaimyo) < daimyoId){ theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString(); }else{ theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo; } int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp); string kuniName = kuni.getKuniName(kuniId); prefab.transform.FindChild("KuniValue").GetComponent<Text>().text = kuniName; prefab.transform.FindChild("DaimyoValue").GetComponent<Text>().text = daimyoName; prefab.GetComponent<GaikouKuniSelect>().Content = content; prefab.GetComponent<GaikouKuniSelect>().Btn = btn; prefab.GetComponent<GaikouKuniSelect>().myYukoudo = myYukoudo; prefab.GetComponent<GaikouKuniSelect>().chiryaku = (int)chiryaku; prefab.GetComponent<GaikouKuniSelect>().kuniDiff = kuniDiff; prefab.GetComponent<GaikouKuniSelect>().theirYukoudo = theirYukoudo; prefab.GetComponent<GaikouKuniSelect>().kuniName = kuniName; prefab.GetComponent<GaikouKuniSelect>().targetKuniId = kuniId; if(i == 0){ prefab.GetComponent<GaikouKuniSelect>().OnClick(); } } if (sameTargetKuniList.Count == 0) { string msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg"; GameObject msg = Instantiate (Resources.Load (msgPath)) as GameObject; msg.transform.SetParent(GameObject.Find("scroll").transform); msg.transform.localScale = new Vector3 (0.17f, 0.2f, 1); RectTransform msgTransform = msg.GetComponent<RectTransform> (); msgTransform.anchoredPosition = new Vector3 (-260, -115, 0); GameObject a = baseObj.transform.FindChild ("RequiredMoney").gameObject; GameObject b = baseObj.transform.FindChild ("KyoutouRatio").gameObject; Destroy(a); Destroy(b); btn.GetComponent<Button>().enabled = false; } }
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; * } * * } * */ } }
public void upYukoudo(int addYukoudo) { //Daimyo Id int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); //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 == myDaimyoId.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) 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 != myDaimyoId) { if (!dstDaimyoList.Contains(tempDaimyoId)) { dstDaimyoList.Add(tempDaimyoId); } } } //Add Yukoudo MainEventHandler main = new MainEventHandler(); Daimyo daimyo = new Daimyo(); string cyouteiText = ""; for (int l = 0; l < dstDaimyoList.Count; l++) { int dstDaimyoId = dstDaimyoList[l]; string dstDaimyoName = daimyo.getName(dstDaimyoId); string tempGaikou = "gaikou" + dstDaimyoId; 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); if (Application.systemLanguage != SystemLanguage.Japanese) { cyouteiText = cyouteiText + "Friendship with " + dstDaimyoName + " increased " + addYukoudo + " point\n"; } else { cyouteiText = cyouteiText + dstDaimyoName + "との友好度が" + addYukoudo + "上がりました。\n"; } } PlayerPrefs.Flush(); //Message Message msg = new Message(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Friendship with surrounded families increased.\n " + cyouteiText; } else { OKtext = "周辺大名との友好度が上がります。\n " + cyouteiText; } msg.makeMessage(OKtext); }
//Asset Manager //public AssetBundleManager assetBundleManager; //public Image image; //public IEnumerator Start() { // //assetBundleManager = GameObject.Find("AssetManager").GetComponent<AssetBundleManager>(); // // yield return StartCoroutine(assetBundleManager.LoadAssetBundleCoroutine()); // //} public void OnClick() { cyouhouSnbRankId = transform.parent.gameObject.transform.FindChild("close").GetComponent <CloseBoard>().cyouhouSnbRankId; //SE sound = GameObject.Find("SEController").GetComponent <AudioSource> (); sound.PlayOneShot(sound.clip); /*Common Process*/ string pathOfBoard = "Prefabs/Map/Popup"; GameObject board = Instantiate(Resources.Load(pathOfBoard)) as GameObject; board.transform.parent = GameObject.Find("Map").transform; board.transform.localScale = new Vector2(1, 0.8f); board.transform.localPosition = new Vector2(0, 0); board.name = "AttackStagePopup"; Daimyo daimyo = new Daimyo(); char[] delimiterChars = { ',' }; if (Application.loadedLevelName == "tutorialMain") { board.transform.FindChild("board").transform.FindChild("close").gameObject.SetActive(false); } /*Indivisual Process by Kuni*/ string pathOfKuniMap = "Prefabs/Map/stage/kuniMap"; GameObject kuniMap = Instantiate(Resources.Load(pathOfKuniMap)) as GameObject; board.transform.FindChild("kuniName").GetComponent <Text> ().text = kuniName; string kuniImagePath = "Prefabs/Map/stage/MapSprite/stage" + kuniId.ToString(); string assetBundlePath = "stage" + kuniId.ToString(); kuniMap.GetComponent <Image> ().sprite = Resources.Load(kuniImagePath, typeof(Sprite)) as Sprite; //assetBundleManager.GetSpriteFromAssetBundle(assetBundlePath); //Asset //assetBundleManager.assetBundleCache.Unload(false); //kuni GameObject boardObj = board.transform.FindChild("board").gameObject; kuniMap.transform.SetParent(boardObj.transform); kuniMap.transform.localScale = new Vector2(9, 6); kuniMap.transform.localPosition = new Vector3(-145, 4, 0); kuniMap.name = "kuniMap" + kuniId; //Clear Stage Setting string clearedStage = "kuni" + kuniId; string clearedStageString = ""; if (Application.loadedLevelName != "tutorialMain") { clearedStageString = PlayerPrefs.GetString(clearedStage); } else { clearedStageString = "1,2,3,4,5,6,7,8,9,10"; } List <string> clearedStageList = new List <string> (); if (clearedStageString != null && clearedStageString != "") { clearedStageList = new List <string> (clearedStageString.Split(delimiterChars)); } //Data adjustment if (!clearFlg && clearedStageList.Count == 10) { clearedStageList = new List <string>(); clearedStageString = ""; PlayerPrefs.DeleteKey(clearedStage); } //Default Value Entity_stage_mst stageMst = Resources.Load("Data/stage_mst") as Entity_stage_mst; int startline = 10 * kuniId - 10; string stagePath = "Prefabs/Map/stage/stage"; string clearedPath = "Prefabs/Map/cleared"; int stageId = 1; bool clearedFlg = false; int mySenryoku = daimyo.getSenryoku(myDaimyoId); int enemySenryoku = daimyo.getSenryoku(daimyoId); float senryokuRatio = (float)enemySenryoku / (float)mySenryoku; for (int i = startline; i < startline + 10; i++) { GameObject stage = Instantiate(Resources.Load(stagePath)) as GameObject; stage.transform.SetParent(kuniMap.transform); stage.transform.localScale = new Vector2(1, 1); stage.name = "stage" + stageId.ToString(); //Cleared Check if (clearedStageList.Contains(stageId.ToString()) == true) { GameObject cleared = Instantiate(Resources.Load(clearedPath)) as GameObject; cleared.transform.SetParent(stage.transform); stage.GetComponent <ShowStageDtl> ().clearedFlg = true; cleared.transform.localScale = new Vector2(3, 5); cleared.transform.localPosition = new Vector2(0, 0); clearedFlg = true; cleared.name = "cleared"; } //Get Stage Info string stageName = ""; int locationX = stageMst.param [i].LocationX; int locationY = stageMst.param [i].LocationY; int powerType = stageMst.param [i].powerTyp; if (Application.systemLanguage != SystemLanguage.Japanese) { stageName = stageMst.param[i].stageNameEng; } else { stageName = stageMst.param[i].stageName; } RectTransform stageTransform = stage.GetComponent <RectTransform> (); stageTransform.anchoredPosition = new Vector3(locationX, locationY, 0); //money and exp calculation int minExp = getMinExp(powerType, senryokuRatio); int maxExp = getMaxExp(powerType, senryokuRatio); int exp = UnityEngine.Random.Range(minExp, maxExp + 1); int minMoney = minExp * 2; int maxMoney = maxExp * 3; int money = UnityEngine.Random.Range(minMoney, maxMoney + 1); string itemGrp = getRandomItemGrp(); string itemTyp = ""; int itemId = 0; int itemQty = 1; if (itemGrp == "item") { itemTyp = getRandomItemTyp(itemGrp); if (itemTyp == "tech") { itemId = getItemRank(66, 33); } else if (itemTyp == "Tama") { itemId = getItemRank(20, 5); if (itemId == 3) { itemQty = 100; } else if (itemId == 2) { itemQty = 20; } else if (itemId == 1) { itemQty = 5; } } else { itemId = getItemRank(20, 5); } } else if (itemGrp == "kahou") { itemTyp = getRandomItemTyp(itemGrp); Kahou kahou = new Kahou(); string kahouRank = getKahouRank(); itemId = kahou.getRamdomKahouId(itemTyp, kahouRank); } stage.GetComponent <ShowStageDtl> ().kuniId = kuniId; stage.GetComponent <ShowStageDtl> ().stageId = stageId; stage.GetComponent <ShowStageDtl> ().stageName = stageName; stage.GetComponent <ShowStageDtl> ().exp = exp; stage.GetComponent <ShowStageDtl> ().showExp = minExp + " - " + maxExp; stage.GetComponent <ShowStageDtl> ().money = money; stage.GetComponent <ShowStageDtl> ().showMoney = minMoney + " - " + maxMoney; stage.GetComponent <ShowStageDtl> ().itemGrp = itemGrp; stage.GetComponent <ShowStageDtl> ().itemTyp = itemTyp; stage.GetComponent <ShowStageDtl> ().itemId = itemId.ToString(); stage.GetComponent <ShowStageDtl> ().itemQty = itemQty; stage.GetComponent <ShowStageDtl> ().powerType = powerType; if (powerType == 2) { string imagePath = "Prefabs/Naisei/Shiro/Sprite/shiro_m"; stage.transform.FindChild("shiroImage").GetComponent <SpriteRenderer> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; } else if (powerType == 3) { string imagePath = "Prefabs/Naisei/Shiro/Sprite/shiro_l"; stage.transform.FindChild("shiroImage").GetComponent <SpriteRenderer> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; } stageId = stageId + 1; } //Line Setting Entity_stageLink_mst stageLinkMst = Resources.Load("Data/stageLink_mst") as Entity_stageLink_mst; List <string> myStageLink = new List <string> (); for (int i = 0; i < stageLinkMst.param.Count; i++) { int tempKuniId = stageLinkMst.param[i].kuniId; if (tempKuniId == kuniId) { myStageLink.Add(stageLinkMst.param[i].Link); } } List <string> myOriginalStageLink = new List <string>(myStageLink); //Reduce Linkcut kousaku string tempLinkuct = "linkcut" + kuniId; string linkcut = PlayerPrefs.GetString(tempLinkuct); List <string> linkcutList = new List <string> (); if (linkcut != null && linkcut != "") { if (linkcut.Contains(",")) { linkcutList = new List <string> (linkcut.Split(delimiterChars)); } else { linkcutList.Add(linkcut); } } myStageLink.RemoveAll(linkcutList.Contains); char[] delimiterChars2 = { '-' }; string linkPath = "Prefabs/Map/stage/link"; for (int j = 0; j < myStageLink.Count; j++) { List <string> linkList = new List <string> (myStageLink[j].Split(delimiterChars2)); string stage1Name = linkList[0]; string stage2Name = linkList[1]; //if(!clearedStageList.Contains(stage1Name) && !clearedStageList.Contains(stage2Name)){ //1st string temp1 = "stage" + stage1Name; GameObject stage1 = kuniMap.transform.FindChild(temp1).gameObject; RectTransform rectStage1 = stage1.GetComponent <RectTransform>(); Vector3 vect1 = new Vector3(rectStage1.anchoredPosition.x, rectStage1.anchoredPosition.y, 0); //2nd string temp2 = "stage" + stage2Name; GameObject stage2 = kuniMap.transform.FindChild(temp2).gameObject; RectTransform rectStage2 = stage2.GetComponent <RectTransform>(); Vector3 vect2 = new Vector3(rectStage2.anchoredPosition.x, rectStage2.anchoredPosition.y, 0); //Set GameObject link = Instantiate(Resources.Load(linkPath)) as GameObject; link.transform.SetParent(kuniMap.transform); link.transform.localScale = new Vector2(1, 1); RectTransform linkRectTransform = link.GetComponent <RectTransform>(); linkRectTransform.anchoredPosition = new Vector3(0, 0, 0); link.GetComponent <LineRenderer>().SetPosition(0, vect1); link.GetComponent <LineRenderer>().SetPosition(1, vect2); if (!clearedStageList.Contains(stage1Name) && !clearedStageList.Contains(stage2Name)) { //Line No stage1.GetComponent <ShowStageDtl>().linkNo = stage1.GetComponent <ShowStageDtl>().linkNo + 1; stage2.GetComponent <ShowStageDtl>().linkNo = stage2.GetComponent <ShowStageDtl>().linkNo + 1; } //Name link.name = "link" + stage1Name + "-" + stage2Name; } //Battle Initial Setting StartKassen sk = GameObject.Find("BattleButton").GetComponent <StartKassen> (); sk.activeBusyoQty = activeBusyoQty; sk.activeBusyoLv = activeBusyoLv; sk.activeButaiQty = activeButaiQty; sk.activeButaiLv = activeButaiLv; sk.activeDaimyoId = daimyoId; sk.doumeiFlg = doumeiFlg; /*Naisei Button*/ string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string>(); seiryokuList = new List <string>(seiryoku.Split(delimiterChars)); //Only for all clear if (clearFlg) { string naiseiPath = "Prefabs/Map/NaiseiButton"; GameObject naiseiBtn = Instantiate(Resources.Load(naiseiPath)) as GameObject; naiseiBtn.transform.SetParent(board.transform); naiseiBtn.GetComponent <StartNaisei> ().activeKuniId = kuniId; naiseiBtn.GetComponent <StartNaisei> ().activeKuniName = kuniName; naiseiBtn.GetComponent <StartNaisei> ().clearedFlg = clearedFlg; naiseiBtn.transform.localScale = new Vector2(0.4f, 0.4f); naiseiBtn.transform.localPosition = new Vector2(-490, -300); if (Application.systemLanguage != SystemLanguage.Japanese) { boardObj.transform.FindChild("stageDtl").transform.FindChild("BattleButton").transform.FindChild("Text").GetComponent <Text> ().text = "Training"; } else { boardObj.transform.FindChild("stageDtl").transform.FindChild("BattleButton").transform.FindChild("Text").GetComponent <Text>().text = "訓練"; } GameObject firstStage = GameObject.Find("stage1"); firstStage.GetComponent <ShowStageDtl>().OnClick(); if (Application.loadedLevelName == "tutorialMain") { GameObject battleBtnObj = boardObj.transform.FindChild("stageDtl").transform.FindChild("BattleButton").gameObject; battleBtnObj.GetComponent <Button>().interactable = false; battleBtnObj.transform.FindChild("Text").GetComponent <Text>().color = new Color(220f / 255f, 190f / 255f, 40f / 255f, 100f / 255f); TutorialController tutorialScript = new TutorialController(); Vector2 vect = new Vector2(0, 100); GameObject animObj = tutorialScript.SetPointer(naiseiBtn, vect); animObj.transform.localScale = new Vector2(300, 300); } } else { //enemy attack GameObject closeObj = boardObj.transform.FindChild("close").gameObject; EnemyEventHandler enemyEvent = board.transform.FindChild("board").GetComponent <EnemyEventHandler>(); enemyEvent.doEnemyEvent(kuniMap, closeObj, kuniId, daimyoId, activeBusyoQty, activeBusyoLv, activeButaiQty, activeButaiLv); //open shiro List <int> closeStageIdList = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; //compare linkKuni with mySeiryoku List <int> linkKuniList = new List <int>(); List <int> linkMyKuniList = new List <int>(); KuniInfo kuniScript = new KuniInfo(); linkKuniList = kuniScript.getMappingKuni(kuniId); for (int i = 0; i < linkKuniList.Count; i++) { int linkKuniId = linkKuniList[i]; if (seiryokuList[linkKuniId - 1] == myDaimyoId.ToString()) { linkMyKuniList.Add(linkKuniId); } } //open initial stage for (int j = 0; j < linkMyKuniList.Count; j++) { int srcKuniId = linkMyKuniList[j]; string linkStage = kuniScript.getLinkStage(srcKuniId, kuniId); linkStage = linkStage.Replace("stage", ""); List <int> linkStageList = new List <int>(Array.ConvertAll(linkStage.Split(','), new Converter <string, int>((s) => { return(Convert.ToInt32(s)); }))); closeStageIdList.RemoveAll(linkStageList.Contains); } //open cleared kuni & linked stage List <int> clearedStageIntList = clearedStageList.ConvertAll(x => int.Parse(x)); closeStageIdList.RemoveAll(clearedStageIntList.Contains); for (int l = 0; l < clearedStageIntList.Count; l++) { int srcStageId = clearedStageIntList[l]; for (int m = 0; m < myOriginalStageLink.Count; m++) { List <string> linkList = new List <string>(myOriginalStageLink[m].Split(delimiterChars2)); int stage1Id = int.Parse(linkList[0]); int stage2Id = int.Parse(linkList[1]); if (srcStageId == stage1Id) { if (!getStageGunzeiExistFlg(stage1Id, stage2Id)) { closeStageIdList.Remove(stage2Id); } } else if (srcStageId == stage2Id) { if (!getStageGunzeiExistFlg(stage2Id, stage1Id)) { closeStageIdList.Remove(stage1Id); } } } } Color closeColor = new Color(60f / 255f, 60f / 255f, 60f / 255f, 255f / 255f); //Black for (int k = 0; k < closeStageIdList.Count; k++) { int closeStageId = closeStageIdList[k]; string stageName = "stage" + closeStageId.ToString(); GameObject closeStageObj = kuniMap.transform.FindChild(stageName).gameObject; closeStageObj.GetComponent <Button>().enabled = false; closeStageObj.transform.FindChild("shiroImage").GetComponent <SpriteRenderer>().color = closeColor; } //Initial Setting int initStageId = 1; for (int i = 1; i <= 10; i++) { if (!closeStageIdList.Contains(i)) { initStageId = i; } } string initStageName = "stage" + initStageId.ToString(); GameObject firstStage = GameObject.Find(initStageName); firstStage.GetComponent <ShowStageDtl>().OnClick(); } //Kousaku if (!clearFlg) { string pathOfScroll = "Prefabs/Map/kousaku/BusyoSelectScroll"; GameObject scroll = Instantiate(Resources.Load(pathOfScroll)) as GameObject; scroll.transform.SetParent(board.transform); scroll.transform.localScale = new Vector2(1, 1); RectTransform rectScroll = scroll.GetComponent <RectTransform> (); rectScroll.anchoredPosition3D = new Vector3(410, 0, 0); rectScroll.sizeDelta = new Vector2(300, 750); scroll.name = "BusyoSelectScroll"; scroll.SetActive(false); KousakuConfirm kousakuScript = GameObject.Find("LinkCutButton").GetComponent <KousakuConfirm> (); kousakuScript.cyouhouSnbRankId = cyouhouSnbRankId; kousakuScript.scrollObj = scroll; KousakuConfirm kousakuScript2 = GameObject.Find("CyouryakuButton").GetComponent <KousakuConfirm> (); kousakuScript2.cyouhouSnbRankId = cyouhouSnbRankId; kousakuScript2.scrollObj = scroll; } else { GameObject LinkCutButton = GameObject.Find("LinkCutButton").gameObject; LinkCutButton.GetComponent <Button> ().interactable = false; LinkCutButton.transform.FindChild("Text").GetComponent <Text> ().color = new Color(220f / 255f, 190f / 255f, 40f / 255f, 100f / 255f); GameObject CyouryakuButton = GameObject.Find("CyouryakuButton").gameObject; CyouryakuButton.GetComponent <Button> ().interactable = false; CyouryakuButton.transform.FindChild("Text").GetComponent <Text> ().color = new Color(220f / 255f, 190f / 255f, 40f / 255f, 100f / 255f); } /*Kassen Event Controller Start*/ KassenEvent kEvent = new KassenEvent(); kEvent.MakeEvent(clearFlg, kuniId, kuniMap, daimyoId); viewKuniLink(board, kuniMap, seiryokuList); /*Kassen Event Controller End*/ }
public void OnClick() { int hyourou = PlayerPrefs.GetInt("hyourou"); AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (name == "AtkOrderBtn") { if (hyourou >= 10) { audioSources [0].Play(); //Common //Back string returnPath = "Prefabs/Bakuhu/Return"; GameObject returnObj = Instantiate(Resources.Load(returnPath)) as GameObject; returnObj.transform.SetParent(board.transform); returnObj.transform.localScale = new Vector2(1, 1); returnObj.transform.localPosition = new Vector2(-560, 290); returnObj.name = "bakuhuReturn"; //Disabled scrollView.SetActive(false); //Base Obj string basePath = "Prefabs/Bakuhu/Base"; GameObject baseObj = Instantiate(Resources.Load(basePath)) as GameObject; baseObj.transform.SetParent(board.transform); baseObj.transform.localScale = new Vector2(1, 1); baseObj.name = "BakuhuBase"; returnObj.GetComponent <BakuhuMenuReturn> ().deleteObj = baseObj; returnObj.GetComponent <BakuhuMenuReturn> ().scrollView = scrollView; returnObj.GetComponent <BakuhuMenuReturn> ().board = board; if (Application.systemLanguage != SystemLanguage.Japanese) { board.transform.FindChild("popText").GetComponent <Text> ().text = "Attack Order"; } else { board.transform.FindChild("popText").GetComponent <Text>().text = "討伐令"; } string textPath = "Prefabs/Bakuhu/ToubatsuText"; GameObject textObj = Instantiate(Resources.Load(textPath)) as GameObject; textObj.transform.SetParent(baseObj.transform); textObj.transform.localScale = new Vector2(0.12f, 0.15f); textObj.transform.localPosition = new Vector2(0, 206); textObj.name = "ToubatsuText"; //View daimyo kuni string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); string kuniPath = "Prefabs/Map/Kuni/"; Entity_kuni_mst kuniMst = Resources.Load("Data/kuni_mst") as Entity_kuni_mst; Entity_daimyo_mst daimyoMst = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst; int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); string kuniIconPath = "Prefabs/Bakuhu/BakuhuKuniMap"; GameObject kuniMapView = Instantiate(Resources.Load(kuniIconPath)) as GameObject; kuniMapView.transform.SetParent(baseObj.transform); kuniMapView.transform.localScale = new Vector2(0.8f, 0.65f); string kuniMapPath = "Prefabs/Bakuhu/BakuhuKuniIconView"; GameObject kuniIconView = Instantiate(Resources.Load(kuniMapPath)) as GameObject; kuniIconView.transform.SetParent(baseObj.transform); kuniIconView.transform.localScale = new Vector2(0.8f, 0.65f); kuniIconView.name = "BakuhuKuniIconView"; List <int> kuniQtyByDaimyoId = new List <int> () { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int myKuniQty = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQty; bool myKuniQtyIsBiggestFlg = true; for (int i = 0; i < kuniMst.param.Count; i++) { int kuniId = kuniMst.param [i].kunId; string newKuniPath = kuniPath + kuniId.ToString(); int locationX = kuniMst.param [i].locationX; int locationY = kuniMst.param [i].locationY; GameObject kuni = Instantiate(Resources.Load(newKuniPath)) as GameObject; kuni.transform.SetParent(kuniIconView.transform); kuni.name = kuniId.ToString(); kuni.transform.localScale = new Vector2(1, 1); //Seiryoku Handling int daimyoId = int.Parse(seiryokuList [kuniId - 1]); if (daimyoId == myDaimyo) { kuni.SetActive(false); float colorR = (float)daimyoMst.param [daimyoId - 1].colorR; float colorG = (float)daimyoMst.param [daimyoId - 1].colorG; float colorB = (float)daimyoMst.param [daimyoId - 1].colorB; Color kuniColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); kuniMapView.transform.FindChild(kuni.name).GetComponent <Image> ().color = kuniColor; } else { Daimyo daimyoScript = new Daimyo(); string daimyoName = daimyoScript.getName(daimyoId); kuni.GetComponent <SendParam> ().bakuhuFlg = true; kuni.GetComponent <SendParam> ().kuniId = kuniId; kuni.GetComponent <SendParam> ().daimyoId = daimyoId; kuni.GetComponent <SendParam> ().daimyoName = daimyoName; int daimyoBusyoIdTemp = daimyoMst.param [daimyoId - 1].busyoId; kuni.GetComponent <SendParam> ().daimyoBusyoId = daimyoBusyoIdTemp; /*Kuni Qty Start*/ int kuniQty = 0; if (kuniQtyByDaimyoId [daimyoId - 1] == 0) { kuniQty = getKuniQty(daimyoId, seiryokuList); kuniQtyByDaimyoId [daimyoId - 1] = kuniQty; } else { kuniQty = kuniQtyByDaimyoId [daimyoId - 1]; } kuni.GetComponent <SendParam> ().kuniQty = kuniQty; if (kuniQty >= myKuniQty) { myKuniQtyIsBiggestFlg = false; } /*Kuni Qty End*/ //Color Handling float colorR = (float)daimyoMst.param [daimyoId - 1].colorR; float colorG = (float)daimyoMst.param [daimyoId - 1].colorG; float colorB = (float)daimyoMst.param [daimyoId - 1].colorB; Color kuniColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); kuniMapView.transform.FindChild(kuni.name).GetComponent <Image> ().color = kuniColor; //Daimyo Kamon Image string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString(); kuni.GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; RectTransform kuniTransform = kuni.GetComponent <RectTransform> (); kuniTransform.anchoredPosition = new Vector3(locationX, locationY, 0); } } returnObj.GetComponent <BakuhuMenuReturn> ().myKuniQtyIsBiggestFlg = myKuniQtyIsBiggestFlg; } else { //Hyourou NG audioSources [4].Play(); Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } else if (name == "DfcOrderBtn") { //Boueirei if (hyourou >= 10) { //Gunzei Exist Check int bakuhuTobatsuDaimyoId = PlayerPrefs.GetInt("bakuhuTobatsuDaimyoId"); bool gunzeiFlg = false; KuniInfo kuni = new KuniInfo(); string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; char[] delimiterChars2 = { ':' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); //Used Engun List List <string> dstEngunDaimyoIdList = new List <string>(); foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")) { string dstEngunDaimyoId = obs.GetComponent <Gunzei>().dstEngunDaimyoId; List <string> tmpDstEngunDaimyoIdList = new List <string>(); if (dstEngunDaimyoId != null && dstEngunDaimyoId != "") { if (dstEngunDaimyoId.Contains(":")) { tmpDstEngunDaimyoIdList = new List <string>(dstEngunDaimyoId.Split(delimiterChars2)); } else { tmpDstEngunDaimyoIdList.Add(dstEngunDaimyoId); } } dstEngunDaimyoIdList.AddRange(tmpDstEngunDaimyoIdList); } List <string> okGunzeiList = new List <string> (); //key1:engunSrcKuni1:engunSrcKuni2...,key2:engunSrcKuni1:engunSrcKuni2.... foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")) { int checkDaimyoId = obs.GetComponent <Gunzei> ().dstDaimyoId; if (checkDaimyoId != bakuhuTobatsuDaimyoId) { int dstKuni = obs.GetComponent <Gunzei> ().dstKuni; int srcDaimyoId = obs.GetComponent <Gunzei> ().srcDaimyoId; int dstDaimyoId = obs.GetComponent <Gunzei> ().dstDaimyoId; List <int> openKuniList = new List <int> (); openKuniList = kuni.getMappingKuni(dstKuni); string tmpString = ""; List <int> usedDaimyoList = new List <int> (); for (int i = 0; i < openKuniList.Count; i++) { int tmpDaimyoId = int.Parse(seiryokuList [openKuniList [i] - 1]); if (tmpDaimyoId != myDaimyo && tmpDaimyoId != srcDaimyoId && tmpDaimyoId != dstDaimyoId) { if (!usedDaimyoList.Contains(tmpDaimyoId)) { if (!dstEngunDaimyoIdList.Contains(tmpDaimyoId.ToString())) { gunzeiFlg = true; usedDaimyoList.Add(tmpDaimyoId); if (tmpString == "") { tmpString = obs.name + ":" + openKuniList [i]; } else { tmpString = tmpString + ":" + openKuniList [i]; } } } } } if (tmpString != "") { okGunzeiList.Add(tmpString); } } } if (gunzeiFlg) { audioSources [0].Play(); //Common //Back string returnPath = "Prefabs/Bakuhu/Return"; GameObject returnObj = Instantiate(Resources.Load(returnPath)) as GameObject; returnObj.transform.SetParent(board.transform); returnObj.transform.localScale = new Vector2(1, 1); returnObj.transform.localPosition = new Vector2(-560, 290); returnObj.name = "bakuhuReturn"; if (Application.systemLanguage != SystemLanguage.Japanese) { board.transform.FindChild("popText").GetComponent <Text> ().text = "Defence Order"; } else { board.transform.FindChild("popText").GetComponent <Text>().text = "防衛令"; } //Disabled scrollView.SetActive(false); //Base Obj string basePath = "Prefabs/Bakuhu/Base"; GameObject baseObj = Instantiate(Resources.Load(basePath)) as GameObject; baseObj.transform.SetParent(board.transform); baseObj.transform.localScale = new Vector2(1, 1); baseObj.name = "BakuhuBase"; returnObj.GetComponent <BakuhuMenuReturn> ().deleteObj = baseObj; returnObj.GetComponent <BakuhuMenuReturn> ().scrollView = scrollView; returnObj.GetComponent <BakuhuMenuReturn> ().board = board; string boubiScrollPath = "Prefabs/Bakuhu/BoueiScrollView"; GameObject boueiScrollObj = Instantiate(Resources.Load(boubiScrollPath)) as GameObject; boueiScrollObj.transform.SetParent(baseObj.transform); boueiScrollObj.transform.localScale = new Vector2(1, 1); boueiScrollObj.transform.localPosition = new Vector2(0, 0); GameObject content = boueiScrollObj.transform.FindChild("Content").gameObject; string uniSlotPath = "Prefabs/Bakuhu/BoueiSlot"; string daimyoBusyoPath = "Prefabs/Player/Sprite/unit"; Daimyo daimyo = new Daimyo(); for (int i = 0; i < okGunzeiList.Count; i++) { string tmp = okGunzeiList [i]; List <string> okGunzeiUnitList = new List <string> (); okGunzeiUnitList = new List <string> (tmp.Split(delimiterChars2)); string key = okGunzeiUnitList [0]; GameObject gunzei = GameObject.Find(key).gameObject; int dstDaimyoId = gunzei.GetComponent <Gunzei> ().dstDaimyoId; int dstDaimyoBusyoId = daimyo.getDaimyoBusyoId(dstDaimyoId); string dstDaimyoName = daimyo.getName(dstDaimyoId); int srcDaimyoId = gunzei.GetComponent <Gunzei> ().srcDaimyoId; int srcDaimyoBusyoId = daimyo.getDaimyoBusyoId(srcDaimyoId); string srcDaimyoName = daimyo.getName(srcDaimyoId); int dstKuniId = gunzei.GetComponent <Gunzei> ().dstKuni; string kuniName = kuni.getKuniName(dstKuniId); for (int j = 1; j < okGunzeiUnitList.Count; j++) { int engunKuniId = int.Parse(okGunzeiUnitList [j]); int engunDaimyoId = int.Parse(seiryokuList [engunKuniId - 1]); int engunDaimyoBusyoId = daimyo.getDaimyoBusyoId(engunDaimyoId); string engunDaimyoName = daimyo.getName(engunDaimyoId); GameObject slot = Instantiate(Resources.Load(uniSlotPath)) as GameObject; slot.transform.SetParent(content.transform); slot.transform.localScale = new Vector2(1, 1); if (Application.systemLanguage != SystemLanguage.Japanese) { slot.transform.FindChild("Kuni").GetComponent <Text> ().text = kuniName + " Defence"; } else { slot.transform.FindChild("Kuni").GetComponent <Text>().text = kuniName + "防衛"; } string dfcDaimyoPath = daimyoBusyoPath + dstDaimyoBusyoId.ToString(); slot.transform.FindChild("Dfc").transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(dfcDaimyoPath, typeof(Sprite)) as Sprite; string atkDaimyoPath = daimyoBusyoPath + srcDaimyoBusyoId.ToString(); slot.transform.FindChild("Atk").transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(atkDaimyoPath, typeof(Sprite)) as Sprite; string engnDaimyoPath = daimyoBusyoPath + engunDaimyoBusyoId.ToString(); slot.transform.FindChild("Egn").transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(engnDaimyoPath, typeof(Sprite)) as Sprite; slot.transform.FindChild("DfcName").GetComponent <Text> ().text = dstDaimyoName; slot.transform.FindChild("AtkName").GetComponent <Text> ().text = srcDaimyoName; slot.transform.FindChild("EgnName").GetComponent <Text> ().text = engunDaimyoName; if (Application.systemLanguage != SystemLanguage.Japanese) { slot.transform.FindChild("Exp").GetComponent <Text>().text = "Request " + engunDaimyoName + " for reinforcement"; } else { slot.transform.FindChild("Exp").GetComponent <Text>().text = engunDaimyoName + "に援軍の出兵支持を出す。"; } //Param GameObject btn = slot.transform.FindChild("BoueiBtn").gameObject; btn.GetComponent <DoBouei> ().key = key; btn.GetComponent <DoBouei> ().engunDaimyoId = engunDaimyoId; btn.GetComponent <DoBouei> ().engunKuniId = engunKuniId; btn.GetComponent <DoBouei> ().engunDaimyoName = engunDaimyoName; btn.GetComponent <DoBouei> ().dfcDaimyoId = dstDaimyoId; btn.GetComponent <DoBouei> ().slot = slot; btn.GetComponent <DoBouei> ().kuniName = kuniName; } } } else { audioSources [4].Play(); Message msg = new Message(); msg.makeMessageOnBoard(msg.getMessage(99)); } } else { audioSources [4].Play(); //Hyourou NG Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } else if (name == "RelationshipBtn") { //Boueirei if (hyourou >= 5) { int bakuhuTobatsuDaimyoId = PlayerPrefs.GetInt("bakuhuTobatsuDaimyoId"); //Not Last Daimyo check 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"); bool isLastDaimyoFlg = false; List <string> checkedDaimyoList = new List <string> (); foreach (string tmp in seiryokuList) { if (tmp != myDaimyo.ToString()) { if (!checkedDaimyoList.Contains(tmp)) { checkedDaimyoList.Add(tmp); } } } //include other 2 daimyos = 3 if (checkedDaimyoList.Count >= 2) { isLastDaimyoFlg = true; } if (isLastDaimyoFlg) { audioSources [0].Play(); //OK //Common //Back string returnPath = "Prefabs/Bakuhu/Return"; GameObject returnObj = Instantiate(Resources.Load(returnPath)) as GameObject; returnObj.transform.SetParent(board.transform); returnObj.transform.localScale = new Vector2(1, 1); returnObj.transform.localPosition = new Vector2(-560, 290); returnObj.name = "bakuhuReturn"; if (Application.systemLanguage != SystemLanguage.Japanese) { board.transform.FindChild("popText").GetComponent <Text> ().text = "Defence Order"; } else { board.transform.FindChild("popText").GetComponent <Text>().text = "防衛令"; } //Disabled scrollView.SetActive(false); //Base Obj string basePath = "Prefabs/Bakuhu/Base"; GameObject baseObj = Instantiate(Resources.Load(basePath)) as GameObject; baseObj.transform.SetParent(board.transform); baseObj.transform.localScale = new Vector2(1, 1); baseObj.name = "BakuhuBase"; returnObj.GetComponent <BakuhuMenuReturn> ().deleteObj = baseObj; returnObj.GetComponent <BakuhuMenuReturn> ().scrollView = scrollView; returnObj.GetComponent <BakuhuMenuReturn> ().board = board; if (Application.systemLanguage != SystemLanguage.Japanese) { board.transform.FindChild("popText").GetComponent <Text> ().text = "Mediation"; } else { board.transform.FindChild("popText").GetComponent <Text>().text = "仲裁"; } //Scroll string scrollPath = "Prefabs/Bakuhu/CyusaiScrollView"; GameObject uprScroll = Instantiate(Resources.Load(scrollPath)) as GameObject; uprScroll.transform.SetParent(baseObj.transform); uprScroll.transform.localPosition = new Vector2(0, 95); uprScroll.transform.localScale = new Vector2(1, 1); uprScroll.name = "CyusaiScrollViewUpper"; GameObject uprContent = uprScroll.transform.FindChild("Content").gameObject; GameObject btnScroll = Instantiate(Resources.Load(scrollPath)) as GameObject; btnScroll.transform.SetParent(baseObj.transform); btnScroll.transform.localPosition = new Vector2(0, -170); btnScroll.transform.localScale = new Vector2(1, 1); btnScroll.name = "CyusaiScrollViewBottom"; GameObject btnContent = btnScroll.transform.FindChild("Content").gameObject; //Upper Scroll string slotPath = "Prefabs/Bakuhu/CyusaiSlot"; Daimyo daimyo = new Daimyo(); foreach (string daimyoId in checkedDaimyoList) { GameObject uprSlot = Instantiate(Resources.Load(slotPath)) as GameObject; uprSlot.transform.SetParent(uprContent.transform); uprSlot.transform.localScale = new Vector2(1, 1); uprSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoId = daimyoId; uprSlot.GetComponent <CyusaiDaimyoSelect> ().checkedDaimyoList = checkedDaimyoList; uprSlot.GetComponent <CyusaiDaimyoSelect> ().uprContent = uprContent; uprSlot.GetComponent <CyusaiDaimyoSelect> ().btnContent = btnContent; int daimyoBusyoId = daimyo.getDaimyoBusyoId(int.Parse(daimyoId)); string daimyoName = daimyo.getName(int.Parse(daimyoId)); uprSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoName = daimyoName; string daimyoBusyoPath = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString(); uprSlot.transform.FindChild("Image").transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(daimyoBusyoPath, typeof(Sprite)) as Sprite; uprSlot.transform.FindChild("DaimyoName").GetComponent <Text> ().text = daimyoName; } 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"; } else { audioSources [4].Play(); Message msg = new Message(); msg.makeMessageOnBoard(msg.getMessage(100)); } } else { audioSources [4].Play(); //Hyourou NG Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } else if (name == "SobujiKessenBtn") { if (hyourou >= 30) { bool myKuniQtyIsTwiceFlg = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQtyIsTwiceFlg; if (myKuniQtyIsTwiceFlg) { audioSources [0].Play(); //Confirm Button //Back Cover string backPath = "Prefabs/Busyo/back"; GameObject back = Instantiate(Resources.Load(backPath)) as GameObject; back.transform.SetParent(GameObject.Find("Map").transform); back.transform.localScale = new Vector2(1, 1); RectTransform backTransform = back.GetComponent <RectTransform> (); backTransform.anchoredPosition3D = new Vector3(0, 0, 0); //Message Box GameObject soubujireiConfirmObj = Instantiate(soubujireiConfirm) as GameObject; soubujireiConfirmObj.transform.SetParent(GameObject.Find("Map").transform); soubujireiConfirmObj.transform.localScale = new Vector2(1, 1); RectTransform msgTransform = soubujireiConfirmObj.GetComponent <RectTransform> (); msgTransform.anchoredPosition3D = new Vector3(0, 0, 0); msgTransform.name = "SoubujireiConfirmObj"; GameObject YesBtn = soubujireiConfirmObj.transform.FindChild("YesButton").gameObject; GameObject NoBtn = soubujireiConfirmObj.transform.FindChild("NoButton").gameObject; YesBtn.GetComponent <DoSoubujirei> ().board = board; YesBtn.GetComponent <DoSoubujirei> ().confirm = soubujireiConfirmObj; YesBtn.GetComponent <DoSoubujirei> ().back = back; NoBtn.GetComponent <DoSoubujirei> ().confirm = soubujireiConfirmObj; NoBtn.GetComponent <DoSoubujirei> ().back = back; } else { audioSources [4].Play(); Message msg = new Message(); msg.makeMessageOnBoard(msg.getMessage(101)); } } else { audioSources [4].Play(); //Hyourou NG Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } else if (name == "KessenBtn") { if (hyourou >= hyourouNo) { audioSources [0].Play(); //Confirm Button //Back Cover string backPath = "Prefabs/Busyo/back"; GameObject back = Instantiate(Resources.Load(backPath)) as GameObject; back.transform.SetParent(GameObject.Find("Map").transform); back.transform.localScale = new Vector2(1, 1); RectTransform backTransform = back.GetComponent <RectTransform> (); backTransform.anchoredPosition3D = new Vector3(0, 0, 0); //Message Box string msgPath = "Prefabs/Bakuhu/KessenConfirm"; GameObject msg = Instantiate(Resources.Load(msgPath)) as GameObject; msg.transform.SetParent(GameObject.Find("Map").transform); msg.transform.localScale = new Vector2(1, 1); RectTransform msgTransform = msg.GetComponent <RectTransform> (); msgTransform.anchoredPosition3D = new Vector3(0, 0, 0); msgTransform.name = "KessenConfirm"; if (Application.systemLanguage != SystemLanguage.Japanese) { msg.transform.FindChild("Text").GetComponent <Text>().text = "Operate final war with " + daimyoName + "."; } else { msg.transform.FindChild("Text").GetComponent <Text>().text = daimyoName + "に決戦を仕掛けます"; } GameObject YesBtn = msg.transform.FindChild("YesButton").gameObject; GameObject NoBtn = msg.transform.FindChild("NoButton").gameObject; YesBtn.GetComponent <DoKessen> ().daimyoId = daimyoId; YesBtn.GetComponent <DoKessen> ().daimyoName = daimyoName; YesBtn.GetComponent <DoKessen> ().kuniId = kuniId; YesBtn.GetComponent <DoKessen> ().needHyourouNo = hyourouNo; NoBtn.GetComponent <DoKessen> ().confirm = msg; NoBtn.GetComponent <DoKessen> ().back = back; YesBtn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text> ().text = hyourouNo.ToString(); } else { audioSources [4].Play(); //Hyourou NG Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } }
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; } } } }
public int countLinkedKuniQty(int kuniQty, int myKuniId, int myDaimyoId, List<string>seiryokuList, List<string>checkedKuniList){ List<int> dstKuniList = new List<int>(); KuniInfo kuni = new KuniInfo (); dstKuniList = kuni.getMappingKuni(myKuniId); foreach(int dstKuniId in dstKuniList){ if (!checkedKuniList.Contains (dstKuniId.ToString())) { string tmpDaimyoId = seiryokuList[dstKuniId - 1]; checkedKuniList.Add (dstKuniId.ToString ()); checkedKuniList.Add (myKuniId.ToString ()); if (int.Parse (tmpDaimyoId) == myDaimyoId) { kuniQty = countLinkedKuniQty (kuniQty, dstKuniId, myDaimyoId, seiryokuList, checkedKuniList) + 1; } } } return kuniQty; }
public void SyuppeiKuniScrollView(GameObject baseObj, string targetDaimyo, GameObject btn) { //View kuni which have openkuni GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject; string seiryoku = PlayerPrefs.GetString("seiryoku"); char[] delimiterChars = { ',' }; List <string> seiryokuList = new List <string>(); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); //my kuni int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); string myKuni = PlayerPrefs.GetString("clearedKuni"); List <int> myKuniList = new List <int>(); if (myKuni.Contains(",")) { List <string> tempMyKuniList = new List <string> (myKuni.Split(delimiterChars)); myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x)); } else { myKuniList.Add(int.Parse(myKuni)); } //doumei daimyo's opne kuni KuniInfo kuni = new KuniInfo(); List <int> doumeiOpenKuniList = new List <int>(); List <int> doumeiKuniList = new List <int>(); for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyo = seiryokuList[i]; if (tempDaimyo == targetDaimyo) { int doumeiKuniId = i + 1; doumeiKuniList.Add(doumeiKuniId); doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId)); } } //"doumei daimyo's doumei check string tempDoumei = "doumei" + targetDaimyo; string doumei = PlayerPrefs.GetString(tempDoumei); List <string> doumeiList = new List <string>(); if (doumei.Contains(",")) { doumeiList = new List <string> (doumei.Split(delimiterChars)); } else { doumeiList.Add(doumei); } //"doumei daimyo's opne kuni" minus "my kuni" /minus Doumei's doumei List <int> doumeiOpenKuniMinusMyKuniList = new List <int>(); foreach (int n in doumeiOpenKuniList) { if (!myKuniList.Contains(n)) { if (!doumeiKuniList.Contains(n)) { if (doumeiList.Count != 0) { string checkDaimyoId = seiryokuList [n - 1]; if (!doumeiList.Contains(checkDaimyoId)) { doumeiOpenKuniMinusMyKuniList.Add(n); } } else { doumeiOpenKuniMinusMyKuniList.Add(n); } } } } //delete duplication List <int> finalKuniList = new List <int>(); for (int i = 0; i < doumeiOpenKuniMinusMyKuniList.Count; i++) { int tmpKuniId = doumeiOpenKuniMinusMyKuniList [i]; if (!finalKuniList.Contains(tmpKuniId)) { finalKuniList.Add(tmpKuniId); } } //Src Kuni List List <int> srcKuniList = new List <int>(); for (int j = 0; j < finalKuniList.Count; j++) { int dstKuniId = finalKuniList [j]; List <int> targetKuniList = new List <int>(); targetKuniList.AddRange(kuni.getMappingKuni(dstKuniId)); for (int k = 0; k < targetKuniList.Count; k++) { int srcKuniId = targetKuniList [k]; if (doumeiKuniList.Contains(srcKuniId)) { srcKuniList.Add(srcKuniId); break; } } } /*Slot making*/ string temp = "gaikou" + targetDaimyo; int myYukoudo = PlayerPrefs.GetInt(temp); //Get Chiryaku //Entity_daimyo_mst daimyoMst = Resources.Load ("Data/daimyo_mst") as Entity_daimyo_mst; Daimyo daimyoScript = new Daimyo(); int myDaimyoBusyoId = daimyoScript.getDaimyoBusyoId(myDaimyo); BusyoInfoGet busyo = new BusyoInfoGet(); int chiryaku = busyo.getMaxDfc(myDaimyoBusyoId); string slotPath = "Prefabs/Map/common/kuniSlot"; for (int i = 0; i < finalKuniList.Count; i++) { GameObject prefab = Instantiate(Resources.Load(slotPath)) as GameObject; prefab.transform.SetParent(content.transform); prefab.transform.localScale = new Vector3(1, 1, 1); int kuniId = finalKuniList[i]; int daimyoId = int.Parse(seiryokuList [kuniId - 1]); string daimyoName = daimyoScript.getName(daimyoId); int srcKuniId = srcKuniList [i]; int srcDaimyoId = int.Parse(seiryokuList [srcKuniId - 1]); string srcDaimyoName = daimyoScript.getName(srcDaimyoId); string theirYukouTemp = ""; if (int.Parse(targetDaimyo) < daimyoId) { theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString(); } else { theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo; } int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp); string kuniName = kuni.getKuniName(kuniId); prefab.transform.FindChild("KuniValue").GetComponent <Text>().text = kuniName; prefab.transform.FindChild("DaimyoValue").GetComponent <Text>().text = daimyoName; prefab.GetComponent <GaikouKuniSelect>().Content = content; prefab.GetComponent <GaikouKuniSelect>().Btn = btn; prefab.GetComponent <GaikouKuniSelect>().myYukoudo = myYukoudo; prefab.GetComponent <GaikouKuniSelect>().chiryaku = chiryaku; prefab.GetComponent <GaikouKuniSelect>().kuniDiff = kuniDiff; prefab.GetComponent <GaikouKuniSelect>().theirYukoudo = theirYukoudo; prefab.GetComponent <GaikouKuniSelect>().kuniName = kuniName; prefab.GetComponent <GaikouKuniSelect>().targetKuniId = kuniId; prefab.GetComponent <GaikouKuniSelect>().targetDaimyoId = daimyoId; prefab.GetComponent <GaikouKuniSelect>().targetDaimyoName = daimyoName; prefab.GetComponent <GaikouKuniSelect>().srcKuniId = srcKuniId; prefab.GetComponent <GaikouKuniSelect>().srcDaimyoId = srcDaimyoId; prefab.GetComponent <GaikouKuniSelect>().srcDaimyoName = srcDaimyoName; if (i == 0) { prefab.GetComponent <GaikouKuniSelect>().OnClick(); } } if (finalKuniList.Count == 0) { string msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg"; GameObject msg = Instantiate(Resources.Load(msgPath)) as GameObject; msg.transform.SetParent(GameObject.Find("scroll").transform); msg.transform.localScale = new Vector3(0.17f, 0.2f, 1); RectTransform msgTransform = msg.GetComponent <RectTransform>(); msgTransform.anchoredPosition = new Vector3(-260, -115, 0); if (Application.systemLanguage != SystemLanguage.Japanese) { msg.GetComponent <Text>().text = "There is no available country.\nWe are surranded by allianced party."; } else { msg.GetComponent <Text>().text = "出兵可能な国はありませぬ\n周辺国は同盟大名しかおりませぬぞ"; } GameObject a = baseObj.transform.FindChild("RequiredMoney").gameObject; GameObject b = baseObj.transform.FindChild("KyoutouRatio").gameObject; Destroy(a); Destroy(b); btn.GetComponent <Button>().enabled = false; Color NGClorBtn = new Color(133 / 255f, 133 / 255f, 80 / 255f, 255f / 255f); Color NGClorTxt = new Color(90 / 255f, 90 / 255f, 40 / 255f, 255f / 255f); btn.GetComponent <Image>().color = NGClorBtn; btn.transform.FindChild("Text").GetComponent <Text>().color = NGClorTxt; btn.transform.FindChild("hyourouIcon").GetComponent <Image>().color = NGClorBtn; btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text>().color = NGClorTxt; btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").transform.FindChild("syouhiText").GetComponent <Text>().color = NGClorTxt; } }
public void kuniScrollView(GameObject baseObj, string targetDaimyo, GameObject btn) { GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject; string seiryoku = PlayerPrefs.GetString("seiryoku"); char[] delimiterChars = { ',' }; List <string> seiryokuList = new List <string>(); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); //my kuni int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); string myKuni = PlayerPrefs.GetString("clearedKuni"); List <int> myKuniList = new List <int>(); if (myKuni.Contains(",")) { List <string> tempMyKuniList = new List <string> (myKuni.Split(delimiterChars)); myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x)); } else { myKuniList.Add(int.Parse(myKuni)); } //doumei daimyo's opne kuni KuniInfo kuni = new KuniInfo(); List <int> doumeiOpenKuniList = new List <int>(); List <int> doumeiKuniList = new List <int>(); for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyo = seiryokuList[i]; if (tempDaimyo == targetDaimyo) { int doumeiKuniId = i + 1; doumeiKuniList.Add(doumeiKuniId); doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId)); } } //"doumei daimyo's opne kuni" minus "my kuni" List <int> doumeiOpenKuniMinusMyKuniList = new List <int>(); foreach (int n in doumeiOpenKuniList) { if (!myKuniList.Contains(n)) { doumeiOpenKuniMinusMyKuniList.Add(n); } } //"doumei daimyo's doumei check string tempDoumei = "doumei" + targetDaimyo; string doumei = PlayerPrefs.GetString(tempDoumei); List <string> doumeiList = new List <string>(); if (doumei.Contains(",")) { doumeiList = new List <string> (doumei.Split(delimiterChars)); } else { doumeiList.Add(doumei); } if (doumei != null && doumei != "") { for (int t = 0; t < doumeiOpenKuniMinusMyKuniList.Count; t++) { //foreach (int n in doumeiOpenKuniMinusMyKuniList) { string checkDaimyoId = seiryokuList [doumeiOpenKuniMinusMyKuniList[t] - 1]; if (doumeiList.Contains(checkDaimyoId)) { doumeiOpenKuniMinusMyKuniList.Remove(doumeiOpenKuniMinusMyKuniList[t]); } } } //Compare "doumei open" with "my open" string myOpenKuni = PlayerPrefs.GetString("openKuni"); List <int> myOpenKuniList = new List <int>(); if (myOpenKuni.Contains(",")) { List <string> tempMyOpenKuniList = new List <string> (myOpenKuni.Split(delimiterChars)); myOpenKuniList = tempMyOpenKuniList.ConvertAll(x => int.Parse(x)); } else { myOpenKuniList.Add(int.Parse(myOpenKuni)); } List <int> sameTargetKuniList = new List <int>(); foreach (int n in myOpenKuniList) { if (doumeiOpenKuniMinusMyKuniList.Contains(n)) { if (!doumeiKuniList.Contains(n)) { if (!sameTargetKuniList.Contains(n)) { sameTargetKuniList.Add(n); } } } } /*Slot making*/ string temp = "gaikou" + targetDaimyo; int myYukoudo = PlayerPrefs.GetInt(temp); //Get Chiryaku Daimyo daimyoScript = new Daimyo(); Entity_daimyo_mst daimyoMst = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst; int myDaimyoBusyoId = daimyoMst.param [myDaimyo - 1].busyoId; BusyoInfoGet busyo = new BusyoInfoGet(); int chiryaku = busyo.getMaxDfc(myDaimyoBusyoId); //StatusGet sts = new StatusGet(); //int lv = PlayerPrefs.GetInt (myDaimyoBusyoId.ToString()); //float chiryaku = (float)sts.getDfc(myDaimyoBusyoId,lv); //chiryaku = chiryaku *10; string slotPath = "Prefabs/Map/common/kuniSlot"; for (int i = 0; i < sameTargetKuniList.Count; i++) { GameObject prefab = Instantiate(Resources.Load(slotPath)) as GameObject; prefab.transform.SetParent(content.transform); prefab.transform.localScale = new Vector3(1, 1, 1); int kuniId = sameTargetKuniList[i]; int daimyoId = int.Parse(seiryokuList [kuniId - 1]); // daimyoName = daimyoMst.param [daimyoId - 1].daimyoName; string daimyoName = daimyoScript.getName(daimyoId); string theirYukouTemp = ""; if (int.Parse(targetDaimyo) < daimyoId) { theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString(); } else { theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo; } int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp); string kuniName = kuni.getKuniName(kuniId); prefab.transform.FindChild("KuniValue").GetComponent <Text>().text = kuniName; prefab.transform.FindChild("DaimyoValue").GetComponent <Text>().text = daimyoName; prefab.GetComponent <GaikouKuniSelect>().Content = content; prefab.GetComponent <GaikouKuniSelect>().Btn = btn; prefab.GetComponent <GaikouKuniSelect>().myYukoudo = myYukoudo; prefab.GetComponent <GaikouKuniSelect>().chiryaku = chiryaku; prefab.GetComponent <GaikouKuniSelect>().kuniDiff = kuniDiff; prefab.GetComponent <GaikouKuniSelect>().theirYukoudo = theirYukoudo; prefab.GetComponent <GaikouKuniSelect>().kuniName = kuniName; prefab.GetComponent <GaikouKuniSelect>().targetKuniId = kuniId; if (i == 0) { prefab.GetComponent <GaikouKuniSelect>().OnClick(); } } if (sameTargetKuniList.Count == 0) { string msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg"; GameObject msg = Instantiate(Resources.Load(msgPath)) as GameObject; msg.transform.SetParent(GameObject.Find("scroll").transform); msg.transform.localScale = new Vector3(0.17f, 0.2f, 1); RectTransform msgTransform = msg.GetComponent <RectTransform> (); msgTransform.anchoredPosition = new Vector3(-260, -115, 0); GameObject a = baseObj.transform.FindChild("RequiredMoney").gameObject; GameObject b = baseObj.transform.FindChild("KyoutouRatio").gameObject; Destroy(a); Destroy(b); btn.GetComponent <Button>().enabled = false; Color NGClorBtn = new Color(133 / 255f, 133 / 255f, 80 / 255f, 255f / 255f); Color NGClorTxt = new Color(90 / 255f, 90 / 255f, 40 / 255f, 255f / 255f); btn.GetComponent <Image>().color = NGClorBtn; btn.transform.FindChild("Text").GetComponent <Text>().color = NGClorTxt; btn.transform.FindChild("hyourouIcon").GetComponent <Image>().color = NGClorBtn; btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text>().color = NGClorTxt; btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").transform.FindChild("syouhiText").GetComponent <Text>().color = NGClorTxt; } }
public void viewKuniLink(GameObject board, GameObject kuniMap, List <string> seiryokuList) { KuniInfo kuniScript = new KuniInfo(); List <int> linkKuniList = kuniScript.getMappingKuni(kuniId); List <int> linkAllKuniList = new List <int>(); for (int i = 0; i < linkKuniList.Count; i++) { int linkKuniId = linkKuniList[i]; linkAllKuniList.Add(linkKuniId); } //view kuni arrow link Daimyo daimyoScript = new Daimyo(); for (int i = 0; i < linkAllKuniList.Count; i++) { int srcKuniId = linkAllKuniList[i]; List <int> XYList = kuniScript.getLinkStageXY(srcKuniId, kuniId); string pathOfSrcKuni = "Prefabs/Map/Stage/ArrowKuniName"; GameObject srcKuniNameObj = Instantiate(Resources.Load(pathOfSrcKuni)) as GameObject; srcKuniNameObj.name = "Arrow" + srcKuniId; srcKuniNameObj.transform.SetParent(board.transform.FindChild("board").transform); srcKuniNameObj.transform.localScale = new Vector2(0.1f, 0.15f); srcKuniNameObj.transform.localPosition = new Vector2(XYList[0], XYList[1]); srcKuniNameObj.GetComponent <Text>().text = kuniScript.getKuniName(srcKuniId); string linkStage = kuniScript.getLinkStage(srcKuniId, kuniId); linkStage = linkStage.Replace("stage", ""); List <int> linkStageList = new List <int>(Array.ConvertAll(linkStage.Split(','), new Converter <string, int>((s) => { return(Convert.ToInt32(s)); }))); string arrowDaimyoPath = "Prefabs/Map/Stage/ArrowDaimyo"; GameObject arrowDaimyo = Instantiate(Resources.Load(arrowDaimyoPath)) as GameObject; arrowDaimyo.transform.SetParent(srcKuniNameObj.transform); arrowDaimyo.transform.localScale = new Vector2(8, 7); arrowDaimyo.transform.localPosition = new Vector2(0, 0); arrowDaimyo.transform.FindChild("Effect").GetComponent <DamagePop>().divSpeed = 5; arrowDaimyo.transform.FindChild("Effect").GetComponent <DamagePop>().attackBoardflg = true; int arrowDaimyoId = int.Parse(seiryokuList[srcKuniId - 1]); string daimyoName = daimyoScript.getName(arrowDaimyoId); arrowDaimyo.transform.FindChild("Effect").GetComponent <Text>().text = daimyoName; arrowDaimyo.transform.FindChild("Effect").transform.localScale = new Vector2(0.12f, 0.12f); string kamonPath = "Prefabs/Kamon/MyDaimyoKamon/" + arrowDaimyoId.ToString(); arrowDaimyo.GetComponent <Image>().sprite = Resources.Load(kamonPath, typeof(Sprite)) as Sprite; //Arrow string arrowPath = "Prefabs/PostKassen/Arrow"; for (int j = 0; j < linkStageList.Count; j++) { GameObject arrow = Instantiate(Resources.Load(arrowPath)) as GameObject; arrow.transform.SetParent(srcKuniNameObj.transform); arrow.transform.localScale = new Vector2(200, 200); arrow.transform.localPosition = new Vector2(0, 0); string stageId = "stage" + linkStageList[j]; GameObject tgtStageObj = kuniMap.transform.FindChild(stageId).gameObject; Vector3 posDif = tgtStageObj.transform.position - arrow.transform.position; float angle = Mathf.Atan2(posDif.y, posDif.x) * Mathf.Rad2Deg; Vector3 euler = new Vector3(0, 0, angle); arrow.transform.rotation = Quaternion.Euler(euler); } } }
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); } } }
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); } }
public void UpdateShiroStatus(GameObject kuniMap) { char[] delimiterChars = { ',' }; char[] delimiterChars2 = { '-' }; int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); //open shiro List <int> closeStageIdList = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string>(); seiryokuList = new List <string>(seiryoku.Split(delimiterChars)); //compare linkKuni with mySeiryoku List <int> linkKuniList = new List <int>(); List <int> linkMyKuniList = new List <int>(); KuniInfo kuniScript = new KuniInfo(); linkKuniList = kuniScript.getMappingKuni(kuniId); for (int i = 0; i < linkKuniList.Count; i++) { int linkKuniId = linkKuniList[i]; if (seiryokuList[linkKuniId - 1] == myDaimyoId.ToString()) { linkMyKuniList.Add(linkKuniId); } } //open initial stage for (int j = 0; j < linkMyKuniList.Count; j++) { int srcKuniId = linkMyKuniList[j]; string linkStage = kuniScript.getLinkStage(srcKuniId, kuniId); linkStage = linkStage.Replace("stage", ""); List <int> linkStageList = new List <int>(Array.ConvertAll(linkStage.Split(','), new Converter <string, int>((s) => { return(Convert.ToInt32(s)); }))); closeStageIdList.RemoveAll(linkStageList.Contains); } //Clear Stage Setting string clearedStage = "kuni" + kuniId; string clearedStageString = PlayerPrefs.GetString(clearedStage); List <string> clearedStageList = new List <string>(); if (clearedStageString != null && clearedStageString != "") { clearedStageList = new List <string>(clearedStageString.Split(delimiterChars)); } //Line Setting Entity_stageLink_mst stageLinkMst = Resources.Load("Data/stageLink_mst") as Entity_stageLink_mst; List <string> myStageLink = new List <string>(); for (int i = 0; i < stageLinkMst.param.Count; i++) { int tempKuniId = stageLinkMst.param[i].kuniId; if (tempKuniId == kuniId) { myStageLink.Add(stageLinkMst.param[i].Link); } } List <string> myOriginalStageLink = new List <string>(myStageLink); //open cleared kuni & linked stage List <int> clearedStageIntList = clearedStageList.ConvertAll(x => int.Parse(x)); closeStageIdList.RemoveAll(clearedStageIntList.Contains); for (int l = 0; l < clearedStageIntList.Count; l++) { int srcStageId = clearedStageIntList[l]; for (int m = 0; m < myOriginalStageLink.Count; m++) { List <string> linkList = new List <string>(myOriginalStageLink[m].Split(delimiterChars2)); int stage1Id = int.Parse(linkList[0]); int stage2Id = int.Parse(linkList[1]); if (srcStageId == stage1Id) { closeStageIdList.Remove(stage2Id); } else if (srcStageId == stage2Id) { closeStageIdList.Remove(stage1Id); } } } //Active or Disabled Color openColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 0f / 255f); //White Color closeColor = new Color(60f / 255f, 60f / 255f, 60f / 255f, 255f / 255f); //Black bool fireflg = false; for (int k = 1; k < 11; k++) { string stageName = "stage" + k.ToString(); GameObject shiroObj = kuniMap.transform.FindChild(stageName).gameObject; if (closeStageIdList.Contains(k)) { //Close shiroObj.GetComponent <Button>().enabled = false; shiroObj.transform.FindChild("shiroImage").GetComponent <SpriteRenderer>().color = closeColor; } else { //Open //shiroObj.GetComponent<Button>().enabled = true; //shiroObj.transform.FindChild("shiroImage").GetComponent<SpriteRenderer>().color = openColor; shiroObj.GetComponent <ShowStageDtl>().clearedFlg = false; if (!fireflg) { shiroObj.GetComponent <ShowStageDtl>().OnClick(); fireflg = true; } } } }
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"); /*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 = CountEnemyAction (); 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; for (int k=0; k<targetKuniList.Count; k++) { 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]; } } }//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; } } Debug.Log ("doumeiFlg:"+doumeiFlg +",src:"+eDaimyo +",dst:"+worstGaikouDaimyo + ",kassen Ratio:" + kassenRatio2); 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 + "人を起こしましたぞ。\t同盟国が援軍" + totalEngunHei + "人を派兵しました。"; } messageList.Add (kassenText); if(doumeiFlg){ //Delete doumei Debug.Log (eDaimyo +":"+ worstGaikouDaimyo); 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 = CountEnemyAction (); 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) { int gaikouAction = UnityEngine.Random.Range (1, 3); if (gaikouAction == 1) { //1. yukoudo up(Mitsugimono) bool yukoudoUpFlg = CheckByProbability (yukoudoUpMissRatio); if (yukoudoUpFlg == true) { //Choose Target Daimyo int randomDstKuni = UnityEngine.Random.Range (1, 66); int dstDaimyoId = int.Parse (seiryokuList [randomDstKuni - 1]); string dstDaimyoName = daimyo.getName (dstDaimyoId); if (srcDaimyoId != dstDaimyoId) { if (dstDaimyoId == myDaimyo) { //In the case that MyDaimyo receive Mitsugimono int addYukoudo = UpYukouValueWithMyDaimyo (myDaimyo, dstDaimyoId); 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 = UpYukouValueWithMyDaimyo (myDaimyo, dstDaimyoId); 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 randomDst1stKuni = UnityEngine.Random.Range (1, 66); int dst1stDaimyoId = int.Parse (seiryokuList [randomDst1stKuni - 1]); int randomDst2ndKuni = UnityEngine.Random.Range (1, 66); int dst2ndDaimyoId = int.Parse (seiryokuList [randomDst2ndKuni - 1]); if (dst1stDaimyoId != dst2ndDaimyoId) { int reduceYukoudo = 0; //My Daimyo if (dst1stDaimyoId == myDaimyo || dst2ndDaimyoId == myDaimyo) { string dstDaimyoName = ""; if (dst1stDaimyoId == myDaimyo) { reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, dst2ndDaimyoId); dstDaimyoName = daimyo.getName (dst1stDaimyoId); } if (dst2ndDaimyoId == myDaimyo) { reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, dst1stDaimyoId); dstDaimyoName = daimyo.getName (dst2ndDaimyoId); } //string yukouDownText = srcDaimyoName + "が当家と" + dstDaimyoName + "に流言を流し、友好度が" + dstDaimyoName + "下がりました。"; string yukouDownText = "何者かが当家と" + dstDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。"; messageList.Add (yukouDownText); } else { reduceYukoudo = DownYukouValueWithOther (dst1stDaimyoId, dst2ndDaimyoId); string dst1stDaimyoName = daimyo.getName (dst1stDaimyoId); string dst2ndDaimyoName = daimyo.getName (dst2ndDaimyoId); string yukouDownText = "何者かが" + dst1stDaimyoName + "と" + dst2ndDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。"; messageList.Add (yukouDownText); } } } } else if (gaikouAction == 3) { //doumei bool doumeiFlg = CheckByProbability (doumeiRatio); if (doumeiFlg == true) { } } else if (gaikouAction == 4) { } } } } /*Nanbanjin*/ /**/ /*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(); } /*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); } } }
public void OnClick() { audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); CloseLayer closeLayerScript = GameObject.Find("CloseSyoukaijyo").GetComponent <CloseLayer> (); string rank = closeLayerScript.syoukaijyoRank; bool occupiedFlg = closeLayerScript.occupiedFlg; int nowPoint = PlayerPrefs.GetInt("cyouteiPoint"); Message msg = new Message(); if (name == "DoKenjyoButton") { audioSources [3].Play(); //Reduce Action Qty reduceActionQty(); //Get Money Value & reduce money int giveMoney = int.Parse(GameObject.Find("GiveMoneyValue").GetComponent <Text> ().text); int money = PlayerPrefs.GetInt("money"); int newMoney = money - giveMoney; PlayerPrefs.SetInt("money", newMoney); GameObject.Find("MoneyValue").GetComponent <Text> ().text = newMoney.ToString(); //Add Kouken Value float addPoint = 0; if (rank == "Jyo") { addPoint = giveMoney / 200; } else if (rank == "Cyu") { addPoint = giveMoney / 300; } else if (rank == "Ge") { addPoint = giveMoney / 500; } if (occupiedFlg) { addPoint = addPoint * 1.5f; } int rdmId = UnityEngine.Random.Range(0, 6); List <float> rdmValueList = new List <float> () { 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f }; float rdmValue = rdmValueList [rdmId]; addPoint = addPoint * rdmValue; int newPoint = nowPoint + Mathf.CeilToInt(addPoint); if (newPoint > 100) { newPoint = 100; } PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; PlayerPrefs.Flush(); string pathOfAnim = "Prefabs/EffectAnime/point_up"; GameObject anim = Instantiate(Resources.Load(pathOfAnim)) as GameObject; anim.transform.SetParent(GameObject.Find("CyouteiPoint").transform); anim.transform.localScale = new Vector2(80, 80); anim.transform.localPosition = new Vector2(40, 30); GameObject menu = GameObject.Find("MenuKenjyo").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); serihuScript.mikadoSerihuChanger(msg.getMessage(32)); } else if (name == "DoCyouteiButton") { int addYukoudo = closeLayerScript.yukouAddValue; int reducePoint = closeLayerScript.yukouReducePoint; if (reducePoint <= nowPoint) { audioSources [3].Play(); //Reduce Action Qty reduceActionQty(); int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; upYukoudo(addYukoudo); serihuScript.mikadoSerihuChanger(msg.getMessage(33)); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuCyoutei").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } else if (name == "DoTeisenButton") { int stropBattleRatio = closeLayerScript.stopBattleRatio; int reducePoint = closeLayerScript.stopBattleReducePoint; if (reducePoint <= nowPoint) { //Reduce Action Qty reduceActionQty(); bool successFlg = teisen(stropBattleRatio); if (successFlg) { int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; } } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuTeisen").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } else if (name == "DoKanniButton") { int reducePoint = closeLayerScript.kanniReducePoint; if (reducePoint <= nowPoint) { //Reduce Action Qty reduceActionQty(); int ratio = closeLayerScript.kanniRatio; int kanniId = closeLayerScript.kanniId; string kanniName = closeLayerScript.kanniName; bool successFlg = registerKanni(ratio, kanniId, kanniName); if (successFlg) { int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; Color enableImageColor = new Color(35f / 255f, 35f / 255f, 35f / 255f, 155f / 255f); Color enableTextColor = new Color(125f / 255f, 125f / 255f, 125f / 255f, 255f / 255f); GameObject btn = GameObject.Find("Kanni").gameObject; btn.GetComponent <Button> ().enabled = false; btn.GetComponent <Image> ().color = enableImageColor; btn.transform.FindChild("Text").GetComponent <Text> ().color = enableTextColor; } } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuKanni").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } else if (name == "DoCyoutekiButton") { int reducePoint = closeLayerScript.cyoutekiReducePoint; if (reducePoint <= nowPoint) { audioSources [3].Play(); //Reduce Action Qty reduceActionQty(); int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; int targetDaimyoId = closeLayerScript.cyoutekiDaimyo; string targetDaimyoName = closeLayerScript.cyoutekiDaimyoName; //reduce yukoudo 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> (); GameObject KuniIconView = GameObject.Find("KuniIconView").gameObject; for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyoId = seiryokuList [i]; if (tempDaimyoId == targetDaimyoId.ToString()) { int temp = i + 1; srcDaimyoKuniList.Add(temp.ToString()); //Change Map Valye KuniIconView.transform.FindChild(temp.ToString()).GetComponent <SendParam> ().myYukouValue = 0; } } //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 != targetDaimyoId) { if (!dstDaimyoList.Contains(tempDaimyoId)) { dstDaimyoList.Add(tempDaimyoId); } } } //Reduce Yukoudo for (int l = 0; l < dstDaimyoList.Count; l++) { int dstDaimyoId = dstDaimyoList [l]; DownYukouToZeroWithOther(targetDaimyoId, dstDaimyoId, myDaimyo); } //Hist PlayerPrefs.SetInt("cyoutekiDaimyo", targetDaimyoId); PlayerPrefs.Flush(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Royal court declared " + targetDaimyoName + " is the enemy.\n friendship with surrounded families decreased."; } else { OKtext = targetDaimyoName + "討伐の勅令が出されました。\n周辺大名との関係が著しく悪化しますぞ。"; } msg.makeMessage(OKtext); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuCyouteki").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } else if (name == "DoBakuhuButton") { int reducePoint = 100; if (reducePoint <= nowPoint) { audioSources [3].Play(); //Reduce Action Qty reduceActionQty(); int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; //Syogun string year = GameObject.Find("YearValue").GetComponent <Text>().text; string season = GameObject.Find("SeasonValue").GetComponent <Text>().text; string daimyoBusyoName = GameObject.Find("DaimyoValue").GetComponent <Text>().text; string text = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { text = year + " " + season + "," + daimyoBusyoName + " was assigned syogun.\n You opened shogunate."; } else { text = year + "年" + season + "," + daimyoBusyoName + "は征夷大将軍に任じられました。\n幕府を開き、天下に号令をかけます。"; } msg.makeMessageWithImage(text); //Change Value int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); PlayerPrefs.SetInt("syogunDaimyoId", myDaimyo); //Up yukoudo int rdmAddYukoudo = UnityEngine.Random.Range(20, 50); upYukoudoWithEveryDaimyo(rdmAddYukoudo); PlayerPrefs.Flush(); //Enable Syogun Button GameObject oya = GameObject.Find("SubButtonViewRight").gameObject; GameObject ko = oya.transform.FindChild("Bakuhu").gameObject; ko.SetActive(true); string pathOfAnim = "Prefabs/EffectAnime/point_up"; GameObject anim = Instantiate(Resources.Load(pathOfAnim)) as GameObject; anim.transform.SetParent(ko.transform); anim.transform.localScale = new Vector2(200, 200); anim.transform.localPosition = new Vector2(0, 100); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuBakuhu").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } }