예제 #1
0
	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);


		}

	}
예제 #2
0
    public void viewKuniLink(GameObject board, GameObject kuniMap, List <string> seiryokuList)
    {
        KuniInfo   kuniScript   = new KuniInfo();
        List <int> linkKuniList = kuniScript.getMappingKuni(kuniId);

        List <int> linkAllKuniList = new List <int>();

        for (int i = 0; i < linkKuniList.Count; i++)
        {
            int linkKuniId = linkKuniList[i];
            linkAllKuniList.Add(linkKuniId);
        }

        //view kuni arrow link
        Daimyo daimyoScript = new Daimyo();

        for (int i = 0; i < linkAllKuniList.Count; i++)
        {
            int        srcKuniId      = linkAllKuniList[i];
            List <int> XYList         = kuniScript.getLinkStageXY(srcKuniId, kuniId);
            string     pathOfSrcKuni  = "Prefabs/Map/Stage/ArrowKuniName";
            GameObject srcKuniNameObj = Instantiate(Resources.Load(pathOfSrcKuni)) as GameObject;
            srcKuniNameObj.name = "Arrow" + srcKuniId;
            srcKuniNameObj.transform.SetParent(board.transform.FindChild("board").transform);
            srcKuniNameObj.transform.localScale       = new Vector2(0.1f, 0.15f);
            srcKuniNameObj.transform.localPosition    = new Vector2(XYList[0], XYList[1]);
            srcKuniNameObj.GetComponent <Text>().text = kuniScript.getKuniName(srcKuniId);

            string linkStage = kuniScript.getLinkStage(srcKuniId, kuniId);
            linkStage = linkStage.Replace("stage", "");
            List <int> linkStageList = new List <int>(Array.ConvertAll(linkStage.Split(','),
                                                                       new Converter <string, int>((s) => { return(Convert.ToInt32(s)); })));

            string     arrowDaimyoPath = "Prefabs/Map/Stage/ArrowDaimyo";
            GameObject arrowDaimyo     = Instantiate(Resources.Load(arrowDaimyoPath)) as GameObject;
            arrowDaimyo.transform.SetParent(srcKuniNameObj.transform);
            arrowDaimyo.transform.localScale    = new Vector2(8, 7);
            arrowDaimyo.transform.localPosition = new Vector2(0, 0);
            arrowDaimyo.transform.FindChild("Effect").GetComponent <DamagePop>().divSpeed       = 5;
            arrowDaimyo.transform.FindChild("Effect").GetComponent <DamagePop>().attackBoardflg = true;

            int    arrowDaimyoId = int.Parse(seiryokuList[srcKuniId - 1]);
            string daimyoName    = daimyoScript.getName(arrowDaimyoId);
            arrowDaimyo.transform.FindChild("Effect").GetComponent <Text>().text = daimyoName;
            arrowDaimyo.transform.FindChild("Effect").transform.localScale       = new Vector2(0.12f, 0.12f);
            string kamonPath = "Prefabs/Kamon/MyDaimyoKamon/" + arrowDaimyoId.ToString();
            arrowDaimyo.GetComponent <Image>().sprite =
                Resources.Load(kamonPath, typeof(Sprite)) as Sprite;


            //Arrow
            string arrowPath = "Prefabs/PostKassen/Arrow";
            for (int j = 0; j < linkStageList.Count; j++)
            {
                GameObject arrow = Instantiate(Resources.Load(arrowPath)) as GameObject;
                arrow.transform.SetParent(srcKuniNameObj.transform);
                arrow.transform.localScale    = new Vector2(200, 200);
                arrow.transform.localPosition = new Vector2(0, 0);
                string     stageId     = "stage" + linkStageList[j];
                GameObject tgtStageObj = kuniMap.transform.FindChild(stageId).gameObject;
                Vector3    posDif      = tgtStageObj.transform.position - arrow.transform.position;
                float      angle       = Mathf.Atan2(posDif.y, posDif.x) * Mathf.Rad2Deg;

                Vector3 euler = new Vector3(0, 0, angle);
                arrow.transform.rotation = Quaternion.Euler(euler);
            }
        }
    }
예제 #3
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);

		}

	}
예제 #4
0
    // 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;
                }
            }
        }
    }
예제 #5
0
    public void createSyoguView(string busyoId)
    {
        int lv = PlayerPrefs.GetInt(busyoId);

        Color ngImageColor = new Color(40f / 255f, 40f / 255f, 40f / 255f, 180f / 255f);
        Color ngTextColor  = new Color(90f / 255f, 90f / 255f, 90f / 255f, 90f / 255f);
        Color okImageColor = new Color(255f / 255f, 255f / 255f, 255f / 255f, 150f / 255f);
        Color okTextColor  = new Color(40f / 255f, 40f / 255f, 0f / 255f, 255f / 255f);

        GameObject kanjyo  = GameObject.Find("kanjyo").gameObject;
        GameObject tsuihou = GameObject.Find("tsuihou").gameObject;

        int daimyoBusyoId = PlayerPrefs.GetInt("myDaimyoBusyo");

        if (busyoId == daimyoBusyoId.ToString())
        {
            kanjyo.GetComponent <Image> ().color = ngImageColor;
            kanjyo.transform.FindChild("Text").GetComponent <Text> ().color = ngTextColor;
            kanjyo.GetComponent <Button> ().enabled = false;

            tsuihou.GetComponent <Image> ().color = ngImageColor;
            tsuihou.transform.FindChild("Text").GetComponent <Text> ().color = ngTextColor;
            tsuihou.GetComponent <Button> ().enabled = false;
        }
        else
        {
            string addLvTmp = "addlv" + busyoId.ToString();
            int    maxLv    = 100 + PlayerPrefs.GetInt(addLvTmp);

            if (lv != maxLv)
            {
                kanjyo.GetComponent <BusyoStatusButton> ().pa_lv = lv;
                kanjyo.GetComponent <Image> ().color             = okImageColor;
                kanjyo.transform.FindChild("Text").GetComponent <Text> ().color = okTextColor;
                kanjyo.GetComponent <Button> ().enabled = true;
            }
            else
            {
                kanjyo.GetComponent <Image> ().color = ngImageColor;
                kanjyo.transform.FindChild("Text").GetComponent <Text> ().color = ngTextColor;
                kanjyo.GetComponent <Button> ().enabled = false;
            }

            tsuihou.GetComponent <Image> ().color = okImageColor;
            tsuihou.transform.FindChild("Text").GetComponent <Text> ().color = okTextColor;
            tsuihou.GetComponent <Button> ().enabled = true;
        }

        GameObject kanni  = GameObject.Find("kanni").gameObject;
        GameObject jyosyu = GameObject.Find("jyosyu").gameObject;
        GameObject syugyo = GameObject.Find("syugyo").gameObject;
        GameObject gokui  = GameObject.Find("gokui").gameObject;

        kanni.GetComponent <RonkouKousyoMenu>().busyoId  = busyoId;
        jyosyu.GetComponent <RonkouKousyoMenu>().busyoId = busyoId;
        syugyo.GetComponent <RonkouKousyoMenu>().busyoId = busyoId;
        gokui.GetComponent <RonkouKousyoMenu>().busyoId  = busyoId;

        //Kanni
        string kanniTmp    = "kanni" + busyoId;
        Kanni  kanniScript = new Kanni();

        if (PlayerPrefs.HasKey(kanniTmp))
        {
            int kanniId = PlayerPrefs.GetInt(kanniTmp);
            if (kanniId != 0)
            {
                foreach (Transform n in kanni.transform)
                {
                    if (n.name == "KanniName")
                    {
                        Destroy(n.gameObject);
                    }
                }
                kanni.GetComponent <RonkouKousyoMenu> ().kanniId = kanniId;
                string     path      = "Prefabs/Busyo/KanniName";
                GameObject kanniName = Instantiate(Resources.Load(path)) as GameObject;
                kanniName.transform.SetParent(kanni.transform);
                kanniName.transform.localScale    = new Vector2(0.12f, 0.12f);
                kanniName.transform.localPosition = new Vector2(0, 0);
                kanniName.name = "KanniName";

                string kanniNameString = kanniScript.getKanni(kanniId);
                string kanniIkai       = kanniScript.getIkai(kanniId);
                kanniName.transform.FindChild("value").GetComponent <Text>().text = kanniIkai + "\n" + kanniNameString;

                string effectLabel = kanniScript.getEffectLabel(kanniId);
                int    effect      = kanniScript.getEffect(kanniId);
                kanniName.transform.FindChild("effectLabel").GetComponent <Text>().text = effectLabel;
                kanniName.transform.FindChild("effectValue").GetComponent <Text>().text = "+" + effect.ToString() + "%";

                kanni.transform.FindChild("Text").GetComponent <Text> ().enabled = false;
            }
            else
            {
                foreach (Transform n in kanni.transform)
                {
                    if (n.name == "KanniName")
                    {
                        Destroy(n.gameObject);
                    }
                }

                kanni.GetComponent <RonkouKousyoMenu>().kanniId = 0;
                kanni.transform.FindChild("Text").GetComponent <Text>().enabled = true;
            }
        }
        else
        {
            foreach (Transform n in kanni.transform)
            {
                if (n.name == "KanniName")
                {
                    Destroy(n.gameObject);
                }
            }

            kanni.GetComponent <RonkouKousyoMenu> ().kanniId = 0;
            kanni.transform.FindChild("Text").GetComponent <Text> ().enabled = true;
        }

        //Jyosyu
        string jyosyuTmp = "jyosyuBusyo" + busyoId;

        if (PlayerPrefs.HasKey(jyosyuTmp))
        {
            BusyoInfoGet busyoInfo = new BusyoInfoGet();
            string       busyoName = busyoInfo.getName(int.Parse(busyoId));
            jyosyu.GetComponent <RonkouKousyoMenu>().jyosyuName = busyoName;

            int kuniId = PlayerPrefs.GetInt(jyosyuTmp);

            if (kuniId != 0)
            {
                foreach (Transform n in jyosyu.transform)
                {
                    if (n.name == "JyosyuName")
                    {
                        Destroy(n.gameObject);
                    }
                }

                KuniInfo kuni     = new KuniInfo();
                string   kuniName = kuni.getKuniName(kuniId);

                string jyosyuHeiTmp = "jyosyuHei" + busyoId;
                int    jyosyuHei    = PlayerPrefs.GetInt(jyosyuHeiTmp);

                jyosyu.GetComponent <RonkouKousyoMenu>().jyosyuKuniId = kuniId;
                string     jyosyuPath = "Prefabs/Busyo/JyosyuName";
                GameObject jyosyuName = Instantiate(Resources.Load(jyosyuPath)) as GameObject;
                jyosyuName.transform.SetParent(jyosyu.transform);
                jyosyuName.transform.localScale    = new Vector2(0.12f, 0.12f);
                jyosyuName.transform.localPosition = new Vector2(0, 0);
                jyosyuName.name = "JyosyuName";

                jyosyuName.transform.FindChild("value").GetComponent <Text>().text       = kuniName;
                jyosyuName.transform.FindChild("effectValue").GetComponent <Text>().text = "+" + jyosyuHei.ToString();

                jyosyu.transform.FindChild("Text").GetComponent <Text> ().enabled = false;
            }
        }
        else
        {
            foreach (Transform n in jyosyu.transform)
            {
                if (n.name == "JyosyuName")
                {
                    Destroy(n.gameObject);
                }
            }
            jyosyu.GetComponent <RonkouKousyoMenu> ().jyosyuKuniId            = 0;
            jyosyu.transform.FindChild("Text").GetComponent <Text> ().enabled = true;
        }
    }
예제 #6
0
	public void mainHandler(){

		/*Basic Info*/
		//make kuni list
		string seiryoku = PlayerPrefs.GetString ("seiryoku");
		List<string> seiryokuList = new List<string> ();
		char[] delimiterChars = {','};
		seiryokuList = new List<string> (seiryoku.Split (delimiterChars));
		int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
		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);
			}
		}


	}
