public void randomMyKahouView(GameObject slot) { //Money or Item 0:money, 1:item int moneyOrItem = UnityEngine.Random.Range(0, 2); if (moneyOrItem == 0) { //money int requriedMoney = UnityEngine.Random.Range(1000, 5000); slot.GetComponent <ShisyaSelect> ().moneyNo = requriedMoney; } else { //kahou Kahou kahou = new Kahou(); List <string> kahouCdId = new List <string> (); kahouCdId = kahou.getMyRandomKahouCdId(); if (kahouCdId.Count != 0) { //kahou slot.GetComponent <ShisyaSelect>().itemCd = kahouCdId[0]; slot.GetComponent <ShisyaSelect>().itemId = kahouCdId[1]; slot.GetComponent <ShisyaSelect>().itemDataCd = kahouCdId[2]; } else { //money int requriedMoney = UnityEngine.Random.Range(1000, 5000); slot.GetComponent <ShisyaSelect> ().moneyNo = requriedMoney; } } }
public void getWinItem() { Message msg = new Message(); AttackNaiseiView script = new AttackNaiseiView(); HPCounter hpScript = new HPCounter(); Item itemScript = new Item(); string itemGrp = getRandomItemGrp(); string itemTyp = ""; int itemId = 0; int itemQty = 1; string itemName = ""; string MsgText = ""; if (itemGrp == "item") { itemTyp = script.getRandomItemTyp(itemGrp); if (itemTyp == "tech") { itemId = script.getItemRank(30, 10); if (Application.systemLanguage != SystemLanguage.Japanese) { MsgText = "You got " + itemScript.getItemName(itemTyp + itemId.ToString()) + "."; } else { MsgText = itemScript.getItemName(itemTyp + itemId.ToString()) + "を手に入れましたぞ。"; } msg.makeMeshMessage(MsgText); } else if (itemTyp == "Tama") { itemId = script.getItemRank(10, 1); if (itemId == 3) { itemQty = 100; } else if (itemId == 2) { itemQty = 20; } else if (itemId == 1) { itemQty = 5; } if (Application.systemLanguage != SystemLanguage.Japanese) { MsgText = "You got " + itemQty.ToString() + " stone."; } else { MsgText = "武将珠を" + itemQty.ToString() + "個手に入れましたぞ。"; } msg.makeMeshMessage(MsgText); } else { itemId = script.getItemRank(10, 1); if (Application.systemLanguage != SystemLanguage.Japanese) { MsgText = "You got " + itemScript.getItemName(itemTyp + itemId.ToString()) + "."; } else { MsgText = itemScript.getItemName(itemTyp + itemId.ToString()) + "を手に入れましたぞ。"; } msg.makeMeshMessage(MsgText); } } else if (itemGrp == "kahou") { itemTyp = script.getRandomItemTyp(itemGrp); Kahou kahou = new Kahou(); string kahouRank = getKahouRank(); itemId = kahou.getRamdomKahouId(itemTyp, kahouRank); itemName = kahou.getKahouName(itemTyp, itemId); if (Application.systemLanguage != SystemLanguage.Japanese) { MsgText = "You got treasure, " + itemName + "."; } else { MsgText = "家宝、" + itemName + "を手に入れましたぞ。"; } msg.makeMeshMessage(MsgText); hpScript.addKahou(itemTyp, itemId); } else if (itemGrp == "money") { itemQty = UnityEngine.Random.Range(100, 500); if (Application.systemLanguage != SystemLanguage.Japanese) { MsgText = "You got money " + itemQty.ToString() + "."; } else { MsgText = "金" + itemQty.ToString() + "を手に入れましたぞ。"; } msg.makeMeshMessage(MsgText); int currentMoney = PlayerPrefs.GetInt("money"); int newMoney = currentMoney + itemQty; if (newMoney < 0) { newMoney = int.MaxValue; } PlayerPrefs.SetInt("money", newMoney); GameObject.Find("MoneyValue").GetComponent <Text>().text = newMoney.ToString(); } else { if (Application.systemLanguage != SystemLanguage.Japanese) { MsgText = "No items"; } else { MsgText = "戦利品はありませんでした。"; } msg.makeMeshMessage(MsgText); } registerItemQty(itemGrp, itemTyp, itemId, itemQty); PlayerPrefs.Flush(); }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); GameObject board = GameObject.Find("SyouninBoard").gameObject; Message msg = new Message(); GameObject actionValue = GameObject.Find("ActionValue").gameObject; int actionRemainQty = int.Parse(actionValue.GetComponent <Text> ().text); char[] delimiterChars = { ',' }; if (actionRemainQty <= 0) { audioSources [4].Play(); msg.makeMessage(msg.getMessage(42)); serihuChanger(msg.getMessage(43)); } else { CloseLayer CloseLayerScript = GameObject.Find("CloseSyoukaijyo").GetComponent <CloseLayer>(); if (name == "Kahou") { audioSources [0].Play(); string path = "Prefabs/Syounin/MenuKahou"; GameObject menu = Instantiate(Resources.Load(path)) as GameObject; menu.transform.SetParent(board.transform); menu.transform.localScale = new Vector2(1, 1); menu.transform.localPosition = new Vector2(0, -150); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuKahou"; //Product Show string kahouCdString = CloseLayerScript.kahouCdString; List <string> kahouCdList = new List <string> (); kahouCdList = new List <string> (kahouCdString.Split(delimiterChars)); string kahouIdString = CloseLayerScript.kahouIdString; List <string> kahouIdList = new List <string> (); kahouIdList = new List <string> (kahouIdString.Split(delimiterChars)); GameObject content = menu.transform.FindChild("ScrollView").transform.FindChild("Content").gameObject; GameObject money = menu.transform.FindChild("MoneyValue").gameObject; GameObject btn = menu.transform.FindChild("DoKahouButton").gameObject; KahouStatusGet kahouSts = new KahouStatusGet(); for (int i = 0; i < kahouCdList.Count; i++) { string kahouCd = kahouCdList[i]; int kahouId = int.Parse(kahouIdList[i]); string kahouCdId = kahouCd + kahouId; string kahouPath = "Prefabs/Item/Kahou/" + kahouCdId; int tmp = i + 1; string slotName = "item" + tmp.ToString(); GameObject itemSlot = content.transform.FindChild(slotName).gameObject; itemSlot.GetComponent <SyouninProductSelect>().Content = content; //status List <string> kahouStsList = new List <string> (); kahouStsList = kahouSts.getKahouInfo(kahouCd, kahouId); itemSlot.GetComponent <SyouninProductSelect>().kahouName = kahouStsList[0]; itemSlot.GetComponent <SyouninProductSelect>().kahouEffectLabel = kahouStsList[2]; itemSlot.GetComponent <SyouninProductSelect>().kahouEffectValue = kahouStsList[3]; float price = float.Parse(kahouStsList[5]); float discount = CloseLayerScript.discount; float finalPrice = price * discount; itemSlot.GetComponent <SyouninProductSelect>().price = Mathf.CeilToInt(finalPrice); itemSlot.GetComponent <SyouninProductSelect>().Money = money; itemSlot.GetComponent <SyouninProductSelect>().Btn = btn; itemSlot.GetComponent <SyouninProductSelect>().menuName = name; itemSlot.GetComponent <SyouninProductSelect>().kahouCd = kahouCd; itemSlot.GetComponent <SyouninProductSelect>().kahouId = kahouId; //kahou icon GameObject kahouObj = Instantiate(Resources.Load(kahouPath)) as GameObject; kahouObj.transform.SetParent(itemSlot.transform); kahouObj.transform.localScale = new Vector2(1, 1); kahouObj.GetComponent <Button>().enabled = false; //Adjust RectTransform rect = kahouObj.transform.FindChild("Rank").GetComponent <RectTransform>(); rect.anchoredPosition3D = new Vector3(20, -30, 0); kahouObj.transform.FindChild("Rank").localScale = new Vector3(0.3f, 0.3f, 0); } //Initial content.transform.FindChild("item1").GetComponent <SyouninProductSelect>().OnClick(); serihuChanger(msg.getMessage(44)); } else if (name == "Busshi") { audioSources [0].Play(); string path = "Prefabs/Syounin/MenuBusshi"; GameObject menu = Instantiate(Resources.Load(path)) as GameObject; menu.transform.SetParent(board.transform); menu.transform.localScale = new Vector2(1, 1); menu.transform.localPosition = new Vector2(0, -150); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuBusshi"; GameObject content = menu.transform.FindChild("ScrollView").transform.FindChild("Content").gameObject; //Prepared Value string busshiQtyString = CloseLayerScript.busshiQtyString; List <string> busshiQtyList = new List <string> (); busshiQtyList = new List <string> (busshiQtyString.Split(delimiterChars)); string busshiRankString = CloseLayerScript.busshiRankString; List <string> busshiRankList = new List <string> (); busshiRankList = new List <string> (busshiRankString.Split(delimiterChars)); Item item = new Item(); float discount = CloseLayerScript.discount; //YR string YRpath = "Prefabs/Item/Cyouhei/CyouheiYR"; GameObject YRObj = Instantiate(Resources.Load(YRpath)) as GameObject; GameObject item1 = content.transform.FindChild("item1").gameObject; YRObj.transform.SetParent(item1.transform); YRObj.transform.localScale = new Vector2(1, 1); YRObj.GetComponent <Button>().enabled = false; YRObj.transform.FindChild("Qty").GetComponent <Text>().text = busshiQtyList[0]; YRObj.name = "CyouheiYR"; RectTransform trn1 = YRObj.transform.FindChild("Qty").GetComponent <RectTransform>(); trn1.anchoredPosition3D = new Vector3(-30, -40, 0); colorByRankChanger(YRObj, busshiRankList[0]); string itemCdYR = YRObj.name + busshiRankList[0]; float unitPriceYR = (float)item.getUnitPrice(itemCdYR); float finalPriceYR = unitPriceYR * discount; item1.GetComponent <SyouninProductSelect>().price = Mathf.CeilToInt(finalPriceYR); item1.GetComponent <SyouninProductSelect>().busshiQty = int.Parse(busshiQtyList[0]); item1.GetComponent <SyouninProductSelect>().menuName = name; item1.GetComponent <SyouninProductSelect>().busshiCd = itemCdYR; //KB string KBpath = "Prefabs/Item/Cyouhei/CyouheiKB"; GameObject KBObj = Instantiate(Resources.Load(KBpath)) as GameObject; GameObject item2 = content.transform.FindChild("item2").gameObject; KBObj.transform.SetParent(item2.transform); KBObj.transform.localScale = new Vector2(1, 1); KBObj.GetComponent <Button>().enabled = false; KBObj.transform.FindChild("Qty").GetComponent <Text>().text = busshiQtyList[1]; KBObj.name = "CyouheiKB"; RectTransform trn2 = KBObj.transform.FindChild("Qty").GetComponent <RectTransform>(); trn2.anchoredPosition3D = new Vector3(-30, -40, 0); colorByRankChanger(KBObj, busshiRankList[1]); string itemCdKB = KBObj.name + busshiRankList[1]; float unitPriceKB = (float)item.getUnitPrice(itemCdKB); float finalPriceKB = unitPriceKB * discount; item2.GetComponent <SyouninProductSelect>().price = Mathf.CeilToInt(finalPriceKB); item2.GetComponent <SyouninProductSelect>().busshiQty = int.Parse(busshiQtyList[1]); item2.GetComponent <SyouninProductSelect>().menuName = name; item2.GetComponent <SyouninProductSelect>().busshiCd = itemCdKB; //TP string TPpath = "Prefabs/Item/Cyouhei/CyouheiTP"; GameObject TPObj = Instantiate(Resources.Load(TPpath)) as GameObject; GameObject item3 = content.transform.FindChild("item3").gameObject; TPObj.transform.SetParent(item3.transform); TPObj.transform.localScale = new Vector2(1, 1); TPObj.GetComponent <Button>().enabled = false; TPObj.transform.FindChild("Qty").GetComponent <Text>().text = busshiQtyList[2]; TPObj.name = "CyouheiTP"; RectTransform trn3 = TPObj.transform.FindChild("Qty").GetComponent <RectTransform>(); trn3.anchoredPosition3D = new Vector3(-30, -40, 0); colorByRankChanger(TPObj, busshiRankList[2]); string itemCdTP = TPObj.name + busshiRankList[2]; float unitPriceTP = (float)item.getUnitPrice(itemCdTP); float finalPriceTP = unitPriceTP * discount; item3.GetComponent <SyouninProductSelect>().price = Mathf.CeilToInt(finalPriceTP); item3.GetComponent <SyouninProductSelect>().busshiQty = int.Parse(busshiQtyList[2]); item3.GetComponent <SyouninProductSelect>().menuName = name; item3.GetComponent <SyouninProductSelect>().busshiCd = itemCdTP; //YM string YMath = "Prefabs/Item/Cyouhei/CyouheiYM"; GameObject YMObj = Instantiate(Resources.Load(YMath)) as GameObject; GameObject item4 = content.transform.FindChild("item4").gameObject; YMObj.transform.SetParent(item4.transform); YMObj.transform.localScale = new Vector2(1, 1); YMObj.GetComponent <Button>().enabled = false; YMObj.transform.FindChild("Qty").GetComponent <Text>().text = busshiQtyList[3]; YMObj.name = "CyouheiYM"; RectTransform trn4 = YMObj.transform.FindChild("Qty").GetComponent <RectTransform>(); trn4.anchoredPosition3D = new Vector3(-30, -40, 0); colorByRankChanger(YMObj, busshiRankList[3]); string itemCdYM = YMObj.name + busshiRankList[3]; float unitPriceYM = (float)item.getUnitPrice(itemCdYM); float finalPriceYM = unitPriceYM * discount; item4.GetComponent <SyouninProductSelect>().price = Mathf.CeilToInt(finalPriceYM); item4.GetComponent <SyouninProductSelect>().busshiQty = int.Parse(busshiQtyList[3]); item4.GetComponent <SyouninProductSelect>().menuName = name; item4.GetComponent <SyouninProductSelect>().busshiCd = itemCdYM; //SNB string SNBpath = "Prefabs/Item/Shinobi/Shinobi"; GameObject SNBObj = Instantiate(Resources.Load(SNBpath)) as GameObject; GameObject item5 = content.transform.FindChild("item5").gameObject; SNBObj.transform.SetParent(item5.transform); SNBObj.transform.localScale = new Vector2(1, 1); SNBObj.GetComponent <Button>().enabled = false; SNBObj.transform.FindChild("Qty").GetComponent <Text>().text = busshiQtyList[4]; SNBObj.name = "Shinobi"; RectTransform trn5 = SNBObj.transform.FindChild("Qty").GetComponent <RectTransform>(); trn5.anchoredPosition3D = new Vector3(-30, -40, 0); RectTransform trnContent = SNBObj.transform.FindChild("Shinobi").GetComponent <RectTransform>(); trnContent.sizeDelta = new Vector3(95, 120, 0); colorByRankChanger(SNBObj, busshiRankList[4]); string itemCdSNB = SNBObj.name + busshiRankList[4]; float unitPriceSNB = (float)item.getUnitPrice(itemCdSNB); float finalPriceSNB = unitPriceSNB * discount; item5.GetComponent <SyouninProductSelect>().price = Mathf.CeilToInt(finalPriceSNB); item5.GetComponent <SyouninProductSelect>().busshiQty = int.Parse(busshiQtyList[4]); item5.GetComponent <SyouninProductSelect>().menuName = name; item5.GetComponent <SyouninProductSelect>().busshiCd = itemCdSNB; //Initial item1.GetComponent <SyouninProductSelect>().OnClick(); serihuChanger(msg.getMessage(45)); } else if (name == "Yasen") { audioSources [0].Play(); string path = "Prefabs/Syounin/MenuYasen"; GameObject menu = Instantiate(Resources.Load(path)) as GameObject; menu.transform.SetParent(board.transform); menu.transform.localScale = new Vector2(1, 1); menu.transform.localPosition = new Vector2(0, -150); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuYasen"; int yasenAmt = CloseLayerScript.yasenAmt; menu.transform.FindChild("MoneyValue").GetComponent <Text>().text = yasenAmt.ToString(); GameObject btn = menu.transform.FindChild("DoYasenButton").gameObject; btn.GetComponent <DoSyouninMenu>().price = yasenAmt; serihuChanger(msg.getMessage(46)); } else if (name == "Youjinbou") { audioSources [0].Play(); string path = "Prefabs/Syounin/MenuRounin"; GameObject menu = Instantiate(Resources.Load(path)) as GameObject; menu.transform.SetParent(board.transform); menu.transform.localScale = new Vector2(1, 1); menu.transform.localPosition = new Vector2(0, -150); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuRounin"; //Preparation float discount = CloseLayerScript.discount; int rdmKengouId = CloseLayerScript.rdmKengouId; GameObject btn = menu.transform.FindChild("DoRouninButton").gameObject; string kengouPath = "Prefabs/Item/kengou"; GameObject kengou = Instantiate(Resources.Load(kengouPath)) as GameObject; kengou.transform.SetParent(menu.transform); kengou.transform.localScale = new Vector2(1.0f, 1.25f); kengou.GetComponent <Button>().enabled = false; RectTransform kengouRect = kengou.GetComponent <RectTransform>(); kengouRect.anchoredPosition3D = new Vector3(-200, -30, 0); GameObject rank = kengou.transform.FindChild("Rank").gameObject; RectTransform kengouRankRect = rank.GetComponent <RectTransform>(); kengouRankRect.anchoredPosition3D = new Vector3(-50, 20, 0); rank.transform.localScale = new Vector2(0.09f, 0.09f); Item item = new Item(); string itemCd = "kengou" + rdmKengouId; string kengouName = item.getItemName(itemCd); string exp = item.getExplanation(itemCd); float unitPrice = (float)item.getUnitPrice(itemCd); rank.GetComponent <Text>().text = kengouName; float finalPrice = unitPrice * discount; btn.GetComponent <DoSyouninMenu>().price = Mathf.CeilToInt(finalPrice); btn.GetComponent <DoSyouninMenu>().kengouId = rdmKengouId; GameObject info = menu.transform.FindChild("Info").gameObject; info.transform.FindChild("Name").GetComponent <Text>().text = kengouName; info.transform.FindChild("EffectLabel").GetComponent <Text>().text = exp; menu.transform.FindChild("MoneyValue").GetComponent <Text>().text = Mathf.CeilToInt(finalPrice).ToString(); serihuChanger(msg.getMessage(47)); } else if (name == "Cyakai") { //check cyadougu List <string> kahouList = new List <string>(); int daimyoBusyoId = PlayerPrefs.GetInt("myDaimyoBusyo"); int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); BusyoInfoGet busyoInfo = new BusyoInfoGet(); string daimyoBusyoName = busyoInfo.getName(daimyoBusyoId); string tmp = "kahou" + daimyoBusyoId; string kahouString = PlayerPrefs.GetString(tmp); kahouList = new List <string>(kahouString.Split(delimiterChars)); if (kahouList [4] == "0" && kahouList [5] == "0") { audioSources [4].Play(); string text = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { text = "Lord " + daimyoBusyoName + " don't have any teaware."; } else { text = daimyoBusyoName + "様は\n茶器をお持ちでないようですな。"; } msg.makeMessageOnBoard(text); serihuChanger(text); } else { audioSources [0].Play(); string path = "Prefabs/Syounin/MenuCyakai"; GameObject menu = Instantiate(Resources.Load(path)) as GameObject; menu.transform.SetParent(board.transform); menu.transform.localScale = new Vector2(1, 1); menu.transform.localPosition = new Vector2(0, -150); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuCyakai"; GameObject btn = menu.transform.FindChild("DoCyakaiButton").gameObject; //Cyadougu History string cyakaiDouguHst = PlayerPrefs.GetString("cyakaiDouguHst"); List <string> cyakaiDouguHstlist = new List <string> (); if (cyakaiDouguHst != "" && cyakaiDouguHst != null) { if (cyakaiDouguHst.Contains(",")) { cyakaiDouguHstlist = new List <string> (cyakaiDouguHst.Split(delimiterChars)); } else { cyakaiDouguHstlist.Add(cyakaiDouguHst); } } //Change Kahou Icon bool doneCyadouguFlg1 = false; bool doneCyadouguFlg2 = false; int targetKuniQty = 0; Kahou kahou = new Kahou(); if (kahouList [4] != "0") { string kahouId1 = kahouList [4]; string cyadouguId = "cyadougu" + kahouId1; string cyadouguPath = "Prefabs/Item/Kahou/" + cyadouguId; GameObject cya = Instantiate(Resources.Load(cyadouguPath)) as GameObject; cya.transform.SetParent(menu.transform); cya.transform.localScale = new Vector3(0.3f, 0.38f, 0); RectTransform transform = cya.GetComponent <RectTransform> (); transform.anchoredPosition3D = new Vector3(-180, -60, 0); cya.GetComponent <Button> ().enabled = false; if (cyakaiDouguHstlist.Contains(kahouId1)) { doneCyadouguFlg1 = true; } else { cyakaiDouguHstlist.Add(kahouId1); } string kahouRank = kahou.getKahouRank("cyadougu", int.Parse(kahouId1)); if (doneCyadouguFlg1) { targetKuniQty = targetKuniQty + 1; } else { if (kahouRank == "S") { targetKuniQty = targetKuniQty + 5; } else if (kahouRank == "A") { targetKuniQty = targetKuniQty + 3; } else if (kahouRank == "B") { targetKuniQty = targetKuniQty + 2; } else if (kahouRank == "C") { targetKuniQty = targetKuniQty + 1; } } } else { //Not Exist string cyadouguPath = "Prefabs/Item/Kahou/NoCyadougu"; GameObject cya = Instantiate(Resources.Load(cyadouguPath)) as GameObject; cya.transform.SetParent(menu.transform); cya.transform.localScale = new Vector3(0.3f, 0.38f, 0); RectTransform transform = cya.GetComponent <RectTransform> (); transform.anchoredPosition3D = new Vector3(-180, -60, 0); cya.GetComponent <Button> ().enabled = false; } if (kahouList [5] != "0") { string kahouId2 = kahouList [5]; string cyadouguId = "cyadougu" + kahouId2; string cyadouguPath = "Prefabs/Item/Kahou/" + cyadouguId; GameObject cya = Instantiate(Resources.Load(cyadouguPath)) as GameObject; cya.transform.SetParent(menu.transform); cya.transform.localScale = new Vector3(0.3f, 0.38f, 0); RectTransform transform = cya.GetComponent <RectTransform> (); transform.anchoredPosition3D = new Vector3(-130, -60, 0); cya.GetComponent <Button> ().enabled = false; if (cyakaiDouguHstlist.Contains(kahouId2)) { doneCyadouguFlg2 = true; } else { cyakaiDouguHstlist.Add(kahouId2); } string kahouRank = kahou.getKahouRank("cyadougu", int.Parse(kahouId2)); if (doneCyadouguFlg2) { targetKuniQty = targetKuniQty + 1; } else { if (kahouRank == "S") { targetKuniQty = targetKuniQty + 5; } else if (kahouRank == "A") { targetKuniQty = targetKuniQty + 3; } else if (kahouRank == "B") { targetKuniQty = targetKuniQty + 2; } else if (kahouRank == "C") { targetKuniQty = targetKuniQty + 1; } } } else { //Not Exist string cyadouguPath = "Prefabs/Item/Kahou/NoCyadougu"; GameObject cya = Instantiate(Resources.Load(cyadouguPath)) as GameObject; cya.transform.SetParent(menu.transform); cya.transform.localScale = new Vector3(0.3f, 0.38f, 0); RectTransform transform = cya.GetComponent <RectTransform> (); transform.anchoredPosition3D = new Vector3(-130, -60, 0); cya.GetComponent <Button> ().enabled = false; } //Change Kuni Qty if (targetKuniQty < 1) { targetKuniQty = 1; } menu.transform.FindChild("Tabibito").transform.FindChild("Text").GetComponent <Text>().text = " X " + targetKuniQty.ToString(); //Set Button Value btn.GetComponent <DoSyouninMenu>().price = 10000; btn.GetComponent <DoSyouninMenu>().targetKuniQty = targetKuniQty; btn.GetComponent <DoSyouninMenu>().cyakaiDouguHstlist = cyakaiDouguHstlist; string serihu = ""; if (!doneCyadouguFlg1 && !doneCyadouguFlg2) { btn.GetComponent <DoSyouninMenu> ().doneCyadouguFlg = false; serihu = msg.getMessage(48); } else { btn.GetComponent <DoSyouninMenu> ().doneCyadouguFlg = true; serihu = msg.getMessage(49); } serihuChanger(serihu); } } else if (name == "Gijyutsu") { audioSources [0].Play(); string path = "Prefabs/Syounin/MenuTech"; GameObject menu = Instantiate(Resources.Load(path)) as GameObject; menu.transform.SetParent(board.transform); menu.transform.localScale = new Vector2(1, 1); menu.transform.localPosition = new Vector2(0, -150); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuTech"; GameObject btn = menu.transform.FindChild("DoTechButton").gameObject; int techId = CloseLayerScript.techId; //Image string spritePath = ""; if (techId == 1) { spritePath = "Prefabs/Item/Tech/Sprite/tp"; } else if (techId == 2) { spritePath = "Prefabs/Item/Tech/Sprite/kb"; } else if (techId == 3) { spritePath = "Prefabs/Item/Tech/Sprite/snb"; } GameObject techImage = menu.transform.FindChild("Tech").gameObject; techImage.GetComponent <Image> ().sprite = Resources.Load(spritePath, typeof(Sprite)) as Sprite; //Detail Info Item item = new Item(); string itemCd = "tech" + techId; string techName = item.getItemName(itemCd); string exp = item.getExplanation(itemCd); float unitPrice = (float)item.getUnitPrice(itemCd); float discount = CloseLayerScript.discount; float finalPrice = unitPrice * discount; btn.GetComponent <DoSyouninMenu>().price = Mathf.CeilToInt(finalPrice); btn.GetComponent <DoSyouninMenu>().techId = techId; GameObject info = menu.transform.FindChild("Info").gameObject; info.transform.FindChild("Name").GetComponent <Text>().text = techName; info.transform.FindChild("EffectLabel").GetComponent <Text>().text = exp; menu.transform.FindChild("MoneyValue").GetComponent <Text>().text = Mathf.CeilToInt(finalPrice).ToString(); serihuChanger(msg.getMessage(50)); } } }
public void OnClick(){ if (name == "DoKahouButton") { reduceActionQty (); int money = PlayerPrefs.GetInt ("money"); int paiedMoney = int.Parse (Money.GetComponent<Text> ().text); Message msg = new Message (); Kahou kahou = new Kahou (); if (paiedMoney <= money) { //reduce money int calc = money - paiedMoney; PlayerPrefs.SetInt ("money", calc); PlayerPrefs.Flush (); GameObject.Find ("MoneyValue").GetComponent<Text> ().text = calc.ToString (); if (kahouCd == "bugu") { kahou.registerBugu (kahouId); } else if (kahouCd == "gusoku") { kahou.registerGusoku (kahouId); } else if (kahouCd == "kabuto") { kahou.registerKabuto (kahouId); } else if (kahouCd == "meiba") { kahou.registerMeiba (kahouId); } else if (kahouCd == "cyadougu") { kahou.registerCyadougu (kahouId); } else if (kahouCd == "chishikisyo") { kahou.registerChishikisyo (kahouId); } else if (kahouCd == "heihousyo") { kahou.registerHeihousyo (kahouId); } msg.makeMessage ("御屋形様、家宝を手に入れましたぞ。"); //Close GameObject.Find ("MenuKahou").transform.FindChild ("Close").GetComponent<CloseMenu> ().OnClick (); 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 ("SyouninBoard").transform.FindChild ("Kahou").gameObject; btn.GetComponent<Button> ().enabled = false; btn.GetComponent<Image> ().color = enableImageColor; btn.transform.FindChild ("Text").GetComponent<Text> ().color = enableTextColor; } else { msg.makeMessage ("御屋形様、金が不足しておりますぞ。"); } } else if (name == "DoBusshiButton") { reduceActionQty (); int money = PlayerPrefs.GetInt ("money"); int paiedMoney = int.Parse (Money.GetComponent<Text> ().text); Message msg = new Message (); if (paiedMoney <= money) { //reduce money int calc = money - paiedMoney; PlayerPrefs.SetInt ("money", calc); PlayerPrefs.Flush (); GameObject.Find ("MoneyValue").GetComponent<Text> ().text = calc.ToString (); char[] delimiterChars = {','}; if (busshiCd.Contains ("Cyouhei") == true) { if (busshiCd.Contains ("YR") == true) { string cyouheiYRString = PlayerPrefs.GetString ("cyouheiYR"); string[] cyouheiYR_list = cyouheiYRString.Split (delimiterChars); string newCyouheiYRString = ""; if (busshiCd == "CyouheiYR1") { int newQty = 0; newQty = int.Parse (cyouheiYR_list [0]) + busshiQty; newCyouheiYRString = newQty.ToString () + "," + cyouheiYR_list [1] + "," + cyouheiYR_list [2]; } else if (busshiCd == "CyouheiYR2") { int newQty = 0; newQty = int.Parse (cyouheiYR_list [1]) + busshiQty; newCyouheiYRString = cyouheiYR_list [0] + "," + newQty.ToString () + "," + cyouheiYR_list [2]; } else if (busshiCd == "CyouheiYR3") { int newQty = 0; newQty = int.Parse (cyouheiYR_list [2]) + busshiQty; newCyouheiYRString = cyouheiYR_list [0] + "," + cyouheiYR_list [1] + "," + newQty.ToString (); } PlayerPrefs.SetString ("cyouheiYR", newCyouheiYRString); } else if (busshiCd.Contains ("KB") == true) { string cyouheiKBString = PlayerPrefs.GetString ("cyouheiKB"); string[] cyouheiKB_list = cyouheiKBString.Split (delimiterChars); string newCyouheiKBString = ""; if (busshiCd == "CyouheiKB1") { int newQty = 0; newQty = int.Parse (cyouheiKB_list [0]) + busshiQty; newCyouheiKBString = newQty.ToString () + "," + cyouheiKB_list [1] + "," + cyouheiKB_list [2]; } else if (busshiCd == "CyouheiKB2") { int newQty = 0; newQty = int.Parse (cyouheiKB_list [1]) + busshiQty; newCyouheiKBString = cyouheiKB_list [0] + "," + newQty.ToString () + "," + cyouheiKB_list [2]; } else if (busshiCd == "CyouheiKB3") { int newQty = 0; newQty = int.Parse (cyouheiKB_list [2]) + busshiQty; newCyouheiKBString = cyouheiKB_list [0] + "," + cyouheiKB_list [1] + "," + newQty.ToString (); } PlayerPrefs.SetString ("cyouheiKB", newCyouheiKBString); } else if (busshiCd.Contains ("TP") == true) { string cyouheiTPString = PlayerPrefs.GetString ("cyouheiTP"); string[] cyouheiTP_list = cyouheiTPString.Split (delimiterChars); string newCyouheiTPString = ""; if (busshiCd == "CyouheiTP1") { int newQty = 0; newQty = int.Parse (cyouheiTP_list [0]) + busshiQty; newCyouheiTPString = newQty.ToString () + "," + cyouheiTP_list [1] + "," + cyouheiTP_list [2]; } else if (busshiCd == "CyouheiTP2") { int newQty = 0; newQty = int.Parse (cyouheiTP_list [1]) + busshiQty; newCyouheiTPString = cyouheiTP_list [0] + "," + newQty.ToString () + "," + cyouheiTP_list [2]; } else if (busshiCd == "CyouheiTP3") { int newQty = 0; newQty = int.Parse (cyouheiTP_list [2]) + busshiQty; newCyouheiTPString = cyouheiTP_list [0] + "," + cyouheiTP_list [1] + "," + newQty.ToString (); } PlayerPrefs.SetString ("cyouheiTP", newCyouheiTPString); } else if (busshiCd.Contains ("YM") == true) { string cyouheiYMString = PlayerPrefs.GetString ("cyouheiYM"); string[] cyouheiYM_list = cyouheiYMString.Split (delimiterChars); string newCyouheiYMString = ""; if (busshiCd == "CyouheiYM1") { int newQty = 0; newQty = int.Parse (cyouheiYM_list [0]) + busshiQty; newCyouheiYMString = newQty.ToString () + "," + cyouheiYM_list [1] + "," + cyouheiYM_list [2]; } else if (busshiCd == "CyouheiYM2") { int newQty = 0; newQty = int.Parse (cyouheiYM_list [1]) + busshiQty; newCyouheiYMString = cyouheiYM_list [0] + "," + newQty.ToString () + "," + cyouheiYM_list [2]; } else if (busshiCd == "CyouheiYM3") { int newQty = 0; newQty = int.Parse (cyouheiYM_list [2]) + busshiQty; newCyouheiYMString = cyouheiYM_list [0] + "," + cyouheiYM_list [1] + "," + newQty.ToString (); } PlayerPrefs.SetString ("cyouheiYM", newCyouheiYMString); } } else if (busshiCd.Contains ("Shinobi") == true) { if (busshiCd == "Shinobi1") { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt ("shinobiGe"); newQty = shinobiQty + busshiQty; PlayerPrefs.SetInt ("shinobiGe", newQty); } else if (busshiCd == "Shinobi2") { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt ("shinobiCyu"); newQty = shinobiQty + busshiQty; PlayerPrefs.SetInt ("shinobiCyu", newQty); } else if (busshiCd == "Shinobi3") { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt ("shinobiJyo"); newQty = shinobiQty + busshiQty; PlayerPrefs.SetInt ("shinobiJyo", newQty); } } PlayerPrefs.Flush (); msg.makeMessage ("御屋形様、物資を手に入れましたぞ。"); //Close GameObject.Find ("MenuBusshi").transform.FindChild ("Close").GetComponent<CloseMenu> ().OnClick (); 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 ("SyouninBoard").transform.FindChild ("Busshi").gameObject; btn.GetComponent<Button> ().enabled = false; btn.GetComponent<Image> ().color = enableImageColor; btn.transform.FindChild ("Text").GetComponent<Text> ().color = enableTextColor; } else { msg.makeMessage ("御屋形様、金が不足しておりますぞ。"); } } else if (name == "DoRouninButton") { reduceActionQty (); int money = PlayerPrefs.GetInt ("money"); Message msg = new Message (); if (price <= money) { //reduce money int calc = money - price; PlayerPrefs.SetInt ("money", calc); PlayerPrefs.Flush (); GameObject.Find ("MoneyValue").GetComponent<Text> ().text = calc.ToString (); string kengouString = PlayerPrefs.GetString ("kengouItem"); List<string> kengouList = new List<string> (); char[] delimiterChars = {','}; kengouList = new List<string> (kengouString.Split (delimiterChars)); int qty = int.Parse (kengouList [kengouId - 1]); int newQty = qty + 1; kengouList [kengouId - 1] = newQty.ToString (); string newKengouString = ""; for (int i=0; i<kengouList.Count; i++) { if (i == 0) { newKengouString = kengouList [i]; } else { newKengouString = newKengouString + "," + kengouList [i]; } } PlayerPrefs.SetString ("kengouItem", newKengouString); PlayerPrefs.Flush (); msg.makeMessage ("御屋形様、浪人中の剣豪を登用しましたぞ。"); //Close GameObject.Find ("MenuRounin").transform.FindChild ("Close").GetComponent<CloseMenu> ().OnClick (); 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 ("SyouninBoard").transform.FindChild ("Youjinbou").gameObject; btn.GetComponent<Button> ().enabled = false; btn.GetComponent<Image> ().color = enableImageColor; btn.transform.FindChild ("Text").GetComponent<Text> ().color = enableTextColor; } else { msg.makeMessage ("御屋形様、金が不足しておりますぞ。"); } } else if (name == "DoYasenButton") { reduceActionQty (); Message msg = new Message (); float percent = Random.value; percent = percent * 100; if (percent > 10) { int money = PlayerPrefs.GetInt ("money"); int newMoney = money + price; PlayerPrefs.SetInt ("money", newMoney); PlayerPrefs.Flush (); GameObject.Find ("MoneyValue").GetComponent<Text> ().text = newMoney.ToString (); string yasenTxt = price + "貫の矢銭を供出させましたぞ。"; msg.makeMessage (yasenTxt); } else { msg.makeMessage ("なんと町衆共が矢銭を断わりましたぞ。"); } //Close GameObject.Find ("MenuYasen").transform.FindChild ("Close").GetComponent<CloseMenu> ().OnClick (); 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 ("SyouninBoard").transform.FindChild ("Yasen").gameObject; btn.GetComponent<Button> ().enabled = false; btn.GetComponent<Image> ().color = enableImageColor; btn.transform.FindChild ("Text").GetComponent<Text> ().color = enableTextColor; } else if (name == "DoTechButton") { reduceActionQty (); int money = PlayerPrefs.GetInt ("money"); Message msg = new Message (); if (price <= money) { //reduce money int calc = money - price; PlayerPrefs.SetInt ("money", calc); GameObject.Find ("MoneyValue").GetComponent<Text> ().text = calc.ToString (); //add tech item string txt = ""; if(techId == 1){ //TP int qty = PlayerPrefs.GetInt("transferTP",0); int newQty = qty + 1; PlayerPrefs.SetInt("transferTP",newQty); txt = "御屋形様、鉄砲鋳造技術を導入しましたぞ。\n内政にて鍛冶屋を建造しましょう。"; }else if(techId == 2){ int qty = PlayerPrefs.GetInt("transferKB",0); int newQty = qty + 1; PlayerPrefs.SetInt("transferKB",newQty); txt = "御屋形様、馬育成技術を導入しましたぞ。\n内政にて厩建造しましょう。"; }else if(techId == 3){ int qty = PlayerPrefs.GetInt("transferSNB",0); int newQty = qty + 1; PlayerPrefs.SetInt("transferSNB",newQty); txt = "御屋形様、忍育成技術を導入しましたぞ。\n内政にて施設建造しましょう。"; } PlayerPrefs.Flush (); msg.makeMessage (txt); 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 ("SyouninBoard").transform.FindChild ("Gijyutsu").gameObject; btn.GetComponent<Button> ().enabled = false; btn.GetComponent<Image> ().color = enableImageColor; btn.transform.FindChild ("Text").GetComponent<Text> ().color = enableTextColor; }else{ msg.makeMessage ("御屋形様、金が不足しておりますぞ。"); } //Close GameObject.Find ("MenuTech").transform.FindChild ("Close").GetComponent<CloseMenu> ().OnClick (); } }
void Update() { //get jinkei if (userId != "" && !isJinkeiMapFetched) { PvPDataStore.GetEnemyJinkei(userId, pvpStageId); isJinkeiMapFetched = true; } //get busyo data if (pvpStageId == 1) { if (PvPDataStore.PvP1BusyoList != null && PvPDataStore.PvP1BusyoList.Count != 0 && !isBusyoStatusFetched) { isBusyoStatusFetched = true; } } else if (pvpStageId == 2 && userId != "") { if (PvPDataStore.PvP2BusyoList != null && PvPDataStore.PvP2BusyoList.Count != 0 && !isBusyoStatusFetched) { isBusyoStatusFetched = true; } } else if (pvpStageId == 3 && userId != "") { if (PvPDataStore.PvP3BusyoList != null && PvPDataStore.PvP3BusyoList.Count != 0 && !isBusyoStatusFetched) { isBusyoStatusFetched = true; } } //register temp lose tran if (userId != "" && isJinkeiMapFetched && isBusyoStatusFetched && clickedFlg && !PvPDataStore.PvPAtkNoFlg && !updatePvPAtkFlg) { updatePvPAtkFlg = true; PvPController = GameObject.Find("GameScene").GetComponent <PvPController>(); PvPDataStore.UpdatePvPAtkNo(PvPController.myUserId, int.Parse(PvPController.todayNCMB)); PvPDataStore.enemyUserId = userId; PvPDataStore.enemyUserName = enemyUserName; PvPDataStore.myUserName = PvPController.myUserName; PvPDataStore.getPt = getPt; PvPDataStore.todayNCMB = int.Parse(PvPDataStore.PvPTimer.todayNCMB); } //register temp lose tran if (userId != "" && isJinkeiMapFetched && isBusyoStatusFetched && clickedFlg && PvPDataStore.PvPAtkNoFlg && updatePvPAtkFlg && !PvPDataStore.donePlusUpdatePtFlg && !updateLosePtFlg) { updateLosePtFlg = true; PvPDataStore.UpdatePvPPt(userId, true, getPt); } if (userId != "" && isJinkeiMapFetched && isBusyoStatusFetched && clickedFlg && PvPDataStore.PvPAtkNoFlg && updatePvPAtkFlg && PvPDataStore.donePlusUpdatePtFlg && updateLosePtFlg && !PvPDataStore.doneMinusUpdatePtFlg && !updateWinPtFlg) { updateWinPtFlg = true; PvPDataStore.UpdatePvPPt(PvPController.myUserId, false, getPt); } //scene change if (userId != "" && isJinkeiMapFetched && isBusyoStatusFetched && clickedFlg && PvPDataStore.PvPAtkNoFlg && updatePvPAtkFlg && PvPDataStore.donePlusUpdatePtFlg && PvPDataStore.doneMinusUpdatePtFlg && updateLosePtFlg && updateWinPtFlg && !sceneChangeFlg) { //hyourou int newHyourou = nowHyourou - 5; PlayerPrefs.SetInt("hyourou", newHyourou); PlayerPrefs.SetBool("pvpFlg", true); //money and exp calculation int minExp = getPvPMinExp(PvPController.per); int maxExp = getPvPMaxExp(PvPController.per); 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 = getPvPRandomItemGrp(); string itemTyp = ""; int itemId = 0; int itemQty = 1; AttackNaiseiView AttackNaiseiView = new AttackNaiseiView(); if (itemGrp == "item") { itemTyp = AttackNaiseiView.getRandomItemTyp(itemGrp); if (itemTyp == "tech") { itemId = AttackNaiseiView.getItemRank(66, 33); } else if (itemTyp == "Tama") { itemId = AttackNaiseiView.getItemRank(20, 5); if (itemId == 3) { itemQty = 100; } else if (itemId == 2) { itemQty = 50; } else if (itemId == 1) { itemQty = 10; } } else { itemId = AttackNaiseiView.getItemRank(20, 5); } } else if (itemGrp == "kahou") { itemTyp = AttackNaiseiView.getRandomItemTyp(itemGrp); Kahou kahou = new Kahou(); string kahouRank = AttackNaiseiView.getKahouRank(); itemId = kahou.getRamdomKahouId(itemTyp, kahouRank); } PlayerPrefs.SetInt("activeStageMoney", money); PlayerPrefs.SetInt("activeStageExp", exp); PlayerPrefs.SetString("activeItemGrp", itemGrp); PlayerPrefs.SetString("activeItemType", itemTyp); PlayerPrefs.SetInt("activeItemId", itemId); PlayerPrefs.SetInt("activeItemQty", itemQty); PlayerPrefs.Flush(); sceneChangeFlg = true; Application.LoadLevel("kassen"); } }
public void OnClick(){ string Text = ""; Kahou kahou = new Kahou (); if (!isNanbansenFlg) { Text = "贈り物を受け取りました。"; if (itemCd == "money") { //Money int nowMoney = PlayerPrefs.GetInt ("money"); nowMoney = nowMoney + itemQty; PlayerPrefs.SetInt ("money", nowMoney); //Label Text nowMoneyLabelText = GameObject.Find ("MoneyValue").GetComponent<Text> (); int nowMoneyLabel = int.Parse (nowMoneyLabelText.text) + itemQty; nowMoneyLabelText.text = nowMoneyLabel.ToString (); } else if (itemCd == "hyourou") { //Hyourou //Check int maxHyourou = PlayerPrefs.GetInt ("hyourouMax"); int nowHyourou = PlayerPrefs.GetInt ("hyourou"); nowHyourou = nowHyourou + itemQty; if (maxHyourou <= nowHyourou) { nowHyourou = maxHyourou; PlayerPrefs.SetInt ("hyourou", nowHyourou); Text = "兵糧はこれ以上受け取れませんぞ。"; //Label Text nowHyourouLabelText = GameObject.Find ("HyourouCurrentValue").GetComponent<Text> (); nowHyourouLabelText.text = nowHyourou.ToString (); } else { PlayerPrefs.SetInt ("hyourou", nowHyourou); //Label Text nowHyourouLabelText = GameObject.Find ("HyourouCurrentValue").GetComponent<Text> (); nowHyourouLabelText.text = nowHyourou.ToString (); } } else if (itemCd == "kengou") { string kengouString = PlayerPrefs.GetString ("kengouItem"); List<string> kengouList = new List<string> (); char[] delimiterChars = {','}; kengouList = new List<string> (kengouString.Split (delimiterChars)); string qty = kengouList [itemId - 1]; int newQty = int.Parse (qty) + itemQty; kengouList [itemId - 1] = newQty.ToString (); string newKengouString = ""; for (int i=0; i<kengouList.Count; i++) { if (i == 0) { newKengouString = kengouList [i]; } else { newKengouString = newKengouString + "," + kengouList [i]; } } PlayerPrefs.SetString ("kengouItem", newKengouString); } else if (itemCd == "gokui") { string gokuiString = PlayerPrefs.GetString ("gokuiItem"); List<string> gokuiList = new List<string> (); char[] delimiterChars = {','}; gokuiList = new List<string> (gokuiString.Split (delimiterChars)); string qty = gokuiList [itemId - 1]; int newQty = int.Parse (qty) + itemQty; gokuiList [itemId - 1] = newQty.ToString (); string newGokuiString = ""; for (int i=0; i<gokuiList.Count; i++) { if (i == 0) { newGokuiString = gokuiList [i]; } else { newGokuiString = newGokuiString + "," + gokuiList [i]; } } PlayerPrefs.SetString ("gokuiItem", newGokuiString); } else if (itemCd == "CyouheiTP") { registerTP(); } else if (itemCd.Contains ("nanban")) { registerNanban(); } else if (itemCd == "bugu") { kahou.registerBugu (itemId); } else if (itemCd == "gusoku") { kahou.registerGusoku (itemId); } else if (itemCd == "kabuto") { kahou.registerKabuto (itemId); } else if (itemCd == "meiba") { kahou.registerMeiba (itemId); } else if (itemCd == "cyadougu") { kahou.registerCyadougu (itemId); } else if (itemCd == "chishikisyo") { kahou.registerChishikisyo (itemId); } else if(itemCd == "heihousyo"){ kahou.registerHeihousyo (itemId); }else if(itemCd == "cyoutei"||itemCd == "koueki"){ registerKouekiOrCyoutei(itemCd, itemId); } PlayerPrefs.Flush (); //Delete Tap Button Destroy (popButton); } else { //Nanbansen if(moneyCheckFlg){ //Money Handling int money = PlayerPrefs.GetInt ("money"); money = money - paiedMoney; PlayerPrefs.SetInt ("money",money); PlayerPrefs.Flush(); GameObject.Find("MoneyValue").GetComponent<Text>().text = money.ToString(); //Fadeout & Button false shipObj.GetComponent<FadeoutImage>().enabled = true; shipObj.GetComponent<Button>().enabled = false; //nanbansen flg change GameObject.Find("NaiseiController").GetComponent<NaiseiController>().isNanbansenFlg = false; //Register Item if(itemCd.Contains("CyouheiTP")){ registerTP(); }else if(itemCd.Contains("nanban")){ registerNanban(); } else if (itemCd == "bugu") { kahou.registerBugu (itemId); } else if (itemCd == "gusoku") { kahou.registerGusoku (itemId); } else if (itemCd == "kabuto") { kahou.registerKabuto (itemId); } else if (itemCd == "meiba") { kahou.registerMeiba (itemId); } else if (itemCd == "cyadougu") { kahou.registerCyadougu (itemId); } else if (itemCd == "chishikisyo") { kahou.registerChishikisyo (itemId); } Text = "有リ難ウゴゼマス。\tマタオ願イシマス。"; }else{ Text = "金ガ足リナイヨウデスヨ。\tマタオ願イシマス。"; } } //Message Message msg = new Message(); msg.makeMessage(Text); //Close GameObject.Find ("close").GetComponent<CloseBoard> ().onClick (); }
public void makeNanbansen(){ string shipPath = "Prefabs/Naisei/ship"; GameObject ship = Instantiate(Resources.Load (shipPath)) as GameObject; GameObject tabibitoView = GameObject.Find ("TabibitoView").gameObject; ship.transform.SetParent(tabibitoView.transform); ship.transform.localScale = new Vector2 (1, 1); RectTransform ship_transform = ship.GetComponent<RectTransform>(); ship_transform.anchoredPosition3D = new Vector3(570,180,0); Item item = new Item (); Nanbansen nanbansen = ship.GetComponent<Nanbansen> (); //Get TP Item string itemTPCd = ""; int itemTPId = 0; int itemTPQty = 0; float itemTPPrice = 0; float tpPercent = UnityEngine.Random.value; tpPercent = tpPercent * 100; if (tpPercent <= 30) { //Jyo itemTPCd = "CyouheiTP3"; itemTPId = 3; } else if(30 < tpPercent && tpPercent <= 60){ //Cyu itemTPCd = "CyouheiTP2"; itemTPId = 2; }else if(60 < tpPercent){ //Ge itemTPCd = "CyouheiTP1"; itemTPId = 1; } itemTPQty = UnityEngine.Random.Range(1,6); //1-5 Qty itemTPPrice = randomPriceChange(itemTPCd, itemTPQty); nanbansen.itemTPCd = itemTPCd; nanbansen.itemTPId = itemTPId; nanbansen.itemTPQty = itemTPQty; nanbansen.itemTPPrice = itemTPPrice; nanbansen.itemTPExp = item.getExplanation (itemTPCd); //Get Saku Item string itemSakuCd = ""; int itemSakuQty = 1; float itemSakuPrice = 0; int itemSakuId = 0; float sakuPercent = UnityEngine.Random.value; sakuPercent = sakuPercent * 100; if (sakuPercent <= 30) { itemSakuCd = "nanban1"; itemSakuId = 1; } else if(30 < sakuPercent && sakuPercent <= 60){ itemSakuCd = "nanban2"; itemSakuId = 2; }else if(60 < sakuPercent){ itemSakuCd = "nanban3"; itemSakuId = 3; } itemSakuPrice = randomPriceChange(itemSakuCd, itemSakuQty); nanbansen.itemSakuCd = itemSakuCd; nanbansen.itemSakuId = itemSakuId; nanbansen.itemSakuPrice = itemSakuPrice; nanbansen.itemSakuExp = item.getExplanation (itemSakuCd); //Get Kahou Item string itemKahouCd = ""; int itemKahouQty = 1; float itemKahouPrice = 0; float kahouPercent = UnityEngine.Random.value; kahouPercent = kahouPercent * 100; string kahouRank = ""; if (kahouPercent <= 10) { //S kahouRank = "S"; } else if(10 < kahouPercent && kahouPercent <= 30){ //A kahouRank = "A"; }else if(30 < kahouPercent && kahouPercent <= 60){ //B kahouRank = "B"; }else if(60 < kahouPercent){ //C kahouRank = "C"; } Kahou kahou = new Kahou (); List<string> kahouRandom = new List<string> (){"bugu","kabuto","gusoku","meiba","cyadougu","chishikisyo","heihousyo"}; int rdm = UnityEngine.Random.Range(0,7); itemKahouCd = kahouRandom[rdm]; int itemKahouId = kahou.getRamdomKahouId(itemKahouCd, kahouRank); List<string> kahouInfo = new List<string> (); KahouStatusGet kahouSts = new KahouStatusGet (); kahouInfo = kahouSts.getKahouInfo(itemKahouCd, itemKahouId); float priceChange = UnityEngine.Random.Range (1, 51); int updown = UnityEngine.Random.Range (0,2); //0:Up, 1:Down float kahouPrice = 0; float kahouUnitPrice = float.Parse (kahouInfo [5]); float diff = kahouUnitPrice * priceChange/100; if(updown==0){ kahouPrice = kahouUnitPrice + diff; }else{ kahouPrice = kahouUnitPrice - diff; } nanbansen.itemKahouCd = itemKahouCd; nanbansen.itemKahouId = itemKahouId; nanbansen.itemKahouPrice = kahouPrice; nanbansen.itemKahouExp = kahouInfo [1]; }
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(){ if (name != "PassButton") { //Syoukaijyo Confirm Pop //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 = "商人からの紹介状が無いと商売の紹介は出来ませんな。"; 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; pop.transform.FindChild("SyouninName").GetComponent<Text>().text = "千利休"; } } else { //Cyoutei Main Pop int hyourou = PlayerPrefs.GetInt("hyourou"); 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){ 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; //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"; } //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 = "これは" + daimyoName + "様。\t私共めに何用で御座いましょうか。" ; pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent<Text>().text = serihu; }else{ Message msg = new Message(); msg.makeMessage("御屋形様、"+occupiedDaimyoName+"めに取引を邪魔されました。"); } } }
public void OnClick() { /*Receive Item*/ AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [3].Play(); //Item1 string gameClearDaimyo = PlayerPrefs.GetString("gameClearDaimyo"); bool hardFlg = PlayerPrefs.GetBool("hardFlg"); List <string> gameClearDaimyoList = new List <string> (); char[] delimiterChars = { ',' }; if (gameClearDaimyo != null && gameClearDaimyo != "") { if (gameClearDaimyo.Contains(",")) { gameClearDaimyoList = new List <string> (gameClearDaimyo.Split(delimiterChars)); } else { gameClearDaimyoList.Add(gameClearDaimyo); } } int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); if (!gameClearDaimyoList.Contains(myDaimyo.ToString())) { if (gameClearDaimyo != null && gameClearDaimyo != "") { gameClearDaimyo = gameClearDaimyo + "," + myDaimyo.ToString(); } else { gameClearDaimyo = myDaimyo.ToString(); } PlayerPrefs.SetString("gameClearDaimyo", gameClearDaimyo); } //Hard mode if (hardFlg) { string gameClearDaimyoHard = PlayerPrefs.GetString("gameClearDaimyoHard"); List <string> gameClearDaimyoHardList = new List <string>(); if (gameClearDaimyoHard != null && gameClearDaimyoHard != "") { if (gameClearDaimyoHard.Contains(",")) { gameClearDaimyoHardList = new List <string>(gameClearDaimyoHard.Split(delimiterChars)); } else { gameClearDaimyoHardList.Add(gameClearDaimyoHard); } } if (!gameClearDaimyoHardList.Contains(myDaimyo.ToString())) { if (gameClearDaimyoHard != null && gameClearDaimyoHard != "") { gameClearDaimyoHard = gameClearDaimyoHard + "," + myDaimyo.ToString(); } else { gameClearDaimyoHard = myDaimyo.ToString(); } PlayerPrefs.SetString("gameClearDaimyoHard", gameClearDaimyoHard); } } PlayerPrefs.SetBool("gameClearItemGetFlg", true); //Item2 PlayerPrefs.DeleteKey("gameClearKahouCd"); PlayerPrefs.DeleteKey("gameClearKahouId"); Kahou kahou = new Kahou(); if (kahouCd == "bugu") { kahou.registerBugu(int.Parse(kahouId)); } else if (kahouCd == "gusoku") { kahou.registerGusoku(int.Parse(kahouId)); } else if (kahouCd == "kabuto") { kahou.registerKabuto(int.Parse(kahouId)); } else if (kahouCd == "meiba") { kahou.registerMeiba(int.Parse(kahouId)); } else if (kahouCd == "cyadougu") { kahou.registerCyadougu(int.Parse(kahouId)); } else if (kahouCd == "chishikisyo") { kahou.registerChishikisyo(int.Parse(kahouId)); } else if (kahouCd == "heihousyo") { kahou.registerHeihousyo(int.Parse(kahouId)); } //Item3 int busyoDama = PlayerPrefs.GetInt("busyoDama"); int newBusyoDama = busyoDama + 1000; PlayerPrefs.SetInt("busyoDama", newBusyoDama); //Get Daimyo Busyo Daimyo daimyoScript = new Daimyo(); int daimyoId = PlayerPrefs.GetInt("myDaimyo"); int daimyoBusyoId = daimyoScript.getDaimyoBusyoId(daimyoId); string zukanBusyoHst = PlayerPrefs.GetString("zukanBusyoHst"); List <string> zukanBusyoHstList = new List <string>(); if (zukanBusyoHst != null && zukanBusyoHst != "") { if (zukanBusyoHst.Contains(",")) { zukanBusyoHstList = new List <string>(zukanBusyoHst.Split(delimiterChars)); } else { zukanBusyoHstList.Add(zukanBusyoHst); } } if (!zukanBusyoHstList.Contains(daimyoBusyoId.ToString())) { if (zukanBusyoHst != null && zukanBusyoHst != "") { zukanBusyoHst = zukanBusyoHst + "," + daimyoBusyoId.ToString(); } else { zukanBusyoHst = daimyoBusyoId.ToString(); } PlayerPrefs.SetString("zukanBusyoHst", zukanBusyoHst); } if (daimyoScript.daimyoBusyoCheck(daimyoBusyoId)) { string gacyaDaimyoHst = PlayerPrefs.GetString("gacyaDaimyoHst"); List <string> gacyaDaimyoHstList = new List <string>(); if (gacyaDaimyoHst != null && gacyaDaimyoHst != "") { if (gacyaDaimyoHst.Contains(",")) { gacyaDaimyoHstList = new List <string>(gacyaDaimyoHst.Split(delimiterChars)); } else { gacyaDaimyoHstList.Add(gacyaDaimyoHst); } } if (!gacyaDaimyoHstList.Contains(daimyoBusyoId.ToString())) { if (gacyaDaimyoHst != null && gacyaDaimyoHst != "") { gacyaDaimyoHst = gacyaDaimyoHst + "," + daimyoBusyoId.ToString(); } else { gacyaDaimyoHst = daimyoBusyoId.ToString(); } PlayerPrefs.SetString("gacyaDaimyoHst", gacyaDaimyoHst); } } PlayerPrefs.Flush(); //Hide Back Destroy(backObj.gameObject); Destroy(popObj.gameObject); Destroy(particleObj.gameObject); GameObject kunimap = GameObject.Find("KuniMap").gameObject; GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject; Destroy(kunimap.gameObject); Destroy(kuniIconView.gameObject); FinMaker(panel); }
void Start() { DataReward DataReward = GameObject.Find("DataStore").GetComponent <DataReward>(); GameObject content = GameObject.Find("Content").gameObject; for (int i = 0; i < DataReward.itemTitleList.Count; i++) { string objectId = DataReward.objectIdList[i]; string title = DataReward.itemTitleList[i]; string grp = DataReward.itemGrpList[i]; string rank = DataReward.itemRankList[i]; int qty = DataReward.itemQtyList[i]; string slotPath = "Prefabs/PvP/RewardSlot"; GameObject slot = Instantiate(Resources.Load(slotPath)) as GameObject; slot.transform.SetParent(content.transform); slot.transform.localScale = new Vector2(1, 1); //view slot.transform.FindChild("title").GetComponent <Text>().text = title; //hide other image GameObject imageContent = slot.transform.FindChild("ScrollView").transform.FindChild("Viewport").transform.FindChild("Content").gameObject; RewardReceive RewardReceive = slot.transform.FindChild("button").GetComponent <RewardReceive>(); foreach (Transform obj in imageContent.transform) { if (obj.name != grp) { Destroy(obj.gameObject); slot.transform.FindChild("circle").transform.FindChild("Text").GetComponent <Text>().text = grp; slot.transform.FindChild("circle").transform.FindChild("Text").GetComponent <Text>().color = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f); } else { if (grp == "money") { obj.transform.FindChild("qty").GetComponent <Text>().text = qty.ToString(); } else if (grp == "stone") { obj.transform.FindChild("qty").GetComponent <Text>().text = qty.ToString(); } else if (grp == "busyo") { obj.transform.FindChild("rank").GetComponent <Text>().text = rank; BusyoInfoGet BusyoInfoGet = new BusyoInfoGet(); int busyoId = BusyoInfoGet.getRandomBusyoId(rank); RewardReceive.busyoId = busyoId; } else if (grp == "kaho") { obj.transform.FindChild("qty").GetComponent <Text>().text = "x " + qty.ToString(); obj.transform.FindChild("rank").GetComponent <Text>().text = rank; //kahouType bugu,kabuto,gusoku,meiba,cyadougu,heihousyo,chishikisyo for (int j = 0; j < qty; j++) { List <string> kahouuTypeList = new List <string>() { "bugu", "kabuto", "gusoku", "meiba", "cyadougu", "heihousyo", "chishikisyo" }; int rdmId = UnityEngine.Random.Range(0, kahouuTypeList.Count); string kahoTyp = kahouuTypeList[rdmId]; Kahou Kahou = new Kahou(); int kahoId = Kahou.getRamdomKahouId(kahoTyp, rank); RewardReceive.kahoTypList.Add(kahoTyp); RewardReceive.kahoIdList.Add(kahoId); RewardReceive.kahoNameList.Add(Kahou.getKahouName(kahoTyp, kahoId)); } } else if (grp == "syokaijyo") { string rankTmp = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { if (rank == "S") { rankTmp = "High"; } else if (rank == "A") { rankTmp = "Mid"; } else if (rank == "B") { rankTmp = "Low"; } } else { if (rank == "S") { rankTmp = "上"; } else if (rank == "A") { rankTmp = "中"; } else if (rank == "B") { rankTmp = "下"; } } obj.transform.FindChild("qty").GetComponent <Text>().text = "x " + qty.ToString(); obj.transform.FindChild("rank").GetComponent <Text>().text = rankTmp; } } } //Set Value RewardReceive.slot = slot; RewardReceive.objectId = objectId; RewardReceive.grp = grp; RewardReceive.qty = qty; RewardReceive.rank = rank; } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources[2].Play(); Color Select = new Color(76f / 255f, 50f / 255f, 18f / 255f, 80f / 255f); Color unSelect = new Color(255f / 255f, 255f / 255f, 255f / 255f, 100f / 255f); foreach (Transform obj in Content.transform) { obj.GetComponent <Image>().color = unSelect; } GetComponent <Image> ().color = Select; baseObj = GameObject.Find("Base").gameObject; baseObj.transform.FindChild("Title").GetComponent <Text> ().text = title; baseObj.transform.FindChild("Mask").transform.FindChild("Image").GetComponent <Image> ().sprite = transform.FindChild("Image").GetComponent <Image> ().sprite; baseObj.transform.FindChild("Comment").transform.FindChild("Text").GetComponent <Text> ().text = serihu; baseObj.transform.FindChild("Name").GetComponent <Text> ().text = shisyaName; reqruiedItemView(shisyaId); //Request to purchase item if (shisyaId == 5 || shisyaId == 19) { RequestBuyItem.gameObject.SetActive(true); Kahou kahou = new Kahou(); string rank = kahou.getKahouRank(itemCd, int.Parse(itemId)); string kahouPath = ""; if (rank == "C") { kahouPath = "Prefabs/Kahou/" + itemCd + "C"; } else { kahouPath = "Prefabs/Kahou/" + itemCd + itemId; } RequestBuyItem.GetComponent <Image>().sprite = Resources.Load(kahouPath, typeof(Sprite)) as Sprite; //string kahouMsg = kahou.getRamdomKahou KahouStatusGet kahouSts = new KahouStatusGet(); List <string> kahouInfoList = new List <string>(); kahouInfoList = kahouSts.getKahouInfo(itemCd, int.Parse(itemId)); string effect = kahouInfoList[0] + "\n" + kahouInfoList[2] + " +" + kahouInfoList[3] + kahouInfoList[4]; RequestBuyItem.GetComponent <PopItem>().text = effect; } else { RequestBuyItem.gameObject.SetActive(false); } //Yes/No Button if (shisyaId != 6) { Color OKbtnColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f); Color OKtxtColor = new Color(190f / 255f, 190f / 255f, 0f / 255f, 255f / 255f); GameObject ysBtn = GameObject.Find("YesButton").gameObject; ysBtn.GetComponent <Button> ().enabled = true; ysBtn.GetComponent <Image> ().color = OKbtnColor; ysBtn.transform.FindChild("Text").GetComponent <Text> ().color = OKtxtColor; GameObject noBtn = GameObject.Find("NoButton").gameObject; noBtn.GetComponent <Button> ().enabled = true; noBtn.GetComponent <Image> ().color = OKbtnColor; noBtn.transform.FindChild("Text").GetComponent <Text> ().color = OKtxtColor; ysBtn.GetComponent <DoShisya> ().slot = gameObject; noBtn.GetComponent <DoShisya> ().slot = gameObject; } else { //Doumei Haki //disable button Color OKbtnColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f); Color OKtxtColor = new Color(190f / 255f, 190f / 255f, 0f / 255f, 255f / 255f); Color NGColor = new Color(118f / 255f, 118f / 255f, 45f / 255f, 255f / 255f); GameObject ysBtn = GameObject.Find("YesButton").gameObject; ysBtn.GetComponent <Button> ().enabled = true; ysBtn.GetComponent <Image> ().color = OKbtnColor; ysBtn.transform.FindChild("Text").GetComponent <Text> ().color = OKtxtColor; GameObject noBtn = GameObject.Find("NoButton").gameObject; noBtn.GetComponent <Button>().enabled = false; noBtn.GetComponent <Image> ().color = NGColor; noBtn.transform.FindChild("Text").GetComponent <Text> ().color = NGColor; ysBtn.GetComponent <DoShisya> ().slot = gameObject; noBtn.GetComponent <DoShisya> ().slot = gameObject; } }
public void reqruiedItemView(int shisyaId) { Shisya shisya = new Shisya(); bool selectFlg = shisya.getSelectFlg(shisyaId); if (!selectFlg) { //initialization if (GameObject.Find("Required1")) { GameObject.Find("Required1").SetActive(true); if (GameObject.Find("Required2")) { GameObject.Find("Required2").SetActive(true); } GameObject.Find("Circle").SetActive(true); if (GameObject.Find("CyouteiSelectScrollView")) { GameObject.Find("CyouteiSelectScrollView").SetActive(false); } if (GameObject.Find("SyouninSelectScrollView")) { GameObject.Find("SyouninSelectScrollView").SetActive(false); } } else { BackMain script = GameObject.Find("Back").GetComponent <BackMain> (); Required1.gameObject.SetActive(true); Required2.gameObject.SetActive(true); Circle.gameObject.SetActive(true); CyouteiSelectScrollView.gameObject.SetActive(false); SyouninSelectScrollView.gameObject.SetActive(false); } //Item 1 string requried1 = shisya.getYesRequried1(shisyaId); if (requried1 == "no") { baseObj.transform.FindChild("Required1").gameObject.SetActive(false); } else if (requried1 == "random") { baseObj.transform.FindChild("Required1").gameObject.SetActive(true); if (moneyNo != 0) { string item1Path = "Prefabs/Common/Sprite/money"; baseObj.transform.FindChild("Required1").GetComponent <Image> ().sprite = Resources.Load(item1Path, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required1").transform.FindChild("Value").GetComponent <Text> ().text = "x " + moneyNo.ToString(); } else { Kahou kahou = new Kahou(); string rank = kahou.getKahouRank(itemCd, int.Parse(itemId)); string kahouPath = ""; if (rank == "C") { kahouPath = "Prefabs/Kahou/" + itemCd + "C"; } else { kahouPath = "Prefabs/Kahou/" + itemCd + itemId; } baseObj.transform.FindChild("Required1").GetComponent <Image> ().sprite = Resources.Load(kahouPath, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required1").transform.FindChild("Value").GetComponent <Text> ().text = "x 1"; } } else if (requried1 == "randomKahou") { baseObj.transform.FindChild("Required1").gameObject.SetActive(true); //Kahou string item1Path = "Prefabs/Common/Sprite/money"; baseObj.transform.FindChild("Required1").GetComponent <Image> ().sprite = Resources.Load(item1Path, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required1").transform.FindChild("Value").GetComponent <Text> ().text = "x " + moneyNo.ToString(); } else { baseObj.transform.FindChild("Required1").gameObject.SetActive(true); List <string> requried1List = new List <string> (); char[] delimiterChars = { ':' }; if (requried1.Contains(":")) { requried1List = new List <string> (requried1.Split(delimiterChars)); } else { requried1List.Add(requried1); } string item1Path = "Prefabs/Common/Sprite/" + requried1List [0]; baseObj.transform.FindChild("Required1").GetComponent <Image> ().sprite = Resources.Load(item1Path, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required1").transform.FindChild("Value").GetComponent <Text>().text = "x " + requried1List [1]; } //Item 2 string requried2 = shisya.getYesRequried2(shisyaId); if (requried2 == "no") { baseObj.transform.FindChild("Required2").gameObject.SetActive(false); } else { baseObj.transform.FindChild("Required2").gameObject.SetActive(true); List <string> requried2List = new List <string> (); char[] delimiterChars = { ':' }; if (requried2.Contains(":")) { requried2List = new List <string> (requried2.Split(delimiterChars)); } else { requried2List.Add(requried2); } string item2Path = "Prefabs/Common/Sprite/" + requried2List [0]; baseObj.transform.FindChild("Required2").GetComponent <Image> ().sprite = Resources.Load(item2Path, typeof(Sprite)) as Sprite; baseObj.transform.FindChild("Required2").transform.FindChild("Value").GetComponent <Text>().text = "x " + requried2List [1]; } } else { //Select if (GameObject.Find("Required1")) { GameObject.Find("Required1").SetActive(false); if (GameObject.Find("Required2")) { GameObject.Find("Required2").SetActive(false); } GameObject.Find("Circle").SetActive(false); } if (shisyaId == 16) { //Cyoutei if (GameObject.Find("CyouteiSelectScrollView")) { GameObject viewObj = GameObject.Find("CyouteiSelectScrollView").gameObject; viewObj.SetActive(true); viewObj.transform.FindChild("CyouteiContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().Start(); viewObj.transform.FindChild("CyouteiContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().OnClick(); } else { CyouteiSelectScrollView.gameObject.SetActive(true); CyouteiSelectScrollView.transform.FindChild("CyouteiContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().Start(); CyouteiSelectScrollView.transform.FindChild("CyouteiContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().OnClick(); } if (GameObject.Find("SyouninSelectScrollView")) { GameObject.Find("SyouninSelectScrollView").SetActive(false); } else { SyouninSelectScrollView.gameObject.SetActive(false); } } else if (shisyaId == 18) { //Syounin if (GameObject.Find("CyouteiSelectScrollView")) { GameObject.Find("CyouteiSelectScrollView").SetActive(false); } else { CyouteiSelectScrollView.gameObject.SetActive(false); } if (GameObject.Find("SyouninSelectScrollView")) { GameObject viewObj = GameObject.Find("SyouninSelectScrollView").gameObject; viewObj.SetActive(true); viewObj.transform.FindChild("SyouninContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().Start(); viewObj.transform.FindChild("SyouninContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().OnClick(); } else { SyouninSelectScrollView.gameObject.SetActive(true); SyouninSelectScrollView.transform.FindChild("SyouninContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().Start(); SyouninSelectScrollView.transform.FindChild("SyouninContent").transform.FindChild("Ge").GetComponent <ShisyaSyoukaijyoSelect> ().OnClick(); } } else if (shisyaId == 19) { //Nanban } } }
//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() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); Color enableImageColor = new Color(35f / 255f, 35f / 255f, 35f / 255f, 155f / 255f); Color enableTextColor = new Color(125f / 255f, 125f / 255f, 125f / 255f, 255f / 255f); if (name == "DoKahouButton") { reduceActionQty(); int money = PlayerPrefs.GetInt("money"); int paiedMoney = int.Parse(Money.GetComponent <Text> ().text); Message msg = new Message(); Kahou kahou = new Kahou(); if (paiedMoney <= money) { audioSources [3].Play(); //reduce money int calc = money - paiedMoney; PlayerPrefs.SetInt("money", calc); PlayerPrefs.Flush(); GameObject.Find("MoneyValue").GetComponent <Text> ().text = calc.ToString(); if (kahouCd == "bugu") { kahou.registerBugu(kahouId); } else if (kahouCd == "gusoku") { kahou.registerGusoku(kahouId); } else if (kahouCd == "kabuto") { kahou.registerKabuto(kahouId); } else if (kahouCd == "meiba") { kahou.registerMeiba(kahouId); } else if (kahouCd == "cyadougu") { kahou.registerCyadougu(kahouId); } else if (kahouCd == "chishikisyo") { kahou.registerChishikisyo(kahouId); } else if (kahouCd == "heihousyo") { kahou.registerHeihousyo(kahouId); } msg.makeMessage(msg.getMessage(92)); //Close GameObject.Find("MenuKahou").transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); GameObject btn = GameObject.Find("SyouninBoard").transform.FindChild("Kahou").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(6)); } } else if (name == "DoBusshiButton") { reduceActionQty(); int money = PlayerPrefs.GetInt("money"); int paiedMoney = int.Parse(Money.GetComponent <Text> ().text); Message msg = new Message(); if (paiedMoney <= money) { audioSources [3].Play(); //reduce money int calc = money - paiedMoney; PlayerPrefs.SetInt("money", calc); PlayerPrefs.Flush(); GameObject.Find("MoneyValue").GetComponent <Text> ().text = calc.ToString(); char[] delimiterChars = { ',' }; if (busshiCd.Contains("Cyouhei") == true) { if (busshiCd.Contains("YR") == true) { string cyouheiYRString = PlayerPrefs.GetString("cyouheiYR"); string[] cyouheiYR_list = cyouheiYRString.Split(delimiterChars); string newCyouheiYRString = ""; if (busshiCd == "CyouheiYR1") { int newQty = 0; newQty = int.Parse(cyouheiYR_list [0]) + busshiQty; newCyouheiYRString = newQty.ToString() + "," + cyouheiYR_list [1] + "," + cyouheiYR_list [2]; } else if (busshiCd == "CyouheiYR2") { int newQty = 0; newQty = int.Parse(cyouheiYR_list [1]) + busshiQty; newCyouheiYRString = cyouheiYR_list [0] + "," + newQty.ToString() + "," + cyouheiYR_list [2]; } else if (busshiCd == "CyouheiYR3") { int newQty = 0; newQty = int.Parse(cyouheiYR_list [2]) + busshiQty; newCyouheiYRString = cyouheiYR_list [0] + "," + cyouheiYR_list [1] + "," + newQty.ToString(); } PlayerPrefs.SetString("cyouheiYR", newCyouheiYRString); } else if (busshiCd.Contains("KB") == true) { string cyouheiKBString = PlayerPrefs.GetString("cyouheiKB"); string[] cyouheiKB_list = cyouheiKBString.Split(delimiterChars); string newCyouheiKBString = ""; if (busshiCd == "CyouheiKB1") { int newQty = 0; newQty = int.Parse(cyouheiKB_list [0]) + busshiQty; newCyouheiKBString = newQty.ToString() + "," + cyouheiKB_list [1] + "," + cyouheiKB_list [2]; } else if (busshiCd == "CyouheiKB2") { int newQty = 0; newQty = int.Parse(cyouheiKB_list [1]) + busshiQty; newCyouheiKBString = cyouheiKB_list [0] + "," + newQty.ToString() + "," + cyouheiKB_list [2]; } else if (busshiCd == "CyouheiKB3") { int newQty = 0; newQty = int.Parse(cyouheiKB_list [2]) + busshiQty; newCyouheiKBString = cyouheiKB_list [0] + "," + cyouheiKB_list [1] + "," + newQty.ToString(); } PlayerPrefs.SetString("cyouheiKB", newCyouheiKBString); } else if (busshiCd.Contains("TP") == true) { string cyouheiTPString = PlayerPrefs.GetString("cyouheiTP"); string[] cyouheiTP_list = cyouheiTPString.Split(delimiterChars); string newCyouheiTPString = ""; if (busshiCd == "CyouheiTP1") { int newQty = 0; newQty = int.Parse(cyouheiTP_list [0]) + busshiQty; newCyouheiTPString = newQty.ToString() + "," + cyouheiTP_list [1] + "," + cyouheiTP_list [2]; } else if (busshiCd == "CyouheiTP2") { int newQty = 0; newQty = int.Parse(cyouheiTP_list [1]) + busshiQty; newCyouheiTPString = cyouheiTP_list [0] + "," + newQty.ToString() + "," + cyouheiTP_list [2]; } else if (busshiCd == "CyouheiTP3") { int newQty = 0; newQty = int.Parse(cyouheiTP_list [2]) + busshiQty; newCyouheiTPString = cyouheiTP_list [0] + "," + cyouheiTP_list [1] + "," + newQty.ToString(); } PlayerPrefs.SetString("cyouheiTP", newCyouheiTPString); } else if (busshiCd.Contains("YM") == true) { string cyouheiYMString = PlayerPrefs.GetString("cyouheiYM"); string[] cyouheiYM_list = cyouheiYMString.Split(delimiterChars); string newCyouheiYMString = ""; if (busshiCd == "CyouheiYM1") { int newQty = 0; newQty = int.Parse(cyouheiYM_list [0]) + busshiQty; newCyouheiYMString = newQty.ToString() + "," + cyouheiYM_list [1] + "," + cyouheiYM_list [2]; } else if (busshiCd == "CyouheiYM2") { int newQty = 0; newQty = int.Parse(cyouheiYM_list [1]) + busshiQty; newCyouheiYMString = cyouheiYM_list [0] + "," + newQty.ToString() + "," + cyouheiYM_list [2]; } else if (busshiCd == "CyouheiYM3") { int newQty = 0; newQty = int.Parse(cyouheiYM_list [2]) + busshiQty; newCyouheiYMString = cyouheiYM_list [0] + "," + cyouheiYM_list [1] + "," + newQty.ToString(); } PlayerPrefs.SetString("cyouheiYM", newCyouheiYMString); } } else if (busshiCd.Contains("Shinobi") == true) { if (busshiCd == "Shinobi1") { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt("shinobiGe"); newQty = shinobiQty + busshiQty; PlayerPrefs.SetInt("shinobiGe", newQty); } else if (busshiCd == "Shinobi2") { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt("shinobiCyu"); newQty = shinobiQty + busshiQty; PlayerPrefs.SetInt("shinobiCyu", newQty); } else if (busshiCd == "Shinobi3") { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt("shinobiJyo"); newQty = shinobiQty + busshiQty; PlayerPrefs.SetInt("shinobiJyo", newQty); } } PlayerPrefs.Flush(); msg.makeMessage(msg.getMessage(93)); //Close GameObject.Find("MenuBusshi").transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); GameObject btn = GameObject.Find("SyouninBoard").transform.FindChild("Busshi").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(6)); } } else if (name == "DoRouninButton") { reduceActionQty(); int money = PlayerPrefs.GetInt("money"); Message msg = new Message(); if (price <= money) { audioSources [3].Play(); //reduce money int calc = money - price; PlayerPrefs.SetInt("money", calc); PlayerPrefs.Flush(); GameObject.Find("MoneyValue").GetComponent <Text> ().text = calc.ToString(); string kengouString = PlayerPrefs.GetString("kengouItem"); List <string> kengouList = new List <string> (); char[] delimiterChars = { ',' }; kengouList = new List <string> (kengouString.Split(delimiterChars)); int qty = int.Parse(kengouList [kengouId - 1]); int newQty = qty + 1; kengouList [kengouId - 1] = newQty.ToString(); string newKengouString = ""; for (int i = 0; i < kengouList.Count; i++) { if (i == 0) { newKengouString = kengouList [i]; } else { newKengouString = newKengouString + "," + kengouList [i]; } } PlayerPrefs.SetString("kengouItem", newKengouString); PlayerPrefs.Flush(); msg.makeMessage(msg.getMessage(94)); //Close GameObject.Find("MenuRounin").transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); GameObject btn = GameObject.Find("SyouninBoard").transform.FindChild("Youjinbou").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(6)); } } else if (name == "DoYasenButton") { reduceActionQty(); Message msg = new Message(); float percent = Random.value; percent = percent * 100; if (percent > 10) { audioSources [3].Play(); int money = PlayerPrefs.GetInt("money"); int newMoney = money + price; if (newMoney < 0) { newMoney = int.MaxValue; } PlayerPrefs.SetInt("money", newMoney); PlayerPrefs.Flush(); GameObject.Find("MoneyValue").GetComponent <Text> ().text = newMoney.ToString(); string yasenTxt = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { yasenTxt = "We levied money " + price + " on merchants."; } else { yasenTxt = price + "貫の矢銭を供出させましたぞ。"; } msg.makeMessage(yasenTxt); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(95)); } //Close GameObject.Find("MenuYasen").transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); GameObject btn = GameObject.Find("SyouninBoard").transform.FindChild("Yasen").gameObject; btn.GetComponent <Button> ().enabled = false; btn.GetComponent <Image> ().color = enableImageColor; btn.transform.FindChild("Text").GetComponent <Text> ().color = enableTextColor; } else if (name == "DoTechButton") { reduceActionQty(); int money = PlayerPrefs.GetInt("money"); Message msg = new Message(); if (price <= money) { audioSources [3].Play(); //reduce money int calc = money - price; PlayerPrefs.SetInt("money", calc); GameObject.Find("MoneyValue").GetComponent <Text> ().text = calc.ToString(); //add tech item string txt = ""; if (techId == 1) { //TP int qty = PlayerPrefs.GetInt("transferTP", 0); int newQty = qty + 1; PlayerPrefs.SetInt("transferTP", newQty); txt = msg.getMessage(96); } else if (techId == 2) { int qty = PlayerPrefs.GetInt("transferKB", 0); int newQty = qty + 1; PlayerPrefs.SetInt("transferKB", newQty); txt = msg.getMessage(97); } else if (techId == 3) { int qty = PlayerPrefs.GetInt("transferSNB", 0); int newQty = qty + 1; PlayerPrefs.SetInt("transferSNB", newQty); txt = msg.getMessage(98); } PlayerPrefs.Flush(); msg.makeMessage(txt); GameObject btn = GameObject.Find("SyouninBoard").transform.FindChild("Gijyutsu").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(6)); } //Close GameObject.Find("MenuTech").transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } else if (name == "DoCyakaiButton") { reduceActionQty(); int money = PlayerPrefs.GetInt("money"); Message msg = new Message(); if (price <= money) { audioSources [3].Play(); //reduce money int calc = money - price; PlayerPrefs.SetInt("money", calc); GameObject.Find("MoneyValue").GetComponent <Text> ().text = calc.ToString(); int meiseiQty = PlayerPrefs.GetInt("meisei"); meiseiQty = meiseiQty + targetKuniQty; PlayerPrefs.SetInt("meisei", meiseiQty); string newcyakaiDouguHst = ""; for (int i = 0; i < cyakaiDouguHstlist.Count; i++) { if (i == 0) { newcyakaiDouguHst = cyakaiDouguHstlist[i]; } else { newcyakaiDouguHst = newcyakaiDouguHst + "," + cyakaiDouguHstlist[i]; } } PlayerPrefs.SetString("cyakaiDouguHst", newcyakaiDouguHst); string finalTxt = ""; if (!doneCyadouguFlg) { if (Application.systemLanguage != SystemLanguage.Japanese) { finalTxt = "It was good tea party.\n You got " + targetKuniQty + " reputation item. \n Traveller will visit your country."; } else { finalTxt = "茶会は大盛況でした。\n名声を" + targetKuniQty + "個取得しました。\n旅人が来訪いたしますぞ。"; } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { finalTxt = "You have already shown your tea item so it didn't get lively. \n You got " + targetKuniQty + " reputation item."; } else { finalTxt = "以前お披露目した茶道具を使用したせいか、盛り上がりは今ひとつでしたな。\n名声を" + targetKuniQty + "個取得しました。"; } } msg.makeMessage(finalTxt); GameObject btn = GameObject.Find("SyouninBoard").transform.FindChild("Cyakai").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(6)); } //Close GameObject.Find("MenuCyakai").transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } }
public void OnClick(){ /*Receive Item*/ //Item1 string gameClearDaimyo = PlayerPrefs.GetString ("gameClearDaimyo"); List<string> gameClearDaimyoList = new List<string> (); char[] delimiterChars = {','}; if (gameClearDaimyo != null && gameClearDaimyo != "") { if (gameClearDaimyo.Contains (",")) { gameClearDaimyoList = new List<string> (gameClearDaimyo.Split (delimiterChars)); }else{ gameClearDaimyoList.Add(gameClearDaimyo); } } int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); if (!gameClearDaimyoList.Contains (myDaimyo.ToString ())) { if (gameClearDaimyo != null && gameClearDaimyo != "") { gameClearDaimyo = gameClearDaimyo + "," + myDaimyo.ToString (); } else { gameClearDaimyo = myDaimyo.ToString (); } PlayerPrefs.SetString ("gameClearDaimyo", gameClearDaimyo); } PlayerPrefs.SetBool ("gameClearItemGetFlg",true); //Item2 PlayerPrefs.DeleteKey ("gameClearKahouCd"); PlayerPrefs.DeleteKey ("gameClearKahouId"); Kahou kahou = new Kahou (); if (kahouCd == "bugu") { kahou.registerBugu (int.Parse(kahouId)); } else if (kahouCd == "gusoku") { kahou.registerGusoku (int.Parse(kahouId)); } else if (kahouCd == "kabuto") { kahou.registerKabuto (int.Parse(kahouId)); } else if (kahouCd == "meiba") { kahou.registerMeiba (int.Parse(kahouId)); } else if (kahouCd == "cyadougu") { kahou.registerCyadougu (int.Parse(kahouId)); } else if (kahouCd == "chishikisyo") { kahou.registerChishikisyo (int.Parse(kahouId)); } //Item3 int busyoDama = PlayerPrefs.GetInt ("busyoDama"); int newBusyoDama = busyoDama + 1000; PlayerPrefs.SetInt ("busyoDama", newBusyoDama); PlayerPrefs.Flush (); //Hide Back Destroy (backObj.gameObject); Destroy (popObj.gameObject); Destroy (particleObj.gameObject); GameObject kunimap = GameObject.Find("KuniMap").gameObject; GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject; Destroy (kunimap.gameObject); Destroy (kuniIconView.gameObject); FinMaker (panel); }
public void addKahou(string kahouType, int kahouId){ string kahouTypeTemp = ""; Kahou kahou = new Kahou (); if(kahouType=="bugu"){ kahou.registerBugu (kahouId); }else if(kahouType=="kabuto"){ kahou.registerKabuto (kahouId); }else if(kahouType=="gusoku"){ kahou.registerGusoku (kahouId); }else if(kahouType=="meiba"){ kahou.registerMeiba (kahouId); }else if(kahouType=="cyadougu"){ kahou.registerCyadougu (kahouId); }else if(kahouType=="heihousyo"){ kahou.registerHeihousyo (kahouId); }else if(kahouType=="chishikisyo"){ kahou.registerChishikisyo (kahouId); } }
public void OnClick(){ //SE if (audioNaisei != null) { audioNaisei.PlayOneShot (touch); } /*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); Daimyo daimyo = new Daimyo(); /*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/" + kuniId.ToString (); kuniMap.GetComponent<Image> ().sprite = Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite; //kuni kuniMap.transform.parent = GameObject.Find ("board").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 = PlayerPrefs.GetString (clearedStage); List<string> clearedStageList = new List<string> (); if (clearedStageString != null && clearedStageString != "") { char[] delimiterChars = {','}; clearedStageList = new List<string> (clearedStageString.Split (delimiterChars)); } //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); cleared.transform.localScale = new Vector2 (3, 5); cleared.transform.localPosition = new Vector2 (0, 0); clearedFlg = true; } //Get Stage Info string stageName = stageMst.param [i].stageName; int locationX = stageMst.param [i].LocationX; int locationY = stageMst.param [i].LocationY; int powerType = stageMst.param [i].powerTyp; 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 * 3; int maxMoney = maxExp * 5; 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/Map/Stage/shiroIcon_m"; stage.transform.FindChild("shiroImage").GetComponent<SpriteRenderer> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; }else if(powerType==3){ string imagePath = "Prefabs/Map/Stage/shiroIcon_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); } } 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); //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 naiseiPath = "Prefabs/Map/NaiseiButton"; GameObject naiseiBtn = Instantiate (Resources.Load (naiseiPath)) as GameObject; naiseiBtn.transform.parent = GameObject.Find ("Popup(Clone)").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); //Initial Setting GameObject firstStage = GameObject.Find ("stage1"); firstStage.GetComponent<ShowStageDtl> ().OnClick (); }
public void makeTabibitoInstance(string targetTyp){ //Rank Check float rankPercent = UnityEngine.Random.value; rankPercent = rankPercent * 100; string targetRank = ""; //For test /* if (rankPercent <= 100) { //S targetRank = "S"; } */ if (rankPercent <= 1) { //S targetRank = "S"; } else if (1 < rankPercent && rankPercent <= 10) { //A targetRank = "A"; }else if (10 < rankPercent && rankPercent <= 45) { //B targetRank = "B"; }else if (45 < rankPercent) { //C targetRank = "C"; } //Extract Target Type & Target Rank Entity_tabibito_mst tabibitoMst = Resources.Load ("Data/tabibito_mst") as Entity_tabibito_mst; List<int> idList = new List<int> (); for (int i=0; i<tabibitoMst.param.Count; i++) { string tempTyp = tabibitoMst.param[i].Typ; string tempRank = tabibitoMst.param[i].Rank; if(tempTyp == targetTyp && tempRank == targetRank){ idList.Add(tabibitoMst.param[i].Id); } } //Random Extract int rdmId = UnityEngine.Random.Range(0,idList.Count); int targetTabibitoId = idList[rdmId]; //Select Start Point List<string> startPointList = new List<string> (){"goalA","goalB","goalC","goalD","goalE","goalF","goalG","goalH","goalI","goalJ","goalK","goalL","goalM","goalN"}; int rdmId2 = UnityEngine.Random.Range(0,startPointList.Count); string startPoint = startPointList[rdmId2]; GameObject tabibitoView = GameObject.Find ("TabibitoView").gameObject; GameObject startPointObj = tabibitoView.transform.FindChild(startPoint).gameObject; //Instance int grpId = 0; string tabibitoPath = ""; if (targetTyp == "common") { tabibitoPath = "Prefabs/Naisei/Tabibito/" + targetTabibitoId; } else if (targetTyp == "boubi") { tabibitoPath = "Prefabs/Naisei/Tabibito/kengou"; } else if (targetTyp == "nanban") { tabibitoPath = "Prefabs/Naisei/Tabibito/nanban"; } else if (targetTyp == "bunka") { grpId = tabibitoMst.param [targetTabibitoId - 1].GrpID; tabibitoPath = "Prefabs/Naisei/Tabibito/bunka" + grpId; } else if (targetTyp == "bukkyo") { tabibitoPath = "Prefabs/Naisei/Tabibito/bukkyo"; } GameObject prefab = Instantiate(Resources.Load (tabibitoPath)) as GameObject; prefab.transform.SetParent(tabibitoView.transform); prefab.GetComponent<TabibitoMove> ().destPoint = startPointObj.GetComponent<TabibitoKiller> ().OppositObj; prefab.transform.localPosition = new Vector3(startPointObj.transform.localPosition.x, startPointObj.transform.localPosition.y, 0); //Add Notice Button string ntcBtnPath = "Prefabs/Naisei/Tabibito/NoticeBtn"; GameObject btn = Instantiate(Resources.Load (ntcBtnPath)) as GameObject; btn.transform.SetParent(prefab.transform); btn.transform.localPosition = new Vector2 (60, 60); if (targetTyp != "nanban" && (targetTyp != "bunka" || grpId != 3)) { btn.transform.localScale = new Vector2 (25, 25); if (startPoint == "goalA" || startPoint == "goalB" || startPoint == "goalC" || startPoint == "goalD" || startPoint == "goalI" || startPoint == "goalJ" || startPoint == "goalK") { prefab.transform.localScale = new Vector2 (0.7f, 0.7f); } else { prefab.transform.localScale = new Vector2 (-0.7f, 0.7f); } } else { btn.transform.localScale = new Vector2 (20, 20); if (startPoint == "goalA" || startPoint == "goalB" || startPoint == "goalC" || startPoint == "goalD" || startPoint == "goalI" || startPoint == "goalJ" || startPoint == "goalK") { prefab.transform.localScale = new Vector2 (0.9f, 0.9f); } else { prefab.transform.localScale = new Vector2 (-0.9f, 0.9f); } } btn.GetComponent<TabibitoNoticeBtn> ().targetGrp= tabibitoMst.param [targetTabibitoId - 1].Grp; btn.GetComponent<TabibitoNoticeBtn> ().targetGrpId= grpId; btn.GetComponent<TabibitoNoticeBtn> ().targetName = tabibitoMst.param [targetTabibitoId - 1].Name; btn.GetComponent<TabibitoNoticeBtn> ().targetExp = tabibitoMst.param [targetTabibitoId - 1].Exp; string rank = tabibitoMst.param [targetTabibitoId - 1].Rank; btn.GetComponent<TabibitoNoticeBtn> ().targetRank = rank; string itemCd = tabibitoMst.param [targetTabibitoId - 1].ItemMst; int itemId = tabibitoMst.param [targetTabibitoId - 1].ItemMstId; if (itemId == 0) { //Random Get Kahou Item Kahou kahou = new Kahou(); string kahouRank = ""; float kahouPercent = UnityEngine.Random.value; kahouPercent = kahouPercent * 100; if(rank=="S"){ //S:A=30%:70% if(kahouPercent<=30){ kahouRank = "S"; }else{ kahouRank = "A"; } }else if(rank=="A"){ //A:B=30%:70% if(kahouPercent<=30){ kahouRank = "A"; }else{ kahouRank = "B"; } }else if(rank=="B"){ //B:C=30%:70% if(kahouPercent<=30){ kahouRank = "B"; }else{ kahouRank = "C"; } } itemId = kahou.getRamdomKahouId(itemCd, kahouRank); } btn.GetComponent<TabibitoNoticeBtn> ().itemCd = itemCd; btn.GetComponent<TabibitoNoticeBtn> ().itemId = itemId; btn.GetComponent<TabibitoNoticeBtn> ().itemQty = tabibitoMst.param [targetTabibitoId - 1].ItemQty; }
public void receiveKaho() { Message msgScript = new Message(); Kahou kahou = new Kahou(); string kahouMsg = ""; for (int i = 0; i < kahoTypList.Count; i++) { string kahoTyp = kahoTypList[i]; int kahoId = kahoIdList[i]; string kahoName = kahoNameList[i]; if (kahoTyp == "bugu") { kahou.registerBugu(kahoId); } else if (kahoTyp == "gusoku") { kahou.registerGusoku(kahoId); } else if (kahoTyp == "kabuto") { kahou.registerKabuto(kahoId); } else if (kahoTyp == "meiba") { kahou.registerMeiba(kahoId); } else if (kahoTyp == "cyadougu") { kahou.registerCyadougu(kahoId); } else if (kahoTyp == "chishikisyo") { kahou.registerChishikisyo(kahoId); } else if (kahoTyp == "heihousyo") { kahou.registerHeihousyo(kahoId); } if (kahouMsg == "") { kahouMsg = kahoName; } else { kahouMsg = kahouMsg + "," + kahoName; } } string msg = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { msg = "You got " + kahouMsg + "."; } else { msg = kahouMsg + "を受領しましたぞ。良い物を手に入れられましたな。"; } msgScript.makeMessage(msg); }
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)); } }
// 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 randomSalesKahouView(GameObject slot) { int requriedMoney = 0; //kahou Kahou kahou = new Kahou(); //Type List <string> kahouTypeList = new List <string> { "bugu", "kabuto", "gusoku", "meiba", "cyadougu", "heihousyo", "chishikisyo" }; int rdmTyp = UnityEngine.Random.Range(0, kahouTypeList.Count); string kahouType = kahouTypeList [rdmTyp]; //Rank float rankPercent = UnityEngine.Random.value; rankPercent = rankPercent * 100; string kahouRank = ""; if (rankPercent <= 5) { //S kahouRank = "S"; } else if (5 < rankPercent && rankPercent <= 20) { //A kahouRank = "A"; } else if (20 < rankPercent && rankPercent <= 50) { //B kahouRank = "B"; } else if (50 < rankPercent) { //C kahouRank = "C"; } int kahouId = kahou.getRamdomKahouId(kahouType, kahouRank); KahouStatusGet kahouSts = new KahouStatusGet(); List <string> kahouInfoList = new List <string> (); kahouInfoList = kahouSts.getKahouInfo(kahouType, kahouId); requriedMoney = int.Parse(kahouInfoList [5]); //discount List <float> discountList = new List <float> { 1.5f, 1.4f, 1.3f, 1.2f, 1.1f, 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f }; int rdmDisc = UnityEngine.Random.Range(0, discountList.Count); float discountPercent = discountList [rdmDisc]; requriedMoney = Mathf.CeilToInt((float)requriedMoney * discountPercent); //kahou slot.GetComponent <ShisyaSelect>().itemCd = kahouType; slot.GetComponent <ShisyaSelect> ().itemId = kahouId.ToString(); slot.GetComponent <ShisyaSelect> ().itemName = kahouInfoList [0]; slot.GetComponent <ShisyaSelect> ().moneyNo = requriedMoney; }
void Start() { Resources.UnloadUnusedAssets(); bool gameOverFlg = PlayerPrefs.GetBool("gameOverFlg"); if (gameOverFlg) { AudioSource[] seSources = GameObject.Find("SEController").GetComponents <AudioSource>(); seSources[12].Stop(); /*--------------------*/ /*Game Over*/ /*--------------------*/ showSeiryoku(); GameObject panel = GameObject.Find("Panel").gameObject; string backPath = "Prefabs/clearOrGameOver/Back"; GameObject backObj = Instantiate(Resources.Load(backPath)) as GameObject; backObj.transform.SetParent(panel.transform); backObj.transform.localScale = new Vector2(1, 1); string popPath = "Prefabs/clearOrGameOver/KakejikuMetsubouPop"; GameObject popObj = Instantiate(Resources.Load(popPath)) as GameObject; popObj.transform.SetParent(panel.transform); popObj.transform.localScale = new Vector2(1, 1); //Change Name string exp = "";// popObj.transform.FindChild("ExpValue").GetComponent<Text>().text; if (Application.systemLanguage != SystemLanguage.Japanese) { exp = myDaimyoName + " clan was downfallen. He fell in battle and there is no one remember his name now."; } else { exp = myDaimyoName + "の一族は滅亡した。武運尽きた" + myDaimyoName + "は、戦場の露と消え、今や彼の者を覚えるものは無い。"; } popObj.transform.FindChild("ExpValue").GetComponent <Text>().text = exp; //Change Yaer & Season string yearSeason = PlayerPrefs.GetString("yearSeason"); char[] delimiterChars = { ',' }; string[] yearSeasonList = yearSeason.Split(delimiterChars); int nowYear = int.Parse(yearSeasonList [0]); int nowSeason = int.Parse(yearSeasonList [1]); GameObject yearSeasonObj = popObj.transform.FindChild("YearValue").gameObject; yearSeasonObj.GetComponent <Text>().text = nowYear.ToString(); if (Application.systemLanguage != SystemLanguage.Japanese) { if (nowSeason == 1) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "Spring"; } else if (nowSeason == 2) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "Summer"; } else if (nowSeason == 3) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "Autumn"; } else if (nowSeason == 4) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "Winter"; } } else { if (nowSeason == 1) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "春"; } else if (nowSeason == 2) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "夏"; } else if (nowSeason == 3) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "秋"; } else if (nowSeason == 4) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "冬"; } } GameObject button = GameObject.Find("Button").gameObject; button.GetComponent <ShowDaimyoSelect>().fin = popObj; button.GetComponent <ShowDaimyoSelect>().panel = panel; button.GetComponent <ShowDaimyoSelect>().gameOverFlg = true; } else { //Audio Change AudioSource[] bgmSources = GameObject.Find("BGMController").GetComponents <AudioSource> (); bgmSources [0].Stop(); bgmSources [1].Play(); bool gameClearItemGetFlg = PlayerPrefs.GetBool("gameClearItemGetFlg"); GameObject panel = GameObject.Find("Panel").gameObject; if (!gameClearItemGetFlg) { //Never Got Item showSeiryoku(); bool gameClearFlg = true; //PlayerPrefs.GetBool ("gameClearFlg"); if (gameClearFlg) { /*--------------------*/ /*Game Clear*/ /*--------------------*/ string backPath = "Prefabs/clearOrGameOver/Back"; GameObject backObj = Instantiate(Resources.Load(backPath)) as GameObject; backObj.transform.SetParent(panel.transform); backObj.transform.localScale = new Vector2(1, 1); string popPath = "Prefabs/clearOrGameOver/KakejikuPop"; GameObject popObj = Instantiate(Resources.Load(popPath)) as GameObject; popObj.transform.SetParent(panel.transform); popObj.transform.localScale = new Vector2(1, 1); string particlePath = "Prefabs/clearOrGameOver/particle"; GameObject particleObj = Instantiate(Resources.Load(particlePath)) as GameObject; particleObj.transform.SetParent(panel.transform); particleObj.transform.localPosition = new Vector2(0, 300); GameObject button = GameObject.Find("Button").gameObject; button.GetComponent <StaffRoll>().backObj = backObj; button.GetComponent <StaffRoll>().popObj = popObj; button.GetComponent <StaffRoll>().particleObj = particleObj; button.GetComponent <StaffRoll>().panel = panel; //Change Name string exp = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { exp = "Finally " + myDaimyoName + " achieved the unification of the whole country. He will be able to create the time of peace as ruler."; } else { exp = "遂に" + myDaimyoName + "は、天下統一を果たした。これより天下人として、泰平の世を創っていくこととなる。"; } popObj.transform.FindChild("ExpValue").GetComponent <Text>().text = exp; //Change Yaer & Season string yearSeason = PlayerPrefs.GetString("yearSeason"); char[] delimiterChars = { ',' }; string[] yearSeasonList = yearSeason.Split(delimiterChars); int nowYear = int.Parse(yearSeasonList [0]); int nowSeason = int.Parse(yearSeasonList [1]); GameObject yearSeasonObj = popObj.transform.FindChild("YearValue").gameObject; yearSeasonObj.GetComponent <Text>().text = nowYear.ToString(); if (Application.systemLanguage != SystemLanguage.Japanese) { if (nowSeason == 1) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "Spring"; } else if (nowSeason == 2) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "Summer"; } else if (nowSeason == 3) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "Autumn"; } else if (nowSeason == 4) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "Winter"; } } else { if (nowSeason == 1) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "春"; } else if (nowSeason == 2) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "夏"; } else if (nowSeason == 3) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "秋"; } else if (nowSeason == 4) { yearSeasonObj.transform.FindChild("SeasonValue").GetComponent <Text>().text = "冬"; } } //Change Kamon string imagePath = "Prefabs/Kamon/" + myDaimyo.ToString(); popObj.transform.FindChild("Kamon").GetComponent <Image>().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; /*Show Item*/ //1st Item - Tenkahubu string itm1Path = "Prefabs/Item/Tenkahubu/tenkahubu"; GameObject item1Obj = Instantiate(Resources.Load(itm1Path)) as GameObject; GameObject item1 = GameObject.Find("item1").gameObject; item1Obj.transform.SetParent(item1.transform); item1Obj.transform.localScale = new Vector2(1.0f, 1.1f); GameObject myKamon = item1Obj.transform.FindChild("kamon").gameObject; string kamonPath = "Prefabs/Kamon/MyDaimyoKamon/" + myDaimyo.ToString(); myKamon.GetComponent <Image> ().sprite = Resources.Load(kamonPath, typeof(Sprite)) as Sprite; //2nd Item - S Rank Item string kahouCdId = ""; string kahouCd = ""; string kahouId = ""; if (PlayerPrefs.HasKey("gameClearKahouCd")) { kahouCd = PlayerPrefs.GetString("gameClearKahouCd"); kahouId = PlayerPrefs.GetString("gameClearKahouId"); kahouCdId = kahouCd + kahouId; } else { Kahou kahou = new Kahou(); List <string> kahouRandom = new List <string> () { "bugu", "kabuto", "gusoku", "meiba", "cyadougu", "chishikisyo", "heihousyo" }; int rdm = UnityEngine.Random.Range(0, 7); kahouCd = kahouRandom[rdm]; kahouId = kahou.getRamdomKahouId(kahouCd, "S").ToString(); kahouCdId = kahouCd + kahouId.ToString(); PlayerPrefs.SetString("gameClearKahouCd", kahouCd); PlayerPrefs.SetString("gameClearKahouId", kahouId); PlayerPrefs.Flush(); } string itm2Path = "Prefabs/Item/Kahou/" + kahouCdId; GameObject item2Obj = Instantiate(Resources.Load(itm2Path)) as GameObject; GameObject item2 = GameObject.Find("item2").gameObject; item2Obj.transform.SetParent(item2.transform); item2Obj.transform.localScale = new Vector2(1.0f, 1.1f); RectTransform rectRank = item2Obj.transform.FindChild("Rank").GetComponent <RectTransform>(); rectRank.anchoredPosition3D = new Vector3(30, -30, 0); item2Obj.GetComponent <Button>().enabled = false; StaffRoll btn = GameObject.Find("Button").GetComponent <StaffRoll>(); btn.kahouCd = kahouCd; btn.kahouId = kahouId; //3rd Item - BusyoDama string itm3Path = "Prefabs/Item/busyoDama"; GameObject item3Obj = Instantiate(Resources.Load(itm3Path)) as GameObject; GameObject item3 = GameObject.Find("item3").gameObject; item3Obj.transform.SetParent(item3.transform); item3Obj.transform.localScale = new Vector2(1.0f, 1.1f); } } else { //Already got item GameObject kunimap = GameObject.Find("KuniMap").gameObject; GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject; Destroy(kunimap.gameObject); Destroy(kuniIconView.gameObject); StaffRoll roll = new StaffRoll(); roll.FinMaker(panel); } } }
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 OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); string Text = ""; Kahou kahou = new Kahou(); Message msg = new Message(); if (!isNanbansenFlg) { audioSources[3].Play(); Text = msg.getMessage(122); if (itemCd == "money") { //Money int nowMoney = PlayerPrefs.GetInt("money"); nowMoney = nowMoney + itemQty; if (nowMoney < 0) { nowMoney = int.MaxValue; } PlayerPrefs.SetInt("money", nowMoney); //Label Text nowMoneyLabelText = GameObject.Find("MoneyValue").GetComponent <Text> (); int nowMoneyLabel = int.Parse(nowMoneyLabelText.text) + itemQty; nowMoneyLabelText.text = nowMoneyLabel.ToString(); } else if (itemCd == "hyourou") { //Hyourou //Check int maxHyourou = PlayerPrefs.GetInt("hyourouMax"); int nowHyourou = PlayerPrefs.GetInt("hyourou"); nowHyourou = nowHyourou + itemQty; if (maxHyourou <= nowHyourou) { nowHyourou = maxHyourou; PlayerPrefs.SetInt("hyourou", nowHyourou); Text = msg.getMessage(123); //Label Text nowHyourouLabelText = GameObject.Find("HyourouCurrentValue").GetComponent <Text> (); nowHyourouLabelText.text = nowHyourou.ToString(); } else { PlayerPrefs.SetInt("hyourou", nowHyourou); //Label Text nowHyourouLabelText = GameObject.Find("HyourouCurrentValue").GetComponent <Text> (); nowHyourouLabelText.text = nowHyourou.ToString(); } } else if (itemCd == "kengou") { string kengouString = PlayerPrefs.GetString("kengouItem"); List <string> kengouList = new List <string> (); char[] delimiterChars = { ',' }; kengouList = new List <string> (kengouString.Split(delimiterChars)); string qty = kengouList [itemId - 1]; int newQty = int.Parse(qty) + itemQty; kengouList [itemId - 1] = newQty.ToString(); string newKengouString = ""; for (int i = 0; i < kengouList.Count; i++) { if (i == 0) { newKengouString = kengouList [i]; } else { newKengouString = newKengouString + "," + kengouList [i]; } } PlayerPrefs.SetString("kengouItem", newKengouString); } else if (itemCd == "gokui") { string gokuiString = PlayerPrefs.GetString("gokuiItem"); List <string> gokuiList = new List <string> (); char[] delimiterChars = { ',' }; gokuiList = new List <string> (gokuiString.Split(delimiterChars)); string qty = gokuiList [itemId - 1]; int newQty = int.Parse(qty) + itemQty; gokuiList [itemId - 1] = newQty.ToString(); string newGokuiString = ""; for (int i = 0; i < gokuiList.Count; i++) { if (i == 0) { newGokuiString = gokuiList [i]; } else { newGokuiString = newGokuiString + "," + gokuiList [i]; } } PlayerPrefs.SetString("gokuiItem", newGokuiString); } else if (itemCd == "CyouheiTP") { registerTP(); } else if (itemCd.Contains("nanban")) { registerNanban(); } else if (itemCd == "bugu") { kahou.registerBugu(itemId); } else if (itemCd == "gusoku") { kahou.registerGusoku(itemId); } else if (itemCd == "kabuto") { kahou.registerKabuto(itemId); } else if (itemCd == "meiba") { kahou.registerMeiba(itemId); } else if (itemCd == "cyadougu") { kahou.registerCyadougu(itemId); } else if (itemCd == "chishikisyo") { kahou.registerChishikisyo(itemId); } else if (itemCd == "heihousyo") { kahou.registerHeihousyo(itemId); } else if (itemCd == "cyoutei" || itemCd == "koueki") { registerKouekiOrCyoutei(itemCd, itemId); } PlayerPrefs.SetBool("questDailyFlg21", true); PlayerPrefs.Flush(); PlayerPrefs.Flush(); //Delete Tap Button Destroy(popButton); } else { //Nanbansen if (moneyCheckFlg) { audioSources[3].Play(); //Money Handling int money = PlayerPrefs.GetInt("money"); money = money - paiedMoney; PlayerPrefs.SetInt("money", money); PlayerPrefs.Flush(); GameObject.Find("MoneyValue").GetComponent <Text>().text = money.ToString(); //Fadeout & Button false shipObj.GetComponent <FadeoutImage>().enabled = true; shipObj.GetComponent <Button>().enabled = false; //nanbansen flg change GameObject.Find("NaiseiController").GetComponent <NaiseiController>().isNanbansenFlg = false; //Register Item if (itemCd.Contains("CyouheiTP")) { registerTP(); } else if (itemCd.Contains("nanban")) { registerNanban(); } else if (itemCd == "bugu") { kahou.registerBugu(itemId); } else if (itemCd == "gusoku") { kahou.registerGusoku(itemId); } else if (itemCd == "kabuto") { kahou.registerKabuto(itemId); } else if (itemCd == "meiba") { kahou.registerMeiba(itemId); } else if (itemCd == "cyadougu") { kahou.registerCyadougu(itemId); } else if (itemCd == "chishikisyo") { kahou.registerChishikisyo(itemId); } else if (itemCd == "heihousyo") { kahou.registerHeihousyo(itemId); } Text = msg.getMessage(124); } else { audioSources [4].Play(); Text = msg.getMessage(125); } } //Message msg.makeMessage(Text); //Close GameObject.Find("close").GetComponent <CloseBoard> ().onClick(); }
// Use this for initialization public void OnClick () { Message msg = new Message(); Gaikou gaikou = new Gaikou (); CloseBoard closeScript = GameObject.Find ("close").GetComponent<CloseBoard> (); daimyoId = closeScript.daimyoId; if (hyourouOKflg) { if (moneyOKflg) { if (name == "DoMitsugiBtn") { reduceMoneyHyourou (); //Doumei bool doumeiFlg = closeScript.doumeiFlg; //Add Yukoudo // AddYukoudo = (Money/200)*chiryaku/100 int addYukoudo = (paiedMoney / 200) * busyoChiryaku / 500; if (addYukoudo <= 0) { addYukoudo = 1; } if(doumeiFlg){ addYukoudo = addYukoudo * 2; } string tempGaikou = "gaikou" + daimyoId; int nowYukoudo = 0; if (PlayerPrefs.HasKey (tempGaikou)) { nowYukoudo = PlayerPrefs.GetInt (tempGaikou); } else { nowYukoudo = 50; } int newYukoudo = nowYukoudo + addYukoudo; if (newYukoudo > 100) { newYukoudo = 100; } PlayerPrefs.SetInt (tempGaikou, newYukoudo); GameObject.Find ("YukouValue").GetComponent<Text> ().text = newYukoudo.ToString (); //Change new yukoudo closeScript.yukoudo = newYukoudo; //Back GameObject.Find ("return").GetComponent<MenuReturn> ().OnClick (); //Message string OKtext = daimyoName + "に金" + paiedMoney + "の貢物をしました。\n友好度が" + addYukoudo + "上がりますぞ。"; msg.makeMessage (OKtext); PlayerPrefs.Flush (); } else if (name == "DoDoumeiBtn") { reduceMoneyHyourou (); //Doumei float percent = Random.value; percent = percent * 100; if(percent <= doumeiRatio){ //Doumei Success string doumei = PlayerPrefs.GetString("doumei"); if(doumei == null || doumei == ""){ doumei = daimyoId.ToString(); }else{ doumei = doumei + "," + daimyoId.ToString(); } //Data int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); string cpuDoumeiTemp = "doumei" + daimyoId.ToString(); string cpuDoumei = PlayerPrefs.GetString(cpuDoumeiTemp); if(cpuDoumei != null & cpuDoumei !=""){ cpuDoumei = cpuDoumei + "," + myDaimyo.ToString(); }else{ cpuDoumei = myDaimyo.ToString(); } PlayerPrefs.SetString(cpuDoumeiTemp,cpuDoumei); PlayerPrefs.SetString("doumei",doumei); //Change Target Flg & Kuni Icon Color string seiryoku = PlayerPrefs.GetString ("seiryoku"); char[] delimiterChars = {','}; List<string> seiryokuList = new List<string> (); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); GameObject KuniIconView = GameObject.Find ("KuniIconView").gameObject; Color doumeiColor = new Color (100f / 255f, 130f / 255f, 255f / 255f, 255f / 255f); //Blue for(int i=0;i<seiryokuList.Count;i++){ int tempDaimyoId = int.Parse (seiryokuList [i]); if(tempDaimyoId == daimyoId){ int kuniId = i + 1; GameObject kuniIcon = KuniIconView.transform.FindChild(kuniId.ToString()).gameObject; kuniIcon.GetComponent<Image>().color = doumeiColor; kuniIcon.GetComponent<SendParam>().doumeiFlg = true; } } //Msg string OKtext = "御目出度う存じまする。\n" + daimyoName + "殿と同盟致しました。\n戦略の幅が拡がりますな。"; msg.makeMessage (OKtext); Destroy(GameObject.Find("smallBoard(Clone)")); Destroy(GameObject.Find("TouchBack(Clone)")); }else{ //Doumie Failed int maxReduceValue = 3; int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId,nowYukoudo,maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; closeScript.yukoudo = newYukoudo; GameObject.Find ("YukouValue").GetComponent<Text> ().text = newYukoudo.ToString (); string NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。"; msg.makeMessage (NGtext); //Back GameObject.Find ("return").GetComponent<MenuReturn> ().OnClick (); } PlayerPrefs.Flush (); } else if (name == "DoKyoutouBtn") { reduceMoneyHyourou (); //Kyoutou Check float percent = Random.value; percent = percent * 100; if(percent <= kyoutouRatio){ //Success string playerKyoutouList = PlayerPrefs.GetString("playerKyoutouList",""); MainEventHandler kyoutou = new MainEventHandler(); if(playerKyoutouList==null || playerKyoutouList == ""){ playerKyoutouList = targetKuniId+ "-" + kyoutou.getEngunSts(daimyoId.ToString()); }else{ playerKyoutouList = playerKyoutouList + ":" + targetKuniId+ "-" + kyoutou.getEngunSts(daimyoId.ToString()); } Debug.Log (playerKyoutouList); PlayerPrefs.SetString("playerKyoutouList",playerKyoutouList); //Msg string OKtext = daimyoName + "殿が" + kuniName + "攻めに加勢してくれますぞ。\n百人力ですな。"; msg.makeMessage (OKtext); }else{ //Fail //Doumie Failed int maxReduceValue = 3; int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId,nowYukoudo,maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find ("YukouValue").GetComponent<Text> ().text = newYukoudo.ToString (); closeScript.yukoudo = newYukoudo; string NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。"; msg.makeMessage (NGtext); } PlayerPrefs.Flush (); //Back GameObject.Find ("return").GetComponent<MenuReturn> ().OnClick (); }else if (name == "DoDoukatsuBtn") { reduceMoneyHyourou (); float percent = Random.value; percent = percent * 100; if(percent <= doukatsuRatio){ //Success int kuniQty = closeScript.kuniQty; int getMoney =0; //Money or Item 0:money, 1:item int moneyOrItem = UnityEngine.Random.Range(0,2); //Kahou or Shizai 0:kahou, 1:shizai int kahouOrShizai = UnityEngine.Random.Range(0,2); string kahouName = ""; string shigenName = ""; int addQty =0; int kahouRank = 0; //kahouRank S,A,B,C=1,2,3,4 //shigen Type int shigenType = 0; //KB,YR,TP,YM=1,2,3,4 if(moneyOrItem==0){ //money int temGetMoney = UnityEngine.Random.Range(1000,1501); getMoney = temGetMoney * kuniQty; int nowMoney = PlayerPrefs.GetInt("money"); nowMoney = nowMoney + getMoney; PlayerPrefs.SetInt("money",nowMoney); PlayerPrefs.Flush(); }else{ //item //Kahou or Shizai 0:kahou, 1:shizai kahouOrShizai = UnityEngine.Random.Range(0,2); if(kahouOrShizai==0){ //kahou Kahou kahou = new Kahou(); ////Bugu, Gusoku, Kabuto, Meiba, Heihousyo, Cyadougu, Chishikisyo(1,2,3,4,5,6) int kahouType = UnityEngine.Random.Range(1,7); float khPercent = Random.value; khPercent = khPercent * 100; if(5<=kuniQty){ //(S,A,B 5,35,60%) if(khPercent<=5){ //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(5<khPercent && khPercent <=41){ //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(41<khPercent){ //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } }else if(3<=kuniQty && kuniQty<5){ //(S,A,B,C : 1,15,25,59%) if(khPercent<=1){ //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(1<khPercent && khPercent <=16){ //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(16<khPercent && khPercent <= 41){ //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(41<khPercent){ //C kahouRank = 4; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } }else if(kuniQty<3){ //(A,B,C : 5, 35, 60%) if(khPercent<=5){ //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(5<khPercent && khPercent <=41){ //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(41<khPercent){ //C kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } }else{ //shizai shigenType = UnityEngine.Random.Range(1,5); float sgPercent = Random.value; sgPercent = sgPercent * 100; addQty = UnityEngine.Random.Range(1,6); Item item = new Item(); int shigenRank = 0;//下、中、上=1,2,3 if(5<=kuniQty){ //(上,中,下 40,40, 20%) if(sgPercent<=40){ shigenRank = 3; }else if(40<sgPercent && sgPercent <=81){ shigenRank = 2; }else if(81<sgPercent){ shigenRank = 1; } shigenName = item.getRandomShigen(shigenType,shigenRank,addQty); }else if(3<=kuniQty && kuniQty<5){ //(上,中,下 20,50,30%) if(sgPercent<=20){ shigenRank = 3; }else if(20<sgPercent && sgPercent <=51){ shigenRank = 2; }else if(51<sgPercent){ shigenRank = 1; } shigenName = item.getRandomShigen(shigenType,shigenRank,addQty); }else if(kuniQty<3){ //(上,中,下 5,25,70%) if(sgPercent<=5){ shigenRank = 3; }else if(5<sgPercent && sgPercent <=26){ shigenRank = 2; }else if(26<sgPercent){ shigenRank = 1; } shigenName = item.getRandomShigen(shigenType,shigenRank,addQty); } } } //Message string OKtext = "御屋形様、恫喝に成功しましたぞ。\n"+daimyoName + "が"; string addText = ""; if(moneyOrItem==0){ addText = "金" + getMoney + "を送って参りました。\n"; }else{ if(kahouOrShizai==0){ //kahou addText = "家宝、" + kahouName + "を送って参りました。\n"; }else{ //shizai+ addText = shigenName + "を" + addQty + "個送って参りました。\n"; } } int maxReduceValue = 5; int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId,nowYukoudo,maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find ("YukouValue").GetComponent<Text> ().text = newYukoudo.ToString (); closeScript.yukoudo = newYukoudo; string reducceText = "友好度が" + reduceYukoudo + "下がりますぞ。"; OKtext = OKtext + addText + reducceText; msg.makeMessage (OKtext); }else{ //Failed int maxReduceValue = 10; int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId,nowYukoudo,maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find ("YukouValue").GetComponent<Text> ().text = newYukoudo.ToString (); closeScript.yukoudo = newYukoudo; //Message string NGtext = daimyoName + "に体よく断られ申した。\n友好度が" + reduceYukoudo + "下がりますぞ。"; msg.makeMessage (NGtext); } PlayerPrefs.Flush(); //Back GameObject.Find ("return").GetComponent<MenuReturn> ().OnClick (); } } else { //Message string NGtext = "御屋形様、金が不足しておりますぞ。"; msg.makeMessage (NGtext); } } else { //Message string NGtext = "御屋形様、兵糧が不足しておりますぞ。"; msg.makeMessage (NGtext); } }
void Start () { Resources.UnloadUnusedAssets (); bool gameOverFlg = PlayerPrefs.GetBool("gameOverFlg"); if (gameOverFlg) { /*--------------------*/ /*Game Over*/ /*--------------------*/ showSeiryoku(); GameObject panel = GameObject.Find("Panel").gameObject; string backPath = "Prefabs/clearOrGameOver/Back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.SetParent(panel.transform); backObj.transform.localScale = new Vector2(1,1); string popPath = "Prefabs/clearOrGameOver/KakejikuMetsubouPop"; GameObject popObj = Instantiate(Resources.Load (popPath)) as GameObject; popObj.transform.SetParent(panel.transform); popObj.transform.localScale = new Vector2(1,1); //Change Name string exp = popObj.transform.FindChild("ExpValue").GetComponent<Text>().text; string newExp = exp.Replace("A",myDaimyoName); popObj.transform.FindChild("ExpValue").GetComponent<Text>().text = newExp; GameObject button = GameObject.Find("Button").gameObject; button.GetComponent<ShowDaimyoSelect>().fin = popObj; button.GetComponent<ShowDaimyoSelect>().panel = panel; button.GetComponent<ShowDaimyoSelect>().gameOverFlg = true; } else { bool gameClearItemGetFlg = PlayerPrefs.GetBool ("gameClearItemGetFlg"); GameObject panel = GameObject.Find("Panel").gameObject; if(!gameClearItemGetFlg){ //Never Got Item showSeiryoku(); bool gameClearFlg = PlayerPrefs.GetBool ("gameClearFlg"); if (gameClearFlg) { /*--------------------*/ /*Game Clear*/ /*--------------------*/ string backPath = "Prefabs/clearOrGameOver/Back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.SetParent(panel.transform); backObj.transform.localScale = new Vector2(1,1); string popPath = "Prefabs/clearOrGameOver/KakejikuPop"; GameObject popObj = Instantiate(Resources.Load (popPath)) as GameObject; popObj.transform.SetParent(panel.transform); popObj.transform.localScale = new Vector2(1,1); string particlePath = "Prefabs/clearOrGameOver/particle"; GameObject particleObj = Instantiate(Resources.Load (particlePath)) as GameObject; particleObj.transform.SetParent(panel.transform); particleObj.transform.localPosition = new Vector2(0,300); GameObject button = GameObject.Find("Button").gameObject; button.GetComponent<StaffRoll>().backObj = backObj; button.GetComponent<StaffRoll>().popObj = popObj; button.GetComponent<StaffRoll>().particleObj = particleObj; button.GetComponent<StaffRoll>().panel = panel; //Change Name string exp = popObj.transform.FindChild("ExpValue").GetComponent<Text>().text; string newExp = exp.Replace("A",myDaimyoName); popObj.transform.FindChild("ExpValue").GetComponent<Text>().text = newExp; /*Show Item*/ //1st Item - Tenkahubu string itm1Path = "Prefabs/Item/Tenkahubu/tenkahubu"; GameObject item1Obj = Instantiate(Resources.Load (itm1Path)) as GameObject; GameObject item1 = GameObject.Find("item1").gameObject; item1Obj.transform.SetParent(item1.transform); item1Obj.transform.localScale = new Vector2(1.0f,1.1f); GameObject myKamon = item1Obj.transform.FindChild("kamon").gameObject; string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + myDaimyo.ToString (); myKamon.GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; //2nd Item - S Rank Item string kahouCdId = ""; string kahouCd = ""; string kahouId = ""; if(PlayerPrefs.HasKey("gameClearKahouCd")){ kahouCd = PlayerPrefs.GetString("gameClearKahouCd"); kahouId = PlayerPrefs.GetString("gameClearKahouId"); kahouCdId = kahouCd + kahouId; }else{ Kahou kahou = new Kahou(); List<string> kahouRandom = new List<string> (){"bugu","kabuto","gusoku","meiba","cyadougu","chishikisyo","heihousyo"}; int rdm = UnityEngine.Random.Range(0,7); kahouCd = kahouRandom[rdm]; kahouId = kahou.getRamdomKahouId(kahouCd, "S").ToString(); kahouCdId = kahouCd + kahouId.ToString(); PlayerPrefs.SetString("gameClearKahouCd",kahouCd); PlayerPrefs.SetString("gameClearKahouId",kahouId); PlayerPrefs.Flush(); } string itm2Path = "Prefabs/Item/Kahou/" + kahouCdId; GameObject item2Obj = Instantiate(Resources.Load (itm2Path)) as GameObject; GameObject item2 = GameObject.Find("item2").gameObject; item2Obj.transform.SetParent(item2.transform); item2Obj.transform.localScale = new Vector2(1.0f,1.1f); RectTransform rectRank = item2Obj.transform.FindChild("Rank").GetComponent<RectTransform>(); rectRank.anchoredPosition3D = new Vector3(30,-30,0); item2Obj.GetComponent<Button>().enabled = false; StaffRoll btn = GameObject.Find("Button").GetComponent<StaffRoll>(); btn.kahouCd = kahouCd; btn.kahouId = kahouId; //3rd Item - BusyoDama string itm3Path = "Prefabs/Item/busyoDama"; GameObject item3Obj = Instantiate(Resources.Load (itm3Path)) as GameObject; GameObject item3 = GameObject.Find("item3").gameObject; item3Obj.transform.SetParent(item3.transform); item3Obj.transform.localScale = new Vector2(1.0f,1.1f); } }else{ //Already got item GameObject kunimap = GameObject.Find("KuniMap").gameObject; GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject; Destroy (kunimap.gameObject); Destroy (kuniIconView.gameObject); StaffRoll roll = new StaffRoll(); roll.FinMaker(panel); } } }