public void OnClick() { if (name == "YesButton") { Message msg = new Message(); //check int busyoDama = PlayerPrefs.GetInt("busyoDama"); if (busyoDama >= 100) { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [3].Play(); int newHyourou = 100; if (Application.loadedLevelName != "shisya") { GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString(); } else { GameObject.Find("Hyourou").transform.FindChild("Value").GetComponent <Text>().text = newHyourou.ToString(); } int newBusyoDama = busyoDama - 100; if (Application.loadedLevelName != "naisei") { GameObject.Find("BusyoDamaValue").GetComponent <Text> ().text = newBusyoDama.ToString(); } PlayerPrefs.SetInt("busyoDama", newBusyoDama); PlayerPrefs.SetInt("hyourou", newHyourou); if (Application.loadedLevelName != "shisya" && Application.loadedLevelName != "naisei" && Application.loadedLevelName != "pvp") { MainStageController mainScript = GameObject.Find("GameController").GetComponent <MainStageController> (); mainScript.hyourouFull = true; mainScript.nowHyourou = 100; mainScript.timer = 180; GameObject.Find("TimerValue").GetComponent <Text> ().text = "180"; } PlayerPrefs.SetBool("questDailyFlg37", true); PlayerPrefs.Flush(); //Extension Mark Handling MainStageController main = new MainStageController(); main.questExtension(); msg.makeMessage(msg.getMessage(4)); } else { msg.makeMessage(msg.getMessage(2)); } } touchBackObj.GetComponent <CloseOneBoard> ().OnClick(); }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (name == "YesButton") { Message msg = new Message(); //check int meiseiItem = PlayerPrefs.GetInt("meisei"); if (meiseiItem >= 1) { audioSources [3].Play(); meiseiItem = meiseiItem - 1; PlayerPrefs.SetInt("meisei", meiseiItem); NaiseiController script = GameObject.Find("NaiseiController").GetComponent <NaiseiController> (); int kuniId = script.activeKuniId; string tmp1 = "naiseiLoginDate" + kuniId.ToString(); string tmp2 = "naiseiTabibitoCounter" + kuniId.ToString(); PlayerPrefs.DeleteKey(tmp1); PlayerPrefs.DeleteKey(tmp2); int tabibitoMaxNo = int.Parse(GameObject.Find("TabibitoMaxValue").GetComponent <Text> ().text); GameObject.Find("TabibitoCountDownValue").GetComponent <Text> ().text = tabibitoMaxNo.ToString(); script.remain = tabibitoMaxNo; float specialRatio = script.specialRatio; //specialRatio = specialRatio * 2; specialRatio = 20; script.specialRatio = specialRatio; PlayerPrefs.SetBool("questDailyFlg151", true); PlayerPrefs.Flush(); //Extension Mark Handling MainStageController main = new MainStageController(); main.questExtension(); msg.makeMessage(msg.getMessage(121)); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(120)); } } else { audioSources [1].Play(); } touchBackObj.GetComponent <CloseOneBoard> ().OnClick(); }
public void OnClick() { if (name == "YesButton") { Message msg = new Message(); //check int busyoDama = PlayerPrefs.GetInt("busyoDama"); if (busyoDama >= 100) { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [3].Play(); int currentMoney = PlayerPrefs.GetInt("money"); currentMoney = currentMoney + 30000; if (currentMoney < 0) { currentMoney = int.MaxValue; } GameObject.Find("MoneyValue").GetComponent <Text> ().text = currentMoney.ToString(); PlayerPrefs.SetInt("money", currentMoney); int newBusyoDama = busyoDama - 100; GameObject.Find("BusyoDamaValue").GetComponent <Text> ().text = newBusyoDama.ToString(); PlayerPrefs.SetInt("busyoDama", newBusyoDama); PlayerPrefs.SetBool("questDailyFlg150", true); PlayerPrefs.Flush(); //Extension Mark Handling MainStageController main = new MainStageController(); main.questExtension(); msg.makeMessage(msg.getMessage(3)); } else { msg.makeMessage(msg.getMessage(2)); } } touchBackObj.GetComponent <CloseOneBoard> ().OnClick(); }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); Message msg = new Message(); if (name != "PassButton") { //Syoukaijyo Confirm Pop audioSources [0].Play(); //Back string pathOfBack = "Prefabs/Cyoutei/TouchBackLayer"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); //Cyoutei Pop string pathOfPop = "Prefabs/Cyoutei/SelectSyoukaijyoBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "SelectSyoukaijyoBoard"; back.GetComponent <CloseLayer> ().closeTargetObj = pop; back.GetComponent <CloseLayer> ().closeTargetBack = back; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetObj = pop; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetBack = back; //Check Syoukaijyo string nowQty = PlayerPrefs.GetString("cyoutei"); //string nowQty = "0,0,0"; List <string> nowQtyList = new List <string> (); char[] delimiterChars = { ',' }; nowQtyList = new List <string> (nowQty.Split(delimiterChars)); GameObject scrollView = pop.transform.FindChild("ScrollView").gameObject; GameObject content = scrollView.transform.FindChild("Content").gameObject; bool notZeroflg = false; //Jyo if (nowQtyList [2] == "0") { content.transform.FindChild("Jyo").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Jyo").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [2]; content.transform.FindChild("Jyo").GetComponent <SyoukaijyoSelect>().OnClick(); } //Cyu if (nowQtyList [1] == "0") { content.transform.FindChild("Cyu").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Cyu").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [1]; content.transform.FindChild("Cyu").GetComponent <SyoukaijyoSelect>().OnClick(); } //Ge if (nowQtyList [0] == "0") { content.transform.FindChild("Ge").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Ge").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [0]; content.transform.FindChild("Ge").GetComponent <SyoukaijyoSelect>().OnClick(); } if (!notZeroflg) { scrollView.transform.FindChild("NoSyoukaijyo").GetComponent <Text> ().enabled = true; pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = msg.getMessage(16); pop.transform.FindChild("PassButton").gameObject.SetActive(false); } pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().SelectSyoukaijyoBoard = pop; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().myDaimyoFlg = myDaimyoFlg; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().occupiedDaimyoId = occupiedDaimyoId; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().occupiedDaimyoName = occupiedDaimyoName; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().yukoudo = yukoudo; } else { //Cyoutei Main Pop int hyourou = PlayerPrefs.GetInt("hyourou"); if (hyourou >= 5) { int newHyourou = hyourou - 5; PlayerPrefs.SetInt("hyourou", newHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text>().text = newHyourou.ToString(); //Check Yukoudo int ratio = 100 - yukoudo; if (myDaimyoFlg) { ratio = 0; } float percent = Random.value; percent = percent * 100; if (percent > ratio) { //Stop Timer stopGunzei(); GameObject.Find("GameController").GetComponent <MainStageController>().eventStopFlg = true; audioSources [3].Play(); SelectSyoukaijyoBoard.transform.FindChild("CloseBtn").GetComponent <CloseLayer>().OnClick(); string pathOfBack = "Prefabs/Cyoutei/CyouteiBack"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); string pathOfPop = "Prefabs/Cyoutei/CyouteiBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "CyouteiBoard"; CloseLayer CloseLayerScript = pop.transform.FindChild("CloseSyoukaijyo").GetComponent <CloseLayer>(); CloseLayerScript.closeTargetBack = back; CloseLayerScript.closeTargetObj = pop; CloseLayerScript.syoukaijyoRank = syoukaijyoRank; CloseLayerScript.occupiedFlg = myDaimyoFlg; CloseLayerScript.syouninCyouteiFlg = true; //RandomValue int yukouAddValue = 0; int yukouReducePoint = Random.Range(2, 10); int stopBattleRatio = 0; int stopBattleReducePoint = Random.Range(2, 10); int kanniRatio = 0; int kanniReducePoint = Random.Range(20, 100); int syoukaijyoRankId = 0; int cyoutekiReducePoint = Random.Range(80, 100); //Change Menu by syoukaijyo rank GameObject action = pop.transform.FindChild("Action").gameObject; if (syoukaijyoRank == "Ge") { List <string> btnNameList = new List <string> () { "Bakuhu", "Cyouteki" }; enableButton(pop, btnNameList); yukouAddValue = Random.Range(1, 3); stopBattleRatio = Random.Range(10, 30); kanniRatio = Random.Range(20, 60); syoukaijyoRankId = 1; action.transform.FindChild("ActionValue").GetComponent <Text>().text = "1"; action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "1"; } else if (syoukaijyoRank == "Cyu") { List <string> btnNameList = new List <string> () { "Bakuhu", "Cyouteki" }; enableButton(pop, btnNameList); yukouAddValue = Random.Range(3, 8); stopBattleRatio = Random.Range(30, 80); kanniRatio = Random.Range(40, 80); syoukaijyoRankId = 2; action.transform.FindChild("ActionValue").GetComponent <Text>().text = "2"; action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "2"; } else if (syoukaijyoRank == "Jyo") { yukouAddValue = Random.Range(8, 15); stopBattleRatio = 100; kanniRatio = Random.Range(60, 100); syoukaijyoRankId = 3; action.transform.FindChild("ActionValue").GetComponent <Text>().text = "3"; action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "3"; } //TargetKanni Kanni kanni = new Kanni(); int kuniQty = GameObject.Find("GameController").GetComponent <MainStageController>().myKuniQty; int kanniId = kanni.getRandomKanni(syoukaijyoRankId, kuniQty); //TargetCyouteki string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); string openKuni = PlayerPrefs.GetString("openKuni"); List <string> openKuniList = new List <string> (); openKuniList = new List <string> (openKuni.Split(delimiterChars)); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); int cyoutekiDaimyoId = CloseLayerScript.cyoutekiDaimyo; //openKuniList.RemoveAll (x => x == occupiedDaimyoId.ToString()); //my kuni List <string> myKuniList = new List <string>(); List <string> occupiedDaimyoKuniList = new List <string>(); for (int i = 0; i < seiryokuList.Count; i++) { int tmpDaimyoId = int.Parse(seiryokuList [i]); if (tmpDaimyoId == myDaimyo) { int kuniId = i + 1; myKuniList.Add(kuniId.ToString()); } else if (tmpDaimyoId == occupiedDaimyoId) { int kuniId = i + 1; occupiedDaimyoKuniList.Add(kuniId.ToString()); } } openKuniList.RemoveAll(myKuniList.Contains); openKuniList.RemoveAll(occupiedDaimyoKuniList.Contains); int rdmId = UnityEngine.Random.Range(0, openKuniList.Count); int targetKuniId = int.Parse(openKuniList[rdmId]); int cyoutekiDaimyo = int.Parse(seiryokuList[targetKuniId - 1]); //reduce cyoutei syoukaijyo DoSell script = new DoSell(); script.deleteKouekiOrCyoutei(syoukaijyoRankId, "cyoutei", 1); //Set Parametor CloseLayerScript.yukouAddValue = yukouAddValue; CloseLayerScript.yukouReducePoint = yukouReducePoint; CloseLayerScript.stopBattleRatio = stopBattleRatio; CloseLayerScript.stopBattleReducePoint = stopBattleReducePoint; CloseLayerScript.kanniId = kanniId; if (kanniId != 0) { CloseLayerScript.kanniName = kanni.getKanniName(kanniId); CloseLayerScript.kanniRatio = kanniRatio; CloseLayerScript.kanniReducePoint = kanniReducePoint; } CloseLayerScript.cyoutekiDaimyo = cyoutekiDaimyo; CloseLayerScript.cyoutekiReducePoint = cyoutekiReducePoint; //Cyoutei Point int cyouteiPoint = PlayerPrefs.GetInt("cyouteiPoint"); pop.transform.FindChild("CyouteiPoint").transform.FindChild("CyouteiValue").GetComponent <Text>().text = cyouteiPoint.ToString() + "%"; bool doneFirstCyouteiFlg = PlayerPrefs.GetBool("doneFirstCyouteiFlg"); Daimyo daimyo = new Daimyo(); if (!doneFirstCyouteiFlg) { //1st time PlayerPrefs.SetBool("questSpecialFlg5", true); PlayerPrefs.SetBool("doneFirstCyouteiFlg", true); KuniInfo kuni = new KuniInfo(); int kuniId = kuni.getOneKuniId(myDaimyo); int firstKanniId = kanni.getKuniKanni(kuniId); string firstKanniName = kanni.getKanniName(firstKanniId); string myKanni = PlayerPrefs.GetString("myKanni"); if (myKanni != null && myKanni != "") { myKanni = myKanni + "," + firstKanniId.ToString(); } else { myKanni = firstKanniId.ToString(); } PlayerPrefs.SetString("myKanni", myKanni); PlayerPrefs.Flush(); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Your good rumor has arrived to the Imperial court. Please lend me your power for the world.\n I assigned you as " + firstKanniName + "."; } else { serihu = "天下静謐のため力を貸してくれ。\n" + firstKanniName + "に任ずるぞ。"; } pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text>().text = serihu; } else { //2nd time //Serihu string daimyoName = daimyo.getName(myDaimyo); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Lord " + daimyoName + ".\n What do you want?"; } else { serihu = "おお、" + daimyoName + "殿。\n此度は何用か。"; } pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text>().text = serihu; } } else { audioSources [4].Play(); if (Application.systemLanguage != SystemLanguage.Japanese) { msg.makeMessage("My lord " + occupiedDaimyoName + " disturbed us to visit coart."); } else { msg.makeMessage("御屋形様、" + occupiedDaimyoName + "めに参内を邪魔されました。"); } } } else { audioSources [4].Play(); //string NGtext = msg.getMessage(7); //msg.makeMessage (NGtext); msg.hyourouMovieMessage(); } } }
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 OnClick() { int nowHyourou = PlayerPrefs.GetInt("hyourou"); Message msg = new Message(); AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (name == "Back") { scrollObj.SetActive(false); audioSources [1].Play(); } else { if (nowHyourou < 2) { msg.makeUpperMessageOnBoard(msg.getMessage(7)); } else { //Track int TrackBouryakuNo = PlayerPrefs.GetInt("TrackBouryakuNo", 0); TrackBouryakuNo = TrackBouryakuNo + 1; PlayerPrefs.SetInt("TrackBouryakuNo", TrackBouryakuNo); nowHyourou = nowHyourou - 2; PlayerPrefs.SetInt("hyourou", nowHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = nowHyourou.ToString(); //Do StartKassen script = GameObject.Find("BattleButton").GetComponent <StartKassen> (); activeKuniId = script.activeKuniId; activeStageId = script.activeStageId; DoGaikou addUsedBusyo = new DoGaikou(); if (linkCutFlg) { //link cut //Make target list string temp = "kuniMap" + activeKuniId; GameObject kuniMap = GameObject.Find(temp).gameObject; List <string> targetList = new List <string> (); foreach (Transform obj in kuniMap.transform) { if (obj.tag == "Link") { string objName = obj.name; objName = objName.Replace("link", ""); List <string> linkList = new List <string> (); char[] delimiterChars = { '-' }; linkList = new List <string> (objName.Split(delimiterChars)); if (int.Parse(linkList [0]) == activeStageId) { targetList.Add(objName); } else if (int.Parse(linkList [1]) == activeStageId) { targetList.Add(objName); } } } okRatio = ((float)cyouhouSnbRankId * (float)dfc) / 8; if (targetList.Count != 0) { int okCount = 0; bool okMsgFlg = false; for (int i = 0; i < targetList.Count; i++) { //success or not float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= okRatio) { //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); //OK Cut okMsgFlg = true; string target = "link" + targetList [i]; GameObject targetObj = kuniMap.transform.FindChild(target).gameObject; Destroy(targetObj.gameObject); //Register Data string tempLinkuct = "linkcut" + activeKuniId; string linkcut = PlayerPrefs.GetString(tempLinkuct); string newLinkcut = ""; if (linkcut != null && linkcut != "") { newLinkcut = linkcut + "," + targetList [i]; } else { newLinkcut = targetList [i]; } PlayerPrefs.SetString(tempLinkuct, newLinkcut); PlayerPrefs.SetBool("questDailyFlg34", true); PlayerPrefs.Flush(); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); //Reduce Cut No. List <string> linkList = new List <string> (); char[] delimiterChars = { '-' }; linkList = new List <string> (targetList [i].Split(delimiterChars)); string stage1 = "stage" + linkList [0]; string stage2 = "stage" + linkList [1]; foreach (Transform obj in kuniMap.transform) { if (obj.tag != "Link") { if (obj.name == stage1 || obj.name == stage2) { obj.GetComponent <ShowStageDtl> ().linkNo = obj.GetComponent <ShowStageDtl> ().linkNo - 1; } } } okCount = okCount + 1; } } if (okMsgFlg) { int TrackLinkCutNo = PlayerPrefs.GetInt("TrackLinkCutNo", 0); TrackLinkCutNo = TrackLinkCutNo + okCount; PlayerPrefs.SetInt("TrackLinkCutNo", TrackLinkCutNo); PlayerPrefs.Flush(); if (Application.systemLanguage != SystemLanguage.Japanese) { msg.makeUpperMessageOnBoard("You cut " + okCount + " line. \n Enemy power keep be down in this season."); } else { msg.makeUpperMessageOnBoard("連絡線を" + okCount + "本遮断しました。\n今季節中は敵戦力が減りますぞ。"); } addUsedBusyo.addUsedBusyo(busyoId); } else { msg.makeUpperMessageOnBoard(msg.getMessage(126)); } } else { msg.makeUpperMessageOnBoard(msg.getMessage(127)); } } else { //cyouryaku okRatio = ((float)cyouhouSnbRankId * (float)dfc) / 8; float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= okRatio) { //OK //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); string cyouryaku = PlayerPrefs.GetString("cyouryaku"); string cyouryakuTmp = activeKuniId.ToString() + "cyouryaku" + activeStageId.ToString(); if (cyouryaku != null && cyouryaku != "") { cyouryaku = cyouryaku + "," + cyouryakuTmp; } else { cyouryaku = cyouryakuTmp; } PlayerPrefs.SetString("cyouryaku", cyouryaku); int cyouryakuHeiQty = 0; if (cyouhouSnbRankId == 1) { cyouryakuHeiQty = UnityEngine.Random.Range(1, 3); } else if (cyouhouSnbRankId == 2) { cyouryakuHeiQty = UnityEngine.Random.Range(1, 4); } else if (cyouhouSnbRankId == 3) { cyouryakuHeiQty = UnityEngine.Random.Range(1, 6); } PlayerPrefs.SetInt(cyouryakuTmp, cyouryakuHeiQty); PlayerPrefs.SetBool("questDailyFlg35", true); int TrackCyouryakuNo = PlayerPrefs.GetInt("TrackCyouryakuNo", 0); TrackCyouryakuNo = TrackCyouryakuNo + cyouryakuHeiQty; PlayerPrefs.SetInt("TrackCyouryakuNo", TrackCyouryakuNo); PlayerPrefs.Flush(); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); if (Application.systemLanguage != SystemLanguage.Japanese) { msg.makeUpperMessageOnBoard("You are succeed to win over. \n Enemy " + cyouryakuHeiQty.ToString() + " unit will change to player unit in a battle."); } else { msg.makeUpperMessageOnBoard("調略に成功しましたぞ。\n合戦にて" + cyouryakuHeiQty.ToString() + "部隊が寝返ります。"); } addUsedBusyo.addUsedBusyo(busyoId); } else { msg.makeUpperMessageOnBoard(msg.getMessage(128)); } } //Push Back Button scrollObj.SetActive(false); } } }
// Use this for initialization public void OnClick() { Message msg = new Message(); Gaikou gaikou = new Gaikou(); CloseBoard closeScript = GameObject.Find("close").GetComponent <CloseBoard> (); daimyoId = closeScript.daimyoId; if (hyourouOKflg) { if (moneyOKflg) { //Track int TrackGaikouNo = PlayerPrefs.GetInt("TrackGaikouNo", 0); TrackGaikouNo = TrackGaikouNo + 1; PlayerPrefs.SetInt("TrackGaikouNo", TrackGaikouNo); if (name == "DoMitsugiBtn") { string tempGaikou = "gaikou" + daimyoId; int nowYukoudo = 0; if (PlayerPrefs.HasKey(tempGaikou)) { nowYukoudo = PlayerPrefs.GetInt(tempGaikou); } else { nowYukoudo = 50; } float percent = UnityEngine.Random.value; percent = percent * 100; float tmpYukoudo = (float)nowYukoudo; if (tmpYukoudo < 5) { tmpYukoudo = 5; } if (percent <= tmpYukoudo * 2) { //Success audioSources[3].Play(); reduceMoneyHyourou(); addUsedBusyo(busyoId); //Doumei bool doumeiFlg = closeScript.doumeiFlg; //Add Yukoudo // AddYukoudo = (Money/200)*chiryaku/500 int addYukoudo = (paiedMoney / 200) + (busyoChiryaku / 100); if (addYukoudo <= 0) { addYukoudo = 1; } if (doumeiFlg) { addYukoudo = addYukoudo * 2; } int newYukoudo = nowYukoudo + addYukoudo; if (newYukoudo > 100) { newYukoudo = 100; } PlayerPrefs.SetInt(tempGaikou, newYukoudo); GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); //Change new yukoudo closeScript.yukoudo = newYukoudo; //Message string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Gave money " + paiedMoney + " to " + daimyoName + ".\n Friendship increased " + addYukoudo + " point"; } else { OKtext = daimyoName + "に金" + paiedMoney + "の貢物をしました。\n友好度が" + addYukoudo + "上がりますぞ。"; } msg.makeMessage(OKtext); PlayerPrefs.SetBool("questDailyFlg28", true); PlayerPrefs.Flush(); //Extension Mark Handling MainStageController main = new MainStageController(); main.questExtension(); upYukouOnIcon(daimyoId, newYukoudo); } else { //Fail audioSources[4].Play(); paiedMoney = 0; reduceMoneyHyourou(); //Message string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = daimyoName + " declined our money.\n He doesn't want to build a good relationship with us"; } else { NGtext = daimyoName + "に貢物を体よく断られ申した。\n当家と関係を修復する気はないようですな。"; } msg.makeMessage(NGtext); } //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } else if (name == "DoDoumeiBtn") { reduceMoneyHyourou(); //Doumei float percent = Random.value; percent = percent * 100; if (percent <= doumeiRatio) { //Doumei Success audioSources [3].Play(); //Track int TrackDoumeiNo = PlayerPrefs.GetInt("TrackDoumeiNo", 0); TrackDoumeiNo = TrackDoumeiNo + 1; PlayerPrefs.SetInt("TrackDoumeiNo", TrackDoumeiNo); addUsedBusyo(busyoId); string doumei = PlayerPrefs.GetString("doumei"); if (doumei == null || doumei == "") { doumei = daimyoId.ToString(); } else { doumei = doumei + "," + daimyoId.ToString(); } //Data int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); string cpuDoumeiTemp = "doumei" + daimyoId.ToString(); string cpuDoumei = PlayerPrefs.GetString(cpuDoumeiTemp); if (cpuDoumei != null & cpuDoumei != "") { cpuDoumei = cpuDoumei + "," + myDaimyo.ToString(); } else { cpuDoumei = myDaimyo.ToString(); } PlayerPrefs.SetString(cpuDoumeiTemp, cpuDoumei); PlayerPrefs.SetString("doumei", doumei); //Change Target Flg & Kuni Icon Color string seiryoku = PlayerPrefs.GetString("seiryoku"); char[] delimiterChars = { ',' }; List <string> seiryokuList = new List <string> (); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); GameObject KuniIconView = GameObject.Find("KuniIconView").gameObject; Color doumeiColor = new Color(100f / 255f, 130f / 255f, 255f / 255f, 255f / 255f); //Blue for (int i = 0; i < seiryokuList.Count; i++) { int tempDaimyoId = int.Parse(seiryokuList [i]); if (tempDaimyoId == daimyoId) { int kuniId = i + 1; GameObject kuniIcon = KuniIconView.transform.FindChild(kuniId.ToString()).gameObject; kuniIcon.GetComponent <Image> ().color = doumeiColor; kuniIcon.GetComponent <SendParam> ().doumeiFlg = true; } } PlayerPrefs.SetBool("questSpecialFlg2", true); //Extension Mark Handling MainStageController main = new MainStageController(); main.questExtension(); //Msg string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Congratulations.\n" + "We concluded an alliance with" + daimyoName + ".\n" + "we got some of strategic options."; } else { OKtext = "教悦至極にございます。" + daimyoName + "と同盟を結びましたぞ。\n" + "戦略の幅が広がりますな。"; } msg.makeMessage(OKtext); //If Gunzei Exist foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")) { int srcDaimyoId = obs.GetComponent <Gunzei>().srcDaimyoId; int dstDaimyoId = obs.GetComponent <Gunzei>().dstDaimyoId; if (srcDaimyoId == daimyoId && dstDaimyoId == myDaimyo) { Gunzei gunzeiScript = new Gunzei(); gunzeiScript.deleteGunzei(obs); } } Destroy(GameObject.Find("smallBoard(Clone)")); Destroy(GameObject.Find("TouchBack(Clone)")); } else { //Doumie Failed audioSources [4].Play(); int maxReduceValue = 3; int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; closeScript.yukoudo = newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = daimyoName + " declined our proposal. \n" + "Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); downYukouOnIcon(daimyoId, newYukoudo); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } PlayerPrefs.Flush(); } else if (name == "DoKyoutouBtn") { reduceMoneyHyourou(); //Kyoutou Check float percent = Random.value; percent = percent * 100; if (percent <= kyoutouRatio) { audioSources [3].Play(); //Success addUsedBusyo(busyoId); string playerKyoutouList = PlayerPrefs.GetString("playerKyoutouList", ""); MainEventHandler kyoutou = new MainEventHandler(); if (playerKyoutouList == null || playerKyoutouList == "") { playerKyoutouList = targetKuniId + "-" + kyoutou.getEngunSts(daimyoId.ToString()); } else { playerKyoutouList = playerKyoutouList + ":" + +targetKuniId + "-" + kyoutou.getEngunSts(daimyoId.ToString()); } PlayerPrefs.SetString("playerKyoutouList", playerKyoutouList); //Msg string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Good. " + daimyoName + "will support our party in " + kuniName + " attack"; } else { OKtext = daimyoName + "殿が" + kuniName + "攻めに\n加勢してくれますぞ。百人力ですな。"; } msg.makeMessage(OKtext); } else { //Fail audioSources [4].Play(); //Doumie Failed int maxReduceValue = 3; int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); closeScript.yukoudo = newYukoudo; string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = daimyoName + " declined our proposal. \n" + "Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); downYukouOnIcon(daimyoId, newYukoudo); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } else if (name == "DoDoukatsuBtn") { reduceMoneyHyourou(); float percent = Random.value; percent = percent * 100; if (percent <= doukatsuRatio) { //Success audioSources [3].Play(); addUsedBusyo(busyoId); int kuniQty = closeScript.kuniQty; int getMoney = 0; //Money or Item 0:money, 1:item int moneyOrItem = UnityEngine.Random.Range(0, 2); //Kahou or Shizai 0:kahou, 1:shizai int kahouOrShizai = UnityEngine.Random.Range(0, 2); string kahouName = ""; string shigenName = ""; int addQty = 0; int kahouRank = 0; //kahouRank S,A,B,C=1,2,3,4 //shigen Type int shigenType = 0; //KB,YR,TP,YM=1,2,3,4 if (moneyOrItem == 0) { //money int temGetMoney = UnityEngine.Random.Range(1000, 1501); getMoney = temGetMoney * kuniQty; int nowMoney = PlayerPrefs.GetInt("money"); nowMoney = nowMoney + getMoney; if (nowMoney < 0) { nowMoney = int.MaxValue; } PlayerPrefs.SetInt("money", nowMoney); PlayerPrefs.Flush(); } else { //item //Kahou or Shizai 0:kahou, 1:shizai kahouOrShizai = UnityEngine.Random.Range(0, 2); if (kahouOrShizai == 0) { //kahou Kahou kahou = new Kahou(); ////Bugu, Gusoku, Kabuto, Meiba, Heihousyo, Cyadougu, Chishikisyo(1,2,3,4,5,6) int kahouType = UnityEngine.Random.Range(1, 7); float khPercent = Random.value; khPercent = khPercent * 100; if (5 <= kuniQty) { if (khPercent <= 1) { //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (1 < khPercent && khPercent <= 30) { //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (30 < khPercent) { //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } else if (3 <= kuniQty && kuniQty < 5) { if (khPercent <= 0.5f) { //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (0.5f < khPercent && khPercent <= 10) { //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (10 < khPercent && khPercent <= 40) { //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (40 < khPercent) { //C kahouRank = 4; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } else if (kuniQty < 3) { //(A,B,C : 5, 35, 60%) if (khPercent <= 3) { //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (3 < khPercent && khPercent <= 31) { //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (31 < khPercent) { //C kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } } else { //shizai shigenType = UnityEngine.Random.Range(1, 5); float sgPercent = Random.value; sgPercent = sgPercent * 100; addQty = UnityEngine.Random.Range(1, 6); Item item = new Item(); int shigenRank = 0; //下、中、上=1,2,3 if (5 <= kuniQty) { //(上,中,下 40,40, 20%) if (sgPercent <= 40) { shigenRank = 3; } else if (40 < sgPercent && sgPercent <= 81) { shigenRank = 2; } else if (81 < sgPercent) { shigenRank = 1; } shigenName = item.getRandomShigen(shigenType, shigenRank, addQty); } else if (3 <= kuniQty && kuniQty < 5) { //(上,中,下 20,50,30%) if (sgPercent <= 20) { shigenRank = 3; } else if (20 < sgPercent && sgPercent <= 51) { shigenRank = 2; } else if (51 < sgPercent) { shigenRank = 1; } shigenName = item.getRandomShigen(shigenType, shigenRank, addQty); } else if (kuniQty < 3) { //(上,中,下 5,25,70%) if (sgPercent <= 5) { shigenRank = 3; } else if (5 < sgPercent && sgPercent <= 26) { shigenRank = 2; } else if (26 < sgPercent) { shigenRank = 1; } shigenName = item.getRandomShigen(shigenType, shigenRank, addQty); } } } //Message PlayerPrefs.SetBool("questDailyFlg29", true); //Extension Mark Handling MainStageController main = new MainStageController(); main.questExtension(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "My lord, successed to threat " + daimyoName; } else { OKtext = "御屋形様、恫喝に成功しましたぞ。\n" + daimyoName + "が"; } string addText = ""; if (moneyOrItem == 0) { if (Application.systemLanguage != SystemLanguage.Japanese) { addText = " gave money " + getMoney + "to us.\n"; } else { addText = "金" + getMoney + "を送って参りました。\n"; } } else { if (kahouOrShizai == 0) { //kahou if (Application.systemLanguage != SystemLanguage.Japanese) { addText = " gave treasure " + kahouName + "to us.\n"; } else { addText = "家宝、" + kahouName + "を送って参りました。\n"; } } else { //shizai+ if (Application.systemLanguage != SystemLanguage.Japanese) { addText = " gave " + addQty + " " + shigenName + " to us.\n"; } else { addText = shigenName + "を" + addQty + "個送って参りました。\n"; } } } int maxReduceValue = 5; int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); closeScript.yukoudo = newYukoudo; string reducceText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { reducceText = "Friendship decreased " + reduceYukoudo + " point"; } else { reducceText = "友好度が" + reduceYukoudo + "下がりますぞ。"; } OKtext = OKtext + addText + reducceText; msg.makeMessage(OKtext); downYukouOnIcon(daimyoId, newYukoudo); } else { //Failed audioSources [4].Play(); int maxReduceValue = 10; int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); closeScript.yukoudo = newYukoudo; //Message string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = daimyoName + " declined our proposal. \n" + "Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); downYukouOnIcon(daimyoId, newYukoudo); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } else if (name == "DoSyuppeiBtn") { reduceMoneyHyourou(); //Syuppei Check float percent = Random.value; percent = percent * 100; if (percent <= kyoutouRatio) { audioSources [3].Play(); //Success //Track int TrackSyuppeiNo = PlayerPrefs.GetInt("TrackSyuppeiNo", 0); TrackSyuppeiNo = TrackSyuppeiNo + 1; PlayerPrefs.SetInt("TrackSyuppeiNo", TrackSyuppeiNo); //Success addUsedBusyo(busyoId); //Process string path = "Prefabs/Map/Gunzei"; GameObject Gunzei = Instantiate(Resources.Load(path)) as GameObject; Gunzei.transform.SetParent(GameObject.Find("Panel").transform); Gunzei.transform.localScale = new Vector2(1, 1); //Location KuniInfo kuni = new KuniInfo(); int srcX = kuni.getKuniLocationX(srcKuniId); int srcY = kuni.getKuniLocationY(srcKuniId); int dstX = kuni.getKuniLocationX(targetKuniId); int dstY = kuni.getKuniLocationY(targetKuniId); string direction = ""; Gunzei gunzei = new Gunzei(); if (srcX < dstX) { Gunzei.transform.localScale = new Vector2(1, 1); direction = "right"; } else { Gunzei.transform.localScale = new Vector2(-1, 1); direction = "left"; Gunzei.GetComponent <Gunzei> ().leftFlg = true; } int aveX = (srcX + dstX) / 2; int aveY = (srcY + dstY) / 2; RectTransform GunzeiTransform = Gunzei.GetComponent <RectTransform> (); GunzeiTransform.anchoredPosition = new Vector3(aveX, aveY, 0); string key = srcKuniId.ToString() + "-" + targetKuniId.ToString(); Gunzei.GetComponent <Gunzei> ().key = key; Gunzei.GetComponent <Gunzei> ().srcKuni = srcKuniId; Gunzei.GetComponent <Gunzei> ().srcDaimyoId = srcDaimyoId; Gunzei.GetComponent <Gunzei> ().srcDaimyoName = srcDaimyoName; Gunzei.GetComponent <Gunzei> ().dstKuni = targetKuniId; Gunzei.GetComponent <Gunzei> ().dstDaimyoId = targetDaimyoId; Gunzei.GetComponent <Gunzei> ().dstDaimyoName = targetDaimyoName; int myHei = gunzei.heiryokuCalc(srcKuniId); //random myHei from -50%-myHeis List <float> randomPercent = new List <float> { 0.8f, 0.9f, 1.0f }; int rmd = UnityEngine.Random.Range(0, randomPercent.Count); float per = randomPercent [rmd]; myHei = Mathf.CeilToInt(myHei * per); Gunzei.GetComponent <Gunzei> ().myHei = myHei; Gunzei.name = key; //Engun from Doumei Doumei doumei = new Doumei(); List <string> doumeiDaimyoList = doumei.doumeiExistCheck(targetDaimyoId, srcDaimyoId.ToString()); bool dstEngunFlg = false; string dstEngunDaimyoId = ""; //2:3:5 string dstEngunHei = ""; string dstEngunSts = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv: int totalEngunHei = 0; string seiryoku = PlayerPrefs.GetString("seiryoku"); char[] delimiterChars = { ',' }; List <string> seiryokuList = new List <string>(); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); //Trace Check List <string> okDaimyoList = new List <string> (); List <string> checkList = new List <string> (); okDaimyoList = doumei.traceNeighborDaimyo(targetKuniId, targetDaimyoId, doumeiDaimyoList, seiryokuList, checkList, okDaimyoList); if (okDaimyoList.Count != 0) { //Doumei & Neghbor Daimyo Exist for (int k = 0; k < okDaimyoList.Count; k++) { string engunDaimyo = okDaimyoList[k]; int yukoudo = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), targetDaimyoId); //engun check MainEventHandler mainEvent = new MainEventHandler(); dstEngunFlg = mainEvent.CheckByProbability(yukoudo); if (dstEngunFlg) { //Engun OK dstEngunFlg = true; if (dstEngunDaimyoId != null && dstEngunDaimyoId != "") { dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo; string tempEngunSts = engunDaimyo + "-" + mainEvent.getEngunSts(engunDaimyo); int tempEngunHei = mainEvent.getEngunHei(tempEngunSts); dstEngunHei = dstEngunHei + ":" + tempEngunHei.ToString(); totalEngunHei = totalEngunHei + tempEngunHei; dstEngunSts = dstEngunSts + ":" + tempEngunSts; } else { dstEngunDaimyoId = engunDaimyo; string tempEngunSts = engunDaimyo + "-" + mainEvent.getEngunSts(engunDaimyo); int tempEngunHei = mainEvent.getEngunHei(tempEngunSts); dstEngunHei = tempEngunHei.ToString(); totalEngunHei = tempEngunHei; dstEngunSts = tempEngunSts; } } } Gunzei.GetComponent <Gunzei> ().dstEngunFlg = dstEngunFlg; Gunzei.GetComponent <Gunzei> ().dstEngunDaimyoId = dstEngunDaimyoId; Gunzei.GetComponent <Gunzei> ().dstEngunHei = dstEngunHei; Gunzei.GetComponent <Gunzei> ().dstEngunSts = dstEngunSts; } //Set Value //CreateTime,srcDaimyoId,dstDaimyoId,srcDaimyoName,dstDaimyoName, srcHei,locationX,locationY,left or right, engunFlg, engunDaimyoId(A:B:C), dstEngunHei(1000:2000:3000), dstEngunSts string keyValue = ""; string createTime = System.DateTime.Now.ToString(); keyValue = createTime + "," + srcDaimyoId + "," + targetDaimyoId + "," + srcDaimyoName + "," + targetDaimyoName + "," + myHei + "," + aveX + "," + aveY + "," + direction + "," + dstEngunFlg + "," + dstEngunDaimyoId + "," + dstEngunHei + "," + dstEngunSts; PlayerPrefs.SetString(key, keyValue); string keyHistory = PlayerPrefs.GetString("keyHistory"); if (keyHistory == null || keyHistory == "") { keyHistory = key; } else { keyHistory = keyHistory + "," + key; } PlayerPrefs.SetString("keyHistory", keyHistory); //Msg string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Lord " + daimyoName + " is sending " + myHei + " soldiers to " + kuniName; } else { OKtext = daimyoName + "殿が" + kuniName + "攻めのため、\n" + myHei + "人の兵を起こしましたぞ。"; } string AddText = ""; if (totalEngunHei != 0) { if (Application.systemLanguage != SystemLanguage.Japanese) { AddText = targetDaimyoName + " has a support army " + totalEngunHei + " soldiers"; } else { AddText = targetDaimyoName + "に" + totalEngunHei + "の援軍がいるようです。"; } OKtext = OKtext + "\n" + AddText; } msg.makeMessage(OKtext); } else { //Fail audioSources [4].Play(); int maxReduceValue = 3; int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); closeScript.yukoudo = newYukoudo; string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = daimyoName + " declined our proposal. \n" + "Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); downYukouOnIcon(daimyoId, newYukoudo); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } } else { //Message audioSources [4].Play(); string NGtext = msg.getMessage(6); msg.makeMessage(NGtext); } } else { //Message audioSources [4].Play(); //string NGtext = msg.getMessage(7); //msg.makeMessage (NGtext); msg.hyourouMovieMessage(); } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (!doneCyosyuFlg) { audioSources [3].Play(); doneCyosyuFlg = true; MainStageController main = new MainStageController(); /*** season change Start ***/ string yearSeason = PlayerPrefs.GetString("yearSeason"); char[] delimiterChars = { ',' }; string[] yearSeasonList = yearSeason.Split(delimiterChars); int nowYear = int.Parse(yearSeasonList[0]); int nowSeason = int.Parse(yearSeasonList[1]); if (nowSeason == 4) { nowYear = nowYear + 1; nowSeason = 1; } else { nowSeason = nowSeason + 1; } string newYearSeason = nowYear.ToString() + "," + nowSeason.ToString(); PlayerPrefs.DeleteKey("bakuhuTobatsuDaimyoId"); PlayerPrefs.SetString("yearSeason", newYearSeason); string lastSeasonChangeTime = System.DateTime.Now.ToString(); PlayerPrefs.SetString("lastSeasonChangeTime", lastSeasonChangeTime); PlayerPrefs.DeleteKey("usedBusyo"); DoNextSeason DoNextSeason = new DoNextSeason(); DoNextSeason.deleteLinkCut(); DoNextSeason.deleteWinOver(); PlayerPrefs.Flush(); //Change Label GameObject.Find("YearValue").GetComponent <Text>().text = nowYear.ToString(); main.SetSeason(nowSeason); /*** season change End ***/ PlayerPrefs.SetBool("doneCyosyuFlg", doneCyosyuFlg); string targetName = ""; //Cyosyu Handling if (cyosyuTarget == "money") { int nowMoney = PlayerPrefs.GetInt("money"); int resultMoney = nowMoney + totalMoney; if (totalKozanMoney != 0) { resultMoney = resultMoney + totalKozanMoney; } if (resultMoney < 0) { resultMoney = int.MaxValue; } PlayerPrefs.SetInt("money", resultMoney); if (Application.systemLanguage != SystemLanguage.Japanese) { targetName = "Money"; } else { targetName = "金"; } GameObject.Find("MoneyValue").GetComponent <Text> ().text = resultMoney.ToString(); int TrackGetMoneyNo = PlayerPrefs.GetInt("TrackGetMoneyNo", 0); TrackGetMoneyNo = TrackGetMoneyNo + totalMoney + totalKozanMoney; PlayerPrefs.SetInt("TrackGetMoneyNo", TrackGetMoneyNo); } else if (cyosyuTarget == "hyourou") { int nowHyourou = PlayerPrefs.GetInt("hyourou"); int maxHyourou = PlayerPrefs.GetInt("hyourouMax"); int resultHyourou = nowHyourou + totalHyourou; if (resultHyourou > maxHyourou) { resultHyourou = maxHyourou; } PlayerPrefs.SetInt("hyourou", resultHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = resultHyourou.ToString(); if (Application.systemLanguage != SystemLanguage.Japanese) { targetName = "Stamina"; } else { targetName = "兵糧"; } int TrackGetHyourouNo = PlayerPrefs.GetInt("TrackGetHyourouNo", 0); TrackGetHyourouNo = TrackGetHyourouNo + totalHyourou; PlayerPrefs.SetInt("TrackGetHyourouNo", TrackGetHyourouNo); if (totalKozanMoney != 0) { int nowMoney = PlayerPrefs.GetInt("money"); int resultMoney = nowMoney + totalKozanMoney; if (resultMoney < 0) { resultMoney = int.MaxValue; } PlayerPrefs.SetInt("money", resultMoney); if (Application.systemLanguage != SystemLanguage.Japanese) { targetName = targetName + " and Gold"; } else { targetName = targetName + "と鉱山収入"; } GameObject.Find("MoneyValue").GetComponent <Text> ().text = resultMoney.ToString(); int TrackGetMoneyNo = PlayerPrefs.GetInt("TrackGetMoneyNo", 0); TrackGetMoneyNo = TrackGetMoneyNo + totalKozanMoney; PlayerPrefs.SetInt("TrackGetMoneyNo", TrackGetMoneyNo); } } else if (cyosyuTarget == "gunjyu") { if (Application.systemLanguage != SystemLanguage.Japanese) { targetName = "Weapon"; } else { targetName = "軍需物資"; } //YR if (totalYRL != 0 || totalYRM != 0 || totalYRH != 0) { string cyoheiYRString = PlayerPrefs.GetString("cyouheiYR"); List <string> cyoheiYRList = new List <string>(); cyoheiYRList = new List <string> (cyoheiYRString.Split(delimiterChars)); int newYRL = totalYRL; int newYRM = totalYRM; int newYRH = totalYRH; newYRL = newYRL + int.Parse(cyoheiYRList[0]); newYRM = newYRM + int.Parse(cyoheiYRList[1]); newYRH = newYRH + int.Parse(cyoheiYRList[2]); string newCyoheiYR = newYRL + "," + newYRM + "," + newYRH; PlayerPrefs.SetString("cyouheiYR", newCyoheiYR); } //KB if (totalKBL != 0 || totalKBM != 0 || totalKBH != 0) { string cyoheiKBString = PlayerPrefs.GetString("cyouheiKB"); List <string> cyoheiKBList = new List <string>(); cyoheiKBList = new List <string> (cyoheiKBString.Split(delimiterChars)); int newKBL = totalKBL; int newKBM = totalKBM; int newKBH = totalKBH; newKBL = newKBL + int.Parse(cyoheiKBList[0]); newKBM = newKBM + int.Parse(cyoheiKBList[1]); newKBH = newKBH + int.Parse(cyoheiKBList[2]); string newCyoheiKB = newKBL + "," + newKBM + "," + newKBH; PlayerPrefs.SetString("cyouheiKB", newCyoheiKB); } //YM if (totalYML != 0 || totalYMM != 0 || totalYMH != 0) { string cyoheiYMString = PlayerPrefs.GetString("cyouheiYM"); List <string> cyoheiYMList = new List <string>(); cyoheiYMList = new List <string> (cyoheiYMString.Split(delimiterChars)); int newYML = totalYML; int newYMM = totalYMM; int newYMH = totalYMH; newYML = newYML + int.Parse(cyoheiYMList[0]); newYMM = newYMM + int.Parse(cyoheiYMList[1]); newYMH = newYMH + int.Parse(cyoheiYMList[2]); string newCyoheiYM = newYML + "," + newYMM + "," + newYMH; PlayerPrefs.SetString("cyouheiYM", newCyoheiYM); } //TP if (totalTPL != 0 || totalTPM != 0 || totalTPH != 0) { string cyoheiTPString = PlayerPrefs.GetString("cyouheiTP"); List <string> cyoheiTPList = new List <string>(); cyoheiTPList = new List <string> (cyoheiTPString.Split(delimiterChars)); int newTPL = totalTPL; int newTPM = totalTPM; int newTPH = totalTPH; newTPL = newTPL + int.Parse(cyoheiTPList[0]); newTPM = newTPM + int.Parse(cyoheiTPList[1]); newTPH = newTPH + int.Parse(cyoheiTPList[2]); string newCyoheiTP = newTPL + "," + newTPM + "," + newTPH; PlayerPrefs.SetString("cyouheiTP", newCyoheiTP); } //SNB if (totalSNBL != 0 || totalSNBM != 0 || totalSNBH != 0) { if (totalSNBL != 0) { int SNBQty = PlayerPrefs.GetInt("shinobiGe"); int newQty = SNBQty + totalSNBL; PlayerPrefs.SetInt("shinobiGe", newQty); } if (totalSNBM != 0) { int SNBQty = PlayerPrefs.GetInt("shinobiCyu"); int newQty = SNBQty + totalSNBM; PlayerPrefs.SetInt("shinobiCyu", newQty); } if (totalSNBH != 0) { int SNBQty = PlayerPrefs.GetInt("shinobiJyo"); int newQty = SNBQty + totalSNBH; PlayerPrefs.SetInt("shinobiJyo", newQty); } } int TrackGetSozaiNo = PlayerPrefs.GetInt("TrackGetSozaiNo", 0); TrackGetSozaiNo = TrackGetSozaiNo + totalYRL + totalKBL + totalYML + totalTPL + totalYRM + totalKBM + totalYMM + totalTPM + totalYRH + totalKBH + totalYMH + totalTPH + totalSNBL + totalSNBM + totalSNBH; PlayerPrefs.SetInt("TrackGetSozaiNo", TrackGetSozaiNo); if (totalKozanMoney != 0) { int nowMoney = PlayerPrefs.GetInt("money"); int resultMoney = nowMoney + totalKozanMoney; if (resultMoney < 0) { resultMoney = int.MaxValue; } PlayerPrefs.SetInt("money", resultMoney); if (Application.systemLanguage != SystemLanguage.Japanese) { targetName = targetName + " and Gold"; } else { targetName = targetName + "と鉱山収入"; } GameObject.Find("MoneyValue").GetComponent <Text> ().text = resultMoney.ToString(); int TrackGetMoneyNo = PlayerPrefs.GetInt("TrackGetMoneyNo", 0); TrackGetMoneyNo = TrackGetMoneyNo + totalKozanMoney; PlayerPrefs.SetInt("TrackGetMoneyNo", TrackGetMoneyNo); } } PlayerPrefs.SetBool("questDailyFlg38", true); PlayerPrefs.Flush(); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); //Message Message msg = new Message(); string text = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { text = "My lord, you earned " + targetName + ".\nPlease enrich the country more by development."; } else { text = targetName + "を徴収しましたぞ。\n内政でより国を富ませましょう。"; } msg.makeMessageOnBoard(text); //Restart GameObject.Find("GameController").GetComponent <MainStageController>().doneCyosyuFlg = true; GameObject.Find("GetTimer").GetComponent <GetNaiseiTimer>().Start(); GameObject.Find("GetTimer").GetComponent <GetNaiseiTimer>().timer = GameObject.Find("GameController").GetComponent <MainStageController>().yearTimer; //tutorial if (Application.loadedLevelName == "tutorialMain") { Destroy(GameObject.Find("board").gameObject); Destroy(GameObject.Find("Back(Clone)").gameObject); PlayerPrefs.SetInt("tutorialId", 5); PlayerPrefs.Flush(); TextController txtScript = GameObject.Find("TextBoard").transform.FindChild("Text").GetComponent <TextController>(); txtScript.SetText(5); txtScript.SetNextLine(); txtScript.tutorialId = 5; txtScript.actOnFlg = false; GameObject SubButtonViewLeft = GameObject.Find("SubButtonViewLeft").gameObject; GameObject.Find("SeiryokuInfo").transform.SetParent(SubButtonViewLeft.transform); } } else { audioSources [4].Play(); Message msg = new Message(); string text = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { text = "Season hasn't changed.\nPlease wait a moment for collecting taxes."; } else { text = "まだ季節は変わっておりませぬぞ。\n徴収は今しばらくお待ち下さいませ。"; } msg.makeMessageOnBoard(text); } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); Message msg = new Message(); if (name != "PassButton") { //Syoukaijyo Confirm Pop audioSources [0].Play(); //Back string pathOfBack = "Prefabs/Cyoutei/TouchBackLayer"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); //Cyoutei Pop string pathOfPop = "Prefabs/Syounin/SelectSyoukaijyoBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "SelectSyoukaijyoBoard"; back.GetComponent <CloseLayer> ().closeTargetObj = pop; back.GetComponent <CloseLayer> ().closeTargetBack = back; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetObj = pop; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetBack = back; //Check Syoukaijyo string nowQty = PlayerPrefs.GetString("koueki"); //string nowQty = "0,0,0"; List <string> nowQtyList = new List <string> (); char[] delimiterChars = { ',' }; nowQtyList = new List <string> (nowQty.Split(delimiterChars)); GameObject scrollView = pop.transform.FindChild("ScrollView").gameObject; GameObject content = scrollView.transform.FindChild("Content").gameObject; bool notZeroflg = false; //Jyo if (nowQtyList [2] == "0") { content.transform.FindChild("Jyo").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Jyo").transform.FindChild("syounin").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [2]; content.transform.FindChild("Jyo").GetComponent <SyoukaijyoSelect> ().OnClick(); } //Cyu if (nowQtyList [1] == "0") { content.transform.FindChild("Cyu").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Cyu").transform.FindChild("syounin").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [1]; content.transform.FindChild("Cyu").GetComponent <SyoukaijyoSelect> ().OnClick(); } //Ge if (nowQtyList [0] == "0") { content.transform.FindChild("Ge").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Ge").transform.FindChild("syounin").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [0]; content.transform.FindChild("Ge").GetComponent <SyoukaijyoSelect> ().OnClick(); } if (!notZeroflg) { scrollView.transform.FindChild("NoSyoukaijyo").GetComponent <Text> ().enabled = true; pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = msg.getMessage(41); pop.transform.FindChild("PassButton").gameObject.SetActive(false); } pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().SelectSyoukaijyoBoard = pop; pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().myDaimyoFlg = myDaimyoFlg; pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().occupiedDaimyoName = occupiedDaimyoName; pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().yukoudo = yukoudo; //Icon Change if (sakaiFlg) { string imagePath = "Prefabs/Syounin/Sprite/syounin2"; pop.transform.FindChild("Syounin").GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; if (Application.systemLanguage != SystemLanguage.Japanese) { pop.transform.FindChild("SyouninName").GetComponent <Text>().text = "Rikyu Sen"; } else { pop.transform.FindChild("SyouninName").GetComponent <Text> ().text = "千利休"; } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { pop.transform.FindChild("SyouninName").GetComponent <Text>().text = "Sotan Kamiya"; } } } else { //Cyoutei Main Pop int hyourou = PlayerPrefs.GetInt("hyourou"); if (hyourou >= 5) { int newHyourou = hyourou - 5; PlayerPrefs.SetInt("hyourou", newHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString(); //Check Yukoudo int ratio = 100 - yukoudo; if (myDaimyoFlg) { ratio = 0; } float percent = Random.value; percent = percent * 100; if (percent > ratio) { //Stop Timer CyouteiPop cyouteiPop = new CyouteiPop(); cyouteiPop.stopGunzei(); GameObject.Find("GameController").GetComponent <MainStageController>().eventStopFlg = true; audioSources [3].Play(); SelectSyoukaijyoBoard.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().OnClick(); string pathOfBack = "Prefabs/Cyoutei/CyouteiBack"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); string pathOfPop = "Prefabs/Syounin/SyouninBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "SyouninBoard"; CloseLayer CloseLayerScript = pop.transform.FindChild("CloseSyoukaijyo").GetComponent <CloseLayer> (); CloseLayerScript.closeTargetBack = back; CloseLayerScript.closeTargetObj = pop; CloseLayerScript.syoukaijyoRank = syoukaijyoRank; CloseLayerScript.occupiedFlg = myDaimyoFlg; CloseLayerScript.syouninCyouteiFlg = true; //RandomValue int yukouAddValue = 0; int yukouReducePoint = Random.Range(2, 10); int stopBattleRatio = 0; int stopBattleReducePoint = Random.Range(2, 10); int kanniRatio = 0; int kanniReducePoint = Random.Range(20, 100); int syoukaijyoRankId = 0; //Change Menu by syoukaijyo rank GameObject action = pop.transform.FindChild("Action").gameObject; if (syoukaijyoRank == "Ge") { if (!myDaimyoFlg) { List <string> btnNameList = new List <string> () { "Yasen", "Youjinbou", "Cyakai", "Gijyutsu" }; enableButton(pop, btnNameList); } else { List <string> btnNameList = new List <string> () { "Youjinbou", "Cyakai", "Gijyutsu" }; enableButton(pop, btnNameList); } yukouAddValue = Random.Range(1, 3); stopBattleRatio = Random.Range(10, 30); kanniRatio = Random.Range(20, 60); syoukaijyoRankId = 1; action.transform.FindChild("ActionValue").GetComponent <Text> ().text = "1"; action.transform.FindChild("ActionMaxValue").GetComponent <Text> ().text = "1"; } else if (syoukaijyoRank == "Cyu") { if (!myDaimyoFlg) { List <string> btnNameList = new List <string> () { "Yasen", "Gijyutsu" }; enableButton(pop, btnNameList); } else { List <string> btnNameList = new List <string> () { "Gijyutsu" }; enableButton(pop, btnNameList); } yukouAddValue = Random.Range(3, 8); stopBattleRatio = Random.Range(30, 80); kanniRatio = Random.Range(40, 80); syoukaijyoRankId = 2; action.transform.FindChild("ActionValue").GetComponent <Text> ().text = "2"; action.transform.FindChild("ActionMaxValue").GetComponent <Text> ().text = "2"; } else if (syoukaijyoRank == "Jyo") { if (!myDaimyoFlg) { List <string> btnNameList = new List <string> () { "Yasen", "Gijyutsu" }; enableButton(pop, btnNameList); } yukouAddValue = Random.Range(8, 15); stopBattleRatio = 100; kanniRatio = Random.Range(60, 100); syoukaijyoRankId = 3; action.transform.FindChild("ActionValue").GetComponent <Text> ().text = "3"; action.transform.FindChild("ActionMaxValue").GetComponent <Text> ().text = "3"; } //reduce cyoutei syoukaijyo DoSell script = new DoSell(); script.deleteKouekiOrCyoutei(syoukaijyoRankId, "koueki", 1); //TargetKahou Preparation Kahou kahou = new Kahou(); string kahouCdString = ""; string kahouIdString = ""; for (int i = 1; i < 4; i++) { List <string> kahouRandom = new List <string> () { "bugu", "kabuto", "gusoku", "meiba", "cyadougu", "chishikisyo", "heihousyo" }; int rdm = UnityEngine.Random.Range(0, 7); string kahouType = kahouRandom [rdm]; string kahouRank = getItemRank(syoukaijyoRankId); int kahouId = kahou.getRamdomKahouId(kahouType, kahouRank); //string targetKahou = kahouType + kahouId.ToString(); if (kahouCdString != null && kahouCdString != "") { kahouCdString = kahouCdString + "," + kahouType; kahouIdString = kahouIdString + "," + kahouId.ToString(); } else { kahouCdString = kahouType; kahouIdString = kahouId.ToString(); } } CloseLayerScript.kahouCdString = kahouCdString; CloseLayerScript.kahouIdString = kahouIdString; //TargetBusshi Preparation string busshiQtyString = ""; //Qty of busshi string busshiRankString = ""; //Rank of busshi for (int l = 1; l < 6; l++) { int rdmQty = UnityEngine.Random.Range(1, 10); int rdmRnk = UnityEngine.Random.Range(1, 4); if (busshiQtyString != null && busshiQtyString != "") { busshiQtyString = busshiQtyString + "," + rdmQty.ToString(); busshiRankString = busshiRankString + "," + rdmRnk.ToString(); } else { busshiQtyString = rdmQty.ToString(); busshiRankString = rdmRnk.ToString(); } } CloseLayerScript.busshiQtyString = busshiQtyString; CloseLayerScript.busshiRankString = busshiRankString; //TargetYoujinbou int rdmKengouId = UnityEngine.Random.Range(1, 10); CloseLayerScript.rdmKengouId = rdmKengouId; //Yasengaku int yasenAmt = 0; if (syoukaijyoRankId == 1) { yasenAmt = UnityEngine.Random.Range(1000, 3000); } else if (syoukaijyoRankId == 2) { yasenAmt = UnityEngine.Random.Range(2000, 5000); } else if (syoukaijyoRankId == 3) { yasenAmt = UnityEngine.Random.Range(3000, 10000); } CloseLayerScript.yasenAmt = yasenAmt; //Gijyutsuiten int techId = UnityEngine.Random.Range(1, 4); CloseLayerScript.techId = techId; //Discount Percent float discount = UnityEngine.Random.Range(0.5f, 0.9f); CloseLayerScript.discount = discount; Daimyo daimyo = new Daimyo(); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); //Serihu string daimyoName = daimyo.getName(myDaimyo); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Oh, lord " + daimyoName + ".\nCan I help you?"; } else { serihu = "これは" + daimyoName + "様。\n私共めに何用で御座いましょうか。"; } pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = serihu; PlayerPrefs.SetBool("questSpecialFlg4", true); PlayerPrefs.Flush(); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); } else { audioSources [4].Play(); if (Application.systemLanguage != SystemLanguage.Japanese) { msg.makeMessage("My lord " + occupiedDaimyoName + " disturbed our business."); } else { msg.makeMessage("御屋形様、" + occupiedDaimyoName + "めに\n取引を邪魔されました。"); } } } else { audioSources [4].Play(); //msg.makeMessage (msg.getMessage(7)); msg.hyourouMovieMessage(); } } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (criteria == 0) { //Change Flg audioSources[3].Play(); PlayerPrefs.SetBool(key, true); if (target == "money") { int money = PlayerPrefs.GetInt("money"); int newMoney = money + amnt; if (newMoney < 0) { newMoney = int.MaxValue; } PlayerPrefs.SetInt("money", newMoney); GameObject.Find("MoneyValue").GetComponent <Text> ().text = newMoney.ToString(); } else if (target == "busyoDama") { int busyoDama = PlayerPrefs.GetInt("busyoDama"); int newBusyoDama = busyoDama + amnt; PlayerPrefs.SetInt("busyoDama", newBusyoDama); GameObject.Find("BusyoDamaValue").GetComponent <Text> ().text = newBusyoDama.ToString(); } PlayerPrefs.Flush(); //Remove Quest Destroy(slot); deleteQuest(false, key, id); } else { if (count < criteria) { //error audioSources[4].Play(); Message msg = new Message(); msg.makeMessageOnBoard(msg.getMessage(152)); } else { audioSources[3].Play(); PlayerPrefs.SetBool(key, true); if (target == "busyoDama") { int busyoDama = PlayerPrefs.GetInt("busyoDama"); int newBusyoDama = busyoDama + amnt; PlayerPrefs.SetInt("busyoDama", newBusyoDama); GameObject.Find("BusyoDamaValue").GetComponent <Text>().text = newBusyoDama.ToString(); } PlayerPrefs.Flush(); //Remove Quest Destroy(slot); deleteQuest(true, key, id); } } //Extension Mark Handling MainStageController main = new MainStageController(); main.questExtension(); }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); int hyourou = PlayerPrefs.GetInt("hyourou"); Message msg = new Message(); if (hyourou >= 5) { int money = PlayerPrefs.GetInt("money"); int payMoney = int.Parse(GameObject.Find("MoneyAmt").GetComponent <Text>().text); if (money >= payMoney) { /***OK***/ audioSources [3].Play(); //Reduce Hyourou int newHyourou = hyourou - 5; PlayerPrefs.SetInt("hyourou", newHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString(); //Reduce Money int newMoney = money - payMoney; PlayerPrefs.SetInt("money", newMoney); GameObject.Find("MoneyValue").GetComponent <Text> ().text = newMoney.ToString(); //Add Item char[] delimiterChars = { ',' }; int buyQty = int.Parse(GameObject.Find("BuyMenu").transform.FindChild("Qty").GetComponent <Text>().text); if (item.Contains("Cyouhei") == true) { if (item.Contains("YR") == true) { string cyouheiYRString = PlayerPrefs.GetString("cyouheiYR"); string[] cyouheiYR_list = cyouheiYRString.Split(delimiterChars); string newCyouheiYRString = ""; if (item == "CyouheiYR1") { int newQty = 0; newQty = int.Parse(cyouheiYR_list[0]) + buyQty; newCyouheiYRString = newQty.ToString() + "," + cyouheiYR_list[1] + "," + cyouheiYR_list[2]; } else if (item == "CyouheiYR2") { int newQty = 0; newQty = int.Parse(cyouheiYR_list[1]) + buyQty; newCyouheiYRString = cyouheiYR_list[0] + "," + newQty.ToString() + "," + cyouheiYR_list[2]; } else if (item == "CyouheiYR3") { int newQty = 0; newQty = int.Parse(cyouheiYR_list[2]) + buyQty; newCyouheiYRString = cyouheiYR_list[0] + "," + cyouheiYR_list[1] + "," + newQty.ToString(); } PlayerPrefs.SetString("cyouheiYR", newCyouheiYRString); } else if (item.Contains("KB") == true) { string cyouheiKBString = PlayerPrefs.GetString("cyouheiKB"); string[] cyouheiKB_list = cyouheiKBString.Split(delimiterChars); string newCyouheiKBString = ""; if (item == "CyouheiKB1") { int newQty = 0; newQty = int.Parse(cyouheiKB_list[0]) + buyQty; newCyouheiKBString = newQty.ToString() + "," + cyouheiKB_list[1] + "," + cyouheiKB_list[2]; } else if (item == "CyouheiKB2") { int newQty = 0; newQty = int.Parse(cyouheiKB_list[1]) + buyQty; newCyouheiKBString = cyouheiKB_list[0] + "," + newQty.ToString() + "," + cyouheiKB_list[2]; } else if (item == "CyouheiKB3") { int newQty = 0; newQty = int.Parse(cyouheiKB_list[2]) + buyQty; newCyouheiKBString = cyouheiKB_list[0] + "," + cyouheiKB_list[1] + "," + newQty.ToString(); } PlayerPrefs.SetString("cyouheiKB", newCyouheiKBString); } else if (item.Contains("TP") == true) { string cyouheiTPString = PlayerPrefs.GetString("cyouheiTP"); string[] cyouheiTP_list = cyouheiTPString.Split(delimiterChars); string newCyouheiTPString = ""; if (item == "CyouheiTP1") { int newQty = 0; newQty = int.Parse(cyouheiTP_list[0]) + buyQty; newCyouheiTPString = newQty.ToString() + "," + cyouheiTP_list[1] + "," + cyouheiTP_list[2]; } else if (item == "CyouheiTP2") { int newQty = 0; newQty = int.Parse(cyouheiTP_list[1]) + buyQty; newCyouheiTPString = cyouheiTP_list[0] + "," + newQty.ToString() + "," + cyouheiTP_list[2]; } else if (item == "CyouheiTP3") { int newQty = 0; newQty = int.Parse(cyouheiTP_list[2]) + buyQty; newCyouheiTPString = cyouheiTP_list[0] + "," + cyouheiTP_list[1] + "," + newQty.ToString(); } PlayerPrefs.SetString("cyouheiTP", newCyouheiTPString); } else if (item.Contains("YM") == true) { string cyouheiYMString = PlayerPrefs.GetString("cyouheiYM"); string[] cyouheiYM_list = cyouheiYMString.Split(delimiterChars); string newCyouheiYMString = ""; if (item == "CyouheiYM1") { int newQty = 0; newQty = int.Parse(cyouheiYM_list[0]) + buyQty; newCyouheiYMString = newQty.ToString() + "," + cyouheiYM_list[1] + "," + cyouheiYM_list[2]; } else if (item == "CyouheiYM2") { int newQty = 0; newQty = int.Parse(cyouheiYM_list[1]) + buyQty; newCyouheiYMString = cyouheiYM_list[0] + "," + newQty.ToString() + "," + cyouheiYM_list[2]; } else if (item == "CyouheiYM3") { int newQty = 0; newQty = int.Parse(cyouheiYM_list[2]) + buyQty; newCyouheiYMString = cyouheiYM_list[0] + "," + cyouheiYM_list[1] + "," + newQty.ToString(); } PlayerPrefs.SetString("cyouheiYM", newCyouheiYMString); } } else if (item.Contains("Hidensyo") == true) { if (item == "Hidensyo1") { int newQty = 0; int HidensyoQty = PlayerPrefs.GetInt("hidensyoGe"); newQty = HidensyoQty + buyQty; PlayerPrefs.SetInt("hidensyoGe", newQty); } else if (item == "Hidensyo2") { int newQty = 0; int HidensyoQty = PlayerPrefs.GetInt("hidensyoCyu"); newQty = HidensyoQty + buyQty; PlayerPrefs.SetInt("hidensyoCyu", newQty); } else if (item == "Hidensyo3") { int newQty = 0; int HidensyoQty = PlayerPrefs.GetInt("hidensyoJyo"); newQty = HidensyoQty + buyQty; PlayerPrefs.SetInt("hidensyoJyo", newQty); } } else if (item.Contains("Shinobi") == true) { if (item == "Shinobi1") { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt("shinobiGe"); newQty = shinobiQty + buyQty; PlayerPrefs.SetInt("shinobiGe", newQty); } else if (item == "Shinobi2") { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt("shinobiCyu"); newQty = shinobiQty + buyQty; PlayerPrefs.SetInt("shinobiCyu", newQty); } else if (item == "Shinobi3") { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt("shinobiJyo"); newQty = shinobiQty + buyQty; PlayerPrefs.SetInt("shinobiJyo", newQty); } } else if (item.Contains("Kanjyo") == true) { string kanjyoString = PlayerPrefs.GetString("kanjyo"); string[] kanjyo_list = kanjyoString.Split(delimiterChars); string newKanjyoString = ""; if (item == "Kanjyo1") { int newQty = 0; newQty = int.Parse(kanjyo_list[0]) + buyQty; newKanjyoString = newQty.ToString() + "," + kanjyo_list[1] + "," + kanjyo_list[2]; } else if (item == "Kanjyo2") { int newQty = 0; newQty = int.Parse(kanjyo_list[1]) + buyQty; newKanjyoString = kanjyo_list[0] + "," + newQty.ToString() + "," + kanjyo_list[2]; } else if (item == "Kanjyo3") { int newQty = 0; newQty = int.Parse(kanjyo_list[2]) + buyQty; newKanjyoString = kanjyo_list[0] + "," + kanjyo_list[1] + "," + newQty.ToString(); } PlayerPrefs.SetString("kanjyo", newKanjyoString); } PlayerPrefs.SetBool("questDailyFlg27", true); PlayerPrefs.Flush(); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); //Closing GameObject.Find("SerihuText").GetComponent <Text>().text = msg.getMessage(11); //Message msg.makeMessage(msg.getMessage(12)); } else { //Message audioSources [4].Play(); msg.makeMessage(msg.getMessage(6)); } } else { //Message audioSources [4].Play(); //msg.makeMessage (msg.getMessage(7)); msg.hyourouMovieMessage(); } }