예제 #7
0
	public void OnClick(){

		BusyoStatusButton bsb = new BusyoStatusButton ();

		if (name == "kanni") {
			if(kanniId ==0){
				string myKanni = PlayerPrefs.GetString("myKanni");

				if(myKanni != null && myKanni !=""){

					bsb.commonPopup ();
					GameObject.Find ("popText").GetComponent<Text> ().text ="官位一覧";
					
					string scrollPath = "Prefabs/Busyo/KanniScrollView";
					GameObject scroll = Instantiate (Resources.Load (scrollPath)) as GameObject;
					scroll.transform.SetParent(GameObject.Find ("board(Clone)").transform);
					scroll.transform.localScale = new Vector2 (1, 1);
					scroll.name = "KanniScrollView";
					RectTransform scrollTransform = scroll.GetComponent<RectTransform> ();
					scrollTransform.anchoredPosition3D = new Vector3 (0, 0, 0);

					List<string> myKanniList = new List<string> ();

					if(myKanni.Contains(",")){
						char[] delimiterChars = {','};
						myKanniList = new List<string> (myKanni.Split (delimiterChars));
					}else{
						myKanniList.Add(myKanni);
					}

					myKanniList.Sort();

					string pathSlot = "Prefabs/Busyo/KanniSlot";
					Kanni kanni = new Kanni();
					GameObject content = scroll.transform.FindChild("KanniContent").gameObject;
					for(int i=0; i<myKanniList.Count; i++){
						GameObject slot = Instantiate (Resources.Load (pathSlot)) as GameObject;
						slot.transform.SetParent(content.transform);
						slot.transform.localScale = new Vector2 (1, 1);

						int kanniIdTmp = int.Parse(myKanniList[i]);
						string kanniName = kanni.getKanni(kanniIdTmp);
						string kanniIkai = kanni.getIkai(kanniIdTmp);
						string EffectLabel = kanni.getEffectLabel(kanniIdTmp);
						int effect = kanni.getEffect(kanniIdTmp);

						slot.transform.FindChild("Name").GetComponent<Text>().text = kanniIkai + "\t" + kanniName;
						slot.transform.FindChild("EffectLabel").GetComponent<Text>().text = EffectLabel;
						slot.transform.FindChild("EffectValue").GetComponent<Text>().text = "+" + effect.ToString() + "%";

						GameObject btn = slot.transform.FindChild("GiveButton").gameObject;
						btn.GetComponent<GiveKanni>().busyoId = busyoId;
						btn.GetComponent<GiveKanni>().kanniId = kanniIdTmp;

					}



				}else{
					Message msg = new Message();
					msg.makeMessage("官位を持っておりませんぞ。\n山城国にある朝廷を訪れてみましょう。");
				}
			}else{

				string backPath = "Prefabs/Busyo/back";
				GameObject back = Instantiate (Resources.Load (backPath)) as GameObject;
				back.transform.SetParent(GameObject.Find ("Panel").transform);
				back.transform.localScale = new Vector2 (1, 1);
				RectTransform backTransform = back.GetComponent<RectTransform> ();
				backTransform.anchoredPosition3D = new Vector3 (0, 0, 0);

				string removePath = "Prefabs/Busyo/KanniRemoveConfirm";
				GameObject remove = Instantiate (Resources.Load (removePath)) as GameObject;
				remove.transform.SetParent(GameObject.Find ("Panel").transform);
				remove.transform.localScale = new Vector2 (1, 1);
				remove.transform.localPosition = new Vector3(0,0,0);
				remove.name = "KanniRemoveConfirm";
				BusyoInfoGet busyo = new BusyoInfoGet();
				string busyoName = busyo.getName(int.Parse(busyoId));
				remove.transform.FindChild("YesButton").GetComponent<DoRemoveKanni>().busyoId = busyoId;
				remove.transform.FindChild("RemoveText").GetComponent<Text>().text = busyoName + "殿の官位を\n罷免なさるのですか?";

			}



		}else if(name == "jyosyu"){
			if(jyosyuKuniId ==0){
				//Available Kuni

				string openKuniString = PlayerPrefs.GetString ("openKuni");
				char[] delimiterChars = {','};
				List<string> openKuniList = new List<string> ();
				if (openKuniString.Contains (",")) {
					openKuniList = new List<string> (openKuniString.Split (delimiterChars));
				} else {
					openKuniList.Add(openKuniString);
				}

				List<string> okKuniList = new List<string> ();
				for (int i=0; i<openKuniList.Count; i++) {
					int kuniId = int.Parse(openKuniList[i]);
					string temp = "kuni" + kuniId.ToString();
					string clearedKuni = PlayerPrefs.GetString (temp);
					//Shiro Qty
					if(clearedKuni != null && clearedKuni != ""){
						//Jyosyu Exist Check
						string jyosyuTmp = "jyosyu" + kuniId.ToString();
						if(!PlayerPrefs.HasKey(jyosyuTmp)){
							okKuniList.Add(kuniId.ToString());
						}
					}
				}

				if(okKuniList.Count != 0){
					bsb.commonPopup ();
					GameObject.Find ("popText").GetComponent<Text> ().text ="国一覧";
					
					string scrollPath = "Prefabs/Busyo/KanniScrollView";
					GameObject scroll = Instantiate (Resources.Load (scrollPath)) as GameObject;
					scroll.transform.SetParent(GameObject.Find ("board(Clone)").transform);
					scroll.transform.localScale = new Vector2 (1, 1);
					scroll.name = "KanniScrollView";
					RectTransform scrollTransform = scroll.GetComponent<RectTransform> ();
					scrollTransform.anchoredPosition3D = new Vector3 (0, 0, 0);

					string pathSlot = "Prefabs/Busyo/ShiroSlot";
					GameObject content = scroll.transform.FindChild("KanniContent").gameObject;
					KuniInfo kuni = new KuniInfo();
					for(int i=0; i<okKuniList.Count; i++){

						GameObject slot = Instantiate (Resources.Load (pathSlot)) as GameObject;
						slot.transform.SetParent(content.transform);
						slot.transform.localScale = new Vector2 (1, 1);
						
						int kuniId = int.Parse(okKuniList[i]);
						string kuniName = kuni.getKuniName(kuniId);

						slot.transform.FindChild("Name").GetComponent<Text>().text = kuniName;


						//Status
						int jyosyuHei = 0;
						string naiseiTemp = "naisei" + kuniId.ToString();
						string naiseiString = PlayerPrefs.GetString (naiseiTemp);

						List<string> naiseiList = new List<string>();
						naiseiList = new List<string>(naiseiString.Split (delimiterChars));
						char[] delimiterChars2 = {':'};
						Entity_naisei_mst naiseiMst = Resources.Load ("Data/naisei_mst") as Entity_naisei_mst;
						NaiseiController naisei = new NaiseiController();


						string shiroLv = naiseiList[0];
						List<int> shiroEffectList = new List<int>();
						shiroEffectList = naisei.getNaiseiList("shiro", int.Parse(shiroLv));
						jyosyuHei = shiroEffectList[0];

						for(int j=1; j<naiseiList.Count;j++){
							List<string> naiseiContentList = new List<string>();
							naiseiContentList = new List<string>(naiseiList[j].Split (delimiterChars2));

							if(naiseiContentList[0] != "0"){
								string type = naiseiMst.param [int.Parse(naiseiContentList[0])].code;
								if(type == "hsy"){
									List<int> naiseiEffectList = new List<int>();
									naiseiEffectList = naisei.getNaiseiList(type, int.Parse(naiseiContentList[1]));

									jyosyuHei = jyosyuHei + naiseiEffectList[0];
								}

							}
						}


						slot.transform.FindChild("EffectValue").GetComponent<Text>().text = "+" + jyosyuHei.ToString();
						
						GameObject btn = slot.transform.FindChild("GiveButton").gameObject;
						btn.GetComponent<DoNinmei>().busyoId = busyoId;
						btn.GetComponent<DoNinmei>().kuniId = kuniId;
						btn.GetComponent<DoNinmei>().jyosyuHei = jyosyuHei;
					}



				}else{
					Message msg = new Message();
					msg.makeMessage("任命可能な国はありませんぞ。\nまずは城を落としなされ。");
				}




			}else{
				string backPath = "Prefabs/Common/TouchBack";
				GameObject back = Instantiate (Resources.Load (backPath)) as GameObject;
				back.transform.SetParent(GameObject.Find ("Panel").transform);
				back.transform.localScale = new Vector2 (1, 1);
				RectTransform backTransform = back.GetComponent<RectTransform> ();
				backTransform.anchoredPosition3D = new Vector3 (0, 0, 0);
				back.name = "TouchBack";

				//Message Box
				string msgPath = "Prefabs/Naisei/KaininConfirm";
				GameObject msg = Instantiate (Resources.Load (msgPath)) as GameObject;
				msg.transform.SetParent(back.transform);
				msg.transform.localScale = new Vector2 (1, 1);
				RectTransform msgTransform = msg.GetComponent<RectTransform> ();
				msgTransform.anchoredPosition3D = new Vector3 (0, 0, 0);
				msgTransform.name = "kaininConfirm";
				msg.transform.FindChild("YesButton").GetComponent<DoKainin>().kuniId = jyosyuKuniId;


				//Message Text Mod
				GameObject msgObj = msg.transform.FindChild ("KaininText").gameObject;
				int myDaimyoBusyo = PlayerPrefs.GetInt ("myDaimyoBusyo");
				string msgText = msgObj.GetComponent<Text> ().text;
				if (myDaimyoBusyo == int.Parse(busyoId)) {
					msgText = msgText.Replace("A殿を", "自らを");
				} else {
					msgText = msgText.Replace("A", jyosyuName);
				}
				msgObj.GetComponent<Text> ().text = msgText;
			}

		}


	}
예제 #8
0
	public void kuniScrollView(GameObject baseObj,  string targetDaimyo, GameObject btn){
		
		GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject;

		string seiryoku = PlayerPrefs.GetString ("seiryoku");
		char[] delimiterChars = {','};
		List<string> seiryokuList = new List<string>();
		seiryokuList = new List<string> (seiryoku.Split (delimiterChars));

		//my kuni
		int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
		string myKuni = PlayerPrefs.GetString ("clearedKuni"); 
		List<int> myKuniList = new List<int>();
		if (myKuni.Contains (",")) {
			List<string> tempMyKuniList = new List<string> (myKuni.Split (delimiterChars));
			myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x));
		} else {
			myKuniList.Add(int.Parse(myKuni));
		}

		//doumei daimyo's opne kuni
		KuniInfo kuni = new KuniInfo ();
		List<int> doumeiOpenKuniList = new List<int>();
		List<int> doumeiKuniList = new List<int>();
		for(int i=0; i<seiryokuList.Count; i++){
			string tempDaimyo = seiryokuList[i];
			if(tempDaimyo == targetDaimyo){
				int doumeiKuniId = i + 1;
				doumeiKuniList.Add(doumeiKuniId);
				doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId));
			}
		}

		//"doumei daimyo's opne kuni" minus "my kuni"  
		List<int> doumeiOpenKuniMinusMyKuniList = new List<int>();
		foreach(int n in doumeiOpenKuniList){

			if(!myKuniList.Contains(n)){
				doumeiOpenKuniMinusMyKuniList.Add(n);
			}
		}

		//"doumei daimyo's doumei check
		string tempDoumei = "doumei" + targetDaimyo;
		string doumei = PlayerPrefs.GetString (tempDoumei);
		List<string> doumeiList = new List<string>();
		if (doumei.Contains (",")) {
			doumeiList = new List<string> (doumei.Split (delimiterChars));
		} else {
			doumeiList.Add(doumei);
		}

		if (doumei != null && doumei != "") {
			for(int t=0; t<doumeiOpenKuniMinusMyKuniList.Count; t++){
			//foreach (int n in doumeiOpenKuniMinusMyKuniList) {
				string checkDaimyoId = seiryokuList [doumeiOpenKuniMinusMyKuniList[t] - 1];
				if (doumeiList.Contains (checkDaimyoId)) {
					doumeiOpenKuniMinusMyKuniList.Remove (doumeiOpenKuniMinusMyKuniList[t]);
				}
			}
		}



		//Compare "doumei open" with "my open"
		string myOpenKuni = PlayerPrefs.GetString ("openKuni"); 
		List<int> myOpenKuniList = new List<int>();
		if (myOpenKuni.Contains (",")) {
			List<string> tempMyOpenKuniList = new List<string> (myOpenKuni.Split (delimiterChars));
			myOpenKuniList = tempMyOpenKuniList.ConvertAll(x => int.Parse(x));
		} else {
			myOpenKuniList.Add(int.Parse(myOpenKuni));
		}

		List<int> sameTargetKuniList = new List<int>();
		foreach(int n in myOpenKuniList){
			if(doumeiOpenKuniMinusMyKuniList.Contains(n)){
				if(!doumeiKuniList.Contains(n)){
					sameTargetKuniList.Add(n);
				}
			}
		}


		/*Slot making*/
		string temp = "gaikou" + targetDaimyo;
		int myYukoudo = PlayerPrefs.GetInt(temp);

		//Get Chiryaku
		Entity_daimyo_mst daimyoMst = Resources.Load ("Data/daimyo_mst") as Entity_daimyo_mst;
		int myDaimyoBusyoId = daimyoMst.param [myDaimyo - 1].busyoId;
		StatusGet sts = new StatusGet();
		int lv = PlayerPrefs.GetInt (myDaimyoBusyoId.ToString());
		float chiryaku = (float)sts.getDfc(myDaimyoBusyoId,lv);
		chiryaku = chiryaku *10;


		string slotPath = "Prefabs/Map/common/kuniSlot";
		for (int i=0; i<sameTargetKuniList.Count; i++) {
			GameObject prefab = Instantiate (Resources.Load (slotPath)) as GameObject;
			prefab.transform.SetParent(content.transform);
			prefab.transform.localScale = new Vector3 (1, 1, 1);

			int kuniId = sameTargetKuniList[i];
			int daimyoId = int.Parse (seiryokuList [kuniId - 1]);
			string daimyoName = daimyoMst.param [daimyoId - 1].daimyoName;

			string theirYukouTemp = "";
			if(int.Parse(targetDaimyo) < daimyoId){
				theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString();
			}else{
				theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo;
			}

			int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp);

			string kuniName = kuni.getKuniName(kuniId);
			prefab.transform.FindChild("KuniValue").GetComponent<Text>().text = kuniName;
			prefab.transform.FindChild("DaimyoValue").GetComponent<Text>().text = daimyoName;
			prefab.GetComponent<GaikouKuniSelect>().Content = content;
			prefab.GetComponent<GaikouKuniSelect>().Btn = btn;

			prefab.GetComponent<GaikouKuniSelect>().myYukoudo = myYukoudo;
			prefab.GetComponent<GaikouKuniSelect>().chiryaku = (int)chiryaku;
			prefab.GetComponent<GaikouKuniSelect>().kuniDiff = kuniDiff;
			prefab.GetComponent<GaikouKuniSelect>().theirYukoudo = theirYukoudo;
			prefab.GetComponent<GaikouKuniSelect>().kuniName = kuniName;
			prefab.GetComponent<GaikouKuniSelect>().targetKuniId = kuniId;

			if(i == 0){
				prefab.GetComponent<GaikouKuniSelect>().OnClick();
			}
		}

		if (sameTargetKuniList.Count == 0) {
			string msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg";
			GameObject msg = Instantiate (Resources.Load (msgPath)) as GameObject;
			msg.transform.SetParent(GameObject.Find("scroll").transform);
			msg.transform.localScale = new Vector3 (0.17f, 0.2f, 1);
			RectTransform msgTransform = msg.GetComponent<RectTransform> ();
			msgTransform.anchoredPosition = new Vector3 (-260, -115, 0);

			GameObject a = baseObj.transform.FindChild ("RequiredMoney").gameObject;
			GameObject b = baseObj.transform.FindChild ("KyoutouRatio").gameObject;
			Destroy(a);
			Destroy(b);

			btn.GetComponent<Button>().enabled = false;
			
		}

		
	}
예제 #9
0
    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);
        }
    }
