Ejemplo 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();
					}
				}
			}
		}
	}
Ejemplo 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;

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

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

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

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

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

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

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

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

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

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

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

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

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

                                PlayerPrefs.SetString("cyouheiYR", newCyouheiString);

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

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

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

                                PlayerPrefs.SetString("cyouheiKB", newCyouheiString);

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

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

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

                                PlayerPrefs.SetString("cyouheiTP", newCyouheiString);

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

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

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

                                PlayerPrefs.SetString("cyouheiYM", newCyouheiString);
                            }

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

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

                            if(activeItemId == 1){
                                int tempQty = int.Parse(kanjyoList[0]);
                                tempQty = tempQty + activeItemQty;
                                newKanjyoString = tempQty.ToString() + "," + kanjyoList[1] +","+ kanjyoList[2];

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

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

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

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

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

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

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

                            //Register
                            addKahou(activeItemType, activeItemId);
                        }

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

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

                        //
                        PlayerPrefs.Flush();
                    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    PlayerPrefs.Flush();

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

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

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

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

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

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

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

                        PlayerPrefs.Flush();
                    }
                }
            }
        }
    }
Ejemplo 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);
    }
Ejemplo n.º 4
0
    public void dataMake(bool busyoExitFlg, int newDaimyo, int newDaimyoBusyo, string heisyu, bool sameDaimyoFlg)
    {
        /*******************************/
        /*****      Base Value     *****/
        /*******************************/
        System.DateTime now = System.DateTime.Now;
        PlayerPrefs.SetString("lasttime", now.ToString());
        //PlayerPrefs.SetInt ("hyourou",100);
        //PlayerPrefs.SetInt ("money",10000);
        PlayerPrefs.SetString("yearSeason", "1560,1");
        PlayerPrefs.DeleteKey("gameClearFlg");
        PlayerPrefs.DeleteKey("gameClearItemGetFlg");
        PlayerPrefs.DeleteKey("gameOverFlg");
        PlayerPrefs.DeleteKey("kuniClearedFlg");


        /*******************************/
        /*****   Delete History    *****/
        /*******************************/
        PlayerPrefs.DeleteKey("TrackTotalKassenNo");
        PlayerPrefs.DeleteKey("TrackWinNo");
        PlayerPrefs.DeleteKey("TrackTettaiNo");
        PlayerPrefs.DeleteKey("TrackBiggestDaimyoId");
        PlayerPrefs.DeleteKey("TrackBiggestDaimyoHei");
        PlayerPrefs.DeleteKey("TrackMyBiggestHei");
        PlayerPrefs.DeleteKey("TrackNewBusyoHireNo");
        PlayerPrefs.DeleteKey("TrackEarnMoney");
        PlayerPrefs.DeleteKey("TrackGetMoneyNo");
        PlayerPrefs.DeleteKey("TrackGetHyourouNo");
        PlayerPrefs.DeleteKey("TrackGetSozaiNo");
        PlayerPrefs.DeleteKey("TrackBuildMoneyNo");
        PlayerPrefs.DeleteKey("TrackJyosyuNinmeiNo");
        PlayerPrefs.DeleteKey("TrackTabibitoNo");
        PlayerPrefs.DeleteKey("TrackIjinNo");
        PlayerPrefs.DeleteKey("HstNanbansen");
        PlayerPrefs.DeleteKey("TrackGaikouNo");
        PlayerPrefs.DeleteKey("TrackGaikouMoneyNo");
        PlayerPrefs.DeleteKey("TrackDoumeiNo");
        PlayerPrefs.DeleteKey("TrackCyouteiNo");
        PlayerPrefs.DeleteKey("TrackSyouninNo");
        PlayerPrefs.DeleteKey("TrackToubatsuNo");
        PlayerPrefs.DeleteKey("TrackBouryakuNo");
        PlayerPrefs.DeleteKey("TrackBouryakuSuccessNo");
        PlayerPrefs.DeleteKey("TrackCyouhouNo");
        PlayerPrefs.DeleteKey("TrackRyugenNo");
        PlayerPrefs.DeleteKey("TrackGihouHei");
        PlayerPrefs.DeleteKey("TrackCyouryakuNo");
        PlayerPrefs.DeleteKey("TrackLinkCutNo");
        PlayerPrefs.DeleteKey("TrackSyuppeiNo");


        /*******************************/
        /*****   Delete Temp Value *****/
        /*******************************/
        PlayerPrefs.DeleteKey("playerEngunList");
        PlayerPrefs.DeleteKey("enemyEngunList");
        PlayerPrefs.DeleteKey("playerKyoutouList");
        PlayerPrefs.DeleteKey("tempKyoutouList");
        PlayerPrefs.DeleteKey("keyHistory");
        PlayerPrefs.DeleteKey("metsubou");

        HPCounter deleteGunzeiScript = new HPCounter();

        for (int i = 1; i < 66; i++)
        {
            string kuniTemp = "kuni" + i.ToString();
            PlayerPrefs.DeleteKey(kuniTemp);

            string jyosyuTemp = "jyosyu" + i.ToString();
            PlayerPrefs.DeleteKey(jyosyuTemp);

            string naiseiLoginDateTemp = "naiseiLoginDate" + i.ToString();
            PlayerPrefs.DeleteKey(naiseiLoginDateTemp);

            string naiseiTabibitoCounterTemp = "naiseiTabibitoCounter" + i.ToString();
            PlayerPrefs.DeleteKey(naiseiTabibitoCounterTemp);

            string cyouhouTemp = "cyouhou" + i.ToString();
            PlayerPrefs.DeleteKey(cyouhouTemp);

            string linkuctTmp = "linkcut" + i.ToString();
            PlayerPrefs.DeleteKey(linkuctTmp);

            //Delete Enemy Gunzei
            deleteGunzeiScript.deleteEnemyGunzeiData(i);
        }

        PlayerPrefs.DeleteKey("cyouhou");
        PlayerPrefs.DeleteKey("lastSeasonChangeTime");
        PlayerPrefs.DeleteKey("doneCyosyuFlg");
        PlayerPrefs.DeleteKey("twiceHeiFlg");
        PlayerPrefs.DeleteKey("rdmEventTimer");
        PlayerPrefs.DeleteKey("fromNaiseiFlg");
        PlayerPrefs.DeleteKey("fromKassenFlg");
        PlayerPrefs.DeleteKey("kassenWinLoseFlee");
        PlayerPrefs.DeleteKey("kessenFlg");
        PlayerPrefs.DeleteKey("kessenHyourou");
        PlayerPrefs.DeleteKey("winChecker");
        PlayerPrefs.DeleteKey("isAttackedFlg");
        PlayerPrefs.DeleteKey("isKessenFlg");


        /*******************************/
        /*****      Cyoutei & Bakuhu Value    *****/
        /*******************************/
        PlayerPrefs.DeleteKey("cyoutekiDaimyo");
        PlayerPrefs.DeleteKey("cyouteiPoint");
        PlayerPrefs.SetInt("syogunDaimyoId", 14);
        PlayerPrefs.DeleteKey("bakuhuTobatsuDaimyoId");
        PlayerPrefs.DeleteKey("soubujireiFlg");


        /*******************************/
        /*****      Busyo Value    *****/
        /*******************************/

        //Jyosyu Delete
        Entity_busyo_mst busyoMst = Resources.Load("Data/busyo_mst") as Entity_busyo_mst;

        for (int i = 0; i < busyoMst.param.Count; i++)
        {
            int    busyoId     = i + 1;
            string daimyoTemp  = "jyosyuHei" + busyoId;
            string daimyoTemp2 = "jyosyuBusyo" + busyoId;
            PlayerPrefs.DeleteKey(daimyoTemp);
            PlayerPrefs.DeleteKey(daimyoTemp2);
        }
        PlayerPrefs.Flush();

        char[] delimiterChars = { ',' };
        if (!sameDaimyoFlg)
        {
            //Old Daimyo
            //Delete Previous Daimyo Busyo in the case of it has never been gotten by Gacya
            int preDaimyoBusyoId = PlayerPrefs.GetInt("myDaimyoBusyo");

            string        gacyaDaimyoHst     = PlayerPrefs.GetString("gacyaDaimyoHst");
            List <string> gacyaDaimyoHstList = new List <string> ();

            if (gacyaDaimyoHst != null && gacyaDaimyoHst != "")
            {
                if (gacyaDaimyoHst.Contains(","))
                {
                    gacyaDaimyoHstList = new List <string> (gacyaDaimyoHst.Split(delimiterChars));
                }
                else
                {
                    gacyaDaimyoHstList.Add(gacyaDaimyoHst);
                }
            }
            if (!gacyaDaimyoHstList.Contains(preDaimyoBusyoId.ToString()))
            {
                //delete daimyo

                //delete my busyo
                string        myBusyo     = PlayerPrefs.GetString("myBusyo");
                List <string> myBusyoList = new List <string> ();
                if (myBusyo.Contains(","))
                {
                    myBusyoList = new List <string> (myBusyo.Split(delimiterChars));
                }
                else
                {
                    myBusyoList.Add(myBusyo);
                }


                myBusyoList.Remove(preDaimyoBusyoId.ToString());
                string myNewBusyo = "";

                for (int i = 0; i < myBusyoList.Count; i++)
                {
                    if (i == 0)
                    {
                        myNewBusyo = myBusyoList [i];
                    }
                    else
                    {
                        myNewBusyo = myNewBusyo + "," + myBusyoList [i];
                    }
                }

                PlayerPrefs.SetString("myBusyo", myNewBusyo);
                int myBusyoQty = PlayerPrefs.GetInt("myBusyoQty");
                myBusyoQty = myBusyoQty - 1;
                PlayerPrefs.SetInt("myBusyoQty", myBusyoQty);
                PlayerPrefs.Flush();

                //delete jinkei
                int  jinkeiMaxId     = 4;
                int  slotMaxId       = 25;
                bool soudaisyoSetFlg = false;
                for (int i = 1; i <= jinkeiMaxId; i++)
                {
                    for (int j = 1; j <= slotMaxId; j++)
                    {
                        string tmp = i.ToString() + "map" + j.ToString();
                        if (PlayerPrefs.HasKey(tmp))
                        {
                            int busyoId = PlayerPrefs.GetInt(tmp);
                            if (busyoId == preDaimyoBusyoId)
                            {
                                PlayerPrefs.DeleteKey(tmp);
                            }
                            else
                            {
                                if (!soudaisyoSetFlg)
                                {
                                    string sJinkeiId = "soudaisyo" + i.ToString();
                                    PlayerPrefs.SetInt(sJinkeiId, busyoId);
                                }
                            }
                        }
                    }
                }

                //kahou check
                string   tempBusyo      = "kahou" + preDaimyoBusyoId;
                string   busyoKahou     = PlayerPrefs.GetString(tempBusyo);
                string[] busyoKahouList = busyoKahou.Split(delimiterChars);
                for (int k = 0; k < busyoKahouList.Length; k++)
                {
                    int kahouId = int.Parse(busyoKahouList[k]);
                    if (kahouId != 0)
                    {
                        //back kahou data
                        string tmp = "";
                        if (k == 0)
                        {
                            tmp = "Bugu";
                        }
                        else if (k == 1)
                        {
                            tmp = "Kabuto";
                        }
                        else if (k == 2)
                        {
                            tmp = "Gusoku";
                        }
                        else if (k == 3)
                        {
                            tmp = "Meiba";
                        }
                        else if (k == 4)
                        {
                            tmp = "Cyadougu";
                        }
                        else if (k == 5)
                        {
                            tmp = "Cyadougu";
                        }
                        else if (k == 6)
                        {
                            tmp = "Heihousyo";
                        }
                        else if (k == 7)
                        {
                            tmp = "Chishikisyo";
                        }

                        string temp           = "available" + tmp;
                        string availableKahou = PlayerPrefs.GetString(temp);
                        if (availableKahou == null || availableKahou == "")
                        {
                            availableKahou = kahouId.ToString();
                        }
                        else
                        {
                            availableKahou = availableKahou + "," + kahouId.ToString();
                        }
                        PlayerPrefs.SetString(temp, availableKahou);
                        PlayerPrefs.SetString(tempBusyo, "0,0,0,0,0,0,0,0");
                    }
                }

                PlayerPrefs.Flush();
            }

            //New Daimyo
            if (!busyoExitFlg)
            {
                //Player dosen't have this daimyo busyo

                //busyo
                int myBusyoQty = PlayerPrefs.GetInt("myBusyoQty");
                myBusyoQty = myBusyoQty + 1;
                PlayerPrefs.SetInt("myBusyoQty", myBusyoQty);

                string myBusyo = PlayerPrefs.GetString("myBusyo");
                if (myBusyo != null && myBusyo != "")
                {
                    myBusyo = myBusyo + "," + newDaimyoBusyo.ToString();
                }
                else
                {
                    myBusyo = newDaimyoBusyo.ToString();
                }

                PlayerPrefs.SetString("myBusyo", myBusyo);

                if (!PlayerPrefs.HasKey(newDaimyoBusyo.ToString()))
                {
                    PlayerPrefs.SetInt(newDaimyoBusyo.ToString(), 1);
                    string tempHei    = "hei" + newDaimyoBusyo.ToString();
                    string tempSenpou = "senpou" + newDaimyoBusyo.ToString();
                    string tempSaku   = "saku" + newDaimyoBusyo.ToString();
                    string tempKahou  = "kahou" + newDaimyoBusyo.ToString();
                    string tempExp    = "exp" + newDaimyoBusyo.ToString();

                    string valueHei = heisyu + ":1:1:1";
                    PlayerPrefs.SetString(tempHei, valueHei);
                    PlayerPrefs.SetInt(tempSenpou, 1);
                    PlayerPrefs.SetInt(tempSaku, 1);
                    PlayerPrefs.SetString(tempKahou, "0,0,0,0,0,0,0,0");
                    PlayerPrefs.SetInt(tempExp, 0);
                }

                //jinkei
                //if there is no busyo in active jinkei
                int  jinkei = PlayerPrefs.GetInt("jinkei");
                bool jinkeiBusyoExistFlg = false;
                for (int i = 1; i <= 25; i++)
                {
                    string tmp = jinkei.ToString() + "map" + i.ToString();
                    if (PlayerPrefs.HasKey(tmp))
                    {
                        jinkeiBusyoExistFlg = true;
                    }
                }
                if (!jinkeiBusyoExistFlg)
                {
                    string tmpMap = "";
                    if (jinkei == 1)
                    {
                        tmpMap = jinkei.ToString() + "map11";
                    }
                    else if (jinkei == 2)
                    {
                        tmpMap = jinkei.ToString() + "map11";
                    }
                    else if (jinkei == 3)
                    {
                        tmpMap = jinkei.ToString() + "map14";
                    }
                    else if (jinkei == 4)
                    {
                        tmpMap = jinkei.ToString() + "map12";
                    }
                    PlayerPrefs.SetInt(tmpMap, newDaimyoBusyo);
                }
            }
        }

        //My Daimyo Busyo
        PlayerPrefs.SetInt("myDaimyo", newDaimyo);
        PlayerPrefs.SetInt("myDaimyoBusyo", newDaimyoBusyo);
        PlayerPrefs.DeleteKey("usedBusyo");


        /*******************************/
        /*****        Kuni Value     *****/
        /*******************************/
        string newSeiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46";

        PlayerPrefs.SetString("seiryoku", newSeiryoku);
        List <string> seiryokuList = new List <string> ();

        seiryokuList = new List <string> (newSeiryoku.Split(delimiterChars));
        string newClearedKuni = "";

        for (int i = 0; i < seiryokuList.Count; i++)
        {
            string tempDaimyoId = seiryokuList[i];
            if (tempDaimyoId == newDaimyo.ToString())
            {
                int kuniId = i + 1;
                if (newClearedKuni == null || newClearedKuni == "")
                {
                    newClearedKuni = kuniId.ToString();
                }
                else
                {
                    newClearedKuni = newClearedKuni + "," + kuniId.ToString();
                }
            }
        }
        PlayerPrefs.SetString("clearedKuni", newClearedKuni);

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

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


        //New Open Kuni
        KuniInfo kuni = new KuniInfo();

        PlayerPrefs.DeleteKey("openKuni");
        PlayerPrefs.Flush();
        foreach (string kuniId in clearedKuniList)
        {
            kuni.registerOpenKuni(int.Parse(kuniId));

            string temp = "kuni" + kuniId;
            PlayerPrefs.SetString(temp, "1,2,3,4,5,6,7,8,9,10");

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

        //Add Cleared Kuni to OpenKuni
        string tempOpenKuni = PlayerPrefs.GetString("openKuni");

        tempOpenKuni = tempOpenKuni + "," + newClearedKuni;
        PlayerPrefs.SetString("openKuni", tempOpenKuni);
        PlayerPrefs.Flush();


        /*******************************/
        /*****     Cyouryaku Value    *****/
        /*******************************/
        string cyouryaku = PlayerPrefs.GetString("cyouryaku");

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

        if (cyouryaku != null && cyouryaku != "")
        {
            if (cyouryaku.Contains(","))
            {
                cyouryakuList = new List <string> (cyouryaku.Split(delimiterChars));
            }
            else
            {
                cyouryakuList.Add(cyouryaku);
            }
        }
        for (int i = 0; i < cyouryakuList.Count; i++)
        {
            PlayerPrefs.DeleteKey(cyouryakuList[i]);
        }
        PlayerPrefs.DeleteKey("cyouryaku");


        /*******************************/
        /*****     Gaikou Value    *****/
        /*******************************/

        //My Gaikou
        Gaikou gaikou = new Gaikou();

        for (int l = 1; l < 47; l++)
        {
            int    value = gaikou.getGaikouValue(newDaimyo, l);
            string temp  = "gaikou" + l.ToString();
            PlayerPrefs.SetInt(temp, value);

            string metsubouTemp = "metsubou" + l.ToString();
            PlayerPrefs.DeleteKey(metsubouTemp);
        }

        //Other Daimyo Gaikou
        for (int x = 2; x < 47; x++)
        {
            for (int y = 2; y < 47; y++)
            {
                if (x != y)
                {
                    string temp  = x.ToString() + "gaikou" + y.ToString();
                    string temp2 = x.ToString() + "key" + y.ToString();
                    PlayerPrefs.DeleteKey(temp);
                    PlayerPrefs.DeleteKey(temp2);
                }
            }
        }
        /*******************************/
        /*****       Shisya        *****/
        /*******************************/
        PlayerPrefs.DeleteKey("shisyaFlg");
        PlayerPrefs.DeleteKey("shisya1");
        PlayerPrefs.DeleteKey("shisya2");
        PlayerPrefs.DeleteKey("shisya3");
        PlayerPrefs.DeleteKey("shisya4");
        PlayerPrefs.DeleteKey("shisya5");
        PlayerPrefs.DeleteKey("shisya6");
        PlayerPrefs.DeleteKey("shisya7");
        PlayerPrefs.DeleteKey("shisya8");
        PlayerPrefs.DeleteKey("shisya9");
        PlayerPrefs.DeleteKey("shisya10");
        PlayerPrefs.DeleteKey("shisya11");
        PlayerPrefs.DeleteKey("shisya12");
        PlayerPrefs.DeleteKey("shisya13");
        PlayerPrefs.DeleteKey("shisya14");
        PlayerPrefs.DeleteKey("shisya15");
        PlayerPrefs.DeleteKey("shisya16");
        PlayerPrefs.DeleteKey("shisya17");
        PlayerPrefs.DeleteKey("shisya18");
        PlayerPrefs.DeleteKey("shisya19");
        PlayerPrefs.DeleteKey("shisya20");
        PlayerPrefs.DeleteKey("shisya21");



        /*******************************/
        /*****       Doumei        *****/
        /*******************************/
        //Delete doumei history
        Entity_daimyo_mst daimyoMst = Resources.Load("Data/daimyo_mst") as Entity_daimyo_mst;

        for (int i = 0; i < daimyoMst.param.Count; i++)
        {
            int    daimyoId = daimyoMst.param[i].daimyoId;
            string temp     = "doumei" + daimyoId;
            PlayerPrefs.DeleteKey(temp);
        }
        PlayerPrefs.Flush();


        PlayerPrefs.DeleteKey("doumei");
        string            newMyDoumei = "";
        Entity_doumei_mst doumeiMst   = Resources.Load("Data/doumei_mst") as Entity_doumei_mst;

        for (int i = 0; i < doumeiMst.param.Count; i++)
        {
            int srcDaimyoId = doumeiMst.param[i].doumeiSrc;
            int dstDaimyoId = doumeiMst.param[i].doumeiDst;

            if (srcDaimyoId == newDaimyo)
            {
                if (newMyDoumei != null && newMyDoumei != "")
                {
                    newMyDoumei = newMyDoumei + "," + dstDaimyoId;
                }
                else
                {
                    newMyDoumei = dstDaimyoId.ToString();
                }
            }
            else
            {
                string temp     = "doumei" + srcDaimyoId;
                string previous = PlayerPrefs.GetString(temp);

                if (previous != null && previous != "")
                {
                    previous = previous + "," + dstDaimyoId;
                    PlayerPrefs.SetString(temp, previous);
                }
                else
                {
                    PlayerPrefs.SetString(temp, dstDaimyoId.ToString());
                }
            }
        }
        PlayerPrefs.SetString("doumei", newMyDoumei);
        PlayerPrefs.Flush();


        Application.LoadLevel("mainStage");
    }
Ejemplo n.º 5
0
	public void dataMake(bool busyoExitFlg, int newDaimyo, int newDaimyoBusyo, string heisyu){

		/*******************************/
		/*****      Base Value     *****/
		/*******************************/
		System.DateTime now = System.DateTime.Now;
		PlayerPrefs.SetString ("lasttime", now.ToString ());
		PlayerPrefs.SetInt ("hyourou",100);
		PlayerPrefs.SetString ("yearSeason","1560,1");
		PlayerPrefs.DeleteKey("gameClearFlg");
		PlayerPrefs.DeleteKey("gameClearItemGetFlg");
		PlayerPrefs.DeleteKey("gameOverFlg");
		PlayerPrefs.DeleteKey("kuniClearedFlg");


		/*******************************/
		/*****   Delete Temp Value *****/
		/*******************************/
		PlayerPrefs.DeleteKey("playerEngunList");
		PlayerPrefs.DeleteKey("enemyEngunList");
		PlayerPrefs.DeleteKey("playerKyoutouList");
		PlayerPrefs.DeleteKey("tempKyoutouList");
		PlayerPrefs.DeleteKey("keyHistory");
		PlayerPrefs.DeleteKey("metsubou");
		for(int i=1; i<65; i++){
			string kuniTemp = "kuni" + i.ToString();
			PlayerPrefs.DeleteKey(kuniTemp);

			string jyosyuTemp = "jyosyu" + i.ToString();
			PlayerPrefs.DeleteKey(jyosyuTemp);
			
			string naiseiLoginDateTemp = "naiseiLoginDate" + i.ToString();
			PlayerPrefs.DeleteKey(naiseiLoginDateTemp);
			
			string naiseiTabibitoCounterTemp = "naiseiTabibitoCounter" + i.ToString();
			PlayerPrefs.DeleteKey(naiseiTabibitoCounterTemp);
		}
		PlayerPrefs.DeleteKey("lastSeasonChangeTime");
		PlayerPrefs.DeleteKey("doneCyosyuFlg");



		/*******************************/
		/*****      Busyo Value    *****/
		/*******************************/
		if (!busyoExitFlg) {
			//Player dosn't have this daimyo busyo

			int myBusyoQty = PlayerPrefs.GetInt ("myBusyoQty");
			myBusyoQty = myBusyoQty + 1;
			PlayerPrefs.SetInt ("myBusyoQty",myBusyoQty);

			string myBusyo = PlayerPrefs.GetString ("myBusyo");
			myBusyo = myBusyo + "," + newDaimyoBusyo.ToString();
			PlayerPrefs.SetString ("myBusyo",myBusyo);

			PlayerPrefs.SetInt (newDaimyoBusyo.ToString(),1);
			string tempHei = "hei" + newDaimyoBusyo.ToString();
			string tempSenpou = "senpou" + newDaimyoBusyo.ToString();
			string tempSaku = "saku" + newDaimyoBusyo.ToString();
			string tempKahou = "kahou" + newDaimyoBusyo.ToString();
			string tempExp = "exp" + newDaimyoBusyo.ToString();

			string valueHei = heisyu + ":1:1:1";
			PlayerPrefs.SetString (tempHei,valueHei);
			PlayerPrefs.SetInt (tempSenpou,1);
			PlayerPrefs.SetInt (tempSaku,1);
			PlayerPrefs.SetString (tempKahou,"0,0,0,0,0,0,0,0");
			PlayerPrefs.SetInt (tempExp,0);
		}

		//My Daimyo Busyo
		PlayerPrefs.SetInt("myDaimyo",newDaimyo);
		PlayerPrefs.SetInt("myDaimyoBusyo",newDaimyoBusyo);



		/*******************************/
		/*****      Kuni Value     *****/
		/*******************************/
		string newSeiryoku = "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46";
		PlayerPrefs.SetString ("seiryoku",newSeiryoku);
		List<string> seiryokuList = new List<string> ();
		char[] delimiterChars = {','};
		seiryokuList = new List<string> (newSeiryoku.Split (delimiterChars));
		string newClearedKuni = "";

		for (int i=0; i<seiryokuList.Count; i++) {
			string tempDaimyoId = seiryokuList[i];
			if(tempDaimyoId == newDaimyo.ToString()){
				int kuniId = i + 1;
				if(newClearedKuni==null || newClearedKuni == ""){
					newClearedKuni = kuniId.ToString();
				}else{
					newClearedKuni = newClearedKuni + "," + kuniId.ToString();
				}
			}
		}
		PlayerPrefs.SetString ("clearedKuni",newClearedKuni);

		List<string> clearedKuniList = new List<string> ();
		clearedKuniList = new List<string> (newClearedKuni.Split (delimiterChars));



		//New Open Kuni
		KuniInfo kuni = new KuniInfo ();
		PlayerPrefs.DeleteKey("openKuni");
		PlayerPrefs.Flush ();
		foreach(string kuniId in clearedKuniList){
			kuni.registerOpenKuni (int.Parse(kuniId));

			string temp = "kuni" + kuniId;
			PlayerPrefs.SetString (temp,"1,2,3,4,5,6,7,8,9,10");

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

		//Add Cleared Kuni to OpenKuni
		string tempOpenKuni = PlayerPrefs.GetString ("openKuni");
		tempOpenKuni = tempOpenKuni + "," + newClearedKuni;
		PlayerPrefs.SetString ("openKuni",tempOpenKuni);
		PlayerPrefs.Flush ();



		/*******************************/
		/*****     Gaikou Value    *****/
		/*******************************/

		//My Gaikou
		Gaikou gaikou = new Gaikou ();
		for(int l=1; l<47; l++){
			int value = gaikou.getGaikouValue(newDaimyo,l);
			string temp = "gaikou" + l.ToString();
			PlayerPrefs.SetInt (temp, value);

			string metsubouTemp = "metsubou" + l.ToString();
			PlayerPrefs.DeleteKey (metsubouTemp);
		}

		//Other Daimyo Gaikou
		for(int x =2; x<47; x++ ){
			for(int y=2; y<47; y++){
				if(x != y){
					string temp = x.ToString() + "gaikou" + y.ToString();
					string temp2 = x.ToString() + "key" + y.ToString();
					PlayerPrefs.DeleteKey(temp);
					PlayerPrefs.DeleteKey(temp2);
				}
			}
		}




		/*******************************/
		/*****       Doumei        *****/
		/*******************************/
		PlayerPrefs.DeleteKey("doumei");
		string newMyDoumei = "";
		Entity_doumei_mst doumeiMst = Resources.Load ("Data/doumei_mst") as Entity_doumei_mst;
		for(int i=0; i < doumeiMst.param.Count; i++){
			int srcDaimyoId = doumeiMst.param[i].doumeiSrc;
			int dstDaimyoId = doumeiMst.param[i].doumeiDst;

			if(srcDaimyoId == newDaimyo){
				if(newMyDoumei != null && newMyDoumei !=""){
					newMyDoumei = newMyDoumei + "," + dstDaimyoId;
				}else{
					newMyDoumei = dstDaimyoId.ToString();
				}

			}else{
				string temp = "doumei" + srcDaimyoId;
				string previous = PlayerPrefs.GetString(temp);

				if(previous != null && previous !=""){
					previous = previous + "," + dstDaimyoId;
					PlayerPrefs.SetString (temp,previous);
				}else{
					PlayerPrefs.SetString (temp,dstDaimyoId.ToString());
				}
			}
		}
		PlayerPrefs.SetString ("doumei",newMyDoumei);
		PlayerPrefs.Flush ();


		Application.LoadLevel ("mainStage");
	}