public void IconMapValueUpdate(int kuniId, int changeDaimyoId, GameObject kuniIconView, GameObject kuniMap, int myKuniQty) { Daimyo daimyo = new Daimyo(); GameObject targetKuniIcon = kuniIconView.transform.FindChild(kuniId.ToString()).gameObject; targetKuniIcon.gameObject.AddComponent <IconFadeChange> (); targetKuniIcon.gameObject.AddComponent <IconFadeChange> ().toDaimyoId = changeDaimyoId; float colorR = daimyo.getColorR(changeDaimyoId); float colorG = daimyo.getColorG(changeDaimyoId); float colorB = daimyo.getColorB(changeDaimyoId); Color newColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); GameObject kuniMapObj = kuniMap.transform.FindChild(kuniId.ToString()).gameObject; kuniMapObj.GetComponent <Image> ().color = newColor; //Change Name of target Kuni by daimyo info SendParam script = targetKuniIcon.GetComponent <SendParam> (); script.daimyoId = changeDaimyoId; string daimyoName = daimyo.getName(changeDaimyoId); script.daimyoName = daimyoName; int daimyoBusyoId = daimyo.getDaimyoBusyoId(changeDaimyoId); script.daimyoBusyoId = daimyoBusyoId; myKuniQty = myKuniQty + 1; script.kuniQty = myKuniQty; script.openFlg = true; script.clearFlg = true; int myHeiryoku = PlayerPrefs.GetInt("jinkeiHeiryoku"); script.heiryoku = myHeiryoku; }
public void upYukoudoWithEveryDaimyo(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 <int> targetDaimyoList = new List <int>(); for (int i = 0; i < seiryokuList.Count; i++) { int tempDaimyoId = int.Parse(seiryokuList[i]); if (!targetDaimyoList.Contains(tempDaimyoId)) { if (tempDaimyoId != myDaimyoId) { targetDaimyoList.Add(tempDaimyoId); } } } //Add Yukoudo Daimyo daimyo = new Daimyo(); string cyouteiText = ""; for (int l = 0; l < targetDaimyoList.Count; l++) { int dstDaimyoId = targetDaimyoList[l]; 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); } PlayerPrefs.Flush(); }
public void updateAtkOrderBtnStatus(GameObject contentObj) { int daimyoId = PlayerPrefs.GetInt("bakuhuTobatsuDaimyoId"); if (daimyoId != null && daimyoId != 0) { GameObject atkBtn = contentObj.transform.FindChild("AtkOrderBtn").gameObject; atkBtn.GetComponent <Button> ().enabled = false; atkBtn.GetComponent <Image> ().color = new Color(120f / 255f, 120f / 255f, 120f / 255f, 150f / 255f); atkBtn.transform.FindChild("HyourouIcon").gameObject.SetActive(false); Daimyo daimyo = new Daimyo(); string toubatsuDaiymoName = daimyo.getName(daimyoId); if (Application.systemLanguage != SystemLanguage.Japanese) { atkBtn.transform.FindChild("Exp").GetComponent <Text> ().text = "You've already issued attack order to " + toubatsuDaiymoName + " in this season.\n You can order for 1 time in a season."; } else { atkBtn.transform.FindChild("Exp").GetComponent <Text>().text = "今季は既に" + toubatsuDaiymoName + "に討伐令が出ています。\n討伐令は季節に一回のみ実施可能です。"; } } }
public GameObject MakeCommentObj(int enemyDaimyoId, int kuniId) { //Popup string cmntPath = "Prefabs/Map/stage/EventComment"; GameObject commentObj = Instantiate(Resources.Load(cmntPath)) as GameObject; GameObject attackStagePopup = GameObject.Find("AttackStagePopup").gameObject; commentObj.transform.SetParent(attackStagePopup.transform); commentObj.transform.localScale = new Vector2(2.0f, 2.5f); commentObj.transform.localPosition = new Vector2(-145, 307); commentObj.GetComponent <FadeoutSenpou> ().enabled = true; commentObj.name = "EventComment"; //Busyo Image GameObject busyoImage = commentObj.transform.FindChild("Mask").transform.FindChild("BusyoImage").gameObject; Daimyo daimyo = new Daimyo(); int daimyoBusyoId = daimyo.getDaimyoBusyoId(enemyDaimyoId); string imagePath = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString(); busyoImage.GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; return(commentObj); }
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 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 win(string tKey, int tSrcDaimyoId, int tDstDaimyoId, bool noGunzeiFlg, int dstKuni) { int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); //Kuni Change string seiryoku = PlayerPrefs.GetString("seiryoku"); char[] delimiterChars = { ',' }; List <string> seiryokuList = new List <string>(); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); List <string> srcDstKuniList = new List <string> (); char[] keyDelimiterChars = { '-' }; srcDstKuniList = new List <string> (tKey.Split(keyDelimiterChars)); seiryokuList[int.Parse(srcDstKuniList[1]) - 1] = tSrcDaimyoId.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); List <string> newSeiryokuList = new List <string>(); newSeiryokuList = new List <string> (newSeiryoku.Split(delimiterChars)); //Delete Enemy Gunzei HPCounter dltScript = new HPCounter(); dltScript.deleteEnemyGunzeiData(int.Parse(srcDstKuniList[1])); //Delete Stage Cleared string clearedString = "kuni" + srcDstKuniList[1]; PlayerPrefs.DeleteKey(clearedString); if (noGunzeiFlg == true) { //Metsubou Check if (!newSeiryokuList.Contains(tDstDaimyoId.ToString())) { //Metsubou string metsubou = PlayerPrefs.GetString("metsubou"); if (metsubou == null || metsubou == "") { metsubou = tSrcDaimyoId.ToString() + ":" + tDstDaimyoId.ToString(); } else { metsubou = metsubou + "," + tSrcDaimyoId.ToString() + ":" + tDstDaimyoId.ToString(); } PlayerPrefs.SetString("metsubou", metsubou); } } else { //Pattern of Has past gameObject.GetComponent <GunzeiFadeOut> ().enabled = true; //Metsubou Check if (!newSeiryokuList.Contains(tDstDaimyoId.ToString())) { audioSources [4].Play(); audioSources [6].Play(); //Metsubou Message string pathOfBack = "Prefabs/Event/TouchEventBack"; 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); back.GetComponent <CloseEventBoard> ().deleteObj = board; back.GetComponent <CloseEventBoard> ().deleteObj2 = back; board.transform.FindChild("close").GetComponent <CloseEventBoard> ().deleteObj = board; board.transform.FindChild("close").GetComponent <CloseEventBoard> ().deleteObj2 = back; string pathOfScroll = "Prefabs/Event/Metsubou"; GameObject scroll = Instantiate(Resources.Load(pathOfScroll)) as GameObject; scroll.transform.SetParent(board.transform); scroll.transform.localScale = new Vector2(1, 1); string pathOfSlot = "Prefabs/Event/MetsubouSlot"; GameObject contents = scroll.transform.FindChild("MetsubouScrollView/MetsubouContent").gameObject; GameObject slot = Instantiate(Resources.Load(pathOfSlot)) as GameObject; slot.transform.SetParent(contents.transform); Daimyo daimyoScript = new Daimyo(); string srcDaimyoName = daimyoScript.getName(tSrcDaimyoId); string dstDaimyoName = daimyoScript.getName(tDstDaimyoId); string metsubouText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { metsubouText = dstDaimyoName + " was destroyed completly by " + srcDaimyoName + "."; } else { metsubouText = dstDaimyoName + "は" + srcDaimyoName + "に滅ぼされました"; } slot.transform.FindChild("MetsubouText").GetComponent <Text> ().text = metsubouText; slot.transform.localScale = new Vector2(1, 1); //pointer back.GetComponent <CloseEventBoard>().metsubouKuniList.Add(dstKuni); board.transform.FindChild("close").GetComponent <CloseEventBoard>().metsubouKuniList.Add(dstKuni); back.GetComponent <CloseEventBoard>().activityUpdateFlg = true; board.transform.FindChild("close").GetComponent <CloseEventBoard>().activityUpdateFlg = true; //Metsubou Daimyo Handling string srcMetsubouTemp = "metsubou" + tSrcDaimyoId.ToString(); string srcMetsubou = PlayerPrefs.GetString(srcMetsubouTemp); string dstMetsubouTemp = "metsubou" + tDstDaimyoId.ToString(); string dstMetsubou = PlayerPrefs.GetString(dstMetsubouTemp); string newSrcMetsubou = ""; if (srcMetsubou != null && srcMetsubou != "") { newSrcMetsubou = srcMetsubou + "," + tDstDaimyoId.ToString(); } else { newSrcMetsubou = tDstDaimyoId.ToString(); } if (dstMetsubou != null && dstMetsubou != "") { newSrcMetsubou = newSrcMetsubou + "," + dstMetsubou; } PlayerPrefs.SetString(srcMetsubouTemp, newSrcMetsubou); } } 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(tKey); 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); PlayerPrefs.DeleteKey(tKey); PlayerPrefs.Flush(); if (myDaimyo == tDstDaimyoId) { //Scene Change Application.LoadLevel("mainStage"); } else { //Load Main Controler int tSrcKuni = int.Parse(srcDstKuniList[0]); int tDstKuni = int.Parse(srcDstKuniList[1]); changeKuniIconAndParam(tSrcKuni, tDstKuni, tSrcDaimyoId, tDstDaimyoId); } }
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 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); }
public void showBusyoZukan(GameObject Content) { //Prepare Master & History Entity_busyo_mst tempBusyoMst = Resources.Load("Data/busyo_mst") as Entity_busyo_mst; string zukanBusyoHst = PlayerPrefs.GetString("zukanBusyoHst"); List <string> zukanBusyoHstList = new List <string> (); char[] delimiterChars = { ',' }; if (zukanBusyoHst != null && zukanBusyoHst != "") { if (zukanBusyoHst.Contains(",")) { zukanBusyoHstList = new List <string> (zukanBusyoHst.Split(delimiterChars)); } else { zukanBusyoHstList.Add(zukanBusyoHst); } } //add temporary daimyo busyo int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); Daimyo daimyo = new Daimyo(); int myDaimyoBusyoId = daimyo.getDaimyoBusyoId(myDaimyo); if (!zukanBusyoHstList.Contains(myDaimyoBusyoId.ToString())) { zukanBusyoHstList.Add(myDaimyoBusyoId.ToString()); } //Sort Master by daimyo Entity_busyo_mst busyoMst = new Entity_busyo_mst(); busyoMst.param.AddRange(tempBusyoMst.param); busyoMst.param.Sort((a, b) => a.daimyoId - b.daimyoId); //Show busyo string path = "Prefabs/Zukan/zukanBusyo"; string nameRankPath = "Prefabs/Zukan/NameRank"; int NowQty = 0; int AllQty = 0; for (int i = 0; i < busyoMst.param.Count; i++) { int daimyoId = busyoMst.param[i].daimyoId; if (daimyoId == 0) { daimyoId = busyoMst.param[i].daimyoHst; } if (daimyoId != 0) { AllQty = AllQty + 1; BusyoInfoGet busyoScript = new BusyoInfoGet(); int busyoId = busyoMst.param[i].id; string busyoName = busyoScript.getName(busyoId); string busyoRank = busyoMst.param[i].rank; GameObject back = Instantiate(Resources.Load(path)) as GameObject; back.transform.SetParent(Content.transform); back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector3(0, 0, 0); GameObject kamon = back.transform.FindChild("kamon").gameObject; //Busyo Icon string busyoPath = "Prefabs/Player/Unit/BusyoUnit"; GameObject busyo = Instantiate(Resources.Load(busyoPath)) as GameObject; busyo.name = busyoId.ToString(); busyo.transform.SetParent(back.transform); busyo.transform.localScale = new Vector2(4, 4); busyo.GetComponent <DragHandler>().enabled = false; foreach (Transform n in busyo.transform) { GameObject.Destroy(n.gameObject); } RectTransform busyoRect = busyo.GetComponent <RectTransform>(); busyoRect.anchoredPosition3D = new Vector3(80, 80, 0); busyoRect.sizeDelta = new Vector2(40, 40); //Kamon string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString(); kamon.GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; //Name GameObject nameRank = Instantiate(Resources.Load(nameRankPath)) as GameObject; nameRank.transform.SetParent(back.transform); nameRank.transform.localScale = new Vector2(1, 1); nameRank.transform.localPosition = new Vector3(0, 0, 0); GameObject rank = nameRank.transform.FindChild("Rank").gameObject; rank.GetComponent <Text>().text = busyoRank; //Have or not if (zukanBusyoHstList.Contains(busyoId.ToString())) { NowQty = NowQty + 1; GameObject name = nameRank.transform.FindChild("Name").gameObject; name.GetComponent <Text>().text = busyoName; int hp = busyoMst.param[i].hp; int atk = busyoMst.param[i].atk; int dfc = busyoMst.param[i].dfc; int spd = busyoMst.param[i].spd; string heisyu = busyoMst.param[i].heisyu; int sendpouId = busyoMst.param[i].senpou_id; PopInfo popScript = back.GetComponent <PopInfo>(); popScript.busyoId = busyoId; popScript.busyoName = busyoName; popScript.hp = hp; popScript.atk = atk; popScript.dfc = dfc; popScript.spd = spd; popScript.heisyu = heisyu; popScript.daimyoId = daimyoId; popScript.senpouId = sendpouId; } else { Color noBusyoColor = new Color(0f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); //Black Color backColor = new Color(95f / 255f, 95f / 255f, 95f / 255f, 240f / 255f); //Black Color kamonColor = new Color(105f / 255f, 105f / 255f, 105f / 255f, 135f / 255f); //Black back.GetComponent <Image>().color = backColor; back.GetComponent <Button>().enabled = false; busyo.GetComponent <Image>().color = noBusyoColor; kamon.GetComponent <Image>().color = kamonColor; } } } //Qty float percent = (float)NowQty / (float)AllQty * 100; GameObject.Find("NowQty").GetComponent <Text> ().text = NowQty.ToString(); GameObject.Find("AllQty").GetComponent <Text> ().text = AllQty.ToString() + "(" + percent.ToString("F1") + "%)"; }
public void showSeiryoku() { /*--------------------*/ /*Show Daimyo Seiryoku*/ /*--------------------*/ 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 = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); string kuniPath = "Prefabs/Map/kuni/"; GameObject kuniIconView = GameObject.Find("KuniIconView"); GameObject KuniMap = GameObject.Find("KuniMap"); myDaimyo = PlayerPrefs.GetInt("myDaimyo"); Daimyo daimyo = new Daimyo(); myDaimyoName = daimyo.getName(myDaimyo); 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); } } 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); kuni.GetComponent <Button>().enabled = false; //Seiryoku Handling int daimyoId = int.Parse(seiryokuList [kuniId - 1]); string daimyoName = daimyoMst.param [daimyoId - 1].daimyoName; int daimyoBusyoIdTemp = daimyoMst.param [daimyoId - 1].busyoId; //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); //My daimyo Check if (daimyoId == myDaimyo) { string myDaimyoPath = "Prefabs/Kamon/MyDaimyoKamon/" + myDaimyo.ToString(); kuni.GetComponent <Image> ().sprite = Resources.Load(myDaimyoPath, typeof(Sprite)) as Sprite; } //Clear Flg if (gameClearDaimyoList.Contains(daimyoId.ToString())) { kuni.GetComponent <SendParam> ().clearFlg = true; } } }
public void kessen(GameObject contentObj) { //disable contentObj.transform.FindChild("SobujiKessenBtn").gameObject.SetActive(false); contentObj.transform.FindChild("AtkOrderBtn").gameObject.SetActive(false); contentObj.transform.FindChild("DfcOrderBtn").gameObject.SetActive(false); contentObj.transform.FindChild("RelationshipBtn").gameObject.SetActive(false); Daimyo daimyo = new Daimyo(); string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); 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 }; List <int> openDaimyoList = new List <int>(); string openKuni = PlayerPrefs.GetString("openKuni"); List <string> openKuniList = new List <string>(); if (openKuni != null && openKuni != "") { if (openKuni.Contains(",")) { openKuniList = new List <string>(openKuni.Split(delimiterChars)); } else { openKuniList.Add(openKuni); } } int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); for (int i = 0; i < seiryokuList.Count; i++) { int daimyoId = int.Parse(seiryokuList [i]); kuniQtyByDaimyoId [daimyoId - 1] = kuniQtyByDaimyoId [daimyoId - 1] + 1; int kuniId = i + 1; if (openKuniList.Contains(kuniId.ToString())) { if (!openDaimyoList.Contains(daimyoId)) { openDaimyoList.Add(daimyoId); } } } string kessenBtnPath = "Prefabs/Bakuhu/KessenBtn"; List <int> checkedDaimyoId = new List <int> (); for (int i = 0; i < seiryokuList.Count; i++) { int daimyoId = int.Parse(seiryokuList [i]); if (daimyoId != myDaimyo) { if (!checkedDaimyoId.Contains(daimyoId)) { //Open Kuni if (openDaimyoList.Contains(daimyoId)) { checkedDaimyoId.Add(daimyoId); string daimyoName = daimyo.getName(daimyoId); int busyoId = daimyo.getDaimyoBusyoId(daimyoId); int kuniId = i + 1; GameObject slotObj = Instantiate(Resources.Load(kessenBtnPath)) as GameObject; slotObj.transform.SetParent(contentObj.transform); slotObj.transform.localScale = new Vector2(1, 1); slotObj.name = "KessenBtn"; if (Application.systemLanguage != SystemLanguage.Japanese) { slotObj.transform.FindChild("Title").GetComponent <Text> ().text = daimyoName + "\n Final War"; } else { slotObj.transform.FindChild("Title").GetComponent <Text>().text = daimyoName + "\n決戦"; } string imagePath = "Prefabs/Player/Sprite/unit" + busyoId.ToString(); slotObj.transform.FindChild("Mask").transform.FindChild("Image").GetComponent <Image>().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; slotObj.GetComponent <BakuhuMenu> ().daimyoId = daimyoId; slotObj.GetComponent <BakuhuMenu> ().daimyoName = daimyoName; slotObj.GetComponent <BakuhuMenu> ().kuniId = kuniId; int hyourou = kuniQtyByDaimyoId [daimyoId - 1] * 20; if (hyourou > 80) { hyourou = 80; } slotObj.GetComponent <BakuhuMenu> ().hyourouNo = hyourou; slotObj.transform.FindChild("HyourouIcon").transform.FindChild("HyourouValue").GetComponent <Text> ().text = hyourou.ToString(); } } } } }
public void OnClick(){ if (name != "PassButton") { //Syoukaijyo Confirm Pop //Back string pathOfBack = "Prefabs/Cyoutei/TouchBackLayer"; GameObject back = Instantiate (Resources.Load (pathOfBack)) as GameObject; back.transform.parent = GameObject.Find ("Panel").transform; back.transform.localScale = new Vector2 (1, 1); back.transform.localPosition = new Vector2 (0, 0); //Cyoutei Pop string pathOfPop = "Prefabs/Syounin/SelectSyoukaijyoBoard"; GameObject pop = Instantiate (Resources.Load (pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find ("Panel").transform; pop.transform.localScale = new Vector2 (1, 1); pop.transform.localPosition = new Vector2 (0, 0); pop.name = "SelectSyoukaijyoBoard"; back.GetComponent<CloseLayer> ().closeTargetObj = pop; back.GetComponent<CloseLayer> ().closeTargetBack = back; pop.transform.FindChild ("CloseBtn").GetComponent<CloseLayer> ().closeTargetObj = pop; pop.transform.FindChild ("CloseBtn").GetComponent<CloseLayer> ().closeTargetBack = back; //Check Syoukaijyo string nowQty = PlayerPrefs.GetString ("koueki"); //string nowQty = "0,0,0"; List<string> nowQtyList = new List<string> (); char[] delimiterChars = {','}; nowQtyList = new List<string> (nowQty.Split (delimiterChars)); GameObject scrollView = pop.transform.FindChild ("ScrollView").gameObject; GameObject content = scrollView.transform.FindChild ("Content").gameObject; bool notZeroflg = false; //Jyo if (nowQtyList [2] == "0") { content.transform.FindChild ("Jyo").gameObject.SetActive (false); } else { notZeroflg = true; content.transform.FindChild ("Jyo").transform.FindChild ("syounin").transform.FindChild ("Qty").GetComponent<Text> ().text = nowQtyList [2]; content.transform.FindChild ("Jyo").GetComponent<SyoukaijyoSelect>().OnClick(); } //Cyu if (nowQtyList [1] == "0") { content.transform.FindChild ("Cyu").gameObject.SetActive (false); } else { notZeroflg = true; content.transform.FindChild ("Cyu").transform.FindChild ("syounin").transform.FindChild ("Qty").GetComponent<Text> ().text = nowQtyList [1]; content.transform.FindChild ("Cyu").GetComponent<SyoukaijyoSelect>().OnClick(); } //Ge if (nowQtyList [0] == "0") { content.transform.FindChild ("Ge").gameObject.SetActive (false); } else { notZeroflg = true; content.transform.FindChild ("Ge").transform.FindChild ("syounin").transform.FindChild ("Qty").GetComponent<Text> ().text = nowQtyList [0]; content.transform.FindChild ("Ge").GetComponent<SyoukaijyoSelect>().OnClick(); } if (!notZeroflg) { scrollView.transform.FindChild ("NoSyoukaijyo").GetComponent<Text> ().enabled = true; pop.transform.FindChild ("Serihu").transform.FindChild ("Text").GetComponent<Text> ().text = "商人からの紹介状が無いと商売の紹介は出来ませんな。"; pop.transform.FindChild ("PassButton").gameObject.SetActive (false); } pop.transform.FindChild("PassButton").GetComponent<SyouninPop>().SelectSyoukaijyoBoard = pop; pop.transform.FindChild("PassButton").GetComponent<SyouninPop>().myDaimyoFlg = myDaimyoFlg; pop.transform.FindChild("PassButton").GetComponent<SyouninPop>().occupiedDaimyoName = occupiedDaimyoName; pop.transform.FindChild("PassButton").GetComponent<SyouninPop>().yukoudo = yukoudo; //Icon Change if(sakaiFlg){ string imagePath = "Prefabs/Syounin/Sprite/syounin2"; pop.transform.FindChild("Syounin").GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; pop.transform.FindChild("SyouninName").GetComponent<Text>().text = "千利休"; } } else { //Cyoutei Main Pop int hyourou = PlayerPrefs.GetInt("hyourou"); int newHyourou = hyourou - 5; PlayerPrefs.SetInt("hyourou",newHyourou); GameObject.Find("HyourouCurrentValue").GetComponent<Text>().text = newHyourou.ToString(); //Check Yukoudo int ratio = 100 - yukoudo; if(myDaimyoFlg){ ratio = 0; } float percent = Random.value; percent = percent * 100; if(percent > ratio){ SelectSyoukaijyoBoard.transform.FindChild("CloseBtn").GetComponent<CloseLayer>().OnClick(); string pathOfBack = "Prefabs/Cyoutei/CyouteiBack"; GameObject back = Instantiate (Resources.Load (pathOfBack)) as GameObject; back.transform.parent = GameObject.Find ("Panel").transform; back.transform.localScale = new Vector2 (1, 1); back.transform.localPosition = new Vector2 (0, 0); string pathOfPop = "Prefabs/Syounin/SyouninBoard"; GameObject pop = Instantiate (Resources.Load (pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find ("Panel").transform; pop.transform.localScale = new Vector2 (1, 1); pop.transform.localPosition = new Vector2 (0, 0); pop.name = "SyouninBoard"; CloseLayer CloseLayerScript = pop.transform.FindChild("CloseSyoukaijyo").GetComponent<CloseLayer>(); CloseLayerScript.closeTargetBack = back; CloseLayerScript.closeTargetObj = pop; CloseLayerScript.syoukaijyoRank = syoukaijyoRank; CloseLayerScript.occupiedFlg = myDaimyoFlg; //RandomValue int yukouAddValue = 0; int yukouReducePoint = Random.Range(2, 10); int stopBattleRatio = 0; int stopBattleReducePoint = Random.Range(2, 10); int kanniRatio = 0; int kanniReducePoint = Random.Range(20, 100); int syoukaijyoRankId = 0; //Change Menu by syoukaijyo rank GameObject action = pop.transform.FindChild("Action").gameObject; if(syoukaijyoRank == "Ge"){ if(!myDaimyoFlg){ List<string> btnNameList = new List<string> (){"Yasen","Youjinbou","Cyakai","Gijyutsu"}; enableButton(pop,btnNameList); }else{ List<string> btnNameList = new List<string> (){"Youjinbou","Cyakai","Gijyutsu"}; enableButton(pop,btnNameList); } yukouAddValue = Random.Range(1, 3); stopBattleRatio = Random.Range(10, 30); kanniRatio = Random.Range(20, 60); syoukaijyoRankId = 1; action.transform.FindChild("ActionValue").GetComponent<Text>().text = "1"; action.transform.FindChild("ActionMaxValue").GetComponent<Text>().text = "1"; }else if(syoukaijyoRank == "Cyu"){ if(!myDaimyoFlg){ List<string> btnNameList = new List<string> (){"Yasen","Gijyutsu"}; enableButton(pop,btnNameList); }else{ List<string> btnNameList = new List<string> (){"Gijyutsu"}; enableButton(pop,btnNameList); } yukouAddValue = Random.Range(3, 8); stopBattleRatio = Random.Range(30, 80); kanniRatio = Random.Range(40, 80); syoukaijyoRankId = 2; action.transform.FindChild("ActionValue").GetComponent<Text>().text = "2"; action.transform.FindChild("ActionMaxValue").GetComponent<Text>().text = "2"; }else if(syoukaijyoRank == "Jyo"){ if(!myDaimyoFlg){ List<string> btnNameList = new List<string> (){"Yasen","Gijyutsu"}; enableButton(pop,btnNameList); } yukouAddValue = Random.Range(8, 15); stopBattleRatio = 100; kanniRatio = Random.Range(60, 100); syoukaijyoRankId = 3; action.transform.FindChild("ActionValue").GetComponent<Text>().text = "3"; action.transform.FindChild("ActionMaxValue").GetComponent<Text>().text = "3"; } //TargetKahou Preparation Kahou kahou = new Kahou(); string kahouCdString = ""; string kahouIdString = ""; for(int i=1; i<4; i++){ List<string> kahouRandom = new List<string> (){"bugu","kabuto","gusoku","meiba","cyadougu","chishikisyo","heihousyo"}; int rdm = UnityEngine.Random.Range(0,7); string kahouType = kahouRandom[rdm]; string kahouRank = getItemRank(syoukaijyoRankId); int kahouId = kahou.getRamdomKahouId(kahouType, kahouRank); //string targetKahou = kahouType + kahouId.ToString(); if(kahouCdString != null && kahouCdString !=""){ kahouCdString = kahouCdString + "," + kahouType; kahouIdString = kahouIdString + "," + kahouId.ToString(); }else{ kahouCdString = kahouType; kahouIdString = kahouId.ToString(); } } CloseLayerScript.kahouCdString = kahouCdString; CloseLayerScript.kahouIdString = kahouIdString; //TargetBusshi Preparation string busshiQtyString = ""; //Qty of busshi string busshiRankString = ""; //Rank of busshi for(int l=1; l<6; l++){ int rdmQty = UnityEngine.Random.Range(1,10); int rdmRnk = UnityEngine.Random.Range(1,4); if(busshiQtyString != null && busshiQtyString !=""){ busshiQtyString = busshiQtyString + "," + rdmQty.ToString(); busshiRankString = busshiRankString + "," + rdmRnk.ToString(); }else{ busshiQtyString = rdmQty.ToString(); busshiRankString = rdmRnk.ToString(); } } CloseLayerScript.busshiQtyString = busshiQtyString; CloseLayerScript.busshiRankString = busshiRankString; //TargetYoujinbou int rdmKengouId = UnityEngine.Random.Range(1,10); CloseLayerScript.rdmKengouId = rdmKengouId; //Yasengaku int yasenAmt = 0; if(syoukaijyoRankId==1){ yasenAmt = UnityEngine.Random.Range(1000,3000); }else if(syoukaijyoRankId==2){ yasenAmt = UnityEngine.Random.Range(2000,5000); }else if(syoukaijyoRankId==3){ yasenAmt = UnityEngine.Random.Range(3000,10000); } CloseLayerScript.yasenAmt = yasenAmt; //Gijyutsuiten int techId = UnityEngine.Random.Range(1,4); CloseLayerScript.techId = techId; //Discount Percent float discount = UnityEngine.Random.Range(0.5f,0.9f); CloseLayerScript.discount = discount; Daimyo daimyo = new Daimyo(); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); //Serihu string daimyoName = daimyo.getName(myDaimyo); string serihu = "これは" + daimyoName + "様。\t私共めに何用で御座いましょうか。" ; pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent<Text>().text = serihu; }else{ Message msg = new Message(); msg.makeMessage("御屋形様、"+occupiedDaimyoName+"めに取引を邪魔されました。"); } } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); Message msg = new Message(); if (name != "PassButton") { //Syoukaijyo Confirm Pop audioSources [0].Play(); //Back string pathOfBack = "Prefabs/Cyoutei/TouchBackLayer"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); //Cyoutei Pop string pathOfPop = "Prefabs/Syounin/SelectSyoukaijyoBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "SelectSyoukaijyoBoard"; back.GetComponent <CloseLayer> ().closeTargetObj = pop; back.GetComponent <CloseLayer> ().closeTargetBack = back; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetObj = pop; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetBack = back; //Check Syoukaijyo string nowQty = PlayerPrefs.GetString("koueki"); //string nowQty = "0,0,0"; List <string> nowQtyList = new List <string> (); char[] delimiterChars = { ',' }; nowQtyList = new List <string> (nowQty.Split(delimiterChars)); GameObject scrollView = pop.transform.FindChild("ScrollView").gameObject; GameObject content = scrollView.transform.FindChild("Content").gameObject; bool notZeroflg = false; //Jyo if (nowQtyList [2] == "0") { content.transform.FindChild("Jyo").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Jyo").transform.FindChild("syounin").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [2]; content.transform.FindChild("Jyo").GetComponent <SyoukaijyoSelect> ().OnClick(); } //Cyu if (nowQtyList [1] == "0") { content.transform.FindChild("Cyu").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Cyu").transform.FindChild("syounin").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [1]; content.transform.FindChild("Cyu").GetComponent <SyoukaijyoSelect> ().OnClick(); } //Ge if (nowQtyList [0] == "0") { content.transform.FindChild("Ge").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Ge").transform.FindChild("syounin").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [0]; content.transform.FindChild("Ge").GetComponent <SyoukaijyoSelect> ().OnClick(); } if (!notZeroflg) { scrollView.transform.FindChild("NoSyoukaijyo").GetComponent <Text> ().enabled = true; pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = msg.getMessage(41); pop.transform.FindChild("PassButton").gameObject.SetActive(false); } pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().SelectSyoukaijyoBoard = pop; pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().myDaimyoFlg = myDaimyoFlg; pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().occupiedDaimyoName = occupiedDaimyoName; pop.transform.FindChild("PassButton").GetComponent <SyouninPop> ().yukoudo = yukoudo; //Icon Change if (sakaiFlg) { string imagePath = "Prefabs/Syounin/Sprite/syounin2"; pop.transform.FindChild("Syounin").GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; if (Application.systemLanguage != SystemLanguage.Japanese) { pop.transform.FindChild("SyouninName").GetComponent <Text>().text = "Rikyu Sen"; } else { pop.transform.FindChild("SyouninName").GetComponent <Text> ().text = "千利休"; } } else { if (Application.systemLanguage != SystemLanguage.Japanese) { pop.transform.FindChild("SyouninName").GetComponent <Text>().text = "Sotan Kamiya"; } } } else { //Cyoutei Main Pop int hyourou = PlayerPrefs.GetInt("hyourou"); if (hyourou >= 5) { int newHyourou = hyourou - 5; PlayerPrefs.SetInt("hyourou", newHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString(); //Check Yukoudo int ratio = 100 - yukoudo; if (myDaimyoFlg) { ratio = 0; } float percent = Random.value; percent = percent * 100; if (percent > ratio) { //Stop Timer CyouteiPop cyouteiPop = new CyouteiPop(); cyouteiPop.stopGunzei(); GameObject.Find("GameController").GetComponent <MainStageController>().eventStopFlg = true; audioSources [3].Play(); SelectSyoukaijyoBoard.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().OnClick(); string pathOfBack = "Prefabs/Cyoutei/CyouteiBack"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); string pathOfPop = "Prefabs/Syounin/SyouninBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "SyouninBoard"; CloseLayer CloseLayerScript = pop.transform.FindChild("CloseSyoukaijyo").GetComponent <CloseLayer> (); CloseLayerScript.closeTargetBack = back; CloseLayerScript.closeTargetObj = pop; CloseLayerScript.syoukaijyoRank = syoukaijyoRank; CloseLayerScript.occupiedFlg = myDaimyoFlg; CloseLayerScript.syouninCyouteiFlg = true; //RandomValue int yukouAddValue = 0; int yukouReducePoint = Random.Range(2, 10); int stopBattleRatio = 0; int stopBattleReducePoint = Random.Range(2, 10); int kanniRatio = 0; int kanniReducePoint = Random.Range(20, 100); int syoukaijyoRankId = 0; //Change Menu by syoukaijyo rank GameObject action = pop.transform.FindChild("Action").gameObject; if (syoukaijyoRank == "Ge") { if (!myDaimyoFlg) { List <string> btnNameList = new List <string> () { "Yasen", "Youjinbou", "Cyakai", "Gijyutsu" }; enableButton(pop, btnNameList); } else { List <string> btnNameList = new List <string> () { "Youjinbou", "Cyakai", "Gijyutsu" }; enableButton(pop, btnNameList); } yukouAddValue = Random.Range(1, 3); stopBattleRatio = Random.Range(10, 30); kanniRatio = Random.Range(20, 60); syoukaijyoRankId = 1; action.transform.FindChild("ActionValue").GetComponent <Text> ().text = "1"; action.transform.FindChild("ActionMaxValue").GetComponent <Text> ().text = "1"; } else if (syoukaijyoRank == "Cyu") { if (!myDaimyoFlg) { List <string> btnNameList = new List <string> () { "Yasen", "Gijyutsu" }; enableButton(pop, btnNameList); } else { List <string> btnNameList = new List <string> () { "Gijyutsu" }; enableButton(pop, btnNameList); } yukouAddValue = Random.Range(3, 8); stopBattleRatio = Random.Range(30, 80); kanniRatio = Random.Range(40, 80); syoukaijyoRankId = 2; action.transform.FindChild("ActionValue").GetComponent <Text> ().text = "2"; action.transform.FindChild("ActionMaxValue").GetComponent <Text> ().text = "2"; } else if (syoukaijyoRank == "Jyo") { if (!myDaimyoFlg) { List <string> btnNameList = new List <string> () { "Yasen", "Gijyutsu" }; enableButton(pop, btnNameList); } yukouAddValue = Random.Range(8, 15); stopBattleRatio = 100; kanniRatio = Random.Range(60, 100); syoukaijyoRankId = 3; action.transform.FindChild("ActionValue").GetComponent <Text> ().text = "3"; action.transform.FindChild("ActionMaxValue").GetComponent <Text> ().text = "3"; } //reduce cyoutei syoukaijyo DoSell script = new DoSell(); script.deleteKouekiOrCyoutei(syoukaijyoRankId, "koueki", 1); //TargetKahou Preparation Kahou kahou = new Kahou(); string kahouCdString = ""; string kahouIdString = ""; for (int i = 1; i < 4; i++) { List <string> kahouRandom = new List <string> () { "bugu", "kabuto", "gusoku", "meiba", "cyadougu", "chishikisyo", "heihousyo" }; int rdm = UnityEngine.Random.Range(0, 7); string kahouType = kahouRandom [rdm]; string kahouRank = getItemRank(syoukaijyoRankId); int kahouId = kahou.getRamdomKahouId(kahouType, kahouRank); //string targetKahou = kahouType + kahouId.ToString(); if (kahouCdString != null && kahouCdString != "") { kahouCdString = kahouCdString + "," + kahouType; kahouIdString = kahouIdString + "," + kahouId.ToString(); } else { kahouCdString = kahouType; kahouIdString = kahouId.ToString(); } } CloseLayerScript.kahouCdString = kahouCdString; CloseLayerScript.kahouIdString = kahouIdString; //TargetBusshi Preparation string busshiQtyString = ""; //Qty of busshi string busshiRankString = ""; //Rank of busshi for (int l = 1; l < 6; l++) { int rdmQty = UnityEngine.Random.Range(1, 10); int rdmRnk = UnityEngine.Random.Range(1, 4); if (busshiQtyString != null && busshiQtyString != "") { busshiQtyString = busshiQtyString + "," + rdmQty.ToString(); busshiRankString = busshiRankString + "," + rdmRnk.ToString(); } else { busshiQtyString = rdmQty.ToString(); busshiRankString = rdmRnk.ToString(); } } CloseLayerScript.busshiQtyString = busshiQtyString; CloseLayerScript.busshiRankString = busshiRankString; //TargetYoujinbou int rdmKengouId = UnityEngine.Random.Range(1, 10); CloseLayerScript.rdmKengouId = rdmKengouId; //Yasengaku int yasenAmt = 0; if (syoukaijyoRankId == 1) { yasenAmt = UnityEngine.Random.Range(1000, 3000); } else if (syoukaijyoRankId == 2) { yasenAmt = UnityEngine.Random.Range(2000, 5000); } else if (syoukaijyoRankId == 3) { yasenAmt = UnityEngine.Random.Range(3000, 10000); } CloseLayerScript.yasenAmt = yasenAmt; //Gijyutsuiten int techId = UnityEngine.Random.Range(1, 4); CloseLayerScript.techId = techId; //Discount Percent float discount = UnityEngine.Random.Range(0.5f, 0.9f); CloseLayerScript.discount = discount; Daimyo daimyo = new Daimyo(); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); //Serihu string daimyoName = daimyo.getName(myDaimyo); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Oh, lord " + daimyoName + ".\nCan I help you?"; } else { serihu = "これは" + daimyoName + "様。\n私共めに何用で御座いましょうか。"; } pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = serihu; PlayerPrefs.SetBool("questSpecialFlg4", true); PlayerPrefs.Flush(); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); } else { audioSources [4].Play(); if (Application.systemLanguage != SystemLanguage.Japanese) { msg.makeMessage("My lord " + occupiedDaimyoName + " disturbed our business."); } else { msg.makeMessage("御屋形様、" + occupiedDaimyoName + "めに\n取引を邪魔されました。"); } } } else { audioSources [4].Play(); //msg.makeMessage (msg.getMessage(7)); msg.hyourouMovieMessage(); } } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); //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(){ CloseBoard close = GameObject.Find ("close").GetComponent<CloseBoard> (); close.layer = close.layer + 1; int nowHyourou = PlayerPrefs.GetInt ("hyourou"); bool hyourouOKflg = false; //Kuni Qty Difference int myKuniQty = GameObject.Find ("GameController").GetComponent<MainStageController> ().myKuniQty; int tKuniQty = close.kuniQty; if (myKuniQty > tKuniQty) { kuniDiff = kuniDiff + myKuniQty - tKuniQty; } if (name == "Mitsugi") { //Menu Handling GameObject.Find ("kuniName").GetComponent<Text> ().text = "貢物"; OffGaikouMenu (); //Mitsugi Object string mitugiPath = "Prefabs/Map/gaikou/MitsugiObj"; GameObject mitsugiObj = Instantiate (Resources.Load (mitugiPath)) as GameObject; mitsugiObj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); mitsugiObj.transform.localScale = new Vector3 (1, 1, 1); //Do Button string buttonPath = "Prefabs/Map/gaikou/DoGaikouBtn"; GameObject btn = Instantiate (Resources.Load (buttonPath)) as GameObject; btn.transform.SetParent (mitsugiObj.transform); btn.transform.localScale = new Vector3 (1, 1, 1); btn.name = "DoMitsugiBtn"; RectTransform btn_transform = btn.GetComponent<RectTransform> (); btn_transform.anchoredPosition = new Vector3 (0, -200, 0); //Slider string sliderPath = "Prefabs/Map/common/MoneySlider"; GameObject slider = Instantiate (Resources.Load (sliderPath)) as GameObject; slider.transform.SetParent (mitsugiObj.transform); slider.transform.localScale = new Vector3 (1, 1.2f, 1); RectTransform slider_transform = slider.GetComponent<RectTransform> (); slider_transform.anchoredPosition = new Vector3 (-70, -90, 0); Slider sliderScript = slider.GetComponent<Slider> (); int nowMoney = PlayerPrefs.GetInt ("money"); nowMoney = nowMoney / 1000; if (nowMoney < 1) { sliderScript.enabled = false; } else { sliderScript.minValue = 1; btn.GetComponent<DoGaikou> ().moneyOKflg = true; btn.GetComponent<DoGaikou> ().paiedMoney = 1000; if (nowMoney < 10) { sliderScript.maxValue = nowMoney; } else { sliderScript.maxValue = 10; } } slider.GetComponent<MoneySlider> ().doBtn = btn; //Hyourou Check GaikouMenu gaikou = new GaikouMenu (); hyourouOKflg = gaikou.HyourouCheck (nowHyourou); btn.GetComponent<DoGaikou> ().hyourouOKflg = hyourouOKflg; //Busyo Scroll View gaikou.ScrollView (mitsugiObj, btn); //Set Obj GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = mitsugiObj; } else if (name == "Kyoutou") { //Menu Handling GameObject.Find ("kuniName").GetComponent<Text> ().text = "共闘"; OffGaikouMenu (); string path = "Prefabs/Map/gaikou/KyoutouObj"; GameObject obj = Instantiate (Resources.Load (path)) as GameObject; obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3 (1, 1, 1); //Do Button string buttonPath = "Prefabs/Map/gaikou/DoGaikouBtn"; GameObject btn = Instantiate (Resources.Load (buttonPath)) as GameObject; btn.transform.SetParent (obj.transform); btn.transform.localScale = new Vector3 (1, 1, 1); btn.name = "DoKyoutouBtn"; RectTransform btn_transform = btn.GetComponent<RectTransform> (); btn_transform.anchoredPosition = new Vector3 (0, -200, 0); btn.transform.FindChild ("Text").GetComponent<Text> ().text = "共闘"; //Money int nowMoney = PlayerPrefs.GetInt ("money"); if (nowMoney >= 3000) { btn.GetComponent<DoGaikou> ().moneyOKflg = true; } btn.GetComponent<DoGaikou> ().paiedMoney = 3000; //Hyourou Check GaikouMenu gaikou = new GaikouMenu (); hyourouOKflg = gaikou.HyourouCheck (nowHyourou); btn.GetComponent<DoGaikou> ().hyourouOKflg = hyourouOKflg; int daimyoId = GameObject.Find ("close").GetComponent<CloseBoard> ().daimyoId; kuniScrollView (obj, daimyoId.ToString (), btn); //Set Obj GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj; } else if (name == "Haki") { //Back Cover 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.anchoredPosition = new Vector3 (0, 0, 0); //Message Box string msgPath = "Prefabs/Map/gaikou/DoumeiHakiConfirm"; GameObject msg = Instantiate (Resources.Load (msgPath)) as GameObject; msg.transform.SetParent (GameObject.Find ("Panel").transform); msg.transform.localScale = new Vector2 (1, 1); RectTransform msgTransform = msg.GetComponent<RectTransform> (); msgTransform.anchoredPosition = new Vector3 (0, 0, 0); msgTransform.name = "DoumeiHakiConfirm"; int daimyoId = GameObject.Find ("close").GetComponent<CloseBoard> ().daimyoId; msg.transform.FindChild ("YesButton").GetComponent<DoDoumeiHaki> ().daimyoId = daimyoId; Daimyo daimyo = new Daimyo (); string daimyoName = daimyo.getName (daimyoId); msg.transform.FindChild ("YesButton").GetComponent<DoDoumeiHaki> ().daimyoName = daimyoName; close.layer = close.layer - 1; } else if (name == "Koueki") { int yukoudo = close.yukoudo; string myDaimyoName = GameObject.Find("DaimyoValue").GetComponent<Text>().text; if(yukoudo>=20){ GameObject.Find ("kuniName").GetComponent<Text> ().text = "交易"; OffGaikouMenu (); string kouekiPath = "Prefabs/Map/gaikou/kouekiObj"; GameObject kouekiObj = Instantiate (Resources.Load (kouekiPath)) as GameObject; kouekiObj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); kouekiObj.transform.localScale = new Vector3 (1, 1, 1); kouekiObj.transform.FindChild("Buy").GetComponent<KouekiMenu>().kouekiObj = kouekiObj; kouekiObj.transform.FindChild("Change").GetComponent<KouekiMenu>().kouekiObj = kouekiObj; kouekiObj.transform.FindChild("Buy").GetComponent<KouekiMenu>().clickBuy(); GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = kouekiObj; //Daimyo Change GameObject daimyo = kouekiObj.transform.FindChild("Daimyo").gameObject; foreach(Transform obj in daimyo.transform){ Destroy(obj); } //SerihuChange if(20<=yukoudo && yukoudo<30)GameObject.Find("SerihuText").GetComponent<Text>().text = myDaimyoName + "か・・・何用で参ったのかな。"; if(30<=yukoudo && yukoudo<40)GameObject.Find("SerihuText").GetComponent<Text>().text = "お久しゅうござるな。近頃は交易品が値上げしておりましてのう。"; if(40<=yukoudo && yukoudo<50)GameObject.Find("SerihuText").GetComponent<Text>().text = "お久しゅうござるな。交易品を見ていって下され。"; if(50<=yukoudo && yukoudo<60)GameObject.Find("SerihuText").GetComponent<Text>().text = "条件次第で交易致しますぞ。さ、交易品を見ていって下され。"; if(60<=yukoudo && yukoudo<70)GameObject.Find("SerihuText").GetComponent<Text>().text = myDaimyoName + "殿、この品は如何かな。珍しいものでござろう。"; if(70<=yukoudo && yukoudo<80)GameObject.Find("SerihuText").GetComponent<Text>().text = myDaimyoName + "殿、ご活躍は噂で聞いておりますぞ。是非品を行ってくだされ。"; if(80<=yukoudo && yukoudo<90)GameObject.Find("SerihuText").GetComponent<Text>().text = myDaimyoName + "殿、丁度話がしたいと思うておったところよ。ゆるりとして行ってくだされ。"; if(90<=yukoudo && yukoudo<100)GameObject.Find("SerihuText").GetComponent<Text>().text = "おお、" + myDaimyoName + "殿では御座らんか!是非見て参られよ。\n素晴らしい品が入ったのじゃ。"; int daimyoBusyoId = close.daimyoBusyoId; string busyoPath = "Prefabs/Player/Unit/" + daimyoBusyoId; GameObject busyo = Instantiate (Resources.Load (busyoPath)) as GameObject; busyo.transform.SetParent (daimyo.transform); busyo.transform.localScale = new Vector2 (4, 4); busyo.GetComponent<DragHandler> ().enabled = false; RectTransform busyoTransform = busyo.GetComponent<RectTransform> (); busyoTransform.anchoredPosition = new Vector3 (70, 80, 0); busyoTransform.sizeDelta = new Vector2 (35, 40); }else{ Message msg = new Message(); msg.makeMessage("にべも無く交易を断られましたぞ。\n友好関係を改善しましょう。"); } } }
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); }
public void OnClick() { /*Receive Item*/ AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [3].Play(); //Item1 string gameClearDaimyo = PlayerPrefs.GetString("gameClearDaimyo"); bool hardFlg = PlayerPrefs.GetBool("hardFlg"); List <string> gameClearDaimyoList = new List <string> (); char[] delimiterChars = { ',' }; if (gameClearDaimyo != null && gameClearDaimyo != "") { if (gameClearDaimyo.Contains(",")) { gameClearDaimyoList = new List <string> (gameClearDaimyo.Split(delimiterChars)); } else { gameClearDaimyoList.Add(gameClearDaimyo); } } int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); if (!gameClearDaimyoList.Contains(myDaimyo.ToString())) { if (gameClearDaimyo != null && gameClearDaimyo != "") { gameClearDaimyo = gameClearDaimyo + "," + myDaimyo.ToString(); } else { gameClearDaimyo = myDaimyo.ToString(); } PlayerPrefs.SetString("gameClearDaimyo", gameClearDaimyo); } //Hard mode if (hardFlg) { string gameClearDaimyoHard = PlayerPrefs.GetString("gameClearDaimyoHard"); List <string> gameClearDaimyoHardList = new List <string>(); if (gameClearDaimyoHard != null && gameClearDaimyoHard != "") { if (gameClearDaimyoHard.Contains(",")) { gameClearDaimyoHardList = new List <string>(gameClearDaimyoHard.Split(delimiterChars)); } else { gameClearDaimyoHardList.Add(gameClearDaimyoHard); } } if (!gameClearDaimyoHardList.Contains(myDaimyo.ToString())) { if (gameClearDaimyoHard != null && gameClearDaimyoHard != "") { gameClearDaimyoHard = gameClearDaimyoHard + "," + myDaimyo.ToString(); } else { gameClearDaimyoHard = myDaimyo.ToString(); } PlayerPrefs.SetString("gameClearDaimyoHard", gameClearDaimyoHard); } } PlayerPrefs.SetBool("gameClearItemGetFlg", true); //Item2 PlayerPrefs.DeleteKey("gameClearKahouCd"); PlayerPrefs.DeleteKey("gameClearKahouId"); Kahou kahou = new Kahou(); if (kahouCd == "bugu") { kahou.registerBugu(int.Parse(kahouId)); } else if (kahouCd == "gusoku") { kahou.registerGusoku(int.Parse(kahouId)); } else if (kahouCd == "kabuto") { kahou.registerKabuto(int.Parse(kahouId)); } else if (kahouCd == "meiba") { kahou.registerMeiba(int.Parse(kahouId)); } else if (kahouCd == "cyadougu") { kahou.registerCyadougu(int.Parse(kahouId)); } else if (kahouCd == "chishikisyo") { kahou.registerChishikisyo(int.Parse(kahouId)); } else if (kahouCd == "heihousyo") { kahou.registerHeihousyo(int.Parse(kahouId)); } //Item3 int busyoDama = PlayerPrefs.GetInt("busyoDama"); int newBusyoDama = busyoDama + 1000; PlayerPrefs.SetInt("busyoDama", newBusyoDama); //Get Daimyo Busyo Daimyo daimyoScript = new Daimyo(); int daimyoId = PlayerPrefs.GetInt("myDaimyo"); int daimyoBusyoId = daimyoScript.getDaimyoBusyoId(daimyoId); string zukanBusyoHst = PlayerPrefs.GetString("zukanBusyoHst"); List <string> zukanBusyoHstList = new List <string>(); if (zukanBusyoHst != null && zukanBusyoHst != "") { if (zukanBusyoHst.Contains(",")) { zukanBusyoHstList = new List <string>(zukanBusyoHst.Split(delimiterChars)); } else { zukanBusyoHstList.Add(zukanBusyoHst); } } if (!zukanBusyoHstList.Contains(daimyoBusyoId.ToString())) { if (zukanBusyoHst != null && zukanBusyoHst != "") { zukanBusyoHst = zukanBusyoHst + "," + daimyoBusyoId.ToString(); } else { zukanBusyoHst = daimyoBusyoId.ToString(); } PlayerPrefs.SetString("zukanBusyoHst", zukanBusyoHst); } if (daimyoScript.daimyoBusyoCheck(daimyoBusyoId)) { string gacyaDaimyoHst = PlayerPrefs.GetString("gacyaDaimyoHst"); List <string> gacyaDaimyoHstList = new List <string>(); if (gacyaDaimyoHst != null && gacyaDaimyoHst != "") { if (gacyaDaimyoHst.Contains(",")) { gacyaDaimyoHstList = new List <string>(gacyaDaimyoHst.Split(delimiterChars)); } else { gacyaDaimyoHstList.Add(gacyaDaimyoHst); } } if (!gacyaDaimyoHstList.Contains(daimyoBusyoId.ToString())) { if (gacyaDaimyoHst != null && gacyaDaimyoHst != "") { gacyaDaimyoHst = gacyaDaimyoHst + "," + daimyoBusyoId.ToString(); } else { gacyaDaimyoHst = daimyoBusyoId.ToString(); } PlayerPrefs.SetString("gacyaDaimyoHst", gacyaDaimyoHst); } } PlayerPrefs.Flush(); //Hide Back Destroy(backObj.gameObject); Destroy(popObj.gameObject); Destroy(particleObj.gameObject); GameObject kunimap = GameObject.Find("KuniMap").gameObject; GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject; Destroy(kunimap.gameObject); Destroy(kuniIconView.gameObject); FinMaker(panel); }
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 FinMaker(GameObject panel){ string finPath = "Prefabs/clearOrGameOver/Fin"; GameObject finObj = Instantiate(Resources.Load (finPath)) as GameObject; finObj.transform.SetParent(panel.transform); finObj.transform.localScale = new Vector2(1,1); finObj.transform.FindChild ("ReStartBtn").GetComponent<ShowDaimyoSelect> ().fin = finObj; finObj.transform.FindChild ("ReStartBtn").GetComponent<ShowDaimyoSelect> ().panel = panel; int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); Daimyo daimyo = new Daimyo (); int busyoId = daimyo.getDaimyoBusyoId (myDaimyo); string path = "Prefabs/Player/" + busyoId; GameObject prefab = Instantiate(Resources.Load (path)) as GameObject; prefab.transform.SetParent (finObj.transform); prefab.transform.localScale = new Vector2 (50, 60); prefab.transform.localPosition = new Vector2 (-170, 250); if (prefab.GetComponent<Homing> () != null) { prefab.GetComponent<Homing> ().enabled = false; } else { prefab.GetComponent<HomingLong> ().enabled = false; } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); Message msg = new Message(); if (name != "PassButton") { //Syoukaijyo Confirm Pop audioSources [0].Play(); //Back string pathOfBack = "Prefabs/Cyoutei/TouchBackLayer"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); //Cyoutei Pop string pathOfPop = "Prefabs/Cyoutei/SelectSyoukaijyoBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "SelectSyoukaijyoBoard"; back.GetComponent <CloseLayer> ().closeTargetObj = pop; back.GetComponent <CloseLayer> ().closeTargetBack = back; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetObj = pop; pop.transform.FindChild("CloseBtn").GetComponent <CloseLayer> ().closeTargetBack = back; //Check Syoukaijyo string nowQty = PlayerPrefs.GetString("cyoutei"); //string nowQty = "0,0,0"; List <string> nowQtyList = new List <string> (); char[] delimiterChars = { ',' }; nowQtyList = new List <string> (nowQty.Split(delimiterChars)); GameObject scrollView = pop.transform.FindChild("ScrollView").gameObject; GameObject content = scrollView.transform.FindChild("Content").gameObject; bool notZeroflg = false; //Jyo if (nowQtyList [2] == "0") { content.transform.FindChild("Jyo").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Jyo").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [2]; content.transform.FindChild("Jyo").GetComponent <SyoukaijyoSelect>().OnClick(); } //Cyu if (nowQtyList [1] == "0") { content.transform.FindChild("Cyu").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Cyu").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [1]; content.transform.FindChild("Cyu").GetComponent <SyoukaijyoSelect>().OnClick(); } //Ge if (nowQtyList [0] == "0") { content.transform.FindChild("Ge").gameObject.SetActive(false); } else { notZeroflg = true; content.transform.FindChild("Ge").transform.FindChild("cyoutei").transform.FindChild("Qty").GetComponent <Text> ().text = nowQtyList [0]; content.transform.FindChild("Ge").GetComponent <SyoukaijyoSelect>().OnClick(); } if (!notZeroflg) { scrollView.transform.FindChild("NoSyoukaijyo").GetComponent <Text> ().enabled = true; pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text> ().text = msg.getMessage(16); pop.transform.FindChild("PassButton").gameObject.SetActive(false); } pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().SelectSyoukaijyoBoard = pop; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().myDaimyoFlg = myDaimyoFlg; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().occupiedDaimyoId = occupiedDaimyoId; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().occupiedDaimyoName = occupiedDaimyoName; pop.transform.FindChild("PassButton").GetComponent <CyouteiPop>().yukoudo = yukoudo; } else { //Cyoutei Main Pop int hyourou = PlayerPrefs.GetInt("hyourou"); if (hyourou >= 5) { int newHyourou = hyourou - 5; PlayerPrefs.SetInt("hyourou", newHyourou); GameObject.Find("HyourouCurrentValue").GetComponent <Text>().text = newHyourou.ToString(); //Check Yukoudo int ratio = 100 - yukoudo; if (myDaimyoFlg) { ratio = 0; } float percent = Random.value; percent = percent * 100; if (percent > ratio) { //Stop Timer stopGunzei(); GameObject.Find("GameController").GetComponent <MainStageController>().eventStopFlg = true; audioSources [3].Play(); SelectSyoukaijyoBoard.transform.FindChild("CloseBtn").GetComponent <CloseLayer>().OnClick(); string pathOfBack = "Prefabs/Cyoutei/CyouteiBack"; GameObject back = Instantiate(Resources.Load(pathOfBack)) as GameObject; back.transform.parent = GameObject.Find("Panel").transform; back.transform.localScale = new Vector2(1, 1); back.transform.localPosition = new Vector2(0, 0); string pathOfPop = "Prefabs/Cyoutei/CyouteiBoard"; GameObject pop = Instantiate(Resources.Load(pathOfPop)) as GameObject; pop.transform.parent = GameObject.Find("Panel").transform; pop.transform.localScale = new Vector2(1, 1); pop.transform.localPosition = new Vector2(0, 0); pop.name = "CyouteiBoard"; CloseLayer CloseLayerScript = pop.transform.FindChild("CloseSyoukaijyo").GetComponent <CloseLayer>(); CloseLayerScript.closeTargetBack = back; CloseLayerScript.closeTargetObj = pop; CloseLayerScript.syoukaijyoRank = syoukaijyoRank; CloseLayerScript.occupiedFlg = myDaimyoFlg; CloseLayerScript.syouninCyouteiFlg = true; //RandomValue int yukouAddValue = 0; int yukouReducePoint = Random.Range(2, 10); int stopBattleRatio = 0; int stopBattleReducePoint = Random.Range(2, 10); int kanniRatio = 0; int kanniReducePoint = Random.Range(20, 100); int syoukaijyoRankId = 0; int cyoutekiReducePoint = Random.Range(80, 100); //Change Menu by syoukaijyo rank GameObject action = pop.transform.FindChild("Action").gameObject; if (syoukaijyoRank == "Ge") { List <string> btnNameList = new List <string> () { "Bakuhu", "Cyouteki" }; enableButton(pop, btnNameList); yukouAddValue = Random.Range(1, 3); stopBattleRatio = Random.Range(10, 30); kanniRatio = Random.Range(20, 60); syoukaijyoRankId = 1; action.transform.FindChild("ActionValue").GetComponent <Text>().text = "1"; action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "1"; } else if (syoukaijyoRank == "Cyu") { List <string> btnNameList = new List <string> () { "Bakuhu", "Cyouteki" }; enableButton(pop, btnNameList); yukouAddValue = Random.Range(3, 8); stopBattleRatio = Random.Range(30, 80); kanniRatio = Random.Range(40, 80); syoukaijyoRankId = 2; action.transform.FindChild("ActionValue").GetComponent <Text>().text = "2"; action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "2"; } else if (syoukaijyoRank == "Jyo") { yukouAddValue = Random.Range(8, 15); stopBattleRatio = 100; kanniRatio = Random.Range(60, 100); syoukaijyoRankId = 3; action.transform.FindChild("ActionValue").GetComponent <Text>().text = "3"; action.transform.FindChild("ActionMaxValue").GetComponent <Text>().text = "3"; } //TargetKanni Kanni kanni = new Kanni(); int kuniQty = GameObject.Find("GameController").GetComponent <MainStageController>().myKuniQty; int kanniId = kanni.getRandomKanni(syoukaijyoRankId, kuniQty); //TargetCyouteki string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); string openKuni = PlayerPrefs.GetString("openKuni"); List <string> openKuniList = new List <string> (); openKuniList = new List <string> (openKuni.Split(delimiterChars)); int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); int cyoutekiDaimyoId = CloseLayerScript.cyoutekiDaimyo; //openKuniList.RemoveAll (x => x == occupiedDaimyoId.ToString()); //my kuni List <string> myKuniList = new List <string>(); List <string> occupiedDaimyoKuniList = new List <string>(); for (int i = 0; i < seiryokuList.Count; i++) { int tmpDaimyoId = int.Parse(seiryokuList [i]); if (tmpDaimyoId == myDaimyo) { int kuniId = i + 1; myKuniList.Add(kuniId.ToString()); } else if (tmpDaimyoId == occupiedDaimyoId) { int kuniId = i + 1; occupiedDaimyoKuniList.Add(kuniId.ToString()); } } openKuniList.RemoveAll(myKuniList.Contains); openKuniList.RemoveAll(occupiedDaimyoKuniList.Contains); int rdmId = UnityEngine.Random.Range(0, openKuniList.Count); int targetKuniId = int.Parse(openKuniList[rdmId]); int cyoutekiDaimyo = int.Parse(seiryokuList[targetKuniId - 1]); //reduce cyoutei syoukaijyo DoSell script = new DoSell(); script.deleteKouekiOrCyoutei(syoukaijyoRankId, "cyoutei", 1); //Set Parametor CloseLayerScript.yukouAddValue = yukouAddValue; CloseLayerScript.yukouReducePoint = yukouReducePoint; CloseLayerScript.stopBattleRatio = stopBattleRatio; CloseLayerScript.stopBattleReducePoint = stopBattleReducePoint; CloseLayerScript.kanniId = kanniId; if (kanniId != 0) { CloseLayerScript.kanniName = kanni.getKanniName(kanniId); CloseLayerScript.kanniRatio = kanniRatio; CloseLayerScript.kanniReducePoint = kanniReducePoint; } CloseLayerScript.cyoutekiDaimyo = cyoutekiDaimyo; CloseLayerScript.cyoutekiReducePoint = cyoutekiReducePoint; //Cyoutei Point int cyouteiPoint = PlayerPrefs.GetInt("cyouteiPoint"); pop.transform.FindChild("CyouteiPoint").transform.FindChild("CyouteiValue").GetComponent <Text>().text = cyouteiPoint.ToString() + "%"; bool doneFirstCyouteiFlg = PlayerPrefs.GetBool("doneFirstCyouteiFlg"); Daimyo daimyo = new Daimyo(); if (!doneFirstCyouteiFlg) { //1st time PlayerPrefs.SetBool("questSpecialFlg5", true); PlayerPrefs.SetBool("doneFirstCyouteiFlg", true); KuniInfo kuni = new KuniInfo(); int kuniId = kuni.getOneKuniId(myDaimyo); int firstKanniId = kanni.getKuniKanni(kuniId); string firstKanniName = kanni.getKanniName(firstKanniId); string myKanni = PlayerPrefs.GetString("myKanni"); if (myKanni != null && myKanni != "") { myKanni = myKanni + "," + firstKanniId.ToString(); } else { myKanni = firstKanniId.ToString(); } PlayerPrefs.SetString("myKanni", myKanni); PlayerPrefs.Flush(); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Your good rumor has arrived to the Imperial court. Please lend me your power for the world.\n I assigned you as " + firstKanniName + "."; } else { serihu = "天下静謐のため力を貸してくれ。\n" + firstKanniName + "に任ずるぞ。"; } pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text>().text = serihu; } else { //2nd time //Serihu string daimyoName = daimyo.getName(myDaimyo); string serihu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { serihu = "Lord " + daimyoName + ".\n What do you want?"; } else { serihu = "おお、" + daimyoName + "殿。\n此度は何用か。"; } pop.transform.FindChild("Serihu").transform.FindChild("Text").GetComponent <Text>().text = serihu; } } else { audioSources [4].Play(); if (Application.systemLanguage != SystemLanguage.Japanese) { msg.makeMessage("My lord " + occupiedDaimyoName + " disturbed us to visit coart."); } else { msg.makeMessage("御屋形様、" + occupiedDaimyoName + "めに参内を邪魔されました。"); } } } else { audioSources [4].Play(); //string NGtext = msg.getMessage(7); //msg.makeMessage (NGtext); msg.hyourouMovieMessage(); } } }
public void OnClick() { Message msg = new Message(); Gaikou gaikou = new Gaikou(); DoGaikou yukouChange = new DoGaikou(); int nowHyourou = PlayerPrefs.GetInt("hyourou"); CloseBoard closeScript = GameObject.Find("close").GetComponent <CloseBoard> (); int daimyoBusyoAtk = closeScript.daimyoBusyoAtk; int daimyoBusyoDfc = closeScript.daimyoBusyoDfc; int daimyoId = closeScript.daimyoId; int kuniId = closeScript.kuniId; AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); if (nowHyourou >= 5) { //Track int TrackBouryakuNo = PlayerPrefs.GetInt("TrackBouryakuNo", 0); TrackBouryakuNo = TrackBouryakuNo + 1; PlayerPrefs.SetInt("TrackBouryakuNo", TrackBouryakuNo); if (name == "DoGihouBtn") { //Reduce Hyourou reduceHyourou(); //Reduce Shinobi //Ratio //Ge 5-15%, Cyu 15-30%, Jyo 30-50% int randomPercent = 0; int newQty = itemQty - 1; if (itemRank == "Ge") { randomPercent = UnityEngine.Random.Range(5, 15); PlayerPrefs.SetInt("shinobiGe", newQty); } else if (itemRank == "Cyu") { randomPercent = UnityEngine.Random.Range(15, 30); PlayerPrefs.SetInt("shinobiCyu", newQty); } else if (itemRank == "Jyo") { randomPercent = UnityEngine.Random.Range(30, 50); PlayerPrefs.SetInt("shinobiJyo", newQty); } float ratio = (float)randomPercent; float percent = Random.value; percent = percent * 100; if (percent <= ratio) { //OK audioSources [3].Play(); //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); //Delete Gunzei Destroy(Gunzei); //Delete Key string gunzeiKey = Gunzei.name; PlayerPrefs.DeleteKey(gunzeiKey); //Delete Key History char[] delimiterChars = { ',' }; string keyHistory = PlayerPrefs.GetString("keyHistory"); List <string> keyHistoryList = new List <string>(); if (keyHistory != null && keyHistory != "") { if (keyHistory.Contains(",")) { keyHistoryList = new List <string> (keyHistory.Split(delimiterChars)); } else { keyHistoryList.Add(keyHistory); } } keyHistoryList.Remove(gunzeiKey); string newKeyHistory = ""; for (int i = 0; i < keyHistoryList.Count; i++) { if (i == 0) { newKeyHistory = keyHistoryList[i]; } else { newKeyHistory = newKeyHistory + "," + keyHistoryList[i]; } } PlayerPrefs.SetString("keyHistory", newKeyHistory); //Message PlayerPrefs.SetBool("questDailyFlg33", true); //Extension Mark Handling MainStageController main = new MainStageController(); main.questExtension(); int TrackGihouHei = PlayerPrefs.GetInt("TrackGihouHei", 0); int hei = Gunzei.GetComponent <Gunzei> ().myHei; TrackGihouHei = TrackGihouHei + hei; PlayerPrefs.SetInt("TrackGihouHei", TrackGihouHei); string daimyoName = Gunzei.GetComponent <Gunzei>().srcDaimyoName; string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "My lord, misreport was successful. \n" + daimyoName + " army withdrawn."; } else { OKtext = "御屋形様、偽報に成功しましたぞ。\n" + daimyoName + "の軍勢が退却します。"; } msg.makeMessage(OKtext); } else { //NG audioSources [4].Play(); int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); //Message string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = "My lord, I'm sorry. failed misreport. \n Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = "申し訳御座りませぬ。偽報に失敗しましたぞ。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); yukouChange.downYukouOnIcon(daimyoId, newYukoudo); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } else if (name == "DoRyugenBtn") { //Reduce Hyourou reduceHyourou(); //Ratio //Ge 10-20%, Cyu 20-40%, Jyo 40-70% float randomPercent = 0; int newQty = itemQty - 1; if (itemRank == "Ge") { float tempRandomPercent = (200 - daimyoBusyoDfc) / 4; float tempValue = UnityEngine.Random.Range(0.5f, 1.5f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiGe", newQty); } else if (itemRank == "Cyu") { float tempRandomPercent = (200 - daimyoBusyoDfc) / 2; float tempValue = UnityEngine.Random.Range(0.8f, 1.2f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiCyu", newQty); } else if (itemRank == "Jyo") { float tempRandomPercent = (200 - daimyoBusyoDfc); float tempValue = UnityEngine.Random.Range(0.9f, 1.1f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiJyo", newQty); } float percent = Random.value; percent = percent * 100; if (percent <= randomPercent) { //Success audioSources [3].Play(); //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); int TrackRyugenNo = PlayerPrefs.GetInt("TrackRyugenNo", 0); TrackRyugenNo = TrackRyugenNo + 1; PlayerPrefs.SetInt("TrackRyugenNo", TrackRyugenNo); //Daimyo Id int srcDaimyoId = GameObject.Find("close").GetComponent <CloseBoard> ().daimyoId; //Seiryoku List string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); //src daimyo kuni list List <string> srcDaimyoKuniList = new List <string> (); for (int i = 0; i < seiryokuList.Count; i++) { string tempDaimyoId = seiryokuList[i]; if (tempDaimyoId == srcDaimyoId.ToString()) { int temp = i + 1; srcDaimyoKuniList.Add(temp.ToString()); } } //src daimyo open kuni list KuniInfo kuni = new KuniInfo(); List <int> openKuniList = new List <int>(); for (int j = 0; j < srcDaimyoKuniList.Count; j++) { openKuniList.AddRange(kuni.getMappingKuni(int.Parse(srcDaimyoKuniList[j]))); } //Target Daimyo (exculde this src daimyo & mydaimyo) int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); List <int> dstDaimyoList = new List <int>(); for (int k = 0; k < openKuniList.Count; k++) { int temp = openKuniList[k] - 1; int tempDaimyoId = int.Parse(seiryokuList[temp]); if (tempDaimyoId != myDaimyo && tempDaimyoId != srcDaimyoId) { if (!dstDaimyoList.Contains(tempDaimyoId)) { dstDaimyoList.Add(tempDaimyoId); } } } //Reduce Yukoudo MainEventHandler main = new MainEventHandler(); Daimyo daimyo = new Daimyo(); string ryugenText = ""; for (int l = 0; l < dstDaimyoList.Count; l++) { int dstDaimyoId = dstDaimyoList[l]; string dstDaimyoName = daimyo.getName(dstDaimyoId); int reduceYukoudo = main.DownYukouValueWithOther(srcDaimyoId, dstDaimyoId); reduceYukoudo = reduceYukoudo / 2; if (reduceYukoudo == 0) { reduceYukoudo = 1; } if (Application.systemLanguage != SystemLanguage.Japanese) { ryugenText = ryugenText + dstDaimyoName + " friendship decreased " + reduceYukoudo + " point \n"; } else { ryugenText = ryugenText + dstDaimyoName + "との友好度が" + reduceYukoudo + "下がりました。\n"; } } //Message PlayerPrefs.SetBool("questDailyFlg31", true); //Extension Mark Handling MainStageController mainStage = new MainStageController(); mainStage.questExtension(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "My lord, bad rumor was successful. \n" + ryugenText; } else { OKtext = "御屋形様、流言に成功しましたぞ。\n " + ryugenText; } msg.makeMessage(OKtext); } else { //Failed audioSources [4].Play(); //Message int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); //Message string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = "My lord, I'm sorry. failed misreport. \n Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = "申し訳御座りませぬ。流言に失敗しましたぞ。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } yukouChange.downYukouOnIcon(daimyoId, newYukoudo); msg.makeMessage(NGtext); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } else if (name == "DoGoudatsuBtn") { reduceHyourou(); //Ratio //Ge 10-20%, Cyu 20-40%, Jyo 40-70% float randomPercent = 0; int newQty = itemQty - 1; if (itemRank == "Ge") { float tempRandomPercent = (200 - daimyoBusyoDfc) / 4; float tempValue = UnityEngine.Random.Range(0.5f, 1.5f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiGe", newQty); } else if (itemRank == "Cyu") { float tempRandomPercent = (200 - daimyoBusyoDfc) / 2; float tempValue = UnityEngine.Random.Range(0.8f, 1.2f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiCyu", newQty); } else if (itemRank == "Jyo") { float tempRandomPercent = (200 - daimyoBusyoDfc); float tempValue = UnityEngine.Random.Range(0.9f, 1.1f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt("shinobiJyo", newQty); } float percent = Random.value; percent = percent * 100; if (percent <= randomPercent) { audioSources [3].Play(); //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); //Success int kuniQty = GameObject.Find("close").GetComponent <CloseBoard>().kuniQty; int getMoney = 0; //Money or Item 0:money, 1:item int moneyOrItem = UnityEngine.Random.Range(0, 2); //Kahou or Shizai 0:kahou, 1:shizai int kahouOrShizai = UnityEngine.Random.Range(0, 2); string kahouName = ""; string shigenName = ""; int addQty = 0; int kahouRank = 0; //kahouRank S,A,B,C=1,2,3,4 //shigen Type int shigenType = 0; //KB,YR,TP,YM=1,2,3,4 if (moneyOrItem == 0) { //money int temGetMoney = UnityEngine.Random.Range(1000, 1501); getMoney = temGetMoney * kuniQty; int nowMoney = PlayerPrefs.GetInt("money"); nowMoney = nowMoney + getMoney; if (nowMoney < 0) { nowMoney = int.MaxValue; } PlayerPrefs.SetInt("money", nowMoney); PlayerPrefs.Flush(); } else { //item //Kahou or Shizai 0:kahou, 1:shizai kahouOrShizai = UnityEngine.Random.Range(0, 2); if (kahouOrShizai == 0) { //kahou Kahou kahou = new Kahou(); ////Bugu, Gusoku, Kabuto, Meiba, Heihousyo, Cyadougu, Chishikisyo(1,2,3,4,5,6) int kahouType = UnityEngine.Random.Range(1, 7); float khPercent = Random.value; khPercent = khPercent * 100; if (5 <= kuniQty) { //(S,A,B 5,35,60%) if (khPercent <= 5) { //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (5 < khPercent && khPercent <= 41) { //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (41 < khPercent) { //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } else if (3 <= kuniQty && kuniQty < 5) { //(S,A,B,C : 1,15,25,59%) if (khPercent <= 1) { //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (1 < khPercent && khPercent <= 16) { //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (16 < khPercent && khPercent <= 41) { //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (41 < khPercent) { //C kahouRank = 4; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } else if (kuniQty < 3) { //(A,B,C : 5, 35, 60%) if (khPercent <= 5) { //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (5 < khPercent && khPercent <= 41) { //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } else if (41 < khPercent) { //C kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } } else { //shizai shigenType = UnityEngine.Random.Range(1, 5); float sgPercent = Random.value; sgPercent = sgPercent * 100; addQty = UnityEngine.Random.Range(1, 6); Item item = new Item(); int shigenRank = 0; //下、中、上=1,2,3 if (5 <= kuniQty) { //(上,中,下 40,40, 20%) if (sgPercent <= 40) { shigenRank = 3; } else if (40 < sgPercent && sgPercent <= 81) { shigenRank = 2; } else if (81 < sgPercent) { shigenRank = 1; } shigenName = item.getRandomShigen(shigenType, shigenRank, addQty); } else if (3 <= kuniQty && kuniQty < 5) { //(上,中,下 20,50,30%) if (sgPercent <= 20) { shigenRank = 3; } else if (20 < sgPercent && sgPercent <= 51) { shigenRank = 2; } else if (51 < sgPercent) { shigenRank = 1; } shigenName = item.getRandomShigen(shigenType, shigenRank, addQty); } else if (kuniQty < 3) { //(上,中,下 5,25,70%) if (sgPercent <= 5) { shigenRank = 3; } else if (5 < sgPercent && sgPercent <= 26) { shigenRank = 2; } else if (26 < sgPercent) { shigenRank = 1; } shigenName = item.getRandomShigen(shigenType, shigenRank, addQty); } } } //Message PlayerPrefs.SetBool("questDailyFlg32", true); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "My lord, successed to rob.\n"; } else { OKtext = "御屋形様、強奪に成功しましたぞ。\n"; } string addText = ""; if (moneyOrItem == 0) { if (Application.systemLanguage != SystemLanguage.Japanese) { addText = "got " + getMoney + " money."; } else { addText = "金を" + getMoney + "奪って参りました。"; } } else { if (kahouOrShizai == 0) { //kahou if (Application.systemLanguage != SystemLanguage.Japanese) { addText = " got treasure " + kahouName + "."; } else { addText = "家宝、" + kahouName + "を奪って参りました。"; } } else { //shizai+ if (Application.systemLanguage != SystemLanguage.Japanese) { addText = " got " + addQty + " " + shigenName + "."; } else { addText = shigenName + "を" + addQty + "個奪って参りました。"; } } } OKtext = OKtext + addText; msg.makeMessage(OKtext); } else { //Failed audioSources [4].Play(); int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); //Message string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = "My lord, I'm sorry. failed to rob. \n Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = "申し訳御座りませぬ。強奪に失敗しましたぞ。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); yukouChange.downYukouOnIcon(daimyoId, newYukoudo); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } else if (name == "DoCyouhouBtn") { reduceHyourou(); //Set Value & REduce Qty float missPercent = 0; int newQty = itemQty - 1; int snbValue = 0; if (itemRank == "Ge") { missPercent = 30; PlayerPrefs.SetInt("shinobiGe", newQty); snbValue = 1; } else if (itemRank == "Cyu") { missPercent = 15; PlayerPrefs.SetInt("shinobiCyu", newQty); snbValue = 2; } else if (itemRank == "Jyo") { missPercent = 5; PlayerPrefs.SetInt("shinobiJyo", newQty); snbValue = 3; } //Random Check float percent = Random.value; percent = percent * 100; if (percent >= missPercent) { //Success audioSources [3].Play(); //Track int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo", 0); TrackBouryakuSuccessNo = TrackBouryakuSuccessNo + 1; PlayerPrefs.SetInt("TrackBouryakuSuccessNo", TrackBouryakuSuccessNo); int TrackCyouhouNo = PlayerPrefs.GetInt("TrackCyouhouNo", 0); TrackCyouhouNo = TrackCyouhouNo + 1; PlayerPrefs.SetInt("TrackCyouhouNo", TrackCyouhouNo); string cyouhouHist = PlayerPrefs.GetString("cyouhou"); char[] delimiterChars = { ',' }; List <string> cyouhouHistList = new List <string> (); if (cyouhouHist != null && cyouhouHist != "") { if (cyouhouHist.Contains(",")) { cyouhouHistList = new List <string> (cyouhouHist.Split(delimiterChars)); } else { cyouhouHistList.Add(cyouhouHist); } } //Add new kuni if (!cyouhouHistList.Contains(kuniId.ToString())) { cyouhouHistList.Add(kuniId.ToString()); } string newCyouhouHist = ""; for (int i = 0; i < cyouhouHistList.Count; i++) { string tmpCyouhouKuniId = cyouhouHistList [i]; if (i == 0) { newCyouhouHist = tmpCyouhouKuniId; } else { newCyouhouHist = newCyouhouHist + "," + tmpCyouhouKuniId; } } PlayerPrefs.SetString("cyouhou", newCyouhouHist); string cyouhouKuni = "cyouhou" + kuniId.ToString(); PlayerPrefs.SetInt(cyouhouKuni, snbValue); bool cyouhouFlg = closeScript.cyouhouFlg; if (cyouhouFlg) { //Change Icon GameObject shinobi = GameObject.Find("shinobi").gameObject; if (snbValue == 1) { Color lowColor = new Color(0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f); shinobi.GetComponent <Image> ().color = lowColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "下"; } else if (snbValue == 2) { Color midColor = new Color(94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent <Image> ().color = midColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "中"; } else if (snbValue == 3) { Color highColor = new Color(84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent <Image> ().color = highColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text> ().text = "上"; } } else { GameObject smallBoardObj = GameObject.Find("smallBoard(Clone)").gameObject; //new Icon string shinobiItemPath = "Prefabs/Item/Shinobi/Shinobi"; GameObject shinobi = Instantiate(Resources.Load(shinobiItemPath)) as GameObject; shinobi.transform.SetParent(smallBoardObj.transform); shinobi.transform.localScale = new Vector2(0.25f, 0.31f); shinobi.name = "shinobi"; RectTransform snbTransform = shinobi.GetComponent <RectTransform> (); snbTransform.anchoredPosition = new Vector3(-251, 250, 0); shinobi.GetComponent <Button> ().enabled = false; if (snbValue == 1) { Color lowColor = new Color(0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f); shinobi.GetComponent <Image>().color = lowColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "下"; } else if (snbValue == 2) { Color midColor = new Color(94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent <Image>().color = midColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "中"; } else if (snbValue == 3) { Color highColor = new Color(84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent <Image>().color = highColor; shinobi.transform.FindChild("ShinobiRank").GetComponent <Text>().text = "上"; } //Set Flg closeScript.cyouhouFlg = true; closeScript.cyouhouSnbRankId = snbValue; } GameObject kuniIconView = GameObject.Find("KuniIconView").gameObject; kuniIconView.transform.FindChild(kuniId.ToString()).GetComponent <SendParam> ().cyouhouSnbRankId = snbValue; KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); PlayerPrefs.SetBool("questDailyFlg30", true); MainStageController mainStage = new MainStageController(); mainStage.questExtension(); string OKtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { OKtext = "Ninja hided in " + kuniName + " well. \n Please check spy report."; } else { OKtext = "忍が上手く" + kuniName + "に潜伏しましたぞ。\n諜報内容をご確認下され。"; } msg.makeMessage(OKtext); } else { //Fail audioSources [4].Play(); int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId, nowYukoudo, maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find("YukouValue").GetComponent <Text> ().text = newYukoudo.ToString(); string NGtext = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { NGtext = "Ninja was caught. \n Friendship decreased " + reduceYukoudo + " point"; } else { NGtext = "忍が捕まってしまったようです。\n友好度が" + reduceYukoudo + "下がりますぞ。"; } msg.makeMessage(NGtext); yukouChange.downYukouOnIcon(daimyoId, newYukoudo); } PlayerPrefs.Flush(); //Back GameObject.Find("return").GetComponent <MenuReturn> ().OnClick(); } } else { audioSources [4].Play(); msg.hyourouMovieMessage(); //msg.makeMessage (msg.getMessage(7)); } }
public void receiveBusyo(int busyoId) { //Common BusyoInfoGet BusyoInfoGet = new BusyoInfoGet(); string busyoName = BusyoInfoGet.getName(busyoId); string heisyu = BusyoInfoGet.getHeisyu(busyoId); string rank = BusyoInfoGet.getRank(busyoId); int myBusyoQty = PlayerPrefs.GetInt("myBusyoQty"); //Tracking int TrackNewBusyoHireNo = PlayerPrefs.GetInt("TrackNewBusyoHireNo", 0); TrackNewBusyoHireNo = TrackNewBusyoHireNo + 1; PlayerPrefs.SetInt("TrackNewBusyoHireNo", TrackNewBusyoHireNo); //Add zukan & gacya History Start string zukanBusyoHst = PlayerPrefs.GetString("zukanBusyoHst"); if (zukanBusyoHst != null && zukanBusyoHst != "") { zukanBusyoHst = zukanBusyoHst + "," + busyoId.ToString(); } else { zukanBusyoHst = busyoId.ToString(); } PlayerPrefs.SetString("zukanBusyoHst", zukanBusyoHst); //Daimyo Busyo History Daimyo daimyo = new Daimyo(); if (daimyo.daimyoBusyoCheck(busyoId)) { string gacyaDaimyoHst = PlayerPrefs.GetString("gacyaDaimyoHst"); if (gacyaDaimyoHst != null && gacyaDaimyoHst != "") { gacyaDaimyoHst = gacyaDaimyoHst + "," + busyoId.ToString(); } else { gacyaDaimyoHst = busyoId.ToString(); } PlayerPrefs.SetString("gacyaDaimyoHst", gacyaDaimyoHst); } //My Busyo Exist Check string myBusyoString = PlayerPrefs.GetString("myBusyo"); char[] delimiterChars = { ',' }; List <string> myBusyoList = new List <string>(); char[] delimiterChars2 = { ',' }; if (myBusyoString.Contains(",")) { myBusyoList = new List <string>(myBusyoString.Split(delimiterChars)); } else { myBusyoList.Add(myBusyoString); } if (myBusyoList.Contains(busyoId.ToString())) { //add lv string addLvTmp = "addlv" + busyoId.ToString(); int addLvValue = 0; if (PlayerPrefs.HasKey(addLvTmp)) { addLvValue = PlayerPrefs.GetInt(addLvTmp); addLvValue = addLvValue + 1; if (addLvValue >= 100) { addLvValue = 100; } } else { addLvValue = 1; } if (addLvValue < 100) { PlayerPrefs.SetInt(addLvTmp, addLvValue); PlayerPrefs.Flush(); MessageBusyo msg = new MessageBusyo(); string type = "touyou"; string msgText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { msgText = "Max Lv of " + busyoName + " increased."; } else { msgText = busyoName + "の最大レベルが1上がりました。"; } msg.makeMessage(msgText, busyoId, type); } else { //Lv up int currentLv = PlayerPrefs.GetInt(busyoId.ToString()); int maxLv = 100 + addLvValue; int newLv = 0; string lvUpText = ""; //Already Lv Max if (currentLv == maxLv) { newLv = currentLv; int busyoDama = 0; if (rank == "S") { busyoDama = 200; } else if (rank == "A") { busyoDama = 50; } else if (rank == "B") { busyoDama = 20; } else if (rank == "C") { busyoDama = 10; } int myBusyoDama = PlayerPrefs.GetInt("busyoDama"); myBusyoDama = myBusyoDama + busyoDama; PlayerPrefs.SetInt("busyoDama", myBusyoDama); if (Application.systemLanguage != SystemLanguage.Japanese) { lvUpText = "You got " + busyoDama + " stone."; } else { lvUpText = "武将珠" + busyoDama + "個を贈呈します。"; } } PlayerPrefs.SetInt(busyoId.ToString(), newLv); if (currentLv != maxLv) { string exp = "exp" + busyoId.ToString(); Exp expCalc = new Exp(); int totalExp = expCalc.getExpforNextLv(currentLv); PlayerPrefs.SetInt(exp, totalExp); } MessageBusyo msg = new MessageBusyo(); string type = "touyou"; msg.makeMessage(lvUpText, busyoId, type); } } else { int existCheck = PlayerPrefs.GetInt(busyoId.ToString()); if (existCheck != 0 && existCheck != null) { //my Busyo not contain but player used him before daimyo was changed if (myBusyoString == null || myBusyoString == "") { myBusyoString = busyoId.ToString(); } else { myBusyoString = myBusyoString + "," + busyoId.ToString(); } PlayerPrefs.SetString("myBusyo", myBusyoString); //Add Qty myBusyoQty = myBusyoQty + 1; PlayerPrefs.SetInt("myBusyoQty", myBusyoQty); MessageBusyo msg = new MessageBusyo(); string touyouuText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { touyouuText = "We hired " + busyoName + "."; } else { touyouuText = busyoName + "を登用しました。"; } string type = "touyou"; msg.makeMessage(touyouuText, busyoId, type); } else { //Add Completely New Data if (myBusyoString == null || myBusyoString == "") { myBusyoString = busyoId.ToString(); } else { myBusyoString = myBusyoString + "," + busyoId.ToString(); } PlayerPrefs.SetString("myBusyo", myBusyoString); PlayerPrefs.SetInt(busyoId.ToString(), 1); string hei = "hei" + busyoId.ToString(); string heiValue = heisyu + ":1:1:1"; PlayerPrefs.SetString(hei, heiValue); string senpou = "senpou" + busyoId.ToString(); PlayerPrefs.SetInt(senpou, 1); //Lv string saku = "saku" + busyoId.ToString(); PlayerPrefs.SetInt(saku, 1); //Lv string kahou = "kahou" + busyoId.ToString(); PlayerPrefs.SetString(kahou, "0,0,0,0,0,0,0,0"); string exp = "exp" + busyoId.ToString(); PlayerPrefs.SetInt(exp, 0); //Add Qty myBusyoQty = myBusyoQty + 1; PlayerPrefs.SetInt("myBusyoQty", myBusyoQty); //View Message Box Destroy(GameObject.Find("board(Clone)")); Destroy(GameObject.Find("Back(Clone)")); MessageBusyo msg = new MessageBusyo(); string touyouuText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { touyouuText = "We hired " + busyoName + "."; } else { touyouuText = busyoName + "を登用しました。"; } string type = "touyou"; msg.makeMessage(touyouuText, busyoId, type); } } }
public void mainHandler(){ /*Basic Info*/ //make kuni list string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string> (); char[] delimiterChars = {','}; seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); GameObject targetKuni = GameObject.Find ("KuniIconView"); /*Kassen*/ //1. Randome choice Kassen Qty between 0,1,2,3 //2. Ratio 50% check //3. Random choice Kassen Souce Kuni 1-65 //4. Destination Check by Mapping // if Same Daimyo between Kassen Souce & Destination Kuni => Skip // else => Make guntai Instance // 4-1. Destination == myDaimyo // 4-2. Destination == has own relation or master relation // //Message List<string> messageList = new List<string> (); //Count Kassen Qty int kassenQty = CountEnemyKassenAction (); for (int i=1; i<kassenQty+1; i++) { //Check Kassen or Not bool kassenFlg = CheckByProbability (kassenRatio); if (kassenFlg == true) { //target kuni extraction while (true) { int randomKuni = UnityEngine.Random.Range (1, 65); string eDaimyo = seiryokuList [randomKuni - 1]; string tDaimyo = ""; bool doumeiFlg = false; if (eDaimyo != myDaimyo.ToString ()) { //Check Kuni Mapping List<int> targetKuniList = new List<int> (); KuniInfo kuni = new KuniInfo (); targetKuniList = kuni.getMappingKuni (randomKuni); //Yukoudo Check int worstGaikouDaimyo = 0; int worstGaikouValue = 100; int worstGaikouKuni = 0; int worstHeiryokuValue = 100000000; SendParam srcSendParam = targetKuni.transform.FindChild (randomKuni.ToString ()).GetComponent<SendParam> (); bool aggressiveFlg = srcSendParam.aggressiveFlg; for (int k=0; k<targetKuniList.Count; k++) { SendParam sendParam = targetKuni.transform.FindChild (targetKuniList [k].ToString ()).GetComponent<SendParam> (); if (aggressiveFlg) { //Find worst gaikou daimyo tDaimyo = seiryokuList [targetKuniList [k] - 1]; int gaikouValue = 0; if (eDaimyo != tDaimyo) { if (tDaimyo == myDaimyo.ToString ()) { //Get Gaikou Value string eGaikouM = "gaikou" + eDaimyo; gaikouValue = PlayerPrefs.GetInt (eGaikouM); } else { //Gaikou Data Check string gaikouTemp = ""; if (int.Parse (eDaimyo) < int.Parse (tDaimyo)) { gaikouTemp = eDaimyo + "gaikou" + tDaimyo; } else { gaikouTemp = tDaimyo + "gaikou" + eDaimyo; } if (PlayerPrefs.HasKey (gaikouTemp)) { //exsit gaikouValue = PlayerPrefs.GetInt (gaikouTemp); } else { //non exist //gaikou check gaikouValue = gaikou.getGaikouValue (int.Parse (eDaimyo), int.Parse (tDaimyo)); } } //Compare with Previous one if (worstGaikouValue > gaikouValue) { worstGaikouValue = gaikouValue; worstGaikouDaimyo = int.Parse (tDaimyo); worstGaikouKuni = targetKuniList [k]; } } } else { //Find worst heiryoku daimyo tDaimyo = seiryokuList [targetKuniList [k] - 1]; if (eDaimyo != tDaimyo) { //Heiryoku Check int heiryoku = sendParam.heiryoku; //Compare with Previous one if (worstHeiryokuValue > heiryoku) { worstHeiryokuValue = heiryoku; int gaikouValue = 0; if (tDaimyo == myDaimyo.ToString ()) { //Get Gaikou Value string eGaikouM = "gaikou" + eDaimyo; gaikouValue = PlayerPrefs.GetInt (eGaikouM); } else { //Gaikou Data Check string gaikouTemp = ""; if (int.Parse (eDaimyo) < int.Parse (tDaimyo)) { gaikouTemp = eDaimyo + "gaikou" + tDaimyo; } else { gaikouTemp = tDaimyo + "gaikou" + eDaimyo; } if (PlayerPrefs.HasKey (gaikouTemp)) { //exsit gaikouValue = PlayerPrefs.GetInt (gaikouTemp); } else { //non exist gaikouValue = gaikou.getGaikouValue (int.Parse (eDaimyo), int.Parse (tDaimyo)); } } worstGaikouValue = gaikouValue; worstGaikouDaimyo = int.Parse (tDaimyo); worstGaikouKuni = targetKuniList [k]; } } } }//Loop End //Create Guntai Instance if (worstGaikouValue != 100) { int kassenRatio2 = 100 - worstGaikouValue; //doumei check string doumeiCheck = "doumei" + eDaimyo; if(PlayerPrefs.HasKey(doumeiCheck)){ string cDoumei = PlayerPrefs.GetString(doumeiCheck); List<string> cDoumeiList = new List<string>(); if(cDoumei.Contains(",")){ cDoumeiList = new List<string> (cDoumei.Split (delimiterChars)); }else{ cDoumeiList.Add(cDoumei); } //If Doumei Daimyo -> Half Ratio if(cDoumeiList.Contains(worstGaikouDaimyo.ToString())){ doumeiFlg = true; kassenRatio2 = kassenRatio2/2; }else{ doumeiFlg = false; } } bool GaikouValueFlg = CheckByProbability (kassenRatio2); if (GaikouValueFlg) { //Make Guntai Instance string key = randomKuni.ToString () + "-" + worstGaikouKuni.ToString (); bool ExistFlg = false; //Exist Check Same Daimyo foreach (GameObject obs in GameObject.FindGameObjectsWithTag("Gunzei")){ int gunzeiSrcDaimyoId = obs.GetComponent<Gunzei>().srcDaimyoId; if(int.Parse(eDaimyo) == gunzeiSrcDaimyoId){ ExistFlg = true; } } if(!ExistFlg){ string path = "Prefabs/Map/Gunzei"; GameObject Gunzei = Instantiate (Resources.Load (path)) as GameObject; Gunzei.transform.SetParent (GameObject.Find ("Panel").transform); Gunzei.transform.localScale = new Vector2 (1, 1); //Location int srcX = kuni.getKuniLocationX(randomKuni); int srcY = kuni.getKuniLocationY(randomKuni); int dstX = kuni.getKuniLocationX(worstGaikouKuni); int dstY = kuni.getKuniLocationY(worstGaikouKuni); string direction = ""; Gunzei gunzei = new Gunzei (); if(srcX < dstX){ Gunzei.transform.localScale = new Vector2 (1, 1); direction = "right"; }else{ Gunzei.transform.localScale = new Vector2 (-1, 1); direction = "left"; Gunzei.GetComponent<Gunzei> ().leftFlg = true; } int aveX = (srcX + dstX)/2; int aveY = (srcY + dstY)/2; RectTransform GunzeiTransform = Gunzei.GetComponent<RectTransform> (); GunzeiTransform.anchoredPosition = new Vector3 (aveX, aveY, 0); Gunzei.GetComponent<Gunzei> ().key = key; Gunzei.GetComponent<Gunzei> ().srcKuni = randomKuni; Gunzei.GetComponent<Gunzei> ().srcDaimyoId = int.Parse (eDaimyo); string srcDaimyoName = daimyo.getName (int.Parse (eDaimyo)); Gunzei.GetComponent<Gunzei> ().srcDaimyoName = srcDaimyoName; Gunzei.GetComponent<Gunzei> ().dstKuni = worstGaikouKuni; Gunzei.GetComponent<Gunzei> ().dstDaimyoId = worstGaikouDaimyo; string dstDaimyoName = daimyo.getName (worstGaikouDaimyo); Gunzei.GetComponent<Gunzei> ().dstDaimyoName = dstDaimyoName; int myHei = gunzei.heiryokuCalc (randomKuni); Gunzei.GetComponent<Gunzei> ().myHei = myHei; Gunzei.name = key; //Engun from Doumei Doumei doumei = new Doumei(); List<string> doumeiDaimyoList = new List<string> (); bool dstEngunFlg = false; string dstEngunDaimyoId = ""; //2:3:5 string dstEngunHei = ""; string dstEngunSts = ""; //BusyoId-BusyoLv-ButaiQty-ButaiLv: int totalEngunHei = 0; doumeiDaimyoList = doumei.doumeiExistCheck(worstGaikouDaimyo,eDaimyo); if(doumeiDaimyoList.Count != 0){ //Doumei Exist //Trace Check List<string> okDaimyoList = new List<string> (); List<string> checkList = new List<string> (); okDaimyoList = doumei.traceNeighborDaimyo(worstGaikouKuni, worstGaikouDaimyo, doumeiDaimyoList, seiryokuList, checkList,okDaimyoList); if(okDaimyoList.Count !=0){ //Doumei & Neghbor Daimyo Exist for(int k=0; k<okDaimyoList.Count; k++){ string engunDaimyo = okDaimyoList[k]; int yukoudo = gaikou.getExistGaikouValue(int.Parse(engunDaimyo), worstGaikouDaimyo); //engun check dstEngunFlg = CheckByProbability (yukoudo); if(dstEngunFlg){ //Engun OK dstEngunFlg = true; if(dstEngunDaimyoId !=null && dstEngunDaimyoId !=""){ dstEngunDaimyoId = dstEngunDaimyoId + ":" + engunDaimyo; string tempEngunSts = getEngunSts(engunDaimyo); int tempEngunHei = getEngunHei(tempEngunSts); dstEngunHei = dstEngunHei + ":" + tempEngunHei.ToString(); totalEngunHei = totalEngunHei + tempEngunHei; dstEngunSts = dstEngunSts + ":" + tempEngunSts; }else{ dstEngunDaimyoId = engunDaimyo; string tempEngunSts = getEngunSts(engunDaimyo); int tempEngunHei = getEngunHei(tempEngunSts); dstEngunHei = tempEngunHei.ToString(); totalEngunHei = tempEngunHei; dstEngunSts = tempEngunSts; } } } Gunzei.GetComponent<Gunzei> ().dstEngunFlg = dstEngunFlg; Gunzei.GetComponent<Gunzei> ().dstEngunDaimyoId = dstEngunDaimyoId; Gunzei.GetComponent<Gunzei> ().dstEngunHei = dstEngunHei; Gunzei.GetComponent<Gunzei> ().dstEngunSts = dstEngunSts; } } //Set Value //CreateTime,srcDaimyoId,dstDaimyoId,srcDaimyoName,dstDaimyoName, srcHei,locationX,locationY,left or right, engunFlg, engunDaimyoId(A:B:C), dstEngunHei(1000:2000:3000), dstEngunSts string keyValue = ""; string createTime = System.DateTime.Now.ToString (); keyValue = createTime + "," + eDaimyo + "," + worstGaikouDaimyo + "," + srcDaimyoName + "," + dstDaimyoName + "," + myHei + "," + aveX + "," + aveY + "," + direction + "," + dstEngunFlg + "," + dstEngunDaimyoId + "," + dstEngunHei + ","+ dstEngunSts; PlayerPrefs.SetString (key, keyValue); string keyHistory = PlayerPrefs.GetString ("keyHistory"); if(keyHistory == null || keyHistory == ""){ keyHistory = key; }else{ keyHistory = keyHistory + "," + key; } PlayerPrefs.SetString ("keyHistory", keyHistory); flush (); string kassenText = ""; if(!dstEngunFlg){ kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。"; }else{ kassenText = srcDaimyoName + "が" + dstDaimyoName + "討伐の兵" + myHei + "人を起こしました。\n防衛側の同盟国が援軍" + totalEngunHei + "人を派兵しました。"; } messageList.Add (kassenText); if(doumeiFlg){ //Delete doumei doumei.deleteDoumei(eDaimyo, worstGaikouDaimyo.ToString()); //Zero Gaikou string tempYukou = ""; if(tDaimyo == myDaimyo.ToString()){ tempYukou = "gaikou" + eDaimyo; }else{ if(worstGaikouDaimyo < int.Parse(eDaimyo)){ tempYukou = worstGaikouDaimyo.ToString() + "gaikou" + eDaimyo; }else{ tempYukou = eDaimyo + "gaikou" + worstGaikouDaimyo.ToString(); } } PlayerPrefs.SetInt(tempYukou,0); PlayerPrefs.Flush (); } } } } break; } } } } /************/ /***Gaikou***/ /************/ int gaikouQty = CountEnemyGaikouAction (); for (int i=1; i<gaikouQty+1; i++) { bool gaikouFlg = CheckByProbability (gaikouRatio); if (gaikouFlg == true) { //Do gaikou int randomKuni = UnityEngine.Random.Range (1, 66); int srcDaimyoId = int.Parse (seiryokuList [randomKuni - 1]); string srcDaimyoName = daimyo.getName (srcDaimyoId); if (srcDaimyoId != myDaimyo) { List<int> targetKuniList = new List<int> (); KuniInfo kuni = new KuniInfo (); targetKuniList = kuni.getMappingKuni (randomKuni); //Yukoudo Check int bestGaikouDaimyo = 0; int bestGaikouValue = 0; int bestGaikouKuni = 0; int bestHeiryokuValue = 0; SendParam sendParamSrc = targetKuni.transform.FindChild (randomKuni.ToString ()).GetComponent<SendParam> (); bool aggressiveFlg = sendParamSrc.aggressiveFlg; for (int k=0; k<targetKuniList.Count; k++) { SendParam sendParam = targetKuni.transform.FindChild (targetKuniList [k].ToString ()).GetComponent<SendParam> (); if (aggressiveFlg) { //Find best gaikou daimyo int dstDaimyoId = int.Parse (seiryokuList [targetKuniList [k] - 1]); int gaikouValue = 0; if (srcDaimyoId != dstDaimyoId) { if (dstDaimyoId == myDaimyo) { //Get Gaikou Value string eGaikouM = "gaikou" + srcDaimyoId; gaikouValue = PlayerPrefs.GetInt (eGaikouM); } else { //Gaikou Data Check string gaikouTemp = ""; if (srcDaimyoId < dstDaimyoId) { gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId; } else { gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId; } if (PlayerPrefs.HasKey (gaikouTemp)) { //exsit gaikouValue = PlayerPrefs.GetInt (gaikouTemp); } else { //non exist //gaikou check gaikouValue = gaikou.getGaikouValue (srcDaimyoId, dstDaimyoId); } } //Compare with Previous one //Best one if (gaikouValue >= bestGaikouValue) { bestGaikouValue = gaikouValue; bestGaikouDaimyo = dstDaimyoId; bestGaikouKuni = targetKuniList [k]; } } } else { //Find best heiryoku daimyo int dstDaimyoId = int.Parse (seiryokuList [targetKuniList [k] - 1]); if (srcDaimyoId != dstDaimyoId) { //Heiryoku Check int heiryoku = sendParam.heiryoku; //Compare with Previous one if (heiryoku >= bestHeiryokuValue) { bestHeiryokuValue = heiryoku; int gaikouValue = 0; if (dstDaimyoId == myDaimyo) { //Get Gaikou Value string eGaikouM = "gaikou" + srcDaimyoId; gaikouValue = PlayerPrefs.GetInt (eGaikouM); } else { //Gaikou Data Check string gaikouTemp = ""; if (srcDaimyoId < dstDaimyoId) { gaikouTemp = srcDaimyoId + "gaikou" + dstDaimyoId; } else { gaikouTemp = dstDaimyoId + "gaikou" + srcDaimyoId; } if (PlayerPrefs.HasKey (gaikouTemp)) { //exsit gaikouValue = PlayerPrefs.GetInt (gaikouTemp); } else { //non exist gaikouValue = gaikou.getGaikouValue (srcDaimyoId, dstDaimyoId); } } bestGaikouValue = gaikouValue; bestGaikouDaimyo = dstDaimyoId; bestGaikouKuni = targetKuniList [k]; } } } }//Loop End //Gaikou Action float percent = UnityEngine.Random.value; percent = percent * 100; int gaikouAction = 0; if (percent <= 60) { gaikouAction = 1; //Mitsugi } else if (60 < percent && percent <= 97) { gaikouAction = 2; //Ryugen } else if (97 < percent && percent <= 100) { gaikouAction = 3; //Doumei } if (gaikouAction == 1) { //1. yukoudo up(Mitsugimono) bool yukoudoUpFlg = CheckByProbability (yukoudoUpMissRatio); if (yukoudoUpFlg == true) { //Choose Target Daimyo string dstDaimyoName = daimyo.getName (bestGaikouDaimyo); if (bestGaikouDaimyo == myDaimyo) { //In the case that MyDaimyo receive Mitsugimono int addYukoudo = UpYukouValueWithMyDaimyo (myDaimyo, bestGaikouDaimyo); int addMoney = addYukoudo * 1000; string yukouUpText = srcDaimyoName + "殿が御屋形様に、金" + addMoney.ToString() + "の貢物を送って参りました。\t友好度が" + addYukoudo + "上がります。"; int myMoney = PlayerPrefs.GetInt("money"); myMoney = myMoney + addMoney; PlayerPrefs.SetInt("money",myMoney); flush (); GameObject.Find ("MoneyValue").GetComponent<Text>().text = myMoney.ToString(); messageList.Add (yukouUpText); } else { //In the case between other daimyos int addYukoudo = UpYukouValueWithOther (srcDaimyoId, bestGaikouDaimyo); string yukouUpText = srcDaimyoName + "が" + dstDaimyoName + "に貢物をしました。友好度が" + addYukoudo + "上がります。"; messageList.Add (yukouUpText); } } } else if (gaikouAction == 2) { //2. yukoudo down(Ryugen) bool yukoudoDownFlg = CheckByProbability (yukoudoDownMissRatio); if (yukoudoDownFlg == true) { //Choose Target Daimyo int reduceYukoudo = 0; if (bestGaikouDaimyo != 0) { if (bestGaikouDaimyo == myDaimyo) { //My Daimyo string dstDaimyoName = ""; reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, srcDaimyoId); dstDaimyoName = daimyo.getName (srcDaimyoId); string yukouDownText = "何者かが当家と" + dstDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。"; messageList.Add (yukouDownText); } else { reduceYukoudo = DownYukouValueWithOther (srcDaimyoId, bestGaikouDaimyo); string dst1stDaimyoName = daimyo.getName (srcDaimyoId); string dst2ndDaimyoName = daimyo.getName (bestGaikouDaimyo); string yukouDownText = "何者かが" + dst1stDaimyoName + "と" + dst2ndDaimyoName + "間に流言を流し、友好度が" + reduceYukoudo + "下がりました。"; messageList.Add (yukouDownText); } } } } else if (gaikouAction == 3) { //3. doumei Gaikou gaiko = new Gaikou(); int yukoudo = gaikou.getExistGaikouValue(srcDaimyoId, bestGaikouDaimyo); bool doumeiFlg = CheckByProbability (yukoudo); if (doumeiFlg == true) { if (bestGaikouDaimyo == myDaimyo) { // // // // // // // // } else { //Exist Check string doumeiTmp = "doumei" + srcDaimyoId; string doumeiString = PlayerPrefs.GetString (doumeiTmp); List<string> doumeiList = new List<string> (); if (doumeiString != null && doumeiString != "") { if (doumeiString.Contains (",")) { doumeiList = new List<string> (doumeiString.Split (delimiterChars)); } else { doumeiList.Add (doumeiString); } } if (!doumeiList.Contains (bestGaikouDaimyo.ToString())) { //Not Exist Case //Doumei Data Register string newDoumei1 = ""; if (doumeiString != null && doumeiString != "") { newDoumei1 = doumeiString + "," + bestGaikouDaimyo; } else { newDoumei1 = bestGaikouDaimyo.ToString(); } PlayerPrefs.SetString (doumeiTmp, newDoumei1); string doumeiTmp2 = "doumei" + bestGaikouDaimyo; string doumeiString2 = PlayerPrefs.GetString (doumeiTmp2); string newDoumei2 = ""; if (doumeiString2 != null && doumeiString2 != "") { newDoumei2 = doumeiString2 + "," + srcDaimyoId; } else { newDoumei2 = srcDaimyoId.ToString(); } PlayerPrefs.SetString (doumeiTmp2, newDoumei2); flush (); string dst1stDaimyoName = daimyo.getName (srcDaimyoId); string dst2ndDaimyoName = daimyo.getName (bestGaikouDaimyo); string doumeiText = dst1stDaimyoName + "と" + dst2ndDaimyoName + "間に同盟が成立しました。"; messageList.Add (doumeiText); } } } } //else if (gaikouAction == 4) { //add here //} } } } //Check Shinobi Cyouhou string cyouhou = PlayerPrefs.GetString("cyouhou"); List<string> cyouhouList = new List<string> (); if (cyouhou != null && cyouhou != "") { if(cyouhou.Contains(",")){ cyouhouList = new List<string> (cyouhou.Split (delimiterChars)); }else{ cyouhouList.Add(cyouhou); } } for(int i=0; i<cyouhouList.Count; i++){ int kuniId = int.Parse(cyouhouList [i]); string snbTmp = "cyouhou" + kuniId.ToString (); int rank = PlayerPrefs.GetInt(snbTmp); float missPercent = 0; if(rank == 1){ missPercent = 30; }else if(rank == 2){ missPercent = 15; }else if(rank == 3){ missPercent = 5; } float percent = Random.value; percent = percent * 100; if (percent < missPercent) { //Miss PlayerPrefs.DeleteKey(snbTmp); cyouhouList.Remove (kuniId.ToString()); string newCyouhou = ""; for(int j=0;j<cyouhouList.Count;j++){ if (j == 0) { newCyouhou = cyouhouList[j]; } else { newCyouhou = newCyouhou + "," + cyouhouList[j]; } } PlayerPrefs.SetString ("cyouhou",newCyouhou); //Reset Chouhou Id targetKuni.transform.FindChild(kuniId.ToString()).GetComponent<SendParam>().cyouhouSnbRankId = 0; //Message KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName(kuniId); int daimyoId = int.Parse(seiryokuList [kuniId - 1]); Daimyo daimyo = new Daimyo (); string daimyoName = daimyo.getName (daimyoId); int reduceYukoudo = DownYukouValueWithMyDaimyo (myDaimyo, daimyoId); string cyouhouMissText = kuniName + "に潜伏中の忍が見つかりました。\n" + daimyoName + "との友好度が"+reduceYukoudo+"下がりました。"; messageList.Add (cyouhouMissText); } } PlayerPrefs.Flush(); /*Decrease Yukou with Doumei koku*/ string myDoumei = PlayerPrefs.GetString ("doumei"); List<string> myDoumeiList = new List<string> (); if (myDoumei != null && myDoumei != "") { if(myDoumei.Contains(",")){ myDoumeiList = new List<string> (myDoumei.Split (delimiterChars)); }else{ myDoumeiList.Add(myDoumei); } } for (int j=0; j<myDoumeiList.Count; j++) { string doumeiDaimyo = myDoumeiList[j]; string yukouTemp = "gaikou" + doumeiDaimyo; int yukouWithDoumei = PlayerPrefs.GetInt (yukouTemp); int reduceYukou = UnityEngine.Random.Range(0,3); yukouWithDoumei = yukouWithDoumei - reduceYukou; PlayerPrefs.SetInt (yukouTemp,yukouWithDoumei); /*Doumei Clear Check*/ if(yukouWithDoumei<30){ //My Doumei Clear myDoumeiList.Remove(doumeiDaimyo); string newMyDoumei = ""; for(int i=0; i<myDoumeiList.Count; i++){ if(i==0){ newMyDoumei = myDoumeiList[i]; }else{ newMyDoumei = newMyDoumei + "," + myDoumeiList[i]; } } PlayerPrefs.SetString ("doumei",newMyDoumei); //Opposite Doumei Clear string otherTemp = "doumei" + doumeiDaimyo; string otherDoumei = PlayerPrefs.GetString (otherTemp); List<string> otherDoumeiList = new List<string> (); if (otherDoumei != null && otherDoumei != "") { if(otherDoumei.Contains(",")){ otherDoumeiList = new List<string> (otherDoumei.Split (delimiterChars)); }else{ otherDoumeiList.Add(otherDoumei); } } otherDoumeiList.Remove(myDaimyo.ToString()); string newOtherDoumei = ""; for(int i=0; i<otherDoumeiList.Count; i++){ if(i==0){ newOtherDoumei = otherDoumeiList[i]; }else{ newOtherDoumei = newOtherDoumei + "," + otherDoumeiList[i]; } } PlayerPrefs.SetString (otherTemp,newOtherDoumei); //Icon & Flg Change KuniInfo kuni = new KuniInfo(); kuni.deleteDoumeiKuniIcon(int.Parse(doumeiDaimyo)); //Message string dstDaimyoName = daimyo.getName (int.Parse(doumeiDaimyo)); string doumeiClearText = "友好度悪化により、当家と" + dstDaimyoName + "間の同盟が解消しました。"; messageList.Add (doumeiClearText); } PlayerPrefs.Flush(); } /*Decrease Yukou with Doumei koku in other county*/ List<string> activeDaimyoList = new List<string> (); for (int k=0; k<seiryokuList.Count; k++) { string daimyoId = seiryokuList[k]; if(int.Parse(daimyoId) != myDaimyo && !activeDaimyoList.Contains(daimyoId)){ activeDaimyoList.Add(daimyoId); } } for(int l=0; l<activeDaimyoList.Count; l++){ string activeDaimyoId = activeDaimyoList[l]; string temp = "doumei" + activeDaimyoId; if(PlayerPrefs.HasKey(temp)){ string doumeiString = PlayerPrefs.GetString(temp); if(doumeiString != null && doumeiString != ""){ List<string> doumeiTargetList = new List<string> (); if(doumeiString.Contains(",")){ doumeiTargetList = new List<string> (doumeiString.Split (delimiterChars)); }else{ doumeiTargetList.Add(doumeiString); } for(int m=0; m<doumeiTargetList.Count; m++){ string targetDaimyoId = doumeiTargetList[m]; string gaikoTemp = ""; if(int.Parse(activeDaimyoId)<int.Parse(targetDaimyoId)){ gaikoTemp = activeDaimyoId + "gaikou" + targetDaimyoId; }else{ gaikoTemp = targetDaimyoId + "gaikou" + activeDaimyoId; } if(PlayerPrefs.HasKey(gaikoTemp)){ int gaikouValue = PlayerPrefs.GetInt(gaikoTemp); if(gaikouValue <30){ //Doumei Clear //src to dst doumeiTargetList.Remove(targetDaimyoId); string newDoumei1 = ""; for(int n=0; n<doumeiTargetList.Count; n++){ if(n==0){ newDoumei1 = doumeiTargetList[n]; }else{ newDoumei1 = newDoumei1 +"," + doumeiTargetList[n]; } } PlayerPrefs.SetString(temp,newDoumei1); //dst to src string tgtTemp = "doumei" + targetDaimyoId; string tgtDoumeiString = PlayerPrefs.GetString(tgtTemp); List<string> tgtDoumeiList = new List<string> (); if(tgtDoumeiString!=null && tgtDoumeiString != ""){ if(tgtDoumeiString.Contains(",")){ tgtDoumeiList = new List<string> (tgtDoumeiString.Split (delimiterChars)); }else{ tgtDoumeiList.Add(tgtDoumeiString); } tgtDoumeiList.Remove(activeDaimyoId); string newDoumei2 = ""; for(int n=0; n<tgtDoumeiList.Count; n++){ if(n==0){ newDoumei2 = tgtDoumeiList[n]; }else{ newDoumei2 = newDoumei2 +"," + tgtDoumeiList[n]; } } PlayerPrefs.SetString(tgtTemp,newDoumei2); } string srcDaimyoName = daimyo.getName(int.Parse(activeDaimyoId)); string dstDaimyoName = daimyo.getName(int.Parse(targetDaimyoId)); string doumeiClearText = "友好度悪化により、"+ srcDaimyoName+"と" + dstDaimyoName + "間の同盟が解消しました。"; messageList.Add (doumeiClearText); PlayerPrefs.Flush(); } } } } } } //Delete Cyouryaku Data string cyoryakuHst = PlayerPrefs.GetString("cyouryaku"); List<string> cyoryakuHstList = new List<string> (); if(cyoryakuHst != null && cyoryakuHst != ""){ if (cyoryakuHst.Contains (",")) { cyoryakuHstList = new List<string> (cyoryakuHst.Split (delimiterChars)); } else { cyoryakuHstList.Add (cyoryakuHst); } for (int i=0; i<cyoryakuHstList.Count; i++) { string tmp = cyoryakuHstList [i]; PlayerPrefs.DeleteKey (tmp); } PlayerPrefs.DeleteKey ("cyouryaku"); PlayerPrefs.Flush (); } /*Message*/ if (messageList.Count != 0) { /*Common Process*/ //make back string pathOfBack = "Prefabs/Common/TouchBack"; GameObject back = Instantiate(Resources.Load (pathOfBack)) as GameObject; back.transform.SetParent(GameObject.Find ("Panel").transform); back.transform.localScale = new Vector2 (1,1); back.transform.localPosition = new Vector2 (0,0); //make board string pathOfBoard = "Prefabs/Event/EventBoard"; GameObject board = Instantiate(Resources.Load (pathOfBoard)) as GameObject; board.transform.SetParent(GameObject.Find ("Panel").transform); board.transform.localScale = new Vector2 (1,1); string pathOfScroll = "Prefabs/Event/EventScrollView"; GameObject scroll = Instantiate(Resources.Load (pathOfScroll)) as GameObject; scroll.transform.SetParent(board.transform); scroll.transform.localScale = new Vector2 (1,1); RectTransform scrollTransform = scroll.GetComponent<RectTransform> (); scrollTransform.anchoredPosition = new Vector3 (0, -40, 0); string pathOfSlot = "Prefabs/Event/EventSlot"; foreach (string text in messageList) { GameObject slot = Instantiate(Resources.Load (pathOfSlot)) as GameObject; slot.transform.SetParent(scroll.transform.FindChild("Content").transform); slot.transform.FindChild("EventText").GetComponent<Text>().text = text; slot.transform.localScale = new Vector2 (1,1); } } }
public void OnClick(){ CloseBoard close = GameObject.Find ("close").GetComponent<CloseBoard> (); close.layer = close.layer + 1; int nowHyourou = PlayerPrefs.GetInt ("hyourou"); bool hyourouOKflg = false; //Kuni Qty Difference int myKuniQty = GameObject.Find ("GameController").GetComponent<MainStageController> ().myKuniQty; int tKuniQty = close.kuniQty; if (myKuniQty > tKuniQty) { kuniDiff = kuniDiff + myKuniQty - tKuniQty; } if (name == "Mitsugi") { //Menu Handling GameObject.Find ("kuniName").GetComponent<Text> ().text = "貢物"; OffGaikouMenu (); //Mitsugi Object string mitugiPath = "Prefabs/Map/gaikou/MitsugiObj"; GameObject mitsugiObj = Instantiate (Resources.Load (mitugiPath)) as GameObject; mitsugiObj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); mitsugiObj.transform.localScale = new Vector3 (1, 1, 1); //Do Button string buttonPath = "Prefabs/Map/gaikou/DoGaikouBtn"; GameObject btn = Instantiate (Resources.Load (buttonPath)) as GameObject; btn.transform.SetParent (mitsugiObj.transform); btn.transform.localScale = new Vector3 (1, 1, 1); btn.name = "DoMitsugiBtn"; RectTransform btn_transform = btn.GetComponent<RectTransform> (); btn_transform.anchoredPosition = new Vector3 (0, -200, 0); //Slider string sliderPath = "Prefabs/Map/common/MoneySlider"; GameObject slider = Instantiate (Resources.Load (sliderPath)) as GameObject; slider.transform.SetParent (mitsugiObj.transform); slider.transform.localScale = new Vector3 (1, 1.2f, 1); RectTransform slider_transform = slider.GetComponent<RectTransform> (); slider_transform.anchoredPosition = new Vector3 (-70, -90, 0); Slider sliderScript = slider.GetComponent<Slider> (); int nowMoney = PlayerPrefs.GetInt ("money"); nowMoney = nowMoney / 1000; if (nowMoney < 1) { sliderScript.enabled = false; } else { sliderScript.minValue = 1; btn.GetComponent<DoGaikou> ().moneyOKflg = true; btn.GetComponent<DoGaikou> ().paiedMoney = 1000; if (nowMoney < 10) { sliderScript.maxValue = nowMoney; } else { sliderScript.maxValue = 10; } } slider.GetComponent<MoneySlider> ().doBtn = btn; //Hyourou Check GaikouMenu gaikou = new GaikouMenu (); hyourouOKflg = gaikou.HyourouCheck (nowHyourou); btn.GetComponent<DoGaikou> ().hyourouOKflg = hyourouOKflg; //Busyo Scroll View gaikou.ScrollView (mitsugiObj, btn); //Set Obj GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = mitsugiObj; } else if (name == "Kyoutou") { //Menu Handling GameObject.Find ("kuniName").GetComponent<Text> ().text = "共闘"; OffGaikouMenu (); string path = "Prefabs/Map/gaikou/KyoutouObj"; GameObject obj = Instantiate (Resources.Load (path)) as GameObject; obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform); obj.transform.localScale = new Vector3 (1, 1, 1); //Do Button string buttonPath = "Prefabs/Map/gaikou/DoGaikouBtn"; GameObject btn = Instantiate (Resources.Load (buttonPath)) as GameObject; btn.transform.SetParent (obj.transform); btn.transform.localScale = new Vector3 (1, 1, 1); btn.name = "DoKyoutouBtn"; RectTransform btn_transform = btn.GetComponent<RectTransform> (); btn_transform.anchoredPosition = new Vector3 (0, -200, 0); btn.transform.FindChild ("Text").GetComponent<Text> ().text = "共闘"; //Money int nowMoney = PlayerPrefs.GetInt ("money"); if (nowMoney >= 3000) { btn.GetComponent<DoGaikou> ().moneyOKflg = true; } btn.GetComponent<DoGaikou> ().paiedMoney = 3000; //Hyourou Check GaikouMenu gaikou = new GaikouMenu (); hyourouOKflg = gaikou.HyourouCheck (nowHyourou); btn.GetComponent<DoGaikou> ().hyourouOKflg = hyourouOKflg; int daimyoId = GameObject.Find ("close").GetComponent<CloseBoard> ().daimyoId; kuniScrollView (obj, daimyoId.ToString (), btn); //Set Obj GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj; } else if (name == "Haki") { //Back Cover 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.anchoredPosition = new Vector3 (0, 0, 0); //Message Box string msgPath = "Prefabs/Map/gaikou/DoumeiHakiConfirm"; GameObject msg = Instantiate (Resources.Load (msgPath)) as GameObject; msg.transform.SetParent(GameObject.Find ("Panel").transform); msg.transform.localScale = new Vector2 (1, 1); RectTransform msgTransform = msg.GetComponent<RectTransform> (); msgTransform.anchoredPosition = new Vector3 (0, 0, 0); msgTransform.name = "DoumeiHakiConfirm"; int daimyoId = GameObject.Find ("close").GetComponent<CloseBoard> ().daimyoId; msg.transform.FindChild("YesButton").GetComponent<DoDoumeiHaki>().daimyoId = daimyoId; Daimyo daimyo = new Daimyo(); string daimyoName = daimyo.getName(daimyoId); msg.transform.FindChild("YesButton").GetComponent<DoDoumeiHaki>().daimyoName = daimyoName; close.layer = close.layer - 1; } }
void Start() { viewCurrentValue(); //Delete Previous Slot GameObject content = GameObject.Find("Content").gameObject; foreach (Transform obj in content.transform) { Destroy(obj.gameObject); } //Make Slot Shisya shisya = new Shisya(); Daimyo daimyo = new Daimyo(); bool ClickFlg = false; for (int i = 1; i < 22; i++) { string tmp = "shisya" + i.ToString(); if (PlayerPrefs.HasKey(tmp)) { //Exist string shisyaString = PlayerPrefs.GetString(tmp); List <string> shisyaList = new List <string> (); char[] delimiterChars = { ',' }; if (shisyaString != null && shisyaString != "") { if (shisyaString.Contains(",")) { shisyaList = new List <string> (shisyaString.Split(delimiterChars)); } else { shisyaList.Add(shisyaString); } } for (int j = 0; j < shisyaList.Count; j++) { string shisyaParam = shisyaList [j]; List <string> shisyaParamList = new List <string> (); char[] delimiterChars2 = { ':' }; if (shisyaParam.Contains(":")) { shisyaParamList = new List <string> (shisyaParam.Split(delimiterChars2)); } else { shisyaParamList.Add(shisyaParam); } //Common string slotName = shisya.getSlot(i); string slotPath = "Prefabs/Shisya/Slot/" + slotName; GameObject slotObj = Instantiate(Resources.Load(slotPath)) as GameObject; slotObj.transform.SetParent(content.transform); slotObj.transform.localScale = new Vector2(1, 1); slotObj.transform.localPosition = new Vector3(0, 0, 0); string title = shisya.getName(i); slotObj.transform.FindChild("Title").GetComponent <Text> ().text = title; ShisyaSelect script = slotObj.GetComponent <ShisyaSelect> (); if (slotName == "DaimyoSlot") { string daimyoId = shisyaParamList [0]; string imagePath = "Prefabs/Kamon/" + daimyoId.ToString(); slotObj.transform.FindChild("Back").GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; //Choose Buka int daimyoBusyoId = daimyo.getDaimyoBusyoId(int.Parse(daimyoId)); int busyoId = getRandomBusyo(int.Parse(daimyoId), daimyoBusyoId); string busyoImagePath = "Prefabs/Player/Sprite/unit" + busyoId.ToString(); slotObj.transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(busyoImagePath, typeof(Sprite)) as Sprite; BusyoInfoGet busyo = new BusyoInfoGet(); string busyoName = busyo.getName(busyoId); string daimyoName = daimyo.getName(int.Parse(daimyoId)); if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = daimyoName + "'s retainer :" + busyoName; } else { script.shisyaName = daimyoName + "配下 " + busyoName; } } else if (slotName == "SyogunSlot") { int syogunId = PlayerPrefs.GetInt("syogunDaimyoId"); string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); if (seiryokuList.Contains(syogunId.ToString())) { string imagePath = "Prefabs/Kamon/" + syogunId.ToString(); slotObj.transform.FindChild("Back").GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; string daimyoName = daimyo.getName(syogunId); if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = " Syogun " + daimyoName + "'s retainer"; } else { script.shisyaName = "将軍" + daimyoName + "配下"; } } else { PlayerPrefs.DeleteKey("shisya" + i.ToString()); } } else { if (i == 13 || i == 15 || i == 16 || i == 17) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Nobleman"; } else { script.shisyaName = "貴族"; } } else if (i == 18) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Merchant"; } else { script.shisyaName = "商人"; } } else if (i == 19) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Westerner"; } else { script.shisyaName = "南蛮人"; } } else if (i == 20) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Monk"; } else { script.shisyaName = "僧"; } } else if (i == 21) { if (Application.systemLanguage != SystemLanguage.Japanese) { script.shisyaName = "Local Samurai"; } else { script.shisyaName = "国人衆"; } } } //Random Handling string requried1 = shisya.getYesRequried1(i); if (requried1 == "random") { randomMyKahouView(slotObj); } else if (requried1 == "randomKahou") { randomSalesKahouView(slotObj); } //Set Value script.shisyaId = i; script.title = title; script.Content = content; int rdm = UnityEngine.Random.Range(1, 4); //1-3 string serihu = ""; if (rdm == 1) { serihu = shisya.getSerihu1(i); } else if (rdm == 2) { serihu = shisya.getSerihu2(i); } else if (rdm == 3) { serihu = shisya.getSerihu3(i); } serihu = serihuChanger(i, serihu, shisyaParamList, slotObj); script.serihu = serihu; if (!ClickFlg) { ClickFlg = true; firstSlot = slotObj; } } } } if (firstSlot != null) { firstSlot.GetComponent <ShisyaSelect> ().OnClick(); } else { Application.LoadLevel("mainStage"); } }
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 FinMaker(GameObject panel) { string finPath = "Prefabs/clearOrGameOver/Fin"; GameObject finObj = Instantiate(Resources.Load(finPath)) as GameObject; finObj.transform.SetParent(panel.transform); finObj.transform.localScale = new Vector2(1, 1); finObj.transform.FindChild("ReStartBtn").GetComponent <ShowDaimyoSelect> ().fin = finObj; finObj.transform.FindChild("ReStartBtn").GetComponent <ShowDaimyoSelect> ().panel = panel; finObj.transform.FindChild("ReStartBtn").transform.FindChild("Question").GetComponent <QA> ().qaId = 12; int myDaimyo = PlayerPrefs.GetInt("myDaimyo"); Daimyo daimyo = new Daimyo(); int busyoId = daimyo.getDaimyoBusyoId(myDaimyo); string path = "Prefabs/Player/" + busyoId; GameObject prefab = Instantiate(Resources.Load(path)) as GameObject; prefab.transform.SetParent(finObj.transform); prefab.transform.localScale = new Vector2(50, 60); prefab.transform.localPosition = new Vector2(-170, 340); prefab.GetComponent <UnitMover> ().enabled = false; Destroy(prefab.GetComponent <PlayerHP>()); //Value Set GameObject eval = finObj.transform.FindChild("Eval").gameObject; GameObject Gunji = eval.transform.FindChild("Gunji").gameObject; GameObject Naisei = eval.transform.FindChild("Naisei").gameObject; GameObject Gaikou = eval.transform.FindChild("Gaikou").gameObject; GameObject Bouryaku = eval.transform.FindChild("Bouryaku").gameObject; //Gunji int TrackTotalKassenNo = PlayerPrefs.GetInt("TrackTotalKassenNo"); int TrackWinNo = PlayerPrefs.GetInt("TrackWinNo"); int TrackTettaiNo = PlayerPrefs.GetInt("TrackTettaiNo"); int TrackBiggestDaimyoId = PlayerPrefs.GetInt("TrackBiggestDaimyoId"); int TrackBiggestDaimyoHei = PlayerPrefs.GetInt("TrackBiggestDaimyoHei"); int TrackMyBiggestHei = PlayerPrefs.GetInt("TrackMyBiggestHei"); int TrackNewBusyoHireNo = PlayerPrefs.GetInt("TrackNewBusyoHireNo"); int TrackEarnMoney = PlayerPrefs.GetInt("TrackEarnMoney"); Gunji.transform.FindChild("KassenNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackTotalKassenNo.ToString(); int winRatio = Mathf.CeilToInt((float)TrackWinNo / (float)TrackTotalKassenNo * 100); if (TrackWinNo == 0) { winRatio = 0; } Gunji.transform.FindChild("WinRatio").transform.FindChild("Text").GetComponent <Text> ().text = winRatio.ToString() + "%"; Gunji.transform.FindChild("Tettai").transform.FindChild("Text").GetComponent <Text> ().text = TrackTettaiNo.ToString(); string daimyoName = daimyo.getName(TrackBiggestDaimyoId); Gunji.transform.FindChild("BiggestEnemy").transform.FindChild("Text").GetComponent <Text> ().text = daimyoName; Gunji.transform.FindChild("BiggestEnemyHei").transform.FindChild("Text").GetComponent <Text> ().text = TrackBiggestDaimyoHei.ToString(); Gunji.transform.FindChild("BiggestPlayerHei").transform.FindChild("Text").GetComponent <Text> ().text = TrackMyBiggestHei.ToString(); Gunji.transform.FindChild("NewBusyoHire").transform.FindChild("Text").GetComponent <Text> ().text = TrackNewBusyoHireNo.ToString(); Gunji.transform.FindChild("EarnMoney").transform.FindChild("Text").GetComponent <Text> ().text = TrackEarnMoney.ToString(); //Naisei int TrackGetMoneyNo = PlayerPrefs.GetInt("TrackGetMoneyNo"); int TrackGetHyourouNo = PlayerPrefs.GetInt("TrackGetHyourouNo"); int TrackGetSozaiNo = PlayerPrefs.GetInt("TrackGetSozaiNo"); int TrackBuildMoneyNo = PlayerPrefs.GetInt("TrackBuildMoneyNo"); int TrackJyosyuNinmeiNo = PlayerPrefs.GetInt("TrackJyosyuNinmeiNo"); int TrackTabibitoNo = PlayerPrefs.GetInt("TrackTabibitoNo"); int TrackIjinNo = PlayerPrefs.GetInt("TrackIjinNo"); int HstNanbansen = PlayerPrefs.GetInt("HstNanbansen"); Naisei.transform.FindChild("MoneyProfitQty").transform.FindChild("Text").GetComponent <Text> ().text = TrackGetMoneyNo.ToString(); Naisei.transform.FindChild("HyourouProfitQty").transform.FindChild("Text").GetComponent <Text> ().text = TrackGetHyourouNo.ToString(); Naisei.transform.FindChild("SozaiProfitQty").transform.FindChild("Text").GetComponent <Text> ().text = TrackGetSozaiNo.ToString(); Naisei.transform.FindChild("NaiseiInvestment").transform.FindChild("Text").GetComponent <Text> ().text = TrackBuildMoneyNo.ToString(); Naisei.transform.FindChild("JyosyuNinmeiNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackJyosyuNinmeiNo.ToString(); Naisei.transform.FindChild("TabibitoNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackTabibitoNo.ToString(); Naisei.transform.FindChild("IjinNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackIjinNo.ToString(); Naisei.transform.FindChild("Nanbansen").transform.FindChild("Text").GetComponent <Text> ().text = HstNanbansen.ToString(); //Gaikou int TrackGaikouNo = PlayerPrefs.GetInt("TrackGaikouNo"); int TrackGaikouMoneyNo = PlayerPrefs.GetInt("TrackGaikouMoneyNo"); int TrackDoumeiNo = PlayerPrefs.GetInt("TrackDoumeiNo"); int TrackCyouteiNo = PlayerPrefs.GetInt("TrackCyouteiNo"); int TrackSyouninNo = PlayerPrefs.GetInt("TrackSyouninNo"); int syogunDaimyoId = PlayerPrefs.GetInt("syogunDaimyoId"); string Bakuhu = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { Bakuhu = "Not Yet"; } else { Bakuhu = "未開闢"; } if (syogunDaimyoId == myDaimyo) { if (Application.systemLanguage != SystemLanguage.Japanese) { Bakuhu = "Done"; } else { Bakuhu = "開闢済"; } } bool soubujireiFlg = PlayerPrefs.GetBool("soubujireiFlg"); string Soubujirei = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { Soubujirei = "Not Yet"; } else { Soubujirei = "未施行"; } if (soubujireiFlg) { if (Application.systemLanguage != SystemLanguage.Japanese) { Soubujirei = "Done"; } else { Soubujirei = "施行済"; } } int TrackToubatsuNo = PlayerPrefs.GetInt("TrackToubatsuNo"); Gaikou.transform.FindChild("GaikouNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackGaikouNo.ToString(); Gaikou.transform.FindChild("GaikouMoney").transform.FindChild("Text").GetComponent <Text> ().text = TrackGaikouMoneyNo.ToString(); Gaikou.transform.FindChild("DoumeiNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackDoumeiNo.ToString(); Gaikou.transform.FindChild("CyouteiNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackCyouteiNo.ToString(); Gaikou.transform.FindChild("SyouninNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackSyouninNo.ToString(); Gaikou.transform.FindChild("Bakuhu").transform.FindChild("Text").GetComponent <Text> ().text = Bakuhu; Gaikou.transform.FindChild("Soubujirei").transform.FindChild("Text").GetComponent <Text> ().text = Soubujirei; Gaikou.transform.FindChild("ToubatsuNo").transform.FindChild("Text").GetComponent <Text> ().text = TrackToubatsuNo.ToString(); //Bouryaku int TrackBouryakuNo = PlayerPrefs.GetInt("TrackBouryakuNo"); int TrackBouryakuSuccessNo = PlayerPrefs.GetInt("TrackBouryakuSuccessNo"); int TrackCyouhouNo = PlayerPrefs.GetInt("TrackCyouhouNo"); int TrackRyugenNo = PlayerPrefs.GetInt("TrackRyugenNo"); int TrackGihouHei = PlayerPrefs.GetInt("TrackGihouHei"); int TrackCyouryakuNo = PlayerPrefs.GetInt("TrackCyouryakuNo"); int TrackLinkCutNo = PlayerPrefs.GetInt("TrackLinkCutNo"); int TrackSyuppeiNo = PlayerPrefs.GetInt("TrackSyuppeiNo"); Bouryaku.transform.FindChild("BouryakuQty").transform.FindChild("Text").GetComponent <Text> ().text = TrackBouryakuNo.ToString(); int successRatio = Mathf.CeilToInt((float)TrackBouryakuSuccessNo / (float)TrackBouryakuNo * 100); if (TrackBouryakuSuccessNo == 0) { successRatio = 0; } Bouryaku.transform.FindChild("BouryakuRatio").transform.FindChild("Text").GetComponent <Text> ().text = successRatio.ToString() + "%"; Bouryaku.transform.FindChild("Cyouhou").transform.FindChild("Text").GetComponent <Text> ().text = TrackCyouhouNo.ToString(); Bouryaku.transform.FindChild("Ryugen").transform.FindChild("Text").GetComponent <Text> ().text = TrackRyugenNo.ToString(); Bouryaku.transform.FindChild("GihouHei").transform.FindChild("Text").GetComponent <Text> ().text = TrackGihouHei.ToString(); Bouryaku.transform.FindChild("Cyouryaku").transform.FindChild("Text").GetComponent <Text> ().text = TrackCyouryakuNo.ToString(); Bouryaku.transform.FindChild("LinkCut").transform.FindChild("Text").GetComponent <Text> ().text = TrackLinkCutNo.ToString(); Bouryaku.transform.FindChild("Syuppei").transform.FindChild("Text").GetComponent <Text> ().text = TrackSyuppeiNo.ToString(); }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [0].Play(); //Panel GameObject.Find("Touyou").GetComponent <Canvas>().sortingLayerName = "unit"; //Pop View BusyoStatusButton pop = new BusyoStatusButton(); GameObject board = pop.commonPopup(27); if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("popText").GetComponent <Text> ().text = "Samurai Recruitment"; } else { GameObject.Find("popText").GetComponent <Text>().text = "武将登用"; } //Kamon string kamonPath = "Prefabs/Touyou/kamon"; GameObject kamon = Instantiate(Resources.Load(kamonPath)) as GameObject; kamon.transform.SetParent(board.transform); kamon.transform.localScale = new Vector2(1, 1); kamon.transform.localPosition = new Vector2(-310, 0); BusyoInfoGet busyoScript = new BusyoInfoGet(); int daimyoId = busyoScript.getDaimyoId(busyoId); if (daimyoId == 0) { daimyoId = busyoScript.getDaimyoHst(busyoId); } string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString(); kamon.GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; //Busyo View string path = "Prefabs/Player/Unit/BusyoUnit"; GameObject Busyo = Instantiate(Resources.Load(path)) as GameObject; Busyo.name = busyoId.ToString(); Busyo.transform.SetParent(board.transform); Busyo.transform.localScale = new Vector2(3.5f, 3.5f); Busyo.GetComponent <DragHandler>().enabled = false; RectTransform busyo_transform = Busyo.GetComponent <RectTransform>(); busyo_transform.anchoredPosition = new Vector3(350, 300, 0); busyo_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, busyoId); ShipObj.transform.localPosition = new Vector3(-40, -40, 0); ShipObj.transform.localScale = new Vector2(0.5f, 0.5f); 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 Busyo.transform.FindChild("Text").gameObject.GetComponent <Text>().enabled = false; //Rank Text Modification GameObject rank = Busyo.transform.FindChild("Rank").gameObject; RectTransform rank_transform = rank.GetComponent <RectTransform>(); rank_transform.anchoredPosition = new Vector3(0, -50, 0); rank_transform.sizeDelta = new Vector2(200, 200); rank.GetComponent <Text>().fontSize = 200; /*Status*/ string statusPath = "Prefabs/Touyou/busyoStatus"; GameObject status = Instantiate(Resources.Load(statusPath)) as GameObject; status.transform.SetParent(board.transform); status.transform.localScale = new Vector2(1, 1); RectTransform status_transform = status.GetComponent <RectTransform>(); status_transform.anchoredPosition = new Vector3(245, -40, 0); Entity_busyo_mst busyoMst = Resources.Load("Data/busyo_mst") as Entity_busyo_mst; Entity_senpou_mst senpouMst = Resources.Load("Data/senpou_mst") as Entity_senpou_mst; string busyoName = busyoScript.getName(busyoId); GameObject.Find("busyoNameValue").GetComponent <Text>().text = busyoName; GameObject.Find("TosotsuValue").GetComponent <Text>().text = busyoMst.param [busyoId - 1].minHp.ToString() + "00"; GameObject.Find("BuyuuValue").GetComponent <Text> ().text = busyoMst.param [busyoId - 1].minAtk.ToString() + "0"; GameObject.Find("ChiryakuValue").GetComponent <Text>().text = busyoMst.param [busyoId - 1].minDfc.ToString() + "0"; GameObject.Find("SpeedValue").GetComponent <Text>().text = busyoMst.param [busyoId - 1].minSpd.ToString(); string heisyuType = busyoMst.param [busyoId - 1].heisyu; string heisyu = ""; Message msg = new Message(); if (heisyuType == "KB") { heisyu = msg.getMessage(55); } else if (heisyuType == "YR") { heisyu = msg.getMessage(56); } else if (heisyuType == "TP") { heisyu = msg.getMessage(57); } else if (heisyuType == "YM") { heisyu = msg.getMessage(58); } GameObject.Find("ChildNameValue").GetComponent <Text>().text = heisyu; int senpouId = busyoMst.param [busyoId - 1].senpou_id; if (Application.systemLanguage != SystemLanguage.Japanese) { GameObject.Find("SenpouValue").GetComponent <Text>().text = senpouMst.param[senpouId - 1].nameEng; } else { GameObject.Find("SenpouValue").GetComponent <Text>().text = senpouMst.param[senpouId - 1].name; } int senpouStatus = senpouMst.param [senpouId - 1].lv1; int each = (int)senpouMst.param [senpouId - 1].each; int ratio = (int)senpouMst.param [senpouId - 1].ratio; int term = (int)senpouMst.param [senpouId - 1].term; string senpouExp = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { senpouExp = senpouMst.param [senpouId - 1].effectionEng; } else { senpouExp = senpouMst.param[senpouId - 1].effection; } if (Application.systemLanguage != SystemLanguage.Japanese) { senpouExp = senpouExp.Replace("ABC", senpouStatus.ToString()); senpouExp = senpouExp.Replace("DEF", each.ToString()); senpouExp = senpouExp.Replace("GHI", ratio.ToString()); senpouExp = senpouExp.Replace("JKL", term.ToString()); } else { senpouExp = senpouExp.Replace("A", senpouStatus.ToString()); senpouExp = senpouExp.Replace("B", each.ToString()); senpouExp = senpouExp.Replace("C", ratio.ToString()); senpouExp = senpouExp.Replace("D", term.ToString()); } GameObject.Find("SenpouExpValue").GetComponent <Text>().text = senpouExp; /*Saku*/ Saku saku = new Saku(); List <string> sakuList = new List <string>(); sakuList = saku.getSakuInfo(busyoId); //Icon string sakuPath = "Prefabs/Saku/saku" + sakuList[0]; GameObject sakuIcon = Instantiate(Resources.Load(sakuPath)) as GameObject; GameObject StatusSaku = status.transform.FindChild("StatusSaku").gameObject; foreach (Transform n in StatusSaku.transform) { if (n.tag == "Saku") { GameObject.Destroy(n.gameObject); } } sakuIcon.transform.SetParent(StatusSaku.transform); sakuIcon.transform.localScale = new Vector2(0.7f, 0.7f); sakuIcon.GetComponent <Button>().enabled = false; RectTransform sakuIcon_transform = sakuIcon.GetComponent <RectTransform>(); sakuIcon_transform.anchoredPosition = new Vector3(-235, 0, 0); StatusSaku.transform.FindChild("SakuExp").transform.FindChild("SakuExpValue").GetComponent <Text>().text = sakuList[2]; /*daimyo busyo check*/ Daimyo daimyo = new Daimyo(); daimyoFlg = daimyo.daimyoBusyoCheck(busyoId); //pass data to button GameObject touyouBtn = GameObject.Find("TouyouButton").gameObject; touyouBtn.GetComponent <DoTouyou> ().busyoId = busyoId; touyouBtn.GetComponent <DoTouyou> ().busyoName = busyoName; touyouBtn.GetComponent <DoTouyou> ().heisyu = heisyuType; touyouBtn.GetComponent <DoTouyou> ().sequence = int.Parse(name); touyouBtn.GetComponent <DoTouyou> ().rank = busyoRank; touyouBtn.GetComponent <DoTouyou> ().daimyoFlg = daimyoFlg; //Tutorial if (Application.loadedLevelName == "tutorialTouyou") { TutorialController tutorialScript = new TutorialController(); Vector2 vect = new Vector2(0, 50); GameObject btn = tutorialScript.SetPointer(touyouBtn, vect); btn.transform.localScale = new Vector2(150, 150); } //Hired Check if (Application.loadedLevelName != "tutorialTouyou") { string myBusyo = PlayerPrefs.GetString("myBusyo"); char[] delimiterChars = { ',' }; if (myBusyo != null && myBusyo != "") { List <string> myBusyoList = new List <string>(); if (myBusyo.Contains(",")) { myBusyoList = new List <string>(myBusyo.Split(delimiterChars)); } else { myBusyoList.Add(myBusyo); } if (myBusyoList.Contains(busyoId.ToString())) { msg.makeMessage(msg.getMessage(137)); } } //Zukan Check string zukanBusyoHst = PlayerPrefs.GetString("zukanBusyoHst"); if (zukanBusyoHst != null && zukanBusyoHst != "") { List <string> myZukanList = new List <string>(); if (zukanBusyoHst.Contains(",")) { myZukanList = new List <string>(zukanBusyoHst.Split(delimiterChars)); } else { myZukanList.Add(zukanBusyoHst); } if (myZukanList.Contains(busyoId.ToString())) { string zukanPath = "Prefabs/Touyou/Zukan"; GameObject zukan = Instantiate(Resources.Load(zukanPath)) as GameObject; zukan.transform.SetParent(board.transform); zukan.transform.localScale = new Vector2(1, 1); zukan.transform.localPosition = new Vector2(-41, 167); } } } }
public void OnClick(){ if (close.GetComponent<CloseBoard> ().kuniId != kuniId) { close.GetComponent<CloseBoard> ().kuniId = kuniId; /*Status*/ //Common GameObject kuniIconView = GameObject.Find ("KuniIconView").gameObject; SendParam script = kuniIconView.transform.FindChild (kuniId.ToString ()).GetComponent<SendParam> (); KuniInfo kuni = new KuniInfo (); Daimyo daimyo = new Daimyo (); Gaikou gaikou = new Gaikou (); List<int> targetKuniList = new List<int> (); targetKuniList = kuni.getMappingKuni (kuniId); char[] delimiterChars = { ',' }; //Kamon GameObject daimyoNameObj = status.transform.FindChild ("DaimyoName").gameObject; string imagePath = "Prefabs/Kamon/MyDaimyoKamon/" + daimyoId.ToString (); daimyoNameObj.transform.FindChild ("Kamon").GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; //Daimyo Name daimyoNameObj.transform.FindChild ("Value").GetComponent<Text> ().text = daimyoName; //Kuni Name GameObject kuniNameObj = status.transform.FindChild ("KuniName").gameObject; kuniNameObj.transform.FindChild ("Value").GetComponent<Text> ().text = kuniName; //Heiryoku status.transform.FindChild ("Heiryoku").transform.FindChild ("Value").GetComponent<Text> ().text = script.heiryoku.ToString (); //Yukou status.transform.FindChild ("Yukoudo").transform.FindChild ("Value").GetComponent<Text> ().text = script.myYukouValue.ToString (); //Attack Target bool aggressiveFlg = script.aggressiveFlg; int myDaimyoId = PlayerPrefs.GetInt ("myDaimyo"); int targetKuniId = getKassenTargetKuni (kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId); if (targetKuniId != 0) { string targetKuniName = kuni.getKuniName (targetKuniId); int targetDaimyoId = int.Parse (seiryokuList [targetKuniId - 1]); string targetDaimyoName = daimyo.getName (targetDaimyoId); status.transform.FindChild ("Atk").transform.FindChild ("Value").GetComponent<Text> ().text = targetKuniName + "(" + targetDaimyoName + ")"; } else { status.transform.FindChild ("Atk").transform.FindChild ("Value").GetComponent<Text> ().text = "無し"; } int targetGaikouKuniId = 0; if (snbRank > 1) { //Jyo or Cyu //Gaikou targetGaikouKuniId = getGaikouTargetKuni (kuniId, daimyoId, targetKuniList, kuniIconView, aggressiveFlg, seiryokuList, myDaimyoId); if (targetGaikouKuniId != 0) { string targetGaikouKuniName = kuni.getKuniName (targetGaikouKuniId); int targetGaikouDaimyoId = int.Parse (seiryokuList [targetGaikouKuniId - 1]); string targetGaikouDaimyoName = daimyo.getName (targetGaikouDaimyoId); status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = targetGaikouKuniName + "(" + targetGaikouDaimyoName + ")"; } else { status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = "無し"; } //Doumei string doumeiTmp = "doumei" + daimyoId.ToString (); string doumeiString = PlayerPrefs.GetString (doumeiTmp); List<string> doumeiList = new List<string> (); if (doumeiString != null && doumeiString != "") { if (doumeiString.Contains (",")) { doumeiList = new List<string> (doumeiString.Split (delimiterChars)); } else { doumeiList.Add (doumeiString); } } string doumeiNameList = "無し"; for (int j = 0; j < doumeiList.Count; j++) { if (j == 0) { doumeiNameList = daimyo.getName (int.Parse (doumeiList [j])); } else { doumeiNameList = doumeiNameList + "," + daimyo.getName (int.Parse (doumeiList [j])); } } status.transform.FindChild ("Doumei").transform.FindChild ("Value").GetComponent<Text> ().text = doumeiNameList; } else { //Ge status.transform.FindChild ("Gaiko").transform.FindChild ("Value").GetComponent<Text> ().text = "?"; status.transform.FindChild ("Doumei").transform.FindChild ("Value").GetComponent<Text> ().text = "?"; } if (snbRank > 2) { //Jyo BusyoInfoGet busyo = new BusyoInfoGet(); string qtyAndHeisyu = busyo.getDaimyoBusyoQtyHeisyu(daimyoId); List<string> qtyAndHeisyuiList = new List<string> (); qtyAndHeisyuiList = new List<string> (qtyAndHeisyu.Split (delimiterChars)); //BusyoQty //Heisyu status.transform.FindChild ("BusyoQty").transform.FindChild ("Value").GetComponent<Text> ().text = qtyAndHeisyuiList[0]; status.transform.FindChild ("Heisyu").transform.FindChild ("Value").GetComponent<Text> ().text = qtyAndHeisyuiList[1]; } else { //Cyu or Ge status.transform.FindChild ("BusyoQty").transform.FindChild ("Value").GetComponent<Text> ().text = "?"; status.transform.FindChild ("Heisyu").transform.FindChild ("Value").GetComponent<Text> ().text = "?"; } //Main Map foreach(Transform obj in board.transform){ if (obj.name != "Explanation") { Destroy (obj.gameObject); } } string kuniMapPath = "Prefabs/Map/cyouhou/kuniImage"; GameObject mainMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject; mainMap.transform.SetParent(board.transform); mainMap.transform.localScale = new Vector2 (13, 9); mainMap.name = "kuniMap" + kuniId; string kuniImagePath = "Prefabs/Map/kuniMap/" + kuniId.ToString (); mainMap.GetComponent<Image> ().sprite = Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite; int baseX = kuni.getKuniLocationX (kuniId); int baseY = kuni.getKuniLocationY (kuniId); int adjstX = baseX * -1; int adjustY = baseY * -1; float colorR = daimyo.getColorR (daimyoId); float colorG = daimyo.getColorG (daimyoId); float colorB = daimyo.getColorB (daimyoId); Color kuniColor = new Color (colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); mainMap.GetComponent<Image> ().color = kuniColor; RectTransform mapRect = mainMap.GetComponent<RectTransform> (); mapRect.anchoredPosition3D = new Vector3 (adjstX, adjustY, 0); //My Kuni Kamon Icon string kamonBackPath ="Prefabs/Map/cyouhou/KamonBack"; GameObject kamonBack = Instantiate (Resources.Load (kamonBackPath)) as GameObject; kamonBack.transform.SetParent (board.transform); kamonBack.transform.localScale = new Vector2 (1, 1); kamonBack.transform.localPosition = new Vector2(0,0); string kamonKuniPath = "Prefabs/Map/Kuni/" + kuniId.ToString(); GameObject kamonObj = Instantiate (Resources.Load (kamonKuniPath)) as GameObject; kamonObj.transform.SetParent (kamonBack.transform); kamonObj.transform.localScale = new Vector2 (1, 0.8f); kamonObj.transform.localPosition = new Vector2(0,0); kamonObj.GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; kamonObj.GetComponent<Button> ().enabled = false; //Mapping Kuni Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst; for (int i=0; i < kuniMst.param.Count; i++) { //for (int i=0; i < targetKuniList.Count; i++) { int subKuniId = i + 1; GameObject subMap = Instantiate (Resources.Load (kuniMapPath)) as GameObject; subMap.transform.SetParent(mainMap.transform); subMap.transform.localScale = new Vector2 (1, 1); subMap.transform.localPosition = new Vector2 (0, 0); subMap.name = "kuniMap" + subKuniId; string subKuniImagePath = "Prefabs/Map/kuniMap/" + subKuniId; subMap.GetComponent<Image> ().sprite = Resources.Load (subKuniImagePath, typeof(Sprite)) as Sprite; if (targetKuniList.Contains (subKuniId)) { //color int subDaimyoId = int.Parse (seiryokuList [subKuniId - 1]); float subColorR = daimyo.getColorR (subDaimyoId); float subColorG = daimyo.getColorG (subDaimyoId); float subColorB = daimyo.getColorB (subDaimyoId); Color subKuniColor = new Color (subColorR / 255f, subColorG / 255f, subColorB / 255f, 255f / 255f); subMap.GetComponent<Image> ().color = subKuniColor; //Kamon string subKamonKuniPath = "Prefabs/Map/Kuni/" + subKuniId.ToString (); GameObject subKamonObj = Instantiate (Resources.Load (subKamonKuniPath)) as GameObject; subKamonObj.transform.SetParent (board.transform); subKamonObj.transform.localScale = new Vector2 (1, 0.8f); if (daimyoId != subDaimyoId) { string subImagePath = "Prefabs/Kamon/" + subDaimyoId.ToString (); subKamonObj.GetComponent<Image> ().sprite = Resources.Load (subImagePath, typeof(Sprite)) as Sprite; //yukoudo int yukoudoValue = gaikou.getExistGaikouValue (daimyoId, subDaimyoId); string syukoudoPath = "Prefabs/Map/cyouhou/YukoudoLabel"; GameObject yukoudoObj = Instantiate (Resources.Load (syukoudoPath)) as GameObject; yukoudoObj.transform.SetParent (subKamonObj.transform); yukoudoObj.GetComponent<Text> ().text = yukoudoValue.ToString (); yukoudoObj.transform.localScale = new Vector2 (0.08f, 0.1f); yukoudoObj.transform.localPosition = new Vector2 (0, 26); } else { subKamonObj.GetComponent<Image> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; } subKamonObj.GetComponent<Button> ().enabled = false; //Kamon adjustment int subBaseX = kuni.getKuniLocationX (subKuniId); int subBaseY = kuni.getKuniLocationY (subKuniId); int subAdjstX = subBaseX - baseX; int subAdjstY = subBaseY - baseY; RectTransform subMapRect = subKamonObj.GetComponent<RectTransform> (); subMapRect.anchoredPosition3D = new Vector3 (subAdjstX, subAdjstY, 0); if (targetKuniId != 0) { if (targetKuniId == subKuniId) { //kassen target Color atkColor = new Color (180f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); subKamonObj.GetComponent<Image> ().color = atkColor; } } if (snbRank > 1) { if (targetGaikouKuniId != 0) { if (targetGaikouKuniId == subKuniId) { //kassen target Color gaikouColor = new Color (80f / 255f, 100f / 255f, 185f / 255f, 255f / 255f); subKamonObj.GetComponent<Image> ().color = gaikouColor; } } } } else { Color noSubKuniColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 40f / 255f); subMap.GetComponent<Image> ().color = noSubKuniColor; } } } }
public 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 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 OnClick(){ Message msg = new Message(); Gaikou gaikou = new Gaikou (); int nowHyourou = PlayerPrefs.GetInt ("hyourou"); CloseBoard closeScript = GameObject.Find ("close").GetComponent<CloseBoard> (); int daimyoBusyoAtk = closeScript.daimyoBusyoAtk; int daimyoBusyoDfc = closeScript.daimyoBusyoDfc; int daimyoId = closeScript.daimyoId; int kuniId = closeScript.kuniId; if(nowHyourou >= 5){ if (name == "DoGihouBtn") { //Reduce Hyourou reduceHyourou (); //Reduce Shinobi //Ratio //Ge 5-15%, Cyu 15-30%, Jyo 30-50% int randomPercent = 0; int newQty = itemQty - 1; if(itemRank == "Ge"){ randomPercent = UnityEngine.Random.Range(5,15); PlayerPrefs.SetInt ("shinobiGe",newQty); }else if(itemRank == "Cyu"){ randomPercent = UnityEngine.Random.Range(15,30); PlayerPrefs.SetInt ("shinobiCyu",newQty); }else if(itemRank == "Jyo"){ randomPercent = UnityEngine.Random.Range(30,50); PlayerPrefs.SetInt ("shinobiJyo",newQty); } float ratio = (float)randomPercent; float percent = Random.value; percent = percent * 100; if(percent <= ratio){ //OK //Delete Gunzei Destroy(Gunzei); //Delete Key string gunzeiKey = Gunzei.name; PlayerPrefs.DeleteKey(gunzeiKey); //Delete Key History char[] delimiterChars = {','}; string keyHistory = PlayerPrefs.GetString ("keyHistory"); List<string> keyHistoryList = new List<string>(); if (keyHistory != null && keyHistory != "") { if(keyHistory.Contains(",")){ keyHistoryList = new List<string> (keyHistory.Split (delimiterChars)); }else{ keyHistoryList.Add(keyHistory); } } keyHistoryList.Remove(gunzeiKey); string newKeyHistory = ""; for(int i=0; i<keyHistoryList.Count; i++){ if(i==0){ newKeyHistory = keyHistoryList[i]; }else{ newKeyHistory = newKeyHistory + "," + keyHistoryList[i]; } } PlayerPrefs.SetString("keyHistory",newKeyHistory); //Message string daimyoName = Gunzei.GetComponent<Gunzei>().srcDaimyoName; string OKtext = "御屋形様、偽報に成功しましたぞ。\t " + daimyoName + "の軍勢が退却します。"; msg.makeMessage (OKtext); }else{ //NG int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId,nowYukoudo,maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find ("YukouValue").GetComponent<Text> ().text = newYukoudo.ToString (); //Message string NGtext = "申し訳御座りませぬ。偽報に失敗しましたぞ。\t友好度が" + reduceYukoudo + "下がりますぞ。"; msg.makeMessage (NGtext); } PlayerPrefs.Flush(); //Back GameObject.Find ("return").GetComponent<MenuReturn> ().OnClick (); }else if(name == "DoRyugenBtn"){ //Reduce Hyourou reduceHyourou (); //Ratio //Ge 10-20%, Cyu 20-40%, Jyo 40-70% float randomPercent = 0; int newQty = itemQty - 1; if(itemRank == "Ge"){ float tempRandomPercent = (150 - daimyoBusyoDfc)/4; float tempValue = UnityEngine.Random.Range(0.5f,1.5f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt ("shinobiGe",newQty); }else if(itemRank == "Cyu"){ float tempRandomPercent = (150 - daimyoBusyoDfc)/2; float tempValue = UnityEngine.Random.Range(0.8f,1.2f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt ("shinobiCyu",newQty); }else if(itemRank == "Jyo"){ float tempRandomPercent = (150 - daimyoBusyoDfc); float tempValue = UnityEngine.Random.Range(0.9f,1.1f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt ("shinobiJyo",newQty); } float percent = Random.value; percent = percent * 100; if(percent <= randomPercent){ //Success //Daimyo Id int srcDaimyoId = GameObject.Find ("close").GetComponent<CloseBoard> ().daimyoId; //Seiryoku List string seiryoku = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string> (); char[] delimiterChars = {','}; seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); //src daimyo kuni list List<string> srcDaimyoKuniList = new List<string> (); for(int i=0; i<seiryokuList.Count;i++){ string tempDaimyoId = seiryokuList[i]; if(tempDaimyoId == srcDaimyoId.ToString()){ int temp = i + 1; srcDaimyoKuniList.Add(temp.ToString()); } } //src daimyo open kuni list KuniInfo kuni = new KuniInfo(); List<int> openKuniList = new List<int>(); for(int j=0; j<srcDaimyoKuniList.Count; j++){ openKuniList.AddRange(kuni.getMappingKuni(int.Parse(srcDaimyoKuniList[j]))); } //Target Daimyo (exculde this src daimyo & mydaimyo) int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); List<int> dstDaimyoList = new List<int>(); for(int k=0; k<openKuniList.Count;k++){ int temp = openKuniList[k] - 1; int tempDaimyoId = int.Parse(seiryokuList[temp]); if(tempDaimyoId != myDaimyo && tempDaimyoId != srcDaimyoId){ if(!dstDaimyoList.Contains(tempDaimyoId)){ dstDaimyoList.Add(tempDaimyoId); } } } //Reduce Yukoudo MainEventHandler main = new MainEventHandler(); Daimyo daimyo = new Daimyo(); string ryugenText = ""; for(int l=0; l<dstDaimyoList.Count;l++){ int dstDaimyoId = dstDaimyoList[l]; string dstDaimyoName = daimyo.getName(dstDaimyoId); int reduceYukoudo = main.DownYukouValueWithOther(srcDaimyoId,dstDaimyoId); reduceYukoudo = reduceYukoudo/2; if(reduceYukoudo==0){ reduceYukoudo=1; } ryugenText = ryugenText + dstDaimyoName + "との友好度が" + reduceYukoudo + "下がりました。\t"; } //Message string OKtext = "御屋形様、流言に成功しましたぞ。\t " + ryugenText; msg.makeMessage (OKtext); }else{ //Failed //Message int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId,nowYukoudo,maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find ("YukouValue").GetComponent<Text> ().text = newYukoudo.ToString (); //Message string NGtext = "申し訳御座りませぬ。流言に失敗しましたぞ。\t友好度が" + reduceYukoudo + "下がりますぞ。"; msg.makeMessage (NGtext); } PlayerPrefs.Flush(); //Back GameObject.Find ("return").GetComponent<MenuReturn> ().OnClick (); }else if(name == "DoGoudatsuBtn"){ reduceHyourou (); //Ratio //Ge 10-20%, Cyu 20-40%, Jyo 40-70% float randomPercent = 0; int newQty = itemQty - 1; if(itemRank == "Ge"){ float tempRandomPercent = (150 - daimyoBusyoDfc)/4; float tempValue = UnityEngine.Random.Range(0.5f,1.5f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt ("shinobiGe",newQty); }else if(itemRank == "Cyu"){ float tempRandomPercent = (150 - daimyoBusyoDfc)/2; float tempValue = UnityEngine.Random.Range(0.8f,1.2f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt ("shinobiCyu",newQty); }else if(itemRank == "Jyo"){ float tempRandomPercent = (150 - daimyoBusyoDfc); float tempValue = UnityEngine.Random.Range(0.9f,1.1f); randomPercent = tempRandomPercent * tempValue; PlayerPrefs.SetInt ("shinobiJyo",newQty); } float percent = Random.value; percent = percent * 100; if(percent <= randomPercent){ //Success int kuniQty = GameObject.Find("close").GetComponent<CloseBoard>().kuniQty; int getMoney =0; //Money or Item 0:money, 1:item int moneyOrItem = UnityEngine.Random.Range(0,2); //Kahou or Shizai 0:kahou, 1:shizai int kahouOrShizai = UnityEngine.Random.Range(0,2); string kahouName = ""; string shigenName = ""; int addQty =0; int kahouRank = 0; //kahouRank S,A,B,C=1,2,3,4 //shigen Type int shigenType = 0; //KB,YR,TP,YM=1,2,3,4 if(moneyOrItem==0){ //money int temGetMoney = UnityEngine.Random.Range(1000,1501); getMoney = temGetMoney * kuniQty; int nowMoney = PlayerPrefs.GetInt("money"); nowMoney = nowMoney + getMoney; PlayerPrefs.SetInt("money",nowMoney); PlayerPrefs.Flush(); }else{ //item //Kahou or Shizai 0:kahou, 1:shizai kahouOrShizai = UnityEngine.Random.Range(0,2); if(kahouOrShizai==0){ //kahou Kahou kahou = new Kahou(); ////Bugu, Gusoku, Kabuto, Meiba, Heihousyo, Cyadougu, Chishikisyo(1,2,3,4,5,6) int kahouType = UnityEngine.Random.Range(1,7); float khPercent = Random.value; khPercent = khPercent * 100; if(5<=kuniQty){ //(S,A,B 5,35,60%) if(khPercent<=5){ //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(5<khPercent && khPercent <=41){ //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(41<khPercent){ //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } }else if(3<=kuniQty && kuniQty<5){ //(S,A,B,C : 1,15,25,59%) if(khPercent<=1){ //S kahouRank = 1; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(1<khPercent && khPercent <=16){ //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(16<khPercent && khPercent <= 41){ //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(41<khPercent){ //C kahouRank = 4; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } }else if(kuniQty<3){ //(A,B,C : 5, 35, 60%) if(khPercent<=5){ //A kahouRank = 2; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(5<khPercent && khPercent <=41){ //B kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); }else if(41<khPercent){ //C kahouRank = 3; kahouName = kahou.getRamdomKahou(kahouType, kahouRank); } } }else{ //shizai shigenType = UnityEngine.Random.Range(1,5); float sgPercent = Random.value; sgPercent = sgPercent * 100; addQty = UnityEngine.Random.Range(1,6); Item item = new Item(); int shigenRank = 0;//下、中、上=1,2,3 if(5<=kuniQty){ //(上,中,下 40,40, 20%) if(sgPercent<=40){ shigenRank = 3; }else if(40<sgPercent && sgPercent <=81){ shigenRank = 2; }else if(81<sgPercent){ shigenRank = 1; } shigenName = item.getRandomShigen(shigenType,shigenRank,addQty); }else if(3<=kuniQty && kuniQty<5){ //(上,中,下 20,50,30%) if(sgPercent<=20){ shigenRank = 3; }else if(20<sgPercent && sgPercent <=51){ shigenRank = 2; }else if(51<sgPercent){ shigenRank = 1; } shigenName = item.getRandomShigen(shigenType,shigenRank,addQty); }else if(kuniQty<3){ //(上,中,下 5,25,70%) if(sgPercent<=5){ shigenRank = 3; }else if(5<sgPercent && sgPercent <=26){ shigenRank = 2; }else if(26<sgPercent){ shigenRank = 1; } shigenName = item.getRandomShigen(shigenType,shigenRank,addQty); } } } //Message string OKtext = "御屋形様、強奪に成功しましたぞ。\t "; string addText = ""; if(moneyOrItem==0){ addText = "金を" + getMoney + "奪って参りました。"; }else{ if(kahouOrShizai==0){ //kahou addText = "家宝、" + kahouName + "を奪って参りました。"; }else{ //shizai+ addText = shigenName + "を" + addQty + "個奪って参りました。"; } } OKtext = OKtext + addText; msg.makeMessage (OKtext); }else{ //Failed int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId,nowYukoudo,maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find ("YukouValue").GetComponent<Text> ().text = newYukoudo.ToString (); //Message string NGtext = "申し訳御座りませぬ。強奪に失敗しましたぞ。\t友好度が" + reduceYukoudo + "下がりますぞ。"; msg.makeMessage (NGtext); } PlayerPrefs.Flush(); //Back GameObject.Find ("return").GetComponent<MenuReturn> ().OnClick (); }else if(name == "DoCyouhouBtn"){ reduceHyourou (); //Set Value & REduce Qty float missPercent = 0; int newQty = itemQty - 1; int snbValue = 0; if(itemRank == "Ge"){ missPercent = 30; PlayerPrefs.SetInt ("shinobiGe",newQty); snbValue = 1; }else if(itemRank == "Cyu"){ missPercent = 15; PlayerPrefs.SetInt ("shinobiCyu",newQty); snbValue = 2; }else if(itemRank == "Jyo"){ missPercent = 5; PlayerPrefs.SetInt ("shinobiJyo",newQty); snbValue = 3; } //Random Check float percent = Random.value; percent = percent * 100; if (percent >= missPercent) { //Success string cyouhouHist = PlayerPrefs.GetString("cyouhou"); char[] delimiterChars = {','}; List<string> cyouhouHistList = new List<string> (); if (cyouhouHist != null && cyouhouHist != "") { if (cyouhouHist.Contains (",")) { cyouhouHistList = new List<string> (cyouhouHist.Split (delimiterChars)); } else { cyouhouHistList.Add (cyouhouHist); } } //Add new kuni if (!cyouhouHistList.Contains (kuniId.ToString())) { cyouhouHistList.Add (kuniId.ToString()); } string newCyouhouHist = ""; for(int i=0;i<cyouhouHistList.Count;i++){ string tmpCyouhouKuniId = cyouhouHistList [i]; if (i == 0) { newCyouhouHist = tmpCyouhouKuniId; } else { newCyouhouHist = newCyouhouHist + "," + tmpCyouhouKuniId; } } PlayerPrefs.SetString("cyouhou",newCyouhouHist); string cyouhouKuni = "cyouhou" + kuniId.ToString (); PlayerPrefs.SetInt(cyouhouKuni,snbValue); bool cyouhouFlg = closeScript.cyouhouFlg; if (cyouhouFlg) { //Change Icon GameObject shinobi = GameObject.Find("shinobi").gameObject; if (snbValue == 1) { Color lowColor = new Color (0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f); shinobi.GetComponent<Image>().color = lowColor; shinobi.transform.FindChild("ShinobiRank").GetComponent<Text>().text = "下"; } else if (snbValue == 2) { Color midColor = new Color (94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent<Image>().color = midColor; shinobi.transform.FindChild("ShinobiRank").GetComponent<Text>().text = "中"; } else if (snbValue == 3) { Color highColor = new Color (84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f); shinobi.GetComponent<Image>().color = highColor; shinobi.transform.FindChild("ShinobiRank").GetComponent<Text>().text = "上"; } GameObject kuniIconView = GameObject.Find ("KuniIconView").gameObject; kuniIconView.transform.FindChild(kuniId.ToString()).GetComponent<SendParam>().cyouhouSnbRankId = snbValue; } KuniInfo kuni = new KuniInfo(); string kuniName = kuni.getKuniName (kuniId); string OKtext = "忍が上手く"+kuniName+"に潜伏しましたぞ。\n諜報内容をご確認下され。"; msg.makeMessage (OKtext); } else { //Fail int nowYukoudo = gaikou.getMyGaikou(daimyoId); int newYukoudo = gaikou.downMyGaikou(daimyoId,nowYukoudo,maxReduceValue); int reduceYukoudo = nowYukoudo - newYukoudo; GameObject.Find ("YukouValue").GetComponent<Text> ().text = newYukoudo.ToString (); string NGtext = "忍が捕まってしまったようです。\t友好度が" + reduceYukoudo + "下がりますぞ。"; msg.makeMessage (NGtext); } PlayerPrefs.Flush(); //Back GameObject.Find ("return").GetComponent<MenuReturn> ().OnClick (); } } else { string NGtext = "御屋形様、兵糧が不足しておりますぞ。"; msg.makeMessage (NGtext); } }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource>(); audioSources[0].Play(); //Common string simpaleBattlePath = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { simpaleBattlePath = "Prefabs/SimpleBattle/BattleBoardEng"; } else { simpaleBattlePath = "Prefabs/SimpleBattle/BattleBoard"; } GameObject boardObj = Instantiate(Resources.Load(simpaleBattlePath)) as GameObject; boardObj.transform.SetParent(GameObject.Find("Map").transform); boardObj.transform.localScale = new Vector2(45, 55); boardObj.transform.FindChild("No").GetComponent <CloseSimpleBattle>().boardObj = boardObj; GameObject battleArea = boardObj.transform.FindChild("Base").transform.FindChild("BattleArea").gameObject; GameObject YesBtn = boardObj.transform.FindChild("Yes").gameObject; GameObject NoBtn = boardObj.transform.FindChild("No").gameObject; GetComponent <Button>().enabled = false; NoBtn.GetComponent <CloseSimpleBattle>().katanaBtnObj = gameObject; boardObj.name = "BattleBoard"; //Time Stop GameObject timer = transform.parent.gameObject; timer.GetComponent <ShiroAttack>().rakujyoFlg = true; NoBtn.GetComponent <CloseSimpleBattle>().timer = timer; //View Player int jinkei = PlayerPrefs.GetInt("jinkei"); string soudaisyoLabel = "soudaisyo" + jinkei; int soudaisyoId = PlayerPrefs.GetInt(soudaisyoLabel); if (soudaisyoId != 0) { makeSimplePlayer(soudaisyoId, true, battleArea, 0, YesBtn); } for (int i = 1; i < 26; i++) { string mapId = jinkei.ToString() + "map" + i.ToString(); int busyoId = PlayerPrefs.GetInt(mapId); if (busyoId != 0) { if (soudaisyoId != busyoId) { makeSimplePlayer(busyoId, false, battleArea, i, YesBtn); } } } //Same Daimyo Check bool sameDaimyoOnFlg = false; foreach (GameObject playerObj in GameObject.FindGameObjectsWithTag("Player")) { int belongDaimyoId = playerObj.GetComponent <SimpleHP>().belongDaimyoId; foreach (GameObject playerObj2 in GameObject.FindGameObjectsWithTag("Player")) { if (playerObj2.GetComponent <SimpleHP>().belongDaimyoId == belongDaimyoId) { playerObj.GetComponent <SimpleHP>().numSameDaimyo = playerObj.GetComponent <SimpleHP>().numSameDaimyo + 1; if (playerObj.GetComponent <SimpleHP>().numSameDaimyo == 2) { sameDaimyoOnFlg = true; } } } } //Power Up Effection if (myDaimyoBusyoFlg) { foreach (GameObject busyoObj in GameObject.FindGameObjectsWithTag("Player")) { int atk = busyoObj.GetComponent <SimpleAttack>().baseAtk; int dfc = busyoObj.GetComponent <SimpleHP>().baseDfc; int addAtk = Mathf.CeilToInt((float)atk * (float)addRatioForMyDaimyoBusyo) / 100; int addDfc = Mathf.CeilToInt((float)dfc * (float)addRatioForMyDaimyoBusyo) / 100; atk = atk + addAtk; dfc = dfc + addDfc; busyoObj.GetComponent <SimpleAttack>().atk = Mathf.FloorToInt(atk); busyoObj.GetComponent <SimpleHP>().dfc = Mathf.FloorToInt(dfc); } } if (sameDaimyoOnFlg) { foreach (GameObject busyoObj in GameObject.FindGameObjectsWithTag("Player")) { int totalAtk = busyoObj.GetComponent <SimpleAttack>().baseAtk; int totalDfc = busyoObj.GetComponent <SimpleHP>().baseDfc; int atk = busyoObj.GetComponent <SimpleAttack>().atk; int dfc = busyoObj.GetComponent <SimpleHP>().dfc; int numSameDaimyo = busyoObj.GetComponent <SimpleHP>().numSameDaimyo; int addRatio = (numSameDaimyo - 1) * 5; busyoObj.GetComponent <SimpleAttack>().atk = atk + Mathf.FloorToInt(((float)totalAtk * (float)addRatio) / 100); busyoObj.GetComponent <SimpleHP>().dfc = dfc + Mathf.FloorToInt(((float)totalDfc * (float)addRatio) / 100); } } /**View Enemy**/ //makeSimpleEnemy(enemyBusyoId, battleArea, 0); int stageId = timer.GetComponent <ShiroAttack>().toStageId; char[] delimiterChars = { ':' }; List <string> chldBusyoList = new List <string>(); foreach (GameObject gunzeiObj in GameObject.FindGameObjectsWithTag("StageGunzei")) { int gunzeiToStageId = gunzeiObj.GetComponent <TabStageGunzei>().toStageId; if (stageId == gunzeiToStageId) { int prnt_busyoId = gunzeiObj.GetComponent <TabStageGunzei>().taisyoBusyoId; makeSimpleEnemy(prnt_busyoId, battleArea, 0, YesBtn); string chld_busyoId = gunzeiObj.GetComponent <TabStageGunzei>().busyoString; if (chld_busyoId != "") { if (chld_busyoId.Contains(":")) { chldBusyoList.AddRange(new List <string>(chld_busyoId.Split(delimiterChars))); } else { chldBusyoList.Add(chld_busyoId); } } } } for (int j = 0; j < chldBusyoList.Count; j++) { int chldBusyoId = int.Parse(chldBusyoList[j]); makeSimpleEnemy(chldBusyoId, battleArea, j, YesBtn); } //View Daimyo daimyScript = new Daimyo(); int myDaimyoId = PlayerPrefs.GetInt("myDaimyo"); string myDaimyoName = daimyScript.getName(myDaimyoId); string enemyDaimyoName = daimyScript.getName(enemyDaimyoId); GameObject baseObj = boardObj.transform.FindChild("Base").gameObject; if (Application.systemLanguage != SystemLanguage.Japanese) { baseObj.transform.FindChild("Player").transform.FindChild("Name").GetComponent <TextMesh>().text = myDaimyoName; baseObj.transform.FindChild("Enemy").transform.FindChild("Name").GetComponent <TextMesh>().text = enemyDaimyoName; } else { baseObj.transform.FindChild("Player").transform.FindChild("Name").GetComponent <TextMesh>().text = myDaimyoName + "軍"; baseObj.transform.FindChild("Enemy").transform.FindChild("Name").GetComponent <TextMesh>().text = enemyDaimyoName + "軍"; } simpleHPCounter playerHPScript = baseObj.transform.FindChild("Player").transform.FindChild("Hei").GetComponent <simpleHPCounter>(); simpleHPCounter enemyHPScript = baseObj.transform.FindChild("Enemy").transform.FindChild("Hei").GetComponent <simpleHPCounter>(); playerHPScript.board = boardObj; enemyHPScript.board = boardObj; enemyHPScript.stageId = stageId; playerHPScript.katanaBtnObj = gameObject; playerHPScript.timer = timer; playerHPScript.stageId = stageId; }
// 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 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 changeKuniIconAndParam(int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId) { //Change Icon string imagePath = "Prefabs/Kamon/" + srcDaimyoId.ToString(); GameObject kuniIconView = GameObject.Find("KuniIconView"); GameObject targetKuni = kuniIconView.transform.FindChild(dstKuni.ToString()).gameObject; targetKuni.GetComponent <Image> ().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite; //Change Tochi Color GameObject KuniMap = GameObject.Find("KuniMap"); Daimyo daimyoScript = new Daimyo(); float colorR = daimyoScript.getColorR(srcDaimyoId); float colorG = daimyoScript.getColorG(srcDaimyoId); float colorB = daimyoScript.getColorB(srcDaimyoId); Color kuniColor = new Color(colorR / 255f, colorG / 255f, colorB / 255f, 255f / 255f); KuniMap.transform.FindChild(dstKuni.ToString()).GetComponent <Image> ().color = kuniColor; //Change Yukoudo string tmp = "gaikou" + srcDaimyoId; int yukoudo = PlayerPrefs.GetInt(tmp); targetKuni.GetComponent <SendParam> ().myYukouValue = yukoudo; /*Change Param*/ //Set Senryoku string seiryoku = PlayerPrefs.GetString("seiryoku"); List <string> seiryokuList = new List <string> (); char[] delimiterChars = { ',' }; seiryokuList = new List <string> (seiryoku.Split(delimiterChars)); /*Get Winner Kuni Qty*/ EnemySenryokuCalc calc = new EnemySenryokuCalc(); int myKuniQty = GameObject.Find("GameController").GetComponent <MainStageController> ().myKuniQty; //int enemyKuniQty = kuniIconView.transform.FindChild (srcKuni.ToString ()).GetComponent<SendParam> ().kuniQty; //int newEnemyKuniQty = enemyKuniQty + 1; MainStageController main = new MainStageController(); for (int i = 0; i < seiryokuList.Count; i++) { int tmpDaimyoId = int.Parse(seiryokuList [i]); if (tmpDaimyoId == srcDaimyoId) { List <string> checkedKuniList = new List <string> (); int tmpKuniId = i + 1; int newWinnerKuniQty = main.countLinkedKuniQty(1, tmpKuniId, tmpDaimyoId, seiryokuList, checkedKuniList); //Get New Senryoku int busyoQty = calc.EnemyBusyoQtyCalc(myKuniQty, newWinnerKuniQty, 0); int senryokuRatio = daimyoScript.getSenryoku(srcDaimyoId); int busyoLv = calc.EnemyBusyoLvCalc(senryokuRatio); int butaiQty = calc.EnemyButaiQtyCalc(newWinnerKuniQty, myKuniQty); int butaiLv = calc.EnemyButaiLvCalc(senryokuRatio); //Change Name of target Kuni by daimyo info targetKuni.GetComponent <SendParam> ().daimyoId = srcDaimyoId; targetKuni.GetComponent <SendParam>().daimyoName = daimyoScript.getName(srcDaimyoId); //daimyoMst.param [srcDaimyoId - 1].daimyoName; targetKuni.GetComponent <SendParam>().daimyoBusyoId = daimyoScript.getDaimyoBusyoId(srcDaimyoId); //daimyoMst.param [srcDaimyoId - 1].busyoId; SendParam winnerParam = kuniIconView.transform.FindChild(tmpKuniId.ToString()).GetComponent <SendParam> (); winnerParam.busyoQty = busyoQty; winnerParam.busyoLv = busyoLv; winnerParam.butaiQty = butaiQty; winnerParam.butaiLv = butaiLv; winnerParam.kuniQty = newWinnerKuniQty; } else if (tmpDaimyoId == dstDaimyoId) { List <string> checkedKuniList = new List <string> (); int tmpKuniId = i + 1; int newLoserKuniQty = main.countLinkedKuniQty(1, tmpKuniId, tmpDaimyoId, seiryokuList, checkedKuniList); //Get New Senryoku int busyoQty = calc.EnemyBusyoQtyCalc(myKuniQty, newLoserKuniQty, 0); int senryokuRatio = daimyoScript.getSenryoku(dstDaimyoId);//daimyoMst.param [dstDaimyoId - 1].senryoku; int busyoLv = calc.EnemyBusyoLvCalc(senryokuRatio); int butaiQty = calc.EnemyButaiQtyCalc(newLoserKuniQty, myKuniQty); int butaiLv = calc.EnemyButaiLvCalc(senryokuRatio); SendParam loserParam = kuniIconView.transform.FindChild(tmpKuniId.ToString()).GetComponent <SendParam> (); loserParam.busyoQty = busyoQty; loserParam.busyoLv = busyoLv; loserParam.butaiQty = butaiQty; loserParam.butaiLv = butaiLv; loserParam.kuniQty = newLoserKuniQty; } } //Icon Color Change by Doumei Situation List <string> myDoumeiList = new List <string> (); string doumeiString = PlayerPrefs.GetString("doumei"); if (doumeiString != null && doumeiString != "") { if (doumeiString.Contains(",")) { myDoumeiList = new List <string> (doumeiString.Split(delimiterChars)); } else { myDoumeiList.Add(doumeiString); } } if (myDoumeiList.Contains(srcDaimyoId.ToString())) { Color doumeiColor = new Color(100f / 255f, 130f / 255f, 255f / 255f, 255f / 255f); targetKuni.GetComponent <SendParam> ().doumeiFlg = true; targetKuni.GetComponent <Image>().color = doumeiColor; } if (!myDoumeiList.Contains(srcDaimyoId.ToString()) && myDoumeiList.Contains(dstDaimyoId.ToString())) { Color unDoumeiColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 255f / 255f); targetKuni.GetComponent <SendParam> ().doumeiFlg = false; targetKuni.GetComponent <Image>().color = unDoumeiColor; } }
public void OnClick(){ //SE if (audioNaisei != null) { audioNaisei.PlayOneShot (touch); } /*Common Process*/ string pathOfBoard = "Prefabs/Map/Popup"; GameObject board = Instantiate (Resources.Load (pathOfBoard)) as GameObject; board.transform.parent = GameObject.Find ("Map").transform; board.transform.localScale = new Vector2 (1, 0.8f); board.transform.localPosition = new Vector2 (0, 0); Daimyo daimyo = new Daimyo(); /*Indivisual Process by Kuni*/ string pathOfKuniMap = "Prefabs/Map/stage/kuniMap"; GameObject kuniMap = Instantiate (Resources.Load (pathOfKuniMap)) as GameObject; board.transform.FindChild ("kuniName").GetComponent<Text> ().text = kuniName; string kuniImagePath = "Prefabs/Map/stage/MapSprite/" + kuniId.ToString (); kuniMap.GetComponent<Image> ().sprite = Resources.Load (kuniImagePath, typeof(Sprite)) as Sprite; //kuni kuniMap.transform.parent = GameObject.Find ("board").transform; kuniMap.transform.localScale = new Vector2 (9, 6); kuniMap.transform.localPosition = new Vector3 (-145, 4, 0); kuniMap.name = "kuniMap" + kuniId; //Clear Stage Setting string clearedStage = "kuni" + kuniId; string clearedStageString = PlayerPrefs.GetString (clearedStage); List<string> clearedStageList = new List<string> (); if (clearedStageString != null && clearedStageString != "") { char[] delimiterChars = {','}; clearedStageList = new List<string> (clearedStageString.Split (delimiterChars)); } //Default Value Entity_stage_mst stageMst = Resources.Load ("Data/stage_mst") as Entity_stage_mst; int startline = 10 * kuniId - 10; string stagePath = "Prefabs/Map/stage/stage"; string clearedPath = "Prefabs/Map/cleared"; int stageId = 1; bool clearedFlg = false; int mySenryoku = daimyo.getSenryoku(myDaimyoId); int enemySenryoku = daimyo.getSenryoku(daimyoId); float senryokuRatio = (float)enemySenryoku / (float)mySenryoku; for (int i=startline; i<startline+10; i++) { GameObject stage = Instantiate (Resources.Load (stagePath)) as GameObject; stage.transform.SetParent (kuniMap.transform); stage.transform.localScale = new Vector2 (1, 1); stage.name = "stage" + stageId.ToString (); //Cleared Check if (clearedStageList.Contains (stageId.ToString ()) == true) { GameObject cleared = Instantiate (Resources.Load (clearedPath)) as GameObject; cleared.transform.SetParent (stage.transform); cleared.transform.localScale = new Vector2 (3, 5); cleared.transform.localPosition = new Vector2 (0, 0); clearedFlg = true; } //Get Stage Info string stageName = stageMst.param [i].stageName; int locationX = stageMst.param [i].LocationX; int locationY = stageMst.param [i].LocationY; int powerType = stageMst.param [i].powerTyp; RectTransform stageTransform = stage.GetComponent<RectTransform> (); stageTransform.anchoredPosition = new Vector3 (locationX, locationY, 0); //money and exp calculation int minExp = getMinExp(powerType,senryokuRatio); int maxExp = getMaxExp(powerType,senryokuRatio); int exp = UnityEngine.Random.Range (minExp, maxExp + 1); int minMoney = minExp * 3; int maxMoney = maxExp * 5; int money = UnityEngine.Random.Range (minMoney, maxMoney + 1); string itemGrp = getRandomItemGrp (); string itemTyp = ""; int itemId = 0; int itemQty = 1; if (itemGrp == "item") { itemTyp = getRandomItemTyp(itemGrp); if (itemTyp == "tech") { itemId = getItemRank (66, 33); } else if (itemTyp == "Tama") { itemId = getItemRank (20, 5); if (itemId == 3) { itemQty = 100; } else if (itemId == 2) { itemQty = 20; } else if (itemId == 1) { itemQty = 5; } } else { itemId = getItemRank (20, 5); } } else if (itemGrp == "kahou") { itemTyp = getRandomItemTyp(itemGrp); Kahou kahou = new Kahou (); string kahouRank = getKahouRank (); itemId = kahou.getRamdomKahouId (itemTyp, kahouRank); } stage.GetComponent<ShowStageDtl> ().kuniId = kuniId; stage.GetComponent<ShowStageDtl> ().stageId = stageId; stage.GetComponent<ShowStageDtl> ().stageName = stageName; stage.GetComponent<ShowStageDtl> ().exp = exp; stage.GetComponent<ShowStageDtl> ().showExp = minExp + " - " + maxExp; stage.GetComponent<ShowStageDtl> ().money = money; stage.GetComponent<ShowStageDtl> ().showMoney = minMoney + " - " + maxMoney; stage.GetComponent<ShowStageDtl> ().itemGrp = itemGrp; stage.GetComponent<ShowStageDtl> ().itemTyp = itemTyp; stage.GetComponent<ShowStageDtl> ().itemId = itemId.ToString (); stage.GetComponent<ShowStageDtl> ().itemQty = itemQty; stage.GetComponent<ShowStageDtl> ().powerType = powerType; if(powerType==2){ string imagePath = "Prefabs/Map/Stage/shiroIcon_m"; stage.transform.FindChild("shiroImage").GetComponent<SpriteRenderer> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; }else if(powerType==3){ string imagePath = "Prefabs/Map/Stage/shiroIcon_l"; stage.transform.FindChild("shiroImage").GetComponent<SpriteRenderer> ().sprite = Resources.Load (imagePath, typeof(Sprite)) as Sprite; } stageId = stageId + 1; } //Line Setting Entity_stageLink_mst stageLinkMst = Resources.Load ("Data/stageLink_mst") as Entity_stageLink_mst; List<string> myStageLink = new List<string> (); for (int i=0; i<stageLinkMst.param.Count; i++) { int tempKuniId = stageLinkMst.param[i].kuniId; if(tempKuniId ==kuniId){ myStageLink.Add(stageLinkMst.param[i].Link); } } char[] delimiterChars2 = {'-'}; string linkPath = "Prefabs/Map/stage/link"; for (int j=0; j<myStageLink.Count; j++) { List<string> linkList = new List<string> (myStageLink[j].Split (delimiterChars2)); string stage1Name = linkList[0]; string stage2Name = linkList[1]; if(!clearedStageList.Contains(stage1Name) && !clearedStageList.Contains(stage2Name)){ //1st string temp1 = "stage" + stage1Name; GameObject stage1 = kuniMap.transform.FindChild(temp1).gameObject; RectTransform rectStage1 = stage1.GetComponent<RectTransform>(); Vector3 vect1 = new Vector3(rectStage1.anchoredPosition.x,rectStage1.anchoredPosition.y,0); //2nd string temp2 = "stage" + stage2Name; GameObject stage2 = kuniMap.transform.FindChild(temp2).gameObject; RectTransform rectStage2 = stage2.GetComponent<RectTransform>(); Vector3 vect2 = new Vector3(rectStage2.anchoredPosition.x,rectStage2.anchoredPosition.y,0); //Set GameObject link = Instantiate (Resources.Load (linkPath)) as GameObject; link.transform.SetParent (kuniMap.transform); link.transform.localScale = new Vector2 (1, 1); RectTransform linkRectTransform =link.GetComponent<RectTransform>(); linkRectTransform.anchoredPosition = new Vector3 (0, 0, 0); link.GetComponent<LineRenderer>().SetPosition(0,vect1); link.GetComponent<LineRenderer>().SetPosition(1,vect2); //Line No stage1.GetComponent<ShowStageDtl>().linkNo = stage1.GetComponent<ShowStageDtl>().linkNo + 1; stage2.GetComponent<ShowStageDtl>().linkNo = stage2.GetComponent<ShowStageDtl>().linkNo + 1; //Name link.name = "link" + stage1Name+ "-" + stage2Name; } } //Battle Initial Setting StartKassen sk = GameObject.Find ("BattleButton").GetComponent<StartKassen> (); sk.activeBusyoQty = activeBusyoQty; sk.activeBusyoLv = activeBusyoLv; sk.activeButaiQty = activeButaiQty; sk.activeButaiLv = activeButaiLv; sk.activeDaimyoId = daimyoId; sk.doumeiFlg = doumeiFlg; /*Naisei Button*/ string naiseiPath = "Prefabs/Map/NaiseiButton"; GameObject naiseiBtn = Instantiate (Resources.Load (naiseiPath)) as GameObject; naiseiBtn.transform.parent = GameObject.Find ("Popup(Clone)").transform; naiseiBtn.GetComponent<StartNaisei> ().activeKuniId = kuniId; naiseiBtn.GetComponent<StartNaisei> ().activeKuniName = kuniName; naiseiBtn.GetComponent<StartNaisei> ().clearedFlg = clearedFlg; naiseiBtn.transform.localScale = new Vector2 (0.4f, 0.4f); naiseiBtn.transform.localPosition = new Vector2 (-490, -300); //Initial Setting GameObject firstStage = GameObject.Find ("stage1"); firstStage.GetComponent<ShowStageDtl> ().OnClick (); }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); audioSources [2].Play(); //Upper if (!bottomFlg) { //Color Color Select = new Color(76f / 255f, 50f / 255f, 18f / 255f, 80f / 255f); Color unSelect = new Color(255f / 255f, 255f / 255f, 255f / 255f, 100f / 255f); foreach (Transform obj in uprContent.transform) { obj.GetComponent <Image> ().color = unSelect; } GetComponent <Image> ().color = Select; //Reset foreach (Transform obj in btnContent.transform) { Destroy(obj.gameObject); } string btnSlot = "Prefabs/Bakuhu/CyusaiSlot"; Daimyo daimyo = new Daimyo(); foreach (string dstDaimyoId in checkedDaimyoList) { if (dstDaimyoId != daimyoId) { GameObject btmSlot = Instantiate(Resources.Load(btnSlot)) as GameObject; btmSlot.transform.SetParent(btnContent.transform); btmSlot.transform.localScale = new Vector2(1, 1); int daimyoBusyoId = daimyo.getDaimyoBusyoId(int.Parse(dstDaimyoId)); string daimyoName2 = daimyo.getName(int.Parse(dstDaimyoId)); string daimyoBusyoPath = "Prefabs/Player/Sprite/unit" + daimyoBusyoId.ToString(); btmSlot.transform.FindChild("Image").transform.FindChild("Image").GetComponent <Image> ().sprite = Resources.Load(daimyoBusyoPath, typeof(Sprite)) as Sprite; btmSlot.transform.FindChild("DaimyoName").GetComponent <Text> ().text = daimyoName2; btmSlot.GetComponent <CyusaiDaimyoSelect> ().bottomFlg = true; btmSlot.GetComponent <CyusaiDaimyoSelect> ().uprContent = uprContent; btmSlot.GetComponent <CyusaiDaimyoSelect> ().btnContent = btnContent; btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoId = daimyoId; btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoId = daimyoId; btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoId2 = dstDaimyoId; btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoName = daimyoName; btmSlot.GetComponent <CyusaiDaimyoSelect> ().daimyoName2 = daimyoName2; } } } else { //Bottom //Color Color Select = new Color(76f / 255f, 50f / 255f, 18f / 255f, 80f / 255f); Color unSelect = new Color(255f / 255f, 255f / 255f, 255f / 255f, 100f / 255f); foreach (Transform obj in btnContent.transform) { obj.GetComponent <Image> ().color = unSelect; } GetComponent <Image> ().color = Select; //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/CyusaiConfirm"; 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 = "CyusaiConfirm"; if (Application.systemLanguage != SystemLanguage.Japanese) { msg.transform.FindChild("Text").GetComponent <Text> ().text = "Do you want to mediate between " + daimyoName + " and " + daimyoName2 + "? \n Friendship will increase."; } else { msg.transform.FindChild("Text").GetComponent <Text>().text = daimyoName + "と" + daimyoName2 + "を仲裁しますか?\n二大名間の友好度が上がります。"; } GameObject YesBtn = msg.transform.FindChild("YesButton").gameObject; GameObject NoBtn = msg.transform.FindChild("NoButton").gameObject; YesBtn.GetComponent <DoCyusai> ().daimyoId = daimyoId; YesBtn.GetComponent <DoCyusai> ().daimyoId2 = daimyoId2; YesBtn.GetComponent <DoCyusai> ().daimyoName = daimyoName; YesBtn.GetComponent <DoCyusai> ().daimyoName2 = daimyoName2; YesBtn.GetComponent <DoCyusai> ().confirm = msg; YesBtn.GetComponent <DoCyusai> ().back = back; NoBtn.GetComponent <DoCyusai> ().confirm = msg; NoBtn.GetComponent <DoCyusai> ().back = back; NoBtn.GetComponent <DoCyusai> ().btnContent = btnContent; NoBtn.GetComponent <DoCyusai> ().uprContent = uprContent; } }
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(){ //Pop View BusyoStatusButton pop = new BusyoStatusButton (); pop.commonPopup (); GameObject.Find ("popText").GetComponent<Text> ().text ="武将登用"; //Busyo View string path = "Prefabs/Player/Unit/" + busyoId; GameObject Busyo = Instantiate (Resources.Load (path)) as GameObject; Busyo.transform.SetParent (GameObject.Find ("board(Clone)").transform); Busyo.transform.localScale = new Vector2 (5, 5); Busyo.GetComponent<DragHandler>().enabled = false; RectTransform busyo_transform = Busyo.GetComponent<RectTransform>(); busyo_transform.anchoredPosition = new Vector3(350,300,0); busyo_transform.sizeDelta = new Vector2( 100, 100); //Text Modification Busyo.transform.FindChild ("Text").gameObject.GetComponent<Text>().enabled = false; //Rank Text Modification GameObject rank = Busyo.transform.FindChild ("Rank").gameObject; RectTransform rank_transform = rank.GetComponent<RectTransform>(); rank_transform.anchoredPosition = new Vector3 (0,-50,0); rank_transform.sizeDelta = new Vector2( 200, 200); rank.GetComponent<Text>().fontSize = 200; /*Status*/ string statusPath = "Prefabs/Touyou/busyoStatus"; GameObject status = Instantiate (Resources.Load (statusPath)) as GameObject; status.transform.SetParent (GameObject.Find ("board(Clone)").transform); status.transform.localScale = new Vector2 (1, 1); RectTransform status_transform = status.GetComponent<RectTransform>(); status_transform.anchoredPosition = new Vector3(245,-40,0); Entity_busyo_mst busyoMst = Resources.Load ("Data/busyo_mst") as Entity_busyo_mst; Entity_senpou_mst senpouMst = Resources.Load ("Data/senpou_mst") as Entity_senpou_mst; string busyoName = busyoMst.param [busyoId-1].name; GameObject.Find ("busyoNameValue").GetComponent<Text>().text = busyoName; GameObject.Find ("TosotsuValue").GetComponent<Text>().text = busyoMst.param [busyoId-1].minHp.ToString() + "00"; GameObject.Find ("BuyuuValue").GetComponent<Text> ().text = busyoMst.param [busyoId - 1].minAtk.ToString () + "0"; GameObject.Find ("ChiryakuValue").GetComponent<Text>().text = busyoMst.param [busyoId-1].minDfc.ToString() + "0"; GameObject.Find ("SpeedValue").GetComponent<Text>().text = busyoMst.param [busyoId-1].minSpd.ToString(); string heisyuType = busyoMst.param [busyoId - 1].heisyu; string heisyu = ""; if (heisyuType == "KB") { heisyu = "騎馬隊"; } else if (heisyuType == "YR") { heisyu = "槍隊"; } else if (heisyuType == "TP") { heisyu = "鉄砲隊"; } else if (heisyuType == "YM") { heisyu = "弓隊"; } GameObject.Find ("ChildNameValue").GetComponent<Text>().text = heisyu; int senpouId = busyoMst.param [busyoId-1].senpou_id; GameObject.Find ("SenpouValue").GetComponent<Text>().text = senpouMst.param[senpouId-1].name; int senpouStatus = senpouMst.param [senpouId - 1].lv1; int each = (int)senpouMst.param [senpouId - 1].each; int ratio = (int)senpouMst.param [senpouId - 1].ratio; int term = (int)senpouMst.param [senpouId - 1].term; string senpouExp = senpouMst.param [senpouId - 1].effection; senpouExp = senpouExp.Replace("A", senpouStatus.ToString()); senpouExp = senpouExp.Replace("B", each.ToString()); senpouExp = senpouExp.Replace("C", ratio.ToString()); senpouExp = senpouExp.Replace("D", term.ToString()); GameObject.Find ("SenpouExpValue").GetComponent<Text>().text = senpouExp; /*Saku*/ Saku saku = new Saku (); List<string> sakuList = new List<string>(); sakuList = saku.getSakuInfo (busyoId); //Icon string sakuPath = "Prefabs/Saku/saku" + sakuList[0]; GameObject sakuIcon = Instantiate (Resources.Load (sakuPath)) as GameObject; GameObject StatusSaku = status.transform.FindChild("StatusSaku").gameObject; foreach ( Transform n in StatusSaku.transform ){ if(n.tag == "Saku"){ GameObject.Destroy(n.gameObject); } } sakuIcon.transform.SetParent (StatusSaku.transform); sakuIcon.transform.localScale = new Vector2 (0.7f, 0.7f); sakuIcon.GetComponent<Button>().enabled = false; RectTransform sakuIcon_transform = sakuIcon.GetComponent<RectTransform>(); sakuIcon_transform.anchoredPosition = new Vector3(-235,0,0); StatusSaku.transform.FindChild("SakuExp").transform.FindChild("SakuExpValue").GetComponent<Text>().text = sakuList[2]; /*daimyo busyo check*/ Daimyo daimyo = new Daimyo (); daimyoFlg = daimyo.daimyoBusyoCheck (busyoId); //pass data to button GameObject touyouBtn = GameObject.Find ("TouyouButton").gameObject; touyouBtn.GetComponent<DoTouyou> ().busyoId = busyoId; touyouBtn.GetComponent<DoTouyou> ().busyoName = busyoName; touyouBtn.GetComponent<DoTouyou> ().heisyu = heisyuType; touyouBtn.GetComponent<DoTouyou> ().sequence = int.Parse(name); touyouBtn.GetComponent<DoTouyou> ().rank = busyoRank; touyouBtn.GetComponent<DoTouyou> ().daimyoFlg = daimyoFlg; }
public void OnClick() { AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> (); //Limit Check int stockLimit = PlayerPrefs.GetInt("stockLimit"); int myBusyoQty = PlayerPrefs.GetInt("myBusyoQty"); char[] delimiterChars = { ',' }; if (myBusyoQty + 1 > stockLimit && Application.loadedLevelName != "tutorialTouyou") { //Error audioSources [4].Play(); Message msg = new Message(); string Text = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { Text = "You can hire samurai by " + stockLimit.ToString() + " members."; } else { Text = "現在の国力では登用出来る武将数は" + stockLimit.ToString() + "人までですぞ。"; } msg.makeMessage(Text); } else { audioSources [3].Play(); audioSources [7].Play(); GameObject.Find("Touyou").GetComponent <Canvas>().sortingLayerName = "Default"; //Track bool tutorialDoneFlg = PlayerPrefs.GetBool("tutorialDoneFlg"); if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialTouyou") { int TrackNewBusyoHireNo = PlayerPrefs.GetInt("TrackNewBusyoHireNo", 0); TrackNewBusyoHireNo = TrackNewBusyoHireNo + 1; PlayerPrefs.SetInt("TrackNewBusyoHireNo", TrackNewBusyoHireNo); /*Add zukan & gacya History Start*/ string zukanBusyoHst = PlayerPrefs.GetString("zukanBusyoHst"); if (zukanBusyoHst != null && zukanBusyoHst != "") { zukanBusyoHst = zukanBusyoHst + "," + busyoId.ToString(); } else { zukanBusyoHst = busyoId.ToString(); } PlayerPrefs.SetString("zukanBusyoHst", zukanBusyoHst); //Daimyo Busyo History Daimyo daimyo = new Daimyo(); if (daimyo.daimyoBusyoCheck(busyoId)) { string gacyaDaimyoHst = PlayerPrefs.GetString("gacyaDaimyoHst"); if (gacyaDaimyoHst != null && gacyaDaimyoHst != "") { gacyaDaimyoHst = gacyaDaimyoHst + "," + busyoId.ToString(); } else { gacyaDaimyoHst = busyoId.ToString(); } PlayerPrefs.SetString("gacyaDaimyoHst", gacyaDaimyoHst); } //sequence string sequenceString = ""; if (sequence == 1) { sequenceString = "1,0,0"; } else if (sequence == 2) { sequenceString = "0,1,0"; } else if (sequence == 3) { sequenceString = "0,0,1"; } PlayerPrefs.SetString("touyouHst", sequenceString); if (rank == "S") { PlayerPrefs.SetBool("questSpecialFlg0", true); } else if (rank == "A") { PlayerPrefs.SetBool("questSpecialFlg1", true); } PlayerPrefs.Flush(); /*Add zukan & gacya History End*/ //My Busyo Exist Check string myBusyoString = PlayerPrefs.GetString("myBusyo"); List <string> myBusyoList = new List <string>(); if (myBusyoString.Contains(",")) { myBusyoList = new List <string>(myBusyoString.Split(delimiterChars)); } else { myBusyoList.Add(myBusyoString); } if (myBusyoList.Contains(busyoId.ToString())) { //add lv string addLvTmp = "addlv" + busyoId.ToString(); int addLvValue = 0; if (PlayerPrefs.HasKey(addLvTmp)) { addLvValue = PlayerPrefs.GetInt(addLvTmp); addLvValue = addLvValue + 1; if (addLvValue >= 100) { addLvValue = 100; } } else { addLvValue = 1; } if (addLvValue < 100) { PlayerPrefs.SetInt(addLvTmp, addLvValue); PlayerPrefs.Flush(); //View Message Box Destroy(GameObject.Find("board(Clone)")); Destroy(GameObject.Find("Back(Clone)")); MessageBusyo msg = new MessageBusyo(); string type = "touyou"; string msgText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { msgText = "Max Lv of " + busyoName + " increased."; } else { msgText = busyoName + "の最大レベルが1上がりました。"; } msg.makeMessage(msgText, busyoId, type); } else { //Lv up int currentLv = PlayerPrefs.GetInt(busyoId.ToString()); int maxLv = 100 + addLvValue; int newLv = 0; string lvUpText = ""; //Already Lv Max if (currentLv == maxLv) { newLv = currentLv; int busyoDama = 0; if (rank == "S") { busyoDama = 200; } else if (rank == "A") { busyoDama = 50; } else if (rank == "B") { busyoDama = 20; } else if (rank == "C") { busyoDama = 10; } int myBusyoDama = PlayerPrefs.GetInt("busyoDama"); myBusyoDama = myBusyoDama + busyoDama; PlayerPrefs.SetInt("busyoDama", myBusyoDama); if (Application.systemLanguage != SystemLanguage.Japanese) { lvUpText = "You got " + busyoDama + " stone."; } else { lvUpText = "武将珠" + busyoDama + "個を贈呈します。"; } GameObject.Find("BusyoDamaValue").GetComponent <Text> ().text = myBusyoDama.ToString(); } else { newLv = currentLv + 1; if (Application.systemLanguage != SystemLanguage.Japanese) { lvUpText = busyoName + " Lv was increased."; } else { lvUpText = busyoName + "をレベルアップしました。"; } } PlayerPrefs.SetInt(busyoId.ToString(), newLv); if (currentLv != maxLv) { string exp = "exp" + busyoId.ToString(); Exp expCalc = new Exp(); int totalExp = expCalc.getExpforNextLv(currentLv); PlayerPrefs.SetInt(exp, totalExp); } //View Message Box Destroy(GameObject.Find("board(Clone)")); Destroy(GameObject.Find("Back(Clone)")); MessageBusyo msg = new MessageBusyo(); string type = "touyou"; msg.makeMessage(lvUpText, busyoId, type); } } else { int existCheck = PlayerPrefs.GetInt(busyoId.ToString()); if (existCheck != 0 && existCheck != null) { //my Busyo not contain but player used him before daimyo was changed if (myBusyoString == null || myBusyoString == "") { myBusyoString = busyoId.ToString(); } else { myBusyoString = myBusyoString + "," + busyoId.ToString(); } PlayerPrefs.SetString("myBusyo", myBusyoString); //Add Qty myBusyoQty = myBusyoQty + 1; PlayerPrefs.SetInt("myBusyoQty", myBusyoQty); //View Message Box Destroy(GameObject.Find("board(Clone)")); Destroy(GameObject.Find("Back(Clone)")); MessageBusyo msg = new MessageBusyo(); string touyouuText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { touyouuText = "We hired " + busyoName + "."; } else { touyouuText = busyoName + "を登用しました。"; } string type = "touyou"; msg.makeMessage(touyouuText, busyoId, type); } else { //Add Completely New Data if (myBusyoString == null || myBusyoString == "") { myBusyoString = busyoId.ToString(); } else { myBusyoString = myBusyoString + "," + busyoId.ToString(); } PlayerPrefs.SetString("myBusyo", myBusyoString); PlayerPrefs.SetInt(busyoId.ToString(), 1); string hei = "hei" + busyoId.ToString(); string heiValue = heisyu + ":1:1:1"; PlayerPrefs.SetString(hei, heiValue); string senpou = "senpou" + busyoId.ToString(); PlayerPrefs.SetInt(senpou, 1); //Lv string saku = "saku" + busyoId.ToString(); PlayerPrefs.SetInt(saku, 1); //Lv string kahou = "kahou" + busyoId.ToString(); PlayerPrefs.SetString(kahou, "0,0,0,0,0,0,0,0"); string exp = "exp" + busyoId.ToString(); PlayerPrefs.SetInt(exp, 0); //Add Qty myBusyoQty = myBusyoQty + 1; PlayerPrefs.SetInt("myBusyoQty", myBusyoQty); //View Message Box Destroy(GameObject.Find("board(Clone)")); Destroy(GameObject.Find("Back(Clone)")); MessageBusyo msg = new MessageBusyo(); string touyouuText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { touyouuText = "We hired " + busyoName + "."; } else { touyouuText = busyoName + "を登用しました。"; } string type = "touyou"; msg.makeMessage(touyouuText, busyoId, type); } } } else { //retry tutorial PlayerPrefs.SetInt("tutorialBusyo", busyoId); PlayerPrefs.Flush(); //View Message Box Destroy(GameObject.Find("board(Clone)")); Destroy(GameObject.Find("Back(Clone)")); MessageBusyo msg = new MessageBusyo(); string touyouuText = ""; if (Application.systemLanguage != SystemLanguage.Japanese) { touyouuText = "We hired " + busyoName + "."; } else { touyouuText = busyoName + "を登用しました。"; } string type = "touyou"; msg.makeMessage(touyouuText, busyoId, type); } } PlayerPrefs.Flush(); //Close Process string gacyaHst = ""; if (Application.loadedLevelName == "tutorialTouyou") { gacyaHst = "4,16,201"; //Set Parametor PlayerPrefs.SetInt("tutorialId", 9); PlayerPrefs.Flush(); TextController txtScript = GameObject.Find("TextBoard").transform.FindChild("Text").GetComponent <TextController>(); txtScript.SetText(8); txtScript.SetNextLine(); txtScript.tutorialId = 8; txtScript.actOnFlg = false; //Center View GameObject centerView = GameObject.Find("CenterView").gameObject; centerView.transform.SetParent(GameObject.Find("tFinished").transform); } else { gacyaHst = PlayerPrefs.GetString("gacyaHst"); } string[] tokens = gacyaHst.Split(delimiterChars); int[] hitBusyo = Array.ConvertAll <string, int>(tokens, int.Parse); Gacya viewBusyo = new Gacya(); viewBusyo.viewBusyo(hitBusyo, false); }
public void OnClick(){ if (!gameOverFlg) { //Clear and Re-srart makeDaimyoSeiryoku(); } else { //GameOver and Re-srart NewDaimyoDataMaker data = new NewDaimyoDataMaker(); //Check Once Cleared or Not string gameClearDaimyo = PlayerPrefs.GetString ("gameClearDaimyo"); if(gameClearDaimyo!=null && gameClearDaimyo !=""){ //Once Cleared >> Can Choose Daimyo GameObject kuniMap = GameObject.Find("KuniMap").gameObject; GameObject KuniIconView = GameObject.Find("KuniIconView").gameObject; Destroy(kuniMap.gameObject); Destroy(KuniIconView.gameObject); makeDaimyoSeiryoku(); //Daimyo Busyo Data Clear in the case there is no gacya history string gacyaDaimyoHst = PlayerPrefs.GetString ("gacyaDaimyoHst"); char[] delimiterChars = {','}; List<string> gacyaDaimyoHstList = new List<string>(); if(gacyaDaimyoHst!=null && gacyaDaimyoHst !=""){ if(gacyaDaimyoHst.Contains(",")){ gacyaDaimyoHstList = new List<string> (gacyaDaimyoHst.Split (delimiterChars)); }else{ gacyaDaimyoHstList.Add(gacyaDaimyoHst); } } Daimyo daimyo = new Daimyo(); int myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); int daimyoBusyoId = daimyo.getDaimyoBusyoId(myDaimyo); if(!gacyaDaimyoHstList.Contains(daimyoBusyoId.ToString())){ //delete daimyo busyo from my busyo string myBusyoString = PlayerPrefs.GetString ("myBusyo"); List<string> myBusyoList = new List<string>(); if(myBusyoString!=null && myBusyoString !=""){ if(myBusyoString.Contains(",")){ myBusyoList = new List<string> (myBusyoString.Split (delimiterChars)); }else{ myBusyoList.Add(myBusyoString); } } string newMyBusyo = ""; for(int i=0; i<myBusyoList.Count; i++){ int myBusyoId = int.Parse(myBusyoList[i]); if(myBusyoId != daimyoBusyoId){ if(newMyBusyo == ""){ newMyBusyo = myBusyoId.ToString(); }else{ newMyBusyo = newMyBusyo + "," + myBusyoId.ToString(); } } } PlayerPrefs.SetString ("myBusyo",newMyBusyo); PlayerPrefs.Flush(); } }else{ //Never Cleared >> Start From Oda Nobunaga data.dataMake(true, 1, 19, "TP"); } } }
public void showSeiryoku(){ /*--------------------*/ /*Show Daimyo Seiryoku*/ /*--------------------*/ 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 = PlayerPrefs.GetString ("seiryoku"); List<string> seiryokuList = new List<string> (); char[] delimiterChars = {','}; seiryokuList = new List<string> (seiryoku.Split (delimiterChars)); string kuniPath = "Prefabs/Map/Kuni/"; GameObject kuniIconView = GameObject.Find ("KuniIconView"); GameObject KuniMap = GameObject.Find ("KuniMap"); myDaimyo = PlayerPrefs.GetInt ("myDaimyo"); Daimyo daimyo = new Daimyo (); myDaimyoName = daimyo.getName (myDaimyo); 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); } } 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); kuni.GetComponent<Button>().enabled = false; //Seiryoku Handling int daimyoId = int.Parse (seiryokuList [kuniId - 1]); string daimyoName = daimyoMst.param [daimyoId - 1].daimyoName; int daimyoBusyoIdTemp = daimyoMst.param [daimyoId - 1].busyoId; //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); //My daimyo Check if (daimyoId == myDaimyo) { string myDaimyoPath = "Prefabs/Kamon/MyDaimyoKamon/" + myDaimyo.ToString (); kuni.GetComponent<Image> ().sprite = Resources.Load (myDaimyoPath, typeof(Sprite)) as Sprite; } //Clear Flg if(gameClearDaimyoList.Contains(daimyoId.ToString())){ kuni.GetComponent<SendParam> ().clearFlg = true; } } }