예제 #10
0
	public void createSyoguView(string busyoId){

		int lv = PlayerPrefs.GetInt (busyoId);

		Color ngImageColor = new Color (40f / 255f, 40f / 255f, 40f / 255f, 180f / 255f);
		Color ngTextColor = new Color (90f / 255f, 90f / 255f, 90f / 255f, 90f / 255f);
		Color okImageColor = new Color (255f / 255f, 255f / 255f, 255f / 255f, 150f / 255f);
		Color okTextColor = new Color (40f / 255f, 40f / 255f, 0f / 255f, 255f / 255f);
		
		GameObject kanjyo = GameObject.Find("kanjyo").gameObject;
		GameObject tsuihou = GameObject.Find("tsuihou").gameObject;

		int daimyoBusyoId = PlayerPrefs.GetInt ("myDaimyoBusyo");
		if (busyoId == daimyoBusyoId.ToString ()) {
			kanjyo.GetComponent<Image> ().color = ngImageColor; 
			kanjyo.transform.FindChild ("Text").GetComponent<Text> ().color = ngTextColor; 
			kanjyo.GetComponent<Button> ().enabled = false;

			tsuihou.GetComponent<Image> ().color = ngImageColor; 
			tsuihou.transform.FindChild ("Text").GetComponent<Text> ().color = ngTextColor; 
			tsuihou.GetComponent<Button> ().enabled = false;

		} else {

			if (lv != 100) {
				kanjyo.GetComponent<BusyoStatusButton> ().pa_lv = lv;
				kanjyo.GetComponent<Image> ().color = okImageColor; 
				kanjyo.transform.FindChild ("Text").GetComponent<Text> ().color = okTextColor;
				kanjyo.GetComponent<Button> ().enabled = true;
			} else {
				kanjyo.GetComponent<Image> ().color = ngImageColor; 
				kanjyo.transform.FindChild ("Text").GetComponent<Text> ().color = ngTextColor; 
				kanjyo.GetComponent<Button> ().enabled = false;
			}

			tsuihou.GetComponent<Image> ().color = okImageColor;
			tsuihou.transform.FindChild ("Text").GetComponent<Text> ().color = okTextColor; 
			tsuihou.GetComponent<Button> ().enabled = true;

		}
		
		GameObject kanni = GameObject.Find("kanni").gameObject;
		GameObject jyosyu = GameObject.Find("jyosyu").gameObject;
		GameObject syugyo = GameObject.Find("syugyo").gameObject;
		GameObject gokui = GameObject.Find("gokui").gameObject;
		kanni.GetComponent<RonkouKousyoMenu>().busyoId = busyoId;
		jyosyu.GetComponent<RonkouKousyoMenu>().busyoId = busyoId;
		syugyo.GetComponent<RonkouKousyoMenu>().busyoId = busyoId;
		gokui.GetComponent<RonkouKousyoMenu>().busyoId = busyoId;

		//Kanni
		string kanniTmp = "kanni" + busyoId;
		Kanni kanniScript = new Kanni();
		if (PlayerPrefs.HasKey (kanniTmp)) {
			int kanniId = PlayerPrefs.GetInt (kanniTmp);
			if (kanniId != 0) {
				foreach(Transform n in kanni.transform){
					if(n.name == "KanniName"){
						Destroy(n.gameObject);
					}
				}
				kanni.GetComponent<RonkouKousyoMenu> ().kanniId = kanniId;
				string path = "Prefabs/Busyo/KanniName";
				GameObject kanniName = Instantiate (Resources.Load (path)) as GameObject;
				kanniName.transform.SetParent (kanni.transform);
				kanniName.transform.localScale = new Vector2 (0.12f, 0.12f);
				kanniName.transform.localPosition = new Vector2 (0, 0);
				kanniName.name = "KanniName";

				string kanniNameString = kanniScript.getKanni(kanniId);
				string kanniIkai = kanniScript.getIkai(kanniId);
				kanniName.transform.FindChild("value").GetComponent<Text>().text = kanniIkai + "\t" + kanniNameString; 

				string effectLabel = kanniScript.getEffectLabel(kanniId);
				int effect = kanniScript.getEffect(kanniId);
				kanniName.transform.FindChild("effectLabel").GetComponent<Text>().text = effectLabel;
				kanniName.transform.FindChild("effectValue").GetComponent<Text>().text = "+" + effect.ToString() + "%"; 

				kanni.transform.FindChild ("Text").GetComponent<Text> ().enabled = false;
			}
		} else {
			foreach(Transform n in kanni.transform){
				if(n.name == "KanniName"){
					Destroy(n.gameObject);
				}
			}


			kanni.GetComponent<RonkouKousyoMenu> ().kanniId = 0;
			kanni.transform.FindChild ("Text").GetComponent<Text> ().enabled = true;
		}

		//Jyosyu
		string jyosyuTmp = "jyosyuBusyo" + busyoId;

		if (PlayerPrefs.HasKey (jyosyuTmp)) {
			BusyoInfoGet busyoInfo = new BusyoInfoGet ();
			string busyoName = busyoInfo.getName (int.Parse(busyoId));
			jyosyu.GetComponent<RonkouKousyoMenu>().jyosyuName = busyoName;

			int kuniId = PlayerPrefs.GetInt(jyosyuTmp);

			if(kuniId !=0){
				foreach(Transform n in jyosyu.transform){
					if(n.name == "JyosyuName"){
						Destroy(n.gameObject);
					}
				}

				KuniInfo kuni = new KuniInfo();
				string kuniName = kuni.getKuniName(kuniId);

				string jyosyuHeiTmp = "jyosyuHei" + busyoId;
				int jyosyuHei = PlayerPrefs.GetInt(jyosyuHeiTmp);

				jyosyu.GetComponent<RonkouKousyoMenu>().jyosyuKuniId = kuniId;
				string jyosyuPath = "Prefabs/Busyo/JyosyuName";
				GameObject jyosyuName = Instantiate (Resources.Load (jyosyuPath)) as GameObject;
				jyosyuName.transform.SetParent (jyosyu.transform);
				jyosyuName.transform.localScale = new Vector2 (0.12f, 0.12f);
				jyosyuName.transform.localPosition = new Vector2 (0, 0);
				jyosyuName.name = "JyosyuName";

				jyosyuName.transform.FindChild("value").GetComponent<Text>().text = kuniName; 
				jyosyuName.transform.FindChild("effectValue").GetComponent<Text>().text = "+" + jyosyuHei.ToString();
				
				jyosyu.transform.FindChild ("Text").GetComponent<Text> ().enabled = false;
			}			
		} else {
			foreach(Transform n in jyosyu.transform){
				if(n.name == "JyosyuName"){
					Destroy(n.gameObject);
				}
			}
			jyosyu.GetComponent<RonkouKousyoMenu> ().jyosyuKuniId = 0;
			jyosyu.transform.FindChild ("Text").GetComponent<Text> ().enabled = true;
		}




	}
예제 #11
0
    public void SyuppeiKuniScrollView(GameObject baseObj, string targetDaimyo, GameObject btn)
    {
        //View kuni which have openkuni

        GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject;

        string seiryoku = PlayerPrefs.GetString("seiryoku");

        char[]        delimiterChars = { ',' };
        List <string> seiryokuList   = new List <string>();

        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

        //my kuni
        int        myDaimyo   = PlayerPrefs.GetInt("myDaimyo");
        string     myKuni     = PlayerPrefs.GetString("clearedKuni");
        List <int> myKuniList = new List <int>();

        if (myKuni.Contains(","))
        {
            List <string> tempMyKuniList = new List <string> (myKuni.Split(delimiterChars));
            myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x));
        }
        else
        {
            myKuniList.Add(int.Parse(myKuni));
        }

        //doumei daimyo's opne kuni
        KuniInfo   kuni = new KuniInfo();
        List <int> doumeiOpenKuniList = new List <int>();
        List <int> doumeiKuniList     = new List <int>();

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            string tempDaimyo = seiryokuList[i];
            if (tempDaimyo == targetDaimyo)
            {
                int doumeiKuniId = i + 1;
                doumeiKuniList.Add(doumeiKuniId);
                doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId));
            }
        }

        //"doumei daimyo's doumei check
        string        tempDoumei = "doumei" + targetDaimyo;
        string        doumei     = PlayerPrefs.GetString(tempDoumei);
        List <string> doumeiList = new List <string>();

        if (doumei.Contains(","))
        {
            doumeiList = new List <string> (doumei.Split(delimiterChars));
        }
        else
        {
            doumeiList.Add(doumei);
        }


        //"doumei daimyo's opne kuni" minus "my kuni"  /minus Doumei's doumei
        List <int> doumeiOpenKuniMinusMyKuniList = new List <int>();

        foreach (int n in doumeiOpenKuniList)
        {
            if (!myKuniList.Contains(n))
            {
                if (!doumeiKuniList.Contains(n))
                {
                    if (doumeiList.Count != 0)
                    {
                        string checkDaimyoId = seiryokuList [n - 1];
                        if (!doumeiList.Contains(checkDaimyoId))
                        {
                            doumeiOpenKuniMinusMyKuniList.Add(n);
                        }
                    }
                    else
                    {
                        doumeiOpenKuniMinusMyKuniList.Add(n);
                    }
                }
            }
        }


        //delete duplication
        List <int> finalKuniList = new List <int>();

        for (int i = 0; i < doumeiOpenKuniMinusMyKuniList.Count; i++)
        {
            int tmpKuniId = doumeiOpenKuniMinusMyKuniList [i];

            if (!finalKuniList.Contains(tmpKuniId))
            {
                finalKuniList.Add(tmpKuniId);
            }
        }

        //Src Kuni List
        List <int> srcKuniList = new List <int>();

        for (int j = 0; j < finalKuniList.Count; j++)
        {
            int dstKuniId = finalKuniList [j];

            List <int> targetKuniList = new List <int>();
            targetKuniList.AddRange(kuni.getMappingKuni(dstKuniId));
            for (int k = 0; k < targetKuniList.Count; k++)
            {
                int srcKuniId = targetKuniList [k];
                if (doumeiKuniList.Contains(srcKuniId))
                {
                    srcKuniList.Add(srcKuniId);
                    break;
                }
            }
        }



        /*Slot making*/
        string temp      = "gaikou" + targetDaimyo;
        int    myYukoudo = PlayerPrefs.GetInt(temp);

        //Get Chiryaku
        //Entity_daimyo_mst daimyoMst = Resources.Load ("Data/daimyo_mst") as Entity_daimyo_mst;
        Daimyo       daimyoScript    = new Daimyo();
        int          myDaimyoBusyoId = daimyoScript.getDaimyoBusyoId(myDaimyo);
        BusyoInfoGet busyo           = new BusyoInfoGet();
        int          chiryaku        = busyo.getMaxDfc(myDaimyoBusyoId);

        string slotPath = "Prefabs/Map/common/kuniSlot";

        for (int i = 0; i < finalKuniList.Count; i++)
        {
            GameObject prefab = Instantiate(Resources.Load(slotPath)) as GameObject;
            prefab.transform.SetParent(content.transform);
            prefab.transform.localScale = new Vector3(1, 1, 1);

            int    kuniId        = finalKuniList[i];
            int    daimyoId      = int.Parse(seiryokuList [kuniId - 1]);
            string daimyoName    = daimyoScript.getName(daimyoId);
            int    srcKuniId     = srcKuniList [i];
            int    srcDaimyoId   = int.Parse(seiryokuList [srcKuniId - 1]);
            string srcDaimyoName = daimyoScript.getName(srcDaimyoId);

            string theirYukouTemp = "";
            if (int.Parse(targetDaimyo) < daimyoId)
            {
                theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString();
            }
            else
            {
                theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo;
            }

            int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp);

            string kuniName = kuni.getKuniName(kuniId);
            prefab.transform.FindChild("KuniValue").GetComponent <Text>().text   = kuniName;
            prefab.transform.FindChild("DaimyoValue").GetComponent <Text>().text = daimyoName;
            prefab.GetComponent <GaikouKuniSelect>().Content = content;
            prefab.GetComponent <GaikouKuniSelect>().Btn     = btn;

            prefab.GetComponent <GaikouKuniSelect>().myYukoudo        = myYukoudo;
            prefab.GetComponent <GaikouKuniSelect>().chiryaku         = chiryaku;
            prefab.GetComponent <GaikouKuniSelect>().kuniDiff         = kuniDiff;
            prefab.GetComponent <GaikouKuniSelect>().theirYukoudo     = theirYukoudo;
            prefab.GetComponent <GaikouKuniSelect>().kuniName         = kuniName;
            prefab.GetComponent <GaikouKuniSelect>().targetKuniId     = kuniId;
            prefab.GetComponent <GaikouKuniSelect>().targetDaimyoId   = daimyoId;
            prefab.GetComponent <GaikouKuniSelect>().targetDaimyoName = daimyoName;
            prefab.GetComponent <GaikouKuniSelect>().srcKuniId        = srcKuniId;
            prefab.GetComponent <GaikouKuniSelect>().srcDaimyoId      = srcDaimyoId;
            prefab.GetComponent <GaikouKuniSelect>().srcDaimyoName    = srcDaimyoName;

            if (i == 0)
            {
                prefab.GetComponent <GaikouKuniSelect>().OnClick();
            }
        }

        if (finalKuniList.Count == 0)
        {
            string     msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg";
            GameObject msg     = Instantiate(Resources.Load(msgPath)) as GameObject;
            msg.transform.SetParent(GameObject.Find("scroll").transform);
            msg.transform.localScale = new Vector3(0.17f, 0.2f, 1);
            RectTransform msgTransform = msg.GetComponent <RectTransform>();
            msgTransform.anchoredPosition = new Vector3(-260, -115, 0);
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                msg.GetComponent <Text>().text = "There is no available country.\nWe are surranded by allianced party.";
            }
            else
            {
                msg.GetComponent <Text>().text = "出兵可能な国はありませぬ\n周辺国は同盟大名しかおりませぬぞ";
            }

            GameObject a = baseObj.transform.FindChild("RequiredMoney").gameObject;
            GameObject b = baseObj.transform.FindChild("KyoutouRatio").gameObject;
            Destroy(a);
            Destroy(b);

            btn.GetComponent <Button>().enabled = false;
            Color NGClorBtn = new Color(133 / 255f, 133 / 255f, 80 / 255f, 255f / 255f);
            Color NGClorTxt = new Color(90 / 255f, 90 / 255f, 40 / 255f, 255f / 255f);
            btn.GetComponent <Image>().color = NGClorBtn;
            btn.transform.FindChild("Text").GetComponent <Text>().color = NGClorTxt;

            btn.transform.FindChild("hyourouIcon").GetComponent <Image>().color = NGClorBtn;
            btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text>().color = NGClorTxt;
            btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").transform.FindChild("syouhiText").GetComponent <Text>().color = NGClorTxt;
        }
    }
