Esempio n. 1
0
	// Update is called once per frame
	void Update () {
		life = getTotalHp (targetTag);

		//Show Heiryoku
		if (life >= 0) {
			gameObject.transform.FindChild("HpText").GetComponent<Text>().text = life.ToString();
		}

		if (!flag) {
			if (life == 0) {
				flag = true;

				GameObject.Find ("ScrollView").SetActive (false);
				GameObject canvas = GameObject.Find ("Canvas").gameObject;

				if (targetTag == "Player") {
					//Game Over
					string backPath = "Prefabs/PostKassen/back";
					GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject;
					backObj.transform.SetParent (canvas.transform);
					backObj.transform.localScale = new Vector2(70,63);
					backObj.transform.localPosition = new Vector2 (0,0);

					//Chane word
					Color color = Color.blue;
					GameObject.Find ("winlose").GetComponent<TextMesh>().text = "敗北";
					GameObject.Find ("winlose").GetComponent<TextMesh>().color = color;
					
					string blackPath = "Prefabs/PostKassen/black";
					GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject;
					blackObj.transform.SetParent (canvas.transform);
					blackObj.transform.localScale = new Vector2(330,300);
					blackObj.transform.localPosition = new Vector2 (0,0);

					string makimonoPath = "Prefabs/PostKassen/makimono";
					GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject;
					makimonoObj.transform.SetParent (canvas.transform);
					makimonoObj.transform.localScale = new Vector2(1,1);
					makimonoObj.transform.localPosition = new Vector2(0,-135);

					//Button List
					string nextbtnPath = "Prefabs/PostKassen/bttnList";
					GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject;
					bttnListObj.transform.SetParent (canvas.transform);
					bttnListObj.transform.localScale = new Vector2(1,1);		
					bttnListObj.transform.localPosition = new Vector2 (0,0);

					//Time Stop
					GameObject.Find ("timer").GetComponent<Timer>().enabled = false;


					//lose Stage Name
					string stageNamePath = "Prefabs/PostKassen/loseStageName";
					GameObject stageNameObj = Instantiate(Resources.Load (stageNamePath)) as GameObject;
					stageNameObj.transform.SetParent (canvas.transform);
					stageNameObj.transform.localScale = new Vector2(1,1);
					stageNameObj.transform.localPosition = new Vector2 (0,-102);
					string stageName = PlayerPrefs.GetString("activeStageName");

					//Check is attacked flag
					if (isAttackedFlg == true) {

						stageNameObj.transform.FindChild ("stageNameValue").GetComponent<Text> ().text = stageName + "失敗";

						//My Daimyo Lose 
						Gunzei lose = new Gunzei ();
						string tKey = PlayerPrefs.GetString ("activeKey");
						int tSrcDaimyoId = PlayerPrefs.GetInt ("activeSrcDaimyoId");
						int tDstDaimyoId = PlayerPrefs.GetInt ("activeDstDaimyoId");
						bool noGunzeiFlg = true;
						PlayerPrefs.DeleteKey ("isAttacked");
						lose.win (tKey, tSrcDaimyoId, tDstDaimyoId, noGunzeiFlg);


						//Delete Cleared Kuni
						int activeKuniId = PlayerPrefs.GetInt ("activeKuniId");
						string clearedKuni = PlayerPrefs.GetString ("clearedKuni");

						char[] delimiterChars = { ',' };
						List<string> clearedKuniList = new List<string> ();
						
						if (clearedKuni != null && clearedKuni != "") {
							if (clearedKuni.Contains (",")) {
								clearedKuniList = new List<string> (clearedKuni.Split (delimiterChars));
							} else {
								clearedKuniList.Add (clearedKuni);
							}
						}

						string tempActiveKuni = activeKuniId.ToString ();
						clearedKuniList.Remove (tempActiveKuni);
						string newClearedKuni = "";
						for (int i = 0; i < clearedKuniList.Count; i++) {
							if (i == 0) {
								newClearedKuni = clearedKuniList [i];
							} else {
								newClearedKuni = newClearedKuni + "," + clearedKuniList [i];
							}
						}
						PlayerPrefs.SetString ("clearedKuni", newClearedKuni);

						if (newClearedKuni == null || newClearedKuni == "") {
							PlayerPrefs.SetBool ("gameOverFlg", true);

						}

						//Delete Naisei
						//string tempNaisei = "naisei" + activeKuniId.ToString();
						//PlayerPrefs.DeleteKey(tempNaisei);

						//Delete Jyosyu
						string tempJyosyu = "jyosyu" + activeKuniId.ToString ();
						PlayerPrefs.DeleteKey (tempJyosyu);

						//Delete Stage Clear
						string tempKuni = "kuni" + activeKuniId.ToString ();
						PlayerPrefs.DeleteKey (tempKuni);

						//Delete open
						KuniInfo kuni = new KuniInfo ();
						kuni.updateOpenKuni ();
						PlayerPrefs.Flush ();
					
					} else {
						stageNameObj.transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "攻略失敗";
					}

				} else if (targetTag == "Enemy") {
					//Win
					if(isAttackedFlg == true){
						//history
						string tKey = PlayerPrefs.GetString("activeKey");
						MainStageController main = new MainStageController();
						main.deleteKeyHistory(tKey);
						PlayerPrefs.DeleteKey("isAttacked");
						PlayerPrefs.Flush();
					}

					string backPath = "Prefabs/PostKassen/back";
					GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject;
					backObj.transform.SetParent (canvas.transform);
					backObj.transform.localScale = new Vector2(70,63);
					backObj.transform.localPosition = new Vector2 (0,0);

					string particlePath = "Prefabs/PostKassen/particle";
					GameObject particleObj = Instantiate(Resources.Load (particlePath)) as GameObject;
					particleObj.transform.SetParent (canvas.transform);
					particleObj.transform.localPosition = new Vector2(0,60);

					string blackPath = "Prefabs/PostKassen/black";
					GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject;
					blackObj.transform.SetParent (canvas.transform);
					blackObj.transform.localScale = new Vector2(330,300);
					blackObj.transform.localPosition = new Vector2 (0,0);

					string makimonoPath = "Prefabs/PostKassen/makimono";
					GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject;
					makimonoObj.transform.SetParent (canvas.transform);
					makimonoObj.transform.localScale = new Vector2(1,1);
					makimonoObj.transform.localPosition = new Vector2(0,-135);

					string stageName = PlayerPrefs.GetString("activeStageName");


					//Item List
					string itemListPath = "Prefabs/PostKassen/itemList";
					GameObject itemListObj = Instantiate(Resources.Load (itemListPath)) as GameObject;
					itemListObj.transform.SetParent (canvas.transform);
					itemListObj.transform.localScale = new Vector2(1,1);
					itemListObj.transform.localPosition = new Vector2 (0,-136);

					if (!isAttackedFlg) {

						itemListObj.transform.FindChild ("stageName").transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "攻略";

						/*Item or Kahou*/
						string activeItemGrp = PlayerPrefs.GetString ("activeItemGrp");

						if (activeItemGrp != "no") {
								
							string activeItemType = PlayerPrefs.GetString ("activeItemType");
							Debug.Log (activeItemType);
							int activeItemId = PlayerPrefs.GetInt ("activeItemId");
							Debug.Log (activeItemId);
							int activeItemQty = PlayerPrefs.GetInt ("activeItemQty");
							Debug.Log (activeItemQty);

							//Get Item
							string cyouheiPath = "Prefabs/Item/Cyouhei/" + activeItemType;
							string kanjyoPath = "Prefabs/Item/Kanjyo/Kanjyo";
							string hidensyoPath = "Prefabs/Item/Hidensyo/Hidensyo";
							string shinobiPath = "Prefabs/Item/Shinobi/Shinobi";
							char[] delimiterChars = { ',' };

							if (activeItemGrp == "item") {

								//Cyouhei
								if (activeItemType.Contains ("Cyouhei") == true) {
									string newCyouheiString = "";

									makeItemIcon (cyouheiPath, activeItemId.ToString (), itemListObj);
									if (activeItemType.Contains ("YR") == true) {
										string cyouheiString = PlayerPrefs.GetString ("cyouheiYR");
										string[] cyouheiList = cyouheiString.Split (delimiterChars);
										if (activeItemId == 1) {
											int tempQty = int.Parse (cyouheiList [0]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2];

										} else if (activeItemId == 2) {
											int tempQty = int.Parse (cyouheiList [1]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2];

										} else if (activeItemId == 3) {
											int tempQty = int.Parse (cyouheiList [2]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString ();
										}

										PlayerPrefs.SetString ("cyouheiYR", newCyouheiString);

									} else if (activeItemType.Contains ("KB") == true) {
										string cyouheiString = PlayerPrefs.GetString ("cyouheiKB");
										string[] cyouheiList = cyouheiString.Split (delimiterChars);
										if (activeItemId == 1) {
											int tempQty = int.Parse (cyouheiList [0]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2];
											
										} else if (activeItemId == 2) {
											int tempQty = int.Parse (cyouheiList [1]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2];
											
										} else if (activeItemId == 3) {
											int tempQty = int.Parse (cyouheiList [2]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString ();
										}
										
										PlayerPrefs.SetString ("cyouheiKB", newCyouheiString);

									} else if (activeItemType.Contains ("TP") == true) {
										string cyouheiString = PlayerPrefs.GetString ("cyouheiTP");
										string[] cyouheiList = cyouheiString.Split (delimiterChars);
										if (activeItemId == 1) {
											int tempQty = int.Parse (cyouheiList [0]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2];
											
										} else if (activeItemId == 2) {
											int tempQty = int.Parse (cyouheiList [1]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2];
											
										} else if (activeItemId == 3) {
											int tempQty = int.Parse (cyouheiList [2]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString ();
										}
										
										PlayerPrefs.SetString ("cyouheiTP", newCyouheiString);

									} else if (activeItemType.Contains ("YM") == true) {
										string cyouheiString = PlayerPrefs.GetString ("cyouheiYM");
										string[] cyouheiList = cyouheiString.Split (delimiterChars);
										if (activeItemId == 1) {
											int tempQty = int.Parse (cyouheiList [0]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = tempQty.ToString () + "," + cyouheiList [1] + "," + cyouheiList [2];
											
										} else if (activeItemId == 2) {
											int tempQty = int.Parse (cyouheiList [1]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + tempQty.ToString () + "," + cyouheiList [2];
											
										} else if (activeItemId == 3) {
											int tempQty = int.Parse (cyouheiList [2]);
											tempQty = tempQty + activeItemQty;
											newCyouheiString = cyouheiList [0] + "," + cyouheiList [1] + "," + tempQty.ToString ();
										}
										
										PlayerPrefs.SetString ("cyouheiYM", newCyouheiString);
									}


									//Kanjyo
								} else if (activeItemType == "Kanjyo") {
									makeItemIcon (kanjyoPath, activeItemId.ToString (), itemListObj);

									string newKanjyoString = "";
									string kanjyoString = PlayerPrefs.GetString ("kanjyo");
									string[] kanjyoList = kanjyoString.Split (delimiterChars);

									if (activeItemId == 1) {
										int tempQty = int.Parse (kanjyoList [0]);
										tempQty = tempQty + activeItemQty;
										newKanjyoString = tempQty.ToString () + "," + kanjyoList [1] + "," + kanjyoList [2];
										
									} else if (activeItemId == 2) {
										int tempQty = int.Parse (kanjyoList [1]);
										tempQty = tempQty + activeItemQty;
										newKanjyoString = kanjyoList [0] + "," + tempQty.ToString () + "," + kanjyoList [2];
										
									} else if (activeItemId == 3) {
										int tempQty = int.Parse (kanjyoList [2]);
										tempQty = tempQty + activeItemQty;
										newKanjyoString = kanjyoList [0] + "," + kanjyoList [1] + "," + tempQty.ToString ();
									}
									PlayerPrefs.SetString ("kanjyo", newKanjyoString);
								
									//Hidensyo
								} else if (activeItemType == "Hidensyo") {
									makeItemIcon (hidensyoPath, activeItemId.ToString (), itemListObj);

									if (activeItemId == 1) {
										int hidensyoQty = PlayerPrefs.GetInt ("hidensyoGe");
										hidensyoQty = hidensyoQty + activeItemQty;
										PlayerPrefs.SetInt ("hidensyoGe", hidensyoQty);

									} else if (activeItemId == 2) {
										int hidensyoQty = PlayerPrefs.GetInt ("hidensyoCyu");
										hidensyoQty = hidensyoQty + activeItemQty;
										PlayerPrefs.SetInt ("hidensyoCyu", hidensyoQty);

									} else if (activeItemId == 3) {
										int hidensyoQty = PlayerPrefs.GetInt ("hidensyoJyo");
										hidensyoQty = hidensyoQty + activeItemQty;
										PlayerPrefs.SetInt ("hidensyoJyo", hidensyoQty);
									}

									//Shinobi
								} else if (activeItemType == "Shinobi") {
									makeItemIcon (shinobiPath, activeItemId.ToString (), itemListObj);
									RectTransform rect = itemListObj.transform.FindChild ("itemIcon").transform.FindChild ("Shinobi").GetComponent<RectTransform> ();
									rect.sizeDelta = new Vector2 (100, 100);


									if (activeItemId == 1) {
										int newQty = 0;
										int shinobiQty = PlayerPrefs.GetInt ("shinobiGe");
										newQty = shinobiQty + activeItemQty;
										PlayerPrefs.SetInt ("shinobiGe", newQty);

									} else if (activeItemId == 2) {
										int newQty = 0;
										int shinobiQty = PlayerPrefs.GetInt ("shinobiCyu");
										newQty = shinobiQty + activeItemQty;
										PlayerPrefs.SetInt ("shinobiCyu", newQty);

									} else if (activeItemId == 3) {
										int newQty = 0;
										int shinobiQty = PlayerPrefs.GetInt ("shinobiJyo");
										newQty = shinobiQty + activeItemQty;
										PlayerPrefs.SetInt ("shinobiJyo", newQty);

									}								
								
									//tech
								} else if (activeItemType == "tech") {
									string path = "Prefabs/Item/Tech/Tech";
									GameObject tech = Instantiate (Resources.Load (path)) as GameObject;
									tech.transform.SetParent (itemListObj.transform);
									tech.transform.localScale = new Vector2 (0.4f, 0.4f);
									RectTransform techTransform = tech.GetComponent<RectTransform> ();
									techTransform.sizeDelta = new Vector2 (100, 100);
									techTransform.anchoredPosition3D = new Vector3 (650, 110, 0);
									tech.GetComponent<Button> ().enabled = false;

									string spritePath = "";
									if (activeItemId == 1) {
										//TP
										int qty = PlayerPrefs.GetInt ("transferTP", 0);
										int newQty = qty + activeItemQty;
										PlayerPrefs.SetInt ("transferTP", newQty);
										spritePath = "Prefabs/Item/Tech/Sprite/tp";

									} else if (activeItemId == 2) {
										int qty = PlayerPrefs.GetInt ("transferKB", 0);
										int newQty = qty + activeItemQty;
										PlayerPrefs.SetInt ("transferKB", newQty);
										spritePath = "Prefabs/Item/Tech/Sprite/kb";

									} else if (activeItemId == 3) {
										int qty = PlayerPrefs.GetInt ("transferSNB", 0);
										int newQty = qty + activeItemQty;
										PlayerPrefs.SetInt ("transferSNB", newQty);
										spritePath = "Prefabs/Item/Tech/Sprite/snb";
									}
										
									tech.GetComponent<Image> ().sprite = 
										Resources.Load (spritePath, typeof(Sprite)) as Sprite;
									
								
									//cyoutei or koueki
								} else if (activeItemType == "cyoutei" || activeItemType == "koueki") {

									if (activeItemType == "cyoutei") {
										string syoukaijyoPath = "Prefabs/Item/cyoutei";
										GameObject icon = Instantiate (Resources.Load (syoukaijyoPath)) as GameObject;
										icon.transform.SetParent (itemListObj.transform);
										icon.transform.localPosition = new Vector3 (250, 35, 0);
										icon.transform.localScale = new Vector2 (0.4f, 0.4f);
										icon.GetComponent<Button> ().enabled = false;

										if (activeItemId == 1) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "山科言継";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "下";
										} else if (activeItemId == 2) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "三条西実枝";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "中";
										} else if (activeItemId == 3) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "近衛前久";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "上";
										}

									} else if (activeItemType == "koueki") {
										string syoukaijyoPath = "Prefabs/Item/koueki";
										GameObject icon = Instantiate (Resources.Load (syoukaijyoPath)) as GameObject;
										icon.transform.SetParent (itemListObj.transform);
										icon.transform.localPosition = new Vector3 (250, 35, 0);
										icon.transform.localScale = new Vector2 (0.4f, 0.4f);
										icon.GetComponent<Button> ().enabled = false;

										if (activeItemId == 1) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "加藤浄与";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "下";
										} else if (activeItemId == 2) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "島井宗室";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "中";
										} else if (activeItemId == 3) {
											GameObject nameObj = icon.transform.FindChild ("Name").gameObject;
											nameObj.GetComponent<Text> ().text = "茶屋四郎次郎";
											nameObj.transform.localScale = new Vector2 (0.08f, 0.1f);
											icon.transform.FindChild ("Rank").GetComponent<Text> ().text = "上";
										}
									}

									TabibitoItemGetter syoukaijyo = new TabibitoItemGetter ();
									syoukaijyo.registerKouekiOrCyoutei (activeItemType, activeItemId);
								
								} else if (activeItemType == "Tama") {

									string path = "Prefabs/Item/Tama";
									GameObject icon = Instantiate (Resources.Load (path)) as GameObject;
									icon.transform.SetParent (itemListObj.transform);
									icon.transform.localPosition = new Vector3 (250, 35, 0);
									icon.transform.localScale = new Vector2 (0.4f, 0.4f);
									icon.GetComponent<Button> ().enabled = false;
								
									int nowQty = PlayerPrefs.GetInt ("busyoDama");
									int newQty = nowQty + activeItemQty;
									PlayerPrefs.SetInt ("busyoDama", newQty);

								}


							} else if (activeItemGrp == "kahou") {
								//Kahou
								string kahouIconPath = "Prefabs/Item/Kahou/" + activeItemType + activeItemId;
								GameObject kahouIcon = Instantiate (Resources.Load (kahouIconPath)) as GameObject;
								kahouIcon.transform.SetParent (itemListObj.transform);
								kahouIcon.name = "itemIcon";
								kahouIcon.transform.localPosition = new Vector3 (250, 35, 0);
								kahouIcon.transform.localScale = new Vector2 (0.4f, 0.4f);
								RectTransform kahouTransform = kahouIcon.GetComponent<RectTransform> ();
								kahouTransform.sizeDelta = new Vector2 (100, 100);

								GameObject rank = kahouIcon.transform.FindChild ("Rank").gameObject;
								rank.transform.localScale = new Vector2 (0.3f, 0.3f);
								rank.transform.localPosition = new Vector2 (20, -20);

								//Register
								addKahou (activeItemType, activeItemId);
							}

							//Qty
							string itemQtyPath = "Prefabs/PostKassen/itemQty";
							GameObject itemQtyObj = Instantiate (Resources.Load (itemQtyPath)) as GameObject;
							itemQtyObj.transform.SetParent (itemListObj.transform);
							itemQtyObj.transform.localScale = new Vector2 (0.09f, 0.09f);
							itemQtyObj.transform.localPosition = new Vector2 (290, 35);
							itemQtyObj.GetComponent<Text> ().text = "x " + activeItemQty.ToString ();

							
							PlayerPrefs.Flush ();
						}

					} else {
						itemListObj.transform.FindChild ("stageName").transform.FindChild("stageNameValue").GetComponent<Text> ().text = stageName + "成功";
					}
					
					//Money
					int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney",0);
					GameObject.Find ("moneyAmt").GetComponent<Text>().text = activeStageMoney.ToString();
					int currentMoney = PlayerPrefs.GetInt("money");
					currentMoney = currentMoney + activeStageMoney;
					PlayerPrefs.SetInt("money",currentMoney);

					//kuniExp
					int activeStageExp = PlayerPrefs.GetInt("activeStageExp",0);
					GameObject.Find ("expAmt").GetComponent<Text>().text = activeStageExp.ToString();
					int currentKuniExp = PlayerPrefs.GetInt ("kuniExp");
					currentKuniExp = currentKuniExp + activeStageExp;
					int kuniLv = PlayerPrefs.GetInt ("kuniLv");
					Exp kuniExp = new Exp();
					int newKuniLv = kuniExp.getKuniLv(kuniLv,currentKuniExp);

					if(newKuniLv>kuniLv){
						//lv up
						int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv);
						int stockLimit = kuniExp.getStockLimit(newKuniLv);
						PlayerPrefs.SetInt("jinkeiLimit",jinkeiLimit);
						PlayerPrefs.SetInt("stockLimit",stockLimit);


					}else{
						Debug.Log ("No level up");
					}

					/*Cleared Flag*/
					if(!isAttackedFlg){
						int activeKuniId  = PlayerPrefs.GetInt("activeKuniId");
						int activeStageId = PlayerPrefs.GetInt("activeStageId");
						string temp = "kuni" + activeKuniId.ToString();

						List<string> clearedStageList = new List<string>();
						string clearedStageString  = PlayerPrefs.GetString(temp);

						if(clearedStageString !=null && clearedStageString !=""){
							//after 1st time
							char[] delimiterChars = {','};
							clearedStageList = new List<string>(clearedStageString.Split (delimiterChars));
							if(clearedStageList.Contains(activeStageId.ToString()) == false){
								clearedStageString = clearedStageString + "," + activeStageId.ToString();

								//1st Kuni Clear Check
								string[] commaCounter = clearedStageString.Split(delimiterChars);
								int counter = commaCounter.Length;

								if(counter == 10){
									//1st time
									string clearedKuni = PlayerPrefs.GetString("clearedKuni");
									if(clearedKuni !=null && clearedKuni !=""){
										clearedKuni = clearedKuni + "," + activeKuniId.ToString();
									}else{
										clearedKuni = activeKuniId.ToString();
									}
									PlayerPrefs.SetString("clearedKuni",clearedKuni);
									//Give 1st cleared revenue 
									PlayerPrefs.SetBool("kuniClearedFlg",true);

									//Open Kuni
									KuniInfo kuni = new KuniInfo();
									kuni.registerOpenKuni(activeKuniId);

									//Seiryoku Change
									string seiryoku = PlayerPrefs.GetString ("seiryoku");
									List<string> seiryokuList = new List<string>();
									seiryokuList = new List<string> (seiryoku.Split (delimiterChars));

									int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
									seiryokuList[activeKuniId-1] = myDaimyo.ToString();
									string newSeiryoku = "";
									bool gameClearFlg = true;
									for(int i=0; i<seiryokuList.Count; i++){
										if(i==0){
											newSeiryoku = seiryokuList[i];
										}else{
											newSeiryoku = newSeiryoku + "," + seiryokuList[i];
										}

										//game clear check
										if(gameClearFlg){
											if(seiryokuList[i] != myDaimyo.ToString()){
												gameClearFlg = false;
											}
										}
									}
									PlayerPrefs.SetBool("gameClearFlg",gameClearFlg);
									PlayerPrefs.SetString("seiryoku",newSeiryoku);


									//Cyouhou Delete
									string cyouhouTmp = "cyouhou" + activeKuniId;
									if (PlayerPrefs.HasKey (cyouhouTmp)) {
										PlayerPrefs.DeleteKey(cyouhouTmp);

										string cyouhou = PlayerPrefs.GetString("cyouhou");
										List<string> cyouhouList = new List<string> ();
										if (cyouhou != null && cyouhou != "") {
											if(cyouhou.Contains(",")){
												cyouhouList = new List<string> (cyouhou.Split (delimiterChars));
											}else{
												cyouhouList.Add(cyouhou);
											}
										}

										cyouhouList.Remove (activeKuniId.ToString());
										string newCyouhou = "";
										for(int j=0;j<cyouhouList.Count;j++){
											if (j == 0) {
												newCyouhou = cyouhouList[j];
											} else {
												newCyouhou = newCyouhou + "," + cyouhouList[j];
											}
										}
										PlayerPrefs.SetString ("cyouhou",newCyouhou);

									}
								}
							}
						}else{
							//1st time
							clearedStageString = activeStageId.ToString();
						}
						PlayerPrefs.SetString(temp,clearedStageString);

						PlayerPrefs.SetInt("kuniLv",newKuniLv);
						PlayerPrefs.SetInt("kuniExp",currentKuniExp);
						PlayerPrefs.Flush();
					}

					//Button List
					string nextbtnPath = "Prefabs/PostKassen/bttnList";
					GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject;
					bttnListObj.transform.SetParent (canvas.transform);
					bttnListObj.transform.localScale = new Vector2(1,1);
					bttnListObj.transform.localPosition = new Vector2 (0,0);

					//Time Stop
					GameObject.Find ("timer").GetComponent<Timer>().enabled = false;


					//Get Exp
					SenkouButton senkou = new SenkouButton();
					List<BusyoSenkou> senkouList = new List<BusyoSenkou>();
					senkouList=senkou.getSenkou ();
					for(int i=0;i<senkouList.Count;i++){

						int busyoId = senkouList[i].id;
						int senkouAmt = senkouList[i].senkou;
						Exp exp = new Exp();

						//Modify by Cyadougu Kahou
						senkouAmt = exp.getExpbyCyadougu(busyoId,senkouAmt);

						//Busyo Exp
						string tempExp = "exp" + busyoId;
						int nowExp = PlayerPrefs.GetInt(tempExp);
						int newExp = nowExp + senkouAmt;
						PlayerPrefs.SetInt(tempExp, newExp);

						//Busyo Lv
						int nowLv = PlayerPrefs.GetInt(busyoId.ToString());
						int newLv = exp.getLvbyTotalExp(nowLv,newExp);
						PlayerPrefs.SetInt(busyoId.ToString(), newLv);

						PlayerPrefs.Flush();
					}
				}
			}
		}
	}
