//Check whether can attacked Kuni trace to doumei Diamyo public List<string> traceNeighborDaimyo(int attackedKuniId, int attackedDaimyoId, List<string> doumeiDaimyoList, List<string>seiryokuList, List<string>checkedList, List<string> okDaimyoList){ List<int> nKuniList = new List<int>(); KuniInfo kuni = new KuniInfo (); nKuniList = kuni.getMappingKuni(attackedKuniId); for (int i=0; i<nKuniList.Count; i++) { string tempDaimyoId = seiryokuList[nKuniList[i]-1]; if(!checkedList.Contains(nKuniList[i].ToString())){ checkedList.Add(nKuniList[i].ToString()); if(doumeiDaimyoList.Contains(tempDaimyoId)){ //found if(!okDaimyoList.Contains(tempDaimyoId)){ //no duplication okDaimyoList.Add(tempDaimyoId); } }else{ //not found if(int.Parse(tempDaimyoId) == attackedDaimyoId){ okDaimyoList = traceNeighborDaimyo(nKuniList[i], attackedDaimyoId, doumeiDaimyoList, seiryokuList, checkedList,okDaimyoList); } } } } return okDaimyoList; }
//Check whether can attacked Kuni trace to doumei Diamyo public List <string> traceNeighborDaimyo(int attackedKuniId, int attackedDaimyoId, List <string> doumeiDaimyoList, List <string> seiryokuList, List <string> checkedList, List <string> okDaimyoList) { List <int> nKuniList = new List <int>(); KuniInfo kuni = new KuniInfo(); nKuniList = kuni.getMappingKuni(attackedKuniId); for (int i = 0; i < nKuniList.Count; i++) { string tempDaimyoId = seiryokuList[nKuniList[i] - 1]; if (!checkedList.Contains(nKuniList[i].ToString())) { checkedList.Add(nKuniList[i].ToString()); if (doumeiDaimyoList.Contains(tempDaimyoId)) { //found if (!okDaimyoList.Contains(tempDaimyoId)) { //no duplication okDaimyoList.Add(tempDaimyoId); } } else { //not found if (int.Parse(tempDaimyoId) == attackedDaimyoId) { okDaimyoList = traceNeighborDaimyo(nKuniList[i], attackedDaimyoId, doumeiDaimyoList, seiryokuList, checkedList, okDaimyoList); } } } } return(okDaimyoList); }
// Update is called once per frame void Update() { life = getTotalHp (targetTag); gameObject.transform.FindChild("HpText").GetComponent<Text>().text = life.ToString(); if (!flag) { if (life == 0) { flag = true; if (targetTag == "Player") { //Game Over string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.parent = GameObject.Find ("Canvas").transform; backObj.transform.localScale = new Vector2(70,63); //Chane word Color color = Color.blue; GameObject.Find ("winlose").GetComponent<TextMesh>().text = "敗北"; GameObject.Find ("winlose").GetComponent<TextMesh>().color = color; string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject; blackObj.transform.parent = GameObject.Find ("Canvas").transform; blackObj.transform.localScale = new Vector2(330,300); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject; makimonoObj.transform.parent = GameObject.Find ("Canvas").transform; makimonoObj.transform.localScale = new Vector2(60,80); makimonoObj.transform.localPosition = new Vector2(0,-130); //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject; bttnListObj.transform.parent = GameObject.Find ("Canvas").transform; bttnListObj.transform.localScale = new Vector2(1,1); //Time Stop GameObject.Find ("timer").GetComponent<Timer>().enabled = false; } else if (targetTag == "Enemy") { //Win string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.parent = GameObject.Find ("Canvas").transform; backObj.transform.localScale = new Vector2(70,63); string particlePath = "Prefabs/PostKassen/particle"; GameObject particleObj = Instantiate(Resources.Load (particlePath)) as GameObject; particleObj.transform.parent = GameObject.Find ("Canvas").transform; particleObj.transform.localPosition = new Vector2(0,60); string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject; blackObj.transform.parent = GameObject.Find ("Canvas").transform; blackObj.transform.localScale = new Vector2(330,300); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject; makimonoObj.transform.parent = GameObject.Find ("Canvas").transform; makimonoObj.transform.localScale = new Vector2(60,80); makimonoObj.transform.localPosition = new Vector2(0,-130); //Item List string itemListPath = "Prefabs/PostKassen/itemList"; GameObject itemListObj = Instantiate(Resources.Load (itemListPath)) as GameObject; itemListObj.transform.parent = GameObject.Find ("Canvas").transform; itemListObj.transform.localScale = new Vector2(1,1); /*Item or Kahou*/ string activeItemType = PlayerPrefs.GetString("activeItemType"); int activeItemId = PlayerPrefs.GetInt("activeItemId"); float activeItemRatio = PlayerPrefs.GetFloat("activeItemRatio"); int activeItemQty = PlayerPrefs.GetInt("activeItemQty"); float percent = Random.value; percent = percent * 100; if(percent <= activeItemRatio){ //if(0 <= activeItemRatio){ //Test //Get Item string cyouheiPath = "Prefabs/Item/Cyouhei/" + activeItemType; string kanjyoPath = "Prefabs/Item/Kanjyo/Kanjyo"; string hidensyoPath = "Prefabs/Item/Hidensyo/Hidensyo"; char[] delimiterChars = {','}; ShowStageDtl itemIcon = new ShowStageDtl(); if(activeItemType.Contains("Cyouhei")==true){ string newCyouheiString = ""; itemIcon.makeItemIcon(cyouheiPath, activeItemId.ToString(), itemListObj); if(activeItemType.Contains("YR")==true){ string cyouheiString = PlayerPrefs.GetString("cyouheiYR"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(cyouheiList[0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(cyouheiList[1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(cyouheiList[2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("cyouheiYR", newCyouheiString); }else if(activeItemType.Contains("KB")==true){ string cyouheiString = PlayerPrefs.GetString("cyouheiKB"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(cyouheiList[0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(cyouheiList[1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(cyouheiList[2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("cyouheiKB", newCyouheiString); }else if(activeItemType.Contains("TP")==true){ string cyouheiString = PlayerPrefs.GetString("cyouheiTP"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(cyouheiList[0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(cyouheiList[1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(cyouheiList[2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("cyouheiTP", newCyouheiString); }else if(activeItemType.Contains("YM")==true){ string cyouheiString = PlayerPrefs.GetString("cyouheiYM"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(cyouheiList[0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(cyouheiList[1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(cyouheiList[2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("cyouheiYM", newCyouheiString); } }else if(activeItemType == "Kanjyo"){ itemIcon.makeItemIcon(kanjyoPath, activeItemId.ToString(), itemListObj); string newKanjyoString = ""; string kanjyoString = PlayerPrefs.GetString("kanjyo"); string[] kanjyoList = kanjyoString.Split (delimiterChars); if(activeItemId == 1){ int tempQty = int.Parse(kanjyoList[0]); tempQty = tempQty + activeItemQty; newKanjyoString = tempQty.ToString() + "," + kanjyoList[1] +","+ kanjyoList[2]; }else if(activeItemId == 2){ int tempQty = int.Parse(kanjyoList[1]); tempQty = tempQty + activeItemQty; newKanjyoString = kanjyoList[0] + "," + tempQty.ToString() +","+ kanjyoList[2]; }else if(activeItemId == 3){ int tempQty = int.Parse(kanjyoList[2]); tempQty = tempQty + activeItemQty; newKanjyoString = kanjyoList[0] +","+ kanjyoList[1] + "," + tempQty.ToString(); } PlayerPrefs.SetString("kanjyo", newKanjyoString); }else if(activeItemType == "Hidensyo"){ itemIcon.makeItemIcon(hidensyoPath, activeItemId.ToString(), itemListObj); if(activeItemId == 1){ int hidensyoQty = PlayerPrefs.GetInt("hidensyoGe"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt("hidensyoGe", hidensyoQty); }else if(activeItemId == 2){ int hidensyoQty = PlayerPrefs.GetInt("hidensyoCyu"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt("hidensyoCyu", hidensyoQty); }else if(activeItemId == 3){ int hidensyoQty = PlayerPrefs.GetInt("hidensyoJyo"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt("hidensyoJyo", hidensyoQty); } }else{ //Kahou string kahouIconPath = "Prefabs/Item/Kahou/" + activeItemType + activeItemId; GameObject kahouIcon = Instantiate (Resources.Load (kahouIconPath)) as GameObject; kahouIcon.transform.SetParent(itemListObj.transform); kahouIcon.name = "itemIcon"; RectTransform kahouTransform = kahouIcon.GetComponent<RectTransform> (); kahouTransform.sizeDelta = new Vector2 (100, 100); GameObject rank = kahouIcon.transform.FindChild("Rank").gameObject; rank.transform.localScale = new Vector2(0.3f,0.3f); rank.transform.localPosition = new Vector2(20,-20); //Register addKahou(activeItemType, activeItemId); } //Modfication Size & Location GameObject item = GameObject.Find ("itemIcon"); item.transform.localScale = new Vector2 (0.4f, 0.42f); item.transform.localPosition = new Vector2(80,-105); item.GetComponent<Button>().enabled = false; //Qty string itemQtyPath = "Prefabs/PostKassen/itemQty"; GameObject itemQtyObj = Instantiate(Resources.Load (itemQtyPath)) as GameObject; itemQtyObj.transform.SetParent(itemListObj.transform); itemQtyObj.transform.localScale = new Vector2(0.09f,0.09f); itemQtyObj.transform.localPosition = new Vector2(130,-105); itemQtyObj.GetComponent<Text>().text = "x " + activeItemQty.ToString(); // PlayerPrefs.Flush(); } //Money int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney",0); GameObject.Find ("moneyAmt").GetComponent<TextMesh>().text = activeStageMoney.ToString(); int currentMoney = PlayerPrefs.GetInt("money"); currentMoney = currentMoney + activeStageMoney; PlayerPrefs.SetInt("money",currentMoney); //kuniExp int activeStageExp = PlayerPrefs.GetInt("activeStageExp",0); GameObject.Find ("expAmt").GetComponent<TextMesh>().text = activeStageExp.ToString(); int currentKuniExp = PlayerPrefs.GetInt ("kuniExp"); currentKuniExp = currentKuniExp + activeStageExp; int kuniLv = PlayerPrefs.GetInt ("kuniLv"); Exp kuniExp = new Exp(); int newKuniLv = kuniExp.getKuniLv(kuniLv,currentKuniExp); if(newKuniLv>kuniLv){ //lv up int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv); int stockLimit = kuniExp.getStockLimit(newKuniLv); PlayerPrefs.SetInt("jinkeiLimit",jinkeiLimit); PlayerPrefs.SetInt("stockLimit",stockLimit); }else{ Debug.Log ("No level up"); } /*Cleared Flag*/ int activeKuniId = PlayerPrefs.GetInt("activeKuniId"); int activeStageId = PlayerPrefs.GetInt("activeStageId"); string temp = "kuni" + activeKuniId.ToString(); List<string> clearedStageList = new List<string>(); string clearedStageString = PlayerPrefs.GetString(temp); if(clearedStageString !=null && clearedStageString !=""){ //after 1st time char[] delimiterChars = {','}; clearedStageList = new List<string>(clearedStageString.Split (delimiterChars)); if(clearedStageList.Contains(activeStageId.ToString()) == false){ clearedStageString = clearedStageString + "," + activeStageId.ToString(); //1st Kuni Clear Check string[] commaCounter = clearedStageString.Split(delimiterChars); int counter = commaCounter.Length; if(counter == 10){ //1st time string clearedKuni = PlayerPrefs.GetString("clearedKuni"); if(clearedKuni !=null && clearedKuni !=""){ clearedKuni = clearedKuni + "," + activeKuniId.ToString(); }else{ clearedKuni = activeKuniId.ToString(); } PlayerPrefs.SetString("clearedKuni",clearedKuni); //Give 1st cleared revenue PlayerPrefs.SetBool("kuniClearedFlg",true); //Open Kuni KuniInfo kuni = new KuniInfo(); kuni.registerOpenKuni(activeKuniId); //Seiryoku Change string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string>(); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); seiryokuList[activeKuniId-1] = myDaimyo.ToString(); string newSeiryoku = ""; for(int i=0; i<seiryokuList.Count; i++){ if(i==0){ newSeiryoku = seiryokuList[i]; }else{ newSeiryoku = newSeiryoku + "," + seiryokuList[i]; } } PlayerPrefs.SetString("seiryoku",newSeiryoku); } } }else{ //1st time clearedStageString = activeKuniId.ToString(); } PlayerPrefs.SetString(temp,clearedStageString); PlayerPrefs.SetInt("kuniLv",newKuniLv); PlayerPrefs.SetInt("kuniExp",currentKuniExp); PlayerPrefs.Flush(); //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject; bttnListObj.transform.parent = GameObject.Find ("Canvas").transform; bttnListObj.transform.localScale = new Vector2(1,1); //Time Stop GameObject.Find ("timer").GetComponent<Timer>().enabled = false; //Get Exp SenkouButton senkou = new SenkouButton(); List<BusyoSenkou> senkouList = new List<BusyoSenkou>(); senkouList=senkou.getSenkou (); for(int i=0;i<senkouList.Count;i++){ int busyoId = senkouList[i].id; int senkouAmt = senkouList[i].senkou; Exp exp = new Exp(); //Modify by Cyadougu Kahou senkouAmt = exp.getExpbyCyadougu(busyoId,senkouAmt); //Busyo Exp string tempExp = "exp" + busyoId; int nowExp = PlayerPrefs.GetInt(tempExp); int newExp = nowExp + senkouAmt; PlayerPrefs.SetInt(tempExp, newExp); //Busyo Lv int nowLv = PlayerPrefs.GetInt(busyoId.ToString()); int newLv = exp.getLvbyTotalExp(nowLv,newExp); PlayerPrefs.SetInt(busyoId.ToString(), newLv); PlayerPrefs.Flush(); } } } } }
public void OnClick() { if (close.GetComponent <CloseBoard> ().kuniId != kuniId) { close.GetComponent <CloseBoard> ().kuniId = kuniId; AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [2].Play(); /*Status*/ //Common GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject; SendParam script = kuniIconView.transform.FindChild(kuniId.ToString()).GetComponent <SendParam> (); KuniInfo kuni = new KuniInfo(); Daimyo daimyo = new Daimyo(); Gaikou gaikou = new Gaikou(); List <int> targetKuniList = new List <int> (); targetKuniList = kuni.getMappingKuni(kuniId); char[] delimiterChars = { ',' }; //Kamon GameObject daimyoNameObj = status.transform.FindChild("DaimyoName").gameObject; string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString(); daimyoNameObj.transform.FindChild("Kamon").GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; //Daimyo Name daimyoNameObj.transform.FindChild("Value").GetComponent <Text> ().text = daimyoName; //Kuni Name GameObject kuniNameObj = status.transform.FindChild("KuniName").gameObject; kuniNameObj.transform.FindChild("Value").GetComponent <Text> ().text = kuniName; //Heiryoku status.transform.FindChild("Heiryoku").transform.FindChild("Value").GetComponent <Text> ().text = script.heiryoku.ToString(); //Yukou status.transform.FindChild("Yukoudo").transform.FindChild("Value").GetComponent <Text> ().text = script.myYukouValue.ToString(); //Attack Target bool aggressiveFlg = script.aggressiveFlg; int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); int targetKuniId = getKassenTargetKuni(kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId); int targetDaimyoId = 0; if (targetKuniId != 0) { string targetKuniName = kuni.getKuniName(targetKuniId); targetDaimyoId = int.Parse(seiryokuList [targetKuniId - 1]); string targetDaimyoName = daimyo.getName(targetDaimyoId); status.transform.FindChild("Atk").transform.FindChild("Value").GetComponent <Text> ().text = targetKuniName + "(" + targetDaimyoName + ")"; } else { if (Application.systemLanguage != SystemLanguage.Japanese) { status.transform.FindChild("Atk").transform.FindChild("Value").GetComponent <Text>().text = "None"; } else { status.transform.FindChild("Atk").transform.FindChild("Value").GetComponent <Text> ().text = "無し"; } } int targetGaikouKuniId = 0; if (snbRank > 1) //Jyo or Cyu //Gaikou { targetGaikouKuniId = getGaikouTargetKuni(kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId); if (targetGaikouKuniId != 0) { string targetGaikouKuniName = kuni.getKuniName(targetGaikouKuniId); int targetGaikouDaimyoId = int.Parse(seiryokuList [targetGaikouKuniId - 1]); string targetGaikouDaimyoName = daimyo.getName(targetGaikouDaimyoId); if (targetDaimyoId != targetGaikouDaimyoId) { status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text> ().text = targetGaikouKuniName + "(" + targetGaikouDaimyoName + ")"; } else { sameDaimyoFlg = true; if (Application.systemLanguage != SystemLanguage.Japanese) { status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text>().text = "None"; } else { status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text> ().text = "無し"; } } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text>().text = "None"; } else { status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text>().text = "無し"; } } //Doumei string doumeiTmp = "doumei" + daimyoId.ToString(); string doumeiString = PlayerPrefs.GetString(doumeiTmp); List <string> doumeiList = new List <string> (); if (doumeiString != null && doumeiString != "") { if (doumeiString.Contains(",")) { doumeiList = new List <string> (doumeiString.Split(delimiterChars)); } else { doumeiList.Add(doumeiString); } } //Exist Check if (doumeiList.Count != 0) { List <string> doumeiListTmp = new List <string> (doumeiList); for (int j = 0; j < doumeiListTmp.Count; j++) { string doumeiDaimyoId = doumeiListTmp [j]; if (!seiryokuList.Contains(doumeiDaimyoId)) { doumeiList.Remove(doumeiDaimyoId); } } } string doumeiNameList = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { doumeiNameList = "None"; } else { doumeiNameList = "無し"; } for (int j = 0; j < doumeiList.Count; j++) { if (j == 0) { doumeiNameList = daimyo.getName(int.Parse(doumeiList [j])); } else { doumeiNameList = doumeiNameList + "," + daimyo.getName(int.Parse(doumeiList [j])); } } status.transform.FindChild("Doumei").transform.FindChild("Value").GetComponent <Text> ().text = doumeiNameList; } else { //Ge status.transform.FindChild("Gaiko").transform.FindChild("Value").GetComponent <Text> ().text = "?"; status.transform.FindChild("Doumei").transform.FindChild("Value").GetComponent <Text> ().text = "?"; } if (snbRank > 2) //Jyo { BusyoInfoGet busyo = new BusyoInfoGet(); string qtyAndHeisyu = busyo.getDaimyoBusyoQtyHeisyu(daimyoId); List <string> qtyAndHeisyuiList = new List <string> (); qtyAndHeisyuiList = new List <string> (qtyAndHeisyu.Split(delimiterChars)); //BusyoQty //Heisyu status.transform.FindChild("BusyoQty").transform.FindChild("Value").GetComponent <Text> ().text = qtyAndHeisyuiList[0]; status.transform.FindChild("Heisyu").transform.FindChild("Value").GetComponent <Text> ().text = qtyAndHeisyuiList[1]; } else { //Cyu or Ge status.transform.FindChild("BusyoQty").transform.FindChild("Value").GetComponent <Text> ().text = "?"; status.transform.FindChild("Heisyu").transform.FindChild("Value").GetComponent <Text> ().text = "?"; } //Main Map foreach (Transform obj in board.transform) { if (obj.name != "Explanation") { Destroy(obj.gameObject); } } //Create Map GameObject originalKuniMap = GameObject.Find("KuniMap"); GameObject copiedKuniMap = Object.Instantiate(originalKuniMap) as GameObject; copiedKuniMap.transform.SetParent(board.transform); copiedKuniMap.transform.localScale = new Vector2(1, 0.8f); Vector3 vect = copiedKuniMap.transform.FindChild(kuniId.ToString()).transform.localPosition; float adjstX = vect.x * -1; float adjustY = vect.y * -1; RectTransform mapRect = copiedKuniMap.GetComponent <RectTransform>(); mapRect.anchoredPosition3D = new Vector3(adjstX, adjustY, 0); //Create Kamon GameObject originalKamon = GameObject.Find("KuniIconView"); GameObject copiedKamon = Object.Instantiate(originalKamon) as GameObject; copiedKamon.transform.SetParent(board.transform); copiedKamon.transform.localScale = new Vector2(1, 0.8f); RectTransform kamonRect = copiedKamon.GetComponent <RectTransform>(); kamonRect.anchoredPosition3D = new Vector3(adjstX, adjustY, 0); Entity_kuni_mst kuniMst = Resources.Load("Data/kuni_mst") as Entity_kuni_mst; Color whiteColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f); for (int i = 0; i < kuniMst.param.Count; i++) { int subKuniId = i + 1; GameObject tmpKuniObj = copiedKuniMap.transform.FindChild(subKuniId.ToString()).gameObject; GameObject tmpKamonObj = copiedKamon.transform.FindChild(subKuniId.ToString()).gameObject; tmpKamonObj.GetComponent <Image>().color = whiteColor; if (subKuniId == kuniId) { tmpKamonObj.GetComponent <Button>().enabled = false; tmpKamonObj.GetComponent <Image>().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; //EFFECT string effectPath = "Prefabs/EffectAnime/point_up"; GameObject pointUp = Instantiate(Resources.Load(effectPath)) as GameObject; pointUp.transform.SetParent(tmpKamonObj.transform); pointUp.transform.localScale = new Vector2(70, 70); pointUp.transform.localPosition = new Vector2(0, 25); pointUp.GetComponent <Fadeout>().enabled = false; } else { if (targetKuniList.Contains(subKuniId)) { tmpKamonObj.GetComponent <Button>().enabled = false; int subDaimyoId = int.Parse(seiryokuList[subKuniId - 1]); if (daimyoId != subDaimyoId) { //yukoudo int yukoudoValue = gaikou.getExistGaikouValue(daimyoId, subDaimyoId); string syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel"; GameObject yukoudoObj = Instantiate(Resources.Load(syukoudoPath)) as GameObject; yukoudoObj.transform.SetParent(tmpKamonObj.transform); yukoudoObj.GetComponent <Text>().text = yukoudoValue.ToString(); yukoudoObj.transform.localScale = new Vector2(0.08f, 0.1f); yukoudoObj.transform.localPosition = new Vector2(0, 26); } else { tmpKamonObj.GetComponent <Image>().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; } if (targetKuniId != 0) { if (targetKuniId == subKuniId) { //kassen target Color atkColor = new Color(180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); tmpKamonObj.GetComponent <Image>().color = atkColor; } } if (snbRank > 1) { if (targetGaikouKuniId != 0) { if (targetGaikouKuniId == subKuniId) { if (!sameDaimyoFlg) { //gaikou target Color gaikouColor = new Color(80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f); tmpKamonObj.GetComponent <Image>().color = gaikouColor; } } } } } else { Color noSubKuniColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f); tmpKuniObj.GetComponent <Image>().color = noSubKuniColor; tmpKamonObj.SetActive(false); } } } /* * string kuniMapPath = "Prefabs/Map/cyouhou/kuniImage"; * GameObject mainMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject; * mainMap.transform.SetParent(board.transform); * mainMap.transform.localScale = new Vector2 (13, 9); * mainMap.name = "kuniMap" + kuniId; * string kuniImagePath = "Prefabs/Map/kuniMap/" + kuniId.ToString (); * mainMap.GetComponent<Image> ().sprite = * Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite; * * int baseX = kuni.getKuniLocationX (kuniId); * int baseY = kuni.getKuniLocationY (kuniId); * int adjstX = baseX * -1; * int adjustY = baseY * -1; * * float colorR = daimyo.getColorR (daimyoId); * float colorG = daimyo.getColorG (daimyoId); * float colorB = daimyo.getColorB (daimyoId); * Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); * mainMap.GetComponent<Image> ().color = kuniColor; * * RectTransform mapRect = mainMap.GetComponent<RectTransform> (); * mapRect.anchoredPosition3D = new Vector3 (adjstX, adjustY, 0); * * //My Kuni Kamon Icon * string kamonBackPath ="Prefabs/Map/cyouhou/KamonBack"; * GameObject kamonBack = Instantiate (Resources.Load (kamonBackPath)) as GameObject; * kamonBack.transform.SetParent (board.transform); * kamonBack.transform.localScale = new Vector2 (1, 1); * kamonBack.transform.localPosition = new Vector2(0,0); * * string kamonKuniPath = "Prefabs/Map/Kuni/" + kuniId.ToString(); * GameObject kamonObj = Instantiate (Resources.Load (kamonKuniPath)) as GameObject; * kamonObj.transform.SetParent (kamonBack.transform); * kamonObj.transform.localScale = new Vector2 (1, 0.8f); * kamonObj.transform.localPosition = new Vector2(0,0); * kamonObj.GetComponent<Image> ().sprite = * Resources.Load (imagePath, typeof(Sprite)) as Sprite; * kamonObj.GetComponent<Button> ().enabled = false; * * * //Mapping Kuni * Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst; * for (int i=0; i < kuniMst.param.Count; i++) { * //for (int i=0; i < targetKuniList.Count; i++) { * int subKuniId = i + 1; * * GameObject subMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject; * subMap.transform.SetParent(mainMap.transform); * subMap.transform.localScale = new Vector2 (1, 1); * subMap.transform.localPosition = new Vector2 (0, 0); * * subMap.name = "kuniMap" + subKuniId; * string subKuniImagePath = "Prefabs/Map/kuniMap/" + subKuniId; * subMap.GetComponent<Image> ().sprite = * Resources.Load (subKuniImagePath, typeof(Sprite)) as Sprite; * * * if (targetKuniList.Contains (subKuniId)) { * //color * int subDaimyoId = int.Parse (seiryokuList [subKuniId - 1]); * float subColorR = daimyo.getColorR (subDaimyoId); * float subColorG = daimyo.getColorG (subDaimyoId); * float subColorB = daimyo.getColorB (subDaimyoId); * Color subKuniColor = new Color (subColorR / 255f, subColorG / 255f, subColorB / 255f, 255f / 255f); * subMap.GetComponent<Image> ().color = subKuniColor; * * //Kamon * string subKamonKuniPath = "Prefabs/Map/Kuni/" + subKuniId.ToString (); * GameObject subKamonObj = Instantiate (Resources.Load (subKamonKuniPath)) as GameObject; * subKamonObj.transform.SetParent (board.transform); * subKamonObj.transform.localScale = new Vector2 (1, 0.8f); * if (daimyoId != subDaimyoId) { * string subImagePath = "Prefabs/Kamon/" + subDaimyoId.ToString (); * subKamonObj.GetComponent<Image> ().sprite = * Resources.Load (subImagePath, typeof(Sprite)) as Sprite; * * //yukoudo * int yukoudoValue = gaikou.getExistGaikouValue (daimyoId, subDaimyoId); * string syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel"; * GameObject yukoudoObj = Instantiate (Resources.Load (syukoudoPath)) as GameObject; * yukoudoObj.transform.SetParent (subKamonObj.transform); * yukoudoObj.GetComponent<Text> ().text = yukoudoValue.ToString (); * yukoudoObj.transform.localScale = new Vector2 (0.08f, 0.1f); * yukoudoObj.transform.localPosition = new Vector2 (0, 26); * * } else { * subKamonObj.GetComponent<Image> ().sprite = * Resources.Load (imagePath, typeof(Sprite)) as Sprite; * } * subKamonObj.GetComponent<Button> ().enabled = false; * * //Kamon adjustment * int subBaseX = kuni.getKuniLocationX (subKuniId); * int subBaseY = kuni.getKuniLocationY (subKuniId); * int subAdjstX = subBaseX - baseX; * int subAdjstY = subBaseY - baseY; * * RectTransform subMapRect = subKamonObj.GetComponent<RectTransform> (); * subMapRect.anchoredPosition3D = new Vector3 (subAdjstX, subAdjstY, 0); * * if (targetKuniId != 0) { * if (targetKuniId == subKuniId) { * //kassen target * Color atkColor = new Color (180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); * subKamonObj.GetComponent<Image> ().color = atkColor; * } * } * * if (snbRank > 1) { * if (targetGaikouKuniId != 0) { * if (targetGaikouKuniId == subKuniId) { * if (!sameDaimyoFlg) { * //gaikou target * Color gaikouColor = new Color (80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f); * subKamonObj.GetComponent<Image> ().color = gaikouColor; * } * } * } * } * } else { * Color noSubKuniColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f); * subMap.GetComponent<Image> ().color = noSubKuniColor; * } * * } * */ } }
public void 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/Cyoutei/SelectSyoukaijyoBoard"; GameObject pop = Instantiate (Resources.Load (pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find ("Panel").transform; pop.transform.localScale = new Vector2 (1, 1); pop.transform.localPosition = new Vector2 (0, 0); pop.name = "SelectSyoukaijyoBoard"; back.GetComponent<CloseLayer> ().closeTargetObj = pop; back.GetComponent<CloseLayer> ().closeTargetBack = back; pop.transform.FindChild ("CloseBtn").GetComponent<CloseLayer> ().closeTargetObj = pop; pop.transform.FindChild ("CloseBtn").GetComponent<CloseLayer> ().closeTargetBack = back; //Check Syoukaijyo string nowQty = PlayerPrefs.GetString ("cyoutei"); //string nowQty = "0,0,0"; List<string> nowQtyList = new List<string> (); char[] delimiterChars = {','}; nowQtyList = new List<string> (nowQty.Split (delimiterChars)); GameObject scrollView = pop.transform.FindChild ("ScrollView").gameObject; GameObject content = scrollView.transform.FindChild ("Content").gameObject; bool notZeroflg = false; //Jyo if (nowQtyList [2] == "0") { content.transform.FindChild ("Jyo").gameObject.SetActive (false); } else { notZeroflg = true; content.transform.FindChild ("Jyo").transform.FindChild ("cyoutei").transform.FindChild ("Qty").GetComponent<Text> ().text = nowQtyList [2]; content.transform.FindChild ("Jyo").GetComponent<SyoukaijyoSelect>().OnClick(); } //Cyu if (nowQtyList [1] == "0") { content.transform.FindChild ("Cyu").gameObject.SetActive (false); } else { notZeroflg = true; content.transform.FindChild ("Cyu").transform.FindChild ("cyoutei").transform.FindChild ("Qty").GetComponent<Text> ().text = nowQtyList [1]; content.transform.FindChild ("Cyu").GetComponent<SyoukaijyoSelect>().OnClick(); } //Ge if (nowQtyList [0] == "0") { content.transform.FindChild ("Ge").gameObject.SetActive (false); } else { notZeroflg = true; content.transform.FindChild ("Ge").transform.FindChild ("cyoutei").transform.FindChild ("Qty").GetComponent<Text> ().text = nowQtyList [0]; content.transform.FindChild ("Ge").GetComponent<SyoukaijyoSelect>().OnClick(); } if (!notZeroflg) { scrollView.transform.FindChild ("NoSyoukaijyo").GetComponent<Text> ().enabled = true; pop.transform.FindChild ("Serihu").transform.FindChild ("Text").GetComponent<Text> ().text = "公家からの紹介状が無いと殿中には入れませんぞ。"; pop.transform.FindChild ("PassButton").gameObject.SetActive (false); } pop.transform.FindChild("PassButton").GetComponent<CyouteiPop>().SelectSyoukaijyoBoard = pop; pop.transform.FindChild("PassButton").GetComponent<CyouteiPop>().myDaimyoFlg = myDaimyoFlg; pop.transform.FindChild("PassButton").GetComponent<CyouteiPop>().occupiedDaimyoName = occupiedDaimyoName; pop.transform.FindChild("PassButton").GetComponent<CyouteiPop>().yukoudo = yukoudo; } 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/Cyoutei/CyouteiBoard"; GameObject pop = Instantiate (Resources.Load (pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find ("Panel").transform; pop.transform.localScale = new Vector2 (1, 1); pop.transform.localPosition = new Vector2 (0, 0); pop.name = "CyouteiBoard"; CloseLayer CloseLayerScript = pop.transform.FindChild("CloseSyoukaijyo").GetComponent<CloseLayer>(); CloseLayerScript.closeTargetBack = back; CloseLayerScript.closeTargetObj = pop; CloseLayerScript.syoukaijyoRank = syoukaijyoRank; CloseLayerScript.occupiedFlg = myDaimyoFlg; //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"){ List<string> btnNameList = new List<string> (){"Bakuhu","Cyouteki"}; enableButton(pop,btnNameList); yukouAddValue = Random.Range(1, 3); stopBattleRatio = Random.Range(10, 30); kanniRatio = Random.Range(20, 60); syoukaijyoRankId = 1; action.transform.FindChild("ActionValue").GetComponent<Text>().text = "1"; action.transform.FindChild("ActionMaxValue").GetComponent<Text>().text = "1"; }else if(syoukaijyoRank == "Cyu"){ List<string> btnNameList = new List<string> (){"Bakuhu","Cyouteki"}; enableButton(pop,btnNameList); yukouAddValue = Random.Range(3, 8); stopBattleRatio = Random.Range(30, 80); kanniRatio = Random.Range(40, 80); syoukaijyoRankId = 2; action.transform.FindChild("ActionValue").GetComponent<Text>().text = "2"; action.transform.FindChild("ActionMaxValue").GetComponent<Text>().text = "2"; }else if(syoukaijyoRank == "Jyo"){ yukouAddValue = Random.Range(8, 15); stopBattleRatio = 100; kanniRatio = Random.Range(60, 100); syoukaijyoRankId = 3; action.transform.FindChild("ActionValue").GetComponent<Text>().text = "3"; action.transform.FindChild("ActionMaxValue").GetComponent<Text>().text = "3"; } //TargetKanni; Kanni kanni = new Kanni(); int kuniQty = GameObject.Find("GameController").GetComponent<MainStageController>().myKuniQty; int kanniId = kanni.getRandomKanni(syoukaijyoRankId,kuniQty); CloseLayerScript.yukouAddValue = yukouAddValue; CloseLayerScript.yukouReducePoint = yukouReducePoint; CloseLayerScript.stopBattleRatio = stopBattleRatio; CloseLayerScript.stopBattleReducePoint = stopBattleReducePoint; CloseLayerScript.kanniId = kanniId; if(kanniId != 0){ CloseLayerScript.kanniName = kanni.getKanniName(kanniId); CloseLayerScript.kanniRatio = kanniRatio; CloseLayerScript.kanniReducePoint = kanniReducePoint; } //Cyoutei Point int cyouteiPoint = PlayerPrefs.GetInt("cyouteiPoint"); pop.transform.FindChild("CyouteiPoint").transform.FindChild("CyouteiValue").GetComponent<Text>().text = cyouteiPoint.ToString() + "%"; bool doneFirstCyouteiFlg = PlayerPrefs.GetBool("doneFirstCyouteiFlg"); Daimyo daimyo = new Daimyo(); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); if(!doneFirstCyouteiFlg){ //1st time PlayerPrefs.SetBool("doneFirstCyouteiFlg",true); KuniInfo kuni = new KuniInfo(); int kuniId = kuni.getOneKuniId(myDaimyo); int firstKanniId = kanni.getKuniKanni(kuniId); string firstKanniName = kanni.getKanniName(firstKanniId); string myKanni = PlayerPrefs.GetString ("myKanni"); if(myKanni != null && myKanni !=""){ myKanni = myKanni + "," + firstKanniId.ToString(); }else{ myKanni = firstKanniId.ToString(); } PlayerPrefs.SetString ("myKanni",myKanni); PlayerPrefs.Flush(); string serihu = "噂は宮中まで届いておるぞ。天下静謐のため力を貸してくれ。\t" + firstKanniName + "に任ずるぞ。"; pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent<Text>().text = serihu; }else{ //2nd time //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() { int hyourou = PlayerPrefs.GetInt("hyourou"); AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (name == "AtkOrderBtn") { if (hyourou >= 10) { audioSources [0].Play(); //Common //Back string returnPath = "Prefabs/Bakuhu/Return"; GameObject returnObj = Instantiate(Resources.Load(returnPath)) as GameObject; returnObj.transform.SetParent(board.transform); returnObj.transform.localScale = new Vector2(1, 1); returnObj.transform.localPosition = new Vector2(-560, 290); returnObj.name = "bakuhuReturn"; //Disabled scrollView.SetActive(false); //Base Obj string basePath = "Prefabs/Bakuhu/Base"; GameObject baseObj = Instantiate(Resources.Load(basePath)) as GameObject; baseObj.transform.SetParent(board.transform); baseObj.transform.localScale = new Vector2(1, 1); baseObj.name = "BakuhuBase"; returnObj.GetComponent <BakuhuMenuReturn> ().deleteObj = baseObj; returnObj.GetComponent <BakuhuMenuReturn> ().scrollView = scrollView; returnObj.GetComponent <BakuhuMenuReturn> ().board = board; if (Application.systemLanguage != SystemLanguage.Japanese) { board.transform.FindChild("popText").GetComponent <Text> ().text = "Attack Order"; } else { board.transform.FindChild("popText").GetComponent <Text>().text = "討伐令"; } string textPath = "Prefabs/Bakuhu/ToubatsuText"; GameObject textObj = Instantiate(Resources.Load(textPath)) as GameObject; textObj.transform.SetParent(baseObj.transform); textObj.transform.localScale = new Vector2(0.12f, 0.15f); textObj.transform.localPosition = new Vector2(0, 206); textObj.name = "ToubatsuText"; //View daimyo kuni string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); string kuniPath = "Prefabs/Map/Kuni/"; Entity_kuni_mst kuniMst = Resources.Load("Data/kuni_mst") as Entity_kuni_mst; Entity_daimyo_mst daimyoMst = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst; int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); string kuniIconPath = "Prefabs/Bakuhu/BakuhuKuniMap"; GameObject kuniMapView = Instantiate(Resources.Load(kuniIconPath)) as GameObject; kuniMapView.transform.SetParent(baseObj.transform); kuniMapView.transform.localScale = new Vector2(0.8f, 0.65f); string kuniMapPath = "Prefabs/Bakuhu/BakuhuKuniIconView"; GameObject kuniIconView = Instantiate(Resources.Load(kuniMapPath)) as GameObject; kuniIconView.transform.SetParent(baseObj.transform); kuniIconView.transform.localScale = new Vector2(0.8f, 0.65f); kuniIconView.name = "BakuhuKuniIconView"; List <int> kuniQtyByDaimyoId = new List <int> () { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int myKuniQty = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQty; bool myKuniQtyIsBiggestFlg = true; for (int i = 0; i < kuniMst.param.Count; i++) { int kuniId = kuniMst.param [i].kunId; string newKuniPath = kuniPath + kuniId.ToString(); int locationX = kuniMst.param [i].locationX; int locationY = kuniMst.param [i].locationY; GameObject kuni = Instantiate(Resources.Load(newKuniPath)) as GameObject; kuni.transform.SetParent(kuniIconView.transform); kuni.name = kuniId.ToString(); kuni.transform.localScale = new Vector2(1, 1); //Seiryoku Handling int daimyoId = int.Parse(seiryokuList [kuniId - 1]); if (daimyoId == myDaimyo) { kuni.SetActive(false); float colorR = (float)daimyoMst.param [daimyoId - 1].colorR; float colorG = (float)daimyoMst.param [daimyoId - 1].colorG; float colorB = (float)daimyoMst.param [daimyoId - 1].colorB; Color kuniColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); kuniMapView.transform.FindChild(kuni.name).GetComponent <Image> ().color = kuniColor; } else { Daimyo daimyoScript = new Daimyo(); string daimyoName = daimyoScript.getName(daimyoId); kuni.GetComponent <SendParam> ().bakuhuFlg = true; kuni.GetComponent <SendParam> ().kuniId = kuniId; kuni.GetComponent <SendParam> ().daimyoId = daimyoId; kuni.GetComponent <SendParam> ().daimyoName = daimyoName; int daimyoBusyoIdTemp = daimyoMst.param [daimyoId - 1].busyoId; kuni.GetComponent <SendParam> ().daimyoBusyoId = daimyoBusyoIdTemp; /*Kuni Qty Start*/ int kuniQty = 0; if (kuniQtyByDaimyoId [daimyoId - 1] == 0) { kuniQty = getKuniQty(daimyoId, seiryokuList); kuniQtyByDaimyoId [daimyoId - 1] = kuniQty; } else { kuniQty = kuniQtyByDaimyoId [daimyoId - 1]; } kuni.GetComponent <SendParam> ().kuniQty = kuniQty; if (kuniQty >= myKuniQty) { myKuniQtyIsBiggestFlg = false; } /*Kuni Qty End*/ //Color Handling float colorR = (float)daimyoMst.param [daimyoId - 1].colorR; float colorG = (float)daimyoMst.param [daimyoId - 1].colorG; float colorB = (float)daimyoMst.param [daimyoId - 1].colorB; Color kuniColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); kuniMapView.transform.FindChild(kuni.name).GetComponent <Image> ().color = kuniColor; //Daimyo Kamon Image string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString(); kuni.GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; RectTransform kuniTransform = kuni.GetComponent <RectTransform> (); kuniTransform.anchoredPosition = new Vector3(locationX, locationY, 0); } } returnObj.GetComponent <BakuhuMenuReturn> ().myKuniQtyIsBiggestFlg = myKuniQtyIsBiggestFlg; } else { //Hyourou NG audioSources [4].Play(); Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } else if (name == "DfcOrderBtn") { //Boueirei if (hyourou >= 10) { //Gunzei Exist Check int bakuhuTobatsuDaimyoId = PlayerPrefs.GetInt("bakuhuTobatsuDaimyoId"); bool gunzeiFlg = false; KuniInfo kuni = new KuniInfo(); string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; char[] delimiterChars2 = { ':' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); //Used Engun List List <string> dstEngunDaimyoIdList = new List <string>(); foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")) { string dstEngunDaimyoId = obs.GetComponent <Gunzei>().dstEngunDaimyoId; List <string> tmpDstEngunDaimyoIdList = new List <string>(); if (dstEngunDaimyoId != null && dstEngunDaimyoId != "") { if (dstEngunDaimyoId.Contains(":")) { tmpDstEngunDaimyoIdList = new List <string>(dstEngunDaimyoId.Split(delimiterChars2)); } else { tmpDstEngunDaimyoIdList.Add(dstEngunDaimyoId); } } dstEngunDaimyoIdList.AddRange(tmpDstEngunDaimyoIdList); } List <string> okGunzeiList = new List <string> (); //key1:engunSrcKuni1:engunSrcKuni2...,key2:engunSrcKuni1:engunSrcKuni2.... foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")) { int checkDaimyoId = obs.GetComponent <Gunzei> ().dstDaimyoId; if (checkDaimyoId != bakuhuTobatsuDaimyoId) { int dstKuni = obs.GetComponent <Gunzei> ().dstKuni; int srcDaimyoId = obs.GetComponent <Gunzei> ().srcDaimyoId; int dstDaimyoId = obs.GetComponent <Gunzei> ().dstDaimyoId; List <int> openKuniList = new List <int> (); openKuniList = kuni.getMappingKuni(dstKuni); string tmpString = ""; List <int> usedDaimyoList = new List <int> (); for (int i = 0; i < openKuniList.Count; i++) { int tmpDaimyoId = int.Parse(seiryokuList [openKuniList [i] - 1]); if (tmpDaimyoId != myDaimyo && tmpDaimyoId != srcDaimyoId && tmpDaimyoId != dstDaimyoId) { if (!usedDaimyoList.Contains(tmpDaimyoId)) { if (!dstEngunDaimyoIdList.Contains(tmpDaimyoId.ToString())) { gunzeiFlg = true; usedDaimyoList.Add(tmpDaimyoId); if (tmpString == "") { tmpString = obs.name + ":" + openKuniList [i]; } else { tmpString = tmpString + ":" + openKuniList [i]; } } } } } if (tmpString != "") { okGunzeiList.Add(tmpString); } } } if (gunzeiFlg) { audioSources [0].Play(); //Common //Back string returnPath = "Prefabs/Bakuhu/Return"; GameObject returnObj = Instantiate(Resources.Load(returnPath)) as GameObject; returnObj.transform.SetParent(board.transform); returnObj.transform.localScale = new Vector2(1, 1); returnObj.transform.localPosition = new Vector2(-560, 290); returnObj.name = "bakuhuReturn"; if (Application.systemLanguage != SystemLanguage.Japanese) { board.transform.FindChild("popText").GetComponent <Text> ().text = "Defence Order"; } else { board.transform.FindChild("popText").GetComponent <Text>().text = "防衛令"; } //Disabled scrollView.SetActive(false); //Base Obj string basePath = "Prefabs/Bakuhu/Base"; GameObject baseObj = Instantiate(Resources.Load(basePath)) as GameObject; baseObj.transform.SetParent(board.transform); baseObj.transform.localScale = new Vector2(1, 1); baseObj.name = "BakuhuBase"; returnObj.GetComponent <BakuhuMenuReturn> ().deleteObj = baseObj; returnObj.GetComponent <BakuhuMenuReturn> ().scrollView = scrollView; returnObj.GetComponent <BakuhuMenuReturn> ().board = board; string boubiScrollPath = "Prefabs/Bakuhu/BoueiScrollView"; GameObject boueiScrollObj = Instantiate(Resources.Load(boubiScrollPath)) as GameObject; boueiScrollObj.transform.SetParent(baseObj.transform); boueiScrollObj.transform.localScale = new Vector2(1, 1); boueiScrollObj.transform.localPosition = new Vector2(0, 0); GameObject content = boueiScrollObj.transform.FindChild("Content").gameObject; string uniSlotPath = "Prefabs/Bakuhu/BoueiSlot"; string daimyoBusyoPath = "Prefabs/Player/Sprite/unit"; Daimyo daimyo = new Daimyo(); for (int i = 0; i < okGunzeiList.Count; i++) { string tmp = okGunzeiList [i]; List <string> okGunzeiUnitList = new List <string> (); okGunzeiUnitList = new List <string> (tmp.Split(delimiterChars2)); string key = okGunzeiUnitList [0]; GameObject gunzei = GameObject.Find(key).gameObject; int dstDaimyoId = gunzei.GetComponent <Gunzei> ().dstDaimyoId; int dstDaimyoBusyoId = daimyo.getDaimyoBusyoId(dstDaimyoId); string dstDaimyoName = daimyo.getName(dstDaimyoId); int srcDaimyoId = gunzei.GetComponent <Gunzei> ().srcDaimyoId; int srcDaimyoBusyoId = daimyo.getDaimyoBusyoId(srcDaimyoId); string srcDaimyoName = daimyo.getName(srcDaimyoId); int dstKuniId = gunzei.GetComponent <Gunzei> ().dstKuni; string kuniName = kuni.getKuniName(dstKuniId); for (int j = 1; j < okGunzeiUnitList.Count; j++) { int engunKuniId = int.Parse(okGunzeiUnitList [j]); int engunDaimyoId = int.Parse(seiryokuList [engunKuniId - 1]); int engunDaimyoBusyoId = daimyo.getDaimyoBusyoId(engunDaimyoId); string engunDaimyoName = daimyo.getName(engunDaimyoId); GameObject slot = Instantiate(Resources.Load(uniSlotPath)) as GameObject; slot.transform.SetParent(content.transform); slot.transform.localScale = new Vector2(1, 1); if (Application.systemLanguage != SystemLanguage.Japanese) { slot.transform.FindChild("Kuni").GetComponent <Text> ().text = kuniName + " Defence"; } else { slot.transform.FindChild("Kuni").GetComponent <Text>().text = kuniName + "防衛"; } string dfcDaimyoPath = daimyoBusyoPath + dstDaimyoBusyoId.ToString(); slot.transform.FindChild("Dfc").transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(dfcDaimyoPath, typeof(Sprite)) as Sprite; string atkDaimyoPath = daimyoBusyoPath + srcDaimyoBusyoId.ToString(); slot.transform.FindChild("Atk").transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(atkDaimyoPath, typeof(Sprite)) as Sprite; string engnDaimyoPath = daimyoBusyoPath + engunDaimyoBusyoId.ToString(); slot.transform.FindChild("Egn").transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(engnDaimyoPath, typeof(Sprite)) as Sprite; slot.transform.FindChild("DfcName").GetComponent <Text> ().text = dstDaimyoName; slot.transform.FindChild("AtkName").GetComponent <Text> ().text = srcDaimyoName; slot.transform.FindChild("EgnName").GetComponent <Text> ().text = engunDaimyoName; if (Application.systemLanguage != SystemLanguage.Japanese) { slot.transform.FindChild("Exp").GetComponent <Text>().text = "Request " + engunDaimyoName + " for reinforcement"; } else { slot.transform.FindChild("Exp").GetComponent <Text>().text = engunDaimyoName + "に援軍の出兵支持を出す。"; } //Param GameObject btn = slot.transform.FindChild("BoueiBtn").gameObject; btn.GetComponent <DoBouei> ().key = key; btn.GetComponent <DoBouei> ().engunDaimyoId = engunDaimyoId; btn.GetComponent <DoBouei> ().engunKuniId = engunKuniId; btn.GetComponent <DoBouei> ().engunDaimyoName = engunDaimyoName; btn.GetComponent <DoBouei> ().dfcDaimyoId = dstDaimyoId; btn.GetComponent <DoBouei> ().slot = slot; btn.GetComponent <DoBouei> ().kuniName = kuniName; } } } else { audioSources [4].Play(); Message msg = new Message(); msg.makeMessageOnBoard(msg.getMessage(99)); } } else { audioSources [4].Play(); //Hyourou NG Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } else if (name == "RelationshipBtn") { //Boueirei if (hyourou >= 5) { int bakuhuTobatsuDaimyoId = PlayerPrefs.GetInt("bakuhuTobatsuDaimyoId"); //Not Last Daimyo check string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); bool isLastDaimyoFlg = false; List <string> checkedDaimyoList = new List <string> (); foreach (string tmp in seiryokuList) { if (tmp != myDaimyo.ToString()) { if (!checkedDaimyoList.Contains(tmp)) { checkedDaimyoList.Add(tmp); } } } //include other 2 daimyos = 3 if (checkedDaimyoList.Count >= 2) { isLastDaimyoFlg = true; } if (isLastDaimyoFlg) { audioSources [0].Play(); //OK //Common //Back string returnPath = "Prefabs/Bakuhu/Return"; GameObject returnObj = Instantiate(Resources.Load(returnPath)) as GameObject; returnObj.transform.SetParent(board.transform); returnObj.transform.localScale = new Vector2(1, 1); returnObj.transform.localPosition = new Vector2(-560, 290); returnObj.name = "bakuhuReturn"; if (Application.systemLanguage != SystemLanguage.Japanese) { board.transform.FindChild("popText").GetComponent <Text> ().text = "Defence Order"; } else { board.transform.FindChild("popText").GetComponent <Text>().text = "防衛令"; } //Disabled scrollView.SetActive(false); //Base Obj string basePath = "Prefabs/Bakuhu/Base"; GameObject baseObj = Instantiate(Resources.Load(basePath)) as GameObject; baseObj.transform.SetParent(board.transform); baseObj.transform.localScale = new Vector2(1, 1); baseObj.name = "BakuhuBase"; returnObj.GetComponent <BakuhuMenuReturn> ().deleteObj = baseObj; returnObj.GetComponent <BakuhuMenuReturn> ().scrollView = scrollView; returnObj.GetComponent <BakuhuMenuReturn> ().board = board; if (Application.systemLanguage != SystemLanguage.Japanese) { board.transform.FindChild("popText").GetComponent <Text> ().text = "Mediation"; } else { board.transform.FindChild("popText").GetComponent <Text>().text = "仲裁"; } //Scroll string scrollPath = "Prefabs/Bakuhu/CyusaiScrollView"; GameObject uprScroll = Instantiate(Resources.Load(scrollPath)) as GameObject; uprScroll.transform.SetParent(baseObj.transform); uprScroll.transform.localPosition = new Vector2(0, 95); uprScroll.transform.localScale = new Vector2(1, 1); uprScroll.name = "CyusaiScrollViewUpper"; GameObject uprContent = uprScroll.transform.FindChild("Content").gameObject; GameObject btnScroll = Instantiate(Resources.Load(scrollPath)) as GameObject; btnScroll.transform.SetParent(baseObj.transform); btnScroll.transform.localPosition = new Vector2(0, -170); btnScroll.transform.localScale = new Vector2(1, 1); btnScroll.name = "CyusaiScrollViewBottom"; GameObject btnContent = btnScroll.transform.FindChild("Content").gameObject; //Upper Scroll string slotPath = "Prefabs/Bakuhu/CyusaiSlot"; Daimyo daimyo = new Daimyo(); foreach (string daimyoId in checkedDaimyoList) { GameObject uprSlot = Instantiate(Resources.Load(slotPath)) as GameObject; uprSlot.transform.SetParent(uprContent.transform); uprSlot.transform.localScale = new Vector2(1, 1); uprSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoId = daimyoId; uprSlot.GetComponent <CyusaiDaimyoSelect> ().checkedDaimyoList = checkedDaimyoList; uprSlot.GetComponent <CyusaiDaimyoSelect> ().uprContent = uprContent; uprSlot.GetComponent <CyusaiDaimyoSelect> ().btnContent = btnContent; int daimyoBusyoId = daimyo.getDaimyoBusyoId(int.Parse(daimyoId)); string daimyoName = daimyo.getName(int.Parse(daimyoId)); uprSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoName = daimyoName; string daimyoBusyoPath = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString(); uprSlot.transform.FindChild("Image").transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(daimyoBusyoPath, typeof(Sprite)) as Sprite; uprSlot.transform.FindChild("DaimyoName").GetComponent <Text> ().text = daimyoName; } string cyusaiTxtPath = "Prefabs/Bakuhu/CyusaiText"; GameObject cTxt = Instantiate(Resources.Load(cyusaiTxtPath)) as GameObject; cTxt.transform.SetParent(btnContent.transform); cTxt.transform.localScale = new Vector2(0.12f, 0.15f); cTxt.name = "CyusaiText"; } else { audioSources [4].Play(); Message msg = new Message(); msg.makeMessageOnBoard(msg.getMessage(100)); } } else { audioSources [4].Play(); //Hyourou NG Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } else if (name == "SobujiKessenBtn") { if (hyourou >= 30) { bool myKuniQtyIsTwiceFlg = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQtyIsTwiceFlg; if (myKuniQtyIsTwiceFlg) { audioSources [0].Play(); //Confirm Button //Back Cover string backPath = "Prefabs/Busyo/back"; GameObject back = Instantiate(Resources.Load(backPath)) as GameObject; back.transform.SetParent(GameObject.Find("Map").transform); back.transform.localScale = new Vector2(1, 1); RectTransform backTransform = back.GetComponent <RectTransform> (); backTransform.anchoredPosition3D = new Vector3(0, 0, 0); //Message Box GameObject soubujireiConfirmObj = Instantiate(soubujireiConfirm) as GameObject; soubujireiConfirmObj.transform.SetParent(GameObject.Find("Map").transform); soubujireiConfirmObj.transform.localScale = new Vector2(1, 1); RectTransform msgTransform = soubujireiConfirmObj.GetComponent <RectTransform> (); msgTransform.anchoredPosition3D = new Vector3(0, 0, 0); msgTransform.name = "SoubujireiConfirmObj"; GameObject YesBtn = soubujireiConfirmObj.transform.FindChild("YesButton").gameObject; GameObject NoBtn = soubujireiConfirmObj.transform.FindChild("NoButton").gameObject; YesBtn.GetComponent <DoSoubujirei> ().board = board; YesBtn.GetComponent <DoSoubujirei> ().confirm = soubujireiConfirmObj; YesBtn.GetComponent <DoSoubujirei> ().back = back; NoBtn.GetComponent <DoSoubujirei> ().confirm = soubujireiConfirmObj; NoBtn.GetComponent <DoSoubujirei> ().back = back; } else { audioSources [4].Play(); Message msg = new Message(); msg.makeMessageOnBoard(msg.getMessage(101)); } } else { audioSources [4].Play(); //Hyourou NG Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } else if (name == "KessenBtn") { if (hyourou >= hyourouNo) { audioSources [0].Play(); //Confirm Button //Back Cover string backPath = "Prefabs/Busyo/back"; GameObject back = Instantiate(Resources.Load(backPath)) as GameObject; back.transform.SetParent(GameObject.Find("Map").transform); back.transform.localScale = new Vector2(1, 1); RectTransform backTransform = back.GetComponent <RectTransform> (); backTransform.anchoredPosition3D = new Vector3(0, 0, 0); //Message Box string msgPath = "Prefabs/Bakuhu/KessenConfirm"; GameObject msg = Instantiate(Resources.Load(msgPath)) as GameObject; msg.transform.SetParent(GameObject.Find("Map").transform); msg.transform.localScale = new Vector2(1, 1); RectTransform msgTransform = msg.GetComponent <RectTransform> (); msgTransform.anchoredPosition3D = new Vector3(0, 0, 0); msgTransform.name = "KessenConfirm"; if (Application.systemLanguage != SystemLanguage.Japanese) { msg.transform.FindChild("Text").GetComponent <Text>().text = "Operate final war with " + daimyoName + "."; } else { msg.transform.FindChild("Text").GetComponent <Text>().text = daimyoName + "に決戦を仕掛けます"; } GameObject YesBtn = msg.transform.FindChild("YesButton").gameObject; GameObject NoBtn = msg.transform.FindChild("NoButton").gameObject; YesBtn.GetComponent <DoKessen> ().daimyoId = daimyoId; YesBtn.GetComponent <DoKessen> ().daimyoName = daimyoName; YesBtn.GetComponent <DoKessen> ().kuniId = kuniId; YesBtn.GetComponent <DoKessen> ().needHyourouNo = hyourouNo; NoBtn.GetComponent <DoKessen> ().confirm = msg; NoBtn.GetComponent <DoKessen> ().back = back; YesBtn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text> ().text = hyourouNo.ToString(); } else { audioSources [4].Play(); //Hyourou NG Message msg = new Message(); //msg.makeMessageOnBoard (msg.getMessage(7)); msg.hyourouMovieMessage(); } } }
public void OnClick() { Message msg = new Message(); Gaikou gaikou = new Gaikou(); DoGaikou yukouChange = new DoGaikou(); int nowHyourou = PlayerPrefs.GetInt("hyourou"); CloseBoard closeScript = GameObject.Find("close").GetComponent <CloseBoard> (); int daimyoBusyoAtk = closeScript.daimyoBusyoAtk; int daimyoBusyoDfc = closeScript.daimyoBusyoDfc; int daimyoId = closeScript.daimyoId; int kuniId = closeScript.kuniId; AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (nowHyourou >= 5) { //Track int TrackBouryakuNo = PlayerPrefs.GetInt("TrackBouryakuNo", 0); TrackBouryakuNo = TrackBouryakuNo + 1; PlayerPrefs.SetInt("TrackBouryakuNo", TrackBouryakuNo); if (name == "DoGihouBtn") { //Reduce Hyourou reduceHyourou(); //Reduce Shinobi //Ratio //Ge 5-15%, Cyu 15-30%, Jyo 30-50% int randomPercent = 0; int newQty = itemQty - 1; if (itemRank == "Ge") { randomPercent = UnityEngine.Random.Range(5, 15); PlayerPrefs.SetInt("shinobiGe", newQty); } else if (itemRank == "Cyu") { randomPercent = UnityEngine.Random.Range(15, 30); PlayerPrefs.SetInt("shinobiCyu", newQty); } else if (itemRank == "Jyo") { randomPercent = UnityEngine.Random.Range(30, 50); PlayerPrefs.SetInt("shinobiJyo", newQty); } float ratio = (float)randomPercent; float percent = Random.value; percent = percent * 100; if (percent <= ratio) { //OK audioSources [3].Play(); //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); //Delete Gunzei Destroy(Gunzei); //Delete Key string gunzeiKey = Gunzei.name; PlayerPrefs.DeleteKey(gunzeiKey); //Delete Key History char[] delimiterChars = { ',' }; string keyHistory = PlayerPrefs.GetString("keyHistory"); List <string> keyHistoryList = new List <string>(); if (keyHistory != null && keyHistory != "") { if (keyHistory.Contains(",")) { keyHistoryList = new List <string> (keyHistory.Split(delimiterChars)); } else { keyHistoryList.Add(keyHistory); } } keyHistoryList.Remove(gunzeiKey); string newKeyHistory = ""; for (int i = 0; i < keyHistoryList.Count; i++) { if (i == 0) { newKeyHistory = keyHistoryList[i]; } else { newKeyHistory = newKeyHistory + "," + keyHistoryList[i]; } } PlayerPrefs.SetString("keyHistory", newKeyHistory); //Message PlayerPrefs.SetBool("questDailyFlg33", true); //Extension Mark Handling MainStageController main = new MainStageController(); main.questExtension(); int TrackGihouHei = PlayerPrefs.GetInt("TrackGihouHei", 0); int hei = Gunzei.GetComponent <Gunzei> ().myHei; TrackGihouHei = TrackGihouHei + hei; PlayerPrefs.SetInt("TrackGihouHei", TrackGihouHei); string daimyoName = Gunzei.GetComponent <Gunzei>().srcDaimyoName; string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "My lord, misreport was successful. \n" + daimyoName + " army withdrawn."; } else { OKtext = "御屋形様、偽報に成功しましたぞ。\n" + daimyoName + "の軍勢が退却します。"; } msg.makeMessage(OKtext); } else { //NG audioSources [4].Play(); int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); //Message string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = "My lord, I'm sorry. failed misreport. \n Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = "申し訳御座りませぬ。偽報に失敗しましたぞ。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); yukouChange.downYukouOnIcon(daimyoId, newYukoudo); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } else if (name == "DoRyugenBtn") { //Reduce Hyourou reduceHyourou(); //Ratio //Ge 10-20%, Cyu 20-40%, Jyo 40-70% float randomPercent = 0; int newQty = itemQty - 1; if (itemRank == "Ge") { float tempRandomPercent = (200 - daimyoBusyoDfc) / 4; float tempValue = UnityEngine.Random.Range(0.5f, 1.5f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiGe", newQty); } else if (itemRank == "Cyu") { float tempRandomPercent = (200 - daimyoBusyoDfc) / 2; float tempValue = UnityEngine.Random.Range(0.8f, 1.2f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiCyu", newQty); } else if (itemRank == "Jyo") { float tempRandomPercent = (200 - daimyoBusyoDfc); float tempValue = UnityEngine.Random.Range(0.9f, 1.1f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiJyo", newQty); } float percent = Random.value; percent = percent * 100; if (percent <= randomPercent) { //Success audioSources [3].Play(); //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); int TrackRyugenNo = PlayerPrefs.GetInt("TrackRyugenNo", 0); TrackRyugenNo = TrackRyugenNo + 1; PlayerPrefs.SetInt("TrackRyugenNo", TrackRyugenNo); //Daimyo Id int srcDaimyoId = GameObject.Find("close").GetComponent <CloseBoard> ().daimyoId; //Seiryoku List string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); //src daimyo kuni list List <string> srcDaimyoKuniList = new List <string> (); for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyoId = seiryokuList[i]; if (tempDaimyoId == srcDaimyoId.ToString()) { int temp = i + 1; srcDaimyoKuniList.Add(temp.ToString()); } } //src daimyo open kuni list KuniInfo kuni = new KuniInfo(); List <int> openKuniList = new List <int>(); for (int j = 0; j < srcDaimyoKuniList.Count; j++) { openKuniList.AddRange(kuni.getMappingKuni(int.Parse(srcDaimyoKuniList[j]))); } //Target Daimyo (exculde this src daimyo & mydaimyo) int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); List <int> dstDaimyoList = new List <int>(); for (int k = 0; k < openKuniList.Count; k++) { int temp = openKuniList[k] - 1; int tempDaimyoId = int.Parse(seiryokuList[temp]); if (tempDaimyoId != myDaimyo && tempDaimyoId != srcDaimyoId) { if (!dstDaimyoList.Contains(tempDaimyoId)) { dstDaimyoList.Add(tempDaimyoId); } } } //Reduce Yukoudo MainEventHandler main = new MainEventHandler(); Daimyo daimyo = new Daimyo(); string ryugenText = ""; for (int l = 0; l < dstDaimyoList.Count; l++) { int dstDaimyoId = dstDaimyoList[l]; string dstDaimyoName = daimyo.getName(dstDaimyoId); int reduceYukoudo = main.DownYukouValueWithOther(srcDaimyoId, dstDaimyoId); reduceYukoudo = reduceYukoudo / 2; if (reduceYukoudo == 0) { reduceYukoudo = 1; } if (Application.systemLanguage != SystemLanguage.Japanese) { ryugenText = ryugenText + dstDaimyoName + " friendship decreased " + reduceYukoudo + " point \n"; } else { ryugenText = ryugenText + dstDaimyoName + "との友好度が" + reduceYukoudo + "下がりました。\n"; } } //Message PlayerPrefs.SetBool("questDailyFlg31", true); //Extension Mark Handling MainStageController mainStage = new MainStageController(); mainStage.questExtension(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "My lord, bad rumor was successful. \n" + ryugenText; } else { OKtext = "御屋形様、流言に成功しましたぞ。\n " + ryugenText; } msg.makeMessage(OKtext); } else { //Failed audioSources [4].Play(); //Message int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); //Message string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = "My lord, I'm sorry. failed misreport. \n Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = "申し訳御座りませぬ。流言に失敗しましたぞ。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } yukouChange.downYukouOnIcon(daimyoId, newYukoudo); msg.makeMessage(NGtext); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } else if (name == "DoGoudatsuBtn") { reduceHyourou(); //Ratio //Ge 10-20%, Cyu 20-40%, Jyo 40-70% float randomPercent = 0; int newQty = itemQty - 1; if (itemRank == "Ge") { float tempRandomPercent = (200 - daimyoBusyoDfc) / 4; float tempValue = UnityEngine.Random.Range(0.5f, 1.5f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiGe", newQty); } else if (itemRank == "Cyu") { float tempRandomPercent = (200 - daimyoBusyoDfc) / 2; float tempValue = UnityEngine.Random.Range(0.8f, 1.2f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiCyu", newQty); } else if (itemRank == "Jyo") { float tempRandomPercent = (200 - daimyoBusyoDfc); float tempValue = UnityEngine.Random.Range(0.9f, 1.1f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiJyo", newQty); } float percent = Random.value; percent = percent * 100; if (percent <= randomPercent) { audioSources [3].Play(); //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); //Success int kuniQty = GameObject.Find("close").GetComponent <CloseBoard>().kuniQty; int getMoney = 0; //Money or Item 0:money, 1:item int moneyOrItem = UnityEngine.Random.Range(0, 2); //Kahou or Shizai 0:kahou, 1:shizai int kahouOrShizai = UnityEngine.Random.Range(0, 2); string kahouName = ""; string shigenName = ""; int addQty = 0; int kahouRank = 0; //kahouRank S,A,B,C=1,2,3,4 //shigen Type int shigenType = 0; //KB,YR,TP,YM=1,2,3,4 if (moneyOrItem == 0) { //money int temGetMoney = UnityEngine.Random.Range(1000, 1501); getMoney = temGetMoney * kuniQty; int nowMoney = PlayerPrefs.GetInt("money"); nowMoney = nowMoney + getMoney; if (nowMoney < 0) { nowMoney = int.MaxValue; } PlayerPrefs.SetInt("money", nowMoney); PlayerPrefs.Flush(); } else { //item //Kahou or Shizai 0:kahou, 1:shizai kahouOrShizai = UnityEngine.Random.Range(0, 2); if (kahouOrShizai == 0) { //kahou Kahou kahou = new Kahou(); ////Bugu, Gusoku, Kabuto, Meiba, Heihousyo, Cyadougu, Chishikisyo(1,2,3,4,5,6) int kahouType = UnityEngine.Random.Range(1, 7); float khPercent = Random.value; khPercent = khPercent * 100; if (5 <= kuniQty) { //(S,A,B 5,35,60%) if (khPercent <= 5) { //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (5 < khPercent && khPercent <= 41) { //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (41 < khPercent) { //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } else if (3 <= kuniQty && kuniQty < 5) { //(S,A,B,C : 1,15,25,59%) if (khPercent <= 1) { //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (1 < khPercent && khPercent <= 16) { //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (16 < khPercent && khPercent <= 41) { //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (41 < khPercent) { //C kahouRank = 4; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } else if (kuniQty < 3) { //(A,B,C : 5, 35, 60%) if (khPercent <= 5) { //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (5 < khPercent && khPercent <= 41) { //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (41 < khPercent) { //C kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } } else { //shizai shigenType = UnityEngine.Random.Range(1, 5); float sgPercent = Random.value; sgPercent = sgPercent * 100; addQty = UnityEngine.Random.Range(1, 6); Item item = new Item(); int shigenRank = 0; //下、中、上=1,2,3 if (5 <= kuniQty) { //(上,中,下 40,40, 20%) if (sgPercent <= 40) { shigenRank = 3; } else if (40 < sgPercent && sgPercent <= 81) { shigenRank = 2; } else if (81 < sgPercent) { shigenRank = 1; } shigenName = item.getRandomShigen(shigenType, shigenRank, addQty); } else if (3 <= kuniQty && kuniQty < 5) { //(上,中,下 20,50,30%) if (sgPercent <= 20) { shigenRank = 3; } else if (20 < sgPercent && sgPercent <= 51) { shigenRank = 2; } else if (51 < sgPercent) { shigenRank = 1; } shigenName = item.getRandomShigen(shigenType, shigenRank, addQty); } else if (kuniQty < 3) { //(上,中,下 5,25,70%) if (sgPercent <= 5) { shigenRank = 3; } else if (5 < sgPercent && sgPercent <= 26) { shigenRank = 2; } else if (26 < sgPercent) { shigenRank = 1; } shigenName = item.getRandomShigen(shigenType, shigenRank, addQty); } } } //Message PlayerPrefs.SetBool("questDailyFlg32", true); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "My lord, successed to rob.\n"; } else { OKtext = "御屋形様、強奪に成功しましたぞ。\n"; } string addText = ""; if (moneyOrItem == 0) { if (Application.systemLanguage != SystemLanguage.Japanese) { addText = "got " + getMoney + " money."; } else { addText = "金を" + getMoney + "奪って参りました。"; } } else { if (kahouOrShizai == 0) { //kahou if (Application.systemLanguage != SystemLanguage.Japanese) { addText = " got treasure " + kahouName + "."; } else { addText = "家宝、" + kahouName + "を奪って参りました。"; } } else { //shizai+ if (Application.systemLanguage != SystemLanguage.Japanese) { addText = " got " + addQty + " " + shigenName + "."; } else { addText = shigenName + "を" + addQty + "個奪って参りました。"; } } } OKtext = OKtext + addText; msg.makeMessage(OKtext); } else { //Failed audioSources [4].Play(); int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); //Message string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = "My lord, I'm sorry. failed to rob. \n Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = "申し訳御座りませぬ。強奪に失敗しましたぞ。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); yukouChange.downYukouOnIcon(daimyoId, newYukoudo); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } else if (name == "DoCyouhouBtn") { reduceHyourou(); //Set Value & REduce Qty float missPercent = 0; int newQty = itemQty - 1; int snbValue = 0; if (itemRank == "Ge") { missPercent = 30; PlayerPrefs.SetInt("shinobiGe", newQty); snbValue = 1; } else if (itemRank == "Cyu") { missPercent = 15; PlayerPrefs.SetInt("shinobiCyu", newQty); snbValue = 2; } else if (itemRank == "Jyo") { missPercent = 5; PlayerPrefs.SetInt("shinobiJyo", newQty); snbValue = 3; } //Random Check float percent = Random.value; percent = percent * 100; if (percent >= missPercent) { //Success audioSources [3].Play(); //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); int TrackCyouhouNo = PlayerPrefs.GetInt("TrackCyouhouNo", 0); TrackCyouhouNo = TrackCyouhouNo + 1; PlayerPrefs.SetInt("TrackCyouhouNo", TrackCyouhouNo); string cyouhouHist = PlayerPrefs.GetString("cyouhou"); char[] delimiterChars = { ',' }; List <string> cyouhouHistList = new List <string> (); if (cyouhouHist != null && cyouhouHist != "") { if (cyouhouHist.Contains(",")) { cyouhouHistList = new List <string> (cyouhouHist.Split(delimiterChars)); } else { cyouhouHistList.Add(cyouhouHist); } } //Add new kuni if (!cyouhouHistList.Contains(kuniId.ToString())) { cyouhouHistList.Add(kuniId.ToString()); } string newCyouhouHist = ""; for (int i = 0; i < cyouhouHistList.Count; i++) { string tmpCyouhouKuniId = cyouhouHistList [i]; if (i == 0) { newCyouhouHist = tmpCyouhouKuniId; } else { newCyouhouHist = newCyouhouHist + "," + tmpCyouhouKuniId; } } PlayerPrefs.SetString("cyouhou", newCyouhouHist); string cyouhouKuni = "cyouhou" + kuniId.ToString(); PlayerPrefs.SetInt(cyouhouKuni, snbValue); bool cyouhouFlg = closeScript.cyouhouFlg; if (cyouhouFlg) { //Change Icon GameObject shinobi = GameObject.Find("shinobi").gameObject; if (snbValue == 1) { Color lowColor = new Color(0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f); shinobi.GetComponent <Image> ().color = lowColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "下"; } else if (snbValue == 2) { Color midColor = new Color(94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent <Image> ().color = midColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "中"; } else if (snbValue == 3) { Color highColor = new Color(84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent <Image> ().color = highColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "上"; } } else { GameObject smallBoardObj = GameObject.Find("smallBoard(Clone)").gameObject; //new Icon string shinobiItemPath = "Prefabs/Item/Shinobi/Shinobi"; GameObject shinobi = Instantiate(Resources.Load(shinobiItemPath)) as GameObject; shinobi.transform.SetParent(smallBoardObj.transform); shinobi.transform.localScale = new Vector2(0.25f, 0.31f); shinobi.name = "shinobi"; RectTransform snbTransform = shinobi.GetComponent <RectTransform> (); snbTransform.anchoredPosition = new Vector3(-251, 250, 0); shinobi.GetComponent <Button> ().enabled = false; if (snbValue == 1) { Color lowColor = new Color(0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f); shinobi.GetComponent <Image>().color = lowColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "下"; } else if (snbValue == 2) { Color midColor = new Color(94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent <Image>().color = midColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "中"; } else if (snbValue == 3) { Color highColor = new Color(84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent <Image>().color = highColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "上"; } //Set Flg closeScript.cyouhouFlg = true; closeScript.cyouhouSnbRankId = snbValue; } GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject; kuniIconView.transform.FindChild(kuniId.ToString()).GetComponent <SendParam> ().cyouhouSnbRankId = snbValue; KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); PlayerPrefs.SetBool("questDailyFlg30", true); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Ninja hided in " + kuniName + " well. \n Please check spy report."; } else { OKtext = "忍が上手く" + kuniName + "に潜伏しましたぞ。\n諜報内容をご確認下され。"; } msg.makeMessage(OKtext); } else { //Fail audioSources [4].Play(); int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = "Ninja was caught. \n Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = "忍が捕まってしまったようです。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); yukouChange.downYukouOnIcon(daimyoId, newYukoudo); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } } else { audioSources [4].Play(); msg.hyourouMovieMessage(); //msg.makeMessage (msg.getMessage(7)); } }
public void createSyoguView(string busyoId) { int lv = PlayerPrefs.GetInt(busyoId); Color ngImageColor = new Color(40f / 255f, 40f / 255f, 40f / 255f, 180f / 255f); Color ngTextColor = new Color(90f / 255f, 90f / 255f, 90f / 255f, 90f / 255f); Color okImageColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 150f / 255f); Color okTextColor = new Color(40f / 255f, 40f / 255f, 0f / 255f, 255f / 255f); GameObject kanjyo = GameObject.Find("kanjyo").gameObject; GameObject tsuihou = GameObject.Find("tsuihou").gameObject; int daimyoBusyoId = PlayerPrefs.GetInt("myDaimyoBusyo"); if (busyoId == daimyoBusyoId.ToString()) { kanjyo.GetComponent <Image> ().color = ngImageColor; kanjyo.transform.FindChild("Text").GetComponent <Text> ().color = ngTextColor; kanjyo.GetComponent <Button> ().enabled = false; tsuihou.GetComponent <Image> ().color = ngImageColor; tsuihou.transform.FindChild("Text").GetComponent <Text> ().color = ngTextColor; tsuihou.GetComponent <Button> ().enabled = false; } else { string addLvTmp = "addlv" + busyoId.ToString(); int maxLv = 100 + PlayerPrefs.GetInt(addLvTmp); if (lv != maxLv) { kanjyo.GetComponent <BusyoStatusButton> ().pa_lv = lv; kanjyo.GetComponent <Image> ().color = okImageColor; kanjyo.transform.FindChild("Text").GetComponent <Text> ().color = okTextColor; kanjyo.GetComponent <Button> ().enabled = true; } else { kanjyo.GetComponent <Image> ().color = ngImageColor; kanjyo.transform.FindChild("Text").GetComponent <Text> ().color = ngTextColor; kanjyo.GetComponent <Button> ().enabled = false; } tsuihou.GetComponent <Image> ().color = okImageColor; tsuihou.transform.FindChild("Text").GetComponent <Text> ().color = okTextColor; tsuihou.GetComponent <Button> ().enabled = true; } GameObject kanni = GameObject.Find("kanni").gameObject; GameObject jyosyu = GameObject.Find("jyosyu").gameObject; GameObject syugyo = GameObject.Find("syugyo").gameObject; GameObject gokui = GameObject.Find("gokui").gameObject; kanni.GetComponent <RonkouKousyoMenu>().busyoId = busyoId; jyosyu.GetComponent <RonkouKousyoMenu>().busyoId = busyoId; syugyo.GetComponent <RonkouKousyoMenu>().busyoId = busyoId; gokui.GetComponent <RonkouKousyoMenu>().busyoId = busyoId; //Kanni string kanniTmp = "kanni" + busyoId; Kanni kanniScript = new Kanni(); if (PlayerPrefs.HasKey(kanniTmp)) { int kanniId = PlayerPrefs.GetInt(kanniTmp); if (kanniId != 0) { foreach (Transform n in kanni.transform) { if (n.name == "KanniName") { Destroy(n.gameObject); } } kanni.GetComponent <RonkouKousyoMenu> ().kanniId = kanniId; string path = "Prefabs/Busyo/KanniName"; GameObject kanniName = Instantiate(Resources.Load(path)) as GameObject; kanniName.transform.SetParent(kanni.transform); kanniName.transform.localScale = new Vector2(0.12f, 0.12f); kanniName.transform.localPosition = new Vector2(0, 0); kanniName.name = "KanniName"; string kanniNameString = kanniScript.getKanni(kanniId); string kanniIkai = kanniScript.getIkai(kanniId); kanniName.transform.FindChild("value").GetComponent <Text>().text = kanniIkai + "\n" + kanniNameString; string effectLabel = kanniScript.getEffectLabel(kanniId); int effect = kanniScript.getEffect(kanniId); kanniName.transform.FindChild("effectLabel").GetComponent <Text>().text = effectLabel; kanniName.transform.FindChild("effectValue").GetComponent <Text>().text = "+" + effect.ToString() + "%"; kanni.transform.FindChild("Text").GetComponent <Text> ().enabled = false; } else { foreach (Transform n in kanni.transform) { if (n.name == "KanniName") { Destroy(n.gameObject); } } kanni.GetComponent <RonkouKousyoMenu>().kanniId = 0; kanni.transform.FindChild("Text").GetComponent <Text>().enabled = true; } } else { foreach (Transform n in kanni.transform) { if (n.name == "KanniName") { Destroy(n.gameObject); } } kanni.GetComponent <RonkouKousyoMenu> ().kanniId = 0; kanni.transform.FindChild("Text").GetComponent <Text> ().enabled = true; } //Jyosyu string jyosyuTmp = "jyosyuBusyo" + busyoId; if (PlayerPrefs.HasKey(jyosyuTmp)) { BusyoInfoGet busyoInfo = new BusyoInfoGet(); string busyoName = busyoInfo.getName(int.Parse(busyoId)); jyosyu.GetComponent <RonkouKousyoMenu>().jyosyuName = busyoName; int kuniId = PlayerPrefs.GetInt(jyosyuTmp); if (kuniId != 0) { foreach (Transform n in jyosyu.transform) { if (n.name == "JyosyuName") { Destroy(n.gameObject); } } KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); string jyosyuHeiTmp = "jyosyuHei" + busyoId; int jyosyuHei = PlayerPrefs.GetInt(jyosyuHeiTmp); jyosyu.GetComponent <RonkouKousyoMenu>().jyosyuKuniId = kuniId; string jyosyuPath = "Prefabs/Busyo/JyosyuName"; GameObject jyosyuName = Instantiate(Resources.Load(jyosyuPath)) as GameObject; jyosyuName.transform.SetParent(jyosyu.transform); jyosyuName.transform.localScale = new Vector2(0.12f, 0.12f); jyosyuName.transform.localPosition = new Vector2(0, 0); jyosyuName.name = "JyosyuName"; jyosyuName.transform.FindChild("value").GetComponent <Text>().text = kuniName; jyosyuName.transform.FindChild("effectValue").GetComponent <Text>().text = "+" + jyosyuHei.ToString(); jyosyu.transform.FindChild("Text").GetComponent <Text> ().enabled = false; } } else { foreach (Transform n in jyosyu.transform) { if (n.name == "JyosyuName") { Destroy(n.gameObject); } } jyosyu.GetComponent <RonkouKousyoMenu> ().jyosyuKuniId = 0; jyosyu.transform.FindChild("Text").GetComponent <Text> ().enabled = true; } }
public void dataMake(bool busyoExitFlg, int newDaimyo, int newDaimyoBusyo, string heisyu){ /*******************************/ /***** Base Value *****/ /*******************************/ System.DateTime now = System.DateTime.Now; PlayerPrefs.SetString ("lasttime", now.ToString ()); PlayerPrefs.SetInt ("hyourou",100); PlayerPrefs.SetString ("yearSeason","1560,1"); PlayerPrefs.DeleteKey("gameClearFlg"); PlayerPrefs.DeleteKey("gameClearItemGetFlg"); PlayerPrefs.DeleteKey("gameOverFlg"); PlayerPrefs.DeleteKey("kuniClearedFlg"); /*******************************/ /***** Delete Temp Value *****/ /*******************************/ PlayerPrefs.DeleteKey("playerEngunList"); PlayerPrefs.DeleteKey("enemyEngunList"); PlayerPrefs.DeleteKey("playerKyoutouList"); PlayerPrefs.DeleteKey("tempKyoutouList"); PlayerPrefs.DeleteKey("keyHistory"); PlayerPrefs.DeleteKey("metsubou"); for(int i=1; i<65; i++){ string kuniTemp = "kuni" + i.ToString(); PlayerPrefs.DeleteKey(kuniTemp); string jyosyuTemp = "jyosyu" + i.ToString(); PlayerPrefs.DeleteKey(jyosyuTemp); string naiseiLoginDateTemp = "naiseiLoginDate" + i.ToString(); PlayerPrefs.DeleteKey(naiseiLoginDateTemp); string naiseiTabibitoCounterTemp = "naiseiTabibitoCounter" + i.ToString(); PlayerPrefs.DeleteKey(naiseiTabibitoCounterTemp); } PlayerPrefs.DeleteKey("lastSeasonChangeTime"); PlayerPrefs.DeleteKey("doneCyosyuFlg"); /*******************************/ /***** Busyo Value *****/ /*******************************/ if (!busyoExitFlg) { //Player dosn't have this daimyo busyo int myBusyoQty = PlayerPrefs.GetInt ("myBusyoQty"); myBusyoQty = myBusyoQty + 1; PlayerPrefs.SetInt ("myBusyoQty",myBusyoQty); string myBusyo = PlayerPrefs.GetString ("myBusyo"); myBusyo = myBusyo + "," + newDaimyoBusyo.ToString(); PlayerPrefs.SetString ("myBusyo",myBusyo); PlayerPrefs.SetInt (newDaimyoBusyo.ToString(),1); string tempHei = "hei" + newDaimyoBusyo.ToString(); string tempSenpou = "senpou" + newDaimyoBusyo.ToString(); string tempSaku = "saku" + newDaimyoBusyo.ToString(); string tempKahou = "kahou" + newDaimyoBusyo.ToString(); string tempExp = "exp" + newDaimyoBusyo.ToString(); string valueHei = heisyu + ":1:1:1"; PlayerPrefs.SetString (tempHei,valueHei); PlayerPrefs.SetInt (tempSenpou,1); PlayerPrefs.SetInt (tempSaku,1); PlayerPrefs.SetString (tempKahou,"0,0,0,0,0,0,0,0"); PlayerPrefs.SetInt (tempExp,0); } //My Daimyo Busyo PlayerPrefs.SetInt("myDaimyo",newDaimyo); PlayerPrefs.SetInt("myDaimyoBusyo",newDaimyoBusyo); /*******************************/ /***** Kuni Value *****/ /*******************************/ string newSeiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46"; PlayerPrefs.SetString ("seiryoku",newSeiryoku); List<string> seiryokuList = new List<string> (); char[] delimiterChars = {','}; seiryokuList = new List<string> (newSeiryoku.Split (delimiterChars)); string newClearedKuni = ""; for (int i=0; i<seiryokuList.Count; i++) { string tempDaimyoId = seiryokuList[i]; if(tempDaimyoId == newDaimyo.ToString()){ int kuniId = i + 1; if(newClearedKuni==null || newClearedKuni == ""){ newClearedKuni = kuniId.ToString(); }else{ newClearedKuni = newClearedKuni + "," + kuniId.ToString(); } } } PlayerPrefs.SetString ("clearedKuni",newClearedKuni); List<string> clearedKuniList = new List<string> (); clearedKuniList = new List<string> (newClearedKuni.Split (delimiterChars)); //New Open Kuni KuniInfo kuni = new KuniInfo (); PlayerPrefs.DeleteKey("openKuni"); PlayerPrefs.Flush (); foreach(string kuniId in clearedKuniList){ kuni.registerOpenKuni (int.Parse(kuniId)); string temp = "kuni" + kuniId; PlayerPrefs.SetString (temp,"1,2,3,4,5,6,7,8,9,10"); string tempNaisei = "naisei" + kuniId; if(!PlayerPrefs.HasKey(tempNaisei)){ PlayerPrefs.SetString(tempNaisei,"1,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0"); } PlayerPrefs.Flush (); } //Add Cleared Kuni to OpenKuni string tempOpenKuni = PlayerPrefs.GetString ("openKuni"); tempOpenKuni = tempOpenKuni + "," + newClearedKuni; PlayerPrefs.SetString ("openKuni",tempOpenKuni); PlayerPrefs.Flush (); /*******************************/ /***** Gaikou Value *****/ /*******************************/ //My Gaikou Gaikou gaikou = new Gaikou (); for(int l=1; l<47; l++){ int value = gaikou.getGaikouValue(newDaimyo,l); string temp = "gaikou" + l.ToString(); PlayerPrefs.SetInt (temp, value); string metsubouTemp = "metsubou" + l.ToString(); PlayerPrefs.DeleteKey (metsubouTemp); } //Other Daimyo Gaikou for(int x =2; x<47; x++ ){ for(int y=2; y<47; y++){ if(x != y){ string temp = x.ToString() + "gaikou" + y.ToString(); string temp2 = x.ToString() + "key" + y.ToString(); PlayerPrefs.DeleteKey(temp); PlayerPrefs.DeleteKey(temp2); } } } /*******************************/ /***** Doumei *****/ /*******************************/ PlayerPrefs.DeleteKey("doumei"); string newMyDoumei = ""; Entity_doumei_mst doumeiMst = Resources.Load ("Data/doumei_mst") as Entity_doumei_mst; for(int i=0; i < doumeiMst.param.Count; i++){ int srcDaimyoId = doumeiMst.param[i].doumeiSrc; int dstDaimyoId = doumeiMst.param[i].doumeiDst; if(srcDaimyoId == newDaimyo){ if(newMyDoumei != null && newMyDoumei !=""){ newMyDoumei = newMyDoumei + "," + dstDaimyoId; }else{ newMyDoumei = dstDaimyoId.ToString(); } }else{ string temp = "doumei" + srcDaimyoId; string previous = PlayerPrefs.GetString(temp); if(previous != null && previous !=""){ previous = previous + "," + dstDaimyoId; PlayerPrefs.SetString (temp,previous); }else{ PlayerPrefs.SetString (temp,dstDaimyoId.ToString()); } } } PlayerPrefs.SetString ("doumei",newMyDoumei); PlayerPrefs.Flush (); Application.LoadLevel ("mainStage"); }
// Use this for initialization public void OnClick () { CloseBoard close = GameObject.Find ("close").GetComponent<CloseBoard> (); close.layer = close.layer + 1; int nowHyourou = PlayerPrefs.GetInt ("hyourou"); bool hyourouOKflg = false; int daimyoId = GameObject.Find ("close").GetComponent<CloseBoard>().daimyoId; if (name == "Cyouhou") { } else if (name == "Ryugen") { } else if (name == "Goudatsu") { } else if (name == "Gihou") { //Gunzei Check bool gunzeiFlg = false; foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")){ int checkDaimyoId = obs.GetComponent<Gunzei>().srcDaimyoId; if(checkDaimyoId == daimyoId){ gunzeiFlg = true; targetGunzei = obs; break; } } if(gunzeiFlg){ //Menu Handling GameObject.Find ("kuniName").GetComponent<Text> ().text = "偽報"; OffBouryakuMenu (); string path = "Prefabs/Map/bouryaku/GihouObj"; GameObject obj = Instantiate (Resources.Load (path)) as GameObject; obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3 (1, 1, 1); //Label int dstKuni = targetGunzei.GetComponent<Gunzei>().dstKuni; int hei = targetGunzei.GetComponent<Gunzei>().myHei; KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(dstKuni); obj.transform.FindChild("GunzeiInfo").transform.FindChild("DaimyoNameValue").GetComponent<Text>().text = kuniName + "に進軍中"; obj.transform.FindChild("Heiryoku").transform.FindChild("HeiryokuValue").GetComponent<Text>().text = hei.ToString(); //Shinobi Slot int shinobiGe = PlayerPrefs.GetInt ("shinobiGe"); int shinobiCyu = PlayerPrefs.GetInt ("shinobiCyu"); int shinobiJyo = PlayerPrefs.GetInt ("shinobiJyo"); int total = shinobiGe + shinobiCyu + shinobiJyo; GameObject btn = obj.transform.FindChild("DoGihouBtn").gameObject; if(total ==0){ //Error Message btn.GetComponent<Button>().enabled = false; }else{ string slotPath = "Prefabs/Map/common/ShinobiSlot"; string shinobiItemPath = "Prefabs/Item/Shinobi/Shinobi"; GameObject content = obj.transform.FindChild("ScrollView").transform.FindChild("Content").gameObject; if(shinobiGe!=0){ GameObject slot = Instantiate (Resources.Load (slotPath)) as GameObject; slot.transform.SetParent (content.transform); slot.transform.localScale = new Vector3 (1, 1, 1); slot.name = "Ge"; GameObject shinobi = Instantiate (Resources.Load (shinobiItemPath)) as GameObject; shinobi.transform.SetParent (slot.transform); shinobi.transform.localScale = new Vector3 (1, 1, 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 = "下"; shinobi.transform.FindChild("Qty").GetComponent<Text>().text = shinobiGe.ToString(); RectTransform shinobiTransform = shinobi.transform.FindChild("Shinobi").GetComponent<RectTransform> (); shinobiTransform.sizeDelta = new Vector2( 155, 190); RectTransform qtyTransform = shinobi.transform.FindChild("Qty").GetComponent<RectTransform> (); qtyTransform.anchoredPosition = new Vector3 (-50, -65, 0); slot.GetComponent<GaikouShinobiSelect>().Gunzei = targetGunzei; slot.GetComponent<GaikouShinobiSelect>().Content = content; slot.GetComponent<GaikouShinobiSelect>().DoBtn = btn; slot.GetComponent<GaikouShinobiSelect>().qty = shinobiGe; } if(shinobiCyu!=0){ GameObject slot = Instantiate (Resources.Load (slotPath)) as GameObject; slot.transform.SetParent (content.transform); slot.transform.localScale = new Vector3 (1, 1, 1); slot.name = "Cyu"; GameObject shinobi = Instantiate (Resources.Load (shinobiItemPath)) as GameObject; shinobi.transform.SetParent (slot.transform); shinobi.transform.localScale = new Vector3 (1, 1, 1); Color midColor = new Color (94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent<Image>().color = midColor; shinobi.transform.FindChild("ShinobiRank").GetComponent<Text>().text = "中"; shinobi.transform.FindChild("Qty").GetComponent<Text>().text = shinobiCyu.ToString(); RectTransform shinobiTransform = shinobi.transform.FindChild("Shinobi").GetComponent<RectTransform> (); shinobiTransform.sizeDelta = new Vector2( 155, 190); RectTransform qtyTransform = shinobi.transform.FindChild("Qty").GetComponent<RectTransform> (); qtyTransform.anchoredPosition = new Vector3 (-50, -65, 0); slot.GetComponent<GaikouShinobiSelect>().Gunzei = targetGunzei; slot.GetComponent<GaikouShinobiSelect>().Content = content; slot.GetComponent<GaikouShinobiSelect>().DoBtn = btn; slot.GetComponent<GaikouShinobiSelect>().qty = shinobiCyu; } if(shinobiJyo!=0){ GameObject slot = Instantiate (Resources.Load (slotPath)) as GameObject; slot.transform.SetParent (content.transform); slot.transform.localScale = new Vector3 (1, 1, 1); slot.name = "Jyo"; GameObject shinobi = Instantiate (Resources.Load (shinobiItemPath)) as GameObject; shinobi.transform.SetParent (slot.transform); shinobi.transform.localScale = new Vector3 (1, 1, 1); Color highColor = new Color (84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent<Image>().color = highColor; shinobi.transform.FindChild("ShinobiRank").GetComponent<Text>().text = "上"; shinobi.transform.FindChild("Qty").GetComponent<Text>().text = shinobiJyo.ToString(); RectTransform shinobiTransform = shinobi.transform.FindChild("Shinobi").GetComponent<RectTransform> (); shinobiTransform.sizeDelta = new Vector2( 155, 190); RectTransform qtyTransform = shinobi.transform.FindChild("Qty").GetComponent<RectTransform> (); qtyTransform.anchoredPosition = new Vector3 (-50, -65, 0); slot.GetComponent<GaikouShinobiSelect>().Gunzei = targetGunzei; slot.GetComponent<GaikouShinobiSelect>().Content = content; slot.GetComponent<GaikouShinobiSelect>().DoBtn = btn; slot.GetComponent<GaikouShinobiSelect>().qty = shinobiJyo; } } GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj; }else{ Message msg = new Message(); string NGtext = "進軍中の軍勢がおりませぬぞ。"; msg.makeMessage (NGtext); } } }
public void viewKuniLink(GameObject board, GameObject kuniMap, List <string> seiryokuList) { KuniInfo kuniScript = new KuniInfo(); List <int> linkKuniList = kuniScript.getMappingKuni(kuniId); List <int> linkAllKuniList = new List <int>(); for (int i = 0; i < linkKuniList.Count; i++) { int linkKuniId = linkKuniList[i]; linkAllKuniList.Add(linkKuniId); } //view kuni arrow link Daimyo daimyoScript = new Daimyo(); for (int i = 0; i < linkAllKuniList.Count; i++) { int srcKuniId = linkAllKuniList[i]; List <int> XYList = kuniScript.getLinkStageXY(srcKuniId, kuniId); string pathOfSrcKuni = "Prefabs/Map/Stage/ArrowKuniName"; GameObject srcKuniNameObj = Instantiate(Resources.Load(pathOfSrcKuni)) as GameObject; srcKuniNameObj.name = "Arrow" + srcKuniId; srcKuniNameObj.transform.SetParent(board.transform.FindChild("board").transform); srcKuniNameObj.transform.localScale = new Vector2(0.1f, 0.15f); srcKuniNameObj.transform.localPosition = new Vector2(XYList[0], XYList[1]); srcKuniNameObj.GetComponent <Text>().text = kuniScript.getKuniName(srcKuniId); string linkStage = kuniScript.getLinkStage(srcKuniId, kuniId); linkStage = linkStage.Replace("stage", ""); List <int> linkStageList = new List <int>(Array.ConvertAll(linkStage.Split(','), new Converter <string, int>((s) => { return(Convert.ToInt32(s)); }))); string arrowDaimyoPath = "Prefabs/Map/Stage/ArrowDaimyo"; GameObject arrowDaimyo = Instantiate(Resources.Load(arrowDaimyoPath)) as GameObject; arrowDaimyo.transform.SetParent(srcKuniNameObj.transform); arrowDaimyo.transform.localScale = new Vector2(8, 7); arrowDaimyo.transform.localPosition = new Vector2(0, 0); arrowDaimyo.transform.FindChild("Effect").GetComponent <DamagePop>().divSpeed = 5; arrowDaimyo.transform.FindChild("Effect").GetComponent <DamagePop>().attackBoardflg = true; int arrowDaimyoId = int.Parse(seiryokuList[srcKuniId - 1]); string daimyoName = daimyoScript.getName(arrowDaimyoId); arrowDaimyo.transform.FindChild("Effect").GetComponent <Text>().text = daimyoName; arrowDaimyo.transform.FindChild("Effect").transform.localScale = new Vector2(0.12f, 0.12f); string kamonPath = "Prefabs/Kamon/MyDaimyoKamon/" + arrowDaimyoId.ToString(); arrowDaimyo.GetComponent <Image>().sprite = Resources.Load(kamonPath, typeof(Sprite)) as Sprite; //Arrow string arrowPath = "Prefabs/PostKassen/Arrow"; for (int j = 0; j < linkStageList.Count; j++) { GameObject arrow = Instantiate(Resources.Load(arrowPath)) as GameObject; arrow.transform.SetParent(srcKuniNameObj.transform); arrow.transform.localScale = new Vector2(200, 200); arrow.transform.localPosition = new Vector2(0, 0); string stageId = "stage" + linkStageList[j]; GameObject tgtStageObj = kuniMap.transform.FindChild(stageId).gameObject; Vector3 posDif = tgtStageObj.transform.position - arrow.transform.position; float angle = Mathf.Atan2(posDif.y, posDif.x) * Mathf.Rad2Deg; Vector3 euler = new Vector3(0, 0, angle); arrow.transform.rotation = Quaternion.Euler(euler); } } }
//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>(); if (name == "YesButton") { audioSources[0].Play(); RecoveryDataStore RecoveryDataStore = GameObject.Find("RecoveryDataStore").GetComponent <RecoveryDataStore>(); //Common PlayerPrefs.SetBool("tutorialDoneFlg", true); PlayerPrefs.SetInt("kuniLv", RecoveryDataStore.kuniLv); Exp expScript = new Exp(); int jinkeiLimit = expScript.getJinkeiLimit(RecoveryDataStore.kuniLv); int stockLimit = expScript.getStockLimit(RecoveryDataStore.kuniLv); PlayerPrefs.SetInt("jinkeiLimit", jinkeiLimit); PlayerPrefs.SetInt("stockLimit", stockLimit); PlayerPrefs.SetString("userId", RecoveryDataStore.inputUserId); if (RecoveryDataStore.addJinkei1) { PlayerPrefs.SetBool("addJinkei1", true); } else { PlayerPrefs.SetBool("addJinkei1", false); } if (RecoveryDataStore.addJinkei2) { PlayerPrefs.SetBool("addJinkei2", true); } else { PlayerPrefs.SetBool("addJinkei2", false); } if (RecoveryDataStore.addJinkei3) { PlayerPrefs.SetBool("addJinkei3", true); } else { PlayerPrefs.SetBool("addJinkei3", false); } if (RecoveryDataStore.addJinkei4) { PlayerPrefs.SetBool("addJinkei4", true); } else { PlayerPrefs.SetBool("addJinkei4", false); } if (RecoveryDataStore.dataStore_userId == 0) { /***dataStore***/ PlayerPrefs.SetInt("kuniExp", RecoveryDataStore.kuniExp); PlayerPrefs.SetString("yearSeason", RecoveryDataStore.yearSeason); PlayerPrefs.SetInt("movieCount", RecoveryDataStore.movieCount); string seiryoku = RecoveryDataStore.seiryoku; if (seiryoku == "") { seiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46"; } PlayerPrefs.SetString("seiryoku", seiryoku); KuniInfo kuniScript = new KuniInfo(); kuniScript.updateOpenKuni(RecoveryDataStore.myDaimyo, seiryoku); kuniScript.updateClearedKuni(RecoveryDataStore.myDaimyo, seiryoku); PlayerPrefs.SetInt("money", RecoveryDataStore.money); PlayerPrefs.SetInt("busyoDama", RecoveryDataStore.busyoDama); PlayerPrefs.SetInt("syogunDaimyoId", RecoveryDataStore.syogunDaimyoId); PlayerPrefs.SetString("doumei", RecoveryDataStore.doumei); for (int i = 0; i < RecoveryDataStore.questSpecialFlgId.Count; i++) { int questId = RecoveryDataStore.questSpecialFlgId[i]; string tmp = "questSpecialFlg" + questId.ToString(); string tmp2 = "questSpecialReceivedFlg" + questId.ToString(); PlayerPrefs.SetBool(tmp, true); bool questReceivedFlg = RecoveryDataStore.questSpecialReceivedFlgId[i]; if (questReceivedFlg) { PlayerPrefs.SetBool(tmp2, true); } else { PlayerPrefs.SetBool(tmp2, false); } } Entity_quest_count_mst questCountMst = Resources.Load("Data/quest_count_mst") as Entity_quest_count_mst; for (int i = 0; i < questCountMst.param.Count; i++) { bool dailyFlg = questCountMst.param[i].daily; if (!dailyFlg) { countSpecialList.Add(i); } } if (RecoveryDataStore.questSpecialCountReceivedFlg.Count != 0) { for (int i = 0; i < countSpecialList.Count; i++) { int id = countSpecialList[i]; string tmp = "questSpecialCountReceivedFlg" + id.ToString(); bool questReceivedFlg = RecoveryDataStore.questSpecialCountReceivedFlg[i]; if (questReceivedFlg) { PlayerPrefs.SetBool(tmp, true); } else { PlayerPrefs.SetBool(tmp, false); } } } int count = 0; string myBusyo = ""; for (int i = 0; i < RecoveryDataStore.busyoList.Count; i++) { int busyoId = RecoveryDataStore.busyoList[i]; if (busyoId != 0) { //add busyo if (myBusyo == null || myBusyo == "") { myBusyo = busyoId.ToString(); } else { myBusyo = myBusyo + "," + busyoId.ToString(); } //add parametor int lv = RecoveryDataStore.lvList[count]; string hei = RecoveryDataStore.heiList[count]; int senpouLv = RecoveryDataStore.senpouLvList[count]; int sakuLv = RecoveryDataStore.sakuLvList[count]; string kahou = RecoveryDataStore.kahouList[count]; //lv PlayerPrefs.SetInt(busyoId.ToString(), lv); if (lv <= 0) { lv = 1; } //hei string heiTmp = "hei" + busyoId.ToString(); PlayerPrefs.SetString(heiTmp, hei); //senpou string senpou = "senpou" + busyoId.ToString(); PlayerPrefs.SetInt(senpou, senpouLv); //Lv //saku string saku = "saku" + busyoId.ToString(); PlayerPrefs.SetInt(saku, sakuLv); //Lv //kahou string kahouTmp = "kahou" + busyoId.ToString(); PlayerPrefs.SetString(kahouTmp, kahou); //exp string exp = "exp" + busyoId.ToString(); int totalBusyoExp = expScript.getExpforNextLv(lv - 1); PlayerPrefs.SetInt(exp, totalBusyoExp); //addLv string addlvTmp = "addlv" + busyoId.ToString(); int addlv = RecoveryDataStore.addLvList[count]; if (addlv != 0) { PlayerPrefs.SetInt(addlvTmp, addlv); } //gokui string gokuiTmp = "gokui" + busyoId.ToString(); int gokui = RecoveryDataStore.gokuiList[count]; if (gokui != 0) { PlayerPrefs.SetInt(gokuiTmp, gokui); } //gokui string kanniTmp = "kanni" + busyoId.ToString(); int kanni = RecoveryDataStore.kanniList[count]; if (kanni != 0) { PlayerPrefs.SetInt(kanniTmp, kanni); } count = count + 1; } } PlayerPrefs.SetInt("myDaimyo", RecoveryDataStore.myDaimyo); Daimyo daimyoScript = new Daimyo(); PlayerPrefs.SetInt("myDaimyoBusyo", daimyoScript.getDaimyoBusyoId(RecoveryDataStore.myDaimyo)); PlayerPrefs.SetString("myBusyo", myBusyo); PlayerPrefs.SetString("myKanni", RecoveryDataStore.myKanni); PlayerPrefs.SetString("availableBugu", RecoveryDataStore.availableBugu); PlayerPrefs.SetString("availableKabuto", RecoveryDataStore.availableKabuto); PlayerPrefs.SetString("availableGusoku", RecoveryDataStore.availableGusoku); PlayerPrefs.SetString("availableMeiba", RecoveryDataStore.availableMeiba); PlayerPrefs.SetString("availableCyadougu", RecoveryDataStore.availableCyadougu); PlayerPrefs.SetString("availableHeihousyo", RecoveryDataStore.availableHeihousyo); PlayerPrefs.SetString("availableChishikisyo", RecoveryDataStore.availableChishikisyo); PlayerPrefs.SetString("kanjyo", RecoveryDataStore.kanjyo); PlayerPrefs.SetString("cyouheiYR", RecoveryDataStore.cyouheiYR); PlayerPrefs.SetString("cyouheiKB", RecoveryDataStore.cyouheiKB); PlayerPrefs.SetString("cyouheiTP", RecoveryDataStore.cyouheiTP); PlayerPrefs.SetString("cyouheiYM", RecoveryDataStore.cyouheiYM); PlayerPrefs.SetInt("hidensyoGe", RecoveryDataStore.hidensyoGe); PlayerPrefs.SetInt("hidensyoCyu", RecoveryDataStore.hidensyoCyu); PlayerPrefs.SetInt("hidensyoJyo", RecoveryDataStore.hidensyoJyo); PlayerPrefs.SetInt("shinobiGe", RecoveryDataStore.shinobiGe); PlayerPrefs.SetInt("shinobiCyu", RecoveryDataStore.shinobiCyu); PlayerPrefs.SetInt("shinobiJyo", RecoveryDataStore.shinobiJyo); PlayerPrefs.SetString("kengouItem", RecoveryDataStore.kengouItem); PlayerPrefs.SetString("gokuiItem", RecoveryDataStore.gokuiItem); PlayerPrefs.SetString("nanbanItem", RecoveryDataStore.nanbanItem); PlayerPrefs.SetInt("transferTP", RecoveryDataStore.transferTP); PlayerPrefs.SetInt("transferKB", RecoveryDataStore.transferKB); PlayerPrefs.SetInt("meisei", RecoveryDataStore.meisei); PlayerPrefs.SetString("shiro", RecoveryDataStore.shiro); PlayerPrefs.SetString("koueki", RecoveryDataStore.koueki); PlayerPrefs.SetString("cyoutei", RecoveryDataStore.cyoutei); PlayerPrefs.SetString("zukanBusyoHst", RecoveryDataStore.zukanBusyoHst); PlayerPrefs.SetString("zukanBuguHst", RecoveryDataStore.zukanBuguHst); PlayerPrefs.SetString("zukanGusokuHst", RecoveryDataStore.zukanGusokuHst); PlayerPrefs.SetString("zukanKabutoHst", RecoveryDataStore.zukanKabutoHst); PlayerPrefs.SetString("zukanMeibaHst", RecoveryDataStore.zukanMeibaHst); PlayerPrefs.SetString("zukanCyadouguHst", RecoveryDataStore.zukanCyadouguHst); PlayerPrefs.SetString("zukanChishikisyoHst", RecoveryDataStore.zukanChishikisyoHst); PlayerPrefs.SetString("zukanHeihousyoHst", RecoveryDataStore.zukanHeihousyoHst); PlayerPrefs.SetString("gameClearDaimyo", RecoveryDataStore.gameClearDaimyo); PlayerPrefs.SetString("gameClearDaimyoHard", RecoveryDataStore.gameClearDaimyoHard); //jinkei PlayerPrefs.SetInt("jinkei", RecoveryDataStore.jinkeiId); PlayerPrefs.SetInt("soudaisyo" + RecoveryDataStore.jinkeiId, RecoveryDataStore.soudaisyo); for (int i = 0; i < 25; i++) { int busyoId = RecoveryDataStore.busyoMapList[i]; int id = i + 1; if (busyoId == 0) { string tmp = RecoveryDataStore.jinkeiId.ToString() + "map" + id.ToString(); PlayerPrefs.DeleteKey(tmp); } else { string tmp = RecoveryDataStore.jinkeiId.ToString() + "map" + id.ToString(); PlayerPrefs.SetInt(tmp, busyoId); } } //naisei for (int i = 0; i < RecoveryDataStore.naiseiKuniList.Count; i++) { int kuniId = RecoveryDataStore.naiseiKuniList[i]; string naiseiTmp = "naisei" + kuniId.ToString(); PlayerPrefs.SetString(naiseiTmp, RecoveryDataStore.naiseiList[i]); if (RecoveryDataStore.naiseiShiroList[i] != 0) { string shiroTmp = "shiro" + kuniId.ToString(); PlayerPrefs.SetInt(shiroTmp, RecoveryDataStore.naiseiShiroList[i]); } } //Add Qty & PvP Name PlayerPrefs.SetInt("myBusyoQty", RecoveryDataStore.busyoList.Count); string userName = RecoveryDataStore.userName; if (userName == "") { userName = "******"; } PlayerPrefs.SetString("PvPName", userName); } else { /***userId + pvpJinkei***/ int totalExp = expScript.getTotalExp(RecoveryDataStore.kuniLv); PlayerPrefs.SetInt("kuniExp", totalExp); PlayerPrefs.SetInt("myDaimyo", RecoveryDataStore.myDaimyo); Daimyo daimyoScript = new Daimyo(); PlayerPrefs.SetInt("myDaimyoBusyo", daimyoScript.getDaimyoBusyoId(RecoveryDataStore.myDaimyo)); //pvp jinkei string myBusyoString = PlayerPrefs.GetString("myBusyo"); List <string> myBusyoList = new List <string>(); char[] delimiterChars = { ',' }; if (myBusyoString != null && myBusyoString != "") { if (myBusyoString.Contains(",")) { myBusyoList = new List <string>(myBusyoString.Split(delimiterChars)); } else { myBusyoList.Add(myBusyoString); } } //zukan 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); } } //Daimyo Busyo History Daimyo daimyo = new Daimyo(); 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); } } int count = 0; for (int i = 0; i < RecoveryDataStore.busyoList.Count; i++) { int busyoId = RecoveryDataStore.busyoList[i]; if (busyoId != 0) { //add busyo if (!myBusyoList.Contains(busyoId.ToString())) { if (myBusyoString == null || myBusyoString == "") { myBusyoString = busyoId.ToString(); } else { myBusyoString = myBusyoString + "," + busyoId.ToString(); } PlayerPrefs.SetString("myBusyo", myBusyoString); } //add zukan if (!zukanBusyoHstList.Contains(busyoId.ToString())) { if (zukanBusyoHst == null || zukanBusyoHst == "") { zukanBusyoHst = busyoId.ToString(); } else { zukanBusyoHst = zukanBusyoHst + "," + busyoId.ToString(); } PlayerPrefs.SetString("zukanBusyoHst", zukanBusyoHst); } //add daimyo busyo if (daimyo.daimyoBusyoCheck(busyoId)) { if (!gacyaDaimyoHstList.Contains(busyoId.ToString())) { if (gacyaDaimyoHst == null || gacyaDaimyoHst == "") { gacyaDaimyoHst = busyoId.ToString(); } else { gacyaDaimyoHst = gacyaDaimyoHst + "," + busyoId.ToString(); } PlayerPrefs.SetString("gacyaDaimyoHst", gacyaDaimyoHst); } } //add parametor int lv = RecoveryDataStore.lvList[count]; string hei = RecoveryDataStore.heiList[count]; int senpouLv = RecoveryDataStore.senpouLvList[count]; int sakuLv = RecoveryDataStore.sakuLvList[count]; string kahou = RecoveryDataStore.kahouList[count]; //lv PlayerPrefs.SetInt(busyoId.ToString(), lv); //hei string heiTmp = "hei" + busyoId.ToString(); PlayerPrefs.SetString(heiTmp, hei); //senpou string senpou = "senpou" + busyoId.ToString(); PlayerPrefs.SetInt(senpou, senpouLv); //Lv //saku string saku = "saku" + busyoId.ToString(); PlayerPrefs.SetInt(saku, sakuLv); //Lv //kahou string kahouTmp = "kahou" + busyoId.ToString(); PlayerPrefs.SetString(kahouTmp, kahou); //exp string exp = "exp" + busyoId.ToString(); int totalBusyoExp = expScript.getExpforNextLv(lv - 1); PlayerPrefs.SetInt(exp, totalBusyoExp); count = count + 1; } } PlayerPrefs.Flush(); //Add Qty & PvP Name string myBusyoStringCount = PlayerPrefs.GetString("myBusyo"); List <string> myBusyoListCount = new List <string>(); if (myBusyoStringCount.Contains(",")) { myBusyoListCount = new List <string>(myBusyoStringCount.Split(delimiterChars)); } else { myBusyoListCount.Add(myBusyoStringCount); } PlayerPrefs.SetInt("myBusyoQty", myBusyoListCount.Count); string userName = RecoveryDataStore.userName; if (userName == "") { userName = "******"; } PlayerPrefs.SetString("PvPName", userName); } PlayerPrefs.Flush(); //add data recovery history RecoveryDataStore.UpdateDataRecovery(RecoveryDataStore.inputUserId); //Final Process audioSources[3].Play(); Destroy(back.gameObject); Destroy(msg.gameObject); GameObject.Find("Start").GetComponent <Button>().enabled = false; Message msgScript = new Message(); msgScript.makeMessage(msgScript.getMessage(151)); } else { RecoveryDataStore RecoveryDataStore = GameObject.Find("RecoveryDataStore").GetComponent <RecoveryDataStore>(); RecoveryDataStore.ResetValue(); audioSources[1].Play(); Destroy(back.gameObject); Destroy(msg.gameObject); } }
public void wasAttacked(string key, int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId, bool dstEngunFlg, string dstEngunDaimyoId, string dstEngunSts){ //In the case of My Damyo was Attacked //For Dramatic Enemy Creation GameObject kuniView = GameObject.Find("KuniIconView"); SendParam param = kuniView.transform.FindChild(srcKuni.ToString()).GetComponent<SendParam>(); int busyoQty = param.busyoQty; int busyoLv = param.busyoLv; int butaiQty = param.butaiQty; int butaiLv = param.butaiLv; //Dummy PlayerPrefs.SetInt("activeStageId", 0); PlayerPrefs.SetInt("activeStageMoney", busyoQty*busyoLv*100); PlayerPrefs.SetInt("activeStageExp", busyoQty*busyoLv*10); PlayerPrefs.SetString("activeItemType", ""); PlayerPrefs.SetInt("activeItemId", 0); PlayerPrefs.SetFloat("activeItemRatio", 0); PlayerPrefs.SetInt("activeItemQty", 0); //Actual PlayerPrefs.SetInt("activeKuniId", dstKuni); KuniInfo kuni = new KuniInfo (); string kuniName = kuni.getKuniName (dstKuni); string kassenName = kuniName + "防衛"; PlayerPrefs.SetString("activeStageName", kassenName); PlayerPrefs.SetInt("activeDaimyoId", srcDaimyoId); PlayerPrefs.SetInt ("activeBusyoQty", busyoQty); PlayerPrefs.SetInt ("activeBusyoLv", busyoLv); PlayerPrefs.SetInt ("activeButaiQty", butaiQty); PlayerPrefs.SetInt ("activeButaiLv", butaiLv); //Passive only PlayerPrefs.SetBool ("isAttackedFlg", true); PlayerPrefs.SetString("activeKey", key); PlayerPrefs.SetInt("activeSrcDaimyoId", srcDaimyoId); PlayerPrefs.SetInt("activeDstDaimyoId", dstDaimyoId); //Engun if (dstEngunFlg) { PlayerPrefs.SetString("playerEngunList", dstEngunSts); PlayerPrefs.DeleteKey("enemyEngunList"); } else { PlayerPrefs.DeleteKey("playerEngunList"); PlayerPrefs.DeleteKey("enemyEngunList"); } //Gaikou Down Gaikou gaikou = new Gaikou (); gaikou.downGaikouByAttack (srcDaimyoId, dstDaimyoId); //Delete "Start Kassen Flg" PlayerPrefs.DeleteKey("activeLink"); PlayerPrefs.DeleteKey("activePowerType"); List<int> powerTypeList = new List<int> (){1,2,3}; int random = UnityEngine.Random.Range(1,powerTypeList.Count + 1); PlayerPrefs.SetInt("activePowerType",random); //Boubi effect string boubiTmp = "boubi" + dstKuni.ToString(); int boubi = PlayerPrefs.GetInt (boubiTmp,0); boubi = boubi / 10; PlayerPrefs.SetInt("activeBoubi", boubi); PlayerPrefs.Flush(); Application.LoadLevel("preKassen"); }
public void createBusyoStatusView(string busyoId) { bool tutorialDoneFlg = PlayerPrefs.GetBool("tutorialDoneFlg"); int lv = 1; if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialBusyo") { lv = PlayerPrefs.GetInt(busyoId); } StatusGet sts = new StatusGet(); int hp = sts.getHp(int.Parse(busyoId), lv); int atk = sts.getAtk(int.Parse(busyoId), lv); int dfc = sts.getDfc(int.Parse(busyoId), lv); int spd = sts.getSpd(int.Parse(busyoId), lv); int adjHp = hp * 100; int adjAtk = atk * 10; int adjDfc = dfc * 10; //add lv string addLvTmp = "addlv" + busyoId.ToString(); if (PlayerPrefs.HasKey(addLvTmp)) { string addLvValue = "+" + PlayerPrefs.GetString(addLvTmp); GameObject.Find("addLvValue").GetComponent <Text>().text = addLvValue.ToString(); } else { GameObject.Find("addLvValue").GetComponent <Text>().text = ""; } int maxLv = 100 + PlayerPrefs.GetInt(addLvTmp); GameObject.Find("LvValue").GetComponent <Text> ().text = lv.ToString(); GameObject.Find("TosotsuValue").GetComponent <Text> ().text = adjHp.ToString(); GameObject.Find("BuyuuValue").GetComponent <Text> ().text = adjAtk.ToString(); GameObject.Find("ChiryakuValue").GetComponent <Text> ().text = adjDfc.ToString(); GameObject.Find("SpeedValue").GetComponent <Text> ().text = spd.ToString(); //Exp string expId = "exp" + busyoId.ToString(); string expString = ""; int nowExp = 0; if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialBusyo") { nowExp = PlayerPrefs.GetInt(expId); } Exp exp = new Exp(); int requiredExp = 0; if (lv != maxLv) { requiredExp = exp.getExpforNextLv(lv); } else { requiredExp = exp.getExpLvMax(maxLv); } expString = nowExp + "/" + requiredExp; GameObject.Find("ExpValue").GetComponent <Text> ().text = expString; //Kahou status int totalBusyoHp = 0; int finalAtk = 0; int finalHp = 0; int finalDfc = 0; int finalSpd = 0; if (tutorialDoneFlg && Application.loadedLevelName != "tutorialBusyo") { KahouStatusGet kahouSts = new KahouStatusGet(); string[] KahouStatusArray = kahouSts.getKahouForStatus(busyoId, adjHp, adjAtk, adjDfc, spd); //Kanni string kanniTmp = "kanni" + busyoId; float addAtkByKanni = 0; float addHpByKanni = 0; float addDfcByKanni = 0; if (PlayerPrefs.HasKey(kanniTmp)) { int kanniId = PlayerPrefs.GetInt(kanniTmp); if (kanniId != 0) { Kanni kanni = new Kanni(); string kanniIkai = kanni.getIkai(kanniId); string kanniName = kanni.getKanni(kanniId); GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text> ().text = kanniIkai + "\n" + kanniName; //Status string kanniTarget = kanni.getEffectTarget(kanniId); int effect = kanni.getEffect(kanniId); if (kanniTarget == "atk") { addAtkByKanni = ((float)adjAtk * (float)effect) / 100; } else if (kanniTarget == "hp") { addHpByKanni = ((float)adjHp * (float)effect) / 100; } else if (kanniTarget == "dfc") { addDfcByKanni = ((float)adjDfc * (float)effect) / 100; } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank"; } else { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し"; } } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank"; } else { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し"; } } //Jyosyu string jyosyuTmp = "jyosyuBusyo" + busyoId; if (PlayerPrefs.HasKey(jyosyuTmp)) { int kuniId = PlayerPrefs.GetInt(jyosyuTmp); KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = kuniName + "\nLord"; } else { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = kuniName + "\n城主"; } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "No Feud"; } else { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "城無し"; } } //Show Additional Status finalAtk = int.Parse(KahouStatusArray [0]) + Mathf.FloorToInt(addAtkByKanni); finalHp = int.Parse(KahouStatusArray [1]) + Mathf.FloorToInt(addHpByKanni); finalDfc = int.Parse(KahouStatusArray [2]) + Mathf.FloorToInt(addDfcByKanni); finalSpd = int.Parse(KahouStatusArray [3]); GameObject.Find("KahouAtkValue").GetComponent <Text> ().text = "+" + finalAtk.ToString(); GameObject.Find("KahouHpValue").GetComponent <Text>().text = "+" + finalHp.ToString(); totalBusyoHp = adjHp + finalHp; GameObject.Find("KahouDfcValue").GetComponent <Text>().text = "+" + finalDfc.ToString(); GameObject.Find("KahouSpdValue").GetComponent <Text>().text = "+" + finalSpd.ToString(); } else { if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank"; } else { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し"; } if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "No Feud"; } else { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "城無し"; } } //Butai Status string heiId = "hei" + busyoId.ToString(); string chParam = ""; if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialBusyo") { chParam = PlayerPrefs.GetString(heiId, "0"); } else { //retry tutorial chParam = "TP: 1:1:1"; } if (chParam == "0" || chParam == "") { StatusGet statusScript = new StatusGet(); string chParamHeisyu = statusScript.getHeisyu(int.Parse(busyoId)); chParam = chParamHeisyu + ":1:1:1"; PlayerPrefs.SetString(heiId, chParam); PlayerPrefs.Flush(); } char[] delimiterChars = { ':' }; string[] ch_list = chParam.Split(delimiterChars); string ch_type = ch_list [0]; int ch_num = int.Parse(ch_list [1]); int ch_lv = int.Parse(ch_list [2]); float ch_status = float.Parse(ch_list [3]); string heisyu = ""; Message msg = new Message(); if (ch_type == "KB") { heisyu = msg.getMessage(55); } else if (ch_type == "YR") { heisyu = msg.getMessage(56); } else if (ch_type == "TP") { heisyu = msg.getMessage(57); } else if (ch_type == "YM") { heisyu = msg.getMessage(58); } GameObject.Find("ChildNameValue").GetComponent <Text> ().text = heisyu; GameObject.Find("ChildQtyValue").GetComponent <Text> ().text = ch_num.ToString(); GameObject.Find("ChildLvValue").GetComponent <Text> ().text = ch_lv.ToString(); //Jyosyu Handling JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku(); float addHei = (float)jyosyuHei.GetJyosyuHeiryoku(busyoId); float hei = ch_status * 10; GameObject.Find("ChildHeiryokuValue").GetComponent <Text> ().text = hei.ToString(); float newHei = finalHp + addHei; GameObject.Find("KahouHpValue").GetComponent <Text>().text = "+" + newHei.ToString(); int chAtkDfc = (int)sts.getChAtkDfc((int)hei, totalBusyoHp); string chAtkDfcString = chAtkDfc.ToString() + "/" + chAtkDfc.ToString(); GameObject.Find("ChildStatusValue").GetComponent <Text> ().text = chAtkDfcString; //Child Image foreach (Transform n in GameObject.Find("Img").transform) { GameObject.Destroy(n.gameObject); } string chPath = "Prefabs/Player/Unit/" + ch_type; GameObject chObj = Instantiate(Resources.Load(chPath)) as GameObject; chObj.transform.SetParent(GameObject.Find("Img").transform); RectTransform chTransform = chObj.GetComponent <RectTransform> (); chTransform.anchoredPosition3D = new Vector3(-200, -50, 0); chTransform.sizeDelta = new Vector2(40, 40); chObj.transform.localScale = new Vector2(4, 4); GameObject chigyo = GameObject.Find("ButtonCyouhei"); if (ch_num < 20) { chigyo.GetComponent <Image> ().color = OKClorBtn; chigyo.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt; chigyo.GetComponent <Button>().enabled = true; chigyo.GetComponent <BusyoStatusButton> ().ch_type = ch_type; chigyo.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu; chigyo.GetComponent <BusyoStatusButton> ().ch_num = ch_num; chigyo.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc; chigyo.GetComponent <BusyoStatusButton> ().ch_hp = hei; chigyo.GetComponent <BusyoStatusButton> ().pa_hp = totalBusyoHp / 100; } else { //MAX chigyo.GetComponent <Image> ().color = NGClorBtn; chigyo.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt; chigyo.GetComponent <Button>().enabled = false; } GameObject kunren = GameObject.Find("ButtonKunren"); if (ch_lv < 100) { kunren.GetComponent <Image> ().color = OKClorBtn; kunren.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt; kunren.GetComponent <Button>().enabled = true; kunren.GetComponent <BusyoStatusButton> ().ch_type = ch_type; kunren.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu; kunren.GetComponent <BusyoStatusButton> ().ch_lv = ch_lv; kunren.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc; kunren.GetComponent <BusyoStatusButton> ().ch_hp = hei; kunren.GetComponent <BusyoStatusButton> ().ch_num = ch_num; kunren.GetComponent <BusyoStatusButton> ().pa_hp = totalBusyoHp / 100; } else { //MAX kunren.GetComponent <Image> ().color = NGClorBtn; kunren.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt; kunren.GetComponent <Button>().enabled = false; } //Parametor Setting GameObject.Find("GameScene").GetComponent <NowOnBusyo>().OnBusyo = busyoId; //Jinkei Flg GameObject BusyoView = GameObject.Find("BusyoView"); if (!BusyoView.transform.FindChild("jinkei")) { if (jinkeiBusyoCheck(int.Parse(busyoId))) { string iconPath = "Prefabs/Busyo/Jinkei"; GameObject jinkei = Instantiate(Resources.Load(iconPath)) as GameObject; jinkei.transform.SetParent(GameObject.Find("BusyoView").transform); jinkei.transform.localScale = new Vector2(0.3f, 0.3f); jinkei.transform.localPosition = new Vector2(220, 200); jinkei.name = "jinkei"; } } }
public void kuniScrollView(GameObject baseObj, string targetDaimyo, GameObject btn){ GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject; string seiryoku = PlayerPrefs.GetString ("seiryoku"); char[] delimiterChars = {','}; List<string> seiryokuList = new List<string>(); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); //my kuni int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); string myKuni = PlayerPrefs.GetString ("clearedKuni"); List<int> myKuniList = new List<int>(); if (myKuni.Contains (",")) { List<string> tempMyKuniList = new List<string> (myKuni.Split (delimiterChars)); myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x)); } else { myKuniList.Add(int.Parse(myKuni)); } //doumei daimyo's opne kuni KuniInfo kuni = new KuniInfo (); List<int> doumeiOpenKuniList = new List<int>(); List<int> doumeiKuniList = new List<int>(); for(int i=0; i<seiryokuList.Count; i++){ string tempDaimyo = seiryokuList[i]; if(tempDaimyo == targetDaimyo){ int doumeiKuniId = i + 1; doumeiKuniList.Add(doumeiKuniId); doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId)); } } //"doumei daimyo's opne kuni" minus "my kuni" List<int> doumeiOpenKuniMinusMyKuniList = new List<int>(); foreach(int n in doumeiOpenKuniList){ if(!myKuniList.Contains(n)){ doumeiOpenKuniMinusMyKuniList.Add(n); } } //"doumei daimyo's doumei check string tempDoumei = "doumei" + targetDaimyo; string doumei = PlayerPrefs.GetString (tempDoumei); List<string> doumeiList = new List<string>(); if (doumei.Contains (",")) { doumeiList = new List<string> (doumei.Split (delimiterChars)); } else { doumeiList.Add(doumei); } if (doumei != null && doumei != "") { for(int t=0; t<doumeiOpenKuniMinusMyKuniList.Count; t++){ //foreach (int n in doumeiOpenKuniMinusMyKuniList) { string checkDaimyoId = seiryokuList [doumeiOpenKuniMinusMyKuniList[t] - 1]; if (doumeiList.Contains (checkDaimyoId)) { doumeiOpenKuniMinusMyKuniList.Remove (doumeiOpenKuniMinusMyKuniList[t]); } } } //Compare "doumei open" with "my open" string myOpenKuni = PlayerPrefs.GetString ("openKuni"); List<int> myOpenKuniList = new List<int>(); if (myOpenKuni.Contains (",")) { List<string> tempMyOpenKuniList = new List<string> (myOpenKuni.Split (delimiterChars)); myOpenKuniList = tempMyOpenKuniList.ConvertAll(x => int.Parse(x)); } else { myOpenKuniList.Add(int.Parse(myOpenKuni)); } List<int> sameTargetKuniList = new List<int>(); foreach(int n in myOpenKuniList){ if(doumeiOpenKuniMinusMyKuniList.Contains(n)){ if(!doumeiKuniList.Contains(n)){ sameTargetKuniList.Add(n); } } } /*Slot making*/ string temp = "gaikou" + targetDaimyo; int myYukoudo = PlayerPrefs.GetInt(temp); //Get Chiryaku Entity_daimyo_mst daimyoMst = Resources.Load ("Data/daimyo_mst") as Entity_daimyo_mst; int myDaimyoBusyoId = daimyoMst.param [myDaimyo - 1].busyoId; StatusGet sts = new StatusGet(); int lv = PlayerPrefs.GetInt (myDaimyoBusyoId.ToString()); float chiryaku = (float)sts.getDfc(myDaimyoBusyoId,lv); chiryaku = chiryaku *10; string slotPath = "Prefabs/Map/common/kuniSlot"; for (int i=0; i<sameTargetKuniList.Count; i++) { GameObject prefab = Instantiate (Resources.Load (slotPath)) as GameObject; prefab.transform.SetParent(content.transform); prefab.transform.localScale = new Vector3 (1, 1, 1); int kuniId = sameTargetKuniList[i]; int daimyoId = int.Parse (seiryokuList [kuniId - 1]); string daimyoName = daimyoMst.param [daimyoId - 1].daimyoName; string theirYukouTemp = ""; if(int.Parse(targetDaimyo) < daimyoId){ theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString(); }else{ theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo; } int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp); string kuniName = kuni.getKuniName(kuniId); prefab.transform.FindChild("KuniValue").GetComponent<Text>().text = kuniName; prefab.transform.FindChild("DaimyoValue").GetComponent<Text>().text = daimyoName; prefab.GetComponent<GaikouKuniSelect>().Content = content; prefab.GetComponent<GaikouKuniSelect>().Btn = btn; prefab.GetComponent<GaikouKuniSelect>().myYukoudo = myYukoudo; prefab.GetComponent<GaikouKuniSelect>().chiryaku = (int)chiryaku; prefab.GetComponent<GaikouKuniSelect>().kuniDiff = kuniDiff; prefab.GetComponent<GaikouKuniSelect>().theirYukoudo = theirYukoudo; prefab.GetComponent<GaikouKuniSelect>().kuniName = kuniName; prefab.GetComponent<GaikouKuniSelect>().targetKuniId = kuniId; if(i == 0){ prefab.GetComponent<GaikouKuniSelect>().OnClick(); } } if (sameTargetKuniList.Count == 0) { string msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg"; GameObject msg = Instantiate (Resources.Load (msgPath)) as GameObject; msg.transform.SetParent(GameObject.Find("scroll").transform); msg.transform.localScale = new Vector3 (0.17f, 0.2f, 1); RectTransform msgTransform = msg.GetComponent<RectTransform> (); msgTransform.anchoredPosition = new Vector3 (-260, -115, 0); GameObject a = baseObj.transform.FindChild ("RequiredMoney").gameObject; GameObject b = baseObj.transform.FindChild ("KyoutouRatio").gameObject; Destroy(a); Destroy(b); btn.GetComponent<Button>().enabled = false; } }
public void kuniScrollView(GameObject baseObj, string targetDaimyo, GameObject btn) { GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject; string seiryoku = PlayerPrefs.GetString("seiryoku"); char[] delimiterChars = { ',' }; List <string> seiryokuList = new List <string>(); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); //my kuni int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); string myKuni = PlayerPrefs.GetString("clearedKuni"); List <int> myKuniList = new List <int>(); if (myKuni.Contains(",")) { List <string> tempMyKuniList = new List <string> (myKuni.Split(delimiterChars)); myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x)); } else { myKuniList.Add(int.Parse(myKuni)); } //doumei daimyo's opne kuni KuniInfo kuni = new KuniInfo(); List <int> doumeiOpenKuniList = new List <int>(); List <int> doumeiKuniList = new List <int>(); for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyo = seiryokuList[i]; if (tempDaimyo == targetDaimyo) { int doumeiKuniId = i + 1; doumeiKuniList.Add(doumeiKuniId); doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId)); } } //"doumei daimyo's opne kuni" minus "my kuni" List <int> doumeiOpenKuniMinusMyKuniList = new List <int>(); foreach (int n in doumeiOpenKuniList) { if (!myKuniList.Contains(n)) { doumeiOpenKuniMinusMyKuniList.Add(n); } } //"doumei daimyo's doumei check string tempDoumei = "doumei" + targetDaimyo; string doumei = PlayerPrefs.GetString(tempDoumei); List <string> doumeiList = new List <string>(); if (doumei.Contains(",")) { doumeiList = new List <string> (doumei.Split(delimiterChars)); } else { doumeiList.Add(doumei); } if (doumei != null && doumei != "") { for (int t = 0; t < doumeiOpenKuniMinusMyKuniList.Count; t++) { //foreach (int n in doumeiOpenKuniMinusMyKuniList) { string checkDaimyoId = seiryokuList [doumeiOpenKuniMinusMyKuniList[t] - 1]; if (doumeiList.Contains(checkDaimyoId)) { doumeiOpenKuniMinusMyKuniList.Remove(doumeiOpenKuniMinusMyKuniList[t]); } } } //Compare "doumei open" with "my open" string myOpenKuni = PlayerPrefs.GetString("openKuni"); List <int> myOpenKuniList = new List <int>(); if (myOpenKuni.Contains(",")) { List <string> tempMyOpenKuniList = new List <string> (myOpenKuni.Split(delimiterChars)); myOpenKuniList = tempMyOpenKuniList.ConvertAll(x => int.Parse(x)); } else { myOpenKuniList.Add(int.Parse(myOpenKuni)); } List <int> sameTargetKuniList = new List <int>(); foreach (int n in myOpenKuniList) { if (doumeiOpenKuniMinusMyKuniList.Contains(n)) { if (!doumeiKuniList.Contains(n)) { if (!sameTargetKuniList.Contains(n)) { sameTargetKuniList.Add(n); } } } } /*Slot making*/ string temp = "gaikou" + targetDaimyo; int myYukoudo = PlayerPrefs.GetInt(temp); //Get Chiryaku Daimyo daimyoScript = new Daimyo(); Entity_daimyo_mst daimyoMst = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst; int myDaimyoBusyoId = daimyoMst.param [myDaimyo - 1].busyoId; BusyoInfoGet busyo = new BusyoInfoGet(); int chiryaku = busyo.getMaxDfc(myDaimyoBusyoId); //StatusGet sts = new StatusGet(); //int lv = PlayerPrefs.GetInt (myDaimyoBusyoId.ToString()); //float chiryaku = (float)sts.getDfc(myDaimyoBusyoId,lv); //chiryaku = chiryaku *10; string slotPath = "Prefabs/Map/common/kuniSlot"; for (int i = 0; i < sameTargetKuniList.Count; i++) { GameObject prefab = Instantiate(Resources.Load(slotPath)) as GameObject; prefab.transform.SetParent(content.transform); prefab.transform.localScale = new Vector3(1, 1, 1); int kuniId = sameTargetKuniList[i]; int daimyoId = int.Parse(seiryokuList [kuniId - 1]); // daimyoName = daimyoMst.param [daimyoId - 1].daimyoName; string daimyoName = daimyoScript.getName(daimyoId); string theirYukouTemp = ""; if (int.Parse(targetDaimyo) < daimyoId) { theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString(); } else { theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo; } int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp); string kuniName = kuni.getKuniName(kuniId); prefab.transform.FindChild("KuniValue").GetComponent <Text>().text = kuniName; prefab.transform.FindChild("DaimyoValue").GetComponent <Text>().text = daimyoName; prefab.GetComponent <GaikouKuniSelect>().Content = content; prefab.GetComponent <GaikouKuniSelect>().Btn = btn; prefab.GetComponent <GaikouKuniSelect>().myYukoudo = myYukoudo; prefab.GetComponent <GaikouKuniSelect>().chiryaku = chiryaku; prefab.GetComponent <GaikouKuniSelect>().kuniDiff = kuniDiff; prefab.GetComponent <GaikouKuniSelect>().theirYukoudo = theirYukoudo; prefab.GetComponent <GaikouKuniSelect>().kuniName = kuniName; prefab.GetComponent <GaikouKuniSelect>().targetKuniId = kuniId; if (i == 0) { prefab.GetComponent <GaikouKuniSelect>().OnClick(); } } if (sameTargetKuniList.Count == 0) { string msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg"; GameObject msg = Instantiate(Resources.Load(msgPath)) as GameObject; msg.transform.SetParent(GameObject.Find("scroll").transform); msg.transform.localScale = new Vector3(0.17f, 0.2f, 1); RectTransform msgTransform = msg.GetComponent <RectTransform> (); msgTransform.anchoredPosition = new Vector3(-260, -115, 0); GameObject a = baseObj.transform.FindChild("RequiredMoney").gameObject; GameObject b = baseObj.transform.FindChild("KyoutouRatio").gameObject; Destroy(a); Destroy(b); btn.GetComponent <Button>().enabled = false; Color NGClorBtn = new Color(133 / 255f, 133 / 255f, 80 / 255f, 255f / 255f); Color NGClorTxt = new Color(90 / 255f, 90 / 255f, 40 / 255f, 255f / 255f); btn.GetComponent <Image>().color = NGClorBtn; btn.transform.FindChild("Text").GetComponent <Text>().color = NGClorTxt; btn.transform.FindChild("hyourouIcon").GetComponent <Image>().color = NGClorBtn; btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text>().color = NGClorTxt; btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").transform.FindChild("syouhiText").GetComponent <Text>().color = NGClorTxt; } }
public void Start () { //Get Temp Kuni Id & Stage Id activeKuniId = PlayerPrefs.GetInt ("activeKuniId"); string temp = "naisei" + activeKuniId.ToString (); /*Initial Setting*/ //Kuni Name & jyosyu string title = ""; string kuniName = PlayerPrefs.GetString ("activeKuniName"); string jyosyuTemp = "jyosyu" + activeKuniId; //Clear Image foreach ( Transform n in GameObject.Find ("JyosyuImage").transform){ GameObject.Destroy(n.gameObject); } if (PlayerPrefs.HasKey (jyosyuTemp)) { //Jyosyu Exist jyosyuId = PlayerPrefs.GetInt (jyosyuTemp); string busyoPath = "Prefabs/Player/Unit/" + jyosyuId; GameObject busyo = Instantiate (Resources.Load (busyoPath)) as GameObject; busyo.transform.SetParent (GameObject.Find ("JyosyuImage").transform); busyo.transform.localScale = new Vector2 (4, 4); busyo.GetComponent<DragHandler>().enabled = false; RectTransform busyo_transform = busyo.GetComponent<RectTransform>(); busyo_transform.anchoredPosition3D = new Vector3(40,40,0); busyo_transform.sizeDelta = new Vector2( 23, 23); foreach(Transform n in busyo.transform){ GameObject.Destroy(n.gameObject); } StatusGet sts = new StatusGet(); string jyosyuName = sts.getBusyoName(jyosyuId); title = kuniName + "・" + jyosyuName; //Ninmei Button GameObject btn = GameObject.Find ("Ninmei").gameObject; btn.GetComponent<Ninmei>().kaininFlg = true; btn.transform.FindChild("NinmeiText").GetComponent<Text>().text = "城主解任"; btn.GetComponent<Ninmei>().jyosyuId = jyosyuId; btn.GetComponent<Ninmei>().jyosyuName = jyosyuName; } else { //Jyosyu Not Exist title = kuniName + "・蔵入地"; //Ninmei Button GameObject btn = GameObject.Find ("Ninmei").gameObject; btn.GetComponent<Ninmei>().kaininFlg = false; btn.transform.FindChild("NinmeiText").GetComponent<Text>().text = "城主任命"; } GameObject.Find ("StageNameValue").GetComponent<Text> ().text = title; //Money int money = PlayerPrefs.GetInt("money"); GameObject.Find ("MoneyValue").GetComponent<Text> ().text = money.ToString(); //Hyourou int hyourou = PlayerPrefs.GetInt("hyourou"); GameObject.Find ("HyourouCurrentValue").GetComponent<Text> ().text = hyourou.ToString(); //HyourouMax int hyourouMax = PlayerPrefs.GetInt("hyourouMax"); GameObject.Find ("HyourouMaxValue").GetComponent<Text> ().text = hyourouMax.ToString(); //Naisei Icon List KuniInfo kuni = new KuniInfo (); shigen = kuni.getKuniNaisei (activeKuniId); //Sea or Tree isSeaFlg = kuni.getKuniIsSeaFlg (activeKuniId); GameObject otherObj = GameObject.Find ("Other").gameObject; if (isSeaFlg) { if(otherObj.transform.FindChild("treeUpper") != null){ otherObj.transform.FindChild("treeUpper").gameObject.SetActive(false); } } else { if(otherObj.transform.FindChild("sea") != null){ otherObj.transform.FindChild("sea").gameObject.SetActive(false); } } /*Open Panel*/ //Clear Previous Panel foreach ( Transform n in GameObject.Find ("NaiseiView").transform){ GameObject.Destroy(n.gameObject); } //Clear Previous Mask Panel foreach ( Transform n in GameObject.Find ("MaskView").transform){ GameObject.Destroy(n.gameObject); } //Open Panel & MaskPanel panelByShiro(activeKuniId); panelByKuniLv(); if (PlayerPrefs.HasKey (temp)) { /*initial setting*/ string naiseiString = PlayerPrefs.GetString (temp); List<string> naiseiList = new List<string>(); char[] delimiterChars = {','}; naiseiList = new List<string>(naiseiString.Split (delimiterChars)); /*Naisei Bldg Handling*/ char[] delimiterChars2 = {':'}; List<string> deletePanelList = new List<string>(); Entity_naisei_mst naiseiMst = Resources.Load ("Data/naisei_mst") as Entity_naisei_mst; for(int i=1; i<naiseiList.Count;i++){ List<string> naiseiContentList = new List<string>(); naiseiContentList = new List<string>(naiseiList[i].Split (delimiterChars2)); if(naiseiContentList[0] != "0"){ //Exist string bldgRank = ""; if(int.Parse(naiseiContentList[1])<8){ bldgRank = "s"; }else if(int.Parse(naiseiContentList[1]) < 15){ bldgRank = "m"; }else if(15 <= int.Parse(naiseiContentList[1])){ bldgRank = "l"; } //Add Delete Target deletePanelList.Add(i.ToString()); //Make New Panel string type = naiseiMst.param [int.Parse(naiseiContentList[0])].code; string bldg = type + "_" + bldgRank; string bldgPath = "Prefabs/Naisei/Bldg/" + bldg; GameObject bldgObj = Instantiate (Resources.Load (bldgPath)) as GameObject; bldgObj.transform.parent = GameObject.Find ("NaiseiView").transform; bldgObj.transform.localScale = new Vector3 (1, 1, 1); setBldg(bldgObj, i); bldgObj.name = i.ToString(); bldgObj.GetComponent<AreaButton>().blank = false; bldgObj.GetComponent<AreaButton>().type = type; bldgObj.GetComponent<AreaButton>().lv = naiseiContentList[1]; bldgObj.GetComponent<AreaButton>().naiseiId = int.Parse(naiseiContentList[0]); //Effect by Level List<int> naiseiEffectList = new List<int>(); naiseiEffectList = getNaiseiList(type, int.Parse(naiseiContentList[1])); if(type != "kzn"){ if(type != "yr" &&type != "kb"&&type != "tp" &&type != "ym" &&type !="snb"){ bldgObj.GetComponent<AreaButton>().effect = naiseiEffectList[0]; bldgObj.GetComponent<AreaButton>().effectNextLv = naiseiEffectList[1]; }else{ bldgObj.GetComponent<AreaButton>().effect = naiseiEffectList[0] * 2; bldgObj.GetComponent<AreaButton>().effectNextLv = naiseiEffectList[1] * 2; } }else{ bldgObj.GetComponent<AreaButton>().effect = naiseiEffectList[0] * 4; bldgObj.GetComponent<AreaButton>().effectNextLv = naiseiEffectList[1] * 4; } bldgObj.GetComponent<AreaButton>().moneyNextLv = naiseiEffectList[2]; bldgObj.GetComponent<AreaButton>().requiredHyourou =naiseiMst.param [int.Parse(naiseiContentList[0])].hyourou; bldgObj.GetComponent<AreaButton>().naiseiName =naiseiMst.param [int.Parse(naiseiContentList[0])].name; //Status if(type == "shop"){ syogyo = syogyo + naiseiEffectList[0]; }else if(type == "ta"){ nogyo = nogyo + naiseiEffectList[0]; }else if(type == "yr" ||type == "kb"||type == "tp" ||type == "ym"||type == "snb"){ int tempCalc = naiseiEffectList[0] * 2; gunjyu = gunjyu + tempCalc; }else if(type == "ashigaru"){ ashigaru = ashigaru + naiseiEffectList[0]; }else if(type == "trd"){ boubi = boubi + naiseiEffectList[0]; }else if(type == "kzn"){ int tempCalc = naiseiEffectList[0] * 4; syogyo = syogyo + tempCalc; }else if(type == "nbn"){ int tempCalc = naiseiEffectList[0]; kirisuto = kirisuto + tempCalc; }else if(type == "kgy"){ int tempCalc = naiseiEffectList[0]; bunka = bunka + tempCalc; }else if(type == "bky"){ int tempCalc = naiseiEffectList[0]; bukkyo = bukkyo + tempCalc; }else if(type == "hsy"){ int tempCalc = naiseiEffectList[0]; ashigaru = ashigaru + tempCalc; }else{ Debug.Log ("Not Yet"); } } } //Clear Duplicated Panel foreach ( Transform n in GameObject.Find ("NaiseiView").transform){ if(deletePanelList.Contains(n.name)){ if(n.tag == "Area"){ GameObject.Destroy(n.gameObject); } } } /*shiro setting*/ string rank = ""; if(int.Parse(naiseiList[0])<8){ rank = "s"; setShiro(rank, naiseiList[0]); }else if(int.Parse(naiseiList[0]) < 15){ rank = "m"; setShiro(rank, naiseiList[0]); }else if(15 <= int.Parse(naiseiList[0])){ rank = "l"; setShiro(rank, naiseiList[0]); } string maskPath = "Prefabs/Naisei/MaskPanel"; GameObject maskPanel = Instantiate (Resources.Load (maskPath)) as GameObject; maskPanel.transform.parent = GameObject.Find ("MaskView").transform; maskPanel.transform.localScale = new Vector3 (1, 1, 1); RectTransform maskPanel_transform = maskPanel.GetComponent<RectTransform>(); maskPanel_transform.anchoredPosition3D = new Vector3(0,-20,0); maskPanel.name = "shiro_" + rank; //Status Handling //Status Jyosyu Modification if (PlayerPrefs.HasKey (jyosyuTemp)) { StatusGet sts = new StatusGet(); int lv = PlayerPrefs.GetInt (jyosyuId.ToString()); float naiseiSts = (float)sts.getDfc(jyosyuId,lv); float hpSts = (float)sts.getHp(jyosyuId,lv); float atkSts = (float)sts.getAtk(jyosyuId,lv); float boubiSts = (hpSts + atkSts)/2; float tempSyogyo = (float)syogyo; tempSyogyo = tempSyogyo + (tempSyogyo * naiseiSts/200); float tempNogyo = (float)nogyo; tempNogyo = tempNogyo + (tempNogyo * naiseiSts/200); float tempBoubi = (float)boubi; tempBoubi = tempBoubi + (tempBoubi * naiseiSts/200); syogyo = (int)tempSyogyo; nogyo = (int)tempNogyo; boubi = (int)tempBoubi; } GameObject.Find("SyogyoValue").GetComponent<Text>().text = syogyo.ToString(); GameObject.Find("NougyoValue").GetComponent<Text>().text = nogyo.ToString(); GameObject.Find("GunjyuValue").GetComponent<Text>().text = gunjyu.ToString(); GameObject.Find("AshigaruValue").GetComponent<Text>().text = ashigaru.ToString(); GameObject.Find("BoubiValue").GetComponent<Text>().text = boubi.ToString(); GameObject.Find("BukkyoValue").GetComponent<Text>().text = bukkyo.ToString(); GameObject.Find("KirisutoValue").GetComponent<Text>().text = kirisuto.ToString(); GameObject.Find("BunkaValue").GetComponent<Text>().text = bunka.ToString(); GameObject.Find("BukkyoValue").GetComponent<Text>().text = bukkyo.ToString(); //jyosyu status update if (PlayerPrefs.HasKey (jyosyuTemp)) { int jyosyuId = PlayerPrefs.GetInt (jyosyuTemp); string heiTmp = "jyosyuHei" + jyosyuId; PlayerPrefs.SetInt (heiTmp,ashigaru); } string boubiTmp = "boubi" + activeKuniId; PlayerPrefs.SetInt (boubiTmp,boubi); } else { //Error Debug.Log ("ERROR"); } /***************************/ /*Tabibito Controller Start*/ /***************************/ tabibitoObj = GameObject.Find ("Tabibito").gameObject; loginTemp = "naiseiLoginDate" + activeKuniId.ToString (); string loginTimeString = PlayerPrefs.GetString (loginTemp); if (loginTimeString == null || loginTimeString == "") { loginTimeString = System.DateTime.Today.ToString (); PlayerPrefs.SetString (loginTemp,loginTimeString); PlayerPrefs.Flush(); } System.DateTime loginTime = System.DateTime.Parse (loginTimeString); System.TimeSpan span = System.DateTime.Today - loginTime; double spanDay = span.TotalDays; string counterTemp = "naiseiTabibitoCounter" + activeKuniId.ToString (); if (spanDay >= 1) { //Reset PlayerPrefs.SetInt (counterTemp,0); PlayerPrefs.Flush(); counter = 0; }else{ //Get Counted No counter = PlayerPrefs.GetInt (counterTemp,0); } //Set Tabibito Max total = (boubi + bukkyo + kirisuto + bunka)/10; remain = total - counter; tabibitoObj.transform.FindChild ("TabibitoMaxValue").GetComponent<Text> ().text = total.ToString (); tabibitoObj.transform.FindChild ("TabibitoCountDownValue").GetComponent<Text> ().text = remain.ToString (); /***************************/ /*Tabibito Controller End */ /***************************/ }
public void SyuppeiKuniScrollView(GameObject baseObj, string targetDaimyo, GameObject btn) { //View kuni which have openkuni GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject; string seiryoku = PlayerPrefs.GetString("seiryoku"); char[] delimiterChars = { ',' }; List <string> seiryokuList = new List <string>(); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); //my kuni int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); string myKuni = PlayerPrefs.GetString("clearedKuni"); List <int> myKuniList = new List <int>(); if (myKuni.Contains(",")) { List <string> tempMyKuniList = new List <string> (myKuni.Split(delimiterChars)); myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x)); } else { myKuniList.Add(int.Parse(myKuni)); } //doumei daimyo's opne kuni KuniInfo kuni = new KuniInfo(); List <int> doumeiOpenKuniList = new List <int>(); List <int> doumeiKuniList = new List <int>(); for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyo = seiryokuList[i]; if (tempDaimyo == targetDaimyo) { int doumeiKuniId = i + 1; doumeiKuniList.Add(doumeiKuniId); doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId)); } } //"doumei daimyo's doumei check string tempDoumei = "doumei" + targetDaimyo; string doumei = PlayerPrefs.GetString(tempDoumei); List <string> doumeiList = new List <string>(); if (doumei.Contains(",")) { doumeiList = new List <string> (doumei.Split(delimiterChars)); } else { doumeiList.Add(doumei); } //"doumei daimyo's opne kuni" minus "my kuni" /minus Doumei's doumei List <int> doumeiOpenKuniMinusMyKuniList = new List <int>(); foreach (int n in doumeiOpenKuniList) { if (!myKuniList.Contains(n)) { if (!doumeiKuniList.Contains(n)) { if (doumeiList.Count != 0) { string checkDaimyoId = seiryokuList [n - 1]; if (!doumeiList.Contains(checkDaimyoId)) { doumeiOpenKuniMinusMyKuniList.Add(n); } } else { doumeiOpenKuniMinusMyKuniList.Add(n); } } } } //delete duplication List <int> finalKuniList = new List <int>(); for (int i = 0; i < doumeiOpenKuniMinusMyKuniList.Count; i++) { int tmpKuniId = doumeiOpenKuniMinusMyKuniList [i]; if (!finalKuniList.Contains(tmpKuniId)) { finalKuniList.Add(tmpKuniId); } } //Src Kuni List List <int> srcKuniList = new List <int>(); for (int j = 0; j < finalKuniList.Count; j++) { int dstKuniId = finalKuniList [j]; List <int> targetKuniList = new List <int>(); targetKuniList.AddRange(kuni.getMappingKuni(dstKuniId)); for (int k = 0; k < targetKuniList.Count; k++) { int srcKuniId = targetKuniList [k]; if (doumeiKuniList.Contains(srcKuniId)) { srcKuniList.Add(srcKuniId); break; } } } /*Slot making*/ string temp = "gaikou" + targetDaimyo; int myYukoudo = PlayerPrefs.GetInt(temp); //Get Chiryaku //Entity_daimyo_mst daimyoMst = Resources.Load ("Data/daimyo_mst") as Entity_daimyo_mst; Daimyo daimyoScript = new Daimyo(); int myDaimyoBusyoId = daimyoScript.getDaimyoBusyoId(myDaimyo); BusyoInfoGet busyo = new BusyoInfoGet(); int chiryaku = busyo.getMaxDfc(myDaimyoBusyoId); string slotPath = "Prefabs/Map/common/kuniSlot"; for (int i = 0; i < finalKuniList.Count; i++) { GameObject prefab = Instantiate(Resources.Load(slotPath)) as GameObject; prefab.transform.SetParent(content.transform); prefab.transform.localScale = new Vector3(1, 1, 1); int kuniId = finalKuniList[i]; int daimyoId = int.Parse(seiryokuList [kuniId - 1]); string daimyoName = daimyoScript.getName(daimyoId); int srcKuniId = srcKuniList [i]; int srcDaimyoId = int.Parse(seiryokuList [srcKuniId - 1]); string srcDaimyoName = daimyoScript.getName(srcDaimyoId); string theirYukouTemp = ""; if (int.Parse(targetDaimyo) < daimyoId) { theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString(); } else { theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo; } int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp); string kuniName = kuni.getKuniName(kuniId); prefab.transform.FindChild("KuniValue").GetComponent <Text>().text = kuniName; prefab.transform.FindChild("DaimyoValue").GetComponent <Text>().text = daimyoName; prefab.GetComponent <GaikouKuniSelect>().Content = content; prefab.GetComponent <GaikouKuniSelect>().Btn = btn; prefab.GetComponent <GaikouKuniSelect>().myYukoudo = myYukoudo; prefab.GetComponent <GaikouKuniSelect>().chiryaku = chiryaku; prefab.GetComponent <GaikouKuniSelect>().kuniDiff = kuniDiff; prefab.GetComponent <GaikouKuniSelect>().theirYukoudo = theirYukoudo; prefab.GetComponent <GaikouKuniSelect>().kuniName = kuniName; prefab.GetComponent <GaikouKuniSelect>().targetKuniId = kuniId; prefab.GetComponent <GaikouKuniSelect>().targetDaimyoId = daimyoId; prefab.GetComponent <GaikouKuniSelect>().targetDaimyoName = daimyoName; prefab.GetComponent <GaikouKuniSelect>().srcKuniId = srcKuniId; prefab.GetComponent <GaikouKuniSelect>().srcDaimyoId = srcDaimyoId; prefab.GetComponent <GaikouKuniSelect>().srcDaimyoName = srcDaimyoName; if (i == 0) { prefab.GetComponent <GaikouKuniSelect>().OnClick(); } } if (finalKuniList.Count == 0) { string msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg"; GameObject msg = Instantiate(Resources.Load(msgPath)) as GameObject; msg.transform.SetParent(GameObject.Find("scroll").transform); msg.transform.localScale = new Vector3(0.17f, 0.2f, 1); RectTransform msgTransform = msg.GetComponent <RectTransform>(); msgTransform.anchoredPosition = new Vector3(-260, -115, 0); if (Application.systemLanguage != SystemLanguage.Japanese) { msg.GetComponent <Text>().text = "There is no available country.\nWe are surranded by allianced party."; } else { msg.GetComponent <Text>().text = "出兵可能な国はありませぬ\n周辺国は同盟大名しかおりませぬぞ"; } GameObject a = baseObj.transform.FindChild("RequiredMoney").gameObject; GameObject b = baseObj.transform.FindChild("KyoutouRatio").gameObject; Destroy(a); Destroy(b); btn.GetComponent <Button>().enabled = false; Color NGClorBtn = new Color(133 / 255f, 133 / 255f, 80 / 255f, 255f / 255f); Color NGClorTxt = new Color(90 / 255f, 90 / 255f, 40 / 255f, 255f / 255f); btn.GetComponent <Image>().color = NGClorBtn; btn.transform.FindChild("Text").GetComponent <Text>().color = NGClorTxt; btn.transform.FindChild("hyourouIcon").GetComponent <Image>().color = NGClorBtn; btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text>().color = NGClorTxt; btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").transform.FindChild("syouhiText").GetComponent <Text>().color = NGClorTxt; } }
public string serihuChanger(int shisyaId, string originalSerihu, List <string> shisyaParamList, GameObject slotObj) { string finalSerihu = ""; Daimyo daimyo = new Daimyo(); KuniInfo kuni = new KuniInfo(); if (shisyaId == 1 || shisyaId == 4 || shisyaId == 5 || shisyaId == 6 || shisyaId == 7 || shisyaId == 17) { string daimyoName = daimyo.getName(int.Parse(shisyaParamList [0])); if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = originalSerihu.Replace("ABC", daimyoName); } else { finalSerihu = originalSerihu.Replace("A", daimyoName); } slotObj.GetComponent <ShisyaSelect> ().srcDaimyoId = int.Parse(shisyaParamList [0]); slotObj.GetComponent <ShisyaSelect> ().srcDaimyoName = daimyoName; if (shisyaId == 5) { string itemName = slotObj.GetComponent <ShisyaSelect> ().itemName; if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = finalSerihu.Replace("DEF", itemName); } else { finalSerihu = finalSerihu.Replace("B", itemName); } } if (shisyaId == 7) { int randomMoney = UnityEngine.Random.Range(1, 6); randomMoney = randomMoney * 1000; slotObj.GetComponent <ShisyaSelect> ().moneyNo = randomMoney; if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = finalSerihu.Replace("DEF", randomMoney.ToString()); } else { finalSerihu = finalSerihu.Replace("B", randomMoney.ToString()); } } } else if (shisyaId == 8) { string daimyoName = daimyo.getName(int.Parse(shisyaParamList [0])); string kuniName = kuni.getKuniName(int.Parse(shisyaParamList [1])); if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = originalSerihu.Replace("ABC", daimyoName); finalSerihu = finalSerihu.Replace("DEF", kuniName); } else { finalSerihu = originalSerihu.Replace("A", daimyoName); finalSerihu = finalSerihu.Replace("B", kuniName); } slotObj.GetComponent <ShisyaSelect> ().key = shisyaParamList [2]; slotObj.GetComponent <ShisyaSelect> ().srcDaimyoId = int.Parse(shisyaParamList [0]); slotObj.GetComponent <ShisyaSelect> ().srcDaimyoName = daimyoName; slotObj.GetComponent <ShisyaSelect> ().targetKuniId = int.Parse(shisyaParamList [1]); slotObj.GetComponent <ShisyaSelect> ().targetKuniName = kuniName; } else if (shisyaId == 9) { string daimyoName = daimyo.getName(int.Parse(shisyaParamList [0])); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); string myDaimyoName = daimyo.getName(myDaimyo); if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = originalSerihu.Replace("ABC", daimyoName); finalSerihu = finalSerihu.Replace("DEF", myDaimyoName); } else { finalSerihu = originalSerihu.Replace("A", daimyoName); finalSerihu = finalSerihu.Replace("B", myDaimyoName); } slotObj.GetComponent <ShisyaSelect> ().srcDaimyoId = int.Parse(shisyaParamList [0]); slotObj.GetComponent <ShisyaSelect> ().srcDaimyoName = daimyoName; } else if (shisyaId == 3) { string srcDaimyoName = daimyo.getName(int.Parse(shisyaParamList[0])); string daimyoName = daimyo.getName(int.Parse(shisyaParamList [1])); string kuniName = kuni.getKuniName(int.Parse(shisyaParamList [2])); if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = originalSerihu.Replace("ABC", daimyoName); finalSerihu = finalSerihu.Replace("DEF", kuniName); } else { finalSerihu = originalSerihu.Replace("A", daimyoName); finalSerihu = finalSerihu.Replace("B", kuniName); } slotObj.GetComponent <ShisyaSelect> ().key = shisyaParamList [3]; slotObj.GetComponent <ShisyaSelect> ().dstDaimyoId = int.Parse(shisyaParamList [1]); slotObj.GetComponent <ShisyaSelect> ().dstDaimyoName = daimyoName; slotObj.GetComponent <ShisyaSelect>().srcDaimyoId = int.Parse(shisyaParamList[0]); slotObj.GetComponent <ShisyaSelect>().srcDaimyoName = srcDaimyoName; slotObj.GetComponent <ShisyaSelect> ().targetKuniId = int.Parse(shisyaParamList [2]); slotObj.GetComponent <ShisyaSelect> ().targetKuniName = kuniName; } else if (shisyaId == 10 || shisyaId == 11 || shisyaId == 12 || shisyaId == 14) { //Syogun int syogunId = PlayerPrefs.GetInt("syogunDaimyoId"); string syogunName = daimyo.getName(syogunId); if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = originalSerihu.Replace("ABC", syogunName); } else { finalSerihu = originalSerihu.Replace("A", syogunName); } slotObj.GetComponent <ShisyaSelect> ().syogunDaimyoId = syogunId; slotObj.GetComponent <ShisyaSelect> ().syogunDaimyoName = syogunName; if (shisyaId == 10 || shisyaId == 11 || shisyaId == 12) { string daimyoName = daimyo.getName(int.Parse(shisyaParamList [0])); if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = finalSerihu.Replace("DEF", daimyoName); } else { finalSerihu = finalSerihu.Replace("B", daimyoName); } slotObj.GetComponent <ShisyaSelect> ().srcDaimyoId = int.Parse(shisyaParamList [0]); slotObj.GetComponent <ShisyaSelect> ().srcDaimyoName = daimyoName; if (shisyaId == 12) { //Bouei string dstDaimyoName = daimyo.getName(int.Parse(shisyaParamList [1])); if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = finalSerihu.Replace("GHI", dstDaimyoName); } else { finalSerihu = finalSerihu.Replace("C", dstDaimyoName); } string dstKuniName = kuni.getKuniName(int.Parse(shisyaParamList [2])); if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = finalSerihu.Replace("JKL", dstKuniName); } else { finalSerihu = finalSerihu.Replace("D", dstKuniName); } slotObj.GetComponent <ShisyaSelect> ().dstDaimyoId = int.Parse(shisyaParamList [1]); slotObj.GetComponent <ShisyaSelect> ().dstDaimyoName = dstDaimyoName; slotObj.GetComponent <ShisyaSelect> ().targetKuniId = int.Parse(shisyaParamList [2]); slotObj.GetComponent <ShisyaSelect> ().targetKuniName = dstKuniName; slotObj.GetComponent <ShisyaSelect> ().key = shisyaParamList [3]; } } } else if (shisyaId == 19) { string itemName = slotObj.GetComponent <ShisyaSelect> ().itemName; if (Application.systemLanguage != SystemLanguage.Japanese) { finalSerihu = originalSerihu.Replace("ABC", itemName); } else { finalSerihu = originalSerihu.Replace("A", itemName); } } else { finalSerihu = originalSerihu; } return(finalSerihu); }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (name == "YesButton") { audioSources [0].Play(); GameObject kuniView = GameObject.Find("KuniIconView"); SendParam param = kuniView.transform.FindChild(kuniId.ToString()).GetComponent <SendParam>(); //adjust int busyoQty = param.busyoQty; int jinkeiBusyoQty = PlayerPrefs.GetInt("jinkeiBusyoQty"); if (busyoQty < jinkeiBusyoQty) { busyoQty = jinkeiBusyoQty; } int busyoLv = param.busyoLv; //adjsut int butaiQty = param.butaiQty; int jinkeiAveChQty = PlayerPrefs.GetInt("jinkeiAveChQty"); if (butaiQty < jinkeiAveChQty) { butaiQty = jinkeiAveChQty; } int butaiLv = param.butaiLv; //Dummy PlayerPrefs.SetInt("activeStageId", 0); PlayerPrefs.SetInt("activeStageMoney", busyoQty * busyoLv * 100); PlayerPrefs.SetInt("activeStageExp", busyoQty * busyoLv * 10); PlayerPrefs.SetString("activeItemType", ""); PlayerPrefs.SetInt("activeItemId", 0); PlayerPrefs.SetFloat("activeItemRatio", 0); PlayerPrefs.SetInt("activeItemQty", 0); PlayerPrefs.SetString("activeItemGrp", "no"); //Actual KuniInfo kuni = new KuniInfo(); string kassenName = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { kassenName = " Final Battle with " + daimyoName; } else { kassenName = daimyoName + "決戦"; } PlayerPrefs.SetString("activeStageName", kassenName); PlayerPrefs.SetInt("activeDaimyoId", daimyoId); PlayerPrefs.SetInt("activeBusyoQty", busyoQty); PlayerPrefs.SetInt("activeBusyoLv", busyoLv); PlayerPrefs.SetInt("activeButaiQty", butaiQty); PlayerPrefs.SetInt("activeButaiLv", butaiLv); //Flag PlayerPrefs.DeleteKey("isAttackedFlg"); PlayerPrefs.SetBool("isKessenFlg", true); PlayerPrefs.SetInt("kessenHyourou", needHyourouNo); //Player Doumei Flg PlayerPrefs.DeleteKey("playerEngunList"); //Enemy Doumei Handling PlayerPrefs.DeleteKey("enemyEngunList"); string doumeiTemp = "doumei" + daimyoId; string enemyDoumeiString = PlayerPrefs.GetString(doumeiTemp); char[] delimiterChars = { ',' }; List <string> doumeiList = new List <string>(); if (enemyDoumeiString != null && enemyDoumeiString != "") { if (enemyDoumeiString.Contains(",")) { doumeiList = new List <string> (enemyDoumeiString.Split(delimiterChars)); } else { doumeiList.Add(enemyDoumeiString); } } string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); Doumei doumei = new Doumei(); Gaikou gaikou = new Gaikou(); List <string> okDaimyoList = new List <string> (); List <string> checkedList = new List <string> (); string dstEngunDaimyoId = ""; string dstEngunSts = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv: okDaimyoList = doumei.traceNeighborDaimyo(kuniId, daimyoId, doumeiList, seiryokuList, checkedList, okDaimyoList); if (okDaimyoList.Count != 0) { for (int k = 0; k < okDaimyoList.Count; k++) { string engunDaimyo = okDaimyoList [k]; int yukoudo = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), daimyoId); //engun check MainEventHandler main = new MainEventHandler(); bool dstEngunFlg = main.CheckByProbability(yukoudo); if (dstEngunFlg) { //Engun OK dstEngunFlg = true; if (dstEngunDaimyoId != null && dstEngunDaimyoId != "") { dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo; string tempEngunSts = main.getEngunSts(engunDaimyo); dstEngunSts = dstEngunSts + ":" + engunDaimyo + "-" + tempEngunSts; } else { dstEngunDaimyoId = engunDaimyo; string tempEngunSts = main.getEngunSts(engunDaimyo); dstEngunSts = engunDaimyo + "-" + tempEngunSts; } } } PlayerPrefs.SetString("enemyEngunList", dstEngunSts); } //Delete "Start Kassen Flg" PlayerPrefs.DeleteKey("activeLink"); PlayerPrefs.SetInt("activePowerType", 3); PlayerPrefs.Flush(); Application.LoadLevel("preKassen"); } else { audioSources [1].Play(); Destroy(confirm.gameObject); Destroy(back.gameObject); } }
public void attack() { audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); //Same Daimyo Check int latestDaimyoId = kuniIconView.transform.FindChild(dstKuni.ToString()).GetComponent <SendParam> ().daimyoId; GameObject MsgBack = this.transform.FindChild("MsgBack").gameObject; GameObject MsgText = MsgBack.transform.FindChild("MsgText").gameObject; if (dstDaimyoId == latestDaimyoId) { if (dstDaimyoId != myDaimyoId) { audioSources [7].Play(); int enemyHei = heiryokuCalc(dstKuni); //Engun int engunTotalHei = 0; if (dstEngunFlg) { char[] delimiterChars2 = { ':' }; List <string> engunHeiList = new List <string>(); engunHeiList = new List <string> (dstEngunHei.Split(delimiterChars2)); for (int k = 0; k < engunHeiList.Count; k++) { engunTotalHei = engunTotalHei + int.Parse(engunHeiList[k]); } } enemyHei = enemyHei + engunTotalHei; int ratio = 0; if ((myHei + enemyHei) != 0) { ratio = 100 * myHei / (myHei + enemyHei); if (ratio < 1) { ratio = 1; } } MainEventHandler kassenEvent = new MainEventHandler(); bool winFlg = kassenEvent.CheckByProbability(ratio); //Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst; KuniInfo kuniScript = new KuniInfo(); string dstKuniName = kuniScript.getKuniName(dstKuni); //Gaikou Gaikou gaikou = new Gaikou(); gaikou.downGaikouByAttack(srcDaimyoId, dstDaimyoId); if (winFlg) { bool noGunzeiFlg = false; string syouhai = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { syouhai = srcDaimyoName + "\n" + "Conquered " + dstKuniName; } else { syouhai = srcDaimyoName + "\n" + dstKuniName + "を攻略"; } MsgBack.GetComponent <Image> ().enabled = true; MsgText.GetComponent <Text> ().enabled = true; MsgText.GetComponent <Text> ().text = syouhai; win(key, srcDaimyoId, dstDaimyoId, noGunzeiFlg, dstKuni); fire(dstKuni); } else { string syouhai = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { syouhai = dstDaimyoName + "\n" + "Defended " + dstKuniName; } else { syouhai = dstDaimyoName + "\n" + dstKuniName + "を防衛"; } MsgBack.GetComponent <Image> ().enabled = true; MsgText.GetComponent <Text> ().enabled = true; MsgText.GetComponent <Text> ().text = syouhai; gameObject.GetComponent <GunzeiFadeOut> ().enabled = true; MainStageController main = new MainStageController(); main.deleteKeyHistory(key); } } else { MyDaimyoWasAttacked atked = new MyDaimyoWasAttacked(); atked.wasAttacked(key, srcKuni, dstKuni, srcDaimyoId, dstDaimyoId, dstEngunFlg, dstEngunDaimyoId, dstEngunSts); } } else { audioSources [1].Play(); string syouhai = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { syouhai = srcDaimyoName + " withdrawed"; } else { syouhai = srcDaimyoName + "撤退"; } MsgBack.GetComponent <Image> ().enabled = true; MsgText.GetComponent <Text> ().enabled = true; MsgText.GetComponent <Text> ().text = syouhai; gameObject.GetComponent <GunzeiFadeOut> ().enabled = true; MainStageController main = new MainStageController(); main.deleteKeyHistory(key); } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); //Count cyouhou string cyouhou = PlayerPrefs.GetString("cyouhou"); if (cyouhou != null && cyouhou != "") { //SE audioSources[0].Play(); /*Popup*/ string backPath = "Prefabs/Busyo/back"; GameObject back = Instantiate(Resources.Load(backPath)) as GameObject; back.transform.SetParent(GameObject.Find("Map").transform); back.transform.localScale = new Vector2(1, 1); RectTransform backTransform = back.GetComponent <RectTransform> (); backTransform.anchoredPosition = new Vector3(0, 0, 0); //Popup Screen string popupPath = "Prefabs/Busyo/board"; GameObject popup = Instantiate(Resources.Load(popupPath)) as GameObject; popup.transform.SetParent(GameObject.Find("Map").transform); popup.transform.localScale = new Vector2(1, 1); RectTransform popupTransform = popup.GetComponent <RectTransform> (); popupTransform.anchoredPosition = new Vector3(0, 0, 0); popup.name = "board"; GameObject close = popup.transform.FindChild("close").gameObject; //qa string qaPath = "Prefabs/Common/Question"; GameObject qa = Instantiate(Resources.Load(qaPath)) as GameObject; qa.transform.SetParent(popup.transform); qa.transform.localScale = new Vector2(1, 1); RectTransform qaTransform = qa.GetComponent <RectTransform> (); qaTransform.anchoredPosition = new Vector3(-540, 285, 0); qa.name = "qa"; qa.GetComponent <QA> ().qaId = 4; //Pop text string popTextPath = "Prefabs/Busyo/popText"; GameObject popText = Instantiate(Resources.Load(popTextPath)) as GameObject; popText.transform.SetParent(popup.transform); popText.transform.localScale = new Vector2(0.35f, 0.35f); RectTransform popTextTransform = popText.GetComponent <RectTransform> (); popTextTransform.anchoredPosition = new Vector3(0, 275, 0); popText.name = "popText"; if (Application.systemLanguage != SystemLanguage.Japanese) { popText.GetComponent <Text>().text = "Spy"; } else { popText.GetComponent <Text>().text = "諜報"; } //kuni board string boardPath = "Prefabs/Map/cyouhou/CyouhouKuniBoard"; GameObject board = Instantiate(Resources.Load(boardPath)) as GameObject; board.transform.SetParent(popup.transform); board.transform.localScale = new Vector2(1, 1); RectTransform boardRect = board.GetComponent <RectTransform> (); boardRect.anchoredPosition3D = new Vector3(-257, -89, 0); string statusPath = "Prefabs/Map/cyouhou/CyouhouStatus"; GameObject status = Instantiate(Resources.Load(statusPath)) as GameObject; status.transform.SetParent(popup.transform); status.transform.localScale = new Vector2(1, 1); RectTransform statusRect = status.GetComponent <RectTransform> (); statusRect.anchoredPosition3D = new Vector3(293, -92, 0); //Scroll Preparation string cyouhouString = PlayerPrefs.GetString("cyouhou"); List <string> cyouhouList = new List <string> (); char[] delimiterChars = { ',' }; if (cyouhouString != null && cyouhouString != "") { if (cyouhouString.Contains(",")) { cyouhouList = new List <string> (cyouhouString.Split(delimiterChars)); } else { cyouhouList.Add(cyouhouString); } } //Scroll string popScrollPath = "Prefabs/Map/cyouhou/CyouhouScrollView"; GameObject scroll = Instantiate(Resources.Load(popScrollPath)) as GameObject; scroll.transform.SetParent(popup.transform); scroll.transform.localScale = new Vector2(1, 1); RectTransform scrollRect = scroll.GetComponent <RectTransform> (); scrollRect.anchoredPosition3D = new Vector3(0, 525, 0); //Seiryoku string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); string slotPath = "Prefabs/Map/cyouhou/CyouhouSlot"; GameObject content = scroll.transform.FindChild("Content").gameObject; KuniInfo kuni = new KuniInfo(); Daimyo daimyo = new Daimyo(); for (int i = 0; i < cyouhouList.Count; i++) { GameObject slot = Instantiate(Resources.Load(slotPath)) as GameObject; slot.transform.SetParent(content.transform); slot.transform.localScale = new Vector2(1, 1); string slotValue = ""; //Kuni Name int kuniId = int.Parse(cyouhouList [i]); string kuniName = kuni.getKuniName(kuniId); //Daimyo int daimyoId = int.Parse(seiryokuList [kuniId - 1]); string daimyoName = daimyo.getName(daimyoId); //Rank of Shinobi string snbTmp = "cyouhou" + kuniId.ToString(); string rankName = ""; int rank = PlayerPrefs.GetInt(snbTmp); if (rank == 1) { if (Application.systemLanguage == SystemLanguage.Japanese) { rankName = "下忍"; } else { rankName = "Ninja Low"; } } else if (rank == 2) { if (Application.systemLanguage == SystemLanguage.Japanese) { rankName = "中忍"; } else { rankName = "Ninja Mid"; } } else if (rank == 3) { if (Application.systemLanguage == SystemLanguage.Japanese) { rankName = "上忍"; } else { rankName = "Ninja High"; } } slotValue = kuniName + "\n" + daimyoName + "\n" + rankName; slot.transform.FindChild("Value").GetComponent <Text> ().text = slotValue; GameObject kamon = slot.transform.FindChild("Image").gameObject; string imagePath = "Prefabs/Kamon/" + daimyoId.ToString(); kamon.GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; //Parametor Setting CyouhouSelect script = slot.GetComponent <CyouhouSelect> (); script.kuniId = kuniId; script.kuniName = kuniName; script.daimyoId = daimyoId; script.daimyoName = daimyoName; script.snbRank = rank; script.board = board; script.status = status; script.close = close; script.seiryokuList = seiryokuList; if (i == 0) { slot.GetComponent <CyouhouSelect> ().OnClick(); } } } else { //Error audioSources [4].Play(); Message msg = new Message(); string txt = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { txt = "You don't have ninja spying in other country.\n Please get Ninja via trading or development your country."; } else { txt = "他国に潜伏中の忍はおりませんぞ。\n忍は他国との交易か、内政開発にて取得できます。"; } msg.makeMessage(txt); } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); Message msg = new Message(); if (name != "PassButton") { //Syoukaijyo Confirm Pop audioSources [0].Play(); //Back string pathOfBack = "Prefabs/Cyoutei/TouchBackLayer"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); //Cyoutei Pop string pathOfPop = "Prefabs/Cyoutei/SelectSyoukaijyoBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "SelectSyoukaijyoBoard"; back.GetComponent <CloseLayer> ().closeTargetObj = pop; back.GetComponent <CloseLayer> ().closeTargetBack = back; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetObj = pop; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetBack = back; //Check Syoukaijyo string nowQty = PlayerPrefs.GetString("cyoutei"); //string nowQty = "0,0,0"; List <string> nowQtyList = new List <string> (); char[] delimiterChars = { ',' }; nowQtyList = new List <string> (nowQty.Split(delimiterChars)); GameObject scrollView = pop.transform.FindChild("ScrollView").gameObject; GameObject content = scrollView.transform.FindChild("Content").gameObject; bool notZeroflg = false; //Jyo if (nowQtyList [2] == "0") { content.transform.FindChild("Jyo").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Jyo").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [2]; content.transform.FindChild("Jyo").GetComponent <SyoukaijyoSelect>().OnClick(); } //Cyu if (nowQtyList [1] == "0") { content.transform.FindChild("Cyu").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Cyu").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [1]; content.transform.FindChild("Cyu").GetComponent <SyoukaijyoSelect>().OnClick(); } //Ge if (nowQtyList [0] == "0") { content.transform.FindChild("Ge").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Ge").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [0]; content.transform.FindChild("Ge").GetComponent <SyoukaijyoSelect>().OnClick(); } if (!notZeroflg) { scrollView.transform.FindChild("NoSyoukaijyo").GetComponent <Text> ().enabled = true; pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = msg.getMessage(16); pop.transform.FindChild("PassButton").gameObject.SetActive(false); } pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().SelectSyoukaijyoBoard = pop; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().myDaimyoFlg = myDaimyoFlg; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().occupiedDaimyoId = occupiedDaimyoId; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().occupiedDaimyoName = occupiedDaimyoName; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().yukoudo = yukoudo; } else { //Cyoutei Main Pop int hyourou = PlayerPrefs.GetInt("hyourou"); if (hyourou >= 5) { int newHyourou = hyourou - 5; PlayerPrefs.SetInt("hyourou", newHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text>().text = newHyourou.ToString(); //Check Yukoudo int ratio = 100 - yukoudo; if (myDaimyoFlg) { ratio = 0; } float percent = Random.value; percent = percent * 100; if (percent > ratio) { //Stop Timer stopGunzei(); GameObject.Find("GameController").GetComponent <MainStageController>().eventStopFlg = true; audioSources [3].Play(); SelectSyoukaijyoBoard.transform.FindChild("CloseBtn").GetComponent <CloseLayer>().OnClick(); string pathOfBack = "Prefabs/Cyoutei/CyouteiBack"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); string pathOfPop = "Prefabs/Cyoutei/CyouteiBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "CyouteiBoard"; CloseLayer CloseLayerScript = pop.transform.FindChild("CloseSyoukaijyo").GetComponent <CloseLayer>(); CloseLayerScript.closeTargetBack = back; CloseLayerScript.closeTargetObj = pop; CloseLayerScript.syoukaijyoRank = syoukaijyoRank; CloseLayerScript.occupiedFlg = myDaimyoFlg; CloseLayerScript.syouninCyouteiFlg = true; //RandomValue int yukouAddValue = 0; int yukouReducePoint = Random.Range(2, 10); int stopBattleRatio = 0; int stopBattleReducePoint = Random.Range(2, 10); int kanniRatio = 0; int kanniReducePoint = Random.Range(20, 100); int syoukaijyoRankId = 0; int cyoutekiReducePoint = Random.Range(80, 100); //Change Menu by syoukaijyo rank GameObject action = pop.transform.FindChild("Action").gameObject; if (syoukaijyoRank == "Ge") { List <string> btnNameList = new List <string> () { "Bakuhu", "Cyouteki" }; enableButton(pop, btnNameList); yukouAddValue = Random.Range(1, 3); stopBattleRatio = Random.Range(10, 30); kanniRatio = Random.Range(20, 60); syoukaijyoRankId = 1; action.transform.FindChild("ActionValue").GetComponent <Text>().text = "1"; action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "1"; } else if (syoukaijyoRank == "Cyu") { List <string> btnNameList = new List <string> () { "Bakuhu", "Cyouteki" }; enableButton(pop, btnNameList); yukouAddValue = Random.Range(3, 8); stopBattleRatio = Random.Range(30, 80); kanniRatio = Random.Range(40, 80); syoukaijyoRankId = 2; action.transform.FindChild("ActionValue").GetComponent <Text>().text = "2"; action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "2"; } else if (syoukaijyoRank == "Jyo") { yukouAddValue = Random.Range(8, 15); stopBattleRatio = 100; kanniRatio = Random.Range(60, 100); syoukaijyoRankId = 3; action.transform.FindChild("ActionValue").GetComponent <Text>().text = "3"; action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "3"; } //TargetKanni Kanni kanni = new Kanni(); int kuniQty = GameObject.Find("GameController").GetComponent <MainStageController>().myKuniQty; int kanniId = kanni.getRandomKanni(syoukaijyoRankId, kuniQty); //TargetCyouteki string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); string openKuni = PlayerPrefs.GetString("openKuni"); List <string> openKuniList = new List <string> (); openKuniList = new List <string> (openKuni.Split(delimiterChars)); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); int cyoutekiDaimyoId = CloseLayerScript.cyoutekiDaimyo; //openKuniList.RemoveAll (x => x == occupiedDaimyoId.ToString()); //my kuni List <string> myKuniList = new List <string>(); List <string> occupiedDaimyoKuniList = new List <string>(); for (int i = 0; i < seiryokuList.Count; i++) { int tmpDaimyoId = int.Parse(seiryokuList [i]); if (tmpDaimyoId == myDaimyo) { int kuniId = i + 1; myKuniList.Add(kuniId.ToString()); } else if (tmpDaimyoId == occupiedDaimyoId) { int kuniId = i + 1; occupiedDaimyoKuniList.Add(kuniId.ToString()); } } openKuniList.RemoveAll(myKuniList.Contains); openKuniList.RemoveAll(occupiedDaimyoKuniList.Contains); int rdmId = UnityEngine.Random.Range(0, openKuniList.Count); int targetKuniId = int.Parse(openKuniList[rdmId]); int cyoutekiDaimyo = int.Parse(seiryokuList[targetKuniId - 1]); //reduce cyoutei syoukaijyo DoSell script = new DoSell(); script.deleteKouekiOrCyoutei(syoukaijyoRankId, "cyoutei", 1); //Set Parametor CloseLayerScript.yukouAddValue = yukouAddValue; CloseLayerScript.yukouReducePoint = yukouReducePoint; CloseLayerScript.stopBattleRatio = stopBattleRatio; CloseLayerScript.stopBattleReducePoint = stopBattleReducePoint; CloseLayerScript.kanniId = kanniId; if (kanniId != 0) { CloseLayerScript.kanniName = kanni.getKanniName(kanniId); CloseLayerScript.kanniRatio = kanniRatio; CloseLayerScript.kanniReducePoint = kanniReducePoint; } CloseLayerScript.cyoutekiDaimyo = cyoutekiDaimyo; CloseLayerScript.cyoutekiReducePoint = cyoutekiReducePoint; //Cyoutei Point int cyouteiPoint = PlayerPrefs.GetInt("cyouteiPoint"); pop.transform.FindChild("CyouteiPoint").transform.FindChild("CyouteiValue").GetComponent <Text>().text = cyouteiPoint.ToString() + "%"; bool doneFirstCyouteiFlg = PlayerPrefs.GetBool("doneFirstCyouteiFlg"); Daimyo daimyo = new Daimyo(); if (!doneFirstCyouteiFlg) { //1st time PlayerPrefs.SetBool("questSpecialFlg5", true); PlayerPrefs.SetBool("doneFirstCyouteiFlg", true); KuniInfo kuni = new KuniInfo(); int kuniId = kuni.getOneKuniId(myDaimyo); int firstKanniId = kanni.getKuniKanni(kuniId); string firstKanniName = kanni.getKanniName(firstKanniId); string myKanni = PlayerPrefs.GetString("myKanni"); if (myKanni != null && myKanni != "") { myKanni = myKanni + "," + firstKanniId.ToString(); } else { myKanni = firstKanniId.ToString(); } PlayerPrefs.SetString("myKanni", myKanni); PlayerPrefs.Flush(); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Your good rumor has arrived to the Imperial court. Please lend me your power for the world.\n I assigned you as " + firstKanniName + "."; } else { serihu = "天下静謐のため力を貸してくれ。\n" + firstKanniName + "に任ずるぞ。"; } pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text>().text = serihu; } else { //2nd time //Serihu string daimyoName = daimyo.getName(myDaimyo); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Lord " + daimyoName + ".\n What do you want?"; } else { serihu = "おお、" + daimyoName + "殿。\n此度は何用か。"; } pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text>().text = serihu; } } else { audioSources [4].Play(); if (Application.systemLanguage != SystemLanguage.Japanese) { msg.makeMessage("My lord " + occupiedDaimyoName + " disturbed us to visit coart."); } else { msg.makeMessage("御屋形様、" + occupiedDaimyoName + "めに参内を邪魔されました。"); } } } else { audioSources [4].Play(); //string NGtext = msg.getMessage(7); //msg.makeMessage (NGtext); msg.hyourouMovieMessage(); } } }
public void createSyoguView(string busyoId){ int lv = PlayerPrefs.GetInt (busyoId); Color ngImageColor = new Color (40f / 255f, 40f / 255f, 40f / 255f, 180f / 255f); Color ngTextColor = new Color (90f / 255f, 90f / 255f, 90f / 255f, 90f / 255f); Color okImageColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 150f / 255f); Color okTextColor = new Color (40f / 255f, 40f / 255f, 0f / 255f, 255f / 255f); GameObject kanjyo = GameObject.Find("kanjyo").gameObject; GameObject tsuihou = GameObject.Find("tsuihou").gameObject; int daimyoBusyoId = PlayerPrefs.GetInt ("myDaimyoBusyo"); if (busyoId == daimyoBusyoId.ToString ()) { kanjyo.GetComponent<Image> ().color = ngImageColor; kanjyo.transform.FindChild ("Text").GetComponent<Text> ().color = ngTextColor; kanjyo.GetComponent<Button> ().enabled = false; tsuihou.GetComponent<Image> ().color = ngImageColor; tsuihou.transform.FindChild ("Text").GetComponent<Text> ().color = ngTextColor; tsuihou.GetComponent<Button> ().enabled = false; } else { if (lv != 100) { kanjyo.GetComponent<BusyoStatusButton> ().pa_lv = lv; kanjyo.GetComponent<Image> ().color = okImageColor; kanjyo.transform.FindChild ("Text").GetComponent<Text> ().color = okTextColor; kanjyo.GetComponent<Button> ().enabled = true; } else { kanjyo.GetComponent<Image> ().color = ngImageColor; kanjyo.transform.FindChild ("Text").GetComponent<Text> ().color = ngTextColor; kanjyo.GetComponent<Button> ().enabled = false; } tsuihou.GetComponent<Image> ().color = okImageColor; tsuihou.transform.FindChild ("Text").GetComponent<Text> ().color = okTextColor; tsuihou.GetComponent<Button> ().enabled = true; } GameObject kanni = GameObject.Find("kanni").gameObject; GameObject jyosyu = GameObject.Find("jyosyu").gameObject; GameObject syugyo = GameObject.Find("syugyo").gameObject; GameObject gokui = GameObject.Find("gokui").gameObject; kanni.GetComponent<RonkouKousyoMenu>().busyoId = busyoId; jyosyu.GetComponent<RonkouKousyoMenu>().busyoId = busyoId; syugyo.GetComponent<RonkouKousyoMenu>().busyoId = busyoId; gokui.GetComponent<RonkouKousyoMenu>().busyoId = busyoId; //Kanni string kanniTmp = "kanni" + busyoId; Kanni kanniScript = new Kanni(); if (PlayerPrefs.HasKey (kanniTmp)) { int kanniId = PlayerPrefs.GetInt (kanniTmp); if (kanniId != 0) { foreach(Transform n in kanni.transform){ if(n.name == "KanniName"){ Destroy(n.gameObject); } } kanni.GetComponent<RonkouKousyoMenu> ().kanniId = kanniId; string path = "Prefabs/Busyo/KanniName"; GameObject kanniName = Instantiate (Resources.Load (path)) as GameObject; kanniName.transform.SetParent (kanni.transform); kanniName.transform.localScale = new Vector2 (0.12f, 0.12f); kanniName.transform.localPosition = new Vector2 (0, 0); kanniName.name = "KanniName"; string kanniNameString = kanniScript.getKanni(kanniId); string kanniIkai = kanniScript.getIkai(kanniId); kanniName.transform.FindChild("value").GetComponent<Text>().text = kanniIkai + "\t" + kanniNameString; string effectLabel = kanniScript.getEffectLabel(kanniId); int effect = kanniScript.getEffect(kanniId); kanniName.transform.FindChild("effectLabel").GetComponent<Text>().text = effectLabel; kanniName.transform.FindChild("effectValue").GetComponent<Text>().text = "+" + effect.ToString() + "%"; kanni.transform.FindChild ("Text").GetComponent<Text> ().enabled = false; } } else { foreach(Transform n in kanni.transform){ if(n.name == "KanniName"){ Destroy(n.gameObject); } } kanni.GetComponent<RonkouKousyoMenu> ().kanniId = 0; kanni.transform.FindChild ("Text").GetComponent<Text> ().enabled = true; } //Jyosyu string jyosyuTmp = "jyosyuBusyo" + busyoId; if (PlayerPrefs.HasKey (jyosyuTmp)) { BusyoInfoGet busyoInfo = new BusyoInfoGet (); string busyoName = busyoInfo.getName (int.Parse(busyoId)); jyosyu.GetComponent<RonkouKousyoMenu>().jyosyuName = busyoName; int kuniId = PlayerPrefs.GetInt(jyosyuTmp); if(kuniId !=0){ foreach(Transform n in jyosyu.transform){ if(n.name == "JyosyuName"){ Destroy(n.gameObject); } } KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); string jyosyuHeiTmp = "jyosyuHei" + busyoId; int jyosyuHei = PlayerPrefs.GetInt(jyosyuHeiTmp); jyosyu.GetComponent<RonkouKousyoMenu>().jyosyuKuniId = kuniId; string jyosyuPath = "Prefabs/Busyo/JyosyuName"; GameObject jyosyuName = Instantiate (Resources.Load (jyosyuPath)) as GameObject; jyosyuName.transform.SetParent (jyosyu.transform); jyosyuName.transform.localScale = new Vector2 (0.12f, 0.12f); jyosyuName.transform.localPosition = new Vector2 (0, 0); jyosyuName.name = "JyosyuName"; jyosyuName.transform.FindChild("value").GetComponent<Text>().text = kuniName; jyosyuName.transform.FindChild("effectValue").GetComponent<Text>().text = "+" + jyosyuHei.ToString(); jyosyu.transform.FindChild ("Text").GetComponent<Text> ().enabled = false; } } else { foreach(Transform n in jyosyu.transform){ if(n.name == "JyosyuName"){ Destroy(n.gameObject); } } jyosyu.GetComponent<RonkouKousyoMenu> ().jyosyuKuniId = 0; jyosyu.transform.FindChild ("Text").GetComponent<Text> ().enabled = true; } }
public void upYukoudo(int addYukoudo) { //Daimyo Id int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); //Seiryoku List string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); //src daimyo kuni list List <string> srcDaimyoKuniList = new List <string> (); for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyoId = seiryokuList[i]; if (tempDaimyoId == myDaimyoId.ToString()) { int temp = i + 1; srcDaimyoKuniList.Add(temp.ToString()); } } //src daimyo open kuni list KuniInfo kuni = new KuniInfo(); List <int> openKuniList = new List <int>(); for (int j = 0; j < srcDaimyoKuniList.Count; j++) { openKuniList.AddRange(kuni.getMappingKuni(int.Parse(srcDaimyoKuniList[j]))); } //Target Daimyo (exculde this src daimyo & mydaimyo) List <int> dstDaimyoList = new List <int>(); for (int k = 0; k < openKuniList.Count; k++) { int temp = openKuniList[k] - 1; int tempDaimyoId = int.Parse(seiryokuList[temp]); if (tempDaimyoId != myDaimyoId) { if (!dstDaimyoList.Contains(tempDaimyoId)) { dstDaimyoList.Add(tempDaimyoId); } } } //Add Yukoudo MainEventHandler main = new MainEventHandler(); Daimyo daimyo = new Daimyo(); string cyouteiText = ""; for (int l = 0; l < dstDaimyoList.Count; l++) { int dstDaimyoId = dstDaimyoList[l]; string dstDaimyoName = daimyo.getName(dstDaimyoId); string tempGaikou = "gaikou" + dstDaimyoId; int nowYukoudo = 0; if (PlayerPrefs.HasKey(tempGaikou)) { nowYukoudo = PlayerPrefs.GetInt(tempGaikou); } else { nowYukoudo = 50; } int newYukoudo = nowYukoudo + addYukoudo; if (newYukoudo > 100) { newYukoudo = 100; } PlayerPrefs.SetInt(tempGaikou, newYukoudo); if (Application.systemLanguage != SystemLanguage.Japanese) { cyouteiText = cyouteiText + "Friendship with " + dstDaimyoName + " increased " + addYukoudo + " point\n"; } else { cyouteiText = cyouteiText + dstDaimyoName + "との友好度が" + addYukoudo + "上がりました。\n"; } } PlayerPrefs.Flush(); //Message Message msg = new Message(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Friendship with surrounded families increased.\n " + cyouteiText; } else { OKtext = "周辺大名との友好度が上がります。\n " + cyouteiText; } msg.makeMessage(OKtext); }
public void OnClick(){ BusyoStatusButton bsb = new BusyoStatusButton (); if (name == "kanni") { if(kanniId ==0){ string myKanni = PlayerPrefs.GetString("myKanni"); if(myKanni != null && myKanni !=""){ bsb.commonPopup (); GameObject.Find ("popText").GetComponent<Text> ().text ="官位一覧"; string scrollPath = "Prefabs/Busyo/KanniScrollView"; GameObject scroll = Instantiate (Resources.Load (scrollPath)) as GameObject; scroll.transform.SetParent(GameObject.Find ("board(Clone)").transform); scroll.transform.localScale = new Vector2 (1, 1); scroll.name = "KanniScrollView"; RectTransform scrollTransform = scroll.GetComponent<RectTransform> (); scrollTransform.anchoredPosition3D = new Vector3 (0, 0, 0); List<string> myKanniList = new List<string> (); if(myKanni.Contains(",")){ char[] delimiterChars = {','}; myKanniList = new List<string> (myKanni.Split (delimiterChars)); }else{ myKanniList.Add(myKanni); } myKanniList.Sort(); string pathSlot = "Prefabs/Busyo/KanniSlot"; Kanni kanni = new Kanni(); GameObject content = scroll.transform.FindChild("KanniContent").gameObject; for(int i=0; i<myKanniList.Count; i++){ GameObject slot = Instantiate (Resources.Load (pathSlot)) as GameObject; slot.transform.SetParent(content.transform); slot.transform.localScale = new Vector2 (1, 1); int kanniIdTmp = int.Parse(myKanniList[i]); string kanniName = kanni.getKanni(kanniIdTmp); string kanniIkai = kanni.getIkai(kanniIdTmp); string EffectLabel = kanni.getEffectLabel(kanniIdTmp); int effect = kanni.getEffect(kanniIdTmp); slot.transform.FindChild("Name").GetComponent<Text>().text = kanniIkai + "\t" + kanniName; slot.transform.FindChild("EffectLabel").GetComponent<Text>().text = EffectLabel; slot.transform.FindChild("EffectValue").GetComponent<Text>().text = "+" + effect.ToString() + "%"; GameObject btn = slot.transform.FindChild("GiveButton").gameObject; btn.GetComponent<GiveKanni>().busyoId = busyoId; btn.GetComponent<GiveKanni>().kanniId = kanniIdTmp; } }else{ Message msg = new Message(); msg.makeMessage("官位を持っておりませんぞ。\n山城国にある朝廷を訪れてみましょう。"); } }else{ string backPath = "Prefabs/Busyo/back"; GameObject back = Instantiate (Resources.Load (backPath)) as GameObject; back.transform.SetParent(GameObject.Find ("Panel").transform); back.transform.localScale = new Vector2 (1, 1); RectTransform backTransform = back.GetComponent<RectTransform> (); backTransform.anchoredPosition3D = new Vector3 (0, 0, 0); string removePath = "Prefabs/Busyo/KanniRemoveConfirm"; GameObject remove = Instantiate (Resources.Load (removePath)) as GameObject; remove.transform.SetParent(GameObject.Find ("Panel").transform); remove.transform.localScale = new Vector2 (1, 1); remove.transform.localPosition = new Vector3(0,0,0); remove.name = "KanniRemoveConfirm"; BusyoInfoGet busyo = new BusyoInfoGet(); string busyoName = busyo.getName(int.Parse(busyoId)); remove.transform.FindChild("YesButton").GetComponent<DoRemoveKanni>().busyoId = busyoId; remove.transform.FindChild("RemoveText").GetComponent<Text>().text = busyoName + "殿の官位を\n罷免なさるのですか?"; } }else if(name == "jyosyu"){ if(jyosyuKuniId ==0){ //Available Kuni string openKuniString = PlayerPrefs.GetString ("openKuni"); char[] delimiterChars = {','}; List<string> openKuniList = new List<string> (); if (openKuniString.Contains (",")) { openKuniList = new List<string> (openKuniString.Split (delimiterChars)); } else { openKuniList.Add(openKuniString); } List<string> okKuniList = new List<string> (); for (int i=0; i<openKuniList.Count; i++) { int kuniId = int.Parse(openKuniList[i]); string temp = "kuni" + kuniId.ToString(); string clearedKuni = PlayerPrefs.GetString (temp); //Shiro Qty if(clearedKuni != null && clearedKuni != ""){ //Jyosyu Exist Check string jyosyuTmp = "jyosyu" + kuniId.ToString(); if(!PlayerPrefs.HasKey(jyosyuTmp)){ okKuniList.Add(kuniId.ToString()); } } } if(okKuniList.Count != 0){ bsb.commonPopup (); GameObject.Find ("popText").GetComponent<Text> ().text ="国一覧"; string scrollPath = "Prefabs/Busyo/KanniScrollView"; GameObject scroll = Instantiate (Resources.Load (scrollPath)) as GameObject; scroll.transform.SetParent(GameObject.Find ("board(Clone)").transform); scroll.transform.localScale = new Vector2 (1, 1); scroll.name = "KanniScrollView"; RectTransform scrollTransform = scroll.GetComponent<RectTransform> (); scrollTransform.anchoredPosition3D = new Vector3 (0, 0, 0); string pathSlot = "Prefabs/Busyo/ShiroSlot"; GameObject content = scroll.transform.FindChild("KanniContent").gameObject; KuniInfo kuni = new KuniInfo(); for(int i=0; i<okKuniList.Count; i++){ GameObject slot = Instantiate (Resources.Load (pathSlot)) as GameObject; slot.transform.SetParent(content.transform); slot.transform.localScale = new Vector2 (1, 1); int kuniId = int.Parse(okKuniList[i]); string kuniName = kuni.getKuniName(kuniId); slot.transform.FindChild("Name").GetComponent<Text>().text = kuniName; //Status int jyosyuHei = 0; string naiseiTemp = "naisei" + kuniId.ToString(); string naiseiString = PlayerPrefs.GetString (naiseiTemp); List<string> naiseiList = new List<string>(); naiseiList = new List<string>(naiseiString.Split (delimiterChars)); char[] delimiterChars2 = {':'}; Entity_naisei_mst naiseiMst = Resources.Load ("Data/naisei_mst") as Entity_naisei_mst; NaiseiController naisei = new NaiseiController(); string shiroLv = naiseiList[0]; List<int> shiroEffectList = new List<int>(); shiroEffectList = naisei.getNaiseiList("shiro", int.Parse(shiroLv)); jyosyuHei = shiroEffectList[0]; for(int j=1; j<naiseiList.Count;j++){ List<string> naiseiContentList = new List<string>(); naiseiContentList = new List<string>(naiseiList[j].Split (delimiterChars2)); if(naiseiContentList[0] != "0"){ string type = naiseiMst.param [int.Parse(naiseiContentList[0])].code; if(type == "hsy"){ List<int> naiseiEffectList = new List<int>(); naiseiEffectList = naisei.getNaiseiList(type, int.Parse(naiseiContentList[1])); jyosyuHei = jyosyuHei + naiseiEffectList[0]; } } } slot.transform.FindChild("EffectValue").GetComponent<Text>().text = "+" + jyosyuHei.ToString(); GameObject btn = slot.transform.FindChild("GiveButton").gameObject; btn.GetComponent<DoNinmei>().busyoId = busyoId; btn.GetComponent<DoNinmei>().kuniId = kuniId; btn.GetComponent<DoNinmei>().jyosyuHei = jyosyuHei; } }else{ Message msg = new Message(); msg.makeMessage("任命可能な国はありませんぞ。\nまずは城を落としなされ。"); } }else{ string backPath = "Prefabs/Common/TouchBack"; GameObject back = Instantiate (Resources.Load (backPath)) as GameObject; back.transform.SetParent(GameObject.Find ("Panel").transform); back.transform.localScale = new Vector2 (1, 1); RectTransform backTransform = back.GetComponent<RectTransform> (); backTransform.anchoredPosition3D = new Vector3 (0, 0, 0); back.name = "TouchBack"; //Message Box string msgPath = "Prefabs/Naisei/KaininConfirm"; GameObject msg = Instantiate (Resources.Load (msgPath)) as GameObject; msg.transform.SetParent(back.transform); msg.transform.localScale = new Vector2 (1, 1); RectTransform msgTransform = msg.GetComponent<RectTransform> (); msgTransform.anchoredPosition3D = new Vector3 (0, 0, 0); msgTransform.name = "kaininConfirm"; msg.transform.FindChild("YesButton").GetComponent<DoKainin>().kuniId = jyosyuKuniId; //Message Text Mod GameObject msgObj = msg.transform.FindChild ("KaininText").gameObject; int myDaimyoBusyo = PlayerPrefs.GetInt ("myDaimyoBusyo"); string msgText = msgObj.GetComponent<Text> ().text; if (myDaimyoBusyo == int.Parse(busyoId)) { msgText = msgText.Replace("A殿を", "自らを"); } else { msgText = msgText.Replace("A", jyosyuName); } msgObj.GetComponent<Text> ().text = msgText; } } }
public void createBusyoStatusView(string busyoId){ int lv = PlayerPrefs.GetInt (busyoId); StatusGet sts = new StatusGet (); int hp = sts.getHp (int.Parse (busyoId), lv); int atk = sts.getAtk (int.Parse (busyoId), lv); int dfc = sts.getDfc (int.Parse (busyoId), lv); int spd = sts.getSpd (int.Parse (busyoId), lv); int adjHp = hp * 100; int adjAtk = atk * 10; int adjDfc = dfc * 10; GameObject.Find ("LvValue").GetComponent<Text> ().text = lv.ToString (); GameObject.Find ("TosotsuValue").GetComponent<Text> ().text = adjHp.ToString (); GameObject.Find ("BuyuuValue").GetComponent<Text> ().text = adjAtk.ToString (); GameObject.Find ("ChiryakuValue").GetComponent<Text> ().text = adjDfc.ToString (); GameObject.Find ("SpeedValue").GetComponent<Text> ().text = spd.ToString (); //Exp string expId = "exp" + busyoId.ToString (); string expString = ""; int nowExp = PlayerPrefs.GetInt(expId); Exp exp = new Exp (); int requiredExp = 0; if (lv != 100) { requiredExp = exp.getExpforNextLv (lv); } else { requiredExp = exp.getExpLv100(); } expString = nowExp + "/" + requiredExp; GameObject.Find ("ExpValue").GetComponent<Text> ().text = expString; //Kahou status KahouStatusGet kahouSts = new KahouStatusGet (); string[] KahouStatusArray =kahouSts.getKahouForStatus (busyoId,adjHp,adjAtk,adjDfc,spd); int totalBusyoHp =0; //Kanni string kanniTmp = "kanni" + busyoId; float addAtkByKanni = 0; float addHpByKanni = 0; float addDfcByKanni = 0; if (PlayerPrefs.HasKey (kanniTmp)) { int kanniId = PlayerPrefs.GetInt (kanniTmp); Kanni kanni = new Kanni (); string kanniIkai = kanni.getIkai (kanniId); string kanniName = kanni.getKanni (kanniId); GameObject.Find ("StatusKanni").transform.FindChild ("Value").GetComponent<Text> ().text = kanniIkai + "\n" + kanniName; //Status string kanniTarget = kanni.getEffectTarget(kanniId); int effect = kanni.getEffect(kanniId); if(kanniTarget=="atk"){ addAtkByKanni = ((float)adjAtk * (float)effect)/100; }else if(kanniTarget=="hp"){ addHpByKanni = ((float)adjHp * (float)effect)/100; }else if(kanniTarget=="dfc"){ addDfcByKanni = ((float)adjDfc * (float)effect)/100; } } else { GameObject.Find ("StatusKanni").transform.FindChild ("Value").GetComponent<Text> ().text = "官位無し"; } //Jyosyu string jyosyuTmp = "jyosyuBusyo" + busyoId; if (PlayerPrefs.HasKey (jyosyuTmp)) { int kuniId = PlayerPrefs.GetInt(jyosyuTmp); KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); GameObject.Find ("StatusJyosyu").transform.FindChild ("Value").GetComponent<Text> ().text = kuniName + "\n城主"; } else { GameObject.Find ("StatusJyosyu").transform.FindChild ("Value").GetComponent<Text> ().text = "城無し"; } //Show Additional Status int finalAtk = int.Parse (KahouStatusArray [0]) + Mathf.FloorToInt (addAtkByKanni); int finalHp = int.Parse (KahouStatusArray [1]) + Mathf.FloorToInt (addHpByKanni); int finalDfc= int.Parse (KahouStatusArray [2]) + Mathf.FloorToInt (addDfcByKanni); int finalSpd = int.Parse (KahouStatusArray [3]); GameObject.Find ("KahouAtkValue").GetComponent<Text> ().text = "+" + finalAtk.ToString (); GameObject.Find ("KahouHpValue").GetComponent<Text>().text = "+" + finalHp.ToString(); totalBusyoHp = adjHp + finalHp; GameObject.Find ("KahouDfcValue").GetComponent<Text>().text = "+" + finalDfc.ToString(); GameObject.Find ("KahouSpdValue").GetComponent<Text>().text = "+" + finalSpd.ToString(); //Butai Status string heiId = "hei" + busyoId.ToString (); string chParam = PlayerPrefs.GetString (heiId, "0"); char[] delimiterChars = {':'}; string[] ch_list = chParam.Split (delimiterChars); string ch_type = ch_list [0]; int ch_num = int.Parse (ch_list [1]); int ch_lv = int.Parse (ch_list [2]); float ch_status = float.Parse (ch_list [3]); string heisyu = ""; if (ch_type == "KB") { heisyu = "騎馬隊"; } else if (ch_type == "YR") { heisyu = "槍隊"; } else if (ch_type == "TP") { heisyu = "鉄砲隊"; } else if (ch_type == "YM") { heisyu = "弓隊"; } GameObject.Find ("ChildNameValue").GetComponent<Text> ().text = heisyu; GameObject.Find ("ChildQtyValue").GetComponent<Text> ().text = ch_num.ToString (); GameObject.Find ("ChildLvValue").GetComponent<Text> ().text = ch_lv.ToString (); //Jyosyu Handling JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku (); float addHei = (float)jyosyuHei.GetJyosyuHeiryoku (busyoId); float hei = ch_status * 10; string heiText = hei.ToString() + "<size=150><Color=#35D74BFF>+" + addHei + "</Color></size>"; GameObject.Find ("ChildHeiryokuValue").GetComponent<Text> ().text = heiText; int chAtkDfc = (int)sts.getChAtkDfc ((int)hei, totalBusyoHp); string chAtkDfcString = chAtkDfc.ToString () + "/" + chAtkDfc.ToString (); GameObject.Find ("ChildStatusValue").GetComponent<Text> ().text = chAtkDfcString; //Child Image foreach (Transform n in GameObject.Find ("Img").transform) { GameObject.Destroy (n.gameObject); } string chPath = "Prefabs/Player/Unit/" + ch_type; GameObject chObj = Instantiate (Resources.Load (chPath)) as GameObject; chObj.transform.SetParent(GameObject.Find ("Img").transform); RectTransform chTransform = chObj.GetComponent<RectTransform> (); chTransform.anchoredPosition3D = new Vector3 (-200, -50, 0); chTransform.sizeDelta = new Vector2 (40, 40); chObj.transform.localScale = new Vector2 (4, 4); GameObject chigyo = GameObject.Find ("ButtonCyouhei"); chigyo.GetComponent<BusyoStatusButton> ().ch_type = ch_type; chigyo.GetComponent<BusyoStatusButton> ().ch_heisyu = heisyu; chigyo.GetComponent<BusyoStatusButton> ().ch_num = ch_num; chigyo.GetComponent<BusyoStatusButton> ().ch_status = chAtkDfc; chigyo.GetComponent<BusyoStatusButton> ().ch_hp = hei; chigyo.GetComponent<BusyoStatusButton> ().pa_hp = totalBusyoHp/100; GameObject kunren = GameObject.Find ("ButtonKunren"); kunren.GetComponent<BusyoStatusButton> ().ch_type = ch_type; kunren.GetComponent<BusyoStatusButton> ().ch_heisyu = heisyu; kunren.GetComponent<BusyoStatusButton> ().ch_lv = ch_lv; kunren.GetComponent<BusyoStatusButton> ().ch_status = chAtkDfc; kunren.GetComponent<BusyoStatusButton> ().ch_hp = hei ; kunren.GetComponent<BusyoStatusButton> ().ch_num = ch_num; kunren.GetComponent<BusyoStatusButton> ().pa_hp = totalBusyoHp/100; //Parametor Setting GameObject.Find ("GameScene").GetComponent<NowOnBusyo>().OnBusyo = busyoId; }
public void OnClick() { Daimyo daimyo = new Daimyo(); audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (name == "YesButton") { //Hyourou int hyourou = PlayerPrefs.GetInt("hyourou"); int newHyourou = hyourou - 30; PlayerPrefs.SetInt("hyourou", newHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString(); //Soubuji Flg PlayerPrefs.SetBool("soubujireiFlg", true); //Listup string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); MainStageController script = GameObject.Find("GameController").GetComponent <MainStageController> (); int myKuniQty = script.myKuniQty; int myDaimyo = script.myDaimyo; List <int> daimyoIdList = new List <int> (); List <int> mainKuniIdList = new List <int> (); List <int> kuniQtyByDaimyoId = new List <int> () { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (int i = 0; i < seiryokuList.Count; i++) { int daimyoId = int.Parse(seiryokuList [i]); if (daimyoId != myDaimyo) { int kuniId = i + 1; if (!daimyoIdList.Contains(daimyoId)) { daimyoIdList.Add(daimyoId); mainKuniIdList.Add(kuniId); } kuniQtyByDaimyoId [daimyoId - 1] = kuniQtyByDaimyoId [daimyoId - 1] + 1; } } //Do Soubujirei List <string> newSeiryokuList = new List <string> (seiryokuList); string clearedKuni = PlayerPrefs.GetString("clearedKuni"); KuniInfo kuni = new KuniInfo(); GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject; GameObject panel = GameObject.Find("Panel").gameObject; GameObject kuniMap = GameObject.Find("KuniMap").gameObject; Doumei doumei = new Doumei(); bool allClearedFlg = true; for (int k = 0; k < daimyoIdList.Count; k++) { int daimyoId = daimyoIdList [k]; string daimyoName = daimyo.getName(daimyoId); int kuniQty = 0; kuniQty = kuniQtyByDaimyoId [daimyoId - 1]; float ratio = 0; ratio = (100 - ((float)kuniQty / (float)myKuniQty * 500)); if (ratio < 0) { ratio = 0; } if (testMode) { ratio = 100; } //Debug.Log (daimyoName+":"+kuniQty +"/"+myKuniQty+"="+ratio); float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= ratio) { //OK for (int j = 0; j < seiryokuList.Count; j++) { if (seiryokuList [j] == daimyoId.ToString()) { int kuniId = j + 1; //1.update seiryoku newSeiryokuList [kuniId - 1] = myDaimyo.ToString(); //2.update cleaered kuni & kuni1,2,3 clearedKuni = clearedKuni + "," + kuniId.ToString(); string tmp = "kuni" + kuniId.ToString(); PlayerPrefs.SetString(tmp, "1,2,3,4,5,6,7,8,9,10"); //3.update openkuni kuni.registerOpenKuni(kuniId); //4.cyouhou delete //Cyouhou Delete string cyouhouTmp = "cyouhou" + kuniId; if (PlayerPrefs.HasKey(cyouhouTmp)) { PlayerPrefs.DeleteKey(cyouhouTmp); string cyouhou = PlayerPrefs.GetString("cyouhou"); List <string> cyouhouList = new List <string> (); if (cyouhou != null && cyouhou != "") { if (cyouhou.Contains(",")) { cyouhouList = new List <string> (cyouhou.Split(delimiterChars)); } else { cyouhouList.Add(cyouhou); } } cyouhouList.Remove(kuniId.ToString()); string newCyouhou = ""; for (int a = 0; a < cyouhouList.Count; a++) { if (a == 0) { newCyouhou = cyouhouList [a]; } else { newCyouhou = newCyouhou + "," + cyouhouList [a]; } } PlayerPrefs.SetString("cyouhou", newCyouhou); } //5. naisei string naiseiTmp = "naisei" + kuniId; if (!PlayerPrefs.HasKey(naiseiTmp)) { PlayerPrefs.SetString(naiseiTmp, "1,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0"); } //Icon Change IconMapValueUpdate(kuniId, myDaimyo, kuniIconView, kuniMap, myKuniQty); } } //Gunzei Check foreach (GameObject GunzeiObj in GameObject.FindGameObjectsWithTag("Gunzei")) { int gunzeiSrcDaimyoId = GunzeiObj.GetComponent <Gunzei> ().srcDaimyoId; if (daimyoId == gunzeiSrcDaimyoId) { deleteGunzei(GunzeiObj); } } //Message int msgKuniId = mainKuniIdList [k]; okNgMessage(true, msgKuniId, kuniIconView, panel, daimyoName); } else { //NG allClearedFlg = false; //Yukoudo 0 string tempGaikou = "gaikou" + daimyoId; PlayerPrefs.SetInt(tempGaikou, 0); //doumei clear bool doumeiFlg = doumei.myDoumeiExistCheck(daimyoId); if (doumeiFlg) { doumei.deleteDoumeiMyDaimyo(myDaimyo.ToString(), daimyoId.ToString()); } //Icon color & value kuni.deleteDoumeiKuniIcon(daimyoId); //Message int msgKuniId = mainKuniIdList [k]; okNgMessage(false, msgKuniId, kuniIconView, panel, daimyoName); } } string newSeiryoku = ""; for (int l = 0; l < newSeiryokuList.Count; l++) { if (l == 0) { newSeiryoku = newSeiryokuList [l]; } else { newSeiryoku = newSeiryoku + "," + newSeiryokuList [l]; } } PlayerPrefs.SetString("seiryoku", newSeiryoku); PlayerPrefs.SetString("clearedKuni", clearedKuni); PlayerPrefs.Flush(); //Update OpenKuniIcon kuni.updateOpenKuni(myDaimyo, newSeiryoku); //Close board.transform.FindChild("close").GetComponent <CloseBoard> ().onClick(); soubujiFlgOn(kuniIconView); if (allClearedFlg) { GameObject.Find("GameController").GetComponent <MainStageController> ().gameClearFlg = true; PlayerPrefs.SetBool("gameClearFlg", true); PlayerPrefs.Flush(); } } else { audioSources [1].Play(); } Destroy(back.gameObject); Destroy(confirm.gameObject); }
// Use this for initialization public void OnClick () { //SE sound = GameObject.Find ("SEController").GetComponent<AudioSource> (); sound.PlayOneShot (sound.clip); //Shinobi Check int shinobiGe = PlayerPrefs.GetInt ("shinobiGe"); int shinobiCyu = PlayerPrefs.GetInt ("shinobiCyu"); int shinobiJyo = PlayerPrefs.GetInt ("shinobiJyo"); int total = shinobiGe + shinobiCyu + shinobiJyo; if (total == 0) { Message msg = new Message (); string text = "派遣可能な忍はおりませんぞ。"; msg.makeMessage (text); }else{ CloseBoard close = GameObject.Find ("close").GetComponent<CloseBoard> (); close.layer = close.layer + 1; int nowHyourou = PlayerPrefs.GetInt ("hyourou"); bool hyourouOKflg = false; int daimyoId = GameObject.Find ("close").GetComponent<CloseBoard>().daimyoId; if (name == "Cyouhou") { GameObject.Find ("kuniName").GetComponent<Text> ().text = "諜報"; OffBouryakuMenuList(); string path = "Prefabs/Map/bouryaku/bouryakuObj"; GameObject obj= Instantiate (Resources.Load (path)) as GameObject; obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3 (1, 1, 1); GameObject btn = obj.transform.FindChild("DoBouryakuBtn").gameObject; btn.name = "DoCyouhouBtn"; btn.transform.FindChild("Text").GetComponent<Text>().text = "諜報"; shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn); GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj; } else if (name == "Ryugen") { GameObject.Find ("kuniName").GetComponent<Text> ().text = "流言"; OffBouryakuMenuList(); string path = "Prefabs/Map/bouryaku/bouryakuObj"; GameObject obj= Instantiate (Resources.Load (path)) as GameObject; obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3 (1, 1, 1); GameObject btn = obj.transform.FindChild("DoBouryakuBtn").gameObject; btn.name = "DoRyugenBtn"; btn.transform.FindChild("Text").GetComponent<Text>().text = "流言"; shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn); GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj; } else if (name == "Goudatsu") { GameObject.Find ("kuniName").GetComponent<Text> ().text = "強奪"; OffBouryakuMenuList(); string path = "Prefabs/Map/bouryaku/bouryakuObj"; GameObject obj= Instantiate (Resources.Load (path)) as GameObject; obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3 (1, 1, 1); GameObject btn = obj.transform.FindChild("DoBouryakuBtn").gameObject; btn.name = "DoGoudatsuBtn"; btn.transform.FindChild("Text").GetComponent<Text>().text = "強奪"; shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn); GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj; } else if (name == "Gihou") { //Gunzei Check bool gunzeiFlg = false; foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")){ int checkDaimyoId = obs.GetComponent<Gunzei>().srcDaimyoId; if(checkDaimyoId == daimyoId){ gunzeiFlg = true; targetGunzei = obs; break; } } if(gunzeiFlg){ //Menu Handling GameObject.Find ("kuniName").GetComponent<Text> ().text = "偽報"; OffBouryakuMenu (); string path = "Prefabs/Map/bouryaku/GihouObj"; GameObject obj = Instantiate (Resources.Load (path)) as GameObject; obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3 (1, 1, 1); //Label int dstKuni = targetGunzei.GetComponent<Gunzei>().dstKuni; int hei = targetGunzei.GetComponent<Gunzei>().myHei; KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(dstKuni); obj.transform.FindChild("GunzeiInfo").transform.FindChild("DaimyoNameValue").GetComponent<Text>().text = kuniName + "に進軍中"; obj.transform.FindChild("Heiryoku").transform.FindChild("HeiryokuValue").GetComponent<Text>().text = hei.ToString(); GameObject btn = obj.transform.FindChild("DoGihouBtn").gameObject; shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn); GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj; }else{ Message msg = new Message(); string NGtext = "進軍中の軍勢がおりませぬぞ。"; msg.makeMessage (NGtext); close.layer = close.layer - 1; } } } }
public void OnClick() { audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [5].Play(); //Hyourou int hyourou = PlayerPrefs.GetInt("hyourou"); int newHyourou = hyourou - 10; PlayerPrefs.SetInt("hyourou", newHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString(); //Track int TrackToubatsuNo = PlayerPrefs.GetInt("TrackToubatsuNo", 0); TrackToubatsuNo = TrackToubatsuNo + 1; PlayerPrefs.SetInt("TrackToubatsuNo", TrackToubatsuNo); MainStageController script = GameObject.Find("GameController").GetComponent <MainStageController> (); myKuniQty = script.myKuniQty; myDaimyo = script.myDaimyo; myKuniQtyIsBiggestFlg = GameObject.Find("bakuhuReturn").GetComponent <BakuhuMenuReturn> ().myKuniQtyIsBiggestFlg; List <string> messageList = new List <string> (); //reduce yukoudo Gaikou gaikou = new Gaikou(); DoGaikou doGaikou = new DoGaikou(); int myGaikouValueWithTarget = gaikou.getMyGaikou(targetDaimyoId); int newYukoudoWithTarget = gaikou.downMyGaikou(targetDaimyoId, myGaikouValueWithTarget, 50); int reducedValueWithTarget = myGaikouValueWithTarget - newYukoudoWithTarget; string firstKassenText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { firstKassenText = "Declared " + targetDaimyoName + " attack order. \n Friendship reduced " + reducedValueWithTarget + " point."; } else { firstKassenText = targetDaimyoName + "討伐を宣言しました。\n当家との友好度が" + reducedValueWithTarget + "下がります。"; } doGaikou.downYukouOnIcon(targetDaimyoId, newYukoudoWithTarget); messageList.Add(firstKassenText); //doumei check Doumei doumei = new Doumei(); KuniInfo kuni = new KuniInfo(); bool doumeiExistFlg = doumei.myDoumeiExistCheck(targetDaimyoId); if (doumeiExistFlg) { doumei.deleteDoumei(myDaimyo.ToString(), targetDaimyoId.ToString()); //Change Map & Yukoudo kuni.deleteDoumeiKuniIcon(targetDaimyoId); } PlayerPrefs.Flush(); //Listup Target kuni Id string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); List <int> targetKuniList = new List <int> (); for (int i = 0; i < seiryokuList.Count; i++) { if (int.Parse(seiryokuList [i]) == targetDaimyoId) { int kuniId = i + 1; targetKuniList.Add(kuniId); } } //Listup Available Open kuni List <string> srcDstKuniList = new List <string> (); Entity_kuni_mapping_mst kuniMapMst = Resources.Load("Data/kuni_mapping_mst") as Entity_kuni_mapping_mst; for (int j = 0; j < targetKuniList.Count; j++) { int tmpTargetKuniId = targetKuniList [j]; for (int i = 0; i < kuniMapMst.param.Count; i++) { int temClearedKuniId = kuniMapMst.param[i].Souce; if (temClearedKuniId == tmpTargetKuniId) { int openKuniId = kuniMapMst.param [i].Open; if (int.Parse(seiryokuList [openKuniId - 1]) != targetDaimyoId && int.Parse(seiryokuList [openKuniId - 1]) != myDaimyo) { srcDstKuniList.Add(openKuniId.ToString() + "-" + tmpTargetKuniId.ToString()); } } } } //Shuffule for (int i = 0; i < srcDstKuniList.Count; i++) { string temp = srcDstKuniList[i]; int randomIndex = Random.Range(i, srcDstKuniList.Count); srcDstKuniList[i] = srcDstKuniList[randomIndex]; srcDstKuniList[randomIndex] = temp; } /*Condition of succesful*/ //1. number of own kuni is more thab twice as number as target ... 20% //2. number of own kuni is the largest ... 30% //3. relathionship btwn my party and src kuni is 100% ... 20% //4. relathionship btwn the other countiries each other is 0% ... 20% //5. attacker keep kuni number more than country receiving attack ... 10% //1. if (myKuniQty > 2 * kuniQty) { baseRatio = 20; } //2. if (myKuniQtyIsBiggestFlg) { baseRatio = baseRatio + 30; } //Make Gunzei char[] delimiterChars2 = { '-' }; GameObject BakuhuKuniIconView = GameObject.Find("BakuhuKuniIconView").gameObject; string path = "Prefabs/Map/Gunzei"; string visualizePath = "Prefabs/Bakuhu/ToubatsuSrcBusyo"; GameObject panel = GameObject.Find("Panel").gameObject; Gunzei gunzei = new Gunzei(); Daimyo daimyo = new Daimyo(); MainEventHandler mEvent = new MainEventHandler(); List <int> doneSrcDaimyoList = new List <int> (); for (int k = 0; k < srcDstKuniList.Count; k++) { float indvRatio = 0; string key = srcDstKuniList[k]; List <string> srcDstList = new List <string> (); srcDstList = new List <string> (key.Split(delimiterChars2)); //3 int srcKuniId = int.Parse(srcDstList[0]); int srcDaimyo = int.Parse(seiryokuList[srcKuniId - 1]); if (!doneSrcDaimyoList.Contains(srcDaimyo)) { doneSrcDaimyoList.Add(srcDaimyo); bool ExistFlg = false; foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")) { int gunzeiSrcDaimyoId = obs.GetComponent <Gunzei>().srcDaimyoId; if (srcDaimyo == gunzeiSrcDaimyoId) { ExistFlg = true; } } if (!ExistFlg) { int myGaikouValue = gaikou.getMyGaikou(srcDaimyo); indvRatio = baseRatio + (float)myGaikouValue / 5; //4. int dstKuniId = int.Parse(srcDstList [1]); int dstDaimyo = int.Parse(seiryokuList [dstKuniId - 1]); int otherGaikouValue = gaikou.getOtherGaikouValue(srcDaimyo, dstDaimyo); indvRatio = indvRatio + (float)((100 - otherGaikouValue) / 5); //5. int srcKuniQty = BakuhuKuniIconView.transform.FindChild(srcDstList [0]).GetComponent <SendParam> ().kuniQty; float addRatio = 0; if (srcKuniQty >= kuniQty) { addRatio = 10; indvRatio = indvRatio + addRatio; } //Success Check float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= indvRatio) { //OK toubatsuFlg = true; GameObject Gunzei = Instantiate(Resources.Load(path)) as GameObject; Gunzei.transform.SetParent(panel.transform); Gunzei.transform.localScale = new Vector2(1, 1); GameObject minGunzei = Instantiate(Resources.Load(visualizePath)) as GameObject; minGunzei.transform.SetParent(BakuhuKuniIconView.transform); int daimyoBusyoId = daimyo.getDaimyoBusyoId(srcDaimyo); string daimyoPath = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString(); minGunzei.GetComponent <SpriteRenderer> ().sprite = Resources.Load(daimyoPath, typeof(Sprite)) as Sprite; //Location int srcX = kuni.getKuniLocationX(srcKuniId); int srcY = kuni.getKuniLocationY(srcKuniId); int dstX = kuni.getKuniLocationX(dstKuniId); int dstY = kuni.getKuniLocationY(dstKuniId); string direction = ""; if (srcX < dstX) { Gunzei.transform.localScale = new Vector2(1, 1); minGunzei.transform.localScale = new Vector2(60, 72); direction = "right"; } else { Gunzei.transform.localScale = new Vector2(-1, 1); minGunzei.transform.localScale = new Vector2(-60, 72); direction = "left"; Gunzei.GetComponent <Gunzei> ().leftFlg = true; } int aveX = (srcX + dstX) / 2; int aveY = (srcY + dstY) / 2; RectTransform GunzeiTransform = Gunzei.GetComponent <RectTransform> (); GunzeiTransform.anchoredPosition = new Vector3(aveX, aveY, 0); RectTransform minGunzeiTransform = minGunzei.GetComponent <RectTransform> (); float minAveX = (float)aveX * 0.8f; float minAveY = (float)aveY * 0.65f; minGunzeiTransform.anchoredPosition = new Vector3((int)minAveX, (int)minAveY, 0); Gunzei.GetComponent <Gunzei> ().key = key; Gunzei.GetComponent <Gunzei> ().srcKuni = srcKuniId; Gunzei.GetComponent <Gunzei> ().srcDaimyoId = srcDaimyo; string srcDaimyoName = daimyo.getName(srcDaimyo); Gunzei.GetComponent <Gunzei> ().srcDaimyoName = srcDaimyoName; Gunzei.GetComponent <Gunzei> ().dstKuni = dstKuniId; Gunzei.GetComponent <Gunzei> ().dstDaimyoId = dstDaimyo; string dstDaimyoName = daimyo.getName(dstDaimyo); Gunzei.GetComponent <Gunzei> ().dstDaimyoName = dstDaimyoName; int myHei = gunzei.heiryokuCalc(srcKuniId); //random myHei from -50%-myHei List <float> randomPercent = new List <float> { 0.8f, 0.9f, 1.0f }; int rmd = UnityEngine.Random.Range(0, randomPercent.Count); float per = randomPercent [rmd]; myHei = Mathf.CeilToInt(myHei * per); Gunzei.GetComponent <Gunzei> ().myHei = myHei; Gunzei.name = key; //Engun from Doumei List <string> doumeiDaimyoList = new List <string> (); bool dstEngunFlg = false; string dstEngunDaimyoId = ""; //2:3:5 string dstEngunHei = ""; string dstEngunSts = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv: int totalEngunHei = 0; //Doumei Check doumeiDaimyoList = doumei.doumeiExistCheck(dstDaimyo, srcDaimyo.ToString()); string doumeiCheck = "doumei" + srcDaimyo; if (PlayerPrefs.HasKey(doumeiCheck)) { string cDoumei = PlayerPrefs.GetString(doumeiCheck); List <string> cDoumeiList = new List <string>(); if (cDoumei.Contains(",")) { cDoumeiList = new List <string> (cDoumei.Split(delimiterChars)); } else { cDoumeiList.Add(cDoumei); } //If Doumei Daimyo -> Delete if (cDoumeiList.Contains(dstDaimyo.ToString())) { doumei.deleteDoumei(srcDaimyo.ToString(), dstDaimyo.ToString()); } } if (doumeiDaimyoList.Count != 0) { //Doumei Exist //Trace Check List <string> okDaimyoList = new List <string> (); List <string> checkList = new List <string> (); okDaimyoList = doumei.traceNeighborDaimyo(dstKuniId, dstDaimyo, doumeiDaimyoList, seiryokuList, checkList, okDaimyoList); if (okDaimyoList.Count != 0) { //Doumei & Neghbor Daimyo Exist for (int h = 0; h < okDaimyoList.Count; h++) { string engunDaimyo = okDaimyoList[h]; int yukoudo = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), dstDaimyo); //engun check dstEngunFlg = mEvent.CheckByProbability(yukoudo); if (dstEngunFlg) { //Engun OK dstEngunFlg = true; if (dstEngunDaimyoId != null && dstEngunDaimyoId != "") { dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo; string tempEngunSts = engunDaimyo + "-" + mEvent.getEngunSts(engunDaimyo); int tempEngunHei = mEvent.getEngunHei(tempEngunSts); dstEngunHei = dstEngunHei + ":" + tempEngunHei.ToString(); totalEngunHei = totalEngunHei + tempEngunHei; dstEngunSts = dstEngunSts + ":" + tempEngunSts; } else { dstEngunDaimyoId = engunDaimyo; string tempEngunSts = engunDaimyo + "-" + mEvent.getEngunSts(engunDaimyo); int tempEngunHei = mEvent.getEngunHei(tempEngunSts); dstEngunHei = tempEngunHei.ToString(); totalEngunHei = tempEngunHei; dstEngunSts = tempEngunSts; } } } Gunzei.GetComponent <Gunzei> ().dstEngunFlg = dstEngunFlg; Gunzei.GetComponent <Gunzei> ().dstEngunDaimyoId = dstEngunDaimyoId; Gunzei.GetComponent <Gunzei> ().dstEngunHei = dstEngunHei; Gunzei.GetComponent <Gunzei> ().dstEngunSts = dstEngunSts; } } //Set Value //CreateTime,srcDaimyoId,dstDaimyoId,srcDaimyoName,dstDaimyoName, srcHei,locationX,locationY,left or right, engunFlg, engunDaimyoId(A:B:C), dstEngunHei(1000:2000:3000), dstEngunSts string keyValue = ""; string createTime = System.DateTime.Now.ToString(); keyValue = createTime + "," + srcDaimyo + "," + dstDaimyo + "," + srcDaimyoName + "," + dstDaimyoName + "," + myHei + "," + aveX + "," + aveY + "," + direction + "," + dstEngunFlg + "," + dstEngunDaimyoId + "," + dstEngunHei + "," + dstEngunSts; PlayerPrefs.SetString(key, keyValue); string keyHistory = PlayerPrefs.GetString("keyHistory"); if (keyHistory == null || keyHistory == "") { keyHistory = key; } else { keyHistory = keyHistory + "," + key; } PlayerPrefs.SetString("keyHistory", keyHistory); PlayerPrefs.SetInt("bakuhuTobatsuDaimyoId", dstDaimyo); PlayerPrefs.Flush(); string kassenText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { if (!dstEngunFlg) { kassenText = srcDaimyoName + " is attacking " + dstDaimyoName + " with " + myHei + " soldiers."; } else { kassenText = srcDaimyoName + " is attacking " + dstDaimyoName + " with " + myHei + " soldiers.\n Defender's allianced country sent " + totalEngunHei + " soldiers."; } } else { if (!dstEngunFlg) { kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。"; } else { kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。\n防衛側の同盟国が援軍" + totalEngunHei + "人を派兵しました。"; } } messageList.Add(kassenText); } else { //NG string kassenText = ""; string srcDaimyoName = daimyo.getName(srcDaimyo); int newYukoudo = gaikou.downMyGaikou(srcDaimyo, myGaikouValue, 15); int reducedValue = myGaikouValue - newYukoudo; if (Application.systemLanguage != SystemLanguage.Japanese) { kassenText = srcDaimyoName + " rejected our attack order. Friendship reduced " + reducedValue + " point."; } else { kassenText = srcDaimyoName + "が討伐令を黙殺しました。当家との友好度が" + reducedValue + "下がります。"; } doGaikou.downYukouOnIcon(srcDaimyo, newYukoudo); messageList.Add(kassenText); } } } } //Disabled foreach (Transform obj in BakuhuKuniIconView.transform) { if (obj.GetComponent <Button> ()) { obj.GetComponent <Button> ().enabled = false; } } GameObject toubatsuSelect = GameObject.Find("ToubatsuSelect").gameObject; toubatsuSelect.transform.FindChild("ToubatsuBtn").gameObject.SetActive(false); if (toubatsuFlg) { audioSources [3].Play(); if (Application.systemLanguage != SystemLanguage.Japanese) { toubatsuSelect.transform.FindChild("Exp").GetComponent <Text> ().text = "Declared " + targetDaimyoName + " attack order. Other family responded to it."; } else { toubatsuSelect.transform.FindChild("Exp").GetComponent <Text>().text = targetDaimyoName + "の討伐令を出しました。諸大名が呼応したようです。"; } } else { audioSources [4].Play(); if (srcDstKuniList.Count == 0) { if (Application.systemLanguage != SystemLanguage.Japanese) { toubatsuSelect.transform.FindChild("Exp").GetComponent <Text> ().text = "There is no family who can respond to " + targetDaimyoName + " attack order."; } else { toubatsuSelect.transform.FindChild("Exp").GetComponent <Text>().text = "現在" + targetDaimyoName + "の討伐に呼応可能な大名はおりません。"; } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { toubatsuSelect.transform.FindChild("Exp").GetComponent <Text> ().text = "No family responded to our attack order because of fear for " + targetDaimyoName + "."; } else { toubatsuSelect.transform.FindChild("Exp").GetComponent <Text>().text = targetDaimyoName + "を恐れてか、討伐令にどの大名も呼応しませんでした。"; } } } Message msg = new Message(); msg.makeSlotMessage(messageList); }
// 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 int countLinkedKuniQty(int kuniQty, int myKuniId, int myDaimyoId, List<string>seiryokuList, List<string>checkedKuniList){ List<int> dstKuniList = new List<int>(); KuniInfo kuni = new KuniInfo (); dstKuniList = kuni.getMappingKuni(myKuniId); foreach(int dstKuniId in dstKuniList){ if (!checkedKuniList.Contains (dstKuniId.ToString())) { string tmpDaimyoId = seiryokuList[dstKuniId - 1]; checkedKuniList.Add (dstKuniId.ToString ()); checkedKuniList.Add (myKuniId.ToString ()); if (int.Parse (tmpDaimyoId) == myDaimyoId) { kuniQty = countLinkedKuniQty (kuniQty, dstKuniId, myDaimyoId, seiryokuList, checkedKuniList) + 1; } } } return kuniQty; }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); GameObject board = GameObject.Find("CyouteiBoard").gameObject; Message msg = new Message(); GameObject actionValue = GameObject.Find("ActionValue").gameObject; int actionRemainQty = int.Parse(actionValue.GetComponent <Text> ().text); if (actionRemainQty <= 0) { audioSources [4].Play(); msg.makeMessage(msg.getMessage(17)); string serihu = msg.getMessage(18); mikadoSerihuChanger(serihu); } else { CloseLayer CloseLayerScript = GameObject.Find("CloseSyoukaijyo").GetComponent <CloseLayer>(); if (name == "Kenjyo") { int money = PlayerPrefs.GetInt("money"); if (money < 1000) { audioSources [4].Play(); msg.makeMessage(msg.getMessage(19)); mikadoSerihuChanger(msg.getMessage(20)); } else { audioSources [0].Play(); string path = "Prefabs/Cyoutei/MenuKenjyo"; 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, -180); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuKenjyo"; GameObject giveSlider = menu.transform.FindChild("GiveSlider").gameObject; giveSlider.GetComponent <GiveSlider> ().valueObj = menu.transform.FindChild("GiveMoneyValue").gameObject; giveSlider.GetComponent <Slider> ().value = 1.0f; int tmp = money / 1000; if (tmp < 10) { giveSlider.GetComponent <Slider> ().maxValue = (float)tmp; } mikadoSerihuChanger(msg.getMessage(21)); } } else if (name == "Cyoutei") { audioSources [0].Play(); string path = "Prefabs/Cyoutei/MenuCyoutei"; 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, -180); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuCyoutei"; int yukoudoUp = CloseLayerScript.yukouAddValue; int reducePoint = CloseLayerScript.yukouReducePoint; menu.transform.FindChild("CyouteiUpValue").GetComponent <Text>().text = yukoudoUp.ToString(); menu.transform.FindChild("ReduceValue").GetComponent <Text>().text = reducePoint.ToString(); mikadoSerihuChanger(msg.getMessage(22)); } else if (name == "Teisen") { //Check bool gunzeiFlg = false; int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")) { int checkDaimyoId = obs.GetComponent <Gunzei>().dstDaimyoId; if (checkDaimyoId == myDaimyo) { gunzeiFlg = true; targetGunzei = obs; break; } } if (gunzeiFlg) { audioSources [0].Play(); string path = "Prefabs/Cyoutei/MenuTeisen"; 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, -180); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuTeisen"; int ratio = CloseLayerScript.stopBattleRatio; int reducePoint = CloseLayerScript.stopBattleReducePoint; menu.transform.FindChild("RatioValue").GetComponent <Text>().text = ratio.ToString(); menu.transform.FindChild("ReduceValue").GetComponent <Text>().text = reducePoint.ToString(); int srcDaimyoId = targetGunzei.GetComponent <Gunzei>().srcDaimyoId; string srcDaimyoName = targetGunzei.GetComponent <Gunzei>().srcDaimyoName; string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + srcDaimyoId.ToString(); GameObject gunzei = menu.transform.FindChild("Gunzei").gameObject; gunzei.GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { gunzei.transform.FindChild("Text").GetComponent <Text>().text = srcDaimyoName; serihu = "Have you not been doing well with " + srcDaimyoName + "? We can stop the battle."; } else { gunzei.transform.FindChild("Text").GetComponent <Text>().text = srcDaimyoName + "隊"; serihu = "ほう、" + srcDaimyoName + "と上手くいっていないのか。停戦要請をしても良いぞ。"; } mikadoSerihuChanger(serihu); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(23)); } } else if (name == "Kanni") { int kanniId = CloseLayerScript.kanniId; if (kanniId != 0) { audioSources [0].Play(); string path = "Prefabs/Cyoutei/MenuKanni"; 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, -180); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuKanni"; int ratio = CloseLayerScript.kanniRatio; int reducePoint = CloseLayerScript.kanniReducePoint; string kanniName = CloseLayerScript.kanniName; GameObject.Find("NextKanni").GetComponent <Text>().text = kanniName; GameObject.Find("ratioValue").GetComponent <Text>().text = ratio.ToString(); GameObject.Find("ReduceValue").GetComponent <Text>().text = reducePoint.ToString(); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "I'm glad of your loyalty.\n I can give you " + kanniName + "."; } else { serihu = "そなたの忠勤うれしく思う。\n今は" + kanniName + "の任が空いておるぞ。"; } mikadoSerihuChanger(serihu); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(24)); mikadoSerihuChanger(msg.getMessage(25)); } } else if (name == "Bakuhu") { //Check I'm not Syougun int syogunDaimyoId = PlayerPrefs.GetInt("syogunDaimyoId"); int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); Daimyo daimyo = new Daimyo(); string myDaimyoBusyoName = daimyo.getName(myDaimyoId); if (syogunDaimyoId == myDaimyoId) { audioSources [4].Play(); msg.makeMessage(msg.getMessage(26)); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Lord " + myDaimyoBusyoName + ". You are syogun. What do you want anymore?"; } else { serihu = myDaimyoBusyoName + "殿、そなた既に幕府を開いておろう。これ以上何を望むというのじゃ。"; } mikadoSerihuChanger(serihu); } else { string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); if (seiryokuList.Contains(syogunDaimyoId.ToString())) { audioSources [4].Play(); //Check the other Syougun Not Exist string syogunBusyoName = daimyo.getName(syogunDaimyoId); string Text = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { Text = "Other family " + syogunBusyoName + " has been assigned as syogun."; } else { Text = "既に" + syogunBusyoName + "殿が征夷大将軍に任命されておりますぞ。"; } msg.makeMessage(Text); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Other family, loard " + syogunBusyoName + " has been assigned as syogun."; } else { serihu = "既に" + syogunBusyoName + "殿が幕府を開いておる。そなた世情にあまりにも疎いのう。"; } mikadoSerihuChanger(serihu); } else { //Checku Kinai Cleared List <int> needKuni = new List <int> { 6, 11, 12, 13, 16, 17, 38, 39 }; bool kuniCheckOKFlg = true; string NGKuniName = ""; KuniInfo kuni = new KuniInfo(); for (int i = 0; i < needKuni.Count; i++) { int kuniId = needKuni [i] - 1; if (seiryokuList[kuniId] != myDaimyoId.ToString()) { kuniCheckOKFlg = false; NGKuniName = kuni.getKuniName(kuniId + 1); } } if (!kuniCheckOKFlg) { //NG audioSources [4].Play(); msg.makeMessage(msg.getMessage(27)); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "You don't have country " + NGKuniName + ". It's too early for you to assign syogun."; } else { serihu = NGKuniName + "をまだ治めていないようじゃのう。残念だが征夷大将軍の任命は時期尚早じゃ。"; } mikadoSerihuChanger(serihu); } else { //Check whether is there any other daimyo who has 1/2 kuni string clearedKuni = PlayerPrefs.GetString("clearedKuni"); List <string> clearedKuniList = new List <string> (); if (clearedKuni.Contains(",")) { clearedKuniList = new List <string> (clearedKuni.Split(delimiterChars)); } else { clearedKuniList.Add(clearedKuni); } int maxKuniQty = 0; int myYukouValue = 0; string maxDaimyoName = ""; GameObject kuniIconView = GameObject.Find("KuniIconView"); foreach (Transform obj in kuniIconView.transform) { int daimyoId = obj.gameObject.GetComponent <SendParam> ().daimyoId; if (daimyoId != myDaimyoId) { int tmpQty = obj.gameObject.GetComponent <SendParam> ().kuniQty; if (tmpQty > maxKuniQty) { maxKuniQty = tmpQty; myYukouValue = obj.gameObject.GetComponent <SendParam> ().myYukouValue; maxDaimyoName = obj.gameObject.GetComponent <SendParam> ().daimyoName; } } } if (clearedKuniList.Count <= maxKuniQty * 2) { float bakuhuPercent = UnityEngine.Random.value; bakuhuPercent = bakuhuPercent * 100; if (bakuhuPercent < myYukouValue && !onceBakuhuNg) { //ok audioSources [0].Play(); string path = "Prefabs/Cyoutei/MenuBakuhu"; 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, -180); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuBakuhu"; mikadoSerihuChanger(msg.getMessage(28)); } else { //NG audioSources [4].Play(); onceBakuhuNg = true; msg.makeMessage(msg.getMessage(29)); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "I want to assign you but " + maxDaimyoName + " disagreed.\n I can't ignore due to his influence."; } else { serihu = "そちを任命したいのだが、\n" + maxDaimyoName + "が五月蝿うてのう。\n宮中にも影響力があるゆえ無視は出来ぬ。"; } mikadoSerihuChanger(serihu); } } else { audioSources [0].Play(); string path = "Prefabs/Cyoutei/MenuBakuhu"; 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, -180); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuBakuhu"; mikadoSerihuChanger(msg.getMessage(28)); } } } } } else if (name == "Cyouteki") { //Cyouteki Check int cyoutekiDaimyo = PlayerPrefs.GetInt("cyoutekiDaimyo", 0); string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); Daimyo daimyo = new Daimyo(); if (seiryokuList.Contains(cyoutekiDaimyo.ToString())) { //Aleady Exsit audioSources [4].Play(); string daimyoName = daimyo.getName(cyoutekiDaimyo); string Text = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { Text = daimyoName + " was declared as enemy of imperial court."; } else { Text = "既に" + daimyoName + "が朝敵に指定されているようですぞ。"; } msg.makeMessage(Text); } else { //Not Exist int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); bool remain1DaimyoFlg = daimyo.checkRemain1DaimyoOnMain(myDaimyo); if (remain1DaimyoFlg) { audioSources [4].Play(); msg.makeMessage(msg.getMessage(14)); } else { audioSources [0].Play(); string path = "Prefabs/Cyoutei/MenuCyouteki"; 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, -180); menu.transform.FindChild("Close").GetComponent <CloseMenu> ().obj = menu; menu.name = "MenuCyouteki"; cyoutekiDaimyo = CloseLayerScript.cyoutekiDaimyo; string daimyoName = daimyo.getName(cyoutekiDaimyo); menu.transform.FindChild("CyoutekiDaimyo").GetComponent <Text> ().text = daimyoName; int cyoutekiReducePoint = CloseLayerScript.cyoutekiReducePoint; menu.transform.FindChild("ReduceValue").GetComponent <Text> ().text = cyoutekiReducePoint.ToString(); CloseLayerScript.cyoutekiDaimyoName = daimyoName; string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Please attack " + daimyoName + ", enemy of imperial court."; } else { serihu = "朝廷に弓引く、逆賊" + daimyoName + "を討ってくれ。"; } mikadoSerihuChanger(serihu); } } } } }
public void wasAttacked(string key, int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId, bool dstEngunFlg, string dstEngunDaimyoId, string dstEngunSts) { //In the case of My Damyo was Attacked //For Dramatic Enemy Creation GameObject kuniView = GameObject.Find("KuniIconView"); if (kuniView.transform.FindChild(srcKuni.ToString())) { SendParam param = kuniView.transform.FindChild(srcKuni.ToString()).GetComponent <SendParam> (); int busyoQty = param.busyoQty; int busyoLv = param.busyoLv; int butaiQty = param.butaiQty; int butaiLv = param.butaiLv; //Dummy PlayerPrefs.SetInt("activeStageId", 0); PlayerPrefs.SetInt("activeStageMoney", busyoQty * 500); PlayerPrefs.SetInt("activeStageExp", busyoQty * 100); PlayerPrefs.SetString("activeItemType", ""); PlayerPrefs.SetInt("activeItemId", 0); PlayerPrefs.SetFloat("activeItemRatio", 0); PlayerPrefs.SetInt("activeItemQty", 0); //Actual PlayerPrefs.SetInt("activeKuniId", dstKuni); KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(dstKuni); string kassenName = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { kassenName = kuniName + " Defence"; } else { kassenName = kuniName + "防衛"; } PlayerPrefs.SetString("activeStageName", kassenName); PlayerPrefs.SetInt("activeDaimyoId", srcDaimyoId); PlayerPrefs.SetInt("activeBusyoQty", busyoQty); PlayerPrefs.SetInt("activeBusyoLv", busyoLv); PlayerPrefs.SetInt("activeButaiQty", butaiQty); PlayerPrefs.SetInt("activeButaiLv", butaiLv); //Passive only PlayerPrefs.SetBool("isAttackedFlg", true); PlayerPrefs.DeleteKey("isKessenFlg"); PlayerPrefs.SetString("activeKey", key); PlayerPrefs.SetInt("activeSrcDaimyoId", srcDaimyoId); PlayerPrefs.SetInt("activeDstDaimyoId", dstDaimyoId); //Engun if (dstEngunFlg) { PlayerPrefs.SetString("playerEngunList", dstEngunSts); PlayerPrefs.DeleteKey("enemyEngunList"); } else { PlayerPrefs.DeleteKey("playerEngunList"); PlayerPrefs.DeleteKey("enemyEngunList"); } //Gaikou Down Gaikou gaikou = new Gaikou(); gaikou.downGaikouByAttack(srcDaimyoId, dstDaimyoId); //Delete "Start Kassen Flg" PlayerPrefs.DeleteKey("activeLink"); PlayerPrefs.DeleteKey("activePowerType"); List <int> powerTypeList = new List <int> () { 1, 2, 3 }; int random = UnityEngine.Random.Range(1, powerTypeList.Count + 1); PlayerPrefs.SetInt("activePowerType", random); //Boubi effect string boubiTmp = "boubi" + dstKuni.ToString(); int boubi = PlayerPrefs.GetInt(boubiTmp, 0); boubi = boubi / 10; PlayerPrefs.SetInt("activeBoubi", boubi); PlayerPrefs.Flush(); Application.LoadLevel("preKassen"); } }
// Update is called once per frame void Update () { life = getTotalHp (targetTag); //Show Heiryoku if (life >= 0) { gameObject.transform.FindChild("HpText").GetComponent<Text>().text = life.ToString(); } if (!flag) { if (life == 0) { flag = true; GameObject.Find ("ScrollView").SetActive (false); GameObject canvas = GameObject.Find ("Canvas").gameObject; if (targetTag == "Player") { //Game Over string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.SetParent (canvas.transform); backObj.transform.localScale = new Vector2(70,63); backObj.transform.localPosition = new Vector2 (0,0); //Chane word Color color = Color.blue; GameObject.Find ("winlose").GetComponent<TextMesh>().text = "敗北"; GameObject.Find ("winlose").GetComponent<TextMesh>().color = color; string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject; blackObj.transform.SetParent (canvas.transform); blackObj.transform.localScale = new Vector2(330,300); blackObj.transform.localPosition = new Vector2 (0,0); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject; makimonoObj.transform.SetParent (canvas.transform); makimonoObj.transform.localScale = new Vector2(1,1); makimonoObj.transform.localPosition = new Vector2(0,-135); //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject; bttnListObj.transform.SetParent (canvas.transform); bttnListObj.transform.localScale = new Vector2(1,1); bttnListObj.transform.localPosition = new Vector2 (0,0); //Time Stop GameObject.Find ("timer").GetComponent<Timer>().enabled = false; //lose Stage Name string stageNamePath = "Prefabs/PostKassen/loseStageName"; GameObject stageNameObj = Instantiate(Resources.Load (stageNamePath)) as GameObject; stageNameObj.transform.SetParent (canvas.transform); stageNameObj.transform.localScale = new Vector2(1,1); stageNameObj.transform.localPosition = new Vector2 (0,-102); string stageName = PlayerPrefs.GetString("activeStageName"); //Check is attacked flag if (isAttackedFlg == true) { stageNameObj.transform.FindChild ("stageNameValue").GetComponent<Text> ().text = stageName + "失敗"; //My Daimyo Lose Gunzei lose = new Gunzei (); string tKey = PlayerPrefs.GetString ("activeKey"); int tSrcDaimyoId = PlayerPrefs.GetInt ("activeSrcDaimyoId"); int tDstDaimyoId = PlayerPrefs.GetInt ("activeDstDaimyoId"); bool noGunzeiFlg = true; PlayerPrefs.DeleteKey ("isAttacked"); lose.win (tKey, tSrcDaimyoId, tDstDaimyoId, noGunzeiFlg); //Delete Cleared Kuni int activeKuniId = PlayerPrefs.GetInt ("activeKuniId"); string clearedKuni = PlayerPrefs.GetString ("clearedKuni"); char[] delimiterChars = { ',' }; List<string> clearedKuniList = new List<string> (); if (clearedKuni != null && clearedKuni != "") { if (clearedKuni.Contains (",")) { clearedKuniList = new List<string> (clearedKuni.Split (delimiterChars)); } else { clearedKuniList.Add (clearedKuni); } } string tempActiveKuni = activeKuniId.ToString (); clearedKuniList.Remove (tempActiveKuni); string newClearedKuni = ""; for (int i = 0; i < clearedKuniList.Count; i++) { if (i == 0) { newClearedKuni = clearedKuniList [i]; } else { newClearedKuni = newClearedKuni + "," + clearedKuniList [i]; } } PlayerPrefs.SetString ("clearedKuni", newClearedKuni); if (newClearedKuni == null || newClearedKuni == "") { PlayerPrefs.SetBool ("gameOverFlg", true); } //Delete Naisei //string tempNaisei = "naisei" + activeKuniId.ToString(); //PlayerPrefs.DeleteKey(tempNaisei); //Delete Jyosyu string tempJyosyu = "jyosyu" + activeKuniId.ToString (); PlayerPrefs.DeleteKey (tempJyosyu); //Delete Stage Clear string tempKuni = "kuni" + activeKuniId.ToString (); PlayerPrefs.DeleteKey (tempKuni); //Delete open KuniInfo kuni = new KuniInfo (); kuni.updateOpenKuni (); PlayerPrefs.Flush (); } else { stageNameObj.transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "攻略失敗"; } } else if (targetTag == "Enemy") { //Win if(isAttackedFlg == true){ //history string tKey = PlayerPrefs.GetString("activeKey"); MainStageController main = new MainStageController(); main.deleteKeyHistory(tKey); PlayerPrefs.DeleteKey("isAttacked"); PlayerPrefs.Flush(); } string backPath = "Prefabs/PostKassen/back"; GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject; backObj.transform.SetParent (canvas.transform); backObj.transform.localScale = new Vector2(70,63); backObj.transform.localPosition = new Vector2 (0,0); string particlePath = "Prefabs/PostKassen/particle"; GameObject particleObj = Instantiate(Resources.Load (particlePath)) as GameObject; particleObj.transform.SetParent (canvas.transform); particleObj.transform.localPosition = new Vector2(0,60); string blackPath = "Prefabs/PostKassen/black"; GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject; blackObj.transform.SetParent (canvas.transform); blackObj.transform.localScale = new Vector2(330,300); blackObj.transform.localPosition = new Vector2 (0,0); string makimonoPath = "Prefabs/PostKassen/makimono"; GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject; makimonoObj.transform.SetParent (canvas.transform); makimonoObj.transform.localScale = new Vector2(1,1); makimonoObj.transform.localPosition = new Vector2(0,-135); string stageName = PlayerPrefs.GetString("activeStageName"); //Item List string itemListPath = "Prefabs/PostKassen/itemList"; GameObject itemListObj = Instantiate(Resources.Load (itemListPath)) as GameObject; itemListObj.transform.SetParent (canvas.transform); itemListObj.transform.localScale = new Vector2(1,1); itemListObj.transform.localPosition = new Vector2 (0,-136); if (!isAttackedFlg) { itemListObj.transform.FindChild ("stageName").transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "攻略"; /*Item or Kahou*/ string activeItemGrp = PlayerPrefs.GetString ("activeItemGrp"); if (activeItemGrp != "no") { string activeItemType = PlayerPrefs.GetString ("activeItemType"); Debug.Log (activeItemType); int activeItemId = PlayerPrefs.GetInt ("activeItemId"); Debug.Log (activeItemId); int activeItemQty = PlayerPrefs.GetInt ("activeItemQty"); Debug.Log (activeItemQty); //Get Item string cyouheiPath = "Prefabs/Item/Cyouhei/" + activeItemType; string kanjyoPath = "Prefabs/Item/Kanjyo/Kanjyo"; string hidensyoPath = "Prefabs/Item/Hidensyo/Hidensyo"; string shinobiPath = "Prefabs/Item/Shinobi/Shinobi"; char[] delimiterChars = { ',' }; if (activeItemGrp == "item") { //Cyouhei if (activeItemType.Contains ("Cyouhei") == true) { string newCyouheiString = ""; makeItemIcon (cyouheiPath, activeItemId.ToString (), itemListObj); if (activeItemType.Contains ("YR") == true) { string cyouheiString = PlayerPrefs.GetString ("cyouheiYR"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (cyouheiList [0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (cyouheiList [1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (cyouheiList [2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("cyouheiYR", newCyouheiString); } else if (activeItemType.Contains ("KB") == true) { string cyouheiString = PlayerPrefs.GetString ("cyouheiKB"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (cyouheiList [0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (cyouheiList [1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (cyouheiList [2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("cyouheiKB", newCyouheiString); } else if (activeItemType.Contains ("TP") == true) { string cyouheiString = PlayerPrefs.GetString ("cyouheiTP"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (cyouheiList [0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (cyouheiList [1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (cyouheiList [2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("cyouheiTP", newCyouheiString); } else if (activeItemType.Contains ("YM") == true) { string cyouheiString = PlayerPrefs.GetString ("cyouheiYM"); string[] cyouheiList = cyouheiString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (cyouheiList [0]); tempQty = tempQty + activeItemQty; newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (cyouheiList [1]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (cyouheiList [2]); tempQty = tempQty + activeItemQty; newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("cyouheiYM", newCyouheiString); } //Kanjyo } else if (activeItemType == "Kanjyo") { makeItemIcon (kanjyoPath, activeItemId.ToString (), itemListObj); string newKanjyoString = ""; string kanjyoString = PlayerPrefs.GetString ("kanjyo"); string[] kanjyoList = kanjyoString.Split (delimiterChars); if (activeItemId == 1) { int tempQty = int.Parse (kanjyoList [0]); tempQty = tempQty + activeItemQty; newKanjyoString = tempQty.ToString () + "," + kanjyoList [1] + "," + kanjyoList [2]; } else if (activeItemId == 2) { int tempQty = int.Parse (kanjyoList [1]); tempQty = tempQty + activeItemQty; newKanjyoString = kanjyoList [0] + "," + tempQty.ToString () + "," + kanjyoList [2]; } else if (activeItemId == 3) { int tempQty = int.Parse (kanjyoList [2]); tempQty = tempQty + activeItemQty; newKanjyoString = kanjyoList [0] + "," + kanjyoList [1] + "," + tempQty.ToString (); } PlayerPrefs.SetString ("kanjyo", newKanjyoString); //Hidensyo } else if (activeItemType == "Hidensyo") { makeItemIcon (hidensyoPath, activeItemId.ToString (), itemListObj); if (activeItemId == 1) { int hidensyoQty = PlayerPrefs.GetInt ("hidensyoGe"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt ("hidensyoGe", hidensyoQty); } else if (activeItemId == 2) { int hidensyoQty = PlayerPrefs.GetInt ("hidensyoCyu"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt ("hidensyoCyu", hidensyoQty); } else if (activeItemId == 3) { int hidensyoQty = PlayerPrefs.GetInt ("hidensyoJyo"); hidensyoQty = hidensyoQty + activeItemQty; PlayerPrefs.SetInt ("hidensyoJyo", hidensyoQty); } //Shinobi } else if (activeItemType == "Shinobi") { makeItemIcon (shinobiPath, activeItemId.ToString (), itemListObj); RectTransform rect = itemListObj.transform.FindChild ("itemIcon").transform.FindChild ("Shinobi").GetComponent<RectTransform> (); rect.sizeDelta = new Vector2 (100, 100); if (activeItemId == 1) { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt ("shinobiGe"); newQty = shinobiQty + activeItemQty; PlayerPrefs.SetInt ("shinobiGe", newQty); } else if (activeItemId == 2) { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt ("shinobiCyu"); newQty = shinobiQty + activeItemQty; PlayerPrefs.SetInt ("shinobiCyu", newQty); } else if (activeItemId == 3) { int newQty = 0; int shinobiQty = PlayerPrefs.GetInt ("shinobiJyo"); newQty = shinobiQty + activeItemQty; PlayerPrefs.SetInt ("shinobiJyo", newQty); } //tech } else if (activeItemType == "tech") { string path = "Prefabs/Item/Tech/Tech"; GameObject tech = Instantiate (Resources.Load (path)) as GameObject; tech.transform.SetParent (itemListObj.transform); tech.transform.localScale = new Vector2 (0.4f, 0.4f); RectTransform techTransform = tech.GetComponent<RectTransform> (); techTransform.sizeDelta = new Vector2 (100, 100); techTransform.anchoredPosition3D = new Vector3 (650, 110, 0); tech.GetComponent<Button> ().enabled = false; string spritePath = ""; if (activeItemId == 1) { //TP int qty = PlayerPrefs.GetInt ("transferTP", 0); int newQty = qty + activeItemQty; PlayerPrefs.SetInt ("transferTP", newQty); spritePath = "Prefabs/Item/Tech/Sprite/tp"; } else if (activeItemId == 2) { int qty = PlayerPrefs.GetInt ("transferKB", 0); int newQty = qty + activeItemQty; PlayerPrefs.SetInt ("transferKB", newQty); spritePath = "Prefabs/Item/Tech/Sprite/kb"; } else if (activeItemId == 3) { int qty = PlayerPrefs.GetInt ("transferSNB", 0); int newQty = qty + activeItemQty; PlayerPrefs.SetInt ("transferSNB", newQty); spritePath = "Prefabs/Item/Tech/Sprite/snb"; } tech.GetComponent<Image> ().sprite = Resources.Load (spritePath, typeof(Sprite)) as Sprite; //cyoutei or koueki } else if (activeItemType == "cyoutei" || activeItemType == "koueki") { if (activeItemType == "cyoutei") { string syoukaijyoPath = "Prefabs/Item/cyoutei"; GameObject icon = Instantiate (Resources.Load (syoukaijyoPath)) as GameObject; icon.transform.SetParent (itemListObj.transform); icon.transform.localPosition = new Vector3 (250, 35, 0); icon.transform.localScale = new Vector2 (0.4f, 0.4f); icon.GetComponent<Button> ().enabled = false; if (activeItemId == 1) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "山科言継"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "下"; } else if (activeItemId == 2) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "三条西実枝"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "中"; } else if (activeItemId == 3) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "近衛前久"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "上"; } } else if (activeItemType == "koueki") { string syoukaijyoPath = "Prefabs/Item/koueki"; GameObject icon = Instantiate (Resources.Load (syoukaijyoPath)) as GameObject; icon.transform.SetParent (itemListObj.transform); icon.transform.localPosition = new Vector3 (250, 35, 0); icon.transform.localScale = new Vector2 (0.4f, 0.4f); icon.GetComponent<Button> ().enabled = false; if (activeItemId == 1) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "加藤浄与"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "下"; } else if (activeItemId == 2) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "島井宗室"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "中"; } else if (activeItemId == 3) { GameObject nameObj = icon.transform.FindChild ("Name").gameObject; nameObj.GetComponent<Text> ().text = "茶屋四郎次郎"; nameObj.transform.localScale = new Vector2 (0.08f, 0.1f); icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "上"; } } TabibitoItemGetter syoukaijyo = new TabibitoItemGetter (); syoukaijyo.registerKouekiOrCyoutei (activeItemType, activeItemId); } else if (activeItemType == "Tama") { string path = "Prefabs/Item/Tama"; GameObject icon = Instantiate (Resources.Load (path)) as GameObject; icon.transform.SetParent (itemListObj.transform); icon.transform.localPosition = new Vector3 (250, 35, 0); icon.transform.localScale = new Vector2 (0.4f, 0.4f); icon.GetComponent<Button> ().enabled = false; int nowQty = PlayerPrefs.GetInt ("busyoDama"); int newQty = nowQty + activeItemQty; PlayerPrefs.SetInt ("busyoDama", newQty); } } else if (activeItemGrp == "kahou") { //Kahou string kahouIconPath = "Prefabs/Item/Kahou/" + activeItemType + activeItemId; GameObject kahouIcon = Instantiate (Resources.Load (kahouIconPath)) as GameObject; kahouIcon.transform.SetParent (itemListObj.transform); kahouIcon.name = "itemIcon"; kahouIcon.transform.localPosition = new Vector3 (250, 35, 0); kahouIcon.transform.localScale = new Vector2 (0.4f, 0.4f); RectTransform kahouTransform = kahouIcon.GetComponent<RectTransform> (); kahouTransform.sizeDelta = new Vector2 (100, 100); GameObject rank = kahouIcon.transform.FindChild ("Rank").gameObject; rank.transform.localScale = new Vector2 (0.3f, 0.3f); rank.transform.localPosition = new Vector2 (20, -20); //Register addKahou (activeItemType, activeItemId); } //Qty string itemQtyPath = "Prefabs/PostKassen/itemQty"; GameObject itemQtyObj = Instantiate (Resources.Load (itemQtyPath)) as GameObject; itemQtyObj.transform.SetParent (itemListObj.transform); itemQtyObj.transform.localScale = new Vector2 (0.09f, 0.09f); itemQtyObj.transform.localPosition = new Vector2 (290, 35); itemQtyObj.GetComponent<Text> ().text = "x " + activeItemQty.ToString (); PlayerPrefs.Flush (); } } else { itemListObj.transform.FindChild ("stageName").transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "成功"; } //Money int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney",0); GameObject.Find ("moneyAmt").GetComponent<Text>().text = activeStageMoney.ToString(); int currentMoney = PlayerPrefs.GetInt("money"); currentMoney = currentMoney + activeStageMoney; PlayerPrefs.SetInt("money",currentMoney); //kuniExp int activeStageExp = PlayerPrefs.GetInt("activeStageExp",0); GameObject.Find ("expAmt").GetComponent<Text>().text = activeStageExp.ToString(); int currentKuniExp = PlayerPrefs.GetInt ("kuniExp"); currentKuniExp = currentKuniExp + activeStageExp; int kuniLv = PlayerPrefs.GetInt ("kuniLv"); Exp kuniExp = new Exp(); int newKuniLv = kuniExp.getKuniLv(kuniLv,currentKuniExp); if(newKuniLv>kuniLv){ //lv up int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv); int stockLimit = kuniExp.getStockLimit(newKuniLv); PlayerPrefs.SetInt("jinkeiLimit",jinkeiLimit); PlayerPrefs.SetInt("stockLimit",stockLimit); }else{ Debug.Log ("No level up"); } /*Cleared Flag*/ if(!isAttackedFlg){ int activeKuniId = PlayerPrefs.GetInt("activeKuniId"); int activeStageId = PlayerPrefs.GetInt("activeStageId"); string temp = "kuni" + activeKuniId.ToString(); List<string> clearedStageList = new List<string>(); string clearedStageString = PlayerPrefs.GetString(temp); if(clearedStageString !=null && clearedStageString !=""){ //after 1st time char[] delimiterChars = {','}; clearedStageList = new List<string>(clearedStageString.Split (delimiterChars)); if(clearedStageList.Contains(activeStageId.ToString()) == false){ clearedStageString = clearedStageString + "," + activeStageId.ToString(); //1st Kuni Clear Check string[] commaCounter = clearedStageString.Split(delimiterChars); int counter = commaCounter.Length; if(counter == 10){ //1st time string clearedKuni = PlayerPrefs.GetString("clearedKuni"); if(clearedKuni !=null && clearedKuni !=""){ clearedKuni = clearedKuni + "," + activeKuniId.ToString(); }else{ clearedKuni = activeKuniId.ToString(); } PlayerPrefs.SetString("clearedKuni",clearedKuni); //Give 1st cleared revenue PlayerPrefs.SetBool("kuniClearedFlg",true); //Open Kuni KuniInfo kuni = new KuniInfo(); kuni.registerOpenKuni(activeKuniId); //Seiryoku Change string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string>(); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); seiryokuList[activeKuniId-1] = myDaimyo.ToString(); string newSeiryoku = ""; bool gameClearFlg = true; for(int i=0; i<seiryokuList.Count; i++){ if(i==0){ newSeiryoku = seiryokuList[i]; }else{ newSeiryoku = newSeiryoku + "," + seiryokuList[i]; } //game clear check if(gameClearFlg){ if(seiryokuList[i] != myDaimyo.ToString()){ gameClearFlg = false; } } } PlayerPrefs.SetBool("gameClearFlg",gameClearFlg); PlayerPrefs.SetString("seiryoku",newSeiryoku); //Cyouhou Delete string cyouhouTmp = "cyouhou" + activeKuniId; if (PlayerPrefs.HasKey (cyouhouTmp)) { PlayerPrefs.DeleteKey(cyouhouTmp); string cyouhou = PlayerPrefs.GetString("cyouhou"); List<string> cyouhouList = new List<string> (); if (cyouhou != null && cyouhou != "") { if(cyouhou.Contains(",")){ cyouhouList = new List<string> (cyouhou.Split (delimiterChars)); }else{ cyouhouList.Add(cyouhou); } } cyouhouList.Remove (activeKuniId.ToString()); string newCyouhou = ""; for(int j=0;j<cyouhouList.Count;j++){ if (j == 0) { newCyouhou = cyouhouList[j]; } else { newCyouhou = newCyouhou + "," + cyouhouList[j]; } } PlayerPrefs.SetString ("cyouhou",newCyouhou); } } } }else{ //1st time clearedStageString = activeStageId.ToString(); } PlayerPrefs.SetString(temp,clearedStageString); PlayerPrefs.SetInt("kuniLv",newKuniLv); PlayerPrefs.SetInt("kuniExp",currentKuniExp); PlayerPrefs.Flush(); } //Button List string nextbtnPath = "Prefabs/PostKassen/bttnList"; GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject; bttnListObj.transform.SetParent (canvas.transform); bttnListObj.transform.localScale = new Vector2(1,1); bttnListObj.transform.localPosition = new Vector2 (0,0); //Time Stop GameObject.Find ("timer").GetComponent<Timer>().enabled = false; //Get Exp SenkouButton senkou = new SenkouButton(); List<BusyoSenkou> senkouList = new List<BusyoSenkou>(); senkouList=senkou.getSenkou (); for(int i=0;i<senkouList.Count;i++){ int busyoId = senkouList[i].id; int senkouAmt = senkouList[i].senkou; Exp exp = new Exp(); //Modify by Cyadougu Kahou senkouAmt = exp.getExpbyCyadougu(busyoId,senkouAmt); //Busyo Exp string tempExp = "exp" + busyoId; int nowExp = PlayerPrefs.GetInt(tempExp); int newExp = nowExp + senkouAmt; PlayerPrefs.SetInt(tempExp, newExp); //Busyo Lv int nowLv = PlayerPrefs.GetInt(busyoId.ToString()); int newLv = exp.getLvbyTotalExp(nowLv,newExp); PlayerPrefs.SetInt(busyoId.ToString(), newLv); PlayerPrefs.Flush(); } } } } }
public void Start() { currentKuniId = PlayerPrefs.GetInt("activeKuniId"); string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string>(); char[] delimiterChars = { ',' }; seiryokuList = new List <string>(seiryoku.Split(delimiterChars)); int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); List <int> myKuniList = new List <int>(); for (int m = 0; m < seiryokuList.Count; m++) { int DaimyoId = int.Parse(seiryokuList[m]); if (DaimyoId == myDaimyoId) { myKuniList.Add(m + 1); } } if (myKuniList.Count > 1) { nextExistFlg = true; for (int i = 0; i < myKuniList.Count; i++) { int kuniId = myKuniList[i]; if (currentKuniId == kuniId) { if ((i + 1) == myKuniList.Count) { //back to first nextKuniId = myKuniList[0]; } else { //next nextKuniId = myKuniList[i + 1]; } } } KuniInfo kuniScript = new KuniInfo(); nextKuniName = kuniScript.getKuniName(nextKuniId); if (Application.systemLanguage != SystemLanguage.Japanese) { transform.FindChild("Text").GetComponent <Text>().text = "Next Town\n" + nextKuniName; } else { transform.FindChild("Text").GetComponent <Text>().text = "次の国へ\n" + nextKuniName; } } else { Destroy(gameObject); } }
public void upYukoudo(int addYukoudo){ //Daimyo Id int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); //Seiryoku List string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string> (); char[] delimiterChars = {','}; seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); //src daimyo kuni list List<string> srcDaimyoKuniList = new List<string> (); for(int i=0; i<seiryokuList.Count;i++){ string tempDaimyoId = seiryokuList[i]; if(tempDaimyoId == myDaimyoId.ToString()){ int temp = i + 1; srcDaimyoKuniList.Add(temp.ToString()); } } //src daimyo open kuni list KuniInfo kuni = new KuniInfo(); List<int> openKuniList = new List<int>(); for(int j=0; j<srcDaimyoKuniList.Count; j++){ openKuniList.AddRange(kuni.getMappingKuni(int.Parse(srcDaimyoKuniList[j]))); } //Target Daimyo (exculde this src daimyo & mydaimyo) List<int> dstDaimyoList = new List<int>(); for(int k=0; k<openKuniList.Count;k++){ int temp = openKuniList[k] - 1; int tempDaimyoId = int.Parse(seiryokuList[temp]); if(tempDaimyoId != myDaimyoId){ if(!dstDaimyoList.Contains(tempDaimyoId)){ dstDaimyoList.Add(tempDaimyoId); } } } //Add Yukoudo MainEventHandler main = new MainEventHandler(); Daimyo daimyo = new Daimyo(); string cyouteiText = ""; for(int l=0; l<dstDaimyoList.Count;l++){ int dstDaimyoId = dstDaimyoList[l]; string dstDaimyoName = daimyo.getName(dstDaimyoId); string tempGaikou = "gaikou" + dstDaimyoId; int nowYukoudo = 0; if (PlayerPrefs.HasKey (tempGaikou)) { nowYukoudo = PlayerPrefs.GetInt (tempGaikou); } else { nowYukoudo = 50; } int newYukoudo = nowYukoudo + addYukoudo; if (newYukoudo > 100) { newYukoudo = 100; } PlayerPrefs.SetInt (tempGaikou, newYukoudo); cyouteiText = cyouteiText + dstDaimyoName + "との友好度が" + addYukoudo + "上がりました。\t"; } PlayerPrefs.Flush(); //Message Message msg = new Message (); string OKtext = "周辺大名との友好度が上がります。\t " + cyouteiText; msg.makeMessage (OKtext); }
public void MakeKassenComment(string kassenWinLoseFlee, int enemyDaimyoId, int kuniId) { //make comment object GameObject commentObj = MakeCommentObj(enemyDaimyoId, kuniId); //Comment List <string> kassenWinLoseFleeList = new List <string> (); kassenWinLoseFleeList = new List <string> (kassenWinLoseFlee.Split(delimiterChars)); int myDaimyoBusyo = PlayerPrefs.GetInt("myDaimyoBusyo"); string myDiamyoName = busyo.getName(myDaimyoBusyo); //Comment Select string finalComment = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { if (kassenWinLoseFleeList [1] == "2") { //Player Win string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0])); int powerTyp = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0])); if (powerTyp == 1) { finalComment = "Aw, hell! We lost " + stageNmae + " castle and face."; } else if (powerTyp == 2) { finalComment = "What? " + stageNmae + " is strategic site for managing the territory. Let's get it back!"; } else if (powerTyp == 3) { finalComment = "Aw, hell! " + myDiamyoName + "! We must get " + stageNmae + " castle back!"; } } else if (kassenWinLoseFleeList [1] == "1") { //Flee string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0])); int powerTyp = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0])); finalComment = "Hahaha, " + myDiamyoName + ". He ran away due to well-fortified " + stageNmae + " castle."; } else if (kassenWinLoseFleeList [1] == "0") { //Player Lose string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0])); int powerTyp = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0])); if (powerTyp == 1) { finalComment = "Haha, We have a good soldiers! We defeated " + myDiamyoName + "."; } else if (powerTyp == 2) { finalComment = "Hahaha, " + myDiamyoName + " ran away! He will give up to aim " + stageNmae + " castle."; } else if (powerTyp == 3) { finalComment = "Our samurai, Raise a battle cry! We won the battle and defended " + stageNmae + " castle!"; } } else if (kassenWinLoseFleeList [1] == "3") { //Kuni KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); finalComment = "We lost " + kuniName + " castle... Damn it " + myDiamyoName + ". Let's bury our resentment deep in our hearts!"; } else if (kassenWinLoseFleeList [1] == "4") { //Metsubou finalComment = "It's a fall of our family...It was short-lived. How earn my place in history?"; } } else { if (kassenWinLoseFleeList[1] == "2") { //Player Win string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0])); int powerTyp = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0])); if (powerTyp == 1) { finalComment = "うぬ、" + stageNmae + "を落とされたか。このままでは主家の面目が立たぬわ。"; } else if (powerTyp == 2) { finalComment = "なんと!" + stageNmae + "は重要拠点…。孤立する前に取り返すぞ。"; } else if (powerTyp == 3) { finalComment = "おのれ、" + myDiamyoName + "め!" + stageNmae + "の借りは必ず返してくれる。"; } } else if (kassenWinLoseFleeList[1] == "1") { //Flee string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0])); int powerTyp = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0])); finalComment = "ははは、" + myDiamyoName + "め、あまりの" + stageNmae + "の堅固さに、戦わずに逃げ帰りおったぞ!"; } else if (kassenWinLoseFleeList[1] == "0") { //Player Lose string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0])); int powerTyp = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0])); if (powerTyp == 1) { finalComment = "ははは、者共、見事な槍働きじゃ!" + myDiamyoName + "めを叩き潰したぞ。"; } else if (powerTyp == 2) { finalComment = "ははは、" + myDiamyoName + "め、ほうほうの体で逃げ帰りおったわ。" + stageNmae + "の堅固さに舌をまいたろうて。"; } else if (powerTyp == 3) { finalComment = "勝ち鬨を上げよ、我等が勝利じゃ!天下の険、" + stageNmae + "を落とせるわけがなかろう。"; } } else if (kassenWinLoseFleeList[1] == "3") { //Kuni KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); finalComment = "我が" + kuniName + "を盗られてしまった…。おのれ、" + myDiamyoName + "め。この雪辱、必ず晴らしてくれようぞ!"; } else if (kassenWinLoseFleeList[1] == "4") { //Metsubou finalComment = "当家もお終いか…。儚い世であったわ。我が名は後世にどう残るのかのう。"; } } commentObj.transform.FindChild("SerihuText").GetComponent <Text> ().text = finalComment; }
public void mainHandler(){ /*Basic Info*/ //make kuni list string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string> (); char[] delimiterChars = {','}; seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); GameObject targetKuni = GameObject.Find ("KuniIconView"); /*Kassen*/ //1. Randome choice Kassen Qty between 0,1,2,3 //2. Ratio 50% check //3. Random choice Kassen Souce Kuni 1-65 //4. Destination Check by Mapping // if Same Daimyo between Kassen Souce & Destination Kuni => Skip // else => Make guntai Instance // 4-1. Destination == myDaimyo // 4-2. Destination == has own relation or master relation // //Message List<string> messageList = new List<string> (); //Count Kassen Qty int kassenQty = CountEnemyKassenAction (); for (int i=1; i<kassenQty+1; i++) { //Check Kassen or Not bool kassenFlg = CheckByProbability (kassenRatio); if (kassenFlg == true) { //target kuni extraction while (true) { int randomKuni = UnityEngine.Random.Range (1, 65); string eDaimyo = seiryokuList [randomKuni - 1]; string tDaimyo = ""; bool doumeiFlg = false; if (eDaimyo != myDaimyo.ToString ()) { //Check Kuni Mapping List<int> targetKuniList = new List<int> (); KuniInfo kuni = new KuniInfo (); targetKuniList = kuni.getMappingKuni (randomKuni); //Yukoudo Check int worstGaikouDaimyo = 0; int worstGaikouValue = 100; int worstGaikouKuni = 0; int worstHeiryokuValue = 100000000; SendParam srcSendParam = targetKuni.transform.FindChild (randomKuni.ToString ()).GetComponent<SendParam> (); bool aggressiveFlg = srcSendParam.aggressiveFlg; for (int k=0; k<targetKuniList.Count; k++) { SendParam sendParam = targetKuni.transform.FindChild (targetKuniList [k].ToString ()).GetComponent<SendParam> (); if (aggressiveFlg) { //Find worst gaikou daimyo tDaimyo = seiryokuList [targetKuniList [k] - 1]; int gaikouValue = 0; if (eDaimyo != tDaimyo) { if (tDaimyo == myDaimyo.ToString ()) { //Get Gaikou Value string eGaikouM = "gaikou" + eDaimyo; gaikouValue = PlayerPrefs.GetInt (eGaikouM); } else { //Gaikou Data Check string gaikouTemp = ""; if (int.Parse (eDaimyo) < int.Parse (tDaimyo)) { gaikouTemp = eDaimyo + "gaikou" + tDaimyo; } else { gaikouTemp = tDaimyo + "gaikou" + eDaimyo; } if (PlayerPrefs.HasKey (gaikouTemp)) { //exsit gaikouValue = PlayerPrefs.GetInt (gaikouTemp); } else { //non exist //gaikou check gaikouValue = gaikou.getGaikouValue (int.Parse (eDaimyo), int.Parse (tDaimyo)); } } //Compare with Previous one if (worstGaikouValue > gaikouValue) { worstGaikouValue = gaikouValue; worstGaikouDaimyo = int.Parse (tDaimyo); worstGaikouKuni = targetKuniList [k]; } } } else { //Find worst heiryoku daimyo tDaimyo = seiryokuList [targetKuniList [k] - 1]; if (eDaimyo != tDaimyo) { //Heiryoku Check int heiryoku = sendParam.heiryoku; //Compare with Previous one if (worstHeiryokuValue > heiryoku) { worstHeiryokuValue = heiryoku; int gaikouValue = 0; if (tDaimyo == myDaimyo.ToString ()) { //Get Gaikou Value string eGaikouM = "gaikou" + eDaimyo; gaikouValue = PlayerPrefs.GetInt (eGaikouM); } else { //Gaikou Data Check string gaikouTemp = ""; if (int.Parse (eDaimyo) < int.Parse (tDaimyo)) { gaikouTemp = eDaimyo + "gaikou" + tDaimyo; } else { gaikouTemp = tDaimyo + "gaikou" + eDaimyo; } if (PlayerPrefs.HasKey (gaikouTemp)) { //exsit gaikouValue = PlayerPrefs.GetInt (gaikouTemp); } else { //non exist gaikouValue = gaikou.getGaikouValue (int.Parse (eDaimyo), int.Parse (tDaimyo)); } } worstGaikouValue = gaikouValue; worstGaikouDaimyo = int.Parse (tDaimyo); worstGaikouKuni = targetKuniList [k]; } } } }//Loop End //Create Guntai Instance if (worstGaikouValue != 100) { int kassenRatio2 = 100 - worstGaikouValue; //doumei check string doumeiCheck = "doumei" + eDaimyo; if(PlayerPrefs.HasKey(doumeiCheck)){ string cDoumei = PlayerPrefs.GetString(doumeiCheck); List<string> cDoumeiList = new List<string>(); if(cDoumei.Contains(",")){ cDoumeiList = new List<string> (cDoumei.Split (delimiterChars)); }else{ cDoumeiList.Add(cDoumei); } //If Doumei Daimyo -> Half Ratio if(cDoumeiList.Contains(worstGaikouDaimyo.ToString())){ doumeiFlg = true; kassenRatio2 = kassenRatio2/2; }else{ doumeiFlg = false; } } bool GaikouValueFlg = CheckByProbability (kassenRatio2); if (GaikouValueFlg) { //Make Guntai Instance string key = randomKuni.ToString () + "-" + worstGaikouKuni.ToString (); bool ExistFlg = false; //Exist Check Same Daimyo foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")){ int gunzeiSrcDaimyoId = obs.GetComponent<Gunzei>().srcDaimyoId; if(int.Parse(eDaimyo) == gunzeiSrcDaimyoId){ ExistFlg = true; } } if(!ExistFlg){ string path = "Prefabs/Map/Gunzei"; GameObject Gunzei = Instantiate (Resources.Load (path)) as GameObject; Gunzei.transform.SetParent (GameObject.Find ("Panel").transform); Gunzei.transform.localScale = new Vector2 (1, 1); //Location int srcX = kuni.getKuniLocationX(randomKuni); int srcY = kuni.getKuniLocationY(randomKuni); int dstX = kuni.getKuniLocationX(worstGaikouKuni); int dstY = kuni.getKuniLocationY(worstGaikouKuni); string direction = ""; Gunzei gunzei = new Gunzei (); if(srcX < dstX){ Gunzei.transform.localScale = new Vector2 (1, 1); direction = "right"; }else{ Gunzei.transform.localScale = new Vector2 (-1, 1); direction = "left"; Gunzei.GetComponent<Gunzei> ().leftFlg = true; } int aveX = (srcX + dstX)/2; int aveY = (srcY + dstY)/2; RectTransform GunzeiTransform = Gunzei.GetComponent<RectTransform> (); GunzeiTransform.anchoredPosition = new Vector3 (aveX, aveY, 0); Gunzei.GetComponent<Gunzei> ().key = key; Gunzei.GetComponent<Gunzei> ().srcKuni = randomKuni; Gunzei.GetComponent<Gunzei> ().srcDaimyoId = int.Parse (eDaimyo); string srcDaimyoName = daimyo.getName (int.Parse (eDaimyo)); Gunzei.GetComponent<Gunzei> ().srcDaimyoName = srcDaimyoName; Gunzei.GetComponent<Gunzei> ().dstKuni = worstGaikouKuni; Gunzei.GetComponent<Gunzei> ().dstDaimyoId = worstGaikouDaimyo; string dstDaimyoName = daimyo.getName (worstGaikouDaimyo); Gunzei.GetComponent<Gunzei> ().dstDaimyoName = dstDaimyoName; int myHei = gunzei.heiryokuCalc (randomKuni); Gunzei.GetComponent<Gunzei> ().myHei = myHei; Gunzei.name = key; //Engun from Doumei Doumei doumei = new Doumei(); List<string> doumeiDaimyoList = new List<string> (); bool dstEngunFlg = false; string dstEngunDaimyoId = ""; //2:3:5 string dstEngunHei = ""; string dstEngunSts = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv: int totalEngunHei = 0; doumeiDaimyoList = doumei.doumeiExistCheck(worstGaikouDaimyo,eDaimyo); if(doumeiDaimyoList.Count != 0){ //Doumei Exist //Trace Check List<string> okDaimyoList = new List<string> (); List<string> checkList = new List<string> (); okDaimyoList = doumei.traceNeighborDaimyo(worstGaikouKuni, worstGaikouDaimyo, doumeiDaimyoList, seiryokuList, checkList,okDaimyoList); if(okDaimyoList.Count !=0){ //Doumei & Neghbor Daimyo Exist for(int k=0; k<okDaimyoList.Count; k++){ string engunDaimyo = okDaimyoList[k]; int yukoudo = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), worstGaikouDaimyo); //engun check dstEngunFlg = CheckByProbability (yukoudo); if(dstEngunFlg){ //Engun OK dstEngunFlg = true; if(dstEngunDaimyoId !=null && dstEngunDaimyoId !=""){ dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo; string tempEngunSts = getEngunSts(engunDaimyo); int tempEngunHei = getEngunHei(tempEngunSts); dstEngunHei = dstEngunHei + ":" + tempEngunHei.ToString(); totalEngunHei = totalEngunHei + tempEngunHei; dstEngunSts = dstEngunSts + ":" + tempEngunSts; }else{ dstEngunDaimyoId = engunDaimyo; string tempEngunSts = getEngunSts(engunDaimyo); int tempEngunHei = getEngunHei(tempEngunSts); dstEngunHei = tempEngunHei.ToString(); totalEngunHei = tempEngunHei; dstEngunSts = tempEngunSts; } } } Gunzei.GetComponent<Gunzei> ().dstEngunFlg = dstEngunFlg; Gunzei.GetComponent<Gunzei> ().dstEngunDaimyoId = dstEngunDaimyoId; Gunzei.GetComponent<Gunzei> ().dstEngunHei = dstEngunHei; Gunzei.GetComponent<Gunzei> ().dstEngunSts = dstEngunSts; } } //Set Value //CreateTime,srcDaimyoId,dstDaimyoId,srcDaimyoName,dstDaimyoName, srcHei,locationX,locationY,left or right, engunFlg, engunDaimyoId(A:B:C), dstEngunHei(1000:2000:3000), dstEngunSts string keyValue = ""; string createTime = System.DateTime.Now.ToString (); keyValue = createTime + "," + eDaimyo + "," + worstGaikouDaimyo + "," + srcDaimyoName + "," + dstDaimyoName + "," + myHei + "," + aveX + "," + aveY + "," + direction + "," + dstEngunFlg + "," + dstEngunDaimyoId + "," + dstEngunHei + ","+ dstEngunSts; PlayerPrefs.SetString (key, keyValue); string keyHistory = PlayerPrefs.GetString ("keyHistory"); if(keyHistory == null || keyHistory == ""){ keyHistory = key; }else{ keyHistory = keyHistory + "," + key; } PlayerPrefs.SetString ("keyHistory", keyHistory); flush (); string kassenText = ""; if(!dstEngunFlg){ kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。"; }else{ kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。\n防衛側の同盟国が援軍" + totalEngunHei + "人を派兵しました。"; } messageList.Add (kassenText); if(doumeiFlg){ //Delete doumei doumei.deleteDoumei(eDaimyo, worstGaikouDaimyo.ToString()); //Zero Gaikou string tempYukou = ""; if(tDaimyo == myDaimyo.ToString()){ tempYukou = "gaikou" + eDaimyo; }else{ if(worstGaikouDaimyo < int.Parse(eDaimyo)){ tempYukou = worstGaikouDaimyo.ToString() + "gaikou" + eDaimyo; }else{ tempYukou = eDaimyo + "gaikou" + worstGaikouDaimyo.ToString(); } } PlayerPrefs.SetInt(tempYukou,0); PlayerPrefs.Flush (); } } } } break; } } } } /************/ /***Gaikou***/ /************/ int gaikouQty = CountEnemyGaikouAction (); for (int i=1; i<gaikouQty+1; i++) { bool gaikouFlg = CheckByProbability (gaikouRatio); if (gaikouFlg == true) { //Do gaikou int randomKuni = UnityEngine.Random.Range (1, 66); int srcDaimyoId = int.Parse (seiryokuList [randomKuni - 1]); string srcDaimyoName = daimyo.getName (srcDaimyoId); if (srcDaimyoId != myDaimyo) { List<int> targetKuniList = new List<int> (); KuniInfo kuni = new KuniInfo (); targetKuniList = kuni.getMappingKuni (randomKuni); //Yukoudo Check int bestGaikouDaimyo = 0; int bestGaikouValue = 0; int bestGaikouKuni = 0; int bestHeiryokuValue = 0; SendParam sendParamSrc = targetKuni.transform.FindChild (randomKuni.ToString ()).GetComponent<SendParam> (); bool aggressiveFlg = sendParamSrc.aggressiveFlg; for (int k=0; k<targetKuniList.Count; k++) { SendParam sendParam = targetKuni.transform.FindChild (targetKuniList [k].ToString ()).GetComponent<SendParam> (); if (aggressiveFlg) { //Find best gaikou daimyo int dstDaimyoId = int.Parse (seiryokuList [targetKuniList [k] - 1]); int gaikouValue = 0; if (srcDaimyoId != dstDaimyoId) { if (dstDaimyoId == myDaimyo) { //Get Gaikou Value string eGaikouM = "gaikou" + srcDaimyoId; gaikouValue = PlayerPrefs.GetInt (eGaikouM); } else { //Gaikou Data Check string gaikouTemp = ""; if (srcDaimyoId < dstDaimyoId) { gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId; } else { gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId; } if (PlayerPrefs.HasKey (gaikouTemp)) { //exsit gaikouValue = PlayerPrefs.GetInt (gaikouTemp); } else { //non exist //gaikou check gaikouValue = gaikou.getGaikouValue (srcDaimyoId, dstDaimyoId); } } //Compare with Previous one //Best one if (gaikouValue >= bestGaikouValue) { bestGaikouValue = gaikouValue; bestGaikouDaimyo = dstDaimyoId; bestGaikouKuni = targetKuniList [k]; } } } else { //Find best heiryoku daimyo int dstDaimyoId = int.Parse (seiryokuList [targetKuniList [k] - 1]); if (srcDaimyoId != dstDaimyoId) { //Heiryoku Check int heiryoku = sendParam.heiryoku; //Compare with Previous one if (heiryoku >= bestHeiryokuValue) { bestHeiryokuValue = heiryoku; int gaikouValue = 0; if (dstDaimyoId == myDaimyo) { //Get Gaikou Value string eGaikouM = "gaikou" + srcDaimyoId; gaikouValue = PlayerPrefs.GetInt (eGaikouM); } else { //Gaikou Data Check string gaikouTemp = ""; if (srcDaimyoId < dstDaimyoId) { gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId; } else { gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId; } if (PlayerPrefs.HasKey (gaikouTemp)) { //exsit gaikouValue = PlayerPrefs.GetInt (gaikouTemp); } else { //non exist gaikouValue = gaikou.getGaikouValue (srcDaimyoId, dstDaimyoId); } } bestGaikouValue = gaikouValue; bestGaikouDaimyo = dstDaimyoId; bestGaikouKuni = targetKuniList [k]; } } } }//Loop End //Gaikou Action float percent = UnityEngine.Random.value; percent = percent * 100; int gaikouAction = 0; if (percent <= 60) { gaikouAction = 1; //Mitsugi } else if (60 < percent && percent <= 97) { gaikouAction = 2; //Ryugen } else if (97 < percent && percent <= 100) { gaikouAction = 3; //Doumei } if (gaikouAction == 1) { //1. yukoudo up(Mitsugimono) bool yukoudoUpFlg = CheckByProbability (yukoudoUpMissRatio); if (yukoudoUpFlg == true) { //Choose Target Daimyo string dstDaimyoName = daimyo.getName (bestGaikouDaimyo); if (bestGaikouDaimyo == myDaimyo) { //In the case that MyDaimyo receive Mitsugimono int addYukoudo = UpYukouValueWithMyDaimyo (myDaimyo, bestGaikouDaimyo); int addMoney = addYukoudo * 1000; string yukouUpText = srcDaimyoName + "殿が御屋形様に、金" + addMoney.ToString() + "の貢物を送って参りました。\t友好度が" + addYukoudo + "上がります。"; int myMoney = PlayerPrefs.GetInt("money"); myMoney = myMoney + addMoney; PlayerPrefs.SetInt("money",myMoney); flush (); GameObject.Find ("MoneyValue").GetComponent<Text>().text = myMoney.ToString(); messageList.Add (yukouUpText); } else { //In the case between other daimyos int addYukoudo = UpYukouValueWithOther (srcDaimyoId, bestGaikouDaimyo); string yukouUpText = srcDaimyoName + "が" + dstDaimyoName + "に貢物をしました。友好度が" + addYukoudo + "上がります。"; messageList.Add (yukouUpText); } } } else if (gaikouAction == 2) { //2. yukoudo down(Ryugen) bool yukoudoDownFlg = CheckByProbability (yukoudoDownMissRatio); if (yukoudoDownFlg == true) { //Choose Target Daimyo int reduceYukoudo = 0; if (bestGaikouDaimyo != 0) { if (bestGaikouDaimyo == myDaimyo) { //My Daimyo string dstDaimyoName = ""; reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, srcDaimyoId); dstDaimyoName = daimyo.getName (srcDaimyoId); string yukouDownText = "何者かが当家と" + dstDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。"; messageList.Add (yukouDownText); } else { reduceYukoudo = DownYukouValueWithOther (srcDaimyoId, bestGaikouDaimyo); string dst1stDaimyoName = daimyo.getName (srcDaimyoId); string dst2ndDaimyoName = daimyo.getName (bestGaikouDaimyo); string yukouDownText = "何者かが" + dst1stDaimyoName + "と" + dst2ndDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。"; messageList.Add (yukouDownText); } } } } else if (gaikouAction == 3) { //3. doumei Gaikou gaiko = new Gaikou(); int yukoudo = gaikou.getExistGaikouValue(srcDaimyoId, bestGaikouDaimyo); bool doumeiFlg = CheckByProbability (yukoudo); if (doumeiFlg == true) { if (bestGaikouDaimyo == myDaimyo) { // // // // // // // // } else { //Exist Check string doumeiTmp = "doumei" + srcDaimyoId; string doumeiString = PlayerPrefs.GetString (doumeiTmp); List<string> doumeiList = new List<string> (); if (doumeiString != null && doumeiString != "") { if (doumeiString.Contains (",")) { doumeiList = new List<string> (doumeiString.Split (delimiterChars)); } else { doumeiList.Add (doumeiString); } } if (!doumeiList.Contains (bestGaikouDaimyo.ToString())) { //Not Exist Case //Doumei Data Register string newDoumei1 = ""; if (doumeiString != null && doumeiString != "") { newDoumei1 = doumeiString + "," + bestGaikouDaimyo; } else { newDoumei1 = bestGaikouDaimyo.ToString(); } PlayerPrefs.SetString (doumeiTmp, newDoumei1); string doumeiTmp2 = "doumei" + bestGaikouDaimyo; string doumeiString2 = PlayerPrefs.GetString (doumeiTmp2); string newDoumei2 = ""; if (doumeiString2 != null && doumeiString2 != "") { newDoumei2 = doumeiString2 + "," + srcDaimyoId; } else { newDoumei2 = srcDaimyoId.ToString(); } PlayerPrefs.SetString (doumeiTmp2, newDoumei2); flush (); string dst1stDaimyoName = daimyo.getName (srcDaimyoId); string dst2ndDaimyoName = daimyo.getName (bestGaikouDaimyo); string doumeiText = dst1stDaimyoName + "と" + dst2ndDaimyoName + "間に同盟が成立しました。"; messageList.Add (doumeiText); } } } } //else if (gaikouAction == 4) { //add here //} } } } //Check Shinobi Cyouhou string cyouhou = PlayerPrefs.GetString("cyouhou"); List<string> cyouhouList = new List<string> (); if (cyouhou != null && cyouhou != "") { if(cyouhou.Contains(",")){ cyouhouList = new List<string> (cyouhou.Split (delimiterChars)); }else{ cyouhouList.Add(cyouhou); } } for(int i=0; i<cyouhouList.Count; i++){ int kuniId = int.Parse(cyouhouList [i]); string snbTmp = "cyouhou" + kuniId.ToString (); int rank = PlayerPrefs.GetInt(snbTmp); float missPercent = 0; if(rank == 1){ missPercent = 30; }else if(rank == 2){ missPercent = 15; }else if(rank == 3){ missPercent = 5; } float percent = Random.value; percent = percent * 100; if (percent < missPercent) { //Miss PlayerPrefs.DeleteKey(snbTmp); cyouhouList.Remove (kuniId.ToString()); string newCyouhou = ""; for(int j=0;j<cyouhouList.Count;j++){ if (j == 0) { newCyouhou = cyouhouList[j]; } else { newCyouhou = newCyouhou + "," + cyouhouList[j]; } } PlayerPrefs.SetString ("cyouhou",newCyouhou); //Reset Chouhou Id targetKuni.transform.FindChild(kuniId.ToString()).GetComponent<SendParam>().cyouhouSnbRankId = 0; //Message KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); int daimyoId = int.Parse(seiryokuList [kuniId - 1]); Daimyo daimyo = new Daimyo (); string daimyoName = daimyo.getName (daimyoId); int reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, daimyoId); string cyouhouMissText = kuniName + "に潜伏中の忍が見つかりました。\n" + daimyoName + "との友好度が"+reduceYukoudo+"下がりました。"; messageList.Add (cyouhouMissText); } } PlayerPrefs.Flush(); /*Decrease Yukou with Doumei koku*/ string myDoumei = PlayerPrefs.GetString ("doumei"); List<string> myDoumeiList = new List<string> (); if (myDoumei != null && myDoumei != "") { if(myDoumei.Contains(",")){ myDoumeiList = new List<string> (myDoumei.Split (delimiterChars)); }else{ myDoumeiList.Add(myDoumei); } } for (int j=0; j<myDoumeiList.Count; j++) { string doumeiDaimyo = myDoumeiList[j]; string yukouTemp = "gaikou" + doumeiDaimyo; int yukouWithDoumei = PlayerPrefs.GetInt (yukouTemp); int reduceYukou = UnityEngine.Random.Range(0,3); yukouWithDoumei = yukouWithDoumei - reduceYukou; PlayerPrefs.SetInt (yukouTemp,yukouWithDoumei); /*Doumei Clear Check*/ if(yukouWithDoumei<30){ //My Doumei Clear myDoumeiList.Remove(doumeiDaimyo); string newMyDoumei = ""; for(int i=0; i<myDoumeiList.Count; i++){ if(i==0){ newMyDoumei = myDoumeiList[i]; }else{ newMyDoumei = newMyDoumei + "," + myDoumeiList[i]; } } PlayerPrefs.SetString ("doumei",newMyDoumei); //Opposite Doumei Clear string otherTemp = "doumei" + doumeiDaimyo; string otherDoumei = PlayerPrefs.GetString (otherTemp); List<string> otherDoumeiList = new List<string> (); if (otherDoumei != null && otherDoumei != "") { if(otherDoumei.Contains(",")){ otherDoumeiList = new List<string> (otherDoumei.Split (delimiterChars)); }else{ otherDoumeiList.Add(otherDoumei); } } otherDoumeiList.Remove(myDaimyo.ToString()); string newOtherDoumei = ""; for(int i=0; i<otherDoumeiList.Count; i++){ if(i==0){ newOtherDoumei = otherDoumeiList[i]; }else{ newOtherDoumei = newOtherDoumei + "," + otherDoumeiList[i]; } } PlayerPrefs.SetString (otherTemp,newOtherDoumei); //Icon & Flg Change KuniInfo kuni = new KuniInfo(); kuni.deleteDoumeiKuniIcon(int.Parse(doumeiDaimyo)); //Message string dstDaimyoName = daimyo.getName (int.Parse(doumeiDaimyo)); string doumeiClearText = "友好度悪化により、当家と" + dstDaimyoName + "間の同盟が解消しました。"; messageList.Add (doumeiClearText); } PlayerPrefs.Flush(); } /*Decrease Yukou with Doumei koku in other county*/ List<string> activeDaimyoList = new List<string> (); for (int k=0; k<seiryokuList.Count; k++) { string daimyoId = seiryokuList[k]; if(int.Parse(daimyoId) != myDaimyo && !activeDaimyoList.Contains(daimyoId)){ activeDaimyoList.Add(daimyoId); } } for(int l=0; l<activeDaimyoList.Count; l++){ string activeDaimyoId = activeDaimyoList[l]; string temp = "doumei" + activeDaimyoId; if(PlayerPrefs.HasKey(temp)){ string doumeiString = PlayerPrefs.GetString(temp); if(doumeiString != null && doumeiString != ""){ List<string> doumeiTargetList = new List<string> (); if(doumeiString.Contains(",")){ doumeiTargetList = new List<string> (doumeiString.Split (delimiterChars)); }else{ doumeiTargetList.Add(doumeiString); } for(int m=0; m<doumeiTargetList.Count; m++){ string targetDaimyoId = doumeiTargetList[m]; string gaikoTemp = ""; if(int.Parse(activeDaimyoId)<int.Parse(targetDaimyoId)){ gaikoTemp = activeDaimyoId + "gaikou" + targetDaimyoId; }else{ gaikoTemp = targetDaimyoId + "gaikou" + activeDaimyoId; } if(PlayerPrefs.HasKey(gaikoTemp)){ int gaikouValue = PlayerPrefs.GetInt(gaikoTemp); if(gaikouValue <30){ //Doumei Clear //src to dst doumeiTargetList.Remove(targetDaimyoId); string newDoumei1 = ""; for(int n=0; n<doumeiTargetList.Count; n++){ if(n==0){ newDoumei1 = doumeiTargetList[n]; }else{ newDoumei1 = newDoumei1 +"," + doumeiTargetList[n]; } } PlayerPrefs.SetString(temp,newDoumei1); //dst to src string tgtTemp = "doumei" + targetDaimyoId; string tgtDoumeiString = PlayerPrefs.GetString(tgtTemp); List<string> tgtDoumeiList = new List<string> (); if(tgtDoumeiString!=null && tgtDoumeiString != ""){ if(tgtDoumeiString.Contains(",")){ tgtDoumeiList = new List<string> (tgtDoumeiString.Split (delimiterChars)); }else{ tgtDoumeiList.Add(tgtDoumeiString); } tgtDoumeiList.Remove(activeDaimyoId); string newDoumei2 = ""; for(int n=0; n<tgtDoumeiList.Count; n++){ if(n==0){ newDoumei2 = tgtDoumeiList[n]; }else{ newDoumei2 = newDoumei2 +"," + tgtDoumeiList[n]; } } PlayerPrefs.SetString(tgtTemp,newDoumei2); } string srcDaimyoName = daimyo.getName(int.Parse(activeDaimyoId)); string dstDaimyoName = daimyo.getName(int.Parse(targetDaimyoId)); string doumeiClearText = "友好度悪化により、"+ srcDaimyoName+"と" + dstDaimyoName + "間の同盟が解消しました。"; messageList.Add (doumeiClearText); PlayerPrefs.Flush(); } } } } } } //Delete Cyouryaku Data string cyoryakuHst = PlayerPrefs.GetString("cyouryaku"); List<string> cyoryakuHstList = new List<string> (); if(cyoryakuHst != null && cyoryakuHst != ""){ if (cyoryakuHst.Contains (",")) { cyoryakuHstList = new List<string> (cyoryakuHst.Split (delimiterChars)); } else { cyoryakuHstList.Add (cyoryakuHst); } for (int i=0; i<cyoryakuHstList.Count; i++) { string tmp = cyoryakuHstList [i]; PlayerPrefs.DeleteKey (tmp); } PlayerPrefs.DeleteKey ("cyouryaku"); PlayerPrefs.Flush (); } /*Message*/ if (messageList.Count != 0) { /*Common Process*/ //make back string pathOfBack = "Prefabs/Common/TouchBack"; GameObject back = Instantiate(Resources.Load (pathOfBack)) as GameObject; back.transform.SetParent(GameObject.Find ("Panel").transform); back.transform.localScale = new Vector2 (1,1); back.transform.localPosition = new Vector2 (0,0); //make board string pathOfBoard = "Prefabs/Event/EventBoard"; GameObject board = Instantiate(Resources.Load (pathOfBoard)) as GameObject; board.transform.SetParent(GameObject.Find ("Panel").transform); board.transform.localScale = new Vector2 (1,1); string pathOfScroll = "Prefabs/Event/EventScrollView"; GameObject scroll = Instantiate(Resources.Load (pathOfScroll)) as GameObject; scroll.transform.SetParent(board.transform); scroll.transform.localScale = new Vector2 (1,1); RectTransform scrollTransform = scroll.GetComponent<RectTransform> (); scrollTransform.anchoredPosition = new Vector3 (0, -40, 0); string pathOfSlot = "Prefabs/Event/EventSlot"; foreach (string text in messageList) { GameObject slot = Instantiate(Resources.Load (pathOfSlot)) as GameObject; slot.transform.SetParent(scroll.transform.FindChild("Content").transform); slot.transform.FindChild("EventText").GetComponent<Text>().text = text; slot.transform.localScale = new Vector2 (1,1); } } }
public void dataMake(bool busyoExitFlg, int newDaimyo, int newDaimyoBusyo, string heisyu, bool sameDaimyoFlg) { /*******************************/ /***** Base Value *****/ /*******************************/ System.DateTime now = System.DateTime.Now; PlayerPrefs.SetString("lasttime", now.ToString()); //PlayerPrefs.SetInt ("hyourou",100); //PlayerPrefs.SetInt ("money",10000); PlayerPrefs.SetString("yearSeason", "1560,1"); PlayerPrefs.DeleteKey("gameClearFlg"); PlayerPrefs.DeleteKey("gameClearItemGetFlg"); PlayerPrefs.DeleteKey("gameOverFlg"); PlayerPrefs.DeleteKey("kuniClearedFlg"); /*******************************/ /***** Delete History *****/ /*******************************/ PlayerPrefs.DeleteKey("TrackTotalKassenNo"); PlayerPrefs.DeleteKey("TrackWinNo"); PlayerPrefs.DeleteKey("TrackTettaiNo"); PlayerPrefs.DeleteKey("TrackBiggestDaimyoId"); PlayerPrefs.DeleteKey("TrackBiggestDaimyoHei"); PlayerPrefs.DeleteKey("TrackMyBiggestHei"); PlayerPrefs.DeleteKey("TrackNewBusyoHireNo"); PlayerPrefs.DeleteKey("TrackEarnMoney"); PlayerPrefs.DeleteKey("TrackGetMoneyNo"); PlayerPrefs.DeleteKey("TrackGetHyourouNo"); PlayerPrefs.DeleteKey("TrackGetSozaiNo"); PlayerPrefs.DeleteKey("TrackBuildMoneyNo"); PlayerPrefs.DeleteKey("TrackJyosyuNinmeiNo"); PlayerPrefs.DeleteKey("TrackTabibitoNo"); PlayerPrefs.DeleteKey("TrackIjinNo"); PlayerPrefs.DeleteKey("HstNanbansen"); PlayerPrefs.DeleteKey("TrackGaikouNo"); PlayerPrefs.DeleteKey("TrackGaikouMoneyNo"); PlayerPrefs.DeleteKey("TrackDoumeiNo"); PlayerPrefs.DeleteKey("TrackCyouteiNo"); PlayerPrefs.DeleteKey("TrackSyouninNo"); PlayerPrefs.DeleteKey("TrackToubatsuNo"); PlayerPrefs.DeleteKey("TrackBouryakuNo"); PlayerPrefs.DeleteKey("TrackBouryakuSuccessNo"); PlayerPrefs.DeleteKey("TrackCyouhouNo"); PlayerPrefs.DeleteKey("TrackRyugenNo"); PlayerPrefs.DeleteKey("TrackGihouHei"); PlayerPrefs.DeleteKey("TrackCyouryakuNo"); PlayerPrefs.DeleteKey("TrackLinkCutNo"); PlayerPrefs.DeleteKey("TrackSyuppeiNo"); /*******************************/ /***** Delete Temp Value *****/ /*******************************/ PlayerPrefs.DeleteKey("playerEngunList"); PlayerPrefs.DeleteKey("enemyEngunList"); PlayerPrefs.DeleteKey("playerKyoutouList"); PlayerPrefs.DeleteKey("tempKyoutouList"); PlayerPrefs.DeleteKey("keyHistory"); PlayerPrefs.DeleteKey("metsubou"); HPCounter deleteGunzeiScript = new HPCounter(); for (int i = 1; i < 66; i++) { string kuniTemp = "kuni" + i.ToString(); PlayerPrefs.DeleteKey(kuniTemp); string jyosyuTemp = "jyosyu" + i.ToString(); PlayerPrefs.DeleteKey(jyosyuTemp); string naiseiLoginDateTemp = "naiseiLoginDate" + i.ToString(); PlayerPrefs.DeleteKey(naiseiLoginDateTemp); string naiseiTabibitoCounterTemp = "naiseiTabibitoCounter" + i.ToString(); PlayerPrefs.DeleteKey(naiseiTabibitoCounterTemp); string cyouhouTemp = "cyouhou" + i.ToString(); PlayerPrefs.DeleteKey(cyouhouTemp); string linkuctTmp = "linkcut" + i.ToString(); PlayerPrefs.DeleteKey(linkuctTmp); //Delete Enemy Gunzei deleteGunzeiScript.deleteEnemyGunzeiData(i); } PlayerPrefs.DeleteKey("cyouhou"); PlayerPrefs.DeleteKey("lastSeasonChangeTime"); PlayerPrefs.DeleteKey("doneCyosyuFlg"); PlayerPrefs.DeleteKey("twiceHeiFlg"); PlayerPrefs.DeleteKey("rdmEventTimer"); PlayerPrefs.DeleteKey("fromNaiseiFlg"); PlayerPrefs.DeleteKey("fromKassenFlg"); PlayerPrefs.DeleteKey("kassenWinLoseFlee"); PlayerPrefs.DeleteKey("kessenFlg"); PlayerPrefs.DeleteKey("kessenHyourou"); PlayerPrefs.DeleteKey("winChecker"); PlayerPrefs.DeleteKey("isAttackedFlg"); PlayerPrefs.DeleteKey("isKessenFlg"); /*******************************/ /***** Cyoutei & Bakuhu Value *****/ /*******************************/ PlayerPrefs.DeleteKey("cyoutekiDaimyo"); PlayerPrefs.DeleteKey("cyouteiPoint"); PlayerPrefs.SetInt("syogunDaimyoId", 14); PlayerPrefs.DeleteKey("bakuhuTobatsuDaimyoId"); PlayerPrefs.DeleteKey("soubujireiFlg"); /*******************************/ /***** Busyo Value *****/ /*******************************/ //Jyosyu Delete Entity_busyo_mst busyoMst = Resources.Load("Data/busyo_mst") as Entity_busyo_mst; for (int i = 0; i < busyoMst.param.Count; i++) { int busyoId = i + 1; string daimyoTemp = "jyosyuHei" + busyoId; string daimyoTemp2 = "jyosyuBusyo" + busyoId; PlayerPrefs.DeleteKey(daimyoTemp); PlayerPrefs.DeleteKey(daimyoTemp2); } PlayerPrefs.Flush(); char[] delimiterChars = { ',' }; if (!sameDaimyoFlg) { //Old Daimyo //Delete Previous Daimyo Busyo in the case of it has never been gotten by Gacya int preDaimyoBusyoId = PlayerPrefs.GetInt("myDaimyoBusyo"); string gacyaDaimyoHst = PlayerPrefs.GetString("gacyaDaimyoHst"); List <string> gacyaDaimyoHstList = new List <string> (); if (gacyaDaimyoHst != null && gacyaDaimyoHst != "") { if (gacyaDaimyoHst.Contains(",")) { gacyaDaimyoHstList = new List <string> (gacyaDaimyoHst.Split(delimiterChars)); } else { gacyaDaimyoHstList.Add(gacyaDaimyoHst); } } if (!gacyaDaimyoHstList.Contains(preDaimyoBusyoId.ToString())) { //delete daimyo //delete my busyo string myBusyo = PlayerPrefs.GetString("myBusyo"); List <string> myBusyoList = new List <string> (); if (myBusyo.Contains(",")) { myBusyoList = new List <string> (myBusyo.Split(delimiterChars)); } else { myBusyoList.Add(myBusyo); } myBusyoList.Remove(preDaimyoBusyoId.ToString()); string myNewBusyo = ""; for (int i = 0; i < myBusyoList.Count; i++) { if (i == 0) { myNewBusyo = myBusyoList [i]; } else { myNewBusyo = myNewBusyo + "," + myBusyoList [i]; } } PlayerPrefs.SetString("myBusyo", myNewBusyo); int myBusyoQty = PlayerPrefs.GetInt("myBusyoQty"); myBusyoQty = myBusyoQty - 1; PlayerPrefs.SetInt("myBusyoQty", myBusyoQty); PlayerPrefs.Flush(); //delete jinkei int jinkeiMaxId = 4; int slotMaxId = 25; bool soudaisyoSetFlg = false; for (int i = 1; i <= jinkeiMaxId; i++) { for (int j = 1; j <= slotMaxId; j++) { string tmp = i.ToString() + "map" + j.ToString(); if (PlayerPrefs.HasKey(tmp)) { int busyoId = PlayerPrefs.GetInt(tmp); if (busyoId == preDaimyoBusyoId) { PlayerPrefs.DeleteKey(tmp); } else { if (!soudaisyoSetFlg) { string sJinkeiId = "soudaisyo" + i.ToString(); PlayerPrefs.SetInt(sJinkeiId, busyoId); } } } } } //kahou check string tempBusyo = "kahou" + preDaimyoBusyoId; string busyoKahou = PlayerPrefs.GetString(tempBusyo); string[] busyoKahouList = busyoKahou.Split(delimiterChars); for (int k = 0; k < busyoKahouList.Length; k++) { int kahouId = int.Parse(busyoKahouList[k]); if (kahouId != 0) { //back kahou data string tmp = ""; if (k == 0) { tmp = "Bugu"; } else if (k == 1) { tmp = "Kabuto"; } else if (k == 2) { tmp = "Gusoku"; } else if (k == 3) { tmp = "Meiba"; } else if (k == 4) { tmp = "Cyadougu"; } else if (k == 5) { tmp = "Cyadougu"; } else if (k == 6) { tmp = "Heihousyo"; } else if (k == 7) { tmp = "Chishikisyo"; } string temp = "available" + tmp; string availableKahou = PlayerPrefs.GetString(temp); if (availableKahou == null || availableKahou == "") { availableKahou = kahouId.ToString(); } else { availableKahou = availableKahou + "," + kahouId.ToString(); } PlayerPrefs.SetString(temp, availableKahou); PlayerPrefs.SetString(tempBusyo, "0,0,0,0,0,0,0,0"); } } PlayerPrefs.Flush(); } //New Daimyo if (!busyoExitFlg) { //Player dosen't have this daimyo busyo //busyo int myBusyoQty = PlayerPrefs.GetInt("myBusyoQty"); myBusyoQty = myBusyoQty + 1; PlayerPrefs.SetInt("myBusyoQty", myBusyoQty); string myBusyo = PlayerPrefs.GetString("myBusyo"); if (myBusyo != null && myBusyo != "") { myBusyo = myBusyo + "," + newDaimyoBusyo.ToString(); } else { myBusyo = newDaimyoBusyo.ToString(); } PlayerPrefs.SetString("myBusyo", myBusyo); if (!PlayerPrefs.HasKey(newDaimyoBusyo.ToString())) { PlayerPrefs.SetInt(newDaimyoBusyo.ToString(), 1); string tempHei = "hei" + newDaimyoBusyo.ToString(); string tempSenpou = "senpou" + newDaimyoBusyo.ToString(); string tempSaku = "saku" + newDaimyoBusyo.ToString(); string tempKahou = "kahou" + newDaimyoBusyo.ToString(); string tempExp = "exp" + newDaimyoBusyo.ToString(); string valueHei = heisyu + ":1:1:1"; PlayerPrefs.SetString(tempHei, valueHei); PlayerPrefs.SetInt(tempSenpou, 1); PlayerPrefs.SetInt(tempSaku, 1); PlayerPrefs.SetString(tempKahou, "0,0,0,0,0,0,0,0"); PlayerPrefs.SetInt(tempExp, 0); } //jinkei //if there is no busyo in active jinkei int jinkei = PlayerPrefs.GetInt("jinkei"); bool jinkeiBusyoExistFlg = false; for (int i = 1; i <= 25; i++) { string tmp = jinkei.ToString() + "map" + i.ToString(); if (PlayerPrefs.HasKey(tmp)) { jinkeiBusyoExistFlg = true; } } if (!jinkeiBusyoExistFlg) { string tmpMap = ""; if (jinkei == 1) { tmpMap = jinkei.ToString() + "map11"; } else if (jinkei == 2) { tmpMap = jinkei.ToString() + "map11"; } else if (jinkei == 3) { tmpMap = jinkei.ToString() + "map14"; } else if (jinkei == 4) { tmpMap = jinkei.ToString() + "map12"; } PlayerPrefs.SetInt(tmpMap, newDaimyoBusyo); } } } //My Daimyo Busyo PlayerPrefs.SetInt("myDaimyo", newDaimyo); PlayerPrefs.SetInt("myDaimyoBusyo", newDaimyoBusyo); PlayerPrefs.DeleteKey("usedBusyo"); /*******************************/ /***** Kuni Value *****/ /*******************************/ string newSeiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46"; PlayerPrefs.SetString("seiryoku", newSeiryoku); List <string> seiryokuList = new List <string> (); seiryokuList = new List <string> (newSeiryoku.Split(delimiterChars)); string newClearedKuni = ""; for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyoId = seiryokuList[i]; if (tempDaimyoId == newDaimyo.ToString()) { int kuniId = i + 1; if (newClearedKuni == null || newClearedKuni == "") { newClearedKuni = kuniId.ToString(); } else { newClearedKuni = newClearedKuni + "," + kuniId.ToString(); } } } PlayerPrefs.SetString("clearedKuni", newClearedKuni); List <string> clearedKuniList = new List <string> (); if (newClearedKuni.Contains(",")) { clearedKuniList = new List <string> (newClearedKuni.Split(delimiterChars)); } else { clearedKuniList.Add(newClearedKuni); } //New Open Kuni KuniInfo kuni = new KuniInfo(); PlayerPrefs.DeleteKey("openKuni"); PlayerPrefs.Flush(); foreach (string kuniId in clearedKuniList) { kuni.registerOpenKuni(int.Parse(kuniId)); string temp = "kuni" + kuniId; PlayerPrefs.SetString(temp, "1,2,3,4,5,6,7,8,9,10"); string tempNaisei = "naisei" + kuniId; if (!PlayerPrefs.HasKey(tempNaisei)) { PlayerPrefs.SetString(tempNaisei, "1,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0"); } PlayerPrefs.Flush(); } //Add Cleared Kuni to OpenKuni string tempOpenKuni = PlayerPrefs.GetString("openKuni"); tempOpenKuni = tempOpenKuni + "," + newClearedKuni; PlayerPrefs.SetString("openKuni", tempOpenKuni); PlayerPrefs.Flush(); /*******************************/ /***** Cyouryaku Value *****/ /*******************************/ string cyouryaku = PlayerPrefs.GetString("cyouryaku"); List <string> cyouryakuList = new List <string> (); if (cyouryaku != null && cyouryaku != "") { if (cyouryaku.Contains(",")) { cyouryakuList = new List <string> (cyouryaku.Split(delimiterChars)); } else { cyouryakuList.Add(cyouryaku); } } for (int i = 0; i < cyouryakuList.Count; i++) { PlayerPrefs.DeleteKey(cyouryakuList[i]); } PlayerPrefs.DeleteKey("cyouryaku"); /*******************************/ /***** Gaikou Value *****/ /*******************************/ //My Gaikou Gaikou gaikou = new Gaikou(); for (int l = 1; l < 47; l++) { int value = gaikou.getGaikouValue(newDaimyo, l); string temp = "gaikou" + l.ToString(); PlayerPrefs.SetInt(temp, value); string metsubouTemp = "metsubou" + l.ToString(); PlayerPrefs.DeleteKey(metsubouTemp); } //Other Daimyo Gaikou for (int x = 2; x < 47; x++) { for (int y = 2; y < 47; y++) { if (x != y) { string temp = x.ToString() + "gaikou" + y.ToString(); string temp2 = x.ToString() + "key" + y.ToString(); PlayerPrefs.DeleteKey(temp); PlayerPrefs.DeleteKey(temp2); } } } /*******************************/ /***** Shisya *****/ /*******************************/ PlayerPrefs.DeleteKey("shisyaFlg"); PlayerPrefs.DeleteKey("shisya1"); PlayerPrefs.DeleteKey("shisya2"); PlayerPrefs.DeleteKey("shisya3"); PlayerPrefs.DeleteKey("shisya4"); PlayerPrefs.DeleteKey("shisya5"); PlayerPrefs.DeleteKey("shisya6"); PlayerPrefs.DeleteKey("shisya7"); PlayerPrefs.DeleteKey("shisya8"); PlayerPrefs.DeleteKey("shisya9"); PlayerPrefs.DeleteKey("shisya10"); PlayerPrefs.DeleteKey("shisya11"); PlayerPrefs.DeleteKey("shisya12"); PlayerPrefs.DeleteKey("shisya13"); PlayerPrefs.DeleteKey("shisya14"); PlayerPrefs.DeleteKey("shisya15"); PlayerPrefs.DeleteKey("shisya16"); PlayerPrefs.DeleteKey("shisya17"); PlayerPrefs.DeleteKey("shisya18"); PlayerPrefs.DeleteKey("shisya19"); PlayerPrefs.DeleteKey("shisya20"); PlayerPrefs.DeleteKey("shisya21"); /*******************************/ /***** Doumei *****/ /*******************************/ //Delete doumei history Entity_daimyo_mst daimyoMst = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst; for (int i = 0; i < daimyoMst.param.Count; i++) { int daimyoId = daimyoMst.param[i].daimyoId; string temp = "doumei" + daimyoId; PlayerPrefs.DeleteKey(temp); } PlayerPrefs.Flush(); PlayerPrefs.DeleteKey("doumei"); string newMyDoumei = ""; Entity_doumei_mst doumeiMst = Resources.Load("Data/doumei_mst") as Entity_doumei_mst; for (int i = 0; i < doumeiMst.param.Count; i++) { int srcDaimyoId = doumeiMst.param[i].doumeiSrc; int dstDaimyoId = doumeiMst.param[i].doumeiDst; if (srcDaimyoId == newDaimyo) { if (newMyDoumei != null && newMyDoumei != "") { newMyDoumei = newMyDoumei + "," + dstDaimyoId; } else { newMyDoumei = dstDaimyoId.ToString(); } } else { string temp = "doumei" + srcDaimyoId; string previous = PlayerPrefs.GetString(temp); if (previous != null && previous != "") { previous = previous + "," + dstDaimyoId; PlayerPrefs.SetString(temp, previous); } else { PlayerPrefs.SetString(temp, dstDaimyoId.ToString()); } } } PlayerPrefs.SetString("doumei", newMyDoumei); PlayerPrefs.Flush(); Application.LoadLevel("mainStage"); }
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(){ if (close.GetComponent<CloseBoard> ().kuniId != kuniId) { close.GetComponent<CloseBoard> ().kuniId = kuniId; /*Status*/ //Common GameObject kuniIconView = GameObject.Find ("KuniIconView").gameObject; SendParam script = kuniIconView.transform.FindChild (kuniId.ToString ()).GetComponent<SendParam> (); KuniInfo kuni = new KuniInfo (); Daimyo daimyo = new Daimyo (); Gaikou gaikou = new Gaikou (); List<int> targetKuniList = new List<int> (); targetKuniList = kuni.getMappingKuni (kuniId); char[] delimiterChars = { ',' }; //Kamon GameObject daimyoNameObj = status.transform.FindChild ("DaimyoName").gameObject; string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString (); daimyoNameObj.transform.FindChild ("Kamon").GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; //Daimyo Name daimyoNameObj.transform.FindChild ("Value").GetComponent<Text> ().text = daimyoName; //Kuni Name GameObject kuniNameObj = status.transform.FindChild ("KuniName").gameObject; kuniNameObj.transform.FindChild ("Value").GetComponent<Text> ().text = kuniName; //Heiryoku status.transform.FindChild ("Heiryoku").transform.FindChild ("Value").GetComponent<Text> ().text = script.heiryoku.ToString (); //Yukou status.transform.FindChild ("Yukoudo").transform.FindChild ("Value").GetComponent<Text> ().text = script.myYukouValue.ToString (); //Attack Target bool aggressiveFlg = script.aggressiveFlg; int myDaimyoId = PlayerPrefs.GetInt ("myDaimyo"); int targetKuniId = getKassenTargetKuni (kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId); if (targetKuniId != 0) { string targetKuniName = kuni.getKuniName (targetKuniId); int targetDaimyoId = int.Parse (seiryokuList [targetKuniId - 1]); string targetDaimyoName = daimyo.getName (targetDaimyoId); status.transform.FindChild ("Atk").transform.FindChild ("Value").GetComponent<Text> ().text = targetKuniName + "(" + targetDaimyoName + ")"; } else { status.transform.FindChild ("Atk").transform.FindChild ("Value").GetComponent<Text> ().text = "無し"; } int targetGaikouKuniId = 0; if (snbRank > 1) { //Jyo or Cyu //Gaikou targetGaikouKuniId = getGaikouTargetKuni (kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId); if (targetGaikouKuniId != 0) { string targetGaikouKuniName = kuni.getKuniName (targetGaikouKuniId); int targetGaikouDaimyoId = int.Parse (seiryokuList [targetGaikouKuniId - 1]); string targetGaikouDaimyoName = daimyo.getName (targetGaikouDaimyoId); status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = targetGaikouKuniName + "(" + targetGaikouDaimyoName + ")"; } else { status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = "無し"; } //Doumei string doumeiTmp = "doumei" + daimyoId.ToString (); string doumeiString = PlayerPrefs.GetString (doumeiTmp); List<string> doumeiList = new List<string> (); if (doumeiString != null && doumeiString != "") { if (doumeiString.Contains (",")) { doumeiList = new List<string> (doumeiString.Split (delimiterChars)); } else { doumeiList.Add (doumeiString); } } string doumeiNameList = "無し"; for (int j = 0; j < doumeiList.Count; j++) { if (j == 0) { doumeiNameList = daimyo.getName (int.Parse (doumeiList [j])); } else { doumeiNameList = doumeiNameList + "," + daimyo.getName (int.Parse (doumeiList [j])); } } status.transform.FindChild ("Doumei").transform.FindChild ("Value").GetComponent<Text> ().text = doumeiNameList; } else { //Ge status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = "?"; status.transform.FindChild ("Doumei").transform.FindChild ("Value").GetComponent<Text> ().text = "?"; } if (snbRank > 2) { //Jyo BusyoInfoGet busyo = new BusyoInfoGet(); string qtyAndHeisyu = busyo.getDaimyoBusyoQtyHeisyu(daimyoId); List<string> qtyAndHeisyuiList = new List<string> (); qtyAndHeisyuiList = new List<string> (qtyAndHeisyu.Split (delimiterChars)); //BusyoQty //Heisyu status.transform.FindChild ("BusyoQty").transform.FindChild ("Value").GetComponent<Text> ().text = qtyAndHeisyuiList[0]; status.transform.FindChild ("Heisyu").transform.FindChild ("Value").GetComponent<Text> ().text = qtyAndHeisyuiList[1]; } else { //Cyu or Ge status.transform.FindChild ("BusyoQty").transform.FindChild ("Value").GetComponent<Text> ().text = "?"; status.transform.FindChild ("Heisyu").transform.FindChild ("Value").GetComponent<Text> ().text = "?"; } //Main Map foreach(Transform obj in board.transform){ if (obj.name != "Explanation") { Destroy (obj.gameObject); } } string kuniMapPath = "Prefabs/Map/cyouhou/kuniImage"; GameObject mainMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject; mainMap.transform.SetParent(board.transform); mainMap.transform.localScale = new Vector2 (13, 9); mainMap.name = "kuniMap" + kuniId; string kuniImagePath = "Prefabs/Map/kuniMap/" + kuniId.ToString (); mainMap.GetComponent<Image> ().sprite = Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite; int baseX = kuni.getKuniLocationX (kuniId); int baseY = kuni.getKuniLocationY (kuniId); int adjstX = baseX * -1; int adjustY = baseY * -1; float colorR = daimyo.getColorR (daimyoId); float colorG = daimyo.getColorG (daimyoId); float colorB = daimyo.getColorB (daimyoId); Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); mainMap.GetComponent<Image> ().color = kuniColor; RectTransform mapRect = mainMap.GetComponent<RectTransform> (); mapRect.anchoredPosition3D = new Vector3 (adjstX, adjustY, 0); //My Kuni Kamon Icon string kamonBackPath ="Prefabs/Map/cyouhou/KamonBack"; GameObject kamonBack = Instantiate (Resources.Load (kamonBackPath)) as GameObject; kamonBack.transform.SetParent (board.transform); kamonBack.transform.localScale = new Vector2 (1, 1); kamonBack.transform.localPosition = new Vector2(0,0); string kamonKuniPath = "Prefabs/Map/Kuni/" + kuniId.ToString(); GameObject kamonObj = Instantiate (Resources.Load (kamonKuniPath)) as GameObject; kamonObj.transform.SetParent (kamonBack.transform); kamonObj.transform.localScale = new Vector2 (1, 0.8f); kamonObj.transform.localPosition = new Vector2(0,0); kamonObj.GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; kamonObj.GetComponent<Button> ().enabled = false; //Mapping Kuni Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst; for (int i=0; i < kuniMst.param.Count; i++) { //for (int i=0; i < targetKuniList.Count; i++) { int subKuniId = i + 1; GameObject subMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject; subMap.transform.SetParent(mainMap.transform); subMap.transform.localScale = new Vector2 (1, 1); subMap.transform.localPosition = new Vector2 (0, 0); subMap.name = "kuniMap" + subKuniId; string subKuniImagePath = "Prefabs/Map/kuniMap/" + subKuniId; subMap.GetComponent<Image> ().sprite = Resources.Load (subKuniImagePath, typeof(Sprite)) as Sprite; if (targetKuniList.Contains (subKuniId)) { //color int subDaimyoId = int.Parse (seiryokuList [subKuniId - 1]); float subColorR = daimyo.getColorR (subDaimyoId); float subColorG = daimyo.getColorG (subDaimyoId); float subColorB = daimyo.getColorB (subDaimyoId); Color subKuniColor = new Color (subColorR / 255f, subColorG / 255f, subColorB / 255f, 255f / 255f); subMap.GetComponent<Image> ().color = subKuniColor; //Kamon string subKamonKuniPath = "Prefabs/Map/Kuni/" + subKuniId.ToString (); GameObject subKamonObj = Instantiate (Resources.Load (subKamonKuniPath)) as GameObject; subKamonObj.transform.SetParent (board.transform); subKamonObj.transform.localScale = new Vector2 (1, 0.8f); if (daimyoId != subDaimyoId) { string subImagePath = "Prefabs/Kamon/" + subDaimyoId.ToString (); subKamonObj.GetComponent<Image> ().sprite = Resources.Load (subImagePath, typeof(Sprite)) as Sprite; //yukoudo int yukoudoValue = gaikou.getExistGaikouValue (daimyoId, subDaimyoId); string syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel"; GameObject yukoudoObj = Instantiate (Resources.Load (syukoudoPath)) as GameObject; yukoudoObj.transform.SetParent (subKamonObj.transform); yukoudoObj.GetComponent<Text> ().text = yukoudoValue.ToString (); yukoudoObj.transform.localScale = new Vector2 (0.08f, 0.1f); yukoudoObj.transform.localPosition = new Vector2 (0, 26); } else { subKamonObj.GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; } subKamonObj.GetComponent<Button> ().enabled = false; //Kamon adjustment int subBaseX = kuni.getKuniLocationX (subKuniId); int subBaseY = kuni.getKuniLocationY (subKuniId); int subAdjstX = subBaseX - baseX; int subAdjstY = subBaseY - baseY; RectTransform subMapRect = subKamonObj.GetComponent<RectTransform> (); subMapRect.anchoredPosition3D = new Vector3 (subAdjstX, subAdjstY, 0); if (targetKuniId != 0) { if (targetKuniId == subKuniId) { //kassen target Color atkColor = new Color (180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); subKamonObj.GetComponent<Image> ().color = atkColor; } } if (snbRank > 1) { if (targetGaikouKuniId != 0) { if (targetGaikouKuniId == subKuniId) { //kassen target Color gaikouColor = new Color (80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f); subKamonObj.GetComponent<Image> ().color = gaikouColor; } } } } else { Color noSubKuniColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f); subMap.GetComponent<Image> ().color = noSubKuniColor; } } } }
// Use this for initialization public void OnClick() { //SE AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); //Shinobi Check int shinobiGe = PlayerPrefs.GetInt("shinobiGe"); int shinobiCyu = PlayerPrefs.GetInt("shinobiCyu"); int shinobiJyo = PlayerPrefs.GetInt("shinobiJyo"); int total = shinobiGe + shinobiCyu + shinobiJyo; if (total == 0) { audioSources [4].Play(); Message msg = new Message(); msg.makeMessage(msg.getMessage(13)); } else { CloseBoard close = GameObject.Find("close").GetComponent <CloseBoard> (); close.layer = close.layer + 1; int nowHyourou = PlayerPrefs.GetInt("hyourou"); bool hyourouOKflg = false; int daimyoId = GameObject.Find("close").GetComponent <CloseBoard>().daimyoId; if (name == "Cyouhou") { audioSources [0].Play(); if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("kuniName").GetComponent <Text> ().text = "Spy"; } else { GameObject.Find("kuniName").GetComponent <Text>().text = "諜報"; } OffBouryakuMenuList(); string path = "Prefabs/Map/bouryaku/bouryakuObj"; GameObject obj = Instantiate(Resources.Load(path)) as GameObject; obj.transform.SetParent(GameObject.Find("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3(1, 1, 1); GameObject btn = obj.transform.FindChild("DoBouryakuBtn").gameObject; btn.name = "DoCyouhouBtn"; if (Application.systemLanguage != SystemLanguage.Japanese) { btn.transform.FindChild("Text").GetComponent <Text>().text = "Spy"; } else { btn.transform.FindChild("Text").GetComponent <Text>().text = "諜報"; } shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn); GameObject.Find("return").GetComponent <MenuReturn> ().layer2 = obj; } else if (name == "Ryugen") { Daimyo daimyo = new Daimyo(); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); bool remain1DaimyoFlg = daimyo.checkRemain1DaimyoOnMain(myDaimyo); if (remain1DaimyoFlg) { audioSources [4].Play(); Message msg = new Message(); msg.makeMessage(msg.getMessage(14)); } else { audioSources [0].Play(); if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("kuniName").GetComponent <Text>().text = "Bad Rumor"; } else { GameObject.Find("kuniName").GetComponent <Text>().text = "流言"; } OffBouryakuMenuList(); string path = "Prefabs/Map/bouryaku/bouryakuObj"; GameObject obj = Instantiate(Resources.Load(path)) as GameObject; obj.transform.SetParent(GameObject.Find("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3(1, 1, 1); GameObject btn = obj.transform.FindChild("DoBouryakuBtn").gameObject; btn.name = "DoRyugenBtn"; if (Application.systemLanguage != SystemLanguage.Japanese) { btn.transform.FindChild("Text").GetComponent <Text>().text = "Bad Rumor"; } else { btn.transform.FindChild("Text").GetComponent <Text>().text = "流言"; } shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn); GameObject.Find("return").GetComponent <MenuReturn> ().layer2 = obj; } } else if (name == "Goudatsu") { audioSources [0].Play(); if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("kuniName").GetComponent <Text>().text = "Theft"; } else { GameObject.Find("kuniName").GetComponent <Text>().text = "強奪"; } OffBouryakuMenuList(); string path = "Prefabs/Map/bouryaku/bouryakuObj"; GameObject obj = Instantiate(Resources.Load(path)) as GameObject; obj.transform.SetParent(GameObject.Find("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3(1, 1, 1); GameObject btn = obj.transform.FindChild("DoBouryakuBtn").gameObject; btn.name = "DoGoudatsuBtn"; if (Application.systemLanguage != SystemLanguage.Japanese) { btn.transform.FindChild("Text").GetComponent <Text>().text = "Theft"; } else { btn.transform.FindChild("Text").GetComponent <Text>().text = "強奪"; } shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn); GameObject.Find("return").GetComponent <MenuReturn> ().layer2 = obj; } else if (name == "Gihou") { //Gunzei Check bool gunzeiFlg = false; foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")) { int checkDaimyoId = obs.GetComponent <Gunzei>().srcDaimyoId; if (checkDaimyoId == daimyoId) { gunzeiFlg = true; targetGunzei = obs; break; } } if (gunzeiFlg) { audioSources [0].Play(); //Menu Handling if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("kuniName").GetComponent <Text>().text = "Misreport"; } else { GameObject.Find("kuniName").GetComponent <Text>().text = "偽報"; } OffBouryakuMenu(); string path = "Prefabs/Map/bouryaku/GihouObj"; GameObject obj = Instantiate(Resources.Load(path)) as GameObject; obj.transform.SetParent(GameObject.Find("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3(1, 1, 1); //Label int dstKuni = targetGunzei.GetComponent <Gunzei>().dstKuni; int hei = targetGunzei.GetComponent <Gunzei>().myHei; KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(dstKuni); if (Application.systemLanguage != SystemLanguage.Japanese) { obj.transform.FindChild("GunzeiInfo").transform.FindChild("DaimyoNameValue").GetComponent <Text>().text = "To " + kuniName; } else { obj.transform.FindChild("GunzeiInfo").transform.FindChild("DaimyoNameValue").GetComponent <Text>().text = kuniName + "に進軍中"; } obj.transform.FindChild("Heiryoku").transform.FindChild("HeiryokuValue").GetComponent <Text>().text = hei.ToString(); GameObject btn = obj.transform.FindChild("DoGihouBtn").gameObject; shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn); GameObject.Find("return").GetComponent <MenuReturn> ().layer2 = obj; } else { audioSources [4].Play(); Message msg = new Message(); msg.makeMessage(msg.getMessage(15)); close.layer = close.layer - 1; } } } }
public void UpdateShiroStatus(GameObject kuniMap) { char[] delimiterChars = { ',' }; char[] delimiterChars2 = { '-' }; int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); //open shiro List <int> closeStageIdList = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string>(); seiryokuList = new List <string>(seiryoku.Split(delimiterChars)); //compare linkKuni with mySeiryoku List <int> linkKuniList = new List <int>(); List <int> linkMyKuniList = new List <int>(); KuniInfo kuniScript = new KuniInfo(); linkKuniList = kuniScript.getMappingKuni(kuniId); for (int i = 0; i < linkKuniList.Count; i++) { int linkKuniId = linkKuniList[i]; if (seiryokuList[linkKuniId - 1] == myDaimyoId.ToString()) { linkMyKuniList.Add(linkKuniId); } } //open initial stage for (int j = 0; j < linkMyKuniList.Count; j++) { int srcKuniId = linkMyKuniList[j]; string linkStage = kuniScript.getLinkStage(srcKuniId, kuniId); linkStage = linkStage.Replace("stage", ""); List <int> linkStageList = new List <int>(Array.ConvertAll(linkStage.Split(','), new Converter <string, int>((s) => { return(Convert.ToInt32(s)); }))); closeStageIdList.RemoveAll(linkStageList.Contains); } //Clear Stage Setting string clearedStage = "kuni" + kuniId; string clearedStageString = PlayerPrefs.GetString(clearedStage); List <string> clearedStageList = new List <string>(); if (clearedStageString != null && clearedStageString != "") { clearedStageList = new List <string>(clearedStageString.Split(delimiterChars)); } //Line Setting Entity_stageLink_mst stageLinkMst = Resources.Load("Data/stageLink_mst") as Entity_stageLink_mst; List <string> myStageLink = new List <string>(); for (int i = 0; i < stageLinkMst.param.Count; i++) { int tempKuniId = stageLinkMst.param[i].kuniId; if (tempKuniId == kuniId) { myStageLink.Add(stageLinkMst.param[i].Link); } } List <string> myOriginalStageLink = new List <string>(myStageLink); //open cleared kuni & linked stage List <int> clearedStageIntList = clearedStageList.ConvertAll(x => int.Parse(x)); closeStageIdList.RemoveAll(clearedStageIntList.Contains); for (int l = 0; l < clearedStageIntList.Count; l++) { int srcStageId = clearedStageIntList[l]; for (int m = 0; m < myOriginalStageLink.Count; m++) { List <string> linkList = new List <string>(myOriginalStageLink[m].Split(delimiterChars2)); int stage1Id = int.Parse(linkList[0]); int stage2Id = int.Parse(linkList[1]); if (srcStageId == stage1Id) { closeStageIdList.Remove(stage2Id); } else if (srcStageId == stage2Id) { closeStageIdList.Remove(stage1Id); } } } //Active or Disabled Color openColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 0f / 255f); //White Color closeColor = new Color(60f / 255f, 60f / 255f, 60f / 255f, 255f / 255f); //Black bool fireflg = false; for (int k = 1; k < 11; k++) { string stageName = "stage" + k.ToString(); GameObject shiroObj = kuniMap.transform.FindChild(stageName).gameObject; if (closeStageIdList.Contains(k)) { //Close shiroObj.GetComponent <Button>().enabled = false; shiroObj.transform.FindChild("shiroImage").GetComponent <SpriteRenderer>().color = closeColor; } else { //Open //shiroObj.GetComponent<Button>().enabled = true; //shiroObj.transform.FindChild("shiroImage").GetComponent<SpriteRenderer>().color = openColor; shiroObj.GetComponent <ShowStageDtl>().clearedFlg = false; if (!fireflg) { shiroObj.GetComponent <ShowStageDtl>().OnClick(); fireflg = true; } } } }
public void OnClick(){ //Count cyouhou string cyouhou = PlayerPrefs.GetString("cyouhou"); if (cyouhou != null && cyouhou != "") { /*Popup*/ string backPath = "Prefabs/Busyo/back"; GameObject back = Instantiate (Resources.Load (backPath)) as GameObject; back.transform.SetParent (GameObject.Find ("Map").transform); back.transform.localScale = new Vector2 (1, 1); RectTransform backTransform = back.GetComponent<RectTransform> (); backTransform.anchoredPosition = new Vector3 (0, 0, 0); //Popup Screen string popupPath = "Prefabs/Busyo/board"; GameObject popup = Instantiate (Resources.Load (popupPath)) as GameObject; popup.transform.SetParent (GameObject.Find ("Map").transform); popup.transform.localScale = new Vector2 (1, 1); RectTransform popupTransform = popup.GetComponent<RectTransform> (); popupTransform.anchoredPosition = new Vector3 (0, 0, 0); popup.name = "board"; GameObject close = popup.transform.FindChild ("close").gameObject; //Pop text string popTextPath = "Prefabs/Busyo/popText"; GameObject popText = Instantiate (Resources.Load (popTextPath)) as GameObject; popText.transform.SetParent (popup.transform); popText.transform.localScale = new Vector2 (0.35f, 0.35f); RectTransform popTextTransform = popText.GetComponent<RectTransform> (); popTextTransform.anchoredPosition = new Vector3 (0, 275, 0); popText.name = "popText"; popText.GetComponent<Text> ().text = "諜報"; //kuni board string boardPath = "Prefabs/Map/cyouhou/CyouhouKuniBoard"; GameObject board = Instantiate (Resources.Load (boardPath)) as GameObject; board.transform.SetParent (popup.transform); board.transform.localScale = new Vector2 (1, 1); RectTransform boardRect = board.GetComponent<RectTransform> (); boardRect.anchoredPosition3D = new Vector3 (-257, -89, 0); string statusPath = "Prefabs/Map/cyouhou/CyouhouStatus"; GameObject status = Instantiate (Resources.Load (statusPath)) as GameObject; status.transform.SetParent (popup.transform); status.transform.localScale = new Vector2 (1, 1); RectTransform statusRect = status.GetComponent<RectTransform> (); statusRect.anchoredPosition3D = new Vector3 (293, -92, 0); //Scroll Preparation string cyouhouString = PlayerPrefs.GetString ("cyouhou"); List<string> cyouhouList = new List<string> (); char[] delimiterChars = { ',' }; if (cyouhouString != null && cyouhouString != "") { if (cyouhouString.Contains (",")) { cyouhouList = new List<string> (cyouhouString.Split (delimiterChars)); } else { cyouhouList.Add (cyouhouString); } } //Scroll string popScrollPath = "Prefabs/Map/cyouhou/CyouhouScrollView"; GameObject scroll = Instantiate (Resources.Load (popScrollPath)) as GameObject; scroll.transform.SetParent (popup.transform); scroll.transform.localScale = new Vector2 (1, 1); RectTransform scrollRect = scroll.GetComponent<RectTransform> (); scrollRect.anchoredPosition3D = new Vector3 (0, 525, 0); //Seiryoku string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string> (); seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); string slotPath = "Prefabs/Map/cyouhou/CyouhouSlot"; GameObject content = scroll.transform.FindChild ("Content").gameObject; KuniInfo kuni = new KuniInfo (); Daimyo daimyo = new Daimyo (); for (int i = 0; i < cyouhouList.Count; i++) { GameObject slot = Instantiate (Resources.Load (slotPath)) as GameObject; slot.transform.SetParent (content.transform); slot.transform.localScale = new Vector2 (1, 1); string slotValue = ""; //Kuni Name int kuniId = int.Parse (cyouhouList [i]); string kuniName = kuni.getKuniName (kuniId); //Daimyo int daimyoId = int.Parse (seiryokuList [kuniId - 1]); string daimyoName = daimyo.getName (daimyoId); //Rank of Shinobi string snbTmp = "cyouhou" + kuniId.ToString (); string rankName = ""; int rank = PlayerPrefs.GetInt (snbTmp); if (rank == 1) { rankName = "下忍"; } else if (rank == 2) { rankName = "中忍"; } else if (rank == 3) { rankName = "上忍"; } slotValue = kuniName + "\n" + daimyoName + "\n" + rankName; slot.transform.FindChild ("Value").GetComponent<Text> ().text = slotValue; GameObject kamon = slot.transform.FindChild ("Image").gameObject; string imagePath = "Prefabs/Kamon/" + daimyoId.ToString (); kamon.GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; //Parametor Setting CyouhouSelect script = slot.GetComponent<CyouhouSelect> (); script.kuniId = kuniId; script.kuniName = kuniName; script.daimyoId = daimyoId; script.daimyoName = daimyoName; script.snbRank = rank; script.board = board; script.status = status; script.close = close; script.seiryokuList = seiryokuList; if (i == 0) { slot.GetComponent<CyouhouSelect> ().OnClick (); } } } else { //Error Message msg = new Message(); string txt = "他国に潜伏中の忍はおりませんぞ。\n諜報にて他国の情報を得ましょう。"; msg.makeMessage (txt); } }
public void makeDaimyoSeiryoku() { Destroy(fin.gameObject); string kuniMapPath = "Prefabs/clearOrGameOver/KuniMap"; GameObject KuniMap = Instantiate(Resources.Load(kuniMapPath)) as GameObject; KuniMap.transform.SetParent(panel.transform); KuniMap.transform.localScale = new Vector2(1, 1); string kuniIconViewPath = "Prefabs/clearOrGameOver/KuniIconView"; GameObject kuniIconView = Instantiate(Resources.Load(kuniIconViewPath)) as GameObject; kuniIconView.transform.SetParent(panel.transform); kuniIconView.transform.localScale = new Vector2(1, 1); string messagePath = "Prefabs/clearOrGameOver/FixedMessage"; GameObject msg = Instantiate(Resources.Load(messagePath)) as GameObject; msg.transform.SetParent(panel.transform); msg.transform.localScale = new Vector2(1, 1); msg.transform.localPosition = new Vector2(0, 380); //Show Entity_kuni_mst kuniMst = Resources.Load("Data/kuni_mst") as Entity_kuni_mst; Entity_daimyo_mst daimyoMst = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst; string seiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46"; List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); string kuniQtybyDaimyo = "1,1,3,2,1,1,1,2,1,1,1,1,1,1,1,1,2,1,3,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,2,1,1,4,1,1,4,1,1,1,2,1"; List <string> KuniQtyList = new List <string> (); KuniQtyList = new List <string> (kuniQtybyDaimyo.Split(delimiterChars)); string gameClearDaimyo = PlayerPrefs.GetString("gameClearDaimyo"); List <string> gameClearDaimyoList = new List <string> (); if (gameClearDaimyo != null && gameClearDaimyo != "") { if (gameClearDaimyo.Contains(",")) { gameClearDaimyoList = new List <string> (gameClearDaimyo.Split(delimiterChars)); } else { gameClearDaimyoList.Add(gameClearDaimyo); } } string myBusyo = PlayerPrefs.GetString("myBusyo"); List <string> myBusyoList = new List <string> (); if (myBusyo != null && myBusyo != "") { if (myBusyo.Contains(",")) { myBusyoList = new List <string> (myBusyo.Split(delimiterChars)); } else { myBusyoList.Add(myBusyo); } } string kuniPath = "Prefabs/Map/kuni/"; KuniInfo kuniScript = new KuniInfo(); Daimyo daimyoScript = new Daimyo(); for (int i = 0; i < kuniMst.param.Count; i++) { int kuniId = kuniMst.param [i].kunId; string newKuniPath = kuniPath + kuniId.ToString(); int locationX = kuniMst.param [i].locationX; int locationY = kuniMst.param [i].locationY; GameObject kuni = Instantiate(Resources.Load(newKuniPath)) as GameObject; kuni.transform.SetParent(kuniIconView.transform); kuni.name = kuniId.ToString(); kuni.GetComponent <SendParam> ().kuniId = kuniId; kuni.GetComponent <SendParam> ().kuniName = kuniScript.getKuniName(kuniId); kuni.transform.localScale = new Vector2(1, 1); kuni.GetComponent <SendParam> ().naiseiItem = kuniMst.param [i].naisei; //Seiryoku Handling int daimyoId = int.Parse(seiryokuList [kuniId - 1]); string daimyoName = daimyoScript.getName(daimyoId); int daimyoBusyoIdTemp = daimyoMst.param [daimyoId - 1].busyoId; kuni.GetComponent <SendParam> ().daimyoId = daimyoId; kuni.GetComponent <SendParam> ().daimyoName = daimyoName; kuni.GetComponent <SendParam> ().daimyoBusyoId = daimyoBusyoIdTemp; kuni.GetComponent <SendParam> ().kuniQty = int.Parse(KuniQtyList [daimyoId - 1]); if (gameClearDaimyoList.Contains(daimyoId.ToString())) { kuni.GetComponent <SendParam> ().gameClearFlg = true; } if (myBusyoList.Contains(daimyoBusyoIdTemp.ToString())) { kuni.GetComponent <SendParam> ().busyoHaveFlg = true; } //Color Handling float colorR = (float)daimyoMst.param [daimyoId - 1].colorR; float colorG = (float)daimyoMst.param [daimyoId - 1].colorG; float colorB = (float)daimyoMst.param [daimyoId - 1].colorB; Color kuniColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); KuniMap.transform.FindChild(kuni.name).GetComponent <Image> ().color = kuniColor; //Daimyo Kamon Image string imagePath = "Prefabs/Kamon/" + daimyoId.ToString(); kuni.GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; RectTransform kuniTransform = kuni.GetComponent <RectTransform> (); kuniTransform.anchoredPosition = new Vector3(locationX, locationY, 0); } }
public void mainHandler(){ /*Basic Info*/ //make kuni list string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string> (); char[] delimiterChars = {','}; seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); /*Kassen*/ //1. Randome choice Kassen Qty between 0,1,2,3 //2. Ratio 50% check //3. Random choice Kassen Souce Kuni 1-65 //4. Destination Check by Mapping // if Same Daimyo between Kassen Souce & Destination Kuni => Skip // else => Make guntai Instance // 4-1. Destination == myDaimyo // 4-2. Destination == has own relation or master relation // //Message List<string> messageList = new List<string> (); //Count Kassen Qty int kassenQty = CountEnemyAction (); for (int i=1; i<kassenQty+1; i++) { //Check Kassen or Not bool kassenFlg = CheckByProbability (kassenRatio); if (kassenFlg == true) { //target kuni extraction while (true) { int randomKuni = UnityEngine.Random.Range (1, 65); string eDaimyo = seiryokuList [randomKuni - 1]; string tDaimyo = ""; bool doumeiFlg = false; if (eDaimyo != myDaimyo.ToString ()) { //Check Kuni Mapping List<int> targetKuniList = new List<int> (); KuniInfo kuni = new KuniInfo (); targetKuniList = kuni.getMappingKuni (randomKuni); //Yukoudo Check int worstGaikouDaimyo = 0; int worstGaikouValue = 100; int worstGaikouKuni = 0; for (int k=0; k<targetKuniList.Count; k++) { tDaimyo = seiryokuList [targetKuniList [k] - 1]; int gaikouValue = 0; if (eDaimyo != tDaimyo) { if (tDaimyo == myDaimyo.ToString ()) { //Get Gaikou Value string eGaikouM = "gaikou" + eDaimyo; gaikouValue = PlayerPrefs.GetInt (eGaikouM); } else { //Gaikou Data Check string gaikouTemp = ""; if (int.Parse (eDaimyo) < int.Parse (tDaimyo)) { gaikouTemp = eDaimyo + "gaikou" + tDaimyo; } else { gaikouTemp = tDaimyo + "gaikou" + eDaimyo; } if (PlayerPrefs.HasKey (gaikouTemp)) { //exsit gaikouValue = PlayerPrefs.GetInt (gaikouTemp); } else { //non exist //gaikou check gaikouValue = gaikou.getGaikouValue (int.Parse (eDaimyo), int.Parse (tDaimyo)); } } //Compare with Previous one if (worstGaikouValue > gaikouValue) { worstGaikouValue = gaikouValue; worstGaikouDaimyo = int.Parse (tDaimyo); worstGaikouKuni = targetKuniList [k]; } } }//Loop End //Create Guntai Instance if (worstGaikouValue != 100) { int kassenRatio2 = 100 - worstGaikouValue; //doumei check string doumeiCheck = "doumei" + eDaimyo; if(PlayerPrefs.HasKey(doumeiCheck)){ string cDoumei = PlayerPrefs.GetString(doumeiCheck); List<string> cDoumeiList = new List<string>(); if(cDoumei.Contains(",")){ cDoumeiList = new List<string> (cDoumei.Split (delimiterChars)); }else{ cDoumeiList.Add(cDoumei); } //If Doumei Daimyo -> Half Ratio if(cDoumeiList.Contains(worstGaikouDaimyo.ToString())){ doumeiFlg = true; kassenRatio2 = kassenRatio2/2; }else{ doumeiFlg = false; } } Debug.Log ("doumeiFlg:"+doumeiFlg +",src:"+eDaimyo +",dst:"+worstGaikouDaimyo + ",kassen Ratio:" + kassenRatio2); bool GaikouValueFlg = CheckByProbability (kassenRatio2); if (GaikouValueFlg) { //Make Guntai Instance string key = randomKuni.ToString () + "-" + worstGaikouKuni.ToString (); bool ExistFlg = false; //Exist Check Same Daimyo foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")){ int gunzeiSrcDaimyoId = obs.GetComponent<Gunzei>().srcDaimyoId; if(int.Parse(eDaimyo) == gunzeiSrcDaimyoId){ ExistFlg = true; } } if(!ExistFlg){ string path = "Prefabs/Map/Gunzei"; GameObject Gunzei = Instantiate (Resources.Load (path)) as GameObject; Gunzei.transform.SetParent (GameObject.Find ("Panel").transform); Gunzei.transform.localScale = new Vector2 (1, 1); //Location int srcX = kuni.getKuniLocationX(randomKuni); int srcY = kuni.getKuniLocationY(randomKuni); int dstX = kuni.getKuniLocationX(worstGaikouKuni); int dstY = kuni.getKuniLocationY(worstGaikouKuni); string direction = ""; Gunzei gunzei = new Gunzei (); if(srcX < dstX){ Gunzei.transform.localScale = new Vector2 (1, 1); direction = "right"; }else{ Gunzei.transform.localScale = new Vector2 (-1, 1); direction = "left"; Gunzei.GetComponent<Gunzei> ().leftFlg = true; } int aveX = (srcX + dstX)/2; int aveY = (srcY + dstY)/2; RectTransform GunzeiTransform = Gunzei.GetComponent<RectTransform> (); GunzeiTransform.anchoredPosition = new Vector3 (aveX, aveY, 0); Gunzei.GetComponent<Gunzei> ().key = key; Gunzei.GetComponent<Gunzei> ().srcKuni = randomKuni; Gunzei.GetComponent<Gunzei> ().srcDaimyoId = int.Parse (eDaimyo); string srcDaimyoName = daimyo.getName (int.Parse (eDaimyo)); Gunzei.GetComponent<Gunzei> ().srcDaimyoName = srcDaimyoName; Gunzei.GetComponent<Gunzei> ().dstKuni = worstGaikouKuni; Gunzei.GetComponent<Gunzei> ().dstDaimyoId = worstGaikouDaimyo; string dstDaimyoName = daimyo.getName (worstGaikouDaimyo); Gunzei.GetComponent<Gunzei> ().dstDaimyoName = dstDaimyoName; int myHei = gunzei.heiryokuCalc (randomKuni); Gunzei.GetComponent<Gunzei> ().myHei = myHei; Gunzei.name = key; //Engun from Doumei Doumei doumei = new Doumei(); List<string> doumeiDaimyoList = new List<string> (); bool dstEngunFlg = false; string dstEngunDaimyoId = ""; //2:3:5 string dstEngunHei = ""; string dstEngunSts = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv: int totalEngunHei = 0; doumeiDaimyoList = doumei.doumeiExistCheck(worstGaikouDaimyo,eDaimyo); if(doumeiDaimyoList.Count != 0){ //Doumei Exist //Trace Check List<string> okDaimyoList = new List<string> (); List<string> checkList = new List<string> (); okDaimyoList = doumei.traceNeighborDaimyo(worstGaikouKuni, worstGaikouDaimyo, doumeiDaimyoList, seiryokuList, checkList,okDaimyoList); if(okDaimyoList.Count !=0){ //Doumei & Neghbor Daimyo Exist for(int k=0; k<okDaimyoList.Count; k++){ string engunDaimyo = okDaimyoList[k]; int yukoudo = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), worstGaikouDaimyo); //engun check dstEngunFlg = CheckByProbability (yukoudo); if(dstEngunFlg){ //Engun OK dstEngunFlg = true; if(dstEngunDaimyoId !=null && dstEngunDaimyoId !=""){ dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo; string tempEngunSts = getEngunSts(engunDaimyo); int tempEngunHei = getEngunHei(tempEngunSts); dstEngunHei = dstEngunHei + ":" + tempEngunHei.ToString(); totalEngunHei = totalEngunHei + tempEngunHei; dstEngunSts = dstEngunSts + ":" + tempEngunSts; }else{ dstEngunDaimyoId = engunDaimyo; string tempEngunSts = getEngunSts(engunDaimyo); int tempEngunHei = getEngunHei(tempEngunSts); dstEngunHei = tempEngunHei.ToString(); totalEngunHei = tempEngunHei; dstEngunSts = tempEngunSts; } } } Gunzei.GetComponent<Gunzei> ().dstEngunFlg = dstEngunFlg; Gunzei.GetComponent<Gunzei> ().dstEngunDaimyoId = dstEngunDaimyoId; Gunzei.GetComponent<Gunzei> ().dstEngunHei = dstEngunHei; Gunzei.GetComponent<Gunzei> ().dstEngunSts = dstEngunSts; } } //Set Value //CreateTime,srcDaimyoId,dstDaimyoId,srcDaimyoName,dstDaimyoName, srcHei,locationX,locationY,left or right, engunFlg, engunDaimyoId(A:B:C), dstEngunHei(1000:2000:3000), dstEngunSts string keyValue = ""; string createTime = System.DateTime.Now.ToString (); keyValue = createTime + "," + eDaimyo + "," + worstGaikouDaimyo + "," + srcDaimyoName + "," + dstDaimyoName + "," + myHei + "," + aveX + "," + aveY + "," + direction + "," + dstEngunFlg + "," + dstEngunDaimyoId + "," + dstEngunHei + ","+ dstEngunSts; PlayerPrefs.SetString (key, keyValue); string keyHistory = PlayerPrefs.GetString ("keyHistory"); if(keyHistory == null || keyHistory == ""){ keyHistory = key; }else{ keyHistory = keyHistory + "," + key; } PlayerPrefs.SetString ("keyHistory", keyHistory); flush (); string kassenText = ""; if(!dstEngunFlg){ kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしましたぞ。"; }else{ kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしましたぞ。\t同盟国が援軍" + totalEngunHei + "人を派兵しました。"; } messageList.Add (kassenText); if(doumeiFlg){ //Delete doumei Debug.Log (eDaimyo +":"+ worstGaikouDaimyo); doumei.deleteDoumei(eDaimyo, worstGaikouDaimyo.ToString()); //Zero Gaikou string tempYukou = ""; if(tDaimyo == myDaimyo.ToString()){ tempYukou = "gaikou" + eDaimyo; }else{ if(worstGaikouDaimyo < int.Parse(eDaimyo)){ tempYukou = worstGaikouDaimyo.ToString() + "gaikou" + eDaimyo; }else{ tempYukou = eDaimyo + "gaikou" + worstGaikouDaimyo.ToString(); } } PlayerPrefs.SetInt(tempYukou,0); PlayerPrefs.Flush (); } } } } break; } } } } /*Gaikou*/ int gaikouQty = CountEnemyAction (); for (int i=1; i<gaikouQty+1; i++) { bool gaikouFlg = CheckByProbability (gaikouRatio); if (gaikouFlg == true) { //Do gaikou int randomKuni = UnityEngine.Random.Range (1, 66); int srcDaimyoId = int.Parse (seiryokuList [randomKuni - 1]); string srcDaimyoName = daimyo.getName (srcDaimyoId); if (srcDaimyoId != myDaimyo) { int gaikouAction = UnityEngine.Random.Range (1, 3); if (gaikouAction == 1) { //1. yukoudo up(Mitsugimono) bool yukoudoUpFlg = CheckByProbability (yukoudoUpMissRatio); if (yukoudoUpFlg == true) { //Choose Target Daimyo int randomDstKuni = UnityEngine.Random.Range (1, 66); int dstDaimyoId = int.Parse (seiryokuList [randomDstKuni - 1]); string dstDaimyoName = daimyo.getName (dstDaimyoId); if (srcDaimyoId != dstDaimyoId) { if (dstDaimyoId == myDaimyo) { //In the case that MyDaimyo receive Mitsugimono int addYukoudo = UpYukouValueWithMyDaimyo (myDaimyo, dstDaimyoId); int addMoney = addYukoudo * 1000; string yukouUpText = srcDaimyoName + "殿が御屋形様に、金" + addMoney.ToString() + "の貢物を送って参りました。\t友好度が" + addYukoudo + "上がります。"; int myMoney = PlayerPrefs.GetInt("money"); myMoney = myMoney + addMoney; PlayerPrefs.SetInt("money",myMoney); flush (); GameObject.Find ("MoneyValue").GetComponent<Text>().text = myMoney.ToString(); messageList.Add (yukouUpText); } else { //In the case between other daimyos int addYukoudo = UpYukouValueWithMyDaimyo (myDaimyo, dstDaimyoId); string yukouUpText = srcDaimyoName + "が" + dstDaimyoName + "に貢物をしました。友好度が" + addYukoudo + "上がります。"; messageList.Add (yukouUpText); } } } } else if (gaikouAction == 2) { //2. yukoudo down(Ryugen) bool yukoudoDownFlg = CheckByProbability (yukoudoDownMissRatio); if (yukoudoDownFlg == true) { //Choose Target Daimyo int randomDst1stKuni = UnityEngine.Random.Range (1, 66); int dst1stDaimyoId = int.Parse (seiryokuList [randomDst1stKuni - 1]); int randomDst2ndKuni = UnityEngine.Random.Range (1, 66); int dst2ndDaimyoId = int.Parse (seiryokuList [randomDst2ndKuni - 1]); if (dst1stDaimyoId != dst2ndDaimyoId) { int reduceYukoudo = 0; //My Daimyo if (dst1stDaimyoId == myDaimyo || dst2ndDaimyoId == myDaimyo) { string dstDaimyoName = ""; if (dst1stDaimyoId == myDaimyo) { reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, dst2ndDaimyoId); dstDaimyoName = daimyo.getName (dst1stDaimyoId); } if (dst2ndDaimyoId == myDaimyo) { reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, dst1stDaimyoId); dstDaimyoName = daimyo.getName (dst2ndDaimyoId); } //string yukouDownText = srcDaimyoName + "が当家と" + dstDaimyoName + "に流言を流し、友好度が" + dstDaimyoName + "下がりました。"; string yukouDownText = "何者かが当家と" + dstDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。"; messageList.Add (yukouDownText); } else { reduceYukoudo = DownYukouValueWithOther (dst1stDaimyoId, dst2ndDaimyoId); string dst1stDaimyoName = daimyo.getName (dst1stDaimyoId); string dst2ndDaimyoName = daimyo.getName (dst2ndDaimyoId); string yukouDownText = "何者かが" + dst1stDaimyoName + "と" + dst2ndDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。"; messageList.Add (yukouDownText); } } } } else if (gaikouAction == 3) { //doumei bool doumeiFlg = CheckByProbability (doumeiRatio); if (doumeiFlg == true) { } } else if (gaikouAction == 4) { } } } } /*Nanbanjin*/ /**/ /*Decrease Yukou with Doumei koku*/ string myDoumei = PlayerPrefs.GetString ("doumei"); List<string> myDoumeiList = new List<string> (); if (myDoumei != null && myDoumei != "") { if(myDoumei.Contains(",")){ myDoumeiList = new List<string> (myDoumei.Split (delimiterChars)); }else{ myDoumeiList.Add(myDoumei); } } for (int j=0; j<myDoumeiList.Count; j++) { string doumeiDaimyo = myDoumeiList[j]; string yukouTemp = "gaikou" + doumeiDaimyo; int yukouWithDoumei = PlayerPrefs.GetInt (yukouTemp); int reduceYukou = UnityEngine.Random.Range(0,3); yukouWithDoumei = yukouWithDoumei - reduceYukou; PlayerPrefs.SetInt (yukouTemp,yukouWithDoumei); /*Doumei Clear Check*/ if(yukouWithDoumei<30){ //My Doumei Clear myDoumeiList.Remove(doumeiDaimyo); string newMyDoumei = ""; for(int i=0; i<myDoumeiList.Count; i++){ if(i==0){ newMyDoumei = myDoumeiList[i]; }else{ newMyDoumei = newMyDoumei + "," + myDoumeiList[i]; } } PlayerPrefs.SetString ("doumei",newMyDoumei); //Opposite Doumei Clear string otherTemp = "doumei" + doumeiDaimyo; string otherDoumei = PlayerPrefs.GetString (otherTemp); List<string> otherDoumeiList = new List<string> (); if (otherDoumei != null && otherDoumei != "") { if(otherDoumei.Contains(",")){ otherDoumeiList = new List<string> (otherDoumei.Split (delimiterChars)); }else{ otherDoumeiList.Add(otherDoumei); } } otherDoumeiList.Remove(myDaimyo.ToString()); string newOtherDoumei = ""; for(int i=0; i<otherDoumeiList.Count; i++){ if(i==0){ newOtherDoumei = otherDoumeiList[i]; }else{ newOtherDoumei = newOtherDoumei + "," + otherDoumeiList[i]; } } PlayerPrefs.SetString (otherTemp,newOtherDoumei); //Icon & Flg Change KuniInfo kuni = new KuniInfo(); kuni.deleteDoumeiKuniIcon(int.Parse(doumeiDaimyo)); //Message string dstDaimyoName = daimyo.getName (int.Parse(doumeiDaimyo)); string doumeiClearText = "友好度悪化により、当家と" + dstDaimyoName + "間の同盟が解消しました。"; messageList.Add (doumeiClearText); } PlayerPrefs.Flush(); } /*Message*/ if (messageList.Count != 0) { /*Common Process*/ //make back string pathOfBack = "Prefabs/Common/TouchBack"; GameObject back = Instantiate(Resources.Load (pathOfBack)) as GameObject; back.transform.SetParent(GameObject.Find ("Panel").transform); back.transform.localScale = new Vector2 (1,1); back.transform.localPosition = new Vector2 (0,0); //make board string pathOfBoard = "Prefabs/Event/EventBoard"; GameObject board = Instantiate(Resources.Load (pathOfBoard)) as GameObject; board.transform.SetParent(GameObject.Find ("Panel").transform); board.transform.localScale = new Vector2 (1,1); string pathOfScroll = "Prefabs/Event/EventScrollView"; GameObject scroll = Instantiate(Resources.Load (pathOfScroll)) as GameObject; scroll.transform.SetParent(board.transform); scroll.transform.localScale = new Vector2 (1,1); RectTransform scrollTransform = scroll.GetComponent<RectTransform> (); scrollTransform.anchoredPosition = new Vector3 (0, -40, 0); string pathOfSlot = "Prefabs/Event/EventSlot"; foreach (string text in messageList) { GameObject slot = Instantiate(Resources.Load (pathOfSlot)) as GameObject; slot.transform.SetParent(scroll.transform.FindChild("Content").transform); slot.transform.FindChild("EventText").GetComponent<Text>().text = text; slot.transform.localScale = new Vector2 (1,1); } } }
public void OnClick() { audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); CloseLayer closeLayerScript = GameObject.Find("CloseSyoukaijyo").GetComponent <CloseLayer> (); string rank = closeLayerScript.syoukaijyoRank; bool occupiedFlg = closeLayerScript.occupiedFlg; int nowPoint = PlayerPrefs.GetInt("cyouteiPoint"); Message msg = new Message(); if (name == "DoKenjyoButton") { audioSources [3].Play(); //Reduce Action Qty reduceActionQty(); //Get Money Value & reduce money int giveMoney = int.Parse(GameObject.Find("GiveMoneyValue").GetComponent <Text> ().text); int money = PlayerPrefs.GetInt("money"); int newMoney = money - giveMoney; PlayerPrefs.SetInt("money", newMoney); GameObject.Find("MoneyValue").GetComponent <Text> ().text = newMoney.ToString(); //Add Kouken Value float addPoint = 0; if (rank == "Jyo") { addPoint = giveMoney / 200; } else if (rank == "Cyu") { addPoint = giveMoney / 300; } else if (rank == "Ge") { addPoint = giveMoney / 500; } if (occupiedFlg) { addPoint = addPoint * 1.5f; } int rdmId = UnityEngine.Random.Range(0, 6); List <float> rdmValueList = new List <float> () { 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f }; float rdmValue = rdmValueList [rdmId]; addPoint = addPoint * rdmValue; int newPoint = nowPoint + Mathf.CeilToInt(addPoint); if (newPoint > 100) { newPoint = 100; } PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; PlayerPrefs.Flush(); string pathOfAnim = "Prefabs/EffectAnime/point_up"; GameObject anim = Instantiate(Resources.Load(pathOfAnim)) as GameObject; anim.transform.SetParent(GameObject.Find("CyouteiPoint").transform); anim.transform.localScale = new Vector2(80, 80); anim.transform.localPosition = new Vector2(40, 30); GameObject menu = GameObject.Find("MenuKenjyo").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); serihuScript.mikadoSerihuChanger(msg.getMessage(32)); } else if (name == "DoCyouteiButton") { int addYukoudo = closeLayerScript.yukouAddValue; int reducePoint = closeLayerScript.yukouReducePoint; if (reducePoint <= nowPoint) { audioSources [3].Play(); //Reduce Action Qty reduceActionQty(); int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; upYukoudo(addYukoudo); serihuScript.mikadoSerihuChanger(msg.getMessage(33)); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuCyoutei").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } else if (name == "DoTeisenButton") { int stropBattleRatio = closeLayerScript.stopBattleRatio; int reducePoint = closeLayerScript.stopBattleReducePoint; if (reducePoint <= nowPoint) { //Reduce Action Qty reduceActionQty(); bool successFlg = teisen(stropBattleRatio); if (successFlg) { int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; } } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuTeisen").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } else if (name == "DoKanniButton") { int reducePoint = closeLayerScript.kanniReducePoint; if (reducePoint <= nowPoint) { //Reduce Action Qty reduceActionQty(); int ratio = closeLayerScript.kanniRatio; int kanniId = closeLayerScript.kanniId; string kanniName = closeLayerScript.kanniName; bool successFlg = registerKanni(ratio, kanniId, kanniName); if (successFlg) { int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; Color enableImageColor = new Color(35f / 255f, 35f / 255f, 35f / 255f, 155f / 255f); Color enableTextColor = new Color(125f / 255f, 125f / 255f, 125f / 255f, 255f / 255f); GameObject btn = GameObject.Find("Kanni").gameObject; btn.GetComponent <Button> ().enabled = false; btn.GetComponent <Image> ().color = enableImageColor; btn.transform.FindChild("Text").GetComponent <Text> ().color = enableTextColor; } } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuKanni").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } else if (name == "DoCyoutekiButton") { int reducePoint = closeLayerScript.cyoutekiReducePoint; if (reducePoint <= nowPoint) { audioSources [3].Play(); //Reduce Action Qty reduceActionQty(); int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; int targetDaimyoId = closeLayerScript.cyoutekiDaimyo; string targetDaimyoName = closeLayerScript.cyoutekiDaimyoName; //reduce yukoudo string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); //src daimyo kuni list List <string> srcDaimyoKuniList = new List <string> (); GameObject KuniIconView = GameObject.Find("KuniIconView").gameObject; for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyoId = seiryokuList [i]; if (tempDaimyoId == targetDaimyoId.ToString()) { int temp = i + 1; srcDaimyoKuniList.Add(temp.ToString()); //Change Map Valye KuniIconView.transform.FindChild(temp.ToString()).GetComponent <SendParam> ().myYukouValue = 0; } } //src daimyo open kuni list KuniInfo kuni = new KuniInfo(); List <int> openKuniList = new List <int> (); for (int j = 0; j < srcDaimyoKuniList.Count; j++) { openKuniList.AddRange(kuni.getMappingKuni(int.Parse(srcDaimyoKuniList [j]))); } //Target Daimyo (exculde this src daimyo & mydaimyo) int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); List <int> dstDaimyoList = new List <int> (); for (int k = 0; k < openKuniList.Count; k++) { int temp = openKuniList [k] - 1; int tempDaimyoId = int.Parse(seiryokuList [temp]); if (tempDaimyoId != targetDaimyoId) { if (!dstDaimyoList.Contains(tempDaimyoId)) { dstDaimyoList.Add(tempDaimyoId); } } } //Reduce Yukoudo for (int l = 0; l < dstDaimyoList.Count; l++) { int dstDaimyoId = dstDaimyoList [l]; DownYukouToZeroWithOther(targetDaimyoId, dstDaimyoId, myDaimyo); } //Hist PlayerPrefs.SetInt("cyoutekiDaimyo", targetDaimyoId); PlayerPrefs.Flush(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Royal court declared " + targetDaimyoName + " is the enemy.\n friendship with surrounded families decreased."; } else { OKtext = targetDaimyoName + "討伐の勅令が出されました。\n周辺大名との関係が著しく悪化しますぞ。"; } msg.makeMessage(OKtext); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuCyouteki").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } else if (name == "DoBakuhuButton") { int reducePoint = 100; if (reducePoint <= nowPoint) { audioSources [3].Play(); //Reduce Action Qty reduceActionQty(); int newPoint = nowPoint - reducePoint; PlayerPrefs.SetInt("cyouteiPoint", newPoint); GameObject.Find("CyouteiValue").GetComponent <Text> ().text = newPoint.ToString() + "%"; //Syogun string year = GameObject.Find("YearValue").GetComponent <Text>().text; string season = GameObject.Find("SeasonValue").GetComponent <Text>().text; string daimyoBusyoName = GameObject.Find("DaimyoValue").GetComponent <Text>().text; string text = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { text = year + " " + season + "," + daimyoBusyoName + " was assigned syogun.\n You opened shogunate."; } else { text = year + "年" + season + "," + daimyoBusyoName + "は征夷大将軍に任じられました。\n幕府を開き、天下に号令をかけます。"; } msg.makeMessageWithImage(text); //Change Value int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); PlayerPrefs.SetInt("syogunDaimyoId", myDaimyo); //Up yukoudo int rdmAddYukoudo = UnityEngine.Random.Range(20, 50); upYukoudoWithEveryDaimyo(rdmAddYukoudo); PlayerPrefs.Flush(); //Enable Syogun Button GameObject oya = GameObject.Find("SubButtonViewRight").gameObject; GameObject ko = oya.transform.FindChild("Bakuhu").gameObject; ko.SetActive(true); string pathOfAnim = "Prefabs/EffectAnime/point_up"; GameObject anim = Instantiate(Resources.Load(pathOfAnim)) as GameObject; anim.transform.SetParent(ko.transform); anim.transform.localScale = new Vector2(200, 200); anim.transform.localPosition = new Vector2(0, 100); } else { audioSources [4].Play(); msg.makeMessage(msg.getMessage(34)); } GameObject menu = GameObject.Find("MenuBakuhu").gameObject; menu.transform.FindChild("Close").GetComponent <CloseMenu> ().OnClick(); } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [2].Play(); /*Busyo View*/ //Delete Previous foreach (Transform n in GameObject.Find("BusyoView").transform) { GameObject.Destroy(n.gameObject); } //Jinkei Flg if (jinkeiFlg) { string iconPath = "Prefabs/Busyo/Jinkei"; GameObject jinkei = Instantiate(Resources.Load(iconPath)) as GameObject; jinkei.transform.SetParent(GameObject.Find("BusyoView").transform); jinkei.transform.localScale = new Vector2(0.3f, 0.3f); jinkei.transform.localPosition = new Vector2(220, 200); jinkei.name = "jinkei"; } //Make New Busyo string busyoId; busyoId = this.name.Remove(0, 4); string path = "Prefabs/Player/Unit/BusyoUnit"; GameObject Busyo = Instantiate(Resources.Load(path)) as GameObject; Busyo.name = busyoId.ToString(); Busyo.transform.SetParent(GameObject.Find("BusyoView").transform); Busyo.transform.localScale = new Vector2(4, 4); Busyo.GetComponent <DragHandler> ().enabled = false; RectTransform rect_transform = Busyo.GetComponent <RectTransform>(); rect_transform.anchoredPosition3D = new Vector3(300, 200, 0); rect_transform.sizeDelta = new Vector2(100, 100); //Ship Rank string shipPath = "Prefabs/Busyo/ShipSts"; GameObject ShipObj = Instantiate(Resources.Load(shipPath)) as GameObject; ShipObj.transform.SetParent(Busyo.transform); preKaisen kaisenScript = new preKaisen(); int shipId = kaisenScript.getShipSprite(ShipObj, int.Parse(busyoId)); ShipObj.transform.localPosition = new Vector3(-40, -40, 0); ShipObj.transform.localScale = new Vector2(0.4f, 0.4f); if (Application.systemLanguage != SystemLanguage.Japanese) { if (shipId == 1) { ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "High"; } else if (shipId == 2) { ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "Mid"; } else if (shipId == 3) { ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "Low"; } } else { if (shipId == 1) { ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "上"; } else if (shipId == 2) { ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "中"; } else if (shipId == 3) { ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "下"; } } //Text Modification GameObject text = Busyo.transform.FindChild("Text").gameObject; text.GetComponent <Text> ().color = new Color(255, 255, 255, 255); RectTransform text_transform = text.GetComponent <RectTransform>(); text_transform.anchoredPosition3D = new Vector3(-70, 30, 0); text_transform.sizeDelta = new Vector2(630, 120); text.transform.localScale = new Vector2(0.2f, 0.2f); //Rank Text Modification GameObject rank = Busyo.transform.FindChild("Rank").gameObject; RectTransform rank_transform = rank.GetComponent <RectTransform>(); rank_transform.anchoredPosition3D = new Vector3(20, -50, 0); rank_transform.sizeDelta = new Vector2(200, 200); rank.GetComponent <Text>().fontSize = 200; /*Busyo Status*/ NowOnBusyo NowOnBusyoScript = GameObject.Find("GameScene").GetComponent <NowOnBusyo> (); BusyoInfoGet busyoInfoGetScript = new BusyoInfoGet(); if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Ronkou") { int lv = PlayerPrefs.GetInt(busyoId); StatusGet sts = new StatusGet(); int hp = sts.getHp(int.Parse(busyoId), lv); int atk = sts.getAtk(int.Parse(busyoId), lv); int dfc = sts.getDfc(int.Parse(busyoId), lv); int spd = sts.getSpd(int.Parse(busyoId), lv); int adjHp = hp * 100; int adjAtk = atk * 10; int adjDfc = dfc * 10; //add lv string addLvTmp = "addlv" + busyoId.ToString(); if (PlayerPrefs.HasKey(addLvTmp)) { string addLvValue = "+" + PlayerPrefs.GetString(addLvTmp); GameObject.Find("addLvValue").GetComponent <Text>().text = addLvValue.ToString(); } else { GameObject.Find("addLvValue").GetComponent <Text>().text = ""; } int maxLv = 100 + PlayerPrefs.GetInt(addLvTmp); GameObject.Find("LvValue").GetComponent <Text> ().text = lv.ToString(); GameObject.Find("TosotsuValue").GetComponent <Text> ().text = adjHp.ToString(); GameObject.Find("BuyuuValue").GetComponent <Text> ().text = adjAtk.ToString(); GameObject.Find("ChiryakuValue").GetComponent <Text> ().text = adjDfc.ToString(); GameObject.Find("SpeedValue").GetComponent <Text> ().text = spd.ToString(); //Exp string expId = "exp" + busyoId.ToString(); string expString = ""; int nowExp = PlayerPrefs.GetInt(expId); Exp exp = new Exp(); int requiredExp = 0; if (lv != maxLv) { requiredExp = exp.getExpforNextLv(lv); } else { requiredExp = exp.getExpLvMax(maxLv); } expString = nowExp + "/" + requiredExp; GameObject.Find("ExpValue").GetComponent <Text> ().text = expString; //Kahou status KahouStatusGet kahouSts = new KahouStatusGet(); string[] KahouStatusArray = kahouSts.getKahouForStatus(busyoId, adjHp, adjAtk, adjDfc, spd); int totalBusyoHp = 0; //Kanni string kanniTmp = "kanni" + busyoId; float addAtkByKanni = 0; float addHpByKanni = 0; float addDfcByKanni = 0; if (PlayerPrefs.HasKey(kanniTmp)) { int kanniId = PlayerPrefs.GetInt(kanniTmp); if (kanniId != 0) { Kanni kanni = new Kanni(); string kanniIkai = kanni.getIkai(kanniId); string kanniName = kanni.getKanni(kanniId); GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text> ().text = kanniIkai + "\n" + kanniName; //Status string kanniTarget = kanni.getEffectTarget(kanniId); int effect = kanni.getEffect(kanniId); if (kanniTarget == "atk") { addAtkByKanni = ((float)adjAtk * (float)effect) / 100; } else if (kanniTarget == "hp") { addHpByKanni = ((float)adjHp * (float)effect) / 100; } else if (kanniTarget == "dfc") { addDfcByKanni = ((float)adjDfc * (float)effect) / 100; } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank"; } else { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し"; } } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text> ().text = "No Rank"; } else { GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し"; } } //Jyosyu string jyosyuTmp = "jyosyuBusyo" + busyoId; if (PlayerPrefs.HasKey(jyosyuTmp)) { int kuniId = PlayerPrefs.GetInt(jyosyuTmp); KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text> ().text = kuniName + "\nLord"; } else { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = kuniName + "\n城主"; } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "No Feud"; } else { GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "城無し"; } } //Show Additional Status int finalAtk = int.Parse(KahouStatusArray [0]) + Mathf.FloorToInt(addAtkByKanni); int finalHp = int.Parse(KahouStatusArray [1]) + Mathf.FloorToInt(addHpByKanni); int finalDfc = int.Parse(KahouStatusArray [2]) + Mathf.FloorToInt(addDfcByKanni); int finalSpd = int.Parse(KahouStatusArray [3]); GameObject.Find("KahouAtkValue").GetComponent <Text> ().text = "+" + finalAtk.ToString(); GameObject.Find("KahouHpValue").GetComponent <Text>().text = "+" + finalHp.ToString(); totalBusyoHp = adjHp + finalHp; GameObject.Find("KahouDfcValue").GetComponent <Text>().text = "+" + finalDfc.ToString(); GameObject.Find("KahouSpdValue").GetComponent <Text>().text = "+" + finalSpd.ToString(); //Butai Status string heiId = "hei" + busyoId.ToString(); string chParam = PlayerPrefs.GetString(heiId, "0"); if (chParam == "0" || chParam == "") { StatusGet statusScript = new StatusGet(); string heisyu = statusScript.getHeisyu(int.Parse(busyoId)); chParam = heisyu + ":1:1:1"; PlayerPrefs.SetString(heiId, chParam); PlayerPrefs.Flush(); } if (chParam.Contains(":")) { char[] delimiterChars = { ':' }; string[] ch_list = chParam.Split(delimiterChars); string ch_type = ch_list [0]; int ch_num = int.Parse(ch_list [1]); int ch_lv = int.Parse(ch_list [2]); float ch_status = float.Parse(ch_list [3]); string heisyu = ""; Message msg = new Message(); if (ch_type == "KB") { heisyu = msg.getMessage(55); } else if (ch_type == "YR") { heisyu = msg.getMessage(56); } else if (ch_type == "TP") { heisyu = msg.getMessage(57); } else if (ch_type == "YM") { heisyu = msg.getMessage(58); } GameObject.Find("ChildNameValue").GetComponent <Text> ().text = heisyu; GameObject.Find("ChildQtyValue").GetComponent <Text> ().text = ch_num.ToString(); GameObject.Find("ChildLvValue").GetComponent <Text> ().text = ch_lv.ToString(); //Jyosyu Handling JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku(); float addHei = (float)jyosyuHei.GetJyosyuHeiryoku(busyoId); float hei = ch_status * 10; GameObject.Find("ChildHeiryokuValue").GetComponent <Text>().text = hei.ToString(); float newHei = finalHp + addHei; GameObject.Find("KahouHpValue").GetComponent <Text>().text = "+" + newHei.ToString(); int chAtkDfc = (int)sts.getChAtkDfc((int)hei, totalBusyoHp); string chAtkDfcString = chAtkDfc.ToString() + "/" + chAtkDfc.ToString(); GameObject.Find("ChildStatusValue").GetComponent <Text> ().text = chAtkDfcString; //Child Image foreach (Transform n in GameObject.Find("Img").transform) { GameObject.Destroy(n.gameObject); } string chPath = "Prefabs/Player/Unit/" + ch_type; GameObject chObj = Instantiate(Resources.Load(chPath)) as GameObject; chObj.transform.SetParent(GameObject.Find("Img").transform); RectTransform chTransform = chObj.GetComponent <RectTransform> (); chTransform.anchoredPosition3D = new Vector3(-200, -50, 0); chTransform.sizeDelta = new Vector2(40, 40); chObj.transform.localScale = new Vector2(4, 4); GameObject chigyo = GameObject.Find("ButtonCyouhei"); if (ch_num < 20) { chigyo.GetComponent <Image> ().color = OKClorBtn; chigyo.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt; chigyo.GetComponent <Button>().enabled = true; chigyo.GetComponent <BusyoStatusButton> ().ch_type = ch_type; chigyo.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu; chigyo.GetComponent <BusyoStatusButton> ().ch_num = ch_num; chigyo.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc; chigyo.GetComponent <BusyoStatusButton> ().ch_hp = hei; chigyo.GetComponent <BusyoStatusButton> ().pa_hp = totalBusyoHp / 100; } else { //MAX chigyo.GetComponent <Image> ().color = NGClorBtn; chigyo.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt; chigyo.GetComponent <Button>().enabled = false; } GameObject kunren = GameObject.Find("ButtonKunren"); if (ch_lv < 100) { kunren.GetComponent <Image> ().color = OKClorBtn; kunren.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt; kunren.GetComponent <Button>().enabled = true; kunren.GetComponent <BusyoStatusButton> ().ch_type = ch_type; kunren.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu; kunren.GetComponent <BusyoStatusButton> ().ch_lv = ch_lv; kunren.GetComponent <BusyoStatusButton> ().ch_num = ch_num; kunren.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc; kunren.GetComponent <BusyoStatusButton> ().ch_hp = hei; kunren.GetComponent <BusyoStatusButton> ().pa_hp = totalBusyoHp / 100; } else { //MAX kunren.GetComponent <Image> ().color = NGClorBtn; kunren.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt; kunren.GetComponent <Button>().enabled = false; } } //Parametor Setting NowOnBusyoScript.OnBusyo = busyoId; NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId)); } else if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Senpou") { NowOnBusyoScript.OnBusyo = busyoId; NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId)); SenpouScene scene = new SenpouScene(); scene.createSenpouStatusView(busyoId); scene.createSakuStatusView(busyoId); } else if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Kahou") { NowOnBusyoScript.OnBusyo = busyoId; NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId)); KahouScene kahou = new KahouScene(); kahou.createKahouStatusView(busyoId); } else if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Syogu") { NowOnBusyoScript.OnBusyo = busyoId; NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId)); SyoguScene syogu = new SyoguScene(); syogu.createSyoguView(busyoId); } }
public int getWeatherId(){ //get season string yearSeason = PlayerPrefs.GetString ("yearSeason"); char[] delimiterChars = {','}; string[] yearSeasonList = yearSeason.Split (delimiterChars); int nowSeason = int.Parse (yearSeasonList [1]); int weatherId = 0; //1:normal, 2:rain, 3:snow if (nowSeason == 1 || nowSeason == 3) { //Spring & Fall float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= 70) { weatherId = 1; } else if (70 < percent && percent <= 90) { weatherId = 2; } else if (90 < percent && percent <= 100) { weatherId = 3; } } else if (nowSeason == 2) { //Summer float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= 60) { weatherId = 1; } else if (60 < percent && percent <= 100) { weatherId = 2; } } else if (nowSeason == 4) { //Winter //Check snow area or not int activeKuniId = PlayerPrefs.GetInt("activeKuniId"); KuniInfo kuni = new KuniInfo (); bool isSnowFlg = kuni.getKuniIsSnowFlg(activeKuniId); if (isSnowFlg) { weatherId = 3; } else { float percent = UnityEngine.Random.value; percent = percent * 100; if (percent <= 50) { weatherId = 1; } else if (50 < percent && percent <= 70) { weatherId = 2; } else if (70 < percent && percent <= 100) { weatherId = 3; } } } //Set Object by wether Id if (weatherId == 2) { //rain string path = "Prefabs/PreKassen/particle/PreRain"; GameObject particle = Instantiate (Resources.Load (path)) as GameObject; }else if(weatherId == 3){ //snow string path = "Prefabs/PreKassen/particle/PreSnow"; GameObject particle = Instantiate (Resources.Load (path)) as GameObject; } return weatherId; }