예제 #12
0
    public void kuniScrollView(GameObject baseObj, string targetDaimyo, GameObject btn)
    {
        GameObject content = baseObj.transform.FindChild("scroll").transform.FindChild("Content").gameObject;

        string seiryoku = PlayerPrefs.GetString("seiryoku");

        char[]        delimiterChars = { ',' };
        List <string> seiryokuList   = new List <string>();

        seiryokuList = new List <string> (seiryoku.Split(delimiterChars));

        //my kuni
        int        myDaimyo   = PlayerPrefs.GetInt("myDaimyo");
        string     myKuni     = PlayerPrefs.GetString("clearedKuni");
        List <int> myKuniList = new List <int>();

        if (myKuni.Contains(","))
        {
            List <string> tempMyKuniList = new List <string> (myKuni.Split(delimiterChars));
            myKuniList = tempMyKuniList.ConvertAll(x => int.Parse(x));
        }
        else
        {
            myKuniList.Add(int.Parse(myKuni));
        }

        //doumei daimyo's opne kuni
        KuniInfo   kuni = new KuniInfo();
        List <int> doumeiOpenKuniList = new List <int>();
        List <int> doumeiKuniList     = new List <int>();

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            string tempDaimyo = seiryokuList[i];
            if (tempDaimyo == targetDaimyo)
            {
                int doumeiKuniId = i + 1;
                doumeiKuniList.Add(doumeiKuniId);
                doumeiOpenKuniList.AddRange(kuni.getMappingKuni(doumeiKuniId));
            }
        }

        //"doumei daimyo's opne kuni" minus "my kuni"
        List <int> doumeiOpenKuniMinusMyKuniList = new List <int>();

        foreach (int n in doumeiOpenKuniList)
        {
            if (!myKuniList.Contains(n))
            {
                doumeiOpenKuniMinusMyKuniList.Add(n);
            }
        }

        //"doumei daimyo's doumei check
        string        tempDoumei = "doumei" + targetDaimyo;
        string        doumei     = PlayerPrefs.GetString(tempDoumei);
        List <string> doumeiList = new List <string>();

        if (doumei.Contains(","))
        {
            doumeiList = new List <string> (doumei.Split(delimiterChars));
        }
        else
        {
            doumeiList.Add(doumei);
        }

        if (doumei != null && doumei != "")
        {
            for (int t = 0; t < doumeiOpenKuniMinusMyKuniList.Count; t++)
            {
                //foreach (int n in doumeiOpenKuniMinusMyKuniList) {
                string checkDaimyoId = seiryokuList [doumeiOpenKuniMinusMyKuniList[t] - 1];
                if (doumeiList.Contains(checkDaimyoId))
                {
                    doumeiOpenKuniMinusMyKuniList.Remove(doumeiOpenKuniMinusMyKuniList[t]);
                }
            }
        }



        //Compare "doumei open" with "my open"
        string     myOpenKuni     = PlayerPrefs.GetString("openKuni");
        List <int> myOpenKuniList = new List <int>();

        if (myOpenKuni.Contains(","))
        {
            List <string> tempMyOpenKuniList = new List <string> (myOpenKuni.Split(delimiterChars));
            myOpenKuniList = tempMyOpenKuniList.ConvertAll(x => int.Parse(x));
        }
        else
        {
            myOpenKuniList.Add(int.Parse(myOpenKuni));
        }

        List <int> sameTargetKuniList = new List <int>();

        foreach (int n in myOpenKuniList)
        {
            if (doumeiOpenKuniMinusMyKuniList.Contains(n))
            {
                if (!doumeiKuniList.Contains(n))
                {
                    if (!sameTargetKuniList.Contains(n))
                    {
                        sameTargetKuniList.Add(n);
                    }
                }
            }
        }


        /*Slot making*/
        string temp      = "gaikou" + targetDaimyo;
        int    myYukoudo = PlayerPrefs.GetInt(temp);

        //Get Chiryaku
        Daimyo            daimyoScript = new Daimyo();
        Entity_daimyo_mst daimyoMst    = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst;
        int          myDaimyoBusyoId   = daimyoMst.param [myDaimyo - 1].busyoId;
        BusyoInfoGet busyo             = new BusyoInfoGet();
        int          chiryaku          = busyo.getMaxDfc(myDaimyoBusyoId);
        //StatusGet sts = new StatusGet();
        //int lv = PlayerPrefs.GetInt (myDaimyoBusyoId.ToString());
        //float chiryaku = (float)sts.getDfc(myDaimyoBusyoId,lv);
        //chiryaku = chiryaku *10;


        string slotPath = "Prefabs/Map/common/kuniSlot";

        for (int i = 0; i < sameTargetKuniList.Count; i++)
        {
            GameObject prefab = Instantiate(Resources.Load(slotPath)) as GameObject;
            prefab.transform.SetParent(content.transform);
            prefab.transform.localScale = new Vector3(1, 1, 1);

            int kuniId   = sameTargetKuniList[i];
            int daimyoId = int.Parse(seiryokuList [kuniId - 1]);
            // daimyoName = daimyoMst.param [daimyoId - 1].daimyoName;
            string daimyoName = daimyoScript.getName(daimyoId);


            string theirYukouTemp = "";
            if (int.Parse(targetDaimyo) < daimyoId)
            {
                theirYukouTemp = targetDaimyo + "gaikou" + daimyoId.ToString();
            }
            else
            {
                theirYukouTemp = daimyoId.ToString() + "gaikou" + targetDaimyo;
            }

            int theirYukoudo = PlayerPrefs.GetInt(theirYukouTemp);

            string kuniName = kuni.getKuniName(kuniId);
            prefab.transform.FindChild("KuniValue").GetComponent <Text>().text   = kuniName;
            prefab.transform.FindChild("DaimyoValue").GetComponent <Text>().text = daimyoName;
            prefab.GetComponent <GaikouKuniSelect>().Content = content;
            prefab.GetComponent <GaikouKuniSelect>().Btn     = btn;

            prefab.GetComponent <GaikouKuniSelect>().myYukoudo    = myYukoudo;
            prefab.GetComponent <GaikouKuniSelect>().chiryaku     = chiryaku;
            prefab.GetComponent <GaikouKuniSelect>().kuniDiff     = kuniDiff;
            prefab.GetComponent <GaikouKuniSelect>().theirYukoudo = theirYukoudo;
            prefab.GetComponent <GaikouKuniSelect>().kuniName     = kuniName;
            prefab.GetComponent <GaikouKuniSelect>().targetKuniId = kuniId;

            if (i == 0)
            {
                prefab.GetComponent <GaikouKuniSelect>().OnClick();
            }
        }

        if (sameTargetKuniList.Count == 0)
        {
            string     msgPath = "Prefabs/Map/gaikou/NoKyoutouMsg";
            GameObject msg     = Instantiate(Resources.Load(msgPath)) as GameObject;
            msg.transform.SetParent(GameObject.Find("scroll").transform);
            msg.transform.localScale = new Vector3(0.17f, 0.2f, 1);
            RectTransform msgTransform = msg.GetComponent <RectTransform> ();
            msgTransform.anchoredPosition = new Vector3(-260, -115, 0);

            GameObject a = baseObj.transform.FindChild("RequiredMoney").gameObject;
            GameObject b = baseObj.transform.FindChild("KyoutouRatio").gameObject;
            Destroy(a);
            Destroy(b);

            btn.GetComponent <Button>().enabled = false;
            Color NGClorBtn = new Color(133 / 255f, 133 / 255f, 80 / 255f, 255f / 255f);
            Color NGClorTxt = new Color(90 / 255f, 90 / 255f, 40 / 255f, 255f / 255f);
            btn.GetComponent <Image>().color = NGClorBtn;
            btn.transform.FindChild("Text").GetComponent <Text>().color = NGClorTxt;

            btn.transform.FindChild("hyourouIcon").GetComponent <Image>().color = NGClorBtn;
            btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").GetComponent <Text>().color = NGClorTxt;
            btn.transform.FindChild("hyourouIcon").transform.FindChild("hyourouNoValue").transform.FindChild("syouhiText").GetComponent <Text>().color = NGClorTxt;
        }
    }
예제 #13
0
	// Use this for initialization
	public void OnClick () {

		CloseBoard close = GameObject.Find ("close").GetComponent<CloseBoard> ();
		close.layer = close.layer + 1;

		int nowHyourou = PlayerPrefs.GetInt ("hyourou");
		bool hyourouOKflg = false;

		int daimyoId = GameObject.Find ("close").GetComponent<CloseBoard>().daimyoId;

		if (name == "Cyouhou") {
		} else if (name == "Ryugen") {
		} else if (name == "Goudatsu") {
		} else if (name == "Gihou") {
			//Gunzei Check
			bool gunzeiFlg = false;
			foreach (GameObject obs in  GameObject.FindGameObjectsWithTag("Gunzei")){
				int checkDaimyoId = obs.GetComponent<Gunzei>().srcDaimyoId;
				if(checkDaimyoId == daimyoId){
					gunzeiFlg = true;
					targetGunzei = obs;
					break;
				}
			}

			if(gunzeiFlg){
				//Menu Handling
				GameObject.Find ("kuniName").GetComponent<Text> ().text = "偽報";
				OffBouryakuMenu ();

				string path = "Prefabs/Map/bouryaku/GihouObj";
				GameObject obj = Instantiate (Resources.Load (path)) as GameObject;
				obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform);
				obj.transform.localScale = new Vector3 (1, 1, 1);

				//Label
				int dstKuni = targetGunzei.GetComponent<Gunzei>().dstKuni;
				int hei = targetGunzei.GetComponent<Gunzei>().myHei;
				KuniInfo kuni = new KuniInfo();
				string kuniName = kuni.getKuniName(dstKuni);
				obj.transform.FindChild("GunzeiInfo").transform.FindChild("DaimyoNameValue").GetComponent<Text>().text = kuniName + "に進軍中";
				obj.transform.FindChild("Heiryoku").transform.FindChild("HeiryokuValue").GetComponent<Text>().text = hei.ToString();

				//Shinobi Slot
				int shinobiGe = PlayerPrefs.GetInt ("shinobiGe");
				int shinobiCyu = PlayerPrefs.GetInt ("shinobiCyu");
				int shinobiJyo = PlayerPrefs.GetInt ("shinobiJyo");
				int total = shinobiGe + shinobiCyu + shinobiJyo;

				GameObject btn = obj.transform.FindChild("DoGihouBtn").gameObject;
				if(total ==0){
					//Error Message

					btn.GetComponent<Button>().enabled = false;


				}else{
					string slotPath = "Prefabs/Map/common/ShinobiSlot";
					string shinobiItemPath = "Prefabs/Item/Shinobi/Shinobi";

					GameObject content = obj.transform.FindChild("ScrollView").transform.FindChild("Content").gameObject;

					
					if(shinobiGe!=0){
						GameObject slot = Instantiate (Resources.Load (slotPath)) as GameObject;			
						slot.transform.SetParent (content.transform);
						slot.transform.localScale = new Vector3 (1, 1, 1);
						slot.name = "Ge";

						GameObject shinobi = Instantiate (Resources.Load (shinobiItemPath)) as GameObject;	
						shinobi.transform.SetParent (slot.transform);
						shinobi.transform.localScale = new Vector3 (1, 1, 1);

						Color lowColor = new Color (0f / 255f, 0f / 255f, 219f / 255f, 255f / 255f);
						shinobi.GetComponent<Image>().color = lowColor;
						shinobi.transform.FindChild("ShinobiRank").GetComponent<Text>().text = "下";
						shinobi.transform.FindChild("Qty").GetComponent<Text>().text = shinobiGe.ToString();

						RectTransform shinobiTransform = shinobi.transform.FindChild("Shinobi").GetComponent<RectTransform> ();
						shinobiTransform.sizeDelta = new Vector2( 155, 190);
						RectTransform qtyTransform = shinobi.transform.FindChild("Qty").GetComponent<RectTransform> ();
						qtyTransform.anchoredPosition = new Vector3 (-50, -65, 0);

						slot.GetComponent<GaikouShinobiSelect>().Gunzei = targetGunzei;
						slot.GetComponent<GaikouShinobiSelect>().Content = content;
						slot.GetComponent<GaikouShinobiSelect>().DoBtn = btn;
						slot.GetComponent<GaikouShinobiSelect>().qty = shinobiGe;
					}

					if(shinobiCyu!=0){
						GameObject slot = Instantiate (Resources.Load (slotPath)) as GameObject;			
						slot.transform.SetParent (content.transform);
						slot.transform.localScale = new Vector3 (1, 1, 1);
						slot.name = "Cyu";

						GameObject shinobi = Instantiate (Resources.Load (shinobiItemPath)) as GameObject;	
						shinobi.transform.SetParent (slot.transform);
						shinobi.transform.localScale = new Vector3 (1, 1, 1);
						
						Color midColor = new Color (94f / 255f, 0f / 255f, 0f / 255f, 255f / 255f);
						shinobi.GetComponent<Image>().color = midColor;
						shinobi.transform.FindChild("ShinobiRank").GetComponent<Text>().text = "中";
						shinobi.transform.FindChild("Qty").GetComponent<Text>().text = shinobiCyu.ToString();

						RectTransform shinobiTransform = shinobi.transform.FindChild("Shinobi").GetComponent<RectTransform> ();
						shinobiTransform.sizeDelta = new Vector2( 155, 190);
						RectTransform qtyTransform = shinobi.transform.FindChild("Qty").GetComponent<RectTransform> ();
						qtyTransform.anchoredPosition = new Vector3 (-50, -65, 0);

						slot.GetComponent<GaikouShinobiSelect>().Gunzei = targetGunzei;
						slot.GetComponent<GaikouShinobiSelect>().Content = content;
						slot.GetComponent<GaikouShinobiSelect>().DoBtn = btn;
						slot.GetComponent<GaikouShinobiSelect>().qty = shinobiCyu;
					}

					if(shinobiJyo!=0){
						GameObject slot = Instantiate (Resources.Load (slotPath)) as GameObject;			
						slot.transform.SetParent (content.transform);
						slot.transform.localScale = new Vector3 (1, 1, 1);
						slot.name = "Jyo";

						GameObject shinobi = Instantiate (Resources.Load (shinobiItemPath)) as GameObject;	
						shinobi.transform.SetParent (slot.transform);
						shinobi.transform.localScale = new Vector3 (1, 1, 1);
						
						Color highColor = new Color (84f / 255f, 103f / 255f, 0f / 255f, 255f / 255f);
						shinobi.GetComponent<Image>().color = highColor;
						shinobi.transform.FindChild("ShinobiRank").GetComponent<Text>().text = "上";
						shinobi.transform.FindChild("Qty").GetComponent<Text>().text = shinobiJyo.ToString();

						RectTransform shinobiTransform = shinobi.transform.FindChild("Shinobi").GetComponent<RectTransform> ();
						shinobiTransform.sizeDelta = new Vector2( 155, 190);
						RectTransform qtyTransform = shinobi.transform.FindChild("Qty").GetComponent<RectTransform> ();
						qtyTransform.anchoredPosition = new Vector3 (-50, -65, 0);

						slot.GetComponent<GaikouShinobiSelect>().Gunzei = targetGunzei;
						slot.GetComponent<GaikouShinobiSelect>().Content = content;
						slot.GetComponent<GaikouShinobiSelect>().DoBtn = btn;
						slot.GetComponent<GaikouShinobiSelect>().qty = shinobiJyo;
					}





				}
				GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj;

			}else{
				Message msg = new Message();
				string NGtext = "進軍中の軍勢がおりませぬぞ。";
				msg.makeMessage (NGtext);
			}

		}


	}