Esempio n. 2
0
	// Update is called once per frame
	void Update () {
		life = getTotalHp (targetTag);
		gameObject.transform.FindChild("HpText").GetComponent<Text>().text = life.ToString();

		if (!flag) {
			if (life == 0) {
				flag = true;

				if (targetTag == "Player") {
					//Game Over
					string backPath = "Prefabs/PostKassen/back";
					GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject;
					backObj.transform.parent = GameObject.Find ("Canvas").transform;
					backObj.transform.localScale = new Vector2(70,63);

					//Chane word
					Color color = Color.blue;
					GameObject.Find ("winlose").GetComponent<TextMesh>().text = "敗北";
					GameObject.Find ("winlose").GetComponent<TextMesh>().color = color;
					
					string blackPath = "Prefabs/PostKassen/black";
					GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject;
					blackObj.transform.parent = GameObject.Find ("Canvas").transform;
					blackObj.transform.localScale = new Vector2(330,300);

					string makimonoPath = "Prefabs/PostKassen/makimono";
					GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject;
					makimonoObj.transform.parent = GameObject.Find ("Canvas").transform;
					makimonoObj.transform.localScale = new Vector2(60,80);
					makimonoObj.transform.localPosition = new Vector2(0,-130);

					//Button List
					string nextbtnPath = "Prefabs/PostKassen/bttnList";
					GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject;
					bttnListObj.transform.parent = GameObject.Find ("Canvas").transform;
					bttnListObj.transform.localScale = new Vector2(1,1);		
					
					//Time Stop
					GameObject.Find ("timer").GetComponent<Timer>().enabled = false;

					Debug.Log (isAttackedFlg);
					//Check is attacked flag
					if(isAttackedFlg == true){
						//My Daimyo Lose 

						Gunzei lose = new Gunzei();
						string tKey = PlayerPrefs.GetString("activeKey");
						int tSrcDaimyoId = PlayerPrefs.GetInt("activeSrcDaimyoId");
						int tDstDaimyoId = PlayerPrefs.GetInt("activeDstDaimyoId");
						bool noGunzeiFlg = true;
						PlayerPrefs.DeleteKey("isAttacked");
						lose.win(tKey, tSrcDaimyoId, tDstDaimyoId,noGunzeiFlg);


						//Delete Cleared Kuni
						int activeKuniId  = PlayerPrefs.GetInt("activeKuniId");
						string clearedKuni = PlayerPrefs.GetString("clearedKuni");

						char[] delimiterChars = {','};
						List<string> clearedKuniList = new List<string>();
						
						if (clearedKuni != null && clearedKuni != "") {
							if(clearedKuni.Contains(",")){
								clearedKuniList = new List<string> (clearedKuni.Split (delimiterChars));
							}else{
								clearedKuniList.Add(clearedKuni);
							}
						}
						Debug.Log ("before:"+clearedKuniList.Count);
						string tempActiveKuni = activeKuniId.ToString();
						clearedKuniList.Remove(tempActiveKuni);
						Debug.Log ("after:"+clearedKuniList.Count);
						string newClearedKuni = "";
						for(int i=0; i<clearedKuniList.Count; i++){
							if(i==0){
								newClearedKuni = clearedKuniList[i];
							}else{
								newClearedKuni = newClearedKuni + "," + clearedKuniList[i];
							}
						}
						PlayerPrefs.SetString("clearedKuni",newClearedKuni);
						Debug.Log ("NewClearedKuni:"+newClearedKuni);

						if(newClearedKuni==null || newClearedKuni == ""){
							PlayerPrefs.SetBool("gameOverFlg",true);
							Debug.Log ("gameOverFlg");

						}

						//Delete Naisei
						string tempNaisei = "naisei" + activeKuniId.ToString();
						PlayerPrefs.DeleteKey(tempNaisei);

						//Delete Jyosyu
						string tempJyosyu = "jyosyu" + activeKuniId.ToString();
						PlayerPrefs.DeleteKey(tempJyosyu);

						//Delete Stage Clear
						string tempKuni = "kuni" + activeKuniId.ToString();
						PlayerPrefs.DeleteKey(tempKuni);

						//Delete open
						KuniInfo kuni = new KuniInfo();
						kuni.updateOpenKuni();
						PlayerPrefs.Flush();
					}

				} else if (targetTag == "Enemy") {
					//Win
					if(isAttackedFlg == true){
						//history
						string tKey = PlayerPrefs.GetString("activeKey");
						MainStageController main = new MainStageController();
						main.deleteKeyHistory(tKey);
						PlayerPrefs.DeleteKey("isAttacked");
						PlayerPrefs.Flush();
					}

					string backPath = "Prefabs/PostKassen/back";
					GameObject backObj = Instantiate(Resources.Load (backPath)) as GameObject;
					backObj.transform.parent = GameObject.Find ("Canvas").transform;
					backObj.transform.localScale = new Vector2(70,63);

					string particlePath = "Prefabs/PostKassen/particle";
					GameObject particleObj = Instantiate(Resources.Load (particlePath)) as GameObject;
					particleObj.transform.parent = GameObject.Find ("Canvas").transform;
					particleObj.transform.localPosition = new Vector2(0,60);

					string blackPath = "Prefabs/PostKassen/black";
					GameObject blackObj = Instantiate(Resources.Load (blackPath)) as GameObject;
					blackObj.transform.parent = GameObject.Find ("Canvas").transform;
					blackObj.transform.localScale = new Vector2(330,300);

					string makimonoPath = "Prefabs/PostKassen/makimono";
					GameObject makimonoObj = Instantiate(Resources.Load (makimonoPath)) as GameObject;
					makimonoObj.transform.parent = GameObject.Find ("Canvas").transform;
					makimonoObj.transform.localScale = new Vector2(60,80);
					makimonoObj.transform.localPosition = new Vector2(0,-130);

					//Item List
					string itemListPath = "Prefabs/PostKassen/itemList";
					GameObject itemListObj = Instantiate(Resources.Load (itemListPath)) as GameObject;
					itemListObj.transform.parent = GameObject.Find ("Canvas").transform;
					itemListObj.transform.localScale = new Vector2(1,1);

					if(!isAttackedFlg){

						/*Item or Kahou*/
						string activeItemType = PlayerPrefs.GetString("activeItemType");
						int activeItemId = PlayerPrefs.GetInt("activeItemId");
						float activeItemRatio = PlayerPrefs.GetFloat("activeItemRatio");
						int activeItemQty = PlayerPrefs.GetInt("activeItemQty");

						float percent = Random.value;
						percent = percent * 100;

						if(percent <= activeItemRatio){
							//if(0 <= activeItemRatio){ //Test
							//Get Item

							string cyouheiPath = "Prefabs/Item/Cyouhei/" + activeItemType;
							string kanjyoPath = "Prefabs/Item/Kanjyo/Kanjyo";
							string hidensyoPath = "Prefabs/Item/Hidensyo/Hidensyo";
							char[] delimiterChars = {','};

							ShowStageDtl itemIcon = new ShowStageDtl();
							if(activeItemType.Contains("Cyouhei")==true){
								string newCyouheiString = "";

								itemIcon.makeItemIcon(cyouheiPath, activeItemId.ToString(), itemListObj);
								if(activeItemType.Contains("YR")==true){
									string cyouheiString = PlayerPrefs.GetString("cyouheiYR");
									string[] cyouheiList = cyouheiString.Split (delimiterChars);
									if(activeItemId == 1){
										int tempQty = int.Parse(cyouheiList[0]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2];

									}else if(activeItemId == 2){
										int tempQty = int.Parse(cyouheiList[1]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2];

									}else if(activeItemId == 3){
										int tempQty = int.Parse(cyouheiList[2]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString();
									}

									PlayerPrefs.SetString("cyouheiYR", newCyouheiString);

								}else if(activeItemType.Contains("KB")==true){
									string cyouheiString = PlayerPrefs.GetString("cyouheiKB");
									string[] cyouheiList = cyouheiString.Split (delimiterChars);
									if(activeItemId == 1){
										int tempQty = int.Parse(cyouheiList[0]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2];
										
									}else if(activeItemId == 2){
										int tempQty = int.Parse(cyouheiList[1]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2];
										
									}else if(activeItemId == 3){
										int tempQty = int.Parse(cyouheiList[2]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString();
									}
									
									PlayerPrefs.SetString("cyouheiKB", newCyouheiString);

								}else if(activeItemType.Contains("TP")==true){
									string cyouheiString = PlayerPrefs.GetString("cyouheiTP");
									string[] cyouheiList = cyouheiString.Split (delimiterChars);
									if(activeItemId == 1){
										int tempQty = int.Parse(cyouheiList[0]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2];
										
									}else if(activeItemId == 2){
										int tempQty = int.Parse(cyouheiList[1]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2];
										
									}else if(activeItemId == 3){
										int tempQty = int.Parse(cyouheiList[2]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString();
									}
									
									PlayerPrefs.SetString("cyouheiTP", newCyouheiString);

								}else if(activeItemType.Contains("YM")==true){
									string cyouheiString = PlayerPrefs.GetString("cyouheiYM");
									string[] cyouheiList = cyouheiString.Split (delimiterChars);
									if(activeItemId == 1){
										int tempQty = int.Parse(cyouheiList[0]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = tempQty.ToString() + "," + cyouheiList[1] +","+ cyouheiList[2];
										
									}else if(activeItemId == 2){
										int tempQty = int.Parse(cyouheiList[1]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] + "," + tempQty.ToString() +","+ cyouheiList[2];
										
									}else if(activeItemId == 3){
										int tempQty = int.Parse(cyouheiList[2]);
										tempQty = tempQty + activeItemQty;
										newCyouheiString = cyouheiList[0] +","+ cyouheiList[1] + "," + tempQty.ToString();
									}
									
									PlayerPrefs.SetString("cyouheiYM", newCyouheiString);
								}



							}else if(activeItemType == "Kanjyo"){
								itemIcon.makeItemIcon(kanjyoPath, activeItemId.ToString(), itemListObj);

								string newKanjyoString = "";
								string kanjyoString = PlayerPrefs.GetString("kanjyo");
								string[] kanjyoList = kanjyoString.Split (delimiterChars);

								if(activeItemId == 1){
									int tempQty = int.Parse(kanjyoList[0]);
									tempQty = tempQty + activeItemQty;
									newKanjyoString = tempQty.ToString() + "," + kanjyoList[1] +","+ kanjyoList[2];
									
								}else if(activeItemId == 2){
									int tempQty = int.Parse(kanjyoList[1]);
									tempQty = tempQty + activeItemQty;
									newKanjyoString = kanjyoList[0] + "," + tempQty.ToString() +","+ kanjyoList[2];
									
								}else if(activeItemId == 3){
									int tempQty = int.Parse(kanjyoList[2]);
									tempQty = tempQty + activeItemQty;
									newKanjyoString = kanjyoList[0] +","+ kanjyoList[1] + "," + tempQty.ToString();
								}
								PlayerPrefs.SetString("kanjyo", newKanjyoString);

							}else if(activeItemType == "Hidensyo"){
								itemIcon.makeItemIcon(hidensyoPath, activeItemId.ToString(), itemListObj);

								if(activeItemId == 1){
									int hidensyoQty = PlayerPrefs.GetInt("hidensyoGe");
									hidensyoQty = hidensyoQty + activeItemQty;
									PlayerPrefs.SetInt("hidensyoGe", hidensyoQty);

								}else if(activeItemId == 2){
									int hidensyoQty = PlayerPrefs.GetInt("hidensyoCyu");
									hidensyoQty = hidensyoQty + activeItemQty;
									PlayerPrefs.SetInt("hidensyoCyu", hidensyoQty);

								}else if(activeItemId == 3){
									int hidensyoQty = PlayerPrefs.GetInt("hidensyoJyo");
									hidensyoQty = hidensyoQty + activeItemQty;
									PlayerPrefs.SetInt("hidensyoJyo", hidensyoQty);
								}

							}else{
								//Kahou
								string kahouIconPath = "Prefabs/Item/Kahou/" + activeItemType + activeItemId;
								GameObject kahouIcon = Instantiate (Resources.Load (kahouIconPath)) as GameObject;
								kahouIcon.transform.SetParent(itemListObj.transform);
								kahouIcon.name = "itemIcon";
								RectTransform kahouTransform = kahouIcon.GetComponent<RectTransform> ();
								kahouTransform.sizeDelta = new Vector2 (100, 100);
								GameObject rank = kahouIcon.transform.FindChild("Rank").gameObject;
								rank.transform.localScale = new Vector2(0.3f,0.3f);
								rank.transform.localPosition = new Vector2(20,-20);

								//Register
								addKahou(activeItemType, activeItemId);
							}



							//Modfication Size & Location
							GameObject item = GameObject.Find ("itemIcon");
							item.transform.localScale = new Vector2 (0.4f, 0.42f);
							item.transform.localPosition = new Vector2(80,-105);
							item.GetComponent<Button>().enabled = false;

							//Qty
							string itemQtyPath = "Prefabs/PostKassen/itemQty";
							GameObject itemQtyObj = Instantiate(Resources.Load (itemQtyPath)) as GameObject;
							itemQtyObj.transform.SetParent(itemListObj.transform);
							itemQtyObj.transform.localScale = new Vector2(0.09f,0.09f);
							itemQtyObj.transform.localPosition = new Vector2(130,-105);
							itemQtyObj.GetComponent<Text>().text = "x " + activeItemQty.ToString();

							//
							PlayerPrefs.Flush();
						}
					}

					//Money
					int activeStageMoney = PlayerPrefs.GetInt("activeStageMoney",0);
					GameObject.Find ("moneyAmt").GetComponent<TextMesh>().text = activeStageMoney.ToString();
					int currentMoney = PlayerPrefs.GetInt("money");
					currentMoney = currentMoney + activeStageMoney;
					PlayerPrefs.SetInt("money",currentMoney);

					//kuniExp
					int activeStageExp = PlayerPrefs.GetInt("activeStageExp",0);
					GameObject.Find ("expAmt").GetComponent<TextMesh>().text = activeStageExp.ToString();
					int currentKuniExp = PlayerPrefs.GetInt ("kuniExp");
					currentKuniExp = currentKuniExp + activeStageExp;
					int kuniLv = PlayerPrefs.GetInt ("kuniLv");
					Exp kuniExp = new Exp();
					int newKuniLv = kuniExp.getKuniLv(kuniLv,currentKuniExp);

					if(newKuniLv>kuniLv){
						//lv up
						int jinkeiLimit = kuniExp.getJinkeiLimit(newKuniLv);
						int stockLimit = kuniExp.getStockLimit(newKuniLv);
						PlayerPrefs.SetInt("jinkeiLimit",jinkeiLimit);
						PlayerPrefs.SetInt("stockLimit",stockLimit);


					}else{
						Debug.Log ("No level up");
					}

					/*Cleared Flag*/
					if(!isAttackedFlg){
						int activeKuniId  = PlayerPrefs.GetInt("activeKuniId");
						int activeStageId = PlayerPrefs.GetInt("activeStageId");
						string temp = "kuni" + activeKuniId.ToString();

						List<string> clearedStageList = new List<string>();
						string clearedStageString  = PlayerPrefs.GetString(temp);

						if(clearedStageString !=null && clearedStageString !=""){
							//after 1st time
							char[] delimiterChars = {','};
							clearedStageList = new List<string>(clearedStageString.Split (delimiterChars));
							if(clearedStageList.Contains(activeStageId.ToString()) == false){
								clearedStageString = clearedStageString + "," + activeStageId.ToString();

								//1st Kuni Clear Check
								string[] commaCounter = clearedStageString.Split(delimiterChars);
								int counter = commaCounter.Length;

								if(counter == 10){
									//1st time
									string clearedKuni = PlayerPrefs.GetString("clearedKuni");
									if(clearedKuni !=null && clearedKuni !=""){
										clearedKuni = clearedKuni + "," + activeKuniId.ToString();
									}else{
										clearedKuni = activeKuniId.ToString();
									}
									PlayerPrefs.SetString("clearedKuni",clearedKuni);
									//Give 1st cleared revenue 
									PlayerPrefs.SetBool("kuniClearedFlg",true);

									//Open Kuni
									KuniInfo kuni = new KuniInfo();
									kuni.registerOpenKuni(activeKuniId);

									//Seiryoku Change
									string seiryoku = PlayerPrefs.GetString ("seiryoku");
									List<string> seiryokuList = new List<string>();
									seiryokuList = new List<string> (seiryoku.Split (delimiterChars));

									int myDaimyo = PlayerPrefs.GetInt ("myDaimyo");
									seiryokuList[activeKuniId-1] = myDaimyo.ToString();
									string newSeiryoku = "";
									for(int i=0; i<seiryokuList.Count; i++){
										if(i==0){
											newSeiryoku = seiryokuList[i];
										}else{
											newSeiryoku = newSeiryoku + "," + seiryokuList[i];
										}
									}
									PlayerPrefs.SetString("seiryoku",newSeiryoku);

								}
							}
						}else{
							//1st time
							clearedStageString = activeStageId.ToString();
							Debug.Log (clearedStageString);
						}
						PlayerPrefs.SetString(temp,clearedStageString);

						PlayerPrefs.SetInt("kuniLv",newKuniLv);
						PlayerPrefs.SetInt("kuniExp",currentKuniExp);
						PlayerPrefs.Flush();
					}

					//Button List
					string nextbtnPath = "Prefabs/PostKassen/bttnList";
					GameObject bttnListObj = Instantiate(Resources.Load (nextbtnPath)) as GameObject;
					bttnListObj.transform.parent = GameObject.Find ("Canvas").transform;
					bttnListObj.transform.localScale = new Vector2(1,1);


					//Time Stop
					GameObject.Find ("timer").GetComponent<Timer>().enabled = false;


					//Get Exp
					SenkouButton senkou = new SenkouButton();
					List<BusyoSenkou> senkouList = new List<BusyoSenkou>();
					senkouList=senkou.getSenkou ();
					for(int i=0;i<senkouList.Count;i++){

						int busyoId = senkouList[i].id;
						int senkouAmt = senkouList[i].senkou;
						Exp exp = new Exp();

						//Modify by Cyadougu Kahou
						senkouAmt = exp.getExpbyCyadougu(busyoId,senkouAmt);

						//Busyo Exp
						string tempExp = "exp" + busyoId;
						int nowExp = PlayerPrefs.GetInt(tempExp);
						int newExp = nowExp + senkouAmt;
						PlayerPrefs.SetInt(tempExp, newExp);

						//Busyo Lv
						int nowLv = PlayerPrefs.GetInt(busyoId.ToString());
						int newLv = exp.getLvbyTotalExp(nowLv,newExp);
						PlayerPrefs.SetInt(busyoId.ToString(), newLv);

						PlayerPrefs.Flush();
					}
				}
			}
		}
	}
Esempio n. 3
0
    public void OnClick()
    {
        Daimyo daimyo = new Daimyo();

        audioSources = GameObject.Find("SEController").GetComponents <AudioSource> ();

        if (name == "YesButton")
        {
            //Hyourou
            int hyourou    = PlayerPrefs.GetInt("hyourou");
            int newHyourou = hyourou - 30;
            PlayerPrefs.SetInt("hyourou", newHyourou);
            GameObject.Find("HyourouCurrentValue").GetComponent <Text> ().text = newHyourou.ToString();

            //Soubuji Flg
            PlayerPrefs.SetBool("soubujireiFlg", true);

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

            MainStageController script = GameObject.Find("GameController").GetComponent <MainStageController> ();
            int myKuniQty = script.myKuniQty;
            int myDaimyo  = script.myDaimyo;

            List <int> daimyoIdList      = new List <int> ();
            List <int> mainKuniIdList    = new List <int> ();
            List <int> kuniQtyByDaimyoId = new List <int> ()
            {
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0
            };
            for (int i = 0; i < seiryokuList.Count; i++)
            {
                int daimyoId = int.Parse(seiryokuList [i]);
                if (daimyoId != myDaimyo)
                {
                    int kuniId = i + 1;

                    if (!daimyoIdList.Contains(daimyoId))
                    {
                        daimyoIdList.Add(daimyoId);
                        mainKuniIdList.Add(kuniId);
                    }
                    kuniQtyByDaimyoId [daimyoId - 1] = kuniQtyByDaimyoId [daimyoId - 1] + 1;
                }
            }


            //Do Soubujirei
            List <string> newSeiryokuList = new List <string> (seiryokuList);
            string        clearedKuni     = PlayerPrefs.GetString("clearedKuni");
            KuniInfo      kuni            = new KuniInfo();
            GameObject    kuniIconView    = GameObject.Find("KuniIconView").gameObject;
            GameObject    panel           = GameObject.Find("Panel").gameObject;
            GameObject    kuniMap         = GameObject.Find("KuniMap").gameObject;
            Doumei        doumei          = new Doumei();
            bool          allClearedFlg   = true;

            for (int k = 0; k < daimyoIdList.Count; k++)
            {
                int    daimyoId   = daimyoIdList [k];
                string daimyoName = daimyo.getName(daimyoId);
                int    kuniQty    = 0;
                kuniQty = kuniQtyByDaimyoId [daimyoId - 1];

                float ratio = 0;
                ratio = (100 - ((float)kuniQty / (float)myKuniQty * 500));

                if (ratio < 0)
                {
                    ratio = 0;
                }
                if (testMode)
                {
                    ratio = 100;
                }


                //Debug.Log (daimyoName+":"+kuniQty +"/"+myKuniQty+"="+ratio);
                float percent = UnityEngine.Random.value;
                percent = percent * 100;
                if (percent <= ratio)
                {
                    //OK
                    for (int j = 0; j < seiryokuList.Count; j++)
                    {
                        if (seiryokuList [j] == daimyoId.ToString())
                        {
                            int kuniId = j + 1;

                            //1.update seiryoku
                            newSeiryokuList [kuniId - 1] = myDaimyo.ToString();

                            //2.update cleaered kuni & kuni1,2,3
                            clearedKuni = clearedKuni + "," + kuniId.ToString();
                            string tmp = "kuni" + kuniId.ToString();
                            PlayerPrefs.SetString(tmp, "1,2,3,4,5,6,7,8,9,10");

                            //3.update openkuni
                            kuni.registerOpenKuni(kuniId);

                            //4.cyouhou delete
                            //Cyouhou Delete
                            string cyouhouTmp = "cyouhou" + kuniId;
                            if (PlayerPrefs.HasKey(cyouhouTmp))
                            {
                                PlayerPrefs.DeleteKey(cyouhouTmp);
                                string        cyouhou     = PlayerPrefs.GetString("cyouhou");
                                List <string> cyouhouList = new List <string> ();
                                if (cyouhou != null && cyouhou != "")
                                {
                                    if (cyouhou.Contains(","))
                                    {
                                        cyouhouList = new List <string> (cyouhou.Split(delimiterChars));
                                    }
                                    else
                                    {
                                        cyouhouList.Add(cyouhou);
                                    }
                                }
                                cyouhouList.Remove(kuniId.ToString());
                                string newCyouhou = "";
                                for (int a = 0; a < cyouhouList.Count; a++)
                                {
                                    if (a == 0)
                                    {
                                        newCyouhou = cyouhouList [a];
                                    }
                                    else
                                    {
                                        newCyouhou = newCyouhou + "," + cyouhouList [a];
                                    }
                                }
                                PlayerPrefs.SetString("cyouhou", newCyouhou);
                            }

                            //5. naisei
                            string naiseiTmp = "naisei" + kuniId;
                            if (!PlayerPrefs.HasKey(naiseiTmp))
                            {
                                PlayerPrefs.SetString(naiseiTmp, "1,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0");
                            }

                            //Icon Change
                            IconMapValueUpdate(kuniId, myDaimyo, kuniIconView, kuniMap, myKuniQty);
                        }
                    }
                    //Gunzei Check
                    foreach (GameObject GunzeiObj in  GameObject.FindGameObjectsWithTag("Gunzei"))
                    {
                        int gunzeiSrcDaimyoId = GunzeiObj.GetComponent <Gunzei> ().srcDaimyoId;
                        if (daimyoId == gunzeiSrcDaimyoId)
                        {
                            deleteGunzei(GunzeiObj);
                        }
                    }

                    //Message
                    int msgKuniId = mainKuniIdList [k];
                    okNgMessage(true, msgKuniId, kuniIconView, panel, daimyoName);
                }
                else
                {
                    //NG

                    allClearedFlg = false;

                    //Yukoudo 0
                    string tempGaikou = "gaikou" + daimyoId;
                    PlayerPrefs.SetInt(tempGaikou, 0);

                    //doumei clear
                    bool doumeiFlg = doumei.myDoumeiExistCheck(daimyoId);
                    if (doumeiFlg)
                    {
                        doumei.deleteDoumeiMyDaimyo(myDaimyo.ToString(), daimyoId.ToString());
                    }

                    //Icon color & value
                    kuni.deleteDoumeiKuniIcon(daimyoId);

                    //Message
                    int msgKuniId = mainKuniIdList [k];
                    okNgMessage(false, msgKuniId, kuniIconView, panel, daimyoName);
                }
            }

            string newSeiryoku = "";
            for (int l = 0; l < newSeiryokuList.Count; l++)
            {
                if (l == 0)
                {
                    newSeiryoku = newSeiryokuList [l];
                }
                else
                {
                    newSeiryoku = newSeiryoku + "," + newSeiryokuList [l];
                }
            }
            PlayerPrefs.SetString("seiryoku", newSeiryoku);
            PlayerPrefs.SetString("clearedKuni", clearedKuni);
            PlayerPrefs.Flush();


            //Update OpenKuniIcon
            kuni.updateOpenKuni(myDaimyo, newSeiryoku);

            //Close
            board.transform.FindChild("close").GetComponent <CloseBoard> ().onClick();
            soubujiFlgOn(kuniIconView);

            if (allClearedFlg)
            {
                GameObject.Find("GameController").GetComponent <MainStageController> ().gameClearFlg = true;
                PlayerPrefs.SetBool("gameClearFlg", true);
                PlayerPrefs.Flush();
            }
        }
        else
        {
            audioSources [1].Play();
        }

        Destroy(back.gameObject);
        Destroy(confirm.gameObject);
    }
    public void OnClick()
    {
        AudioSource[] audioSources = GameObject.Find("SEController").GetComponents <AudioSource>();

        if (name == "YesButton")
        {
            audioSources[0].Play();
            RecoveryDataStore RecoveryDataStore = GameObject.Find("RecoveryDataStore").GetComponent <RecoveryDataStore>();

            //Common
            PlayerPrefs.SetBool("tutorialDoneFlg", true);
            PlayerPrefs.SetInt("kuniLv", RecoveryDataStore.kuniLv);
            Exp expScript   = new Exp();
            int jinkeiLimit = expScript.getJinkeiLimit(RecoveryDataStore.kuniLv);
            int stockLimit  = expScript.getStockLimit(RecoveryDataStore.kuniLv);
            PlayerPrefs.SetInt("jinkeiLimit", jinkeiLimit);
            PlayerPrefs.SetInt("stockLimit", stockLimit);
            PlayerPrefs.SetString("userId", RecoveryDataStore.inputUserId);
            if (RecoveryDataStore.addJinkei1)
            {
                PlayerPrefs.SetBool("addJinkei1", true);
            }
            else
            {
                PlayerPrefs.SetBool("addJinkei1", false);
            }
            if (RecoveryDataStore.addJinkei2)
            {
                PlayerPrefs.SetBool("addJinkei2", true);
            }
            else
            {
                PlayerPrefs.SetBool("addJinkei2", false);
            }
            if (RecoveryDataStore.addJinkei3)
            {
                PlayerPrefs.SetBool("addJinkei3", true);
            }
            else
            {
                PlayerPrefs.SetBool("addJinkei3", false);
            }
            if (RecoveryDataStore.addJinkei4)
            {
                PlayerPrefs.SetBool("addJinkei4", true);
            }
            else
            {
                PlayerPrefs.SetBool("addJinkei4", false);
            }

            if (RecoveryDataStore.dataStore_userId == 0)
            {
                /***dataStore***/
                PlayerPrefs.SetInt("kuniExp", RecoveryDataStore.kuniExp);
                PlayerPrefs.SetString("yearSeason", RecoveryDataStore.yearSeason);
                PlayerPrefs.SetInt("movieCount", RecoveryDataStore.movieCount);
                string seiryoku = RecoveryDataStore.seiryoku;
                if (seiryoku == "")
                {
                    seiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46";
                }
                PlayerPrefs.SetString("seiryoku", seiryoku);
                KuniInfo kuniScript = new KuniInfo();
                kuniScript.updateOpenKuni(RecoveryDataStore.myDaimyo, seiryoku);
                kuniScript.updateClearedKuni(RecoveryDataStore.myDaimyo, seiryoku);
                PlayerPrefs.SetInt("money", RecoveryDataStore.money);
                PlayerPrefs.SetInt("busyoDama", RecoveryDataStore.busyoDama);
                PlayerPrefs.SetInt("syogunDaimyoId", RecoveryDataStore.syogunDaimyoId);
                PlayerPrefs.SetString("doumei", RecoveryDataStore.doumei);

                for (int i = 0; i < RecoveryDataStore.questSpecialFlgId.Count; i++)
                {
                    int    questId = RecoveryDataStore.questSpecialFlgId[i];
                    string tmp     = "questSpecialFlg" + questId.ToString();
                    string tmp2    = "questSpecialReceivedFlg" + questId.ToString();
                    PlayerPrefs.SetBool(tmp, true);

                    bool questReceivedFlg = RecoveryDataStore.questSpecialReceivedFlgId[i];
                    if (questReceivedFlg)
                    {
                        PlayerPrefs.SetBool(tmp2, true);
                    }
                    else
                    {
                        PlayerPrefs.SetBool(tmp2, false);
                    }
                }

                Entity_quest_count_mst questCountMst = Resources.Load("Data/quest_count_mst") as Entity_quest_count_mst;
                for (int i = 0; i < questCountMst.param.Count; i++)
                {
                    bool dailyFlg = questCountMst.param[i].daily;
                    if (!dailyFlg)
                    {
                        countSpecialList.Add(i);
                    }
                }
                if (RecoveryDataStore.questSpecialCountReceivedFlg.Count != 0)
                {
                    for (int i = 0; i < countSpecialList.Count; i++)
                    {
                        int    id  = countSpecialList[i];
                        string tmp = "questSpecialCountReceivedFlg" + id.ToString();
                        bool   questReceivedFlg = RecoveryDataStore.questSpecialCountReceivedFlg[i];
                        if (questReceivedFlg)
                        {
                            PlayerPrefs.SetBool(tmp, true);
                        }
                        else
                        {
                            PlayerPrefs.SetBool(tmp, false);
                        }
                    }
                }


                int    count   = 0;
                string myBusyo = "";
                for (int i = 0; i < RecoveryDataStore.busyoList.Count; i++)
                {
                    int busyoId = RecoveryDataStore.busyoList[i];

                    if (busyoId != 0)
                    {
                        //add busyo
                        if (myBusyo == null || myBusyo == "")
                        {
                            myBusyo = busyoId.ToString();
                        }
                        else
                        {
                            myBusyo = myBusyo + "," + busyoId.ToString();
                        }
                        //add parametor
                        int    lv       = RecoveryDataStore.lvList[count];
                        string hei      = RecoveryDataStore.heiList[count];
                        int    senpouLv = RecoveryDataStore.senpouLvList[count];
                        int    sakuLv   = RecoveryDataStore.sakuLvList[count];
                        string kahou    = RecoveryDataStore.kahouList[count];

                        //lv
                        PlayerPrefs.SetInt(busyoId.ToString(), lv);
                        if (lv <= 0)
                        {
                            lv = 1;
                        }

                        //hei
                        string heiTmp = "hei" + busyoId.ToString();
                        PlayerPrefs.SetString(heiTmp, hei);

                        //senpou
                        string senpou = "senpou" + busyoId.ToString();
                        PlayerPrefs.SetInt(senpou, senpouLv); //Lv

                        //saku
                        string saku = "saku" + busyoId.ToString();
                        PlayerPrefs.SetInt(saku, sakuLv); //Lv

                        //kahou
                        string kahouTmp = "kahou" + busyoId.ToString();
                        PlayerPrefs.SetString(kahouTmp, kahou);

                        //exp
                        string exp           = "exp" + busyoId.ToString();
                        int    totalBusyoExp = expScript.getExpforNextLv(lv - 1);
                        PlayerPrefs.SetInt(exp, totalBusyoExp);

                        //addLv
                        string addlvTmp = "addlv" + busyoId.ToString();
                        int    addlv    = RecoveryDataStore.addLvList[count];
                        if (addlv != 0)
                        {
                            PlayerPrefs.SetInt(addlvTmp, addlv);
                        }

                        //gokui
                        string gokuiTmp = "gokui" + busyoId.ToString();
                        int    gokui    = RecoveryDataStore.gokuiList[count];
                        if (gokui != 0)
                        {
                            PlayerPrefs.SetInt(gokuiTmp, gokui);
                        }

                        //gokui
                        string kanniTmp = "kanni" + busyoId.ToString();
                        int    kanni    = RecoveryDataStore.kanniList[count];
                        if (kanni != 0)
                        {
                            PlayerPrefs.SetInt(kanniTmp, kanni);
                        }

                        count = count + 1;
                    }
                }

                PlayerPrefs.SetInt("myDaimyo", RecoveryDataStore.myDaimyo);
                Daimyo daimyoScript = new Daimyo();
                PlayerPrefs.SetInt("myDaimyoBusyo", daimyoScript.getDaimyoBusyoId(RecoveryDataStore.myDaimyo));
                PlayerPrefs.SetString("myBusyo", myBusyo);
                PlayerPrefs.SetString("myKanni", RecoveryDataStore.myKanni);
                PlayerPrefs.SetString("availableBugu", RecoveryDataStore.availableBugu);
                PlayerPrefs.SetString("availableKabuto", RecoveryDataStore.availableKabuto);
                PlayerPrefs.SetString("availableGusoku", RecoveryDataStore.availableGusoku);
                PlayerPrefs.SetString("availableMeiba", RecoveryDataStore.availableMeiba);
                PlayerPrefs.SetString("availableCyadougu", RecoveryDataStore.availableCyadougu);
                PlayerPrefs.SetString("availableHeihousyo", RecoveryDataStore.availableHeihousyo);
                PlayerPrefs.SetString("availableChishikisyo", RecoveryDataStore.availableChishikisyo);
                PlayerPrefs.SetString("kanjyo", RecoveryDataStore.kanjyo);
                PlayerPrefs.SetString("cyouheiYR", RecoveryDataStore.cyouheiYR);
                PlayerPrefs.SetString("cyouheiKB", RecoveryDataStore.cyouheiKB);
                PlayerPrefs.SetString("cyouheiTP", RecoveryDataStore.cyouheiTP);
                PlayerPrefs.SetString("cyouheiYM", RecoveryDataStore.cyouheiYM);
                PlayerPrefs.SetInt("hidensyoGe", RecoveryDataStore.hidensyoGe);
                PlayerPrefs.SetInt("hidensyoCyu", RecoveryDataStore.hidensyoCyu);
                PlayerPrefs.SetInt("hidensyoJyo", RecoveryDataStore.hidensyoJyo);
                PlayerPrefs.SetInt("shinobiGe", RecoveryDataStore.shinobiGe);
                PlayerPrefs.SetInt("shinobiCyu", RecoveryDataStore.shinobiCyu);
                PlayerPrefs.SetInt("shinobiJyo", RecoveryDataStore.shinobiJyo);
                PlayerPrefs.SetString("kengouItem", RecoveryDataStore.kengouItem);
                PlayerPrefs.SetString("gokuiItem", RecoveryDataStore.gokuiItem);
                PlayerPrefs.SetString("nanbanItem", RecoveryDataStore.nanbanItem);
                PlayerPrefs.SetInt("transferTP", RecoveryDataStore.transferTP);
                PlayerPrefs.SetInt("transferKB", RecoveryDataStore.transferKB);
                PlayerPrefs.SetInt("meisei", RecoveryDataStore.meisei);
                PlayerPrefs.SetString("shiro", RecoveryDataStore.shiro);
                PlayerPrefs.SetString("koueki", RecoveryDataStore.koueki);
                PlayerPrefs.SetString("cyoutei", RecoveryDataStore.cyoutei);
                PlayerPrefs.SetString("zukanBusyoHst", RecoveryDataStore.zukanBusyoHst);
                PlayerPrefs.SetString("zukanBuguHst", RecoveryDataStore.zukanBuguHst);
                PlayerPrefs.SetString("zukanGusokuHst", RecoveryDataStore.zukanGusokuHst);
                PlayerPrefs.SetString("zukanKabutoHst", RecoveryDataStore.zukanKabutoHst);
                PlayerPrefs.SetString("zukanMeibaHst", RecoveryDataStore.zukanMeibaHst);
                PlayerPrefs.SetString("zukanCyadouguHst", RecoveryDataStore.zukanCyadouguHst);
                PlayerPrefs.SetString("zukanChishikisyoHst", RecoveryDataStore.zukanChishikisyoHst);
                PlayerPrefs.SetString("zukanHeihousyoHst", RecoveryDataStore.zukanHeihousyoHst);
                PlayerPrefs.SetString("gameClearDaimyo", RecoveryDataStore.gameClearDaimyo);
                PlayerPrefs.SetString("gameClearDaimyoHard", RecoveryDataStore.gameClearDaimyoHard);

                //jinkei
                PlayerPrefs.SetInt("jinkei", RecoveryDataStore.jinkeiId);
                PlayerPrefs.SetInt("soudaisyo" + RecoveryDataStore.jinkeiId, RecoveryDataStore.soudaisyo);
                for (int i = 0; i < 25; i++)
                {
                    int busyoId = RecoveryDataStore.busyoMapList[i];
                    int id      = i + 1;
                    if (busyoId == 0)
                    {
                        string tmp = RecoveryDataStore.jinkeiId.ToString() + "map" + id.ToString();
                        PlayerPrefs.DeleteKey(tmp);
                    }
                    else
                    {
                        string tmp = RecoveryDataStore.jinkeiId.ToString() + "map" + id.ToString();
                        PlayerPrefs.SetInt(tmp, busyoId);
                    }
                }

                //naisei
                for (int i = 0; i < RecoveryDataStore.naiseiKuniList.Count; i++)
                {
                    int    kuniId    = RecoveryDataStore.naiseiKuniList[i];
                    string naiseiTmp = "naisei" + kuniId.ToString();
                    PlayerPrefs.SetString(naiseiTmp, RecoveryDataStore.naiseiList[i]);

                    if (RecoveryDataStore.naiseiShiroList[i] != 0)
                    {
                        string shiroTmp = "shiro" + kuniId.ToString();
                        PlayerPrefs.SetInt(shiroTmp, RecoveryDataStore.naiseiShiroList[i]);
                    }
                }

                //Add Qty & PvP Name
                PlayerPrefs.SetInt("myBusyoQty", RecoveryDataStore.busyoList.Count);
                string userName = RecoveryDataStore.userName;
                if (userName == "")
                {
                    userName = "******";
                }
                PlayerPrefs.SetString("PvPName", userName);
            }
            else
            {
                /***userId + pvpJinkei***/
                int totalExp = expScript.getTotalExp(RecoveryDataStore.kuniLv);
                PlayerPrefs.SetInt("kuniExp", totalExp);
                PlayerPrefs.SetInt("myDaimyo", RecoveryDataStore.myDaimyo);
                Daimyo daimyoScript = new Daimyo();
                PlayerPrefs.SetInt("myDaimyoBusyo", daimyoScript.getDaimyoBusyoId(RecoveryDataStore.myDaimyo));

                //pvp jinkei
                string        myBusyoString  = PlayerPrefs.GetString("myBusyo");
                List <string> myBusyoList    = new List <string>();
                char[]        delimiterChars = { ',' };
                if (myBusyoString != null && myBusyoString != "")
                {
                    if (myBusyoString.Contains(","))
                    {
                        myBusyoList = new List <string>(myBusyoString.Split(delimiterChars));
                    }
                    else
                    {
                        myBusyoList.Add(myBusyoString);
                    }
                }

                //zukan
                string        zukanBusyoHst     = PlayerPrefs.GetString("zukanBusyoHst");
                List <string> zukanBusyoHstList = new List <string>();
                if (zukanBusyoHst != null && zukanBusyoHst != "")
                {
                    if (zukanBusyoHst.Contains(","))
                    {
                        zukanBusyoHstList = new List <string>(zukanBusyoHst.Split(delimiterChars));
                    }
                    else
                    {
                        zukanBusyoHstList.Add(zukanBusyoHst);
                    }
                }

                //Daimyo Busyo History
                Daimyo        daimyo             = new Daimyo();
                string        gacyaDaimyoHst     = PlayerPrefs.GetString("gacyaDaimyoHst");
                List <string> gacyaDaimyoHstList = new List <string>();
                if (gacyaDaimyoHst != null && gacyaDaimyoHst != "")
                {
                    if (gacyaDaimyoHst.Contains(","))
                    {
                        gacyaDaimyoHstList = new List <string>(gacyaDaimyoHst.Split(delimiterChars));
                    }
                    else
                    {
                        gacyaDaimyoHstList.Add(gacyaDaimyoHst);
                    }
                }

                int count = 0;
                for (int i = 0; i < RecoveryDataStore.busyoList.Count; i++)
                {
                    int busyoId = RecoveryDataStore.busyoList[i];

                    if (busyoId != 0)
                    {
                        //add busyo
                        if (!myBusyoList.Contains(busyoId.ToString()))
                        {
                            if (myBusyoString == null || myBusyoString == "")
                            {
                                myBusyoString = busyoId.ToString();
                            }
                            else
                            {
                                myBusyoString = myBusyoString + "," + busyoId.ToString();
                            }
                            PlayerPrefs.SetString("myBusyo", myBusyoString);
                        }

                        //add zukan
                        if (!zukanBusyoHstList.Contains(busyoId.ToString()))
                        {
                            if (zukanBusyoHst == null || zukanBusyoHst == "")
                            {
                                zukanBusyoHst = busyoId.ToString();
                            }
                            else
                            {
                                zukanBusyoHst = zukanBusyoHst + "," + busyoId.ToString();
                            }
                            PlayerPrefs.SetString("zukanBusyoHst", zukanBusyoHst);
                        }

                        //add daimyo busyo
                        if (daimyo.daimyoBusyoCheck(busyoId))
                        {
                            if (!gacyaDaimyoHstList.Contains(busyoId.ToString()))
                            {
                                if (gacyaDaimyoHst == null || gacyaDaimyoHst == "")
                                {
                                    gacyaDaimyoHst = busyoId.ToString();
                                }
                                else
                                {
                                    gacyaDaimyoHst = gacyaDaimyoHst + "," + busyoId.ToString();
                                }
                                PlayerPrefs.SetString("gacyaDaimyoHst", gacyaDaimyoHst);
                            }
                        }

                        //add parametor
                        int    lv       = RecoveryDataStore.lvList[count];
                        string hei      = RecoveryDataStore.heiList[count];
                        int    senpouLv = RecoveryDataStore.senpouLvList[count];
                        int    sakuLv   = RecoveryDataStore.sakuLvList[count];
                        string kahou    = RecoveryDataStore.kahouList[count];

                        //lv
                        PlayerPrefs.SetInt(busyoId.ToString(), lv);

                        //hei
                        string heiTmp = "hei" + busyoId.ToString();
                        PlayerPrefs.SetString(heiTmp, hei);

                        //senpou
                        string senpou = "senpou" + busyoId.ToString();
                        PlayerPrefs.SetInt(senpou, senpouLv); //Lv

                        //saku
                        string saku = "saku" + busyoId.ToString();
                        PlayerPrefs.SetInt(saku, sakuLv); //Lv

                        //kahou
                        string kahouTmp = "kahou" + busyoId.ToString();
                        PlayerPrefs.SetString(kahouTmp, kahou);

                        //exp
                        string exp           = "exp" + busyoId.ToString();
                        int    totalBusyoExp = expScript.getExpforNextLv(lv - 1);
                        PlayerPrefs.SetInt(exp, totalBusyoExp);

                        count = count + 1;
                    }
                }
                PlayerPrefs.Flush();

                //Add Qty & PvP Name
                string        myBusyoStringCount = PlayerPrefs.GetString("myBusyo");
                List <string> myBusyoListCount   = new List <string>();
                if (myBusyoStringCount.Contains(","))
                {
                    myBusyoListCount = new List <string>(myBusyoStringCount.Split(delimiterChars));
                }
                else
                {
                    myBusyoListCount.Add(myBusyoStringCount);
                }
                PlayerPrefs.SetInt("myBusyoQty", myBusyoListCount.Count);
                string userName = RecoveryDataStore.userName;
                if (userName == "")
                {
                    userName = "******";
                }
                PlayerPrefs.SetString("PvPName", userName);
            }

            PlayerPrefs.Flush();

            //add data recovery history
            RecoveryDataStore.UpdateDataRecovery(RecoveryDataStore.inputUserId);


            //Final Process
            audioSources[3].Play();
            Destroy(back.gameObject);
            Destroy(msg.gameObject);
            GameObject.Find("Start").GetComponent <Button>().enabled = false;
            Message msgScript = new Message();
            msgScript.makeMessage(msgScript.getMessage(151));
        }
        else
        {
            RecoveryDataStore RecoveryDataStore = GameObject.Find("RecoveryDataStore").GetComponent <RecoveryDataStore>();
            RecoveryDataStore.ResetValue();

            audioSources[1].Play();
            Destroy(back.gameObject);
            Destroy(msg.gameObject);
        }
    }