예제 #14
0
	// Use this for initialization
	public void OnClick () {

		//SE
		sound = GameObject.Find ("SEController").GetComponent<AudioSource> ();
		sound.PlayOneShot (sound.clip); 

		//Shinobi Check
		int shinobiGe = PlayerPrefs.GetInt ("shinobiGe");
		int shinobiCyu = PlayerPrefs.GetInt ("shinobiCyu");
		int shinobiJyo = PlayerPrefs.GetInt ("shinobiJyo");

		int total = shinobiGe + shinobiCyu + shinobiJyo;

		if (total == 0) {
			Message msg = new Message ();
			string text = "派遣可能な忍はおりませんぞ。";
			msg.makeMessage (text);

		}else{

			CloseBoard close = GameObject.Find ("close").GetComponent<CloseBoard> ();
			close.layer = close.layer + 1;

			int nowHyourou = PlayerPrefs.GetInt ("hyourou");
			bool hyourouOKflg = false;

			int daimyoId = GameObject.Find ("close").GetComponent<CloseBoard>().daimyoId;


			if (name == "Cyouhou") {
				GameObject.Find ("kuniName").GetComponent<Text> ().text = "諜報";
				OffBouryakuMenuList();
				
				string path = "Prefabs/Map/bouryaku/bouryakuObj";
				GameObject obj= Instantiate (Resources.Load (path)) as GameObject;
				obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform);
				obj.transform.localScale = new Vector3 (1, 1, 1);
				GameObject btn = obj.transform.FindChild("DoBouryakuBtn").gameObject;
				btn.name = "DoCyouhouBtn";
				btn.transform.FindChild("Text").GetComponent<Text>().text = "諜報";

				shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn);

				GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj;

			} else if (name == "Ryugen") {
				GameObject.Find ("kuniName").GetComponent<Text> ().text = "流言";
				OffBouryakuMenuList();

				string path = "Prefabs/Map/bouryaku/bouryakuObj";
				GameObject obj= Instantiate (Resources.Load (path)) as GameObject;
				obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform);
				obj.transform.localScale = new Vector3 (1, 1, 1);
				GameObject btn = obj.transform.FindChild("DoBouryakuBtn").gameObject;
				btn.name = "DoRyugenBtn";
				btn.transform.FindChild("Text").GetComponent<Text>().text = "流言";

				shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn);

				GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj;

			} else if (name == "Goudatsu") {
				GameObject.Find ("kuniName").GetComponent<Text> ().text = "強奪";
				OffBouryakuMenuList();
				
				string path = "Prefabs/Map/bouryaku/bouryakuObj";
				GameObject obj= Instantiate (Resources.Load (path)) as GameObject;
				obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform);
				obj.transform.localScale = new Vector3 (1, 1, 1);
				GameObject btn = obj.transform.FindChild("DoBouryakuBtn").gameObject;
				btn.name = "DoGoudatsuBtn";
				btn.transform.FindChild("Text").GetComponent<Text>().text = "強奪";
				
				shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn);

				GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj;
			
			} else if (name == "Gihou") {
				//Gunzei Check
				bool gunzeiFlg = false;
				foreach (GameObject obs in  GameObject.FindGameObjectsWithTag("Gunzei")){
					int checkDaimyoId = obs.GetComponent<Gunzei>().srcDaimyoId;
					if(checkDaimyoId == daimyoId){
						gunzeiFlg = true;
						targetGunzei = obs;
						break;
					}
				}

				if(gunzeiFlg){
					//Menu Handling
					GameObject.Find ("kuniName").GetComponent<Text> ().text = "偽報";
					OffBouryakuMenu ();

					string path = "Prefabs/Map/bouryaku/GihouObj";
					GameObject obj = Instantiate (Resources.Load (path)) as GameObject;
					obj.transform.SetParent (GameObject.Find ("smallBoard(Clone)").transform);
					obj.transform.localScale = new Vector3 (1, 1, 1);

					//Label
					int dstKuni = targetGunzei.GetComponent<Gunzei>().dstKuni;
					int hei = targetGunzei.GetComponent<Gunzei>().myHei;
					KuniInfo kuni = new KuniInfo();
					string kuniName = kuni.getKuniName(dstKuni);
					obj.transform.FindChild("GunzeiInfo").transform.FindChild("DaimyoNameValue").GetComponent<Text>().text = kuniName + "に進軍中";
					obj.transform.FindChild("Heiryoku").transform.FindChild("HeiryokuValue").GetComponent<Text>().text = hei.ToString();

					GameObject btn = obj.transform.FindChild("DoGihouBtn").gameObject;

					shinobiScroll(obj, shinobiGe, shinobiCyu, shinobiJyo, btn);

					GameObject.Find ("return").GetComponent<MenuReturn> ().layer2 = obj;

				}else{
					Message msg = new Message();
					string NGtext = "進軍中の軍勢がおりませぬぞ。";
					msg.makeMessage (NGtext);
					close.layer = close.layer - 1;
				}
			}
		}
	}
예제 #15
0
    public void wasAttacked(string key, int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId, bool dstEngunFlg, string dstEngunDaimyoId, string dstEngunSts)
    {
        //In the case of My Damyo was Attacked

        //For Dramatic Enemy Creation
        GameObject kuniView = GameObject.Find("KuniIconView");

        if (kuniView.transform.FindChild(srcKuni.ToString()))
        {
            SendParam param    = kuniView.transform.FindChild(srcKuni.ToString()).GetComponent <SendParam> ();
            int       busyoQty = param.busyoQty;
            int       busyoLv  = param.busyoLv;
            int       butaiQty = param.butaiQty;
            int       butaiLv  = param.butaiLv;

            //Dummy
            PlayerPrefs.SetInt("activeStageId", 0);
            PlayerPrefs.SetInt("activeStageMoney", busyoQty * 500);
            PlayerPrefs.SetInt("activeStageExp", busyoQty * 100);
            PlayerPrefs.SetString("activeItemType", "");
            PlayerPrefs.SetInt("activeItemId", 0);
            PlayerPrefs.SetFloat("activeItemRatio", 0);
            PlayerPrefs.SetInt("activeItemQty", 0);

            //Actual
            PlayerPrefs.SetInt("activeKuniId", dstKuni);
            KuniInfo kuni       = new KuniInfo();
            string   kuniName   = kuni.getKuniName(dstKuni);
            string   kassenName = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                kassenName = kuniName + " Defence";
            }
            else
            {
                kassenName = kuniName + "防衛";
            }
            PlayerPrefs.SetString("activeStageName", kassenName);

            PlayerPrefs.SetInt("activeDaimyoId", srcDaimyoId);
            PlayerPrefs.SetInt("activeBusyoQty", busyoQty);
            PlayerPrefs.SetInt("activeBusyoLv", busyoLv);
            PlayerPrefs.SetInt("activeButaiQty", butaiQty);
            PlayerPrefs.SetInt("activeButaiLv", butaiLv);

            //Passive only
            PlayerPrefs.SetBool("isAttackedFlg", true);
            PlayerPrefs.DeleteKey("isKessenFlg");
            PlayerPrefs.SetString("activeKey", key);
            PlayerPrefs.SetInt("activeSrcDaimyoId", srcDaimyoId);
            PlayerPrefs.SetInt("activeDstDaimyoId", dstDaimyoId);

            //Engun
            if (dstEngunFlg)
            {
                PlayerPrefs.SetString("playerEngunList", dstEngunSts);
                PlayerPrefs.DeleteKey("enemyEngunList");
            }
            else
            {
                PlayerPrefs.DeleteKey("playerEngunList");
                PlayerPrefs.DeleteKey("enemyEngunList");
            }

            //Gaikou Down
            Gaikou gaikou = new Gaikou();
            gaikou.downGaikouByAttack(srcDaimyoId, dstDaimyoId);

            //Delete "Start Kassen Flg"
            PlayerPrefs.DeleteKey("activeLink");
            PlayerPrefs.DeleteKey("activePowerType");

            List <int> powerTypeList = new List <int> ()
            {
                1, 2, 3
            };
            int random = UnityEngine.Random.Range(1, powerTypeList.Count + 1);
            PlayerPrefs.SetInt("activePowerType", random);


            //Boubi effect
            string boubiTmp = "boubi" + dstKuni.ToString();
            int    boubi    = PlayerPrefs.GetInt(boubiTmp, 0);
            boubi = boubi / 10;
            PlayerPrefs.SetInt("activeBoubi", boubi);



            PlayerPrefs.Flush();
            Application.LoadLevel("preKassen");
        }
    }
예제 #16
0
    public void createBusyoStatusView(string busyoId)
    {
        bool tutorialDoneFlg = PlayerPrefs.GetBool("tutorialDoneFlg");
        int  lv = 1;

        if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialBusyo")
        {
            lv = PlayerPrefs.GetInt(busyoId);
        }

        StatusGet sts = new StatusGet();
        int       hp  = sts.getHp(int.Parse(busyoId), lv);
        int       atk = sts.getAtk(int.Parse(busyoId), lv);
        int       dfc = sts.getDfc(int.Parse(busyoId), lv);
        int       spd = sts.getSpd(int.Parse(busyoId), lv);

        int adjHp  = hp * 100;
        int adjAtk = atk * 10;
        int adjDfc = dfc * 10;

        //add lv
        string addLvTmp = "addlv" + busyoId.ToString();

        if (PlayerPrefs.HasKey(addLvTmp))
        {
            string addLvValue = "+" + PlayerPrefs.GetString(addLvTmp);
            GameObject.Find("addLvValue").GetComponent <Text>().text = addLvValue.ToString();
        }
        else
        {
            GameObject.Find("addLvValue").GetComponent <Text>().text = "";
        }
        int maxLv = 100 + PlayerPrefs.GetInt(addLvTmp);

        GameObject.Find("LvValue").GetComponent <Text> ().text       = lv.ToString();
        GameObject.Find("TosotsuValue").GetComponent <Text> ().text  = adjHp.ToString();
        GameObject.Find("BuyuuValue").GetComponent <Text> ().text    = adjAtk.ToString();
        GameObject.Find("ChiryakuValue").GetComponent <Text> ().text = adjDfc.ToString();
        GameObject.Find("SpeedValue").GetComponent <Text> ().text    = spd.ToString();


        //Exp
        string expId     = "exp" + busyoId.ToString();
        string expString = "";
        int    nowExp    = 0;

        if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialBusyo")
        {
            nowExp = PlayerPrefs.GetInt(expId);
        }
        Exp exp         = new Exp();
        int requiredExp = 0;

        if (lv != maxLv)
        {
            requiredExp = exp.getExpforNextLv(lv);
        }
        else
        {
            requiredExp = exp.getExpLvMax(maxLv);
        }

        expString = nowExp + "/" + requiredExp;
        GameObject.Find("ExpValue").GetComponent <Text> ().text = expString;


        //Kahou status
        int totalBusyoHp = 0;
        int finalAtk     = 0;
        int finalHp      = 0;
        int finalDfc     = 0;
        int finalSpd     = 0;

        if (tutorialDoneFlg && Application.loadedLevelName != "tutorialBusyo")
        {
            KahouStatusGet kahouSts         = new KahouStatusGet();
            string[]       KahouStatusArray = kahouSts.getKahouForStatus(busyoId, adjHp, adjAtk, adjDfc, spd);

            //Kanni
            string kanniTmp      = "kanni" + busyoId;
            float  addAtkByKanni = 0;
            float  addHpByKanni  = 0;
            float  addDfcByKanni = 0;

            if (PlayerPrefs.HasKey(kanniTmp))
            {
                int kanniId = PlayerPrefs.GetInt(kanniTmp);
                if (kanniId != 0)
                {
                    Kanni  kanni     = new Kanni();
                    string kanniIkai = kanni.getIkai(kanniId);
                    string kanniName = kanni.getKanni(kanniId);
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text> ().text = kanniIkai + "\n" + kanniName;

                    //Status
                    string kanniTarget = kanni.getEffectTarget(kanniId);
                    int    effect      = kanni.getEffect(kanniId);
                    if (kanniTarget == "atk")
                    {
                        addAtkByKanni = ((float)adjAtk * (float)effect) / 100;
                    }
                    else if (kanniTarget == "hp")
                    {
                        addHpByKanni = ((float)adjHp * (float)effect) / 100;
                    }
                    else if (kanniTarget == "dfc")
                    {
                        addDfcByKanni = ((float)adjDfc * (float)effect) / 100;
                    }
                }
                else
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank";
                    }
                    else
                    {
                        GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
                    }
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank";
                }
                else
                {
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
                }
            }

            //Jyosyu
            string jyosyuTmp = "jyosyuBusyo" + busyoId;
            if (PlayerPrefs.HasKey(jyosyuTmp))
            {
                int      kuniId   = PlayerPrefs.GetInt(jyosyuTmp);
                KuniInfo kuni     = new KuniInfo();
                string   kuniName = kuni.getKuniName(kuniId);

                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = kuniName + "\nLord";
                }
                else
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = kuniName + "\n城主";
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "No Feud";
                }
                else
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "城無し";
                }
            }

            //Show Additional Status
            finalAtk = int.Parse(KahouStatusArray [0]) + Mathf.FloorToInt(addAtkByKanni);
            finalHp  = int.Parse(KahouStatusArray [1]) + Mathf.FloorToInt(addHpByKanni);
            finalDfc = int.Parse(KahouStatusArray [2]) + Mathf.FloorToInt(addDfcByKanni);
            finalSpd = int.Parse(KahouStatusArray [3]);

            GameObject.Find("KahouAtkValue").GetComponent <Text> ().text = "+" + finalAtk.ToString();
            GameObject.Find("KahouHpValue").GetComponent <Text>().text   = "+" + finalHp.ToString();
            totalBusyoHp = adjHp + finalHp;
            GameObject.Find("KahouDfcValue").GetComponent <Text>().text = "+" + finalDfc.ToString();
            GameObject.Find("KahouSpdValue").GetComponent <Text>().text = "+" + finalSpd.ToString();
        }
        else
        {
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank";
            }
            else
            {
                GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
            }

            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "No Feud";
            }
            else
            {
                GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "城無し";
            }
        }

        //Butai Status
        string heiId   = "hei" + busyoId.ToString();
        string chParam = "";

        if (!tutorialDoneFlg || Application.loadedLevelName != "tutorialBusyo")
        {
            chParam = PlayerPrefs.GetString(heiId, "0");
        }
        else
        {
            //retry tutorial
            chParam = "TP: 1:1:1";
        }

        if (chParam == "0" || chParam == "")
        {
            StatusGet statusScript  = new StatusGet();
            string    chParamHeisyu = statusScript.getHeisyu(int.Parse(busyoId));
            chParam = chParamHeisyu + ":1:1:1";
            PlayerPrefs.SetString(heiId, chParam);
            PlayerPrefs.Flush();
        }


        char[]   delimiterChars = { ':' };
        string[] ch_list        = chParam.Split(delimiterChars);

        string ch_type   = ch_list [0];
        int    ch_num    = int.Parse(ch_list [1]);
        int    ch_lv     = int.Parse(ch_list [2]);
        float  ch_status = float.Parse(ch_list [3]);

        string heisyu = "";

        Message msg = new Message();

        if (ch_type == "KB")
        {
            heisyu = msg.getMessage(55);
        }
        else if (ch_type == "YR")
        {
            heisyu = msg.getMessage(56);
        }
        else if (ch_type == "TP")
        {
            heisyu = msg.getMessage(57);
        }
        else if (ch_type == "YM")
        {
            heisyu = msg.getMessage(58);
        }

        GameObject.Find("ChildNameValue").GetComponent <Text> ().text = heisyu;
        GameObject.Find("ChildQtyValue").GetComponent <Text> ().text  = ch_num.ToString();
        GameObject.Find("ChildLvValue").GetComponent <Text> ().text   = ch_lv.ToString();

        //Jyosyu Handling
        JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku();
        float          addHei    = (float)jyosyuHei.GetJyosyuHeiryoku(busyoId);
        float          hei       = ch_status * 10;

        GameObject.Find("ChildHeiryokuValue").GetComponent <Text> ().text = hei.ToString();
        float newHei = finalHp + addHei;

        GameObject.Find("KahouHpValue").GetComponent <Text>().text = "+" + newHei.ToString();


        int    chAtkDfc       = (int)sts.getChAtkDfc((int)hei, totalBusyoHp);
        string chAtkDfcString = chAtkDfc.ToString() + "/" + chAtkDfc.ToString();

        GameObject.Find("ChildStatusValue").GetComponent <Text> ().text = chAtkDfcString;

        //Child Image
        foreach (Transform n in GameObject.Find("Img").transform)
        {
            GameObject.Destroy(n.gameObject);
        }
        string     chPath = "Prefabs/Player/Unit/" + ch_type;
        GameObject chObj  = Instantiate(Resources.Load(chPath)) as GameObject;

        chObj.transform.SetParent(GameObject.Find("Img").transform);
        RectTransform chTransform = chObj.GetComponent <RectTransform> ();

        chTransform.anchoredPosition3D = new Vector3(-200, -50, 0);
        chTransform.sizeDelta          = new Vector2(40, 40);
        chObj.transform.localScale     = new Vector2(4, 4);



        GameObject chigyo = GameObject.Find("ButtonCyouhei");

        if (ch_num < 20)
        {
            chigyo.GetComponent <Image> ().color = OKClorBtn;
            chigyo.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt;
            chigyo.GetComponent <Button>().enabled = true;

            chigyo.GetComponent <BusyoStatusButton> ().ch_type   = ch_type;
            chigyo.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu;
            chigyo.GetComponent <BusyoStatusButton> ().ch_num    = ch_num;
            chigyo.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc;
            chigyo.GetComponent <BusyoStatusButton> ().ch_hp     = hei;
            chigyo.GetComponent <BusyoStatusButton> ().pa_hp     = totalBusyoHp / 100;
        }
        else
        {
            //MAX
            chigyo.GetComponent <Image> ().color = NGClorBtn;
            chigyo.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
            chigyo.GetComponent <Button>().enabled = false;
        }
        GameObject kunren = GameObject.Find("ButtonKunren");

        if (ch_lv < 100)
        {
            kunren.GetComponent <Image> ().color = OKClorBtn;
            kunren.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt;
            kunren.GetComponent <Button>().enabled = true;

            kunren.GetComponent <BusyoStatusButton> ().ch_type   = ch_type;
            kunren.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu;
            kunren.GetComponent <BusyoStatusButton> ().ch_lv     = ch_lv;
            kunren.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc;
            kunren.GetComponent <BusyoStatusButton> ().ch_hp     = hei;
            kunren.GetComponent <BusyoStatusButton> ().ch_num    = ch_num;
            kunren.GetComponent <BusyoStatusButton> ().pa_hp     = totalBusyoHp / 100;
        }
        else
        {
            //MAX
            kunren.GetComponent <Image> ().color = NGClorBtn;
            kunren.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
            kunren.GetComponent <Button>().enabled = false;
        }
        //Parametor Setting
        GameObject.Find("GameScene").GetComponent <NowOnBusyo>().OnBusyo = busyoId;

        //Jinkei Flg
        GameObject BusyoView = GameObject.Find("BusyoView");

        if (!BusyoView.transform.FindChild("jinkei"))
        {
            if (jinkeiBusyoCheck(int.Parse(busyoId)))
            {
                string     iconPath = "Prefabs/Busyo/Jinkei";
                GameObject jinkei   = Instantiate(Resources.Load(iconPath)) as GameObject;
                jinkei.transform.SetParent(GameObject.Find("BusyoView").transform);
                jinkei.transform.localScale    = new Vector2(0.3f, 0.3f);
                jinkei.transform.localPosition = new Vector2(220, 200);
                jinkei.name = "jinkei";
            }
        }
    }
예제 #17
0
    public void Start()
    {
        currentKuniId = PlayerPrefs.GetInt("activeKuniId");

        string        seiryoku     = PlayerPrefs.GetString("seiryoku");
        List <string> seiryokuList = new List <string>();

        char[] delimiterChars = { ',' };
        seiryokuList = new List <string>(seiryoku.Split(delimiterChars));

        int        myDaimyoId = PlayerPrefs.GetInt("myDaimyo");
        List <int> myKuniList = new List <int>();

        for (int m = 0; m < seiryokuList.Count; m++)
        {
            int DaimyoId = int.Parse(seiryokuList[m]);
            if (DaimyoId == myDaimyoId)
            {
                myKuniList.Add(m + 1);
            }
        }


        if (myKuniList.Count > 1)
        {
            nextExistFlg = true;
            for (int i = 0; i < myKuniList.Count; i++)
            {
                int kuniId = myKuniList[i];
                if (currentKuniId == kuniId)
                {
                    if ((i + 1) == myKuniList.Count)
                    {
                        //back to first
                        nextKuniId = myKuniList[0];
                    }
                    else
                    {
                        //next
                        nextKuniId = myKuniList[i + 1];
                    }
                }
            }
            KuniInfo kuniScript = new KuniInfo();
            nextKuniName = kuniScript.getKuniName(nextKuniId);


            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                transform.FindChild("Text").GetComponent <Text>().text = "Next Town\n" + nextKuniName;
            }
            else
            {
                transform.FindChild("Text").GetComponent <Text>().text = "次の国へ\n" + nextKuniName;
            }
        }
        else
        {
            Destroy(gameObject);
        }
    }
예제 #18
0
    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);
                    }
                }
            }
        }
    }
예제 #19
0
    public void MakeKassenComment(string kassenWinLoseFlee, int enemyDaimyoId, int kuniId)
    {
        //make comment object
        GameObject commentObj = MakeCommentObj(enemyDaimyoId, kuniId);

        //Comment
        List <string> kassenWinLoseFleeList = new List <string> ();

        kassenWinLoseFleeList = new List <string> (kassenWinLoseFlee.Split(delimiterChars));
        int    myDaimyoBusyo = PlayerPrefs.GetInt("myDaimyoBusyo");
        string myDiamyoName  = busyo.getName(myDaimyoBusyo);

        //Comment Select
        string finalComment = "";

        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            if (kassenWinLoseFleeList [1] == "2")
            {
                //Player Win
                string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                int    powerTyp  = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                if (powerTyp == 1)
                {
                    finalComment = "Aw, hell! We lost " + stageNmae + " castle and face.";
                }
                else if (powerTyp == 2)
                {
                    finalComment = "What? " + stageNmae + " is strategic site for managing the territory. Let's get it back!";
                }
                else if (powerTyp == 3)
                {
                    finalComment = "Aw, hell! " + myDiamyoName + "! We must get " + stageNmae + " castle back!";
                }
            }
            else if (kassenWinLoseFleeList [1] == "1")
            {
                //Flee
                string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                int    powerTyp  = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                finalComment = "Hahaha, " + myDiamyoName + ". He ran away due to well-fortified " + stageNmae + " castle.";
            }
            else if (kassenWinLoseFleeList [1] == "0")
            {
                //Player Lose
                string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                int    powerTyp  = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                if (powerTyp == 1)
                {
                    finalComment = "Haha, We have a good soldiers! We defeated " + myDiamyoName + ".";
                }
                else if (powerTyp == 2)
                {
                    finalComment = "Hahaha, " + myDiamyoName + " ran away! He will give up to aim " + stageNmae + " castle.";
                }
                else if (powerTyp == 3)
                {
                    finalComment = "Our samurai, Raise a battle cry! We won the battle and defended " + stageNmae + " castle!";
                }
            }
            else if (kassenWinLoseFleeList [1] == "3")
            {
                //Kuni
                KuniInfo kuni     = new KuniInfo();
                string   kuniName = kuni.getKuniName(kuniId);
                finalComment = "We lost " + kuniName + " castle... Damn it " + myDiamyoName + ". Let's bury our resentment deep in our hearts!";
            }
            else if (kassenWinLoseFleeList [1] == "4")
            {
                //Metsubou
                finalComment = "It's a fall of our family...It was short-lived. How earn my place in history?";
            }
        }
        else
        {
            if (kassenWinLoseFleeList[1] == "2")
            {
                //Player Win
                string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                int    powerTyp  = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                if (powerTyp == 1)
                {
                    finalComment = "うぬ、" + stageNmae + "を落とされたか。このままでは主家の面目が立たぬわ。";
                }
                else if (powerTyp == 2)
                {
                    finalComment = "なんと!" + stageNmae + "は重要拠点…。孤立する前に取り返すぞ。";
                }
                else if (powerTyp == 3)
                {
                    finalComment = "おのれ、" + myDiamyoName + "め!" + stageNmae + "の借りは必ず返してくれる。";
                }
            }
            else if (kassenWinLoseFleeList[1] == "1")
            {
                //Flee
                string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                int    powerTyp  = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                finalComment = "ははは、" + myDiamyoName + "め、あまりの" + stageNmae + "の堅固さに、戦わずに逃げ帰りおったぞ!";
            }
            else if (kassenWinLoseFleeList[1] == "0")
            {
                //Player Lose
                string stageNmae = stage.getStageName(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                int    powerTyp  = stage.getPowerTyp(kuniId, int.Parse(kassenWinLoseFleeList[0]));
                if (powerTyp == 1)
                {
                    finalComment = "ははは、者共、見事な槍働きじゃ!" + myDiamyoName + "めを叩き潰したぞ。";
                }
                else if (powerTyp == 2)
                {
                    finalComment = "ははは、" + myDiamyoName + "め、ほうほうの体で逃げ帰りおったわ。" + stageNmae + "の堅固さに舌をまいたろうて。";
                }
                else if (powerTyp == 3)
                {
                    finalComment = "勝ち鬨を上げよ、我等が勝利じゃ!天下の険、" + stageNmae + "を落とせるわけがなかろう。";
                }
            }
            else if (kassenWinLoseFleeList[1] == "3")
            {
                //Kuni
                KuniInfo kuni     = new KuniInfo();
                string   kuniName = kuni.getKuniName(kuniId);
                finalComment = "我が" + kuniName + "を盗られてしまった…。おのれ、" + myDiamyoName + "め。この雪辱、必ず晴らしてくれようぞ!";
            }
            else if (kassenWinLoseFleeList[1] == "4")
            {
                //Metsubou
                finalComment = "当家もお終いか…。儚い世であったわ。我が名は後世にどう残るのかのう。";
            }
        }

        commentObj.transform.FindChild("SerihuText").GetComponent <Text> ().text = finalComment;
    }
예제 #20
0
    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));
        }
    }
예제 #21
0
	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;
				}

			}






		}


	}
예제 #22
0
    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);
    }
예제 #23
0
    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);
        }
    }
예제 #24
0
    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();
            }
        }
    }
예제 #25
0
    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;
             *  }
             *
             * }
             *
             */
        }
    }
예제 #26
0
    public void attack()
    {
        audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        //Same Daimyo Check
        int        latestDaimyoId = kuniIconView.transform.FindChild(dstKuni.ToString()).GetComponent <SendParam> ().daimyoId;
        GameObject MsgBack        = this.transform.FindChild("MsgBack").gameObject;
        GameObject MsgText        = MsgBack.transform.FindChild("MsgText").gameObject;

        if (dstDaimyoId == latestDaimyoId)
        {
            if (dstDaimyoId != myDaimyoId)
            {
                audioSources [7].Play();

                int enemyHei = heiryokuCalc(dstKuni);

                //Engun
                int engunTotalHei = 0;
                if (dstEngunFlg)
                {
                    char[]        delimiterChars2 = { ':' };
                    List <string> engunHeiList    = new List <string>();
                    engunHeiList = new List <string> (dstEngunHei.Split(delimiterChars2));

                    for (int k = 0; k < engunHeiList.Count; k++)
                    {
                        engunTotalHei = engunTotalHei + int.Parse(engunHeiList[k]);
                    }
                }

                enemyHei = enemyHei + engunTotalHei;

                int ratio = 0;
                if ((myHei + enemyHei) != 0)
                {
                    ratio = 100 * myHei / (myHei + enemyHei);
                    if (ratio < 1)
                    {
                        ratio = 1;
                    }
                }

                MainEventHandler kassenEvent = new MainEventHandler();
                bool             winFlg      = kassenEvent.CheckByProbability(ratio);

                //Entity_kuni_mst kuniMst = Resources.Load ("Data/kuni_mst") as Entity_kuni_mst;
                KuniInfo kuniScript  = new KuniInfo();
                string   dstKuniName = kuniScript.getKuniName(dstKuni);

                //Gaikou
                Gaikou gaikou = new Gaikou();
                gaikou.downGaikouByAttack(srcDaimyoId, dstDaimyoId);

                if (winFlg)
                {
                    bool   noGunzeiFlg = false;
                    string syouhai     = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        syouhai = srcDaimyoName + "\n" + "Conquered " + dstKuniName;
                    }
                    else
                    {
                        syouhai = srcDaimyoName + "\n" + dstKuniName + "を攻略";
                    }
                    MsgBack.GetComponent <Image> ().enabled = true;
                    MsgText.GetComponent <Text> ().enabled  = true;
                    MsgText.GetComponent <Text> ().text     = syouhai;

                    win(key, srcDaimyoId, dstDaimyoId, noGunzeiFlg, dstKuni);

                    fire(dstKuni);
                }
                else
                {
                    string syouhai = "";
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        syouhai = dstDaimyoName + "\n" + "Defended " + dstKuniName;
                    }
                    else
                    {
                        syouhai = dstDaimyoName + "\n" + dstKuniName + "を防衛";
                    }
                    MsgBack.GetComponent <Image> ().enabled = true;
                    MsgText.GetComponent <Text> ().enabled  = true;
                    MsgText.GetComponent <Text> ().text     = syouhai;

                    gameObject.GetComponent <GunzeiFadeOut> ().enabled = true;

                    MainStageController main = new MainStageController();
                    main.deleteKeyHistory(key);
                }
            }
            else
            {
                MyDaimyoWasAttacked atked = new MyDaimyoWasAttacked();
                atked.wasAttacked(key, srcKuni, dstKuni, srcDaimyoId, dstDaimyoId, dstEngunFlg, dstEngunDaimyoId, dstEngunSts);
            }
        }
        else
        {
            audioSources [1].Play();
            string syouhai = "";
            if (Application.systemLanguage != SystemLanguage.Japanese)
            {
                syouhai = srcDaimyoName + " withdrawed";
            }
            else
            {
                syouhai = srcDaimyoName + "撤退";
            }
            MsgBack.GetComponent <Image> ().enabled = true;
            MsgText.GetComponent <Text> ().enabled  = true;
            MsgText.GetComponent <Text> ().text     = syouhai;

            gameObject.GetComponent <GunzeiFadeOut> ().enabled = true;

            MainStageController main = new MainStageController();
            main.deleteKeyHistory(key);
        }
    }
예제 #27
0
	public void createBusyoStatusView(string busyoId){
		int lv = PlayerPrefs.GetInt (busyoId);
		StatusGet sts = new StatusGet ();
		int hp = sts.getHp (int.Parse (busyoId), lv);
		int atk = sts.getAtk (int.Parse (busyoId), lv);
		int dfc = sts.getDfc (int.Parse (busyoId), lv);
		int spd = sts.getSpd (int.Parse (busyoId), lv);
		
		int adjHp = hp * 100;
		int adjAtk = atk * 10;
		int adjDfc = dfc * 10;
		
		GameObject.Find ("LvValue").GetComponent<Text> ().text = lv.ToString ();
		GameObject.Find ("TosotsuValue").GetComponent<Text> ().text = adjHp.ToString ();
		GameObject.Find ("BuyuuValue").GetComponent<Text> ().text = adjAtk.ToString ();
		GameObject.Find ("ChiryakuValue").GetComponent<Text> ().text = adjDfc.ToString ();
		GameObject.Find ("SpeedValue").GetComponent<Text> ().text = spd.ToString ();

		//Exp
		string expId = "exp" + busyoId.ToString ();
		string expString = "";
		int nowExp = PlayerPrefs.GetInt(expId);
		Exp exp = new Exp ();
		int requiredExp = 0;
		if (lv != 100) {
			requiredExp = exp.getExpforNextLv (lv);
		} else {
			requiredExp = exp.getExpLv100();
		}

		expString = nowExp + "/" + requiredExp;
		GameObject.Find ("ExpValue").GetComponent<Text> ().text = expString;


		//Kahou status
		KahouStatusGet kahouSts = new KahouStatusGet ();
		string[] KahouStatusArray =kahouSts.getKahouForStatus (busyoId,adjHp,adjAtk,adjDfc,spd);
		int totalBusyoHp =0;


		//Kanni
		string kanniTmp = "kanni" + busyoId;
		float addAtkByKanni = 0;
		float addHpByKanni = 0;
		float addDfcByKanni = 0;

		if (PlayerPrefs.HasKey (kanniTmp)) {
			int kanniId = PlayerPrefs.GetInt (kanniTmp);
			Kanni kanni = new Kanni ();
			string kanniIkai = kanni.getIkai (kanniId);
			string kanniName = kanni.getKanni (kanniId);
			GameObject.Find ("StatusKanni").transform.FindChild ("Value").GetComponent<Text> ().text = kanniIkai + "\n" + kanniName;

			//Status
			string kanniTarget = kanni.getEffectTarget(kanniId);
			int effect = kanni.getEffect(kanniId);
			if(kanniTarget=="atk"){
				addAtkByKanni = ((float)adjAtk * (float)effect)/100;
			}else if(kanniTarget=="hp"){
				addHpByKanni = ((float)adjHp * (float)effect)/100;
			}else if(kanniTarget=="dfc"){
				addDfcByKanni = ((float)adjDfc * (float)effect)/100;
			}

		
		} else {
			GameObject.Find ("StatusKanni").transform.FindChild ("Value").GetComponent<Text> ().text = "官位無し";
		}

		//Jyosyu
		string jyosyuTmp = "jyosyuBusyo" + busyoId;
		if (PlayerPrefs.HasKey (jyosyuTmp)) {
			int kuniId = PlayerPrefs.GetInt(jyosyuTmp);
			KuniInfo kuni = new KuniInfo();
			string kuniName = kuni.getKuniName(kuniId);

			GameObject.Find ("StatusJyosyu").transform.FindChild ("Value").GetComponent<Text> ().text = kuniName + "\n城主";

		} else {
			GameObject.Find ("StatusJyosyu").transform.FindChild ("Value").GetComponent<Text> ().text = "城無し";
		}




		//Show Additional Status
		int finalAtk = int.Parse (KahouStatusArray [0]) + Mathf.FloorToInt (addAtkByKanni);
		int finalHp = int.Parse (KahouStatusArray [1]) + Mathf.FloorToInt (addHpByKanni);
		int finalDfc= int.Parse (KahouStatusArray [2]) + Mathf.FloorToInt (addDfcByKanni);
		int finalSpd = int.Parse (KahouStatusArray [3]);

		GameObject.Find ("KahouAtkValue").GetComponent<Text> ().text = "+" + finalAtk.ToString ();
		GameObject.Find ("KahouHpValue").GetComponent<Text>().text = "+" + finalHp.ToString();
		totalBusyoHp = adjHp + finalHp;
		GameObject.Find ("KahouDfcValue").GetComponent<Text>().text = "+" + finalDfc.ToString();
		GameObject.Find ("KahouSpdValue").GetComponent<Text>().text = "+" + finalSpd.ToString();


		//Butai Status
		string heiId = "hei" + busyoId.ToString ();
		string chParam = PlayerPrefs.GetString (heiId, "0");
		
		char[] delimiterChars = {':'};
		string[] ch_list = chParam.Split (delimiterChars);
		
		string ch_type = ch_list [0];
		int ch_num = int.Parse (ch_list [1]);
		int ch_lv = int.Parse (ch_list [2]);
		float ch_status = float.Parse (ch_list [3]);
		
		string heisyu = "";
		if (ch_type == "KB") {
			heisyu = "騎馬隊";
		} else if (ch_type == "YR") {
			heisyu = "槍隊";
		} else if (ch_type == "TP") {
			heisyu = "鉄砲隊";
		} else if (ch_type == "YM") {
			heisyu = "弓隊";
		}
		GameObject.Find ("ChildNameValue").GetComponent<Text> ().text = heisyu;
		GameObject.Find ("ChildQtyValue").GetComponent<Text> ().text = ch_num.ToString ();
		GameObject.Find ("ChildLvValue").GetComponent<Text> ().text = ch_lv.ToString ();

		//Jyosyu Handling
		JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku ();
		float addHei = (float)jyosyuHei.GetJyosyuHeiryoku (busyoId);
		float hei = ch_status * 10;
		string heiText = hei.ToString() + "<size=150><Color=#35D74BFF>+" + addHei + "</Color></size>";
		GameObject.Find ("ChildHeiryokuValue").GetComponent<Text> ().text = heiText;


		int chAtkDfc = (int)sts.getChAtkDfc ((int)hei, totalBusyoHp);
		string chAtkDfcString = chAtkDfc.ToString () + "/" + chAtkDfc.ToString (); 
		GameObject.Find ("ChildStatusValue").GetComponent<Text> ().text = chAtkDfcString;
		
		//Child Image
		foreach (Transform n in GameObject.Find ("Img").transform) {
			GameObject.Destroy (n.gameObject);
		}
		string chPath = "Prefabs/Player/Unit/" + ch_type;
		GameObject chObj = Instantiate (Resources.Load (chPath)) as GameObject;
		chObj.transform.SetParent(GameObject.Find ("Img").transform);
		RectTransform chTransform = chObj.GetComponent<RectTransform> ();
		chTransform.anchoredPosition3D = new Vector3 (-200, -50, 0);
		chTransform.sizeDelta = new Vector2 (40, 40);
		chObj.transform.localScale = new Vector2 (4, 4);



		GameObject chigyo = GameObject.Find ("ButtonCyouhei");
		chigyo.GetComponent<BusyoStatusButton> ().ch_type = ch_type;
		chigyo.GetComponent<BusyoStatusButton> ().ch_heisyu = heisyu;
		chigyo.GetComponent<BusyoStatusButton> ().ch_num = ch_num;
		chigyo.GetComponent<BusyoStatusButton> ().ch_status = chAtkDfc;
		chigyo.GetComponent<BusyoStatusButton> ().ch_hp = hei;
		chigyo.GetComponent<BusyoStatusButton> ().pa_hp = totalBusyoHp/100;

		GameObject kunren = GameObject.Find ("ButtonKunren");
		kunren.GetComponent<BusyoStatusButton> ().ch_type = ch_type;
		kunren.GetComponent<BusyoStatusButton> ().ch_heisyu = heisyu;
		kunren.GetComponent<BusyoStatusButton> ().ch_lv = ch_lv;
		kunren.GetComponent<BusyoStatusButton> ().ch_status = chAtkDfc;
		kunren.GetComponent<BusyoStatusButton> ().ch_hp = hei ;
		kunren.GetComponent<BusyoStatusButton> ().ch_num = ch_num;
		kunren.GetComponent<BusyoStatusButton> ().pa_hp = totalBusyoHp/100;

		//Parametor Setting
		GameObject.Find ("GameScene").GetComponent<NowOnBusyo>().OnBusyo = busyoId;

	}
예제 #28
0
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();
        audioSources [2].Play();

        /*Busyo View*/
        //Delete Previous
        foreach (Transform n in GameObject.Find("BusyoView").transform)
        {
            GameObject.Destroy(n.gameObject);
        }
        //Jinkei Flg
        if (jinkeiFlg)
        {
            string     iconPath = "Prefabs/Busyo/Jinkei";
            GameObject jinkei   = Instantiate(Resources.Load(iconPath)) as GameObject;
            jinkei.transform.SetParent(GameObject.Find("BusyoView").transform);
            jinkei.transform.localScale    = new Vector2(0.3f, 0.3f);
            jinkei.transform.localPosition = new Vector2(220, 200);
            jinkei.name = "jinkei";
        }

        //Make New Busyo
        string busyoId;

        busyoId = this.name.Remove(0, 4);
        string     path  = "Prefabs/Player/Unit/BusyoUnit";
        GameObject Busyo = Instantiate(Resources.Load(path)) as GameObject;

        Busyo.name = busyoId.ToString();
        Busyo.transform.SetParent(GameObject.Find("BusyoView").transform);
        Busyo.transform.localScale = new Vector2(4, 4);
        Busyo.GetComponent <DragHandler> ().enabled = false;

        RectTransform rect_transform = Busyo.GetComponent <RectTransform>();

        rect_transform.anchoredPosition3D = new Vector3(300, 200, 0);
        rect_transform.sizeDelta          = new Vector2(100, 100);

        //Ship Rank
        string     shipPath = "Prefabs/Busyo/ShipSts";
        GameObject ShipObj  = Instantiate(Resources.Load(shipPath)) as GameObject;

        ShipObj.transform.SetParent(Busyo.transform);
        preKaisen kaisenScript = new preKaisen();
        int       shipId       = kaisenScript.getShipSprite(ShipObj, int.Parse(busyoId));

        ShipObj.transform.localPosition = new Vector3(-40, -40, 0);
        ShipObj.transform.localScale    = new Vector2(0.4f, 0.4f);
        if (Application.systemLanguage != SystemLanguage.Japanese)
        {
            if (shipId == 1)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "High";
            }
            else if (shipId == 2)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "Mid";
            }
            else if (shipId == 3)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "Low";
            }
        }
        else
        {
            if (shipId == 1)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "上";
            }
            else if (shipId == 2)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "中";
            }
            else if (shipId == 3)
            {
                ShipObj.transform.FindChild("Text").GetComponent <Text>().text = "下";
            }
        }
        //Text Modification
        GameObject text = Busyo.transform.FindChild("Text").gameObject;

        text.GetComponent <Text> ().color = new Color(255, 255, 255, 255);
        RectTransform text_transform = text.GetComponent <RectTransform>();

        text_transform.anchoredPosition3D = new Vector3(-70, 30, 0);
        text_transform.sizeDelta          = new Vector2(630, 120);
        text.transform.localScale         = new Vector2(0.2f, 0.2f);

        //Rank Text Modification
        GameObject    rank           = Busyo.transform.FindChild("Rank").gameObject;
        RectTransform rank_transform = rank.GetComponent <RectTransform>();

        rank_transform.anchoredPosition3D   = new Vector3(20, -50, 0);
        rank_transform.sizeDelta            = new Vector2(200, 200);
        rank.GetComponent <Text>().fontSize = 200;


        /*Busyo Status*/
        NowOnBusyo   NowOnBusyoScript   = GameObject.Find("GameScene").GetComponent <NowOnBusyo> ();
        BusyoInfoGet busyoInfoGetScript = new BusyoInfoGet();

        if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Ronkou")
        {
            int       lv  = PlayerPrefs.GetInt(busyoId);
            StatusGet sts = new StatusGet();
            int       hp  = sts.getHp(int.Parse(busyoId), lv);
            int       atk = sts.getAtk(int.Parse(busyoId), lv);
            int       dfc = sts.getDfc(int.Parse(busyoId), lv);
            int       spd = sts.getSpd(int.Parse(busyoId), lv);

            int adjHp  = hp * 100;
            int adjAtk = atk * 10;
            int adjDfc = dfc * 10;

            //add lv
            string addLvTmp = "addlv" + busyoId.ToString();
            if (PlayerPrefs.HasKey(addLvTmp))
            {
                string addLvValue = "+" + PlayerPrefs.GetString(addLvTmp);
                GameObject.Find("addLvValue").GetComponent <Text>().text = addLvValue.ToString();
            }
            else
            {
                GameObject.Find("addLvValue").GetComponent <Text>().text = "";
            }
            int maxLv = 100 + PlayerPrefs.GetInt(addLvTmp);

            GameObject.Find("LvValue").GetComponent <Text> ().text       = lv.ToString();
            GameObject.Find("TosotsuValue").GetComponent <Text> ().text  = adjHp.ToString();
            GameObject.Find("BuyuuValue").GetComponent <Text> ().text    = adjAtk.ToString();
            GameObject.Find("ChiryakuValue").GetComponent <Text> ().text = adjDfc.ToString();
            GameObject.Find("SpeedValue").GetComponent <Text> ().text    = spd.ToString();

            //Exp
            string expId       = "exp" + busyoId.ToString();
            string expString   = "";
            int    nowExp      = PlayerPrefs.GetInt(expId);
            Exp    exp         = new Exp();
            int    requiredExp = 0;
            if (lv != maxLv)
            {
                requiredExp = exp.getExpforNextLv(lv);
            }
            else
            {
                requiredExp = exp.getExpLvMax(maxLv);
            }


            expString = nowExp + "/" + requiredExp;
            GameObject.Find("ExpValue").GetComponent <Text> ().text = expString;

            //Kahou status
            KahouStatusGet kahouSts         = new KahouStatusGet();
            string[]       KahouStatusArray = kahouSts.getKahouForStatus(busyoId, adjHp, adjAtk, adjDfc, spd);
            int            totalBusyoHp     = 0;


            //Kanni
            string kanniTmp      = "kanni" + busyoId;
            float  addAtkByKanni = 0;
            float  addHpByKanni  = 0;
            float  addDfcByKanni = 0;

            if (PlayerPrefs.HasKey(kanniTmp))
            {
                int kanniId = PlayerPrefs.GetInt(kanniTmp);
                if (kanniId != 0)
                {
                    Kanni  kanni     = new Kanni();
                    string kanniIkai = kanni.getIkai(kanniId);
                    string kanniName = kanni.getKanni(kanniId);
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text> ().text = kanniIkai + "\n" + kanniName;

                    //Status
                    string kanniTarget = kanni.getEffectTarget(kanniId);
                    int    effect      = kanni.getEffect(kanniId);
                    if (kanniTarget == "atk")
                    {
                        addAtkByKanni = ((float)adjAtk * (float)effect) / 100;
                    }
                    else if (kanniTarget == "hp")
                    {
                        addHpByKanni = ((float)adjHp * (float)effect) / 100;
                    }
                    else if (kanniTarget == "dfc")
                    {
                        addDfcByKanni = ((float)adjDfc * (float)effect) / 100;
                    }
                }
                else
                {
                    if (Application.systemLanguage != SystemLanguage.Japanese)
                    {
                        GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "No Rank";
                    }
                    else
                    {
                        GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
                    }
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text> ().text = "No Rank";
                }
                else
                {
                    GameObject.Find("StatusKanni").transform.FindChild("Value").GetComponent <Text>().text = "官位無し";
                }
            }

            //Jyosyu
            string jyosyuTmp = "jyosyuBusyo" + busyoId;
            if (PlayerPrefs.HasKey(jyosyuTmp))
            {
                int      kuniId   = PlayerPrefs.GetInt(jyosyuTmp);
                KuniInfo kuni     = new KuniInfo();
                string   kuniName = kuni.getKuniName(kuniId);
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text> ().text = kuniName + "\nLord";
                }
                else
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = kuniName + "\n城主";
                }
            }
            else
            {
                if (Application.systemLanguage != SystemLanguage.Japanese)
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "No Feud";
                }
                else
                {
                    GameObject.Find("StatusJyosyu").transform.FindChild("Value").GetComponent <Text>().text = "城無し";
                }
            }

            //Show Additional Status
            int finalAtk = int.Parse(KahouStatusArray [0]) + Mathf.FloorToInt(addAtkByKanni);
            int finalHp  = int.Parse(KahouStatusArray [1]) + Mathf.FloorToInt(addHpByKanni);
            int finalDfc = int.Parse(KahouStatusArray [2]) + Mathf.FloorToInt(addDfcByKanni);
            int finalSpd = int.Parse(KahouStatusArray [3]);

            GameObject.Find("KahouAtkValue").GetComponent <Text> ().text = "+" + finalAtk.ToString();
            GameObject.Find("KahouHpValue").GetComponent <Text>().text   = "+" + finalHp.ToString();
            totalBusyoHp = adjHp + finalHp;
            GameObject.Find("KahouDfcValue").GetComponent <Text>().text = "+" + finalDfc.ToString();
            GameObject.Find("KahouSpdValue").GetComponent <Text>().text = "+" + finalSpd.ToString();

            //Butai Status
            string heiId   = "hei" + busyoId.ToString();
            string chParam = PlayerPrefs.GetString(heiId, "0");

            if (chParam == "0" || chParam == "")
            {
                StatusGet statusScript = new StatusGet();
                string    heisyu       = statusScript.getHeisyu(int.Parse(busyoId));
                chParam = heisyu + ":1:1:1";
                PlayerPrefs.SetString(heiId, chParam);
                PlayerPrefs.Flush();
            }


            if (chParam.Contains(":"))
            {
                char[]   delimiterChars = { ':' };
                string[] ch_list        = chParam.Split(delimiterChars);

                string ch_type   = ch_list [0];
                int    ch_num    = int.Parse(ch_list [1]);
                int    ch_lv     = int.Parse(ch_list [2]);
                float  ch_status = float.Parse(ch_list [3]);

                string  heisyu = "";
                Message msg    = new Message();
                if (ch_type == "KB")
                {
                    heisyu = msg.getMessage(55);
                }
                else if (ch_type == "YR")
                {
                    heisyu = msg.getMessage(56);
                }
                else if (ch_type == "TP")
                {
                    heisyu = msg.getMessage(57);
                }
                else if (ch_type == "YM")
                {
                    heisyu = msg.getMessage(58);
                }

                GameObject.Find("ChildNameValue").GetComponent <Text> ().text = heisyu;
                GameObject.Find("ChildQtyValue").GetComponent <Text> ().text  = ch_num.ToString();
                GameObject.Find("ChildLvValue").GetComponent <Text> ().text   = ch_lv.ToString();

                //Jyosyu Handling
                JyosyuHeiryoku jyosyuHei = new JyosyuHeiryoku();
                float          addHei    = (float)jyosyuHei.GetJyosyuHeiryoku(busyoId);
                float          hei       = ch_status * 10;
                GameObject.Find("ChildHeiryokuValue").GetComponent <Text>().text = hei.ToString();
                float newHei = finalHp + addHei;
                GameObject.Find("KahouHpValue").GetComponent <Text>().text = "+" + newHei.ToString();

                int    chAtkDfc       = (int)sts.getChAtkDfc((int)hei, totalBusyoHp);
                string chAtkDfcString = chAtkDfc.ToString() + "/" + chAtkDfc.ToString();
                GameObject.Find("ChildStatusValue").GetComponent <Text> ().text = chAtkDfcString;


                //Child Image
                foreach (Transform n in GameObject.Find("Img").transform)
                {
                    GameObject.Destroy(n.gameObject);
                }
                string     chPath = "Prefabs/Player/Unit/" + ch_type;
                GameObject chObj  = Instantiate(Resources.Load(chPath)) as GameObject;
                chObj.transform.SetParent(GameObject.Find("Img").transform);
                RectTransform chTransform = chObj.GetComponent <RectTransform> ();
                chTransform.anchoredPosition3D = new Vector3(-200, -50, 0);
                chTransform.sizeDelta          = new Vector2(40, 40);
                chObj.transform.localScale     = new Vector2(4, 4);


                GameObject chigyo = GameObject.Find("ButtonCyouhei");
                if (ch_num < 20)
                {
                    chigyo.GetComponent <Image> ().color = OKClorBtn;
                    chigyo.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt;
                    chigyo.GetComponent <Button>().enabled = true;

                    chigyo.GetComponent <BusyoStatusButton> ().ch_type   = ch_type;
                    chigyo.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu;
                    chigyo.GetComponent <BusyoStatusButton> ().ch_num    = ch_num;
                    chigyo.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc;
                    chigyo.GetComponent <BusyoStatusButton> ().ch_hp     = hei;
                    chigyo.GetComponent <BusyoStatusButton> ().pa_hp     = totalBusyoHp / 100;
                }
                else
                {
                    //MAX
                    chigyo.GetComponent <Image> ().color = NGClorBtn;
                    chigyo.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
                    chigyo.GetComponent <Button>().enabled = false;
                }
                GameObject kunren = GameObject.Find("ButtonKunren");
                if (ch_lv < 100)
                {
                    kunren.GetComponent <Image> ().color = OKClorBtn;
                    kunren.transform.FindChild("Text").GetComponent <Text> ().color = OKClorTxt;
                    kunren.GetComponent <Button>().enabled = true;

                    kunren.GetComponent <BusyoStatusButton> ().ch_type   = ch_type;
                    kunren.GetComponent <BusyoStatusButton> ().ch_heisyu = heisyu;
                    kunren.GetComponent <BusyoStatusButton> ().ch_lv     = ch_lv;
                    kunren.GetComponent <BusyoStatusButton> ().ch_num    = ch_num;
                    kunren.GetComponent <BusyoStatusButton> ().ch_status = chAtkDfc;
                    kunren.GetComponent <BusyoStatusButton> ().ch_hp     = hei;
                    kunren.GetComponent <BusyoStatusButton> ().pa_hp     = totalBusyoHp / 100;
                }
                else
                {
                    //MAX
                    kunren.GetComponent <Image> ().color = NGClorBtn;
                    kunren.transform.FindChild("Text").GetComponent <Text> ().color = NGClorTxt;
                    kunren.GetComponent <Button>().enabled = false;
                }
            }

            //Parametor Setting
            NowOnBusyoScript.OnBusyo     = busyoId;
            NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId));
        }
        else if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Senpou")
        {
            NowOnBusyoScript.OnBusyo     = busyoId;
            NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId));
            SenpouScene scene = new SenpouScene();
            scene.createSenpouStatusView(busyoId);
            scene.createSakuStatusView(busyoId);
        }
        else if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Kahou")
        {
            NowOnBusyoScript.OnBusyo     = busyoId;
            NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId));
            KahouScene kahou = new KahouScene();
            kahou.createKahouStatusView(busyoId);
        }
        else if (GameObject.Find("GameScene").GetComponent <NowOnButton> ().onButton == "Syogu")
        {
            NowOnBusyoScript.OnBusyo     = busyoId;
            NowOnBusyoScript.OnBusyoName = busyoInfoGetScript.getName(int.Parse(busyoId));
            SyoguScene syogu = new SyoguScene();
            syogu.createSyoguView(busyoId);
        }
    }
예제 #29
0
	public void wasAttacked(string key, int srcKuni, int dstKuni, int srcDaimyoId, int dstDaimyoId, bool dstEngunFlg, string dstEngunDaimyoId, string dstEngunSts){

		//In the case of My Damyo was Attacked

		//For Dramatic Enemy Creation
		GameObject kuniView = GameObject.Find("KuniIconView");
		SendParam param = kuniView.transform.FindChild(srcKuni.ToString()).GetComponent<SendParam>();
		int busyoQty = param.busyoQty;
		int busyoLv = param.busyoLv;
		int butaiQty = param.butaiQty;
		int butaiLv = param.butaiLv;

		//Dummy
		PlayerPrefs.SetInt("activeStageId", 0);
		PlayerPrefs.SetInt("activeStageMoney", busyoQty*busyoLv*100);
		PlayerPrefs.SetInt("activeStageExp", busyoQty*busyoLv*10);
		PlayerPrefs.SetString("activeItemType", "");
		PlayerPrefs.SetInt("activeItemId", 0);
		PlayerPrefs.SetFloat("activeItemRatio", 0);
		PlayerPrefs.SetInt("activeItemQty", 0);
		
		//Actual
		PlayerPrefs.SetInt("activeKuniId", dstKuni);
		KuniInfo kuni = new KuniInfo ();
		string kuniName = kuni.getKuniName (dstKuni);
		string kassenName = kuniName + "防衛";
		PlayerPrefs.SetString("activeStageName", kassenName);

		PlayerPrefs.SetInt("activeDaimyoId", srcDaimyoId);
		PlayerPrefs.SetInt ("activeBusyoQty", busyoQty);
		PlayerPrefs.SetInt ("activeBusyoLv", busyoLv);
		PlayerPrefs.SetInt ("activeButaiQty", butaiQty);
		PlayerPrefs.SetInt ("activeButaiLv", butaiLv);

		//Passive only
		PlayerPrefs.SetBool ("isAttackedFlg", true);
		PlayerPrefs.SetString("activeKey", key);
		PlayerPrefs.SetInt("activeSrcDaimyoId", srcDaimyoId);
		PlayerPrefs.SetInt("activeDstDaimyoId", dstDaimyoId);

		//Engun
		if (dstEngunFlg) {
			PlayerPrefs.SetString("playerEngunList", dstEngunSts);
			PlayerPrefs.DeleteKey("enemyEngunList");

		} else {
			PlayerPrefs.DeleteKey("playerEngunList");
			PlayerPrefs.DeleteKey("enemyEngunList");
		}

		//Gaikou Down
		Gaikou gaikou = new Gaikou ();
		gaikou.downGaikouByAttack (srcDaimyoId, dstDaimyoId);

		//Delete "Start Kassen Flg"
		PlayerPrefs.DeleteKey("activeLink");
		PlayerPrefs.DeleteKey("activePowerType");

		List<int> powerTypeList = new List<int> (){1,2,3};
		int random = UnityEngine.Random.Range(1,powerTypeList.Count + 1);
		PlayerPrefs.SetInt("activePowerType",random);


		//Boubi effect
		string boubiTmp = "boubi" + dstKuni.ToString();
		int boubi = PlayerPrefs.GetInt (boubiTmp,0);
		boubi = boubi / 10;
		PlayerPrefs.SetInt("activeBoubi", boubi);



		PlayerPrefs.Flush();
		Application.LoadLevel("preKassen